"Fossies" - the Fresh Open Source Software Archive

Member "tcpflow-1.6.1/src/wifipcap/arp.h" (19 Feb 2021, 3540 Bytes) of package /linux/misc/tcpflow-1.6.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "arp.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
    3  *  The Regents of the University of California.  All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that: (1) source code distributions
    7  * retain the above copyright notice and this paragraph in its entirety, (2)
    8  * distributions including binary code include the above copyright notice and
    9  * this paragraph in its entirety in the documentation or other materials
   10  * provided with the distribution, and (3) all advertising materials mentioning
   11  * features or use of this software display the following acknowledgement:
   12  * ``This product includes software developed by the University of California,
   13  * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
   14  * the University nor the names of its contributors may be used to endorse
   15  * or promote products derived from this software without specific prior
   16  * written permission.
   17  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
   18  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
   19  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
   20  */
   21 
   22 /*
   23  * Address Resolution Protocol.
   24  *
   25  * See RFC 826 for protocol description.  ARP packets are variable
   26  * in size; the arphdr structure defines the fixed-length portion.
   27  * Protocol type values are the same as those for 10 Mb/s Ethernet.
   28  * It is followed by the variable-sized fields ar_sha, arp_spa,
   29  * arp_tha and arp_tpa in that order, according to the lengths
   30  * specified.  Field names used correspond to RFC 826.
   31  */
   32 struct  arp_pkthdr {
   33     u_short ar_hrd;     /* format of hardware address */
   34 #define ARPHRD_ETHER    1   /* ethernet hardware format */
   35 #define ARPHRD_IEEE802  6   /* token-ring hardware format */
   36 #define ARPHRD_ARCNET   7   /* arcnet hardware format */
   37 #define ARPHRD_FRELAY   15  /* frame relay hardware format */
   38 #define ARPHRD_STRIP    23  /* Ricochet Starmode Radio hardware format */
   39 #define ARPHRD_IEEE1394 24  /* IEEE 1394 (FireWire) hardware format */
   40     u_short ar_pro;     /* format of protocol address */
   41     u_char  ar_hln;     /* length of hardware address */
   42     u_char  ar_pln;     /* length of protocol address */
   43     u_short ar_op;      /* one of: */
   44 #define ARPOP_REQUEST   1   /* request to resolve address */
   45 #define ARPOP_REPLY 2   /* response to previous request */
   46 #define ARPOP_REVREQUEST 3  /* request protocol address given hardware */
   47 #define ARPOP_REVREPLY  4   /* response giving protocol address */
   48 #define ARPOP_INVREQUEST 8  /* request to identify peer */
   49 #define ARPOP_INVREPLY  9   /* response identifying peer */
   50 /*
   51  * The remaining fields are variable in size,
   52  * according to the sizes above.
   53  */
   54 #ifdef COMMENT_ONLY
   55     u_char  ar_sha[];   /* sender hardware address */
   56     u_char  ar_spa[];   /* sender protocol address */
   57     u_char  ar_tha[];   /* target hardware address */
   58     u_char  ar_tpa[];   /* target protocol address */
   59 #endif
   60 #define ar_sha(ap)  (((const u_char *)((ap)+1))+0)
   61 #define ar_spa(ap)  (((const u_char *)((ap)+1))+  (ap)->ar_hln)
   62 #define ar_tha(ap)  (((const u_char *)((ap)+1))+  (ap)->ar_hln+(ap)->ar_pln)
   63 #define ar_tpa(ap)  (((const u_char *)((ap)+1))+2*(ap)->ar_hln+(ap)->ar_pln)
   64 };
   65 
   66 #define ARP_HDRLEN  8
   67 
   68 #define HRD(ap) EXTRACT_16BITS(&(ap)->ar_hrd)
   69 #define HLN(ap) ((ap)->ar_hln)
   70 #define PLN(ap) ((ap)->ar_pln)
   71 #define OP(ap)  EXTRACT_16BITS(&(ap)->ar_op)
   72 #define PRO(ap) EXTRACT_16BITS(&(ap)->ar_pro)
   73 #define SHA(ap) (ar_sha(ap))
   74 #define SPA(ap) (ar_spa(ap))
   75 #define THA(ap) (ar_tha(ap))
   76 #define TPA(ap) (ar_tpa(ap))