Thomas M. wrote:
>
> Hi
>
> I was just trying to get flexnet running (on a dos box), using the
> bpqether interface. But somehow it doesn't work. In the ax25 howto, it
> says that the BPQ code use a multicast address, and linux a normal
> (singlecast??) address. Is it the same thing with flexnet??
> I was planing on running it with the ipx module, as i'm using ipx on
> my local lan to access my mars_nwe server... But have also tried the
> ether module. But no luck with either of them...
Flexnet uses Broadcasts for BPQ-Ethernet, but don't ask me how to
configure a linux box to talk to a flexnet box via that interface. Try
IPX, it really simple. I've attached a small daemon I call "ipxnetd", it
does pretty much the same as ax25ipd from the ax25-utils for axip.
Though, it's very limited, yet easy to set up: No config files, just
call the daemon. It assumes a pty as it's first argument, and you need
to kissattach this pty before.
Ah, yes. I've attached the source code.
Gruss,
Matthias
--------------4E2E6C8A420A27D878A62C12
Content-Type: text/plain; charset=us-ascii; name="ipxnetd.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="ipxnetd.c"
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <termios.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <linux/ipx.h>
#include <netinet/in.h>
#define FEND 0300
#define FESC 0333
#define TFEND 0334
#define TFESC 0335
static struct sockaddr_ipx bcaddr = {
AF_IPX, 0x73CE, 0x00L,
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
25
};
static struct sockaddr_ipx myaddr;
static int
kiss_esc(char* d, unsigned char* s, int len)
{
char* ptr = d;
unsigned char c;
*ptr++ = FEND;
*ptr++ = 0;
while (len-- > 0) {
switch (c = *s++) {
case FEND:
*ptr++ = FESC;
*ptr++ = TFEND;
break;
case FESC:
*ptr++ = FESC;
*ptr++ = TFESC;
break;
default:
*ptr++ = c;
break;
}
}
*ptr++ = FEND;
return ptr - d;
}
static void
kiss_unesc(int fd, unsigned char* s, int len)
{
static int esc_seen = 0;
static unsigned char sbuf[800];
static int count = 0;
unsigned char c;
while (len-- > 0) {
switch(c = *s++) {
case FEND:
if (count != 0) {
sendto(fd, sbuf+1, count-1, 0, &bcaddr, sizeof(bcaddr));
count = 0;
esc_seen = 0;
}
continue;
case FESC:
esc_seen = 1;
continue;
case TFESC:
if (esc_seen) {
c = FESC;
esc_seen = 0;
}
break;
case TFEND:
if (esc_seen) {
c = FEND;
esc_seen = 0;
}
break;
}
sbuf[count++] = c;
}
}
int
main(int argc, char** argv)
{
struct termios old_termios;
struct termios new_termios;
int maxfd;
int ipxfd;
int ptyfd;
int addrlen;
fd_set rmask;
struct timeval timeout;
if (argc < 2) {
puts("Usage: ipxnetd <pty>");
exit(1);
}
ipxfd = socket(AF_IPX, SOCK_DGRAM, PF_IPX);
if (ipxfd < 0) {
perror("socket");
exit(1);
}
ptyfd = open(argv[1], O_RDWR|O_NONBLOCK);
if (ptyfd < 0) {
perror("open");
exit(1);
}
maxfd = ptyfd > ipxfd ? ptyfd : ipxfd;
memset(&myaddr, 0, sizeof(myaddr));
myaddr.sipx_family = AF_IPX;
myaddr.sipx_network = 0x00L;
myaddr.sipx_port = htons(0xCE73);
if (bind(ipxfd, (struct sockaddr *)&myaddr, sizeof(myaddr))) {
perror("bind");
exit(1);
}
addrlen = sizeof(myaddr);
if (getsockname(ipxfd, (struct sockaddr *)&myaddr, &addrlen) < 0) {
perror("getsockname");
exit(1);
}
tcgetattr(ptyfd, &old_termios);
new_termios = old_termios;
cfmakeraw(&new_termios);
cfsetospeed(&new_termios, B9600);
cfsetispeed(&new_termios, B9600);
tcsetattr(ptyfd, TCSANOW, &new_termios);
while (1) {
char rbuf[400];
char sbuf[800];
int len;
struct sockaddr_ipx addr;
timeout.tv_sec = 1;
timeout.tv_usec = 0;
FD_ZERO(&rmask);
FD_SET(ipxfd, &rmask);
FD_SET(ptyfd, &rmask);
if (select(maxfd+1, &rmask, NULL, NULL, &timeout)) {
if (FD_ISSET(ipxfd, &rmask)) {
len = recvfrom(ipxfd, rbuf, sizeof(rbuf), 0, (struct sockaddr *)&addr, &addrlen);
if (len <= 0)
break;
if (!memcmp(addr.sipx_node, myaddr.sipx_node, IPX_NODE_LEN))
continue;
len = kiss_esc(sbuf, rbuf, len);
write(ptyfd, sbuf, len);
}
if (FD_ISSET(ptyfd, &rmask)) {
len = read(ptyfd, rbuf, sizeof(rbuf));
if (len <= 0)
break;
kiss_unesc(ipxfd, rbuf, len);
}
}
}
close(ipxfd);
tcsetattr(ptyfd, TCSANOW, &old_termios);
}
--------------4E2E6C8A420A27D878A62C12--