blob: 6b4dfa6ab3d28bd8b13f8a82929dad5d82f6a488 [file] [log] [blame]
Ed Warnickecb9cada2015-12-08 15:45:58 -07001/*
2 * ethernet/arp.c: IP v4 ARP node
3 *
4 * Copyright (c) 2010 Cisco and/or its affiliates.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef included_ethernet_arp_packet_h
19#define included_ethernet_arp_packet_h
20
Neale Rannscbe25aa2019-09-30 10:53:31 +000021#include <vnet/ip/ip4_packet.h>
Neale Ranns37029302018-08-10 05:30:06 -070022#include <vnet/ethernet/mac_address.h>
23
Ed Warnickecb9cada2015-12-08 15:45:58 -070024#define foreach_ethernet_arp_hardware_type \
25 _ (0, reserved) \
26 _ (1, ethernet) \
27 _ (2, experimental_ethernet) \
28 _ (3, ax_25) \
29 _ (4, proteon_pronet_token_ring) \
30 _ (5, chaos) \
31 _ (6, ieee_802) \
32 _ (7, arcnet) \
33 _ (8, hyperchannel) \
34 _ (9, lanstar) \
35 _ (10, autonet) \
36 _ (11, localtalk) \
37 _ (12, localnet) \
38 _ (13, ultra_link) \
39 _ (14, smds) \
40 _ (15, frame_relay) \
41 _ (16, atm) \
42 _ (17, hdlc) \
43 _ (18, fibre_channel) \
44 _ (19, atm19) \
45 _ (20, serial_line) \
46 _ (21, atm21) \
47 _ (22, mil_std_188_220) \
48 _ (23, metricom) \
49 _ (24, ieee_1394) \
50 _ (25, mapos) \
51 _ (26, twinaxial) \
52 _ (27, eui_64) \
53 _ (28, hiparp) \
54 _ (29, iso_7816_3) \
55 _ (30, arpsec) \
56 _ (31, ipsec_tunnel) \
57 _ (32, infiniband) \
58 _ (33, cai) \
59 _ (34, wiegand) \
60 _ (35, pure_ip) \
61 _ (36, hw_exp1) \
62 _ (256, hw_exp2)
63
64#define foreach_ethernet_arp_opcode \
65 _ (reserved) \
66 _ (request) \
67 _ (reply) \
68 _ (reverse_request) \
69 _ (reverse_reply) \
70 _ (drarp_request) \
71 _ (drarp_reply) \
72 _ (drarp_error) \
73 _ (inarp_request) \
74 _ (inarp_reply) \
75 _ (arp_nak) \
76 _ (mars_request) \
77 _ (mars_multi) \
78 _ (mars_mserv) \
79 _ (mars_join) \
80 _ (mars_leave) \
81 _ (mars_nak) \
82 _ (mars_unserv) \
83 _ (mars_sjoin) \
84 _ (mars_sleave) \
85 _ (mars_grouplist_request) \
86 _ (mars_grouplist_reply) \
87 _ (mars_redirect_map) \
88 _ (mapos_unarp) \
89 _ (exp1) \
90 _ (exp2)
91
Keith Burns (alagalah)e70dcc82016-08-15 18:33:19 -070092typedef enum
93{
Ed Warnickecb9cada2015-12-08 15:45:58 -070094#define _(n,f) ETHERNET_ARP_HARDWARE_TYPE_##f = (n),
95 foreach_ethernet_arp_hardware_type
96#undef _
97} ethernet_arp_hardware_type_t;
98
Keith Burns (alagalah)e70dcc82016-08-15 18:33:19 -070099typedef enum
100{
Ed Warnickecb9cada2015-12-08 15:45:58 -0700101#define _(f) ETHERNET_ARP_OPCODE_##f,
102 foreach_ethernet_arp_opcode
103#undef _
Keith Burns (alagalah)e70dcc82016-08-15 18:33:19 -0700104 ETHERNET_ARP_N_OPCODE,
Ed Warnickecb9cada2015-12-08 15:45:58 -0700105} ethernet_arp_opcode_t;
106
Keith Burns (alagalah)e70dcc82016-08-15 18:33:19 -0700107typedef enum
108{
Ed Warnickecb9cada2015-12-08 15:45:58 -0700109 IP4_ARP_NEXT_DROP,
110 IP4_ARP_N_NEXT,
111} ip4_arp_next_t;
112
Keith Burns (alagalah)e70dcc82016-08-15 18:33:19 -0700113typedef enum
114{
Eyal Baribf9f02c2018-10-31 13:19:11 +0200115 IP4_ARP_ERROR_THROTTLED,
116 IP4_ARP_ERROR_RESOLVED,
117 IP4_ARP_ERROR_NO_BUFFERS,
Ed Warnickecb9cada2015-12-08 15:45:58 -0700118 IP4_ARP_ERROR_REQUEST_SENT,
119 IP4_ARP_ERROR_NON_ARP_ADJ,
Pierre Pfisterd076f192016-06-22 12:58:30 +0100120 IP4_ARP_ERROR_NO_SOURCE_ADDRESS,
Ed Warnickecb9cada2015-12-08 15:45:58 -0700121} ip4_arp_error_t;
122
Keith Burns (alagalah)e70dcc82016-08-15 18:33:19 -0700123/* *INDENT-OFF* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700124typedef CLIB_PACKED (struct {
Neale Ranns37029302018-08-10 05:30:06 -0700125 mac_address_t mac;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700126 ip4_address_t ip4;
127}) ethernet_arp_ip4_over_ethernet_address_t;
Keith Burns (alagalah)e70dcc82016-08-15 18:33:19 -0700128/* *INDENT-ON* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700129
Neale Ranns37029302018-08-10 05:30:06 -0700130STATIC_ASSERT (sizeof (ethernet_arp_ip4_over_ethernet_address_t) == 10,
131 "Packet ethernet address and IP4 address too big");
132
Keith Burns (alagalah)e70dcc82016-08-15 18:33:19 -0700133typedef struct
134{
Ed Warnickecb9cada2015-12-08 15:45:58 -0700135 u16 l2_type;
136 u16 l3_type;
137 u8 n_l2_address_bytes;
138 u8 n_l3_address_bytes;
139 u16 opcode;
Keith Burns (alagalah)e70dcc82016-08-15 18:33:19 -0700140 union
141 {
Ed Warnickecb9cada2015-12-08 15:45:58 -0700142 ethernet_arp_ip4_over_ethernet_address_t ip4_over_ethernet[2];
143
144 /* Others... */
145 u8 data[0];
146 };
147} ethernet_arp_header_t;
148
Neale Rannse98d71b2020-02-24 12:45:53 +0000149#define ARP_SENDER 0
150#define ARP_TARGET 1
151
Neale Rannscbe25aa2019-09-30 10:53:31 +0000152extern u8 *format_ethernet_arp_header (u8 * s, va_list * va);
153extern u8 *format_ethernet_arp_opcode (u8 * s, va_list * va);
154extern u8 *format_ethernet_arp_hardware_type (u8 * s, va_list * va);
John Lo8b81cb42017-06-26 01:40:20 -0400155
Ed Warnickecb9cada2015-12-08 15:45:58 -0700156#endif /* included_ethernet_arp_packet_h */
Keith Burns (alagalah)e70dcc82016-08-15 18:33:19 -0700157
158/*
159 * fd.io coding-style-patch-verification: ON
160 *
161 * Local Variables:
162 * eval: (c-set-style "gnu")
163 * End:
164 */