/* History:126,1 */ /* public domain by Russell Nelson, nelson@crynwr.com. Politeness dictates * that you leave this notice intact */ #include #include #include "pktdrvr.h" #define MAXSTORE 20 typedef char buffer[1514]; buffer store [MAXSTORE]; int current_store=0; /* single buffer */ int packet_len [MAXSTORE]; /* the length of data in buffer */ int intno; /* our handle */ int oldmode; char myeaddr[6]; /* our Ethernet address */ int interrupt receiver(bp, di, si, ds, es, dx, cx, bx, ax, ip, cs, flags) { if (packet_len || cx > sizeof(&store[current_store])) { es = di = 0; /* discard this packet */ } else if (ax == 0) { es = FP_SEG(&store[current_store]); /* tell them to stick it in our buffer */ di = FP_OFF(&store[current_store]); } else { packet_len[current_store] = cx; /* second upcall -- remember size. */ if (++current_store>(MAXSTORE-1)) current_store=0; } } int main() { int handle; char idle_chars[] = "-/|\\"; int idle_index = 0; int junk=0; puts("TNTAP - TELNET Tapper V0.1 (C)Veghead 1994"); /* search for the first packet driver in memory */ for (intno = 0x60; intno <= 0x80; intno++) { if (test_for_pd(intno)) break; } /* if there is none, crap out */ if (!test_for_pd(intno)) { fprintf(stderr, "No packet driver found"); exit(1); } /* get a handle so that we can receive packets */ printf("Packet driver found at 0x%02X\n",intno); handle = access_type(intno, CL_ETHERNET, /* has to be an Ethernet driver */ 0xffff, /* we don't care whose it is. */ 0, /* we want the first piece of hardware */ NULL, /* doesn't matter because we want all */ 0, /* zero type length, that is, all. */ receiver); /* -> our upcall */ /* get the adaptor's Ethernet address */ get_address (intno,handle,myeaddr,sizeof myeaddr); /* put the interface into promiscuous mode */ oldmode = set_mode(intno,handle,6); while (!kbhit()) { if (current_store!=junk) {printf("Packet! Buffer:%d",current_store); junk++; if (junk>MAXSTORE-1) junk=0;} } getch(); set_mode(intno,handle,oldmode); release_type(intno, handle); return 0; }