if_arp.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /* Definitions for Address Resolution Protocol.
  2. Copyright (C) 1997, 1999, 2001 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. /* Dummy types for non ARP hardware */
  71. #define ARPHRD_SLIP 256
  72. #define ARPHRD_CSLIP 257
  73. #define ARPHRD_SLIP6 258
  74. #define ARPHRD_CSLIP6 259
  75. #define ARPHRD_RSRVD 260 /* Notional KISS type. */
  76. #define ARPHRD_ADAPT 264
  77. #define ARPHRD_ROSE 270
  78. #define ARPHRD_X25 271 /* CCITT X.25. */
  79. #define ARPHDR_HWX25 272 /* Boards with X.25 in firmware. */
  80. #define ARPHRD_PPP 512
  81. #define ARPHRD_CISCO 513 /* Cisco HDLC. */
  82. #define ARPHRD_HDLC ARPHRD_CISCO
  83. #define ARPHRD_LAPB 516 /* LAPB. */
  84. #define ARPHRD_DDCMP 517 /* Digital's DDCMP. */
  85. #define ARPHRD_RAWHDLC 518 /* Raw HDLC. */
  86. #define ARPHRD_TUNNEL 768 /* IPIP tunnel. */
  87. #define ARPHRD_TUNNEL6 769 /* IPIP6 tunnel. */
  88. #define ARPHRD_FRAD 770 /* Frame Relay Access Device. */
  89. #define ARPHRD_SKIP 771 /* SKIP vif. */
  90. #define ARPHRD_LOOPBACK 772 /* Loopback device. */
  91. #define ARPHRD_LOCALTLK 773 /* Localtalk device. */
  92. #define ARPHRD_FDDI 774 /* Fiber Distributed Data Interface. */
  93. #define ARPHRD_BIF 775 /* AP1000 BIF. */
  94. #define ARPHRD_SIT 776 /* sit0 device - IPv6-in-IPv4. */
  95. #define ARPHRD_IPDDP 777 /* IP-in-DDP tunnel. */
  96. #define ARPHRD_IPGRE 778 /* GRE over IP. */
  97. #define ARPHRD_PIMREG 779 /* PIMSM register interface. */
  98. #define ARPHRD_HIPPI 780 /* High Performance Parallel I'face. */
  99. #define ARPHRD_ASH 781 /* (Nexus Electronics) Ash. */
  100. #define ARPHRD_ECONET 782 /* Acorn Econet. */
  101. #define ARPHRD_IRDA 783 /* Linux-IrDA. */
  102. #define ARPHRD_FCPP 784 /* Point to point fibrechanel. */
  103. #define ARPHRD_FCAL 785 /* Fibrechanel arbitrated loop. */
  104. #define ARPHRD_FCPL 786 /* Fibrechanel public loop. */
  105. #define ARPHRD_FCPFABRIC 787 /* Fibrechanel fabric. */
  106. #define ARPHRD_IEEE802_TR 800 /* Magic type ident for TR. */
  107. #define ARPHRD_IEEE80211 801 /* IEEE 802.11. */
  108. /* ARP ioctl request. */
  109. struct arpreq
  110. {
  111. struct sockaddr arp_pa; /* Protocol address. */
  112. struct sockaddr arp_ha; /* Hardware address. */
  113. int arp_flags; /* Flags. */
  114. struct sockaddr arp_netmask; /* Netmask (only for proxy arps). */
  115. char arp_dev[16];
  116. };
  117. struct arpreq_old
  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. };
  124. /* ARP Flag values. */
  125. #define ATF_COM 0x02 /* Completed entry (ha valid). */
  126. #define ATF_PERM 0x04 /* Permanent entry. */
  127. #define ATF_PUBL 0x08 /* Publish entry. */
  128. #define ATF_USETRAILERS 0x10 /* Has requested trailers. */
  129. #define ATF_NETMASK 0x20 /* Want to use a netmask (only
  130. for proxy entries). */
  131. #define ATF_DONTPUB 0x40 /* Don't answer this addresses. */
  132. #define ATF_MAGIC 0x80 /* Automatically added entry. */
  133. /* Support for the user space arp daemon, arpd. */
  134. #define ARPD_UPDATE 0x01
  135. #define ARPD_LOOKUP 0x02
  136. #define ARPD_FLUSH 0x03
  137. struct arpd_request
  138. {
  139. unsigned short int req; /* Request type. */
  140. u_int32_t ip; /* IP address of entry. */
  141. unsigned long int dev; /* Device entry is tied to. */
  142. unsigned long int stamp;
  143. unsigned long int updated;
  144. unsigned char ha[MAX_ADDR_LEN]; /* Hardware address. */
  145. };
  146. __END_DECLS
  147. #endif /* net/if_arp.h */