home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / protocol / tcpip / ibmpc / 6322 < prev    next >
Encoding:
Text File  |  1992-11-15  |  3.3 KB  |  72 lines

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!ira.uka.de!ira.uka.de!math.fu-berlin.de!unidus.rz.uni-duesseldorf.de!mueller.rz.uni-duesseldorf.de!dvs
  2. From: dvs@ze8.rz.uni-duesseldorf.de (Wolfgang R. Mueller)
  3. Newsgroups: comp.protocols.tcp-ip.ibmpc
  4. Subject: Re: TCP/IP Packet analyser
  5. Date: Mon, 16 Nov 1992 08:38:18 GMT
  6. Organization: Computing Centre, Heinrich-Heine-University, Duesseldorf, Germany
  7. Lines: 60
  8. Message-ID: <dvs.21.721903098@ze8.rz.uni-duesseldorf.de>
  9. References: <1992Nov11.152717.1@ccla.demon.co.uk>
  10. NNTP-Posting-Host: mueller.rz.uni-duesseldorf.de
  11.  
  12. In article <1992Nov11.152717.1@ccla.demon.co.uk> dblack@ccla.demon.co.uk (David Black) writes:
  13. > Is there a Public domain IP packet analyser that I can run on a
  14. > PC through the packet driver i/f. I need it for debugging purposes.
  15. Perhaps this may help:
  16. --------------------------------------------------------------------
  17. #include <stdio.h>
  18. #include <conio.h>
  19. #include <alloc.h>
  20. #include <dos.h>
  21. #include <bios.h>
  22.  
  23. #define PKI 0x70   /* constant packet int no makes program simpler */
  24. static unsigned int bufseg,bufoff=0,
  25. bufrdr=0,lact=1;static void interrupt prx(unsigned bp,unsigned di,unsigned 
  26. si, unsigned ds,unsigned es,unsigned dx,unsigned cx,unsigned bx,unsigned 
  27. ax) {  if(!ax) {
  28.     if((bufoff+64)!=bufrdr) {
  29.       poke(bufseg,bufoff,peek(0x40,0x6c)); poke(bufseg,bufoff+2,cx);
  30.       es = bufseg;  di = bufoff+4;  cx = ax; bufoff+=64;
  31.       return;
  32.     } else { es = di = 0;
  33.   } } return;
  34. }
  35. static struct { unsigned char pushf; unsigned char callf;
  36.   void interrupt (*farpt)(); unsigned char retf; } pkrec={0x9c,0x9a,prx,0xcb};
  37.  
  38. static unsigned char eta[]={0x01,0x02,0x03,0x04,0x05,0x06};
  39. static unsigned char *bw=0xb0000000, atr=0x07; static int xy=0;
  40. static char hextab[]="0123456789ABCDEF";
  41. static void tinit() { clrscr();
  42.   if(*((unsigned char *)(0x00400049))!=7) bw=(unsigned char *)0xb8000000; }
  43. static void hexout(xy,c) int xy; unsigned char c; { unsigned char *bp;
  44.   bp=bw+xy+xy; *(bp++)=hextab[c>>4]; *(bp++)=atr;
  45.   *(bp++)=hextab[c&15]; *bp=atr; }
  46. void evaltrace() {  int i,j; unsigned char *p; unsigned int bo=bufoff;
  47.   j=1920; atr=0x07; hexout(j,bo>>8); hexout(j+2,bo&255);
  48.   hexout(j+5,bufrdr>>8); hexout(j+7,bufrdr&255);
  49.   if(bo==bufrdr) return;
  50.   gotoxy(1,1+xy); j=xy*80; atr=7;
  51.   p=(unsigned char *)MK_FP(bufseg,bufrdr);
  52. /*  if(memcmp(p+4,&(eta[0]),6) && memcmp(p+10,&(eta[0]),6)) { bufrdr+=64; return; }*/
  53.   hexout(j,*(p+1)); hexout(j+2,*p);
  54.   hexout(j+5,*(p+3)); hexout(j+7,*(p+2)); j+=10; p+=4;
  55.   for(i=0;i<14;i++,p++) { hexout(j,*p); j+=2; if((i%6)==5) j++; }  p+=12;
  56.   for(i=0;i<12;i++,p++) { if((i%4)==0) j++; if(i==10) j++; hexout(j,*p); j+=2;}
  57.   if((++xy)==24) xy=0;
  58.   bufrdr+=64; return;
  59. }
  60. void main() { int hdl;  bufseg=1+FP_SEG(farmalloc(0x10010)); tinit();
  61.   _BX=0; hdl=_DS; _AX=0x01ff; geninterrupt(PKI); _DS=hdl; /*driver_info*/
  62.   _ES=FP_SEG(&pkrec); _DI=FP_OFF(&pkrec); _AL=_CH; _AH=0x02;
  63.   _BX=0xffff; _CX=0; _DX=0; geninterrupt(PKI); hdl=_AX;   /*access_type*/
  64.   _BX=hdl; _AX=0x1400; _CX=6; geninterrupt(PKI);          /*set_rcv_mode*/
  65.   while(!bioskey(1)) evaltrace();
  66.   _BX=hdl; _AX=0x0300; geninterrupt(PKI);                 /*release_type*/
  67. }
  68. ----------------------------------------------------------------------
  69. Have fun,
  70. Wolfgang R. Mueller <dvs@ze8.rz.uni-duesseldorf.de>,
  71. Computing Centre, Heinrich-Heine-University, Duesseldorf, Germany.
  72.