b4e021cce19e3e4e6343b185ce030c05ccf8f86a
[vpp.git] / src / vnet / ethernet / arp_packet.h
1 /*
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
21 #include <vnet/ethernet/mac_address.h>
22
23 #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
91 typedef enum
92 {
93 #define _(n,f) ETHERNET_ARP_HARDWARE_TYPE_##f = (n),
94   foreach_ethernet_arp_hardware_type
95 #undef _
96 } ethernet_arp_hardware_type_t;
97
98 typedef enum
99 {
100 #define _(f) ETHERNET_ARP_OPCODE_##f,
101   foreach_ethernet_arp_opcode
102 #undef _
103     ETHERNET_ARP_N_OPCODE,
104 } ethernet_arp_opcode_t;
105
106 typedef enum
107 {
108   IP4_ARP_NEXT_DROP,
109   IP4_ARP_N_NEXT,
110 } ip4_arp_next_t;
111
112 typedef enum
113 {
114   IP4_ARP_ERROR_THROTTLED,
115   IP4_ARP_ERROR_RESOLVED,
116   IP4_ARP_ERROR_NO_BUFFERS,
117   IP4_ARP_ERROR_REQUEST_SENT,
118   IP4_ARP_ERROR_NON_ARP_ADJ,
119   IP4_ARP_ERROR_NO_SOURCE_ADDRESS,
120 } ip4_arp_error_t;
121
122 /* *INDENT-OFF* */
123 typedef CLIB_PACKED (struct {
124   mac_address_t mac;
125   ip4_address_t ip4;
126 }) ethernet_arp_ip4_over_ethernet_address_t;
127 /* *INDENT-ON* */
128
129 STATIC_ASSERT (sizeof (ethernet_arp_ip4_over_ethernet_address_t) == 10,
130                "Packet ethernet address and IP4 address too big");
131
132 typedef struct
133 {
134   u16 l2_type;
135   u16 l3_type;
136   u8 n_l2_address_bytes;
137   u8 n_l3_address_bytes;
138   u16 opcode;
139   union
140   {
141     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
148 void send_ip4_garp (vlib_main_t * vm, u32 sw_if_index);
149 void send_ip4_garp_w_addr (vlib_main_t * vm,
150                            const ip4_address_t * ip4_addr, u32 sw_if_index);
151
152 #endif /* included_ethernet_arp_packet_h */
153
154 /*
155  * fd.io coding-style-patch-verification: ON
156  *
157  * Local Variables:
158  * eval: (c-set-style "gnu")
159  * End:
160  */