Binary files rpld-1.2/.util.c.swp and rpld-1.2-lbr.new/.util.c.swp differ diff -r -c --new-file rpld-1.2/Makefile rpld-1.2-lbr.new/Makefile *** rpld-1.2/Makefile Wed Sep 15 16:29:10 1999 --- rpld-1.2-lbr.new/Makefile Fri Sep 15 01:20:24 2000 *************** *** 70,76 **** # issue a retransmit request causing a delay. # do make clean after changing this ! DEFINES=-DPACKET_DELAY=0 # where do you want all this stuff --- 70,76 ---- # issue a retransmit request causing a delay. # do make clean after changing this ! DEFINES=-DPACKET_DELAY=10000 # -DNOLOG # -DDEBUG # where do you want all this stuff *************** *** 190,202 **** ana:ana.c realtime: ana ! tcpdump -l -x -s 2048 ether[14]=0xfc and ether[15]=0xfc | ana capture: tcpdump -x -s 2048 ether[14]=0xfc and ether[15]=0xfc -w capture.dat replay: ana capture.dat ! tcpdump -x -r capture.dat | ana nics: nics.doesntexist --- 190,202 ---- ana:ana.c realtime: ana ! tcpdump -l -x -s 2048 ether[14]=0xfc and ether[15]=0xfc | ./ana capture: tcpdump -x -s 2048 ether[14]=0xfc and ether[15]=0xfc -w capture.dat replay: ana capture.dat ! tcpdump -x -r capture.dat | ./ana nics: nics.doesntexist *************** *** 206,211 **** --- 206,218 ---- ${PROG}:${OBJS} ${CC} ${CFLAGS} ${LDFLAGS} -o ${PROG} ${OBJS} ${LIBS} + + debugclean: + /bin/rm protocol.o + /bin/rm util.o + /bin/rm client.o + /bin/rm llc.o + /bin/rm linux-ps.o clean: nodep /bin/rm -rf ${OBJS} *% *~ *.o *.BAK core a.out ${PROG} diff -r -c --new-file rpld-1.2/ana.c rpld-1.2-lbr.new/ana.c *** rpld-1.2/ana.c Wed Sep 15 16:29:10 1999 --- rpld-1.2-lbr.new/ana.c Fri May 26 06:49:28 2000 *************** *** 19,24 **** --- 19,26 ---- * */ + #define MAX_HOSTNAME_LEN 255 + unsigned char pbuf[4096]; int plen; *************** *** 220,230 **** --- 222,235 ---- main () { int i, s; + int dataflag; char *pptr; *buf = '\t'; while (!feof (stdin)) { + char name[MAX_HOSTNAME_LEN]; + dataflag=0; get_packet (); pptr = pbuf; *************** *** 232,237 **** --- 237,295 ---- plen -= 2; printf (" Pack Type:"); + if (plen == 0x494e) { /* fscking "IP"-2+1 */ + if (pull_short(pptr) == 0x4c4f) + pptr += 2; + plen -= 2; + if (pull_short (pptr) == 0x4b01) { + printf (" IPLOK:"); + pptr += 2; + plen -= 2; + if ((pull_short (pptr) == 0) && (pull_short (pptr+2) == 0) && (pull_short (pptr+4) == 0)) { + pptr += 9; /* wtf? why not a prime? */ + plen -= 9; + printf ("\n YOU-ARE %i.%i.%i.%i", + pptr[0]&0xff, pptr[1]&0xff, pptr[2]&0xff, pptr[3]&0xff); + pptr += 4; + plen -= 4; + printf ("\n NETMASK %i.%i.%i.%i", + pptr[0]&0xff, pptr[1]&0xff, pptr[2]&0xff, pptr[3]&0xff); + pptr += 4; + plen -= 4; + printf ("\n NETWORK %i.%i.%i.%i", + pptr[0]&0xff, pptr[1]&0xff, pptr[2]&0xff, pptr[3]&0xff); + pptr += 4; + plen -= 4; + printf ("\n GW %i.%i.%i.%i", + pptr[0]&0xff, pptr[1]&0xff, pptr[2]&0xff, pptr[3]&0xff); + pptr += 4; + plen -= 4; + snprintf (name, MAX_HOSTNAME_LEN, "\n DNS %s\n ", &pptr[0]); + printf(name); + if (strlen(name) > MAX_HOSTNAME_LEN) { + pptr += MAX_HOSTNAME_LEN; + plen -= MAX_HOSTNAME_LEN; + } else { + pptr += strlen(name); + plen -= strlen(name); + } + } else { + printf (" I-AM %0.2x:%0.2x:%0.2x:%0.2x:%0.2x:%0.2x", + pptr[0]&0xff, pptr[1]&0xff, pptr[2]&0xff, pptr[3]&0xff, pptr[4]&0xff, pptr[5]&0xff); + pptr += 6; + plen -= 6; + }; + /* if ((i = pull_short(pptr)) > 0) { + printf (" - \n weird payload (presumably 0x%x words) found, skipping ",i); + plen = 2*i; + } + plen=0; + */ + dataflag=unix; + } else + printf (" IPLOK lookalike???: 0x%04x ?:", pull_short (pptr)); + } else + switch (pull_short (pptr)) { case 0x1: *************** *** 245,250 **** --- 303,309 ---- break; case 0x20: printf (" FILE.DATA.RESPONSE:"); + dataflag=unix; break; default: printf (" 0x%04x ?:", pull_short (pptr)); *************** *** 253,259 **** pptr += 2; plen -= 2; ! s = ana_frag (pptr, plen); printf ("\n\n"); --- 312,319 ---- pptr += 2; plen -= 2; ! if (!dataflag) ! s = ana_frag (pptr, plen); printf ("\n\n"); diff -r -c --new-file rpld-1.2/client.c rpld-1.2-lbr.new/client.c *** rpld-1.2/client.c Wed Sep 15 16:29:10 1999 --- rpld-1.2-lbr.new/client.c Thu Sep 14 23:56:52 2000 *************** *** 86,91 **** --- 86,99 ---- while (c) { + #ifdef DEBUG + printf("testing " ); + {int i; + for (i=0; imac[i] & 0xff ); + } + printf("\b \n" ); + #endif if (memcmp (mac, c->mac, ETH_ALEN) == 0) { if (pc) *************** *** 94,99 **** --- 102,115 ---- c->next = clients; clients = c; } + #ifdef DEBUG + printf("found " ); + {int i; + for (i=0; i #define ST_START 0 *************** *** 66,71 **** --- 66,75 ---- int blocknum; int blocklen; + int timeoutnum; + int timeoutpersec; + + time_t query[REMEMBER_QUERIES]; u32 run_addr; diff -r -c --new-file rpld-1.2/llc.c rpld-1.2-lbr.new/llc.c *** rpld-1.2/llc.c Wed Sep 15 16:29:10 1999 --- rpld-1.2-lbr.new/llc.c Thu Sep 14 22:50:17 2000 *************** *** 62,68 **** struct llchdr *h = (struct llchdr *) buf; int llclen; ! if ((h->h_dsap == RPL_SAP) && (h->h_ssap == RPL_SAP)) { #ifdef DEBUG --- 62,68 ---- struct llchdr *h = (struct llchdr *) buf; int llclen; ! if (((h->h_dsap == MY_RPL_SAP) || (h->h_dsap == RPL_SAP)) && ((h->h_ssap == RPL_SAP))) { #ifdef DEBUG diff -r -c --new-file rpld-1.2/llc.h rpld-1.2-lbr.new/llc.h *** rpld-1.2/llc.h Wed Sep 15 16:29:10 1999 --- rpld-1.2-lbr.new/llc.h Thu Sep 14 22:35:35 2000 *************** *** 32,37 **** --- 32,39 ---- */ #define RPL_SAP 0xfc + #define MY_RPL_SAP 0xf8 + #define LLC_HDR_LEN 17 #define LLC_SAP_LEN 3 diff -r -c --new-file rpld-1.2/project.h rpld-1.2-lbr.new/project.h *** rpld-1.2/project.h Wed Sep 15 16:29:10 1999 --- rpld-1.2-lbr.new/project.h Thu Sep 14 23:14:49 2000 *************** *** 48,54 **** #include #include #include ! #include #include #include #include --- 48,62 ---- #include #include #include ! #if !defined(NOLOG) ! # include ! #else ! # define syslog(chan,a...) ({printf(## a); printf("\n");}) ! # define openlog(a,...) ! # define LOG_PID ! # define LOG_DAEMON ! #endif ! #include #include #include *************** *** 69,74 **** --- 77,86 ---- #define CONFIG_FILE "/etc/rpld.conf" #define NOTINRANGE(l,v,h) (((v)<(l)) || ((v)>(h))) + + /* needed for the timeout feature */ + + #define REMEMBER_QUERIES 100 #include "linux-ps.h" diff -r -c --new-file rpld-1.2/protocol.c rpld-1.2-lbr.new/protocol.c *** rpld-1.2/protocol.c Wed Sep 15 16:29:10 1999 --- rpld-1.2-lbr.new/protocol.c Fri Sep 15 01:18:40 2000 *************** *** 42,52 **** --- 42,57 ---- { struct client *c; struct rpl_packet out; + int i; + time_t now; c = find_client_by_mac (in->mymac); if (!c) { + #ifdef DEBUG + printf("unknown client %s", ethtoa (in->mymac)); + #endif syslog (LOG_ERR, "unknown client %s", ethtoa (in->mymac)); return; } *************** *** 73,86 **** } c->framelen = out.framelen = (in->framelen > c->framelen) ? c->framelen : in->framelen; ! out.sap = RPL_SAP; bcopy (in->mymac, out.youmac, ETH_ALEN); bcopy (nit_mac (n), out.mymac, ETH_ALEN); c->state = ST_FIND; ! rpl_send_packet (n, c->mac, &out); c->state = ST_FOUND; --- 78,120 ---- } c->framelen = out.framelen = (in->framelen > c->framelen) ? c->framelen : in->framelen; ! out.sap = MY_RPL_SAP; bcopy (in->mymac, out.youmac, ETH_ALEN); bcopy (nit_mac (n), out.mymac, ETH_ALEN); c->state = ST_FIND; ! now=time(NULL); ! #ifdef DEBUG ! printf("request @%i",(int)now); ! #endif ! // shortcut, 0/0 would alwyays be accepted, too ! if (c->timeoutnum == 0) { ! #ifdef DEBUG ! printf(", no timeout - sending immediately",(int)now); ! #endif ! rpl_send_packet (n, c->mac, &out); ! } else if (c->timeoutnum >= REMEMBER_QUERIES) { ! // never answer (or point beyond end of query[]) ! } else { ! #ifdef DEBUG ! printf(", num = %i, query[%i] = %i",c->timeoutnum,c->timeoutnum,c->query[c->timeoutnum] ); ! #endif ! if (now <= (c->query[c->timeoutnum] + c->timeoutpersec)) { ! #ifdef DEBUG ! printf(", sending packet"); ! #endif ! rpl_send_packet (n, c->mac, &out); ! } ! for (i=REMEMBER_QUERIES-1;i>0; i--) { ! c->query[i]=c->query[i-1]; ! } ! } ! #ifdef DEBUG ! printf("\n"); ! #endif ! c->query[0]=now; c->state = ST_FOUND; diff -r -c --new-file rpld-1.2/rpl.c rpld-1.2-lbr.new/rpl.c *** rpld-1.2/rpl.c Wed Sep 15 16:29:10 1999 --- rpld-1.2-lbr.new/rpl.c Thu Sep 14 23:07:40 2000 *************** *** 388,393 **** --- 388,396 ---- if (elen != plen) { + #ifdef DEBUG + printf("received lengths disagree %d vs %d", elen, plen); + #endif syslog (LOG_ERR, "received lengths disagree %d vs %d", elen, plen); } diff -r -c --new-file rpld-1.2/rpl.h rpld-1.2-lbr.new/rpl.h *** rpld-1.2/rpl.h Wed Sep 15 16:29:10 1999 --- rpld-1.2-lbr.new/rpl.h Fri May 26 06:49:28 2000 *************** *** 44,49 **** --- 44,50 ---- #define LLC_RPL_OVERHEAD 0x30 #define RPL_SAP 0xfc + #define MY_RPL_SAP 0xf8 #define RPL_PK_FIND 0x0001 #define RPL_PK_FOUND 0x0002 diff -r -c --new-file rpld-1.2/rpld.c rpld-1.2-lbr.new/rpld.c *** rpld-1.2/rpld.c Wed Sep 15 16:29:10 1999 --- rpld-1.2-lbr.new/rpld.c Fri May 26 06:49:28 2000 *************** *** 55,61 **** daemonize (); ! n = nit_open (NULL); if (!n) { --- 55,65 ---- daemonize (); ! if (argc>=2) ! n = nit_open (argv[1]); ! else ! n = nit_open (NULL); ! if (!n) { diff -r -c --new-file rpld-1.2/rpld_conf.lex rpld-1.2-lbr.new/rpld_conf.lex *** rpld-1.2/rpld_conf.lex Wed Sep 15 16:29:10 1999 --- rpld-1.2-lbr.new/rpld_conf.lex Fri Sep 15 01:07:12 2000 *************** *** 107,112 **** --- 107,114 ---- {hb}:{hb}:{hb}:{hb}:{hb}:{hb} { strtomac(yytext, (yylval.mac_address)); return MACADDR; } + [0-9]+[/][0-9]+ { yylval.timeout=strcpy((char *)malloc(strlen(yytext)),yytext); return TIMEOUT; } + 0x[0-9A-Fa-f]+ { yylval.number = strtol(yytext + 2, NULL, 16); return NUMBER; diff -r -c --new-file rpld-1.2/rpld_conf.y rpld-1.2-lbr.new/rpld_conf.y *** rpld-1.2/rpld_conf.y Wed Sep 15 16:29:10 1999 --- rpld-1.2-lbr.new/rpld_conf.y Fri Sep 15 01:07:12 2000 *************** *** 70,82 **** %} ! %token BLOCK_START BLOCK_END NAME TEXT NUMBER MACADDR %union { long number; char *name; char *text; char mac_address[6]; } %start block_list --- 70,83 ---- %} ! %token BLOCK_START BLOCK_END NAME TEXT NUMBER MACADDR TIMEOUT %union { long number; char *name; char *text; char mac_address[6]; + char *timeout; } %start block_list *************** *** 102,107 **** --- 103,109 ---- | NAME '=' TEXT { process_thing(ASSIGNMENT, $1.name, TEXT, &$3); } | NAME '=' NUMBER { process_thing(ASSIGNMENT, $1.name, NUMBER, &$3); } | NAME '=' MACADDR { process_thing(ASSIGNMENT, $1.name, MACADDR, &$3); } + | NAME '=' TIMEOUT { process_thing(ASSIGNMENT, $1.name, TIMEOUT, &$3); } | block %% *************** *** 140,145 **** --- 142,148 ---- int have_mac; int have_run_addr; int have_files; + int have_timeout; // optional int have_framesize; int have_blocksize; *************** *** 234,239 **** --- 237,250 ---- if (!ci.have_mac) THROW_ERROR("Must specify an ethernet (MAC) address for host"); else if (!ci.have_run_addr) THROW_ERROR("Must specify an initial execute address for host"); else if (!ci.have_files) THROW_ERROR("Must specify at least one file to load for host"); + if (!ci.have_timeout) { + pc->timeoutnum=0; + pc->timeoutpersec=0; + } else { + int i; + for (i=0; iquery[i]=0; + } // OK, should have an entire host spec, so copy it in pc->next = clients; *************** *** 300,305 **** --- 311,328 ---- // set MAC address bcopy(pvalue->mac_address,pc->mac,ETH_ALEN); ci.have_mac = 1; + } + // timeout + else if (strsame(name, "timeout")) { + int *num,*persec; + if (type != TIMEOUT) THROW_ERROR("Directive must be followed by a retries/seconds pair"); + // set timeout + if ((sscanf(pvalue->timeout,"%li/%li",&num,&persec)) + != 2) + THROW_ERROR("Directive must be followed by a retries/seconds pair"); + pc->timeoutnum = (int)num; + pc->timeoutpersec = (int)persec; + ci.have_timeout = 1; } // execute address else if (strsame(name, "execute") || strsame(name, "run")) { diff -r -c --new-file rpld-1.2/util.c rpld-1.2-lbr.new/util.c *** rpld-1.2/util.c Wed Sep 15 16:29:10 1999 --- rpld-1.2-lbr.new/util.c Fri May 26 06:49:28 2000 *************** *** 56,61 **** --- 56,62 ---- { int fd; + #ifndef DEBUG /* grrrrrrrrr! aoe */ switch (fork ()) { case 0: *************** *** 67,78 **** default: exit (0); } setpgrp (); ! fd = open ("/dev/null", O_RDWR); dup2 (fd, 0); dup2 (fd, 1); dup2 (fd, 2); close (fd); } --- 68,81 ---- default: exit (0); } + #endif setpgrp (); ! #ifndef DEBUG /* grrrrrrrrr! aoe */ fd = open ("/dev/null", O_RDWR); dup2 (fd, 0); dup2 (fd, 1); dup2 (fd, 2); close (fd); + #endif }