/************************************************************************/
/* */
/* ***** ***** */
/* ***** ***** */
/* ***** ***** */
/* ***** ***** */
/* *************** *************** */
/* ***************** ***************** */
/* *************** *************** */
/* ***** ***** TheNetNode */
/* ***** ***** Portable */
/* ***** ***** Network */
/* ***** ***** Software */
/* */
/* File os/linux/axipx.c (maintained by: DG1KWA) */
/* */
/* This file is part of "TheNetNode" - Software Package */
/* */
/* Copyright (C) 1998 - 2008 NORD>kisslink = socket(AF_IPX, SOCK_DGRAM, PF_IPX);
l2flp = (LHEAD *) &txl2fl[l2port];
if (l1pp->kisslink < 0)
{
#ifdef SPEECH
printf(speech_message(331), strerror(errno));
#else
printf("cannot create socket for IPX : %s\n", strerror(errno));
#endif
return(FALSE);
}
memset(&myaddr, 0, sizeof(myaddr));
myaddr.sipx_family = AF_IPX;
myaddr.sipx_network = 0x00L;
myaddr.sipx_port = htons(0xCE73);
if (bind(l1pp->kisslink, (struct sockaddr *) &myaddr, sizeof(myaddr)))
{
#ifdef SPEECH
printf(speech_message(332), strerror(errno));
#else
printf("cannot bind IPX address: %s\n", strerror(errno));
#endif
close(l1pp->kisslink);
l1pp->kisslink = -1;
return(FALSE);
}
addrlen = sizeof(myaddr);
if (getsockname(l1pp->kisslink, (struct sockaddr *) &myaddr, &addrlen) < 0)
{
perror("getsockname(ipx)");
}
if (fcntl(l1pp->kisslink, F_SETFL, FNDELAY) < 0)
{
#ifdef SPEECH
printf(speech_message(333));
#else
printf("Error: can't set non-blocking I/O on IPX socket");
#endif
close(l1pp->kisslink);
l1pp->kisslink = -1;
return(FALSE);
}
axipx_active = TRUE;
return(TRUE);
}
void axipx_l1exit(void)
{
if (axipx_active == FALSE)
return;
close(l1pp->kisslink);
axipx_active = FALSE;
l1pp->kisslink = -1;
}
void axipx_l1ctl(int req, int port)
{
/* nur eigene Ports bearbeiten */
if (kissmode(port) != KISS_IPX)
return;
switch(req)
{
/* Testpattern auf dem Port senden (wird unterdrueckt) */
case L1CTST : testflag[port] = FALSE;
kick[port] = FALSE;
break;
default : break;
}
}
void axipx_hwstr(int port, MBHEAD *mbp)
{
}
BOOLEAN axipx_dcd(int port)
{
return (FALSE);
}
/* IPX-Sende-Routine */
void axipx_send(void)
{
char buf[MAX_FRAME];
WORD len = 0;
MBHEAD *txfhdl;
if (kick[axipx_port])
{ /* haben wir was zu senden ? */
/* Sicherheitsabfrage, da kisck[] auch manipuliert werden kann */
if (l2flp->head == l2flp)
{
kick[axipx_port] = FALSE;
return;
}
ulink((LEHEAD *)(txfhdl = (MBHEAD *) l2flp->head));/*Zeiger holen*/
while ( (txfhdl->mbgc < txfhdl->mbpc) /* solange Daten vorhanden sind */
&& (len < MAX_FRAME))
buf[len++] = getchr(txfhdl);
relink((LEHEAD *)txfhdl, /* als gesendet betrachten und in */
(LEHEAD *)stfl.tail); /* die gesendet Liste umhaengen */
kick[axipx_port] = ((LHEAD *)l2flp->head != l2flp);
if (sendto(l1pp->kisslink, (char *)buf, len, 0,
(struct sockaddr *)&bcaddr, sizeof(bcaddr)) < 0)
{
perror("sendto(l1pp->kisslink) in axipx_send()");
}
}
}
/* IPX Empfangs-Routine */
void axipx_recv(void)
{
struct sockaddr_ipx addr;
socklen_t addrlen = sizeof(addr);
int l = 0;
int i = 0;
UBYTE buf[MAX_FRAME];
UBYTE *bufptr;
MBHEAD *rxfhd;
if (!axipx_active)
return;
l = recvfrom(l1pp->kisslink, (char *) (bufptr = buf), sizeof(buf), 0,
(struct sockaddr *) &addr, &addrlen);
if (l > 0)
{
/* unseren eigenen Frames wollen wir nicht empfangen */
if (!memcmp(addr.sipx_node, myaddr.sipx_node, IPX_NODE_LEN))
return;
(rxfhd = (MBHEAD *)allocb(ALLOC_MBHEAD))->l2port = axipx_port;
for (i = 0; i < l; i++)
putchr(buf[i], rxfhd); /* Buffer umkopieren */
relink((LEHEAD *)rxfhd, (LEHEAD *)rxfl.tail);
}
}
#endif
/* End of os/linux/axipx.c */