if_arp.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /* Definitions for Address Resolution Protocol.
  2. Copyright (C) 1997,1999,2001,2006,2009 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, write to the Free
  15. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  16. 02111-1307 USA. */
  17. /* Based on the 4.4BSD and Linux version of this file. */
  18. #ifndef _NET_IF_ARP_H
  19. #define _NET_IF_ARP_H 1
  20. #include <sys/cdefs.h>
  21. #include <sys/types.h>
  22. #include <sys/socket.h>
  23. __BEGIN_DECLS
  24. /* Some internals from deep down in the kernel. */
  25. #define MAX_ADDR_LEN 7
  26. /* This structure defines an ethernet arp header. */
  27. /* ARP protocol opcodes. */
  28. #define ARPOP_REQUEST 1 /* ARP request. */
  29. #define ARPOP_REPLY 2 /* ARP reply. */
  30. #define ARPOP_RREQUEST 3 /* RARP request. */
  31. #define ARPOP_RREPLY 4 /* RARP reply. */
  32. #define ARPOP_InREQUEST 8 /* InARP request. */
  33. #define ARPOP_InREPLY 9 /* InARP reply. */
  34. #define ARPOP_NAK 10 /* (ATM)ARP NAK. */
  35. /* See RFC 826 for protocol description. ARP packets are variable
  36. in size; the arphdr structure defines the fixed-length portion.
  37. Protocol type values are the same as those for 10 Mb/s Ethernet.
  38. It is followed by the variable-sized fields ar_sha, arp_spa,
  39. arp_tha and arp_tpa in that order, according to the lengths
  40. specified. Field names used correspond to RFC 826. */
  41. struct arphdr
  42. {
  43. unsigned short int ar_hrd; /* Format of hardware address. */
  44. unsigned short int ar_pro; /* Format of protocol address. */
  45. unsigned char ar_hln; /* Length of hardware address. */
  46. unsigned char ar_pln; /* Length of protocol address. */
  47. unsigned short int ar_op; /* ARP opcode (command). */
  48. #if 0
  49. /* Ethernet looks like this : This bit is variable sized
  50. however... */
  51. unsigned char __ar_sha[ETH_ALEN]; /* Sender hardware address. */
  52. unsigned char __ar_sip[4]; /* Sender IP address. */
  53. unsigned char __ar_tha[ETH_ALEN]; /* Target hardware address. */
  54. unsigned char __ar_tip[4]; /* Target IP address. */
  55. #endif
  56. };
  57. /* ARP protocol HARDWARE identifiers. */
  58. #define ARPHRD_NETROM 0 /* From KA9Q: NET/ROM pseudo. */
  59. #define ARPHRD_ETHER 1 /* Ethernet 10/100Mbps. */
  60. #define ARPHRD_EETHER 2 /* Experimental Ethernet. */
  61. #define ARPHRD_AX25 3 /* AX.25 Level 2. */
  62. #define ARPHRD_PRONET 4 /* PROnet token ring. */
  63. #define ARPHRD_CHAOS 5 /* Chaosnet. */
  64. #define ARPHRD_IEEE802 6 /* IEEE 802.2 Ethernet/TR/TB. */
  65. #define ARPHRD_ARCNET 7 /* ARCnet. */
  66. #define ARPHRD_APPLETLK 8 /* APPLEtalk. */
  67. #define ARPHRD_DLCI 15 /* Frame Relay DLCI. */
  68. #define ARPHRD_ATM 19 /* ATM. */
  69. #define ARPHRD_METRICOM 23 /* Metricom STRIP (new IANA id). */
  70. #define ARPHRD_IEEE1394 24 /* IEEE 1394 IPv4 - RFC 2734. */
  71. #define ARPHRD_EUI64 27 /* EUI-64. */
  72. #define ARPHRD_INFINIBAND 32 /* InfiniBand. */
  73. /* Dummy types for non ARP hardware */
  74. #define ARPHRD_SLIP 256
  75. #define ARPHRD_CSLIP 257
  76. #define ARPHRD_SLIP6 258
  77. #define ARPHRD_CSLIP6 259
  78. #define ARPHRD_RSRVD 260 /* Notional KISS type. */
  79. #define ARPHRD_ADAPT 264
  80. #define ARPHRD_ROSE 270
  81. #define ARPHRD_X25 271 /* CCITT X.25. */
  82. #define ARPHRD_HWX25 272 /* Boards with X.25 in firmware. */
  83. #define ARPHRD_PPP 512
  84. #define ARPHRD_CISCO 513 /* Cisco HDLC. */
  85. #define ARPHRD_HDLC ARPHRD_CISCO
  86. #define ARPHRD_LAPB 516 /* LAPB. */
  87. #define ARPHRD_DDCMP 517 /* Digital's DDCMP. */
  88. #define ARPHRD_RAWHDLC 518 /* Raw HDLC. */
  89. #define ARPHRD_TUNNEL 768 /* IPIP tunnel. */
  90. #define ARPHRD_TUNNEL6 769 /* IPIP6 tunnel. */
  91. #define ARPHRD_FRAD 770 /* Frame Relay Access Device. */
  92. #define ARPHRD_SKIP 771 /* SKIP vif. */
  93. #define ARPHRD_LOOPBACK 772 /* Loopback device. */
  94. #define ARPHRD_LOCALTLK 773 /* Localtalk device. */
  95. #define ARPHRD_FDDI 774 /* Fiber Distributed Data Interface. */
  96. #define ARPHRD_BIF 775 /* AP1000 BIF. */
  97. #define ARPHRD_SIT 776 /* sit0 device - IPv6-in-IPv4. */
  98. #define ARPHRD_IPDDP 777 /* IP-in-DDP tunnel. */
  99. #define ARPHRD_IPGRE 778 /* GRE over IP. */
  100. #define ARPHRD_PIMREG 779 /* PIMSM register interface. */
  101. #define ARPHRD_HIPPI 780 /* High Performance Parallel I'face. */
  102. #define ARPHRD_ASH 781 /* (Nexus Electronics) Ash. */
  103. #define ARPHRD_ECONET 782 /* Acorn Econet. */
  104. #define ARPHRD_IRDA 783 /* Linux-IrDA. */
  105. #define ARPHRD_FCPP 784 /* Point to point fibrechanel. */
  106. #define ARPHRD_FCAL 785 /* Fibrechanel arbitrated loop. */
  107. #define ARPHRD_FCPL 786 /* Fibrechanel public loop. */
  108. #define ARPHRD_FCFABRIC 787 /* Fibrechanel fabric. */
  109. #define ARPHRD_IEEE802_TR 800 /* Magic type ident for TR. */
  110. #define ARPHRD_IEEE80211 801 /* IEEE 802.11. */
  111. #define ARPHRD_IEEE80211_PRISM 802 /* IEEE 802.11 + Prism2 header. */
  112. #define ARPHRD_IEEE80211_RADIOTAP 803 /* IEEE 802.11 + radiotap header. */
  113. #define ARPHRD_IEEE802154 804 /* IEEE 802.15.4 header. */
  114. #define ARPHRD_IEEE802154_PHY 805 /* IEEE 802.15.4 PHY header. */
  115. #define ARPHRD_VOID 0xFFFF /* Void type, nothing is known. */
  116. #define ARPHRD_NONE 0xFFFE /* Zero header length. */
  117. /* ARP ioctl request. */
  118. struct arpreq
  119. {
  120. struct sockaddr arp_pa; /* Protocol address. */
  121. struct sockaddr arp_ha; /* Hardware address. */
  122. int arp_flags; /* Flags. */
  123. struct sockaddr arp_netmask; /* Netmask (only for proxy arps). */
  124. char arp_dev[16];
  125. };
  126. struct arpreq_old
  127. {
  128. struct sockaddr arp_pa; /* Protocol address. */
  129. struct sockaddr arp_ha; /* Hardware address. */
  130. int arp_flags; /* Flags. */
  131. struct sockaddr arp_netmask; /* Netmask (only for proxy arps). */
  132. };
  133. /* ARP Flag values. */
  134. #define ATF_COM 0x02 /* Completed entry (ha valid). */
  135. #define ATF_PERM 0x04 /* Permanent entry. */
  136. #define ATF_PUBL 0x08 /* Publish entry. */
  137. #define ATF_USETRAILERS 0x10 /* Has requested trailers. */
  138. #define ATF_NETMASK 0x20 /* Want to use a netmask (only
  139. for proxy entries). */
  140. #define ATF_DONTPUB 0x40 /* Don't answer this addresses. */
  141. #define ATF_MAGIC 0x80 /* Automatically added entry. */
  142. /* Support for the user space arp daemon, arpd. */
  143. #define ARPD_UPDATE 0x01
  144. #define ARPD_LOOKUP 0x02
  145. #define ARPD_FLUSH 0x03
  146. struct arpd_request
  147. {
  148. unsigned short int req; /* Request type. */
  149. u_int32_t ip; /* IP address of entry. */
  150. unsigned long int dev; /* Device entry is tied to. */
  151. unsigned long int stamp;
  152. unsigned long int updated;
  153. unsigned char ha[MAX_ADDR_LEN]; /* Hardware address. */
  154. };
  155. __END_DECLS
  156. #endif /* net/if_arp.h */