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> |
Neale Ranns | 3702930 | 2018-08-10 05:30:06 -0700 | [diff] [blame^] | 23 | #include <vnet/ethernet/mac_address.h> |
| 24 | #include <vnet/ip/ip_neighbor.h> |
Pavel Kotucek | 3e046ea | 2016-12-05 08:27:37 +0100 | [diff] [blame] | 25 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 26 | typedef struct |
| 27 | { |
Pavel Kotucek | 3e046ea | 2016-12-05 08:27:37 +0100 | [diff] [blame] | 28 | ip6_address_t ip6_address; |
| 29 | u32 sw_if_index; |
| 30 | u32 pad; |
| 31 | } ip6_neighbor_key_t; |
| 32 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 33 | typedef struct |
| 34 | { |
Pavel Kotucek | 3e046ea | 2016-12-05 08:27:37 +0100 | [diff] [blame] | 35 | ip6_neighbor_key_t key; |
Neale Ranns | 3702930 | 2018-08-10 05:30:06 -0700 | [diff] [blame^] | 36 | mac_address_t mac; |
| 37 | ip_neighbor_flags_t flags; |
John Lo | 7f358b3 | 2018-04-28 01:19:24 -0400 | [diff] [blame] | 38 | f64 time_last_updated; |
Pavel Kotucek | 3e046ea | 2016-12-05 08:27:37 +0100 | [diff] [blame] | 39 | fib_node_index_t fib_entry_index; |
| 40 | } ip6_neighbor_t; |
| 41 | |
Juraj Sloboda | 81119e8 | 2018-05-25 14:02:20 +0200 | [diff] [blame] | 42 | extern ip6_address_t ip6_neighbor_get_link_local_address (u32 sw_if_index); |
| 43 | |
Juraj Sloboda | 5bb1eca | 2018-10-22 09:57:13 +0200 | [diff] [blame] | 44 | extern clib_error_t *ip6_neighbor_set_link_local_address (vlib_main_t * vm, |
| 45 | u32 sw_if_index, |
| 46 | ip6_address_t * |
| 47 | address); |
| 48 | |
John Lo | 7f358b3 | 2018-04-28 01:19:24 -0400 | [diff] [blame] | 49 | extern ip6_neighbor_t *ip6_neighbors_pool (void); |
| 50 | |
Neale Ranns | 3f844d0 | 2017-02-18 00:03:54 -0800 | [diff] [blame] | 51 | extern ip6_neighbor_t *ip6_neighbors_entries (u32 sw_if_index); |
| 52 | |
| 53 | extern int ip6_neighbor_ra_config (vlib_main_t * vm, u32 sw_if_index, |
| 54 | u8 suppress, u8 managed, u8 other, |
| 55 | u8 ll_option, u8 send_unicast, u8 cease, |
| 56 | u8 use_lifetime, u32 lifetime, |
| 57 | u32 initial_count, u32 initial_interval, |
| 58 | u32 max_interval, u32 min_interval, |
| 59 | u8 is_no); |
| 60 | |
| 61 | extern int ip6_neighbor_ra_prefix (vlib_main_t * vm, u32 sw_if_index, |
| 62 | ip6_address_t * prefix_addr, u8 prefix_len, |
| 63 | u8 use_default, u32 val_lifetime, |
| 64 | u32 pref_lifetime, u8 no_advertise, |
| 65 | u8 off_link, u8 no_autoconfig, |
| 66 | u8 no_onlink, u8 is_no); |
| 67 | |
| 68 | extern clib_error_t *ip6_set_neighbor_limit (u32 neighbor_limit); |
| 69 | |
| 70 | extern void vnet_register_ip6_neighbor_resolution_event (vnet_main_t * vnm, |
| 71 | void *address_arg, |
| 72 | uword node_index, |
| 73 | uword type_opaque, |
| 74 | uword data); |
| 75 | |
| 76 | extern int vnet_set_ip6_ethernet_neighbor (vlib_main_t * vm, |
| 77 | u32 sw_if_index, |
Neale Ranns | 0bdd319 | 2018-09-07 11:04:52 -0700 | [diff] [blame] | 78 | const ip6_address_t * a, |
Neale Ranns | 3702930 | 2018-08-10 05:30:06 -0700 | [diff] [blame^] | 79 | const mac_address_t * mac, |
| 80 | ip_neighbor_flags_t flags); |
Neale Ranns | 3f844d0 | 2017-02-18 00:03:54 -0800 | [diff] [blame] | 81 | |
| 82 | extern int vnet_unset_ip6_ethernet_neighbor (vlib_main_t * vm, |
| 83 | u32 sw_if_index, |
Neale Ranns | 0bdd319 | 2018-09-07 11:04:52 -0700 | [diff] [blame] | 84 | const ip6_address_t * a); |
Neale Ranns | 3f844d0 | 2017-02-18 00:03:54 -0800 | [diff] [blame] | 85 | |
| 86 | extern int ip6_neighbor_proxy_add_del (u32 sw_if_index, |
| 87 | ip6_address_t * addr, u8 is_add); |
Pavel Kotucek | 3e046ea | 2016-12-05 08:27:37 +0100 | [diff] [blame] | 88 | |
Pavel Kotucek | 9f5a2b6 | 2017-06-14 13:56:55 +0200 | [diff] [blame] | 89 | u32 ip6_neighbor_sw_interface_add_del (vnet_main_t * vnm, u32 sw_if_index, |
| 90 | u32 is_add); |
Eyal Bari | c125ecc | 2017-09-20 11:29:17 +0300 | [diff] [blame] | 91 | typedef struct |
| 92 | { |
| 93 | u32 sw_if_index; |
| 94 | ip6_address_t ip6; |
Neale Ranns | 3702930 | 2018-08-10 05:30:06 -0700 | [diff] [blame^] | 95 | mac_address_t mac; |
Eyal Bari | c125ecc | 2017-09-20 11:29:17 +0300 | [diff] [blame] | 96 | } wc_nd_report_t; |
| 97 | |
| 98 | void wc_nd_set_publisher_node (uword node_index, uword event_type); |
Pavel Kotucek | 9f5a2b6 | 2017-06-14 13:56:55 +0200 | [diff] [blame] | 99 | |
Juraj Sloboda | 4b9669d | 2018-01-15 10:39:21 +0100 | [diff] [blame] | 100 | typedef struct |
| 101 | { |
| 102 | u32 irt; |
| 103 | u32 mrt; |
| 104 | u32 mrc; |
| 105 | u32 mrd; |
| 106 | } icmp6_send_router_solicitation_params_t; |
| 107 | |
| 108 | void icmp6_send_router_solicitation (vlib_main_t * vm, u32 sw_if_index, |
| 109 | u8 stop, |
| 110 | icmp6_send_router_solicitation_params_t * |
| 111 | params); |
| 112 | |
| 113 | typedef struct |
| 114 | { |
Neale Ranns | 3702930 | 2018-08-10 05:30:06 -0700 | [diff] [blame^] | 115 | fib_prefix_t prefix; |
Juraj Sloboda | 4b9669d | 2018-01-15 10:39:21 +0100 | [diff] [blame] | 116 | u8 flags; |
| 117 | u32 valid_time; |
| 118 | u32 preferred_time; |
| 119 | } ra_report_prefix_info_t; |
| 120 | |
| 121 | typedef struct |
| 122 | { |
| 123 | u32 sw_if_index; |
Neale Ranns | 3702930 | 2018-08-10 05:30:06 -0700 | [diff] [blame^] | 124 | ip6_address_t router_address; |
Juraj Sloboda | 4b9669d | 2018-01-15 10:39:21 +0100 | [diff] [blame] | 125 | u8 current_hop_limit; |
| 126 | u8 flags; |
| 127 | u16 router_lifetime_in_sec; |
| 128 | u32 neighbor_reachable_time_in_msec; |
| 129 | u32 time_in_msec_between_retransmitted_neighbor_solicitations; |
| 130 | u8 slla[6]; |
| 131 | u32 mtu; |
| 132 | ra_report_prefix_info_t *prefixes; |
| 133 | } ra_report_t; |
| 134 | |
| 135 | void ra_set_publisher_node (uword node_index, uword event_type); |
| 136 | |
Juraj Sloboda | 5257452 | 2018-05-03 10:03:50 +0200 | [diff] [blame] | 137 | typedef struct _vnet_ip6_neighbor_function_list_elt |
| 138 | { |
| 139 | struct _vnet_ip6_neighbor_function_list_elt *next_ip6_neighbor_function; |
| 140 | clib_error_t *(*fp) (void *data); |
| 141 | } _vnet_ip6_neighbor_function_list_elt_t; |
| 142 | |
| 143 | typedef struct |
| 144 | { |
| 145 | _vnet_ip6_neighbor_function_list_elt_t *ra_report_functions; |
| 146 | } ip6_neighbor_public_main_t; |
| 147 | |
| 148 | extern ip6_neighbor_public_main_t ip6_neighbor_public_main; |
| 149 | |
| 150 | #define _VNET_IP6_NEIGHBOR_FUNCTION_DECL(f,tag) \ |
| 151 | \ |
| 152 | static void __vnet_ip6_neighbor_function_init_##tag##_##f (void) \ |
| 153 | __attribute__((__constructor__)) ; \ |
| 154 | \ |
| 155 | static void __vnet_ip6_neighbor_function_init_##tag##_##f (void) \ |
| 156 | { \ |
| 157 | ip6_neighbor_public_main_t * nm = &ip6_neighbor_public_main; \ |
| 158 | static _vnet_ip6_neighbor_function_list_elt_t init_function; \ |
| 159 | init_function.next_ip6_neighbor_function = nm->tag##_functions; \ |
| 160 | nm->tag##_functions = &init_function; \ |
| 161 | init_function.fp = (void *) &f; \ |
| 162 | } \ |
| 163 | \ |
| 164 | static void __vnet_ip6_neighbor_function_deinit_##tag##_##f (void) \ |
| 165 | __attribute__((__destructor__)) ; \ |
| 166 | \ |
| 167 | static void __vnet_ip6_neighbor_function_deinit_##tag##_##f (void) \ |
| 168 | { \ |
| 169 | ip6_neighbor_public_main_t * nm = &ip6_neighbor_public_main; \ |
| 170 | _vnet_ip6_neighbor_function_list_elt_t *next; \ |
| 171 | if (nm->tag##_functions->fp == (void *) &f) \ |
| 172 | { \ |
| 173 | nm->tag##_functions = \ |
| 174 | nm->tag##_functions->next_ip6_neighbor_function; \ |
| 175 | return; \ |
| 176 | } \ |
| 177 | next = nm->tag##_functions; \ |
| 178 | while (next->next_ip6_neighbor_function) \ |
| 179 | { \ |
| 180 | if (next->next_ip6_neighbor_function->fp == (void *) &f) \ |
| 181 | { \ |
| 182 | next->next_ip6_neighbor_function = \ |
| 183 | next->next_ip6_neighbor_function->next_ip6_neighbor_function; \ |
| 184 | return; \ |
| 185 | } \ |
| 186 | next = next->next_ip6_neighbor_function; \ |
| 187 | } \ |
| 188 | } |
| 189 | |
| 190 | #define VNET_IP6_NEIGHBOR_RA_FUNCTION(f) \ |
| 191 | _VNET_IP6_NEIGHBOR_FUNCTION_DECL(f,ra_report) |
| 192 | |
| 193 | clib_error_t *call_ip6_neighbor_callbacks (void *data, |
| 194 | _vnet_ip6_neighbor_function_list_elt_t |
| 195 | * elt); |
| 196 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 197 | #endif /* included_ip6_neighbor_h */ |
| 198 | |
| 199 | /* |
| 200 | * fd.io coding-style-patch-verification: ON |
| 201 | * |
| 202 | * Local Variables: |
| 203 | * eval: (c-set-style "gnu") |
| 204 | * End: |
| 205 | */ |