blob: b346563c83b826e825255a21f97dc9215fa483ca [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
Juraj Sloboda81119e82018-05-25 14:02:20 +020047extern ip6_address_t ip6_neighbor_get_link_local_address (u32 sw_if_index);
48
John Lo7f358b32018-04-28 01:19:24 -040049extern ip6_neighbor_t *ip6_neighbors_pool (void);
50
Neale Ranns3f844d02017-02-18 00:03:54 -080051extern ip6_neighbor_t *ip6_neighbors_entries (u32 sw_if_index);
52
53extern 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
61extern 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
68extern clib_error_t *ip6_set_neighbor_limit (u32 neighbor_limit);
69
70extern 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
76extern int vnet_set_ip6_ethernet_neighbor (vlib_main_t * vm,
77 u32 sw_if_index,
78 ip6_address_t * a,
79 u8 * link_layer_address,
80 uword n_bytes_link_layer_address,
Neale Rannsb3b2de72017-03-08 05:17:22 -080081 int is_static,
82 int is_no_fib_entry);
Neale Ranns3f844d02017-02-18 00:03:54 -080083
84extern int vnet_unset_ip6_ethernet_neighbor (vlib_main_t * vm,
85 u32 sw_if_index,
86 ip6_address_t * a,
87 u8 * link_layer_address,
88 uword
89 n_bytes_link_layer_address);
90
91extern int ip6_neighbor_proxy_add_del (u32 sw_if_index,
92 ip6_address_t * addr, u8 is_add);
Pavel Kotucek3e046ea2016-12-05 08:27:37 +010093
Pavel Kotucek9f5a2b62017-06-14 13:56:55 +020094u32 ip6_neighbor_sw_interface_add_del (vnet_main_t * vnm, u32 sw_if_index,
95 u32 is_add);
Eyal Baric125ecc2017-09-20 11:29:17 +030096typedef struct
97{
98 u32 sw_if_index;
99 ip6_address_t ip6;
100 u8 mac[6];
101} wc_nd_report_t;
102
103void wc_nd_set_publisher_node (uword node_index, uword event_type);
Pavel Kotucek9f5a2b62017-06-14 13:56:55 +0200104
Juraj Sloboda4b9669d2018-01-15 10:39:21 +0100105typedef struct
106{
107 u32 irt;
108 u32 mrt;
109 u32 mrc;
110 u32 mrd;
111} icmp6_send_router_solicitation_params_t;
112
113void icmp6_send_router_solicitation (vlib_main_t * vm, u32 sw_if_index,
114 u8 stop,
115 icmp6_send_router_solicitation_params_t *
116 params);
117
118typedef struct
119{
120 ip6_address_t dst_address;
121 u8 dst_address_length;
122 u8 flags;
123 u32 valid_time;
124 u32 preferred_time;
125} ra_report_prefix_info_t;
126
127typedef struct
128{
129 u32 sw_if_index;
130 u8 router_address[16];
131 u8 current_hop_limit;
132 u8 flags;
133 u16 router_lifetime_in_sec;
134 u32 neighbor_reachable_time_in_msec;
135 u32 time_in_msec_between_retransmitted_neighbor_solicitations;
136 u8 slla[6];
137 u32 mtu;
138 ra_report_prefix_info_t *prefixes;
139} ra_report_t;
140
141void ra_set_publisher_node (uword node_index, uword event_type);
142
Juraj Sloboda52574522018-05-03 10:03:50 +0200143typedef struct _vnet_ip6_neighbor_function_list_elt
144{
145 struct _vnet_ip6_neighbor_function_list_elt *next_ip6_neighbor_function;
146 clib_error_t *(*fp) (void *data);
147} _vnet_ip6_neighbor_function_list_elt_t;
148
149typedef struct
150{
151 _vnet_ip6_neighbor_function_list_elt_t *ra_report_functions;
152} ip6_neighbor_public_main_t;
153
154extern ip6_neighbor_public_main_t ip6_neighbor_public_main;
155
156#define _VNET_IP6_NEIGHBOR_FUNCTION_DECL(f,tag) \
157 \
158static void __vnet_ip6_neighbor_function_init_##tag##_##f (void) \
159 __attribute__((__constructor__)) ; \
160 \
161static void __vnet_ip6_neighbor_function_init_##tag##_##f (void) \
162{ \
163 ip6_neighbor_public_main_t * nm = &ip6_neighbor_public_main; \
164 static _vnet_ip6_neighbor_function_list_elt_t init_function; \
165 init_function.next_ip6_neighbor_function = nm->tag##_functions; \
166 nm->tag##_functions = &init_function; \
167 init_function.fp = (void *) &f; \
168} \
169 \
170static void __vnet_ip6_neighbor_function_deinit_##tag##_##f (void) \
171 __attribute__((__destructor__)) ; \
172 \
173static void __vnet_ip6_neighbor_function_deinit_##tag##_##f (void) \
174{ \
175 ip6_neighbor_public_main_t * nm = &ip6_neighbor_public_main; \
176 _vnet_ip6_neighbor_function_list_elt_t *next; \
177 if (nm->tag##_functions->fp == (void *) &f) \
178 { \
179 nm->tag##_functions = \
180 nm->tag##_functions->next_ip6_neighbor_function; \
181 return; \
182 } \
183 next = nm->tag##_functions; \
184 while (next->next_ip6_neighbor_function) \
185 { \
186 if (next->next_ip6_neighbor_function->fp == (void *) &f) \
187 { \
188 next->next_ip6_neighbor_function = \
189 next->next_ip6_neighbor_function->next_ip6_neighbor_function; \
190 return; \
191 } \
192 next = next->next_ip6_neighbor_function; \
193 } \
194}
195
196#define VNET_IP6_NEIGHBOR_RA_FUNCTION(f) \
197 _VNET_IP6_NEIGHBOR_FUNCTION_DECL(f,ra_report)
198
199clib_error_t *call_ip6_neighbor_callbacks (void *data,
200 _vnet_ip6_neighbor_function_list_elt_t
201 * elt);
202
Dave Barachd7cb1b52016-12-09 09:52:16 -0500203#endif /* included_ip6_neighbor_h */
204
205/*
206 * fd.io coding-style-patch-verification: ON
207 *
208 * Local Variables:
209 * eval: (c-set-style "gnu")
210 * End:
211 */