blob: 27d8cb27eaeab0e21c08c3b064a33a791717bf68 [file] [log] [blame]
Pavel Kotucek3e046ea2016-12-05 08:27:37 +01001/*
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 Barachd7cb1b52016-12-09 09:52:16 -050024typedef struct
25{
Pavel Kotucek3e046ea2016-12-05 08:27:37 +010026 ip6_address_t ip6_address;
27 u32 sw_if_index;
28 u32 pad;
29} ip6_neighbor_key_t;
30
Neale Rannsb3b2de72017-03-08 05:17:22 -080031typedef 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 Barachd7cb1b52016-12-09 09:52:16 -050038typedef struct
39{
Pavel Kotucek3e046ea2016-12-05 08:27:37 +010040 ip6_neighbor_key_t key;
41 u8 link_layer_address[8];
Neale Rannsb3b2de72017-03-08 05:17:22 -080042 ip6_neighbor_flags_t flags;
John Lo7f358b32018-04-28 01:19:24 -040043 f64 time_last_updated;
Pavel Kotucek3e046ea2016-12-05 08:27:37 +010044 fib_node_index_t fib_entry_index;
45} ip6_neighbor_t;
46
John Lo7f358b32018-04-28 01:19:24 -040047extern ip6_neighbor_t *ip6_neighbors_pool (void);
48
Neale Ranns3f844d02017-02-18 00:03:54 -080049extern ip6_neighbor_t *ip6_neighbors_entries (u32 sw_if_index);
50
51extern int ip6_neighbor_ra_config (vlib_main_t * vm, u32 sw_if_index,
52 u8 suppress, u8 managed, u8 other,
53 u8 ll_option, u8 send_unicast, u8 cease,
54 u8 use_lifetime, u32 lifetime,
55 u32 initial_count, u32 initial_interval,
56 u32 max_interval, u32 min_interval,
57 u8 is_no);
58
59extern int ip6_neighbor_ra_prefix (vlib_main_t * vm, u32 sw_if_index,
60 ip6_address_t * prefix_addr, u8 prefix_len,
61 u8 use_default, u32 val_lifetime,
62 u32 pref_lifetime, u8 no_advertise,
63 u8 off_link, u8 no_autoconfig,
64 u8 no_onlink, u8 is_no);
65
66extern clib_error_t *ip6_set_neighbor_limit (u32 neighbor_limit);
67
68extern void vnet_register_ip6_neighbor_resolution_event (vnet_main_t * vnm,
69 void *address_arg,
70 uword node_index,
71 uword type_opaque,
72 uword data);
73
74extern int vnet_set_ip6_ethernet_neighbor (vlib_main_t * vm,
75 u32 sw_if_index,
76 ip6_address_t * a,
77 u8 * link_layer_address,
78 uword n_bytes_link_layer_address,
Neale Rannsb3b2de72017-03-08 05:17:22 -080079 int is_static,
80 int is_no_fib_entry);
Neale Ranns3f844d02017-02-18 00:03:54 -080081
82extern int vnet_unset_ip6_ethernet_neighbor (vlib_main_t * vm,
83 u32 sw_if_index,
84 ip6_address_t * a,
85 u8 * link_layer_address,
86 uword
87 n_bytes_link_layer_address);
88
89extern int ip6_neighbor_proxy_add_del (u32 sw_if_index,
90 ip6_address_t * addr, u8 is_add);
Pavel Kotucek3e046ea2016-12-05 08:27:37 +010091
Pavel Kotucek9f5a2b62017-06-14 13:56:55 +020092u32 ip6_neighbor_sw_interface_add_del (vnet_main_t * vnm, u32 sw_if_index,
93 u32 is_add);
Eyal Baric125ecc2017-09-20 11:29:17 +030094typedef struct
95{
96 u32 sw_if_index;
97 ip6_address_t ip6;
98 u8 mac[6];
99} wc_nd_report_t;
100
101void wc_nd_set_publisher_node (uword node_index, uword event_type);
Pavel Kotucek9f5a2b62017-06-14 13:56:55 +0200102
Juraj Sloboda4b9669d2018-01-15 10:39:21 +0100103typedef struct
104{
105 u32 irt;
106 u32 mrt;
107 u32 mrc;
108 u32 mrd;
109} icmp6_send_router_solicitation_params_t;
110
111void icmp6_send_router_solicitation (vlib_main_t * vm, u32 sw_if_index,
112 u8 stop,
113 icmp6_send_router_solicitation_params_t *
114 params);
115
116typedef struct
117{
118 ip6_address_t dst_address;
119 u8 dst_address_length;
120 u8 flags;
121 u32 valid_time;
122 u32 preferred_time;
123} ra_report_prefix_info_t;
124
125typedef struct
126{
127 u32 sw_if_index;
128 u8 router_address[16];
129 u8 current_hop_limit;
130 u8 flags;
131 u16 router_lifetime_in_sec;
132 u32 neighbor_reachable_time_in_msec;
133 u32 time_in_msec_between_retransmitted_neighbor_solicitations;
134 u8 slla[6];
135 u32 mtu;
136 ra_report_prefix_info_t *prefixes;
137} ra_report_t;
138
139void ra_set_publisher_node (uword node_index, uword event_type);
140
Juraj Sloboda52574522018-05-03 10:03:50 +0200141typedef struct _vnet_ip6_neighbor_function_list_elt
142{
143 struct _vnet_ip6_neighbor_function_list_elt *next_ip6_neighbor_function;
144 clib_error_t *(*fp) (void *data);
145} _vnet_ip6_neighbor_function_list_elt_t;
146
147typedef struct
148{
149 _vnet_ip6_neighbor_function_list_elt_t *ra_report_functions;
150} ip6_neighbor_public_main_t;
151
152extern ip6_neighbor_public_main_t ip6_neighbor_public_main;
153
154#define _VNET_IP6_NEIGHBOR_FUNCTION_DECL(f,tag) \
155 \
156static void __vnet_ip6_neighbor_function_init_##tag##_##f (void) \
157 __attribute__((__constructor__)) ; \
158 \
159static void __vnet_ip6_neighbor_function_init_##tag##_##f (void) \
160{ \
161 ip6_neighbor_public_main_t * nm = &ip6_neighbor_public_main; \
162 static _vnet_ip6_neighbor_function_list_elt_t init_function; \
163 init_function.next_ip6_neighbor_function = nm->tag##_functions; \
164 nm->tag##_functions = &init_function; \
165 init_function.fp = (void *) &f; \
166} \
167 \
168static void __vnet_ip6_neighbor_function_deinit_##tag##_##f (void) \
169 __attribute__((__destructor__)) ; \
170 \
171static void __vnet_ip6_neighbor_function_deinit_##tag##_##f (void) \
172{ \
173 ip6_neighbor_public_main_t * nm = &ip6_neighbor_public_main; \
174 _vnet_ip6_neighbor_function_list_elt_t *next; \
175 if (nm->tag##_functions->fp == (void *) &f) \
176 { \
177 nm->tag##_functions = \
178 nm->tag##_functions->next_ip6_neighbor_function; \
179 return; \
180 } \
181 next = nm->tag##_functions; \
182 while (next->next_ip6_neighbor_function) \
183 { \
184 if (next->next_ip6_neighbor_function->fp == (void *) &f) \
185 { \
186 next->next_ip6_neighbor_function = \
187 next->next_ip6_neighbor_function->next_ip6_neighbor_function; \
188 return; \
189 } \
190 next = next->next_ip6_neighbor_function; \
191 } \
192}
193
194#define VNET_IP6_NEIGHBOR_RA_FUNCTION(f) \
195 _VNET_IP6_NEIGHBOR_FUNCTION_DECL(f,ra_report)
196
197clib_error_t *call_ip6_neighbor_callbacks (void *data,
198 _vnet_ip6_neighbor_function_list_elt_t
199 * elt);
200
Dave Barachd7cb1b52016-12-09 09:52:16 -0500201#endif /* included_ip6_neighbor_h */
202
203/*
204 * fd.io coding-style-patch-verification: ON
205 *
206 * Local Variables:
207 * eval: (c-set-style "gnu")
208 * End:
209 */