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 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 
00045 /* See RFC 826 for protocol description.  ARP packets are variable
00046    in size; the arphdr structure defines the fixed-length portion.
00047    Protocol type values are the same as those for 10 Mb/s Ethernet.
00048    It is followed by the variable-sized fields ar_sha, arp_spa,
00049    arp_tha and arp_tpa in that order, according to the lengths
00050    specified.  Field names used correspond to RFC 826.  */
00051 
00052 struct arphdr
00053   {
00054     unsigned short int ar_hrd;            /* Format of hardware address.  */
00055     unsigned short int ar_pro;            /* Format of protocol address.  */
00056     unsigned char ar_hln;          /* Length of hardware address.  */
00057     unsigned char ar_pln;          /* Length of protocol address.  */
00058     unsigned short int ar_op;             /* ARP opcode (command).  */
00059 #if 0
00060     /* Ethernet looks like this : This bit is variable sized
00061        however...  */
00062     unsigned char __ar_sha[ETH_ALEN];     /* Sender hardware address.  */
00063     unsigned char __ar_sip[4];            /* Sender IP address.  */
00064     unsigned char __ar_tha[ETH_ALEN];     /* Target hardware address.  */
00065     unsigned char __ar_tip[4];            /* Target IP address.  */
00066 #endif
00067   };
00068 
00069 
00070 /* ARP protocol HARDWARE identifiers. */
00071 #define ARPHRD_NETROM       0             /* From KA9Q: NET/ROM pseudo. */
00072 #define ARPHRD_ETHER        1             /* Ethernet 10Mbps.  */
00073 #define       ARPHRD_EETHER 2             /* Experimental Ethernet.  */
00074 #define       ARPHRD_AX25   3             /* AX.25 Level 2.  */
00075 #define       ARPHRD_PRONET 4             /* PROnet token ring.  */
00076 #define       ARPHRD_CHAOS  5             /* Chaosnet.  */
00077 #define       ARPHRD_IEEE802       6             /* IEEE 802.2 Ethernet/TR/TB.  */
00078 #define       ARPHRD_ARCNET 7             /* ARCnet.  */
00079 #define       ARPHRD_APPLETLK      8             /* APPLEtalk.  */
00080 #define ARPHRD_DLCI  15            /* Frame Relay DLCI.  */
00081 #define ARPHRD_METRICOM     23            /* Metricom STRIP (new IANA id).  */
00082 
00083 /* Dummy types for non ARP hardware */
00084 #define ARPHRD_SLIP  256
00085 #define ARPHRD_CSLIP 257
00086 #define ARPHRD_SLIP6 258
00087 #define ARPHRD_CSLIP6       259
00088 #define ARPHRD_RSRVD 260           /* Notional KISS type.  */
00089 #define ARPHRD_ADAPT 264
00090 #define ARPHRD_ROSE  270
00091 #define ARPHRD_X25   271           /* CCITT X.25.  */
00092 #define ARPHRD_PPP   512
00093 #define ARPHRD_HDLC  513           /* (Cisco) HDLC.  */
00094 #define ARPHRD_LAPB  516           /* LAPB.  */
00095 
00096 #define ARPHRD_TUNNEL       768           /* IPIP tunnel.  */
00097 #define ARPHRD_TUNNEL6      769           /* IPIP6 tunnel.  */
00098 #define ARPHRD_FRAD  770             /* Frame Relay Access Device.  */
00099 #define ARPHRD_SKIP  771           /* SKIP vif.  */
00100 #define ARPHRD_LOOPBACK     772           /* Loopback device.  */
00101 #define ARPHRD_LOCALTLK 773        /* Localtalk device.  */
00102 #define ARPHRD_FDDI  774           /* Fiber Distributed Data Interface. */
00103 #define ARPHRD_BIF      775             /* AP1000 BIF.  */
00104 #define ARPHRD_SIT   776           /* sit0 device - IPv6-in-IPv4.  */
00105 
00106 
00107 /* ARP ioctl request.  */
00108 struct arpreq
00109   {
00110     struct sockaddr arp_pa;        /* Protocol address.  */
00111     struct sockaddr arp_ha;        /* Hardware address.  */
00112     int arp_flags;                 /* Flags.  */
00113     struct sockaddr arp_netmask;   /* Netmask (only for proxy arps).  */
00114     char arp_dev[16];
00115   };
00116 
00117 /* ARP Flag values.  */
00118 #define ATF_COM             0x02          /* Completed entry (ha valid).  */
00119 #define       ATF_PERM      0x04          /* Permanent entry.  */
00120 #define       ATF_PUBL      0x08          /* Publish entry.  */
00121 #define       ATF_USETRAILERS      0x10          /* Has requested trailers.  */
00122 #define ATF_NETMASK     0x20            /* Want to use a netmask (only
00123                                       for proxy entries).  */
00124 #define ATF_DONTPUB  0x40          /* Don't answer this addresses.  */
00125 #define ATF_MAGIC    0x80          /* Automatically added entry.  */
00126 
00127 
00128 /* Support for the user space arp daemon, arpd.  */
00129 #define ARPD_UPDATE  0x01
00130 #define ARPD_LOOKUP  0x02
00131 #define ARPD_FLUSH   0x03
00132 
00133 struct arpd_request
00134   {
00135     unsigned short int req;        /* Request type.  */
00136     u_int32_t ip;                  /* IP address of entry.  */
00137     unsigned long int dev;         /* Device entry is tied to.  */
00138     unsigned long int stamp;
00139     unsigned long int updated;
00140     unsigned char ha[MAX_ADDR_LEN];       /* Hardware address.  */
00141   };
00142 
00143 __END_DECLS
00144 
00145 #endif /* net/if_arp.h */