if_arp.h 6.9 KB

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