Back to index

glibc  2.9
if_arp.h
Go to the documentation of this file.
00001 /* Definitions for Address Resolution Protocol.
00002    Copyright (C) 1997,1999,2001,2006 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
00005 
00006    The GNU C Library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser General Public
00008    License as published by the Free Software Foundation; either
00009    version 2.1 of the License, or (at your option) any later version.
00010 
00011    The GNU C Library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser General Public
00017    License along with the GNU C Library; if not, write to the Free
00018    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019    02111-1307 USA.  */
00020 
00021 /* Based on the 4.4BSD and Linux version of this file.  */
00022 
00023 #ifndef _NET_IF_ARP_H
00024 
00025 #define _NET_IF_ARP_H 1
00026 #include <sys/cdefs.h>
00027 
00028 #include <sys/types.h>
00029 #include <sys/socket.h>
00030 
00031 __BEGIN_DECLS
00032 
00033 /* Some internals from deep down in the kernel.  */
00034 #define MAX_ADDR_LEN 7
00035 
00036 
00037 /* This structure defines an ethernet arp header.  */
00038 
00039 /* ARP protocol opcodes. */
00040 #define       ARPOP_REQUEST 1             /* ARP request.  */
00041 #define       ARPOP_REPLY   2             /* ARP reply.  */
00042 #define       ARPOP_RREQUEST       3             /* RARP request.  */
00043 #define       ARPOP_RREPLY  4             /* RARP reply.  */
00044 #define       ARPOP_InREQUEST      8             /* InARP request.  */
00045 #define       ARPOP_InREPLY 9             /* InARP reply.  */
00046 #define       ARPOP_NAK     10            /* (ATM)ARP NAK.  */
00047 
00048 /* See RFC 826 for protocol description.  ARP packets are variable
00049    in size; the arphdr structure defines the fixed-length portion.
00050    Protocol type values are the same as those for 10 Mb/s Ethernet.
00051    It is followed by the variable-sized fields ar_sha, arp_spa,
00052    arp_tha and arp_tpa in that order, according to the lengths
00053    specified.  Field names used correspond to RFC 826.  */
00054 
00055 struct arphdr
00056   {
00057     unsigned short int ar_hrd;            /* Format of hardware address.  */
00058     unsigned short int ar_pro;            /* Format of protocol address.  */
00059     unsigned char ar_hln;          /* Length of hardware address.  */
00060     unsigned char ar_pln;          /* Length of protocol address.  */
00061     unsigned short int ar_op;             /* ARP opcode (command).  */
00062 #if 0
00063     /* Ethernet looks like this : This bit is variable sized
00064        however...  */
00065     unsigned char __ar_sha[ETH_ALEN];     /* Sender hardware address.  */
00066     unsigned char __ar_sip[4];            /* Sender IP address.  */
00067     unsigned char __ar_tha[ETH_ALEN];     /* Target hardware address.  */
00068     unsigned char __ar_tip[4];            /* Target IP address.  */
00069 #endif
00070   };
00071 
00072 
00073 /* ARP protocol HARDWARE identifiers. */
00074 #define ARPHRD_NETROM       0             /* From KA9Q: NET/ROM pseudo. */
00075 #define ARPHRD_ETHER        1             /* Ethernet 10/100Mbps.  */
00076 #define       ARPHRD_EETHER 2             /* Experimental Ethernet.  */
00077 #define       ARPHRD_AX25   3             /* AX.25 Level 2.  */
00078 #define       ARPHRD_PRONET 4             /* PROnet token ring.  */
00079 #define       ARPHRD_CHAOS  5             /* Chaosnet.  */
00080 #define       ARPHRD_IEEE802       6             /* IEEE 802.2 Ethernet/TR/TB.  */
00081 #define       ARPHRD_ARCNET 7             /* ARCnet.  */
00082 #define       ARPHRD_APPLETLK      8             /* APPLEtalk.  */
00083 #define       ARPHRD_DLCI   15            /* Frame Relay DLCI.  */
00084 #define       ARPHRD_ATM    19            /* ATM.  */
00085 #define       ARPHRD_METRICOM      23            /* Metricom STRIP (new IANA id).  */
00086 #define ARPHRD_IEEE1394     24            /* IEEE 1394 IPv4 - RFC 2734.  */
00087 #define ARPHRD_EUI64        27            /* EUI-64.  */
00088 #define ARPHRD_INFINIBAND   32            /* InfiniBand.  */
00089 
00090 /* Dummy types for non ARP hardware */
00091 #define ARPHRD_SLIP  256
00092 #define ARPHRD_CSLIP 257
00093 #define ARPHRD_SLIP6 258
00094 #define ARPHRD_CSLIP6       259
00095 #define ARPHRD_RSRVD 260           /* Notional KISS type.  */
00096 #define ARPHRD_ADAPT 264
00097 #define ARPHRD_ROSE  270
00098 #define ARPHRD_X25   271           /* CCITT X.25.  */
00099 #define ARPHRD_HWX25 272           /* Boards with X.25 in firmware.  */
00100 #define ARPHRD_PPP   512
00101 #define ARPHRD_CISCO 513           /* Cisco HDLC.  */
00102 #define ARPHRD_HDLC  ARPHRD_CISCO
00103 #define ARPHRD_LAPB  516           /* LAPB.  */
00104 #define ARPHRD_DDCMP 517           /* Digital's DDCMP.  */
00105 #define       ARPHRD_RAWHDLC       518           /* Raw HDLC.  */
00106 
00107 #define ARPHRD_TUNNEL       768           /* IPIP tunnel.  */
00108 #define ARPHRD_TUNNEL6      769           /* IPIP6 tunnel.  */
00109 #define ARPHRD_FRAD  770             /* Frame Relay Access Device.  */
00110 #define ARPHRD_SKIP  771           /* SKIP vif.  */
00111 #define ARPHRD_LOOPBACK     772           /* Loopback device.  */
00112 #define ARPHRD_LOCALTLK 773        /* Localtalk device.  */
00113 #define ARPHRD_FDDI  774           /* Fiber Distributed Data Interface. */
00114 #define ARPHRD_BIF   775             /* AP1000 BIF.  */
00115 #define ARPHRD_SIT   776           /* sit0 device - IPv6-in-IPv4.  */
00116 #define ARPHRD_IPDDP 777           /* IP-in-DDP tunnel.  */
00117 #define ARPHRD_IPGRE 778           /* GRE over IP.  */
00118 #define ARPHRD_PIMREG       779           /* PIMSM register interface.  */
00119 #define ARPHRD_HIPPI 780           /* High Performance Parallel I'face. */
00120 #define ARPHRD_ASH   781           /* (Nexus Electronics) Ash.  */
00121 #define ARPHRD_ECONET       782           /* Acorn Econet.  */
00122 #define ARPHRD_IRDA  783           /* Linux-IrDA.  */
00123 #define ARPHRD_FCPP  784           /* Point to point fibrechanel.  */
00124 #define ARPHRD_FCAL  785           /* Fibrechanel arbitrated loop.  */
00125 #define ARPHRD_FCPL  786           /* Fibrechanel public loop.  */
00126 #define ARPHRD_FCFABRIC 787        /* Fibrechanel fabric.  */
00127 #define ARPHRD_IEEE802_TR 800             /* Magic type ident for TR.  */
00128 #define ARPHRD_IEEE80211 801              /* IEEE 802.11.  */
00129 #define ARPHRD_IEEE80211_PRISM 802 /* IEEE 802.11 + Prism2 header.  */
00130 #define ARPHRD_IEEE80211_RADIOTAP 803     /* IEEE 802.11 + radiotap header.  */
00131 
00132 #define ARPHRD_VOID    0xFFFF      /* Void type, nothing is known.  */
00133 #define ARPHRD_NONE    0xFFFE      /* Zero header length.  */
00134 
00135 
00136 /* ARP ioctl request.  */
00137 struct arpreq
00138   {
00139     struct sockaddr arp_pa;        /* Protocol address.  */
00140     struct sockaddr arp_ha;        /* Hardware address.  */
00141     int arp_flags;                 /* Flags.  */
00142     struct sockaddr arp_netmask;   /* Netmask (only for proxy arps).  */
00143     char arp_dev[16];
00144   };
00145 
00146 struct arpreq_old
00147   {
00148     struct sockaddr arp_pa;        /* Protocol address.  */
00149     struct sockaddr arp_ha;        /* Hardware address.  */
00150     int arp_flags;                 /* Flags.  */
00151     struct sockaddr arp_netmask;   /* Netmask (only for proxy arps).  */
00152   };
00153 
00154 /* ARP Flag values.  */
00155 #define ATF_COM             0x02          /* Completed entry (ha valid).  */
00156 #define       ATF_PERM      0x04          /* Permanent entry.  */
00157 #define       ATF_PUBL      0x08          /* Publish entry.  */
00158 #define       ATF_USETRAILERS      0x10          /* Has requested trailers.  */
00159 #define ATF_NETMASK     0x20            /* Want to use a netmask (only
00160                                       for proxy entries).  */
00161 #define ATF_DONTPUB  0x40          /* Don't answer this addresses.  */
00162 #define ATF_MAGIC    0x80          /* Automatically added entry.  */
00163 
00164 
00165 /* Support for the user space arp daemon, arpd.  */
00166 #define ARPD_UPDATE  0x01
00167 #define ARPD_LOOKUP  0x02
00168 #define ARPD_FLUSH   0x03
00169 
00170 struct arpd_request
00171   {
00172     unsigned short int req;        /* Request type.  */
00173     u_int32_t ip;                  /* IP address of entry.  */
00174     unsigned long int dev;         /* Device entry is tied to.  */
00175     unsigned long int stamp;
00176     unsigned long int updated;
00177     unsigned char ha[MAX_ADDR_LEN];       /* Hardware address.  */
00178   };
00179 
00180 __END_DECLS
00181 
00182 #endif /* net/if_arp.h */