Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 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 | |
Neale Ranns | 3702930 | 2018-08-10 05:30:06 -0700 | [diff] [blame] | 21 | #include <vnet/ethernet/mac_address.h> |
| 22 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 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 | |
Keith Burns (alagalah) | e70dcc8 | 2016-08-15 18:33:19 -0700 | [diff] [blame] | 91 | typedef enum |
| 92 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 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 | |
Keith Burns (alagalah) | e70dcc8 | 2016-08-15 18:33:19 -0700 | [diff] [blame] | 98 | typedef enum |
| 99 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 100 | #define _(f) ETHERNET_ARP_OPCODE_##f, |
| 101 | foreach_ethernet_arp_opcode |
| 102 | #undef _ |
Keith Burns (alagalah) | e70dcc8 | 2016-08-15 18:33:19 -0700 | [diff] [blame] | 103 | ETHERNET_ARP_N_OPCODE, |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 104 | } ethernet_arp_opcode_t; |
| 105 | |
Keith Burns (alagalah) | e70dcc8 | 2016-08-15 18:33:19 -0700 | [diff] [blame] | 106 | typedef enum |
| 107 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 108 | IP4_ARP_NEXT_DROP, |
| 109 | IP4_ARP_N_NEXT, |
| 110 | } ip4_arp_next_t; |
| 111 | |
Keith Burns (alagalah) | e70dcc8 | 2016-08-15 18:33:19 -0700 | [diff] [blame] | 112 | typedef enum |
| 113 | { |
Eyal Bari | bf9f02c | 2018-10-31 13:19:11 +0200 | [diff] [blame] | 114 | IP4_ARP_ERROR_THROTTLED, |
| 115 | IP4_ARP_ERROR_RESOLVED, |
| 116 | IP4_ARP_ERROR_NO_BUFFERS, |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 117 | IP4_ARP_ERROR_REQUEST_SENT, |
| 118 | IP4_ARP_ERROR_NON_ARP_ADJ, |
Pierre Pfister | d076f19 | 2016-06-22 12:58:30 +0100 | [diff] [blame] | 119 | IP4_ARP_ERROR_NO_SOURCE_ADDRESS, |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 120 | } ip4_arp_error_t; |
| 121 | |
Keith Burns (alagalah) | e70dcc8 | 2016-08-15 18:33:19 -0700 | [diff] [blame] | 122 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 123 | typedef CLIB_PACKED (struct { |
Neale Ranns | 3702930 | 2018-08-10 05:30:06 -0700 | [diff] [blame] | 124 | mac_address_t mac; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 125 | ip4_address_t ip4; |
| 126 | }) ethernet_arp_ip4_over_ethernet_address_t; |
Keith Burns (alagalah) | e70dcc8 | 2016-08-15 18:33:19 -0700 | [diff] [blame] | 127 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 128 | |
Neale Ranns | 3702930 | 2018-08-10 05:30:06 -0700 | [diff] [blame] | 129 | STATIC_ASSERT (sizeof (ethernet_arp_ip4_over_ethernet_address_t) == 10, |
| 130 | "Packet ethernet address and IP4 address too big"); |
| 131 | |
Keith Burns (alagalah) | e70dcc8 | 2016-08-15 18:33:19 -0700 | [diff] [blame] | 132 | typedef struct |
| 133 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 134 | 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) | e70dcc8 | 2016-08-15 18:33:19 -0700 | [diff] [blame] | 139 | union |
| 140 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 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 | |
Steven | 9f781d8 | 2018-06-05 11:09:32 -0700 | [diff] [blame] | 148 | void send_ip4_garp (vlib_main_t * vm, u32 sw_if_index); |
Neale Ranns | 25b0494 | 2018-04-04 09:34:50 -0700 | [diff] [blame] | 149 | void send_ip4_garp_w_addr (vlib_main_t * vm, |
Steven | 9f781d8 | 2018-06-05 11:09:32 -0700 | [diff] [blame] | 150 | const ip4_address_t * ip4_addr, u32 sw_if_index); |
John Lo | 8b81cb4 | 2017-06-26 01:40:20 -0400 | [diff] [blame] | 151 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 152 | #endif /* included_ethernet_arp_packet_h */ |
Keith Burns (alagalah) | e70dcc8 | 2016-08-15 18:33:19 -0700 | [diff] [blame] | 153 | |
| 154 | /* |
| 155 | * fd.io coding-style-patch-verification: ON |
| 156 | * |
| 157 | * Local Variables: |
| 158 | * eval: (c-set-style "gnu") |
| 159 | * End: |
| 160 | */ |