blob: b4e021cce19e3e4e6343b185ce030c05ccf8f86a [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 Ranns37029302018-08-10 05:30:06 -070021#include <vnet/ethernet/mac_address.h>
22
Ed Warnickecb9cada2015-12-08 15:45:58 -070023#define foreach_ethernet_arp_hardware_type \
24 _ (0, reserved) \
25 _ (1, ethernet) \
26 _ (2, experimental_ethernet) \
27 _ (3, ax_25) \
28 _ (4, proteon_pronet_token_ring) \
29 _ (5, chaos) \
30 _ (6, ieee_802) \
31 _ (7, arcnet) \
32 _ (8, hyperchannel) \
33 _ (9, lanstar) \
34 _ (10, autonet) \
35 _ (11, localtalk) \
36 _ (12, localnet) \
37 _ (13, ultra_link) \
38 _ (14, smds) \
39 _ (15, frame_relay) \
40 _ (16, atm) \
41 _ (17, hdlc) \
42 _ (18, fibre_channel) \
43 _ (19, atm19) \
44 _ (20, serial_line) \
45 _ (21, atm21) \
46 _ (22, mil_std_188_220) \
47 _ (23, metricom) \
48 _ (24, ieee_1394) \
49 _ (25, mapos) \
50 _ (26, twinaxial) \
51 _ (27, eui_64) \
52 _ (28, hiparp) \
53 _ (29, iso_7816_3) \
54 _ (30, arpsec) \
55 _ (31, ipsec_tunnel) \
56 _ (32, infiniband) \
57 _ (33, cai) \
58 _ (34, wiegand) \
59 _ (35, pure_ip) \
60 _ (36, hw_exp1) \
61 _ (256, hw_exp2)
62
63#define foreach_ethernet_arp_opcode \
64 _ (reserved) \
65 _ (request) \
66 _ (reply) \
67 _ (reverse_request) \
68 _ (reverse_reply) \
69 _ (drarp_request) \
70 _ (drarp_reply) \
71 _ (drarp_error) \
72 _ (inarp_request) \
73 _ (inarp_reply) \
74 _ (arp_nak) \
75 _ (mars_request) \
76 _ (mars_multi) \
77 _ (mars_mserv) \
78 _ (mars_join) \
79 _ (mars_leave) \
80 _ (mars_nak) \
81 _ (mars_unserv) \
82 _ (mars_sjoin) \
83 _ (mars_sleave) \
84 _ (mars_grouplist_request) \
85 _ (mars_grouplist_reply) \
86 _ (mars_redirect_map) \
87 _ (mapos_unarp) \
88 _ (exp1) \
89 _ (exp2)
90
Keith Burns (alagalah)e70dcc82016-08-15 18:33:19 -070091typedef enum
92{
Ed Warnickecb9cada2015-12-08 15:45:58 -070093#define _(n,f) ETHERNET_ARP_HARDWARE_TYPE_##f = (n),
94 foreach_ethernet_arp_hardware_type
95#undef _
96} ethernet_arp_hardware_type_t;
97
Keith Burns (alagalah)e70dcc82016-08-15 18:33:19 -070098typedef enum
99{
Ed Warnickecb9cada2015-12-08 15:45:58 -0700100#define _(f) ETHERNET_ARP_OPCODE_##f,
101 foreach_ethernet_arp_opcode
102#undef _
Keith Burns (alagalah)e70dcc82016-08-15 18:33:19 -0700103 ETHERNET_ARP_N_OPCODE,
Ed Warnickecb9cada2015-12-08 15:45:58 -0700104} ethernet_arp_opcode_t;
105
Keith Burns (alagalah)e70dcc82016-08-15 18:33:19 -0700106typedef enum
107{
Ed Warnickecb9cada2015-12-08 15:45:58 -0700108 IP4_ARP_NEXT_DROP,
109 IP4_ARP_N_NEXT,
110} ip4_arp_next_t;
111
Keith Burns (alagalah)e70dcc82016-08-15 18:33:19 -0700112typedef enum
113{
Eyal Baribf9f02c2018-10-31 13:19:11 +0200114 IP4_ARP_ERROR_THROTTLED,
115 IP4_ARP_ERROR_RESOLVED,
116 IP4_ARP_ERROR_NO_BUFFERS,
Ed Warnickecb9cada2015-12-08 15:45:58 -0700117 IP4_ARP_ERROR_REQUEST_SENT,
118 IP4_ARP_ERROR_NON_ARP_ADJ,
Pierre Pfisterd076f192016-06-22 12:58:30 +0100119 IP4_ARP_ERROR_NO_SOURCE_ADDRESS,
Ed Warnickecb9cada2015-12-08 15:45:58 -0700120} ip4_arp_error_t;
121
Keith Burns (alagalah)e70dcc82016-08-15 18:33:19 -0700122/* *INDENT-OFF* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700123typedef CLIB_PACKED (struct {
Neale Ranns37029302018-08-10 05:30:06 -0700124 mac_address_t mac;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700125 ip4_address_t ip4;
126}) ethernet_arp_ip4_over_ethernet_address_t;
Keith Burns (alagalah)e70dcc82016-08-15 18:33:19 -0700127/* *INDENT-ON* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700128
Neale Ranns37029302018-08-10 05:30:06 -0700129STATIC_ASSERT (sizeof (ethernet_arp_ip4_over_ethernet_address_t) == 10,
130 "Packet ethernet address and IP4 address too big");
131
Keith Burns (alagalah)e70dcc82016-08-15 18:33:19 -0700132typedef struct
133{
Ed Warnickecb9cada2015-12-08 15:45:58 -0700134 u16 l2_type;
135 u16 l3_type;
136 u8 n_l2_address_bytes;
137 u8 n_l3_address_bytes;
138 u16 opcode;
Keith Burns (alagalah)e70dcc82016-08-15 18:33:19 -0700139 union
140 {
Ed Warnickecb9cada2015-12-08 15:45:58 -0700141 ethernet_arp_ip4_over_ethernet_address_t ip4_over_ethernet[2];
142
143 /* Others... */
144 u8 data[0];
145 };
146} ethernet_arp_header_t;
147
Steven9f781d82018-06-05 11:09:32 -0700148void send_ip4_garp (vlib_main_t * vm, u32 sw_if_index);
Neale Ranns25b04942018-04-04 09:34:50 -0700149void send_ip4_garp_w_addr (vlib_main_t * vm,
Steven9f781d82018-06-05 11:09:32 -0700150 const ip4_address_t * ip4_addr, u32 sw_if_index);
John Lo8b81cb42017-06-26 01:40:20 -0400151
Ed Warnickecb9cada2015-12-08 15:45:58 -0700152#endif /* included_ethernet_arp_packet_h */
Keith Burns (alagalah)e70dcc82016-08-15 18:33:19 -0700153
154/*
155 * fd.io coding-style-patch-verification: ON
156 *
157 * Local Variables:
158 * eval: (c-set-style "gnu")
159 * End:
160 */