home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR3 / KA9Q212.ZIP / ENETDUMP.C < prev    next >
C/C++ Source or Header  |  1993-07-16  |  1KB  |  61 lines

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