blob: 958845b0a555f5f53365198682fe7ebd1706036f [file] [log] [blame]
Neale Rannscbe25aa2019-09-30 10:53:31 +00001/*
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 __IP6_RA_H__
20#define __IP6_RA_H__
21
22#include <vnet/fib/fib_types.h>
23
Alexander Chernavin3b28fd72023-02-02 14:22:56 +000024/* advertised prefix option */
25typedef struct
26{
27 /* basic advertised information */
28 ip6_address_t prefix;
29 u8 prefix_len;
30 int adv_on_link_flag;
31 int adv_autonomous_flag;
32 u32 adv_valid_lifetime_in_secs;
33 u32 adv_pref_lifetime_in_secs;
34
35 /* advertised values are computed from these times if decrementing */
36 f64 valid_lifetime_expires;
37 f64 pref_lifetime_expires;
38
39 /* local information */
40 int enabled;
41 int deprecated_prefix_flag;
42 int decrement_lifetime_flag;
43
44#define MIN_ADV_VALID_LIFETIME 7203 /* seconds */
45#define DEF_ADV_VALID_LIFETIME 2592000
46#define DEF_ADV_PREF_LIFETIME 604800
47
48 /* extensions are added here, mobile, DNS etc.. */
49} ip6_radv_prefix_t;
50
51typedef struct
52{
53 u32 irt;
54 u32 mrt;
55 u32 mrc;
56 u32 mrd;
57} icmp6_send_router_solicitation_params_t;
58
59typedef struct ip6_ra_t_
60{
61 /* advertised config information, zero means unspecified */
62 u8 curr_hop_limit;
63 int adv_managed_flag;
64 int adv_other_flag;
65 u16 adv_router_lifetime_in_sec;
66 u32 adv_neighbor_reachable_time_in_msec;
67 u32 adv_time_in_msec_between_retransmitted_neighbor_solicitations;
68
69 /* mtu option */
70 u32 adv_link_mtu;
71
72 /* local information */
73 u32 sw_if_index;
74 int send_radv; /* radv on/off on this interface - set by config */
75 int cease_radv; /* we are ceasing to send - set byf config */
76 int send_unicast;
77 int adv_link_layer_address;
78 int prefix_option;
79 int failed_device_check;
80 int ref_count;
81
82 /* prefix option */
83 ip6_radv_prefix_t *adv_prefixes_pool;
84
85 /* Hash table mapping address to index in interface advertised prefix pool.
86 */
87 mhash_t address_to_prefix_index;
88
89 f64 max_radv_interval;
90 f64 min_radv_interval;
91 f64 min_delay_between_radv;
92 f64 max_delay_between_radv;
93 f64 max_rtr_default_lifetime;
94
95 f64 last_radv_time;
96 f64 last_multicast_time;
97 f64 next_multicast_time;
98
99 u32 initial_adverts_count;
100 f64 initial_adverts_interval;
101 u32 initial_adverts_sent;
102
103 /* stats */
104 u32 n_advertisements_sent;
105 u32 n_solicitations_rcvd;
106 u32 n_solicitations_dropped;
107
108 /* router solicitations sending state */
109 u8 keep_sending_rs; /* when true then next fields are valid */
110 icmp6_send_router_solicitation_params_t params;
111 f64 sleep_interval;
112 f64 due_time;
113 u32 n_left;
114 f64 start_time;
115 vlib_buffer_t *buffer;
116
117 u32 seed;
118
119} ip6_ra_t;
120
121extern ip6_ra_t *ip6_ra_get_itf (u32 sw_if_index);
122
Neale Rannscbe25aa2019-09-30 10:53:31 +0000123extern int ip6_ra_config (vlib_main_t * vm, u32 sw_if_index,
124 u8 suppress, u8 managed, u8 other,
125 u8 ll_option, u8 send_unicast, u8 cease,
126 u8 use_lifetime, u32 lifetime,
127 u32 initial_count, u32 initial_interval,
128 u32 max_interval, u32 min_interval, u8 is_no);
129
130extern int ip6_ra_prefix (vlib_main_t * vm, u32 sw_if_index,
131 ip6_address_t * prefix_addr, u8 prefix_len,
132 u8 use_default, u32 val_lifetime,
133 u32 pref_lifetime, u8 no_advertise,
134 u8 off_link, u8 no_autoconfig,
135 u8 no_onlink, u8 is_no);
136
Alexander Chernavin3b28fd72023-02-02 14:22:56 +0000137typedef walk_rc_t (*ip6_ra_itf_walk_fn_t) (u32 sw_if_index, void *ctx);
138
139extern void ip6_ra_itf_walk (ip6_ra_itf_walk_fn_t fn, void *ctx);
Neale Rannscbe25aa2019-09-30 10:53:31 +0000140
141extern void icmp6_send_router_solicitation (vlib_main_t * vm,
142 u32 sw_if_index,
143 u8 stop,
144 const
145 icmp6_send_router_solicitation_params_t
146 * params);
147
148typedef struct
149{
150 fib_prefix_t prefix;
151 u8 flags;
152 u32 valid_time;
153 u32 preferred_time;
154} ra_report_prefix_info_t;
155
156typedef struct
157{
158 ip6_address_t router_address;
159 u32 sw_if_index;
160 u8 current_hop_limit;
161 u8 flags;
162 u16 router_lifetime_in_sec;
163 u32 neighbor_reachable_time_in_msec;
164 u32 time_in_msec_between_retransmitted_neighbor_solicitations;
165 u8 slla[6];
166 u32 mtu;
167 ra_report_prefix_info_t *prefixes;
168} ip6_ra_report_t;
169
170
171typedef void (*ip6_ra_report_notify_t) (const ip6_ra_report_t * rap);
172
173extern void ip6_ra_report_register (ip6_ra_report_notify_t fn);
174extern void ip6_ra_report_unregister (ip6_ra_report_notify_t fn);
Dave Barachd1586962020-02-20 16:17:58 -0500175extern void ip6_ra_update_secondary_radv_info (ip6_address_t * address,
176 u8 prefix_len,
177 u32 primary_sw_if_index,
178 u32 valid_time,
179 u32 preferred_time);
Matthew Smithce1ff6a2022-11-05 18:33:08 +0000180extern u8 ip6_ra_adv_enabled (u32 sw_if_index);
Neale Rannscbe25aa2019-09-30 10:53:31 +0000181#endif /* included_ip6_neighbor_h */
182
183/*
184 * fd.io coding-style-patch-verification: ON
185 *
186 * Local Variables:
187 * eval: (c-set-style "gnu")
188 * End:
189 */