home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 024 / psi110g.zip / ENETDUMP.C < prev    next >
C/C++ Source or Header  |  1994-04-17  |  1KB  |  56 lines

  1. /* Ethernet header tracing routines
  2.  * Copyright 1991 Phil Karn, KA9Q
  3.  */
  4. #include "global.h"
  5. #if defined PC_EC || defined PACKET
  6. #include "mbuf.h"
  7. #include "enet.h"
  8. #include "trace.h"
  9.   
  10. void
  11. ether_dump(fp,bpp,check)
  12. FILE *fp;
  13. struct mbuf **bpp;
  14. int check;  /* Not used */
  15. {
  16.     struct ether ehdr;
  17.     char s[20],d[20];
  18.   
  19.     ntohether(&ehdr,bpp);
  20.     pether(s,ehdr.source);
  21.     pether(d,ehdr.dest);
  22.     fprintf(fp,"Ether: len %u %s->%s",ETHERLEN + len_p(*bpp),s,d);
  23.   
  24.     switch(ehdr.type){
  25.         case IP_TYPE:
  26.             fprintf(fp," type IP\n");
  27.             ip_dump(fp,bpp,1);
  28.             break;
  29.         case REVARP_TYPE:
  30.             fprintf(fp," type REVARP\n");
  31.             arp_dump(fp,bpp);
  32.             break;
  33.         case ARP_TYPE:
  34.             fprintf(fp," type ARP\n");
  35.             arp_dump(fp,bpp);
  36.             break;
  37.         default:
  38.             fprintf(fp," type 0x%x\n",ehdr.type);
  39.             break;
  40.     }
  41. }
  42. int
  43. ether_forus(iface,bp)
  44. struct iface *iface;
  45. struct mbuf *bp;
  46. {
  47.     /* Just look at the multicast bit */
  48.   
  49.     if(bp->data[0] & 1)
  50.         return 0;
  51.     else
  52.         return 1;
  53. }
  54. #endif /* PC_EC || PACKET */
  55.   
  56.