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

  1. /* Ethernet header conversion 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.   
  9. /* Convert Ethernet header in host form to network mbuf */
  10. struct mbuf *
  11. htonether(ether,bp)
  12. struct ether *ether;
  13. struct mbuf *bp;
  14. {
  15.     register char *cp;
  16.   
  17.     if((bp = pushdown(bp,ETHERLEN)) == NULLBUF)
  18.         return NULLBUF;
  19.   
  20.     cp = bp->data;
  21.   
  22.     memcpy(cp,ether->dest,EADDR_LEN);
  23.     cp += EADDR_LEN;
  24.     memcpy(cp,ether->source,EADDR_LEN);
  25.     cp += EADDR_LEN;
  26.     put16(cp,ether->type);
  27.   
  28.     return bp;
  29. }
  30. /* Extract Ethernet header */
  31. int
  32. ntohether(ether,bpp)
  33. struct ether *ether;
  34. struct mbuf **bpp;
  35. {
  36.     pullup(bpp,ether->dest,EADDR_LEN);
  37.     pullup(bpp,ether->source,EADDR_LEN);
  38.     ether->type = pull16(bpp);
  39.     return ETHERLEN;
  40. }
  41. #endif /* PC_EC || PACKET */
  42.   
  43.