|
@@ -0,0 +1,100 @@
|
|
1
|
+#ifndef _IF_ARP_H
|
|
2
|
+#define _IF_ARP_H
|
|
3
|
+
|
|
4
|
+/** @file
|
|
5
|
+ *
|
|
6
|
+ * Address Resolution Protocol constants and types
|
|
7
|
+ *
|
|
8
|
+ */
|
|
9
|
+
|
|
10
|
+#include <stdint.h>
|
|
11
|
+
|
|
12
|
+/* ARP protocol HARDWARE identifiers. */
|
|
13
|
+#define ARPHRD_NETROM 0 /**< from KA9Q: NET/ROM pseudo */
|
|
14
|
+#define ARPHRD_ETHER 1 /**< Ethernet 10Mbps */
|
|
15
|
+#define ARPHRD_EETHER 2 /**< Experimental Ethernet */
|
|
16
|
+#define ARPHRD_AX25 3 /**< AX.25 Level 2 */
|
|
17
|
+#define ARPHRD_PRONET 4 /**< PROnet token ring */
|
|
18
|
+#define ARPHRD_CHAOS 5 /**< Chaosnet */
|
|
19
|
+#define ARPHRD_IEEE802 6 /**< IEEE 802.2 Ethernet/TR/TB */
|
|
20
|
+#define ARPHRD_ARCNET 7 /**< ARCnet */
|
|
21
|
+#define ARPHRD_APPLETLK 8 /**< APPLEtalk */
|
|
22
|
+#define ARPHRD_DLCI 15 /**< Frame Relay DLCI */
|
|
23
|
+#define ARPHRD_ATM 19 /**< ATM */
|
|
24
|
+#define ARPHRD_METRICOM 23 /**< Metricom STRIP (new IANA id) */
|
|
25
|
+#define ARPHRD_IEEE1394 24 /**< IEEE 1394 IPv4 - RFC 2734 */
|
|
26
|
+#define ARPHRD_EUI64 27 /**< EUI-64 */
|
|
27
|
+#define ARPHRD_INFINIBAND 32 /**< InfiniBand */
|
|
28
|
+
|
|
29
|
+/* ARP protocol opcodes. */
|
|
30
|
+#define ARPOP_REQUEST 1 /**< ARP request */
|
|
31
|
+#define ARPOP_REPLY 2 /**< ARP reply */
|
|
32
|
+#define ARPOP_RREQUEST 3 /**< RARP request */
|
|
33
|
+#define ARPOP_RREPLY 4 /**< RARP reply */
|
|
34
|
+#define ARPOP_InREQUEST 8 /**< InARP request */
|
|
35
|
+#define ARPOP_InREPLY 9 /**< InARP reply */
|
|
36
|
+#define ARPOP_NAK 10 /**< (ATM)ARP NAK */
|
|
37
|
+
|
|
38
|
+/**
|
|
39
|
+ * An ARP header
|
|
40
|
+ *
|
|
41
|
+ * This contains only the fixed-size portions of an ARP header; for
|
|
42
|
+ * other fields use the arp_{sender,target}_{ha,pa} family of
|
|
43
|
+ * functions.
|
|
44
|
+ */
|
|
45
|
+struct arphdr {
|
|
46
|
+ /** Link-layer protocol
|
|
47
|
+ *
|
|
48
|
+ * This is an ARPHRD_XXX constant
|
|
49
|
+ */
|
|
50
|
+ uint16_t ar_hrd;
|
|
51
|
+ /** Network-layer protocol
|
|
52
|
+ *
|
|
53
|
+ * This is, for Ethernet, an ETH_P_XXX constant.
|
|
54
|
+ */
|
|
55
|
+ uint16_t ar_pro;
|
|
56
|
+ /** Link-layer address length */
|
|
57
|
+ uint8_t ar_hln;
|
|
58
|
+ /** Network-layer address length */
|
|
59
|
+ uint8_t ar_pln;
|
|
60
|
+ /** ARP opcode */
|
|
61
|
+ uint16_t ar_op;
|
|
62
|
+} __attribute__ (( packed ));
|
|
63
|
+
|
|
64
|
+/** ARP packet sender hardware address
|
|
65
|
+ *
|
|
66
|
+ * @v arphdr ARP header
|
|
67
|
+ * @ret ar_sha Sender hardware address
|
|
68
|
+ */
|
|
69
|
+static inline void * arp_sender_ha ( struct arphdr *arphdr ) {
|
|
70
|
+ return ( ( ( void * ) arphdr ) + sizeof ( *arphdr ) );
|
|
71
|
+}
|
|
72
|
+
|
|
73
|
+/** ARP packet sender protocol address
|
|
74
|
+ *
|
|
75
|
+ * @v arphdr ARP header
|
|
76
|
+ * @ret ar_spa Sender protocol address
|
|
77
|
+ */
|
|
78
|
+static inline void * arp_sender_pa ( struct arphdr *arphdr ) {
|
|
79
|
+ return ( arp_sender_ha ( arphdr ) + arphdr->ar_hln );
|
|
80
|
+}
|
|
81
|
+
|
|
82
|
+/** ARP packet target hardware address
|
|
83
|
+ *
|
|
84
|
+ * @v arphdr ARP header
|
|
85
|
+ * @ret ar_tha Target hardware address
|
|
86
|
+ */
|
|
87
|
+static inline void * arp_target_ha ( struct arphdr *arphdr ) {
|
|
88
|
+ return ( arp_sender_pa ( arphdr ) + arphdr->ar_pln );
|
|
89
|
+}
|
|
90
|
+
|
|
91
|
+/** ARP packet target protocol address
|
|
92
|
+ *
|
|
93
|
+ * @v arphdr ARP header
|
|
94
|
+ * @ret ar_tpa Target protocol address
|
|
95
|
+ */
|
|
96
|
+static inline void * arp_target_pa ( struct arphdr *arphdr ) {
|
|
97
|
+ return ( arp_target_ha ( arphdr ) + arphdr->ar_hln );
|
|
98
|
+}
|
|
99
|
+
|
|
100
|
+#endif /* _IF_ARP_H */
|