if_arp.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /* Definitions for Address Resolution Protocol.
  2. Copyright (C) 1997, 1999 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 Library General Public License as
  7. published by the Free Software Foundation; either version 2 of the
  8. 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. Library General Public License for more details.
  13. You should have received a copy of the GNU Library General Public
  14. License along with the GNU C Library; see the file COPYING.LIB. If not,
  15. write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  16. Boston, MA 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 ARPHRD_PPP 512
  80. #define ARPHRD_HDLC 513 /* (Cisco) HDLC. */
  81. #define ARPHRD_LAPB 516 /* LAPB. */
  82. #define ARPHRD_DDCMP 517 /* Digital's DDCMP. */
  83. #define ARPHRD_TUNNEL 768 /* IPIP tunnel. */
  84. #define ARPHRD_TUNNEL6 769 /* IPIP6 tunnel. */
  85. #define ARPHRD_FRAD 770 /* Frame Relay Access Device. */
  86. #define ARPHRD_SKIP 771 /* SKIP vif. */
  87. #define ARPHRD_LOOPBACK 772 /* Loopback device. */
  88. #define ARPHRD_LOCALTLK 773 /* Localtalk device. */
  89. #define ARPHRD_FDDI 774 /* Fiber Distributed Data Interface. */
  90. #define ARPHRD_BIF 775 /* AP1000 BIF. */
  91. #define ARPHRD_SIT 776 /* sit0 device - IPv6-in-IPv4. */
  92. #define ARPHRD_IPDDP 777 /* IP-in-DDP tunnel. */
  93. #define ARPHRD_IPGRE 778 /* GRE over IP. */
  94. #define ARPHRD_PIMREG 779 /* PIMSM register interface. */
  95. #define ARPHRD_HIPPI 780 /* High Performance Parallel I'face. */
  96. #define ARPHRD_ASH 781 /* (Nexus Electronics) Ash. */
  97. #define ARPHRD_ECONET 782 /* Acorn Econet. */
  98. #define ARPHRD_IRDA 783 /* Linux/IR. */
  99. #define ARPHRD_FCPP 784 /* Point to point fibrechanel. */
  100. #define ARPHRD_FCAL 785 /* Fibrechanel arbitrated loop. */
  101. #define ARPHRD_FCPL 786 /* Fibrechanel public loop. */
  102. #define ARPHRD_FCPFABRIC 787 /* Fibrechanel fabric. */
  103. #define ARPHRD_IEEE802_TR 800 /* Magic type ident for TR. */
  104. /* ARP ioctl request. */
  105. struct arpreq
  106. {
  107. struct sockaddr arp_pa; /* Protocol address. */
  108. struct sockaddr arp_ha; /* Hardware address. */
  109. int arp_flags; /* Flags. */
  110. struct sockaddr arp_netmask; /* Netmask (only for proxy arps). */
  111. char arp_dev[16];
  112. };
  113. struct arpreq_old
  114. {
  115. struct sockaddr arp_pa; /* Protocol address. */
  116. struct sockaddr arp_ha; /* Hardware address. */
  117. int arp_flags; /* Flags. */
  118. struct sockaddr arp_netmask; /* Netmask (only for proxy arps). */
  119. };
  120. /* ARP Flag values. */
  121. #define ATF_COM 0x02 /* Completed entry (ha valid). */
  122. #define ATF_PERM 0x04 /* Permanent entry. */
  123. #define ATF_PUBL 0x08 /* Publish entry. */
  124. #define ATF_USETRAILERS 0x10 /* Has requested trailers. */
  125. #define ATF_NETMASK 0x20 /* Want to use a netmask (only
  126. for proxy entries). */
  127. #define ATF_DONTPUB 0x40 /* Don't answer this addresses. */
  128. #define ATF_MAGIC 0x80 /* Automatically added entry. */
  129. /* Support for the user space arp daemon, arpd. */
  130. #define ARPD_UPDATE 0x01
  131. #define ARPD_LOOKUP 0x02
  132. #define ARPD_FLUSH 0x03
  133. struct arpd_request
  134. {
  135. unsigned short int req; /* Request type. */
  136. u_int32_t ip; /* IP address of entry. */
  137. unsigned long int dev; /* Device entry is tied to. */
  138. unsigned long int stamp;
  139. unsigned long int updated;
  140. unsigned char ha[MAX_ADDR_LEN]; /* Hardware address. */
  141. };
  142. __END_DECLS
  143. #endif /* net/if_arp.h */