/* * Tunnel IP datagrams thru NET/ROM nonsense. Requires (right now) use * of AX.25 module. No reason that we can't also speak their async serial * line protocol, expect that you'd have to have your own NET/ROM node. * * Louis A. Mamakos WA3YMH */ #ifdef NETROM #include #include "machdep.h" #include "mbuf.h" #include "iface.h" #include "ax25.h" #include "netrom.h" #ifdef TRACE #include "trace.h" #endif static int nnr; void netrom_input(interface, bp) struct interface *interface; struct mbuf *bp; { netrom_dump(bp); /** DEBUG **/ free_p(bp); } #ifdef TRACE netrom_dump(bp) struct mbuf *bp; { struct ax25_addr addr; char qual, ident[20]; if (bp == NULLBUF) return; /* make a copy of the frame */ if ((bp = copy_p(bp, len_mbuf(bp))) == NULL) return; printf("NET/ROM: "); /* first: examine the first byte in the NET/ROM packet. If it is * equal to NETROM_SIG, then this frame is a routing update. * Otherwise, it is an inter-node frame. */ if ((unsigned char) *bp->data == NETROM_SIG) { /* routing update */ if (pullup(&bp, NULLCHAR, 1) != 1) /* trash signature */ return; /* get ident of sending node */ ident[6] = '\0'; if (pullup(&bp, ident, 6) != 6) return; printf("RT from %s:\r\n", ident); /* now, loop through and display each of the routing entries */ for(;;) { if (pullup(&bp, (char *)&addr, AXALEN) != AXALEN) { break; } pax25(ident, &addr); printf(" [%s/", ident); if (pullup(&bp, ident, 6) != 6) { printf("\r\nMissing ident!\r\n"); break; } ident[6] = '\0'; printf("%s via ", ident); if (pullup(&bp, (char *)&addr, AXALEN) != AXALEN) { printf("Missing neighbor node\r\n"); break; } pax25(ident, &addr); if (pullup(&bp, &qual, 1) != 1) { printf("missing qual\r\n"); break; } printf("%s qual %u]", ident, qual & 0xff); } printf("\r\n"); } else { /* inter node frame */ printf("inter-node frame\r\n"); } free_p(bp); } #endif TRACE /* * Attach a NET/ROM virual interface to the system. This interface needs the * presence of a companion AX.25 interface to actually communicate. * * argv[0]: hardware type: "netrom" * argv[1]: name of companion ax.25 interface (like ax0) * argv[2]: must be "ax25" to indicate using AX.25 as link level protocol * argv[3]: label, name of interface like "nr0" * argv[4]: optional: MTU * argv[5]: optional: update frequency in seconds */ netrom_attach(argc, argv) int argc; char *argv[]; { #ifdef foobarbaz int dev; register struct interface *if_nr; if (nnr >= NR_MAX) { printf("Too many NET/ROM devices\r\n"); return -1; } dev = nnr++; if_nr = calloc(1, sizeof(struct interface)); #endif NETROM } #endif