Pavel Kotucek | 3e046ea | 2016-12-05 08:27:37 +0100 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * ip6_neighboor.h: ip6 neighbor structures |
| 4 | * |
| 5 | * Copyright (c) 2016 Cisco and/or its affiliates. |
| 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at: |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
| 17 | */ |
| 18 | |
| 19 | #ifndef included_ip6_neighbor_h |
| 20 | #define included_ip6_neighbor_h |
| 21 | |
| 22 | #include <vnet/fib/fib_types.h> |
| 23 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 24 | typedef struct |
| 25 | { |
Pavel Kotucek | 3e046ea | 2016-12-05 08:27:37 +0100 | [diff] [blame] | 26 | ip6_address_t ip6_address; |
| 27 | u32 sw_if_index; |
| 28 | u32 pad; |
| 29 | } ip6_neighbor_key_t; |
| 30 | |
Neale Ranns | b3b2de7 | 2017-03-08 05:17:22 -0800 | [diff] [blame] | 31 | typedef enum ip6_neighbor_flags_t_ |
| 32 | { |
| 33 | IP6_NEIGHBOR_FLAG_STATIC = (1 << 0), |
| 34 | IP6_NEIGHBOR_FLAG_DYNAMIC = (1 << 1), |
| 35 | IP6_NEIGHBOR_FLAG_NO_FIB_ENTRY = (1 << 2), |
| 36 | } __attribute__ ((packed)) ip6_neighbor_flags_t; |
| 37 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 38 | typedef struct |
| 39 | { |
Pavel Kotucek | 3e046ea | 2016-12-05 08:27:37 +0100 | [diff] [blame] | 40 | ip6_neighbor_key_t key; |
| 41 | u8 link_layer_address[8]; |
Neale Ranns | b3b2de7 | 2017-03-08 05:17:22 -0800 | [diff] [blame] | 42 | ip6_neighbor_flags_t flags; |
John Lo | 7f358b3 | 2018-04-28 01:19:24 -0400 | [diff] [blame] | 43 | f64 time_last_updated; |
Pavel Kotucek | 3e046ea | 2016-12-05 08:27:37 +0100 | [diff] [blame] | 44 | fib_node_index_t fib_entry_index; |
| 45 | } ip6_neighbor_t; |
| 46 | |
Juraj Sloboda | 81119e8 | 2018-05-25 14:02:20 +0200 | [diff] [blame] | 47 | extern ip6_address_t ip6_neighbor_get_link_local_address (u32 sw_if_index); |
| 48 | |
Juraj Sloboda | 5bb1eca | 2018-10-22 09:57:13 +0200 | [diff] [blame] | 49 | extern clib_error_t *ip6_neighbor_set_link_local_address (vlib_main_t * vm, |
| 50 | u32 sw_if_index, |
| 51 | ip6_address_t * |
| 52 | address); |
| 53 | |
John Lo | 7f358b3 | 2018-04-28 01:19:24 -0400 | [diff] [blame] | 54 | extern ip6_neighbor_t *ip6_neighbors_pool (void); |
| 55 | |
Neale Ranns | 3f844d0 | 2017-02-18 00:03:54 -0800 | [diff] [blame] | 56 | extern ip6_neighbor_t *ip6_neighbors_entries (u32 sw_if_index); |
| 57 | |
| 58 | extern int ip6_neighbor_ra_config (vlib_main_t * vm, u32 sw_if_index, |
| 59 | u8 suppress, u8 managed, u8 other, |
| 60 | u8 ll_option, u8 send_unicast, u8 cease, |
| 61 | u8 use_lifetime, u32 lifetime, |
| 62 | u32 initial_count, u32 initial_interval, |
| 63 | u32 max_interval, u32 min_interval, |
| 64 | u8 is_no); |
| 65 | |
| 66 | extern int ip6_neighbor_ra_prefix (vlib_main_t * vm, u32 sw_if_index, |
| 67 | ip6_address_t * prefix_addr, u8 prefix_len, |
| 68 | u8 use_default, u32 val_lifetime, |
| 69 | u32 pref_lifetime, u8 no_advertise, |
| 70 | u8 off_link, u8 no_autoconfig, |
| 71 | u8 no_onlink, u8 is_no); |
| 72 | |
| 73 | extern clib_error_t *ip6_set_neighbor_limit (u32 neighbor_limit); |
| 74 | |
| 75 | extern void vnet_register_ip6_neighbor_resolution_event (vnet_main_t * vnm, |
| 76 | void *address_arg, |
| 77 | uword node_index, |
| 78 | uword type_opaque, |
| 79 | uword data); |
| 80 | |
| 81 | extern int vnet_set_ip6_ethernet_neighbor (vlib_main_t * vm, |
| 82 | u32 sw_if_index, |
Neale Ranns | 0bdd319 | 2018-09-07 11:04:52 -0700 | [diff] [blame] | 83 | const ip6_address_t * a, |
| 84 | const u8 * link_layer_address, |
Neale Ranns | 3f844d0 | 2017-02-18 00:03:54 -0800 | [diff] [blame] | 85 | uword n_bytes_link_layer_address, |
Neale Ranns | b3b2de7 | 2017-03-08 05:17:22 -0800 | [diff] [blame] | 86 | int is_static, |
| 87 | int is_no_fib_entry); |
Neale Ranns | 3f844d0 | 2017-02-18 00:03:54 -0800 | [diff] [blame] | 88 | |
| 89 | extern int vnet_unset_ip6_ethernet_neighbor (vlib_main_t * vm, |
| 90 | u32 sw_if_index, |
Neale Ranns | 0bdd319 | 2018-09-07 11:04:52 -0700 | [diff] [blame] | 91 | const ip6_address_t * a); |
Neale Ranns | 3f844d0 | 2017-02-18 00:03:54 -0800 | [diff] [blame] | 92 | |
| 93 | extern int ip6_neighbor_proxy_add_del (u32 sw_if_index, |
| 94 | ip6_address_t * addr, u8 is_add); |
Pavel Kotucek | 3e046ea | 2016-12-05 08:27:37 +0100 | [diff] [blame] | 95 | |
Pavel Kotucek | 9f5a2b6 | 2017-06-14 13:56:55 +0200 | [diff] [blame] | 96 | u32 ip6_neighbor_sw_interface_add_del (vnet_main_t * vnm, u32 sw_if_index, |
| 97 | u32 is_add); |
Eyal Bari | c125ecc | 2017-09-20 11:29:17 +0300 | [diff] [blame] | 98 | typedef struct |
| 99 | { |
| 100 | u32 sw_if_index; |
| 101 | ip6_address_t ip6; |
| 102 | u8 mac[6]; |
| 103 | } wc_nd_report_t; |
| 104 | |
| 105 | void wc_nd_set_publisher_node (uword node_index, uword event_type); |
Pavel Kotucek | 9f5a2b6 | 2017-06-14 13:56:55 +0200 | [diff] [blame] | 106 | |
Juraj Sloboda | 4b9669d | 2018-01-15 10:39:21 +0100 | [diff] [blame] | 107 | typedef struct |
| 108 | { |
| 109 | u32 irt; |
| 110 | u32 mrt; |
| 111 | u32 mrc; |
| 112 | u32 mrd; |
| 113 | } icmp6_send_router_solicitation_params_t; |
| 114 | |
| 115 | void icmp6_send_router_solicitation (vlib_main_t * vm, u32 sw_if_index, |
| 116 | u8 stop, |
| 117 | icmp6_send_router_solicitation_params_t * |
| 118 | params); |
| 119 | |
| 120 | typedef struct |
| 121 | { |
| 122 | ip6_address_t dst_address; |
| 123 | u8 dst_address_length; |
| 124 | u8 flags; |
| 125 | u32 valid_time; |
| 126 | u32 preferred_time; |
| 127 | } ra_report_prefix_info_t; |
| 128 | |
| 129 | typedef struct |
| 130 | { |
| 131 | u32 sw_if_index; |
| 132 | u8 router_address[16]; |
| 133 | u8 current_hop_limit; |
| 134 | u8 flags; |
| 135 | u16 router_lifetime_in_sec; |
| 136 | u32 neighbor_reachable_time_in_msec; |
| 137 | u32 time_in_msec_between_retransmitted_neighbor_solicitations; |
| 138 | u8 slla[6]; |
| 139 | u32 mtu; |
| 140 | ra_report_prefix_info_t *prefixes; |
| 141 | } ra_report_t; |
| 142 | |
| 143 | void ra_set_publisher_node (uword node_index, uword event_type); |
| 144 | |
Juraj Sloboda | 5257452 | 2018-05-03 10:03:50 +0200 | [diff] [blame] | 145 | typedef struct _vnet_ip6_neighbor_function_list_elt |
| 146 | { |
| 147 | struct _vnet_ip6_neighbor_function_list_elt *next_ip6_neighbor_function; |
| 148 | clib_error_t *(*fp) (void *data); |
| 149 | } _vnet_ip6_neighbor_function_list_elt_t; |
| 150 | |
| 151 | typedef struct |
| 152 | { |
| 153 | _vnet_ip6_neighbor_function_list_elt_t *ra_report_functions; |
| 154 | } ip6_neighbor_public_main_t; |
| 155 | |
| 156 | extern ip6_neighbor_public_main_t ip6_neighbor_public_main; |
| 157 | |
| 158 | #define _VNET_IP6_NEIGHBOR_FUNCTION_DECL(f,tag) \ |
| 159 | \ |
| 160 | static void __vnet_ip6_neighbor_function_init_##tag##_##f (void) \ |
| 161 | __attribute__((__constructor__)) ; \ |
| 162 | \ |
| 163 | static void __vnet_ip6_neighbor_function_init_##tag##_##f (void) \ |
| 164 | { \ |
| 165 | ip6_neighbor_public_main_t * nm = &ip6_neighbor_public_main; \ |
| 166 | static _vnet_ip6_neighbor_function_list_elt_t init_function; \ |
| 167 | init_function.next_ip6_neighbor_function = nm->tag##_functions; \ |
| 168 | nm->tag##_functions = &init_function; \ |
| 169 | init_function.fp = (void *) &f; \ |
| 170 | } \ |
| 171 | \ |
| 172 | static void __vnet_ip6_neighbor_function_deinit_##tag##_##f (void) \ |
| 173 | __attribute__((__destructor__)) ; \ |
| 174 | \ |
| 175 | static void __vnet_ip6_neighbor_function_deinit_##tag##_##f (void) \ |
| 176 | { \ |
| 177 | ip6_neighbor_public_main_t * nm = &ip6_neighbor_public_main; \ |
| 178 | _vnet_ip6_neighbor_function_list_elt_t *next; \ |
| 179 | if (nm->tag##_functions->fp == (void *) &f) \ |
| 180 | { \ |
| 181 | nm->tag##_functions = \ |
| 182 | nm->tag##_functions->next_ip6_neighbor_function; \ |
| 183 | return; \ |
| 184 | } \ |
| 185 | next = nm->tag##_functions; \ |
| 186 | while (next->next_ip6_neighbor_function) \ |
| 187 | { \ |
| 188 | if (next->next_ip6_neighbor_function->fp == (void *) &f) \ |
| 189 | { \ |
| 190 | next->next_ip6_neighbor_function = \ |
| 191 | next->next_ip6_neighbor_function->next_ip6_neighbor_function; \ |
| 192 | return; \ |
| 193 | } \ |
| 194 | next = next->next_ip6_neighbor_function; \ |
| 195 | } \ |
| 196 | } |
| 197 | |
| 198 | #define VNET_IP6_NEIGHBOR_RA_FUNCTION(f) \ |
| 199 | _VNET_IP6_NEIGHBOR_FUNCTION_DECL(f,ra_report) |
| 200 | |
| 201 | clib_error_t *call_ip6_neighbor_callbacks (void *data, |
| 202 | _vnet_ip6_neighbor_function_list_elt_t |
| 203 | * elt); |
| 204 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 205 | #endif /* included_ip6_neighbor_h */ |
| 206 | |
| 207 | /* |
| 208 | * fd.io coding-style-patch-verification: ON |
| 209 | * |
| 210 | * Local Variables: |
| 211 | * eval: (c-set-style "gnu") |
| 212 | * End: |
| 213 | */ |