]>
Commit | Line | Data |
---|---|---|
acddc0ed | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
d62a17ae | 2 | /* |
65efcfce LB |
3 | * |
4 | * Copyright 2009-2016, LabN Consulting, L.L.C. | |
5 | * | |
65efcfce LB |
6 | */ |
7 | ||
8 | #ifndef _QUAGGA_BGP_RFAPI_H | |
9 | #define _QUAGGA_BGP_RFAPI_H | |
10 | ||
49e5a4a0 | 11 | #ifdef ENABLE_BGP_VNC |
65efcfce LB |
12 | |
13 | #include <stdint.h> | |
14 | #include <netinet/in.h> | |
f8b6f499 LB |
15 | #include "lib/zebra.h" |
16 | #include "lib/vty.h" | |
17 | #include "lib/prefix.h" | |
18 | #include "bgpd/bgpd.h" | |
19 | #include "bgpd/bgp_encap_types.h" | |
65efcfce LB |
20 | |
21 | /* probably ought to have a field-specific define in config.h */ | |
d62a17ae | 22 | #ifndef s6_addr32 /* for solaris/bsd */ |
65efcfce | 23 | # define s6_addr32 __u6_addr.__u6_addr32 |
d62a17ae | 24 | #endif |
65efcfce LB |
25 | |
26 | #define RFAPI_V4_ADDR 0x04 | |
27 | #define RFAPI_V6_ADDR 0x06 | |
28 | #define RFAPI_SHOW_STR "VNC information\n" | |
29 | ||
d62a17ae | 30 | struct rfapi_ip_addr { |
31 | uint8_t addr_family; /* AF_INET | AF_INET6 */ | |
32 | union { | |
33 | struct in_addr v4; /* in network order */ | |
34 | struct in6_addr v6; /* in network order */ | |
35 | } addr; | |
65efcfce LB |
36 | }; |
37 | ||
d62a17ae | 38 | struct rfapi_ip_prefix { |
39 | uint8_t length; | |
40 | uint8_t cost; /* bgp local pref = 255 - cost */ | |
41 | struct rfapi_ip_addr prefix; | |
65efcfce LB |
42 | }; |
43 | ||
d62a17ae | 44 | struct rfapi_nexthop { |
45 | struct prefix addr; | |
46 | uint8_t cost; | |
65efcfce LB |
47 | }; |
48 | ||
d62a17ae | 49 | struct rfapi_next_hop_entry { |
50 | struct rfapi_next_hop_entry *next; | |
51 | struct rfapi_ip_prefix prefix; | |
52 | uint32_t lifetime; | |
53 | struct rfapi_ip_addr un_address; | |
54 | struct rfapi_ip_addr vn_address; | |
55 | struct rfapi_vn_option *vn_options; | |
56 | struct rfapi_un_option *un_options; | |
65efcfce LB |
57 | }; |
58 | ||
59 | #define RFAPI_REMOVE_RESPONSE_LIFETIME 0 | |
60 | #define RFAPI_INFINITE_LIFETIME 0xFFFFFFFF | |
61 | ||
d62a17ae | 62 | struct rfapi_l2address_option { |
63 | struct ethaddr macaddr; /* use 0 to assign label to IP prefix */ | |
64 | uint32_t label; /* 20bit label in low bits, no TC, S, or TTL */ | |
65 | uint32_t logical_net_id; /* ~= EVPN Ethernet Segment Id, | |
66 | must not be zero for mac regis. */ | |
67 | uint8_t local_nve_id; | |
68 | uint16_t tag_id; /* EVPN Ethernet Tag ID, 0 = none */ | |
65efcfce LB |
69 | }; |
70 | ||
d62a17ae | 71 | typedef enum { |
72 | RFAPI_UN_OPTION_TYPE_PROVISIONAL, /* internal use only */ | |
73 | RFAPI_UN_OPTION_TYPE_TUNNELTYPE, | |
65efcfce LB |
74 | } rfapi_un_option_type; |
75 | ||
d62a17ae | 76 | struct rfapi_tunneltype_option { |
77 | bgp_encap_types type; | |
78 | union { | |
79 | struct bgp_encap_type_reserved reserved; | |
80 | struct bgp_encap_type_l2tpv3_over_ip l2tpv3_ip; | |
81 | struct bgp_encap_type_gre gre; | |
82 | struct bgp_encap_type_transmit_tunnel_endpoint | |
83 | transmit_tunnel_endpoint; | |
84 | struct bgp_encap_type_ipsec_in_tunnel_mode ipsec_tunnel; | |
85 | struct bgp_encap_type_ip_in_ip_tunnel_with_ipsec_transport_mode | |
86 | ip_ipsec; | |
87 | struct bgp_encap_type_mpls_in_ip_tunnel_with_ipsec_transport_mode | |
88 | mpls_ipsec; | |
89 | struct bgp_encap_type_ip_in_ip ip_ip; | |
90 | struct bgp_encap_type_vxlan vxlan; | |
91 | struct bgp_encap_type_nvgre nvgre; | |
92 | struct bgp_encap_type_mpls mpls; | |
93 | struct bgp_encap_type_mpls_in_gre mpls_gre; | |
94 | struct bgp_encap_type_vxlan_gpe vxlan_gpe; | |
95 | struct bgp_encap_type_mpls_in_udp mpls_udp; | |
96 | struct bgp_encap_type_pbb pbb; | |
97 | } bgpinfo; | |
65efcfce LB |
98 | }; |
99 | ||
d62a17ae | 100 | struct rfapi_un_option { |
101 | struct rfapi_un_option *next; | |
102 | rfapi_un_option_type type; | |
103 | union { | |
104 | struct rfapi_tunneltype_option tunnel; | |
105 | } v; | |
65efcfce LB |
106 | }; |
107 | ||
d62a17ae | 108 | typedef enum { |
109 | RFAPI_VN_OPTION_TYPE_L2ADDR = | |
110 | 3, /* Layer 2 address, 3 for legacy compatibility */ | |
111 | RFAPI_VN_OPTION_TYPE_LOCAL_NEXTHOP, /* for static routes */ | |
112 | RFAPI_VN_OPTION_TYPE_INTERNAL_RD, /* internal use only */ | |
65efcfce LB |
113 | } rfapi_vn_option_type; |
114 | ||
d62a17ae | 115 | struct rfapi_vn_option { |
116 | struct rfapi_vn_option *next; | |
65efcfce | 117 | |
d62a17ae | 118 | rfapi_vn_option_type type; |
65efcfce | 119 | |
d62a17ae | 120 | union { |
121 | struct rfapi_l2address_option l2addr; | |
65efcfce | 122 | |
d62a17ae | 123 | /* |
124 | * If this option is present, the next hop is local to the | |
125 | * client NVE (i.e., not via a tunnel). | |
126 | */ | |
127 | struct rfapi_nexthop local_nexthop; | |
65efcfce | 128 | |
d62a17ae | 129 | /* |
130 | * For rfapi internal use only | |
131 | */ | |
132 | struct prefix_rd internal_rd; | |
133 | } v; | |
65efcfce LB |
134 | }; |
135 | ||
d62a17ae | 136 | struct rfapi_l2address_option_match { |
137 | struct rfapi_l2address_option o; | |
138 | uint32_t flags; | |
65efcfce LB |
139 | |
140 | #define RFAPI_L2O_MACADDR 0x00000001 | |
141 | #define RFAPI_L2O_LABEL 0x00000002 | |
142 | #define RFAPI_L2O_LNI 0x00000004 | |
143 | #define RFAPI_L2O_LHI 0x00000008 | |
144 | }; | |
145 | ||
146 | #define VNC_CONFIG_STR "VNC/RFP related configuration\n" | |
147 | ||
148 | typedef void *rfapi_handle; | |
149 | ||
150 | /*********************************************************************** | |
151 | * RFP Callbacks | |
152 | ***********************************************************************/ | |
153 | /*------------------------------------------ | |
154 | * rfapi_response_cb_t (callback typedef) | |
155 | * | |
d62a17ae | 156 | * Callbacks of this type are used to provide asynchronous |
65efcfce LB |
157 | * route updates from RFAPI to the RFP client. |
158 | * | |
159 | * response_cb | |
160 | * called to notify the rfp client that a next hop list | |
161 | * that has previously been provided in response to an | |
162 | * rfapi_query call has been updated. Deleted routes are indicated | |
163 | * with lifetime==RFAPI_REMOVE_RESPONSE_LIFETIME. | |
164 | * | |
165 | * By default, the routes an NVE receives via this callback include | |
166 | * its own routes (that it has registered). However, these may be | |
167 | * filtered out if the global BGP_VNC_CONFIG_FILTER_SELF_FROM_RSP | |
168 | * flag is set. | |
169 | * | |
170 | * local_cb | |
171 | * called to notify the rfp client that a local route | |
172 | * has been added or deleted. Deleted routes are indicated | |
173 | * with lifetime==RFAPI_REMOVE_RESPONSE_LIFETIME. | |
174 | * | |
d62a17ae | 175 | * input: |
65efcfce LB |
176 | * next_hops a list of possible next hops. |
177 | * This is a linked list allocated within the | |
178 | * rfapi. The response_cb callback function is responsible | |
179 | * for freeing this memory via rfapi_free_next_hop_list() | |
180 | * in order to avoid memory leaks. | |
181 | * | |
182 | * userdata value (cookie) originally specified in call to | |
183 | * rfapi_open() | |
184 | * | |
185 | *------------------------------------------*/ | |
d62a17ae | 186 | typedef void(rfapi_response_cb_t)(struct rfapi_next_hop_entry *next_hops, |
187 | void *userdata); | |
65efcfce LB |
188 | |
189 | /*------------------------------------------ | |
190 | * rfapi_nve_close_cb_t (callback typedef) | |
191 | * | |
d62a17ae | 192 | * Callbacks of this type are used to provide asynchronous |
65efcfce LB |
193 | * notification that an rfapi_handle was invalidated |
194 | * | |
d62a17ae | 195 | * input: |
65efcfce LB |
196 | * pHandle Firmerly valid rfapi_handle returned to |
197 | * client via rfapi_open(). | |
198 | * | |
199 | * reason EIDRM handle administratively closed (clear nve ...) | |
200 | * ESTALE handle invalidated by configuration change | |
201 | * | |
202 | *------------------------------------------*/ | |
d62a17ae | 203 | typedef void(rfapi_nve_close_cb_t)(rfapi_handle pHandle, int reason); |
65efcfce LB |
204 | |
205 | /*------------------------------------------ | |
206 | * rfp_cfg_write_cb_t (callback typedef) | |
207 | * | |
208 | * This callback is used to generate output for any config parameters | |
d62a17ae | 209 | * that may supported by RFP via RFP defined vty commands at the bgp |
65efcfce LB |
210 | * level. See loglevel as an example. |
211 | * | |
d62a17ae | 212 | * input: |
65efcfce LB |
213 | * vty -- quagga vty context |
214 | * rfp_start_val -- value returned by rfp_start | |
215 | * | |
216 | * output: | |
217 | * to vty, rfp related configuration | |
218 | * | |
d62a17ae | 219 | * return value: |
65efcfce LB |
220 | * lines written |
221 | --------------------------------------------*/ | |
d62a17ae | 222 | typedef int(rfp_cfg_write_cb_t)(struct vty *vty, void *rfp_start_val); |
65efcfce LB |
223 | |
224 | /*------------------------------------------ | |
225 | * rfp_cfg_group_write_cb_t (callback typedef) | |
226 | * | |
227 | * This callback is used to generate output for any config parameters | |
d62a17ae | 228 | * that may supported by RFP via RFP defined vty commands at the |
65efcfce LB |
229 | * L2 or NVE level. See loglevel as an example. |
230 | * | |
d62a17ae | 231 | * input: |
65efcfce LB |
232 | * vty quagga vty context |
233 | * rfp_start_val value returned by rfp_start | |
234 | * type group type | |
235 | * name group name | |
d62a17ae | 236 | * rfp_cfg_group Pointer to configuration structure |
65efcfce LB |
237 | * |
238 | * output: | |
239 | * to vty, rfp related configuration | |
240 | * | |
d62a17ae | 241 | * return value: |
65efcfce LB |
242 | * lines written |
243 | --------------------------------------------*/ | |
d62a17ae | 244 | typedef enum { |
245 | RFAPI_RFP_CFG_GROUP_DEFAULT, | |
246 | RFAPI_RFP_CFG_GROUP_NVE, | |
247 | RFAPI_RFP_CFG_GROUP_L2 | |
65efcfce LB |
248 | } rfapi_rfp_cfg_group_type; |
249 | ||
d62a17ae | 250 | typedef int(rfp_cfg_group_write_cb_t)(struct vty *vty, void *rfp_start_val, |
251 | rfapi_rfp_cfg_group_type type, | |
252 | const char *name, void *rfp_cfg_group); | |
65efcfce LB |
253 | |
254 | /*********************************************************************** | |
255 | * Configuration related defines and structures | |
256 | ***********************************************************************/ | |
257 | ||
d62a17ae | 258 | struct rfapi_rfp_cb_methods { |
259 | rfp_cfg_write_cb_t *cfg_cb; /* show top level config */ | |
260 | rfp_cfg_group_write_cb_t *cfg_group_cb; /* show group level config */ | |
261 | rfapi_response_cb_t *response_cb; /* unsolicited responses */ | |
262 | rfapi_response_cb_t *local_cb; /* local route add/delete */ | |
263 | rfapi_nve_close_cb_t *close_cb; /* handle closed */ | |
65efcfce LB |
264 | }; |
265 | ||
266 | /* | |
267 | * If a route with infinite lifetime is withdrawn, this is | |
268 | * how long (in seconds) to wait before expiring it (because | |
269 | * RFAPI_LIFETIME_MULTIPLIER_PCT * infinity is too long to wait) | |
270 | */ | |
271 | #define RFAPI_LIFETIME_INFINITE_WITHDRAW_DELAY (60*120) | |
272 | ||
d62a17ae | 273 | /* |
65efcfce LB |
274 | * the factor that should be applied to a prefix's <lifetime> value |
275 | * before using it to expire a withdrawn prefix, expressed as a percent. | |
276 | * Thus, a value of 100 means to use the exact value of <lifetime>, | |
277 | * a value of 200 means to use twice the value of <lifetime>, etc. | |
278 | */ | |
279 | #define RFAPI_RFP_CFG_DEFAULT_HOLDDOWN_FACTOR 150 | |
280 | ||
281 | /* | |
d62a17ae | 282 | * This is used by rfapi to determine if RFP is using/supports |
65efcfce LB |
283 | * a partial (i.e., cache) or full table download approach for |
284 | * mapping information. When full table download approach is | |
285 | * used all information is passed to RFP after an initial | |
d62a17ae | 286 | * rfapi_query. When partial table download is used, only |
287 | * information matching a query is passed. | |
65efcfce | 288 | */ |
d62a17ae | 289 | typedef enum { |
290 | RFAPI_RFP_DOWNLOAD_PARTIAL = 0, | |
291 | RFAPI_RFP_DOWNLOAD_FULL | |
65efcfce LB |
292 | } rfapi_rfp_download_type; |
293 | ||
294 | #define RFAPI_RFP_CFG_DEFAULT_FTD_ADVERTISEMENT_INTERVAL 1 | |
295 | ||
d62a17ae | 296 | struct rfapi_rfp_cfg { |
297 | /* partial or full table download */ | |
298 | rfapi_rfp_download_type download_type; /* default=partial */ | |
299 | /* | |
300 | * When full-table-download is enabled, this is the minimum | |
301 | * number of seconds between times a non-queried prefix will | |
302 | * be updated to a particular NVE. | |
303 | * default: RFAPI_RFP_CFG_DEFAULT_FTD_ADVERTISEMENT_INTERVAL | |
304 | */ | |
305 | uint32_t ftd_advertisement_interval; | |
306 | /* | |
307 | * percentage of registration lifetime to continue to use information | |
308 | * post soft-state refresh timeout | |
309 | default: RFAPI_RFP_CFG_DEFAULT_HOLDDOWN_FACTOR | |
310 | */ | |
311 | uint32_t holddown_factor; | |
312 | /* Control generation of updated RFP responses */ | |
313 | uint8_t use_updated_response; /* default=0/no */ | |
314 | /* when use_updated_response, also generate remove responses */ | |
315 | uint8_t use_removes; /* default=0/no */ | |
65efcfce LB |
316 | }; |
317 | ||
318 | /*********************************************************************** | |
d62a17ae | 319 | * Process related functions -- MUST be provided by the RFAPI user <<=== |
65efcfce LB |
320 | ***********************************************************************/ |
321 | ||
322 | /*------------------------------------------ | |
323 | * rfp_start | |
324 | * | |
325 | * This function will start the RFP code | |
326 | * | |
d62a17ae | 327 | * input: |
65efcfce | 328 | * master quagga thread_master to tie into bgpd threads |
d62a17ae | 329 | * |
65efcfce | 330 | * output: |
d62a17ae | 331 | * cfgp Pointer to rfapi_rfp_cfg (null = use defaults), |
65efcfce LB |
332 | * copied by caller, updated via rfp_set_configuration |
333 | * cbmp Pointer to rfapi_rfp_cb_methods, may be null | |
334 | * copied by caller, updated via rfapi_rfp_set_cb_methods | |
d62a17ae | 335 | * return value: |
65efcfce LB |
336 | * rfp_start_val rfp returned value passed on rfp_stop and other rfapi calls |
337 | --------------------------------------------*/ | |
d62a17ae | 338 | extern void *rfp_start(struct thread_master *master, |
339 | struct rfapi_rfp_cfg **cfgp, | |
340 | struct rfapi_rfp_cb_methods **cbmp); | |
65efcfce LB |
341 | |
342 | /*------------------------------------------ | |
343 | * rfp_stop | |
344 | * | |
345 | * This function is called on shutdown to trigger RFP cleanup | |
346 | * | |
d62a17ae | 347 | * input: |
65efcfce LB |
348 | * rfp_start_val |
349 | * | |
350 | * output: | |
351 | * none | |
352 | * | |
d62a17ae | 353 | * return value: |
65efcfce | 354 | --------------------------------------------*/ |
d62a17ae | 355 | extern void rfp_stop(void *rfp_start_val); |
65efcfce LB |
356 | |
357 | /*********************************************************************** | |
358 | * RFP processing behavior configuration | |
359 | ***********************************************************************/ | |
360 | ||
361 | /*------------------------------------------ | |
362 | * rfapi_rfp_set_configuration | |
363 | * | |
d62a17ae | 364 | * This is used to change rfapi's processing behavior based on |
365 | * RFP requirements. | |
65efcfce | 366 | * |
d62a17ae | 367 | * input: |
65efcfce LB |
368 | * rfp_start_val value returned by rfp_start |
369 | * rfapi_rfp_cfg Pointer to configuration structure | |
370 | * | |
371 | * output: | |
372 | * none | |
373 | * | |
d62a17ae | 374 | * return value: |
65efcfce LB |
375 | * 0 Success |
376 | * ENXIO Unabled to locate configured BGP/VNC | |
377 | --------------------------------------------*/ | |
d62a17ae | 378 | extern int rfapi_rfp_set_configuration(void *rfp_start_val, |
379 | struct rfapi_rfp_cfg *rfp_cfg); | |
65efcfce LB |
380 | |
381 | /*------------------------------------------ | |
382 | * rfapi_rfp_set_cb_methods | |
383 | * | |
d62a17ae | 384 | * Change registered callback functions for asynchronous notifications |
65efcfce LB |
385 | * from RFAPI to the RFP client. |
386 | * | |
d62a17ae | 387 | * input: |
65efcfce LB |
388 | * rfp_start_val value by rfp_start |
389 | * methods Pointer to struct rfapi_rfp_cb_methods containing | |
390 | * pointers to callback methods as described above | |
391 | * | |
d62a17ae | 392 | * return value: |
65efcfce LB |
393 | * 0 Success |
394 | * ENXIO BGP or VNC not configured | |
395 | *------------------------------------------*/ | |
d62a17ae | 396 | extern int rfapi_rfp_set_cb_methods(void *rfp_start_val, |
397 | struct rfapi_rfp_cb_methods *methods); | |
65efcfce LB |
398 | |
399 | /*********************************************************************** | |
400 | * RFP group specific configuration | |
401 | ***********************************************************************/ | |
402 | ||
403 | /*------------------------------------------ | |
404 | * rfapi_rfp_init_group_config_ptr_vty | |
405 | * | |
406 | * This is used to init or return a previously init'ed group specific | |
d62a17ae | 407 | * configuration pointer. Group is identified by vty context. |
65efcfce LB |
408 | * NOTE: size is ignored when a previously init'ed value is returned. |
409 | * RFAPI frees rfp_cfg_group when group is deleted during reconfig, | |
410 | * bgp restart or shutdown. | |
411 | * | |
d62a17ae | 412 | * input: |
65efcfce LB |
413 | * rfp_start_val value returned by rfp_start |
414 | * type group type | |
415 | * vty quagga vty context | |
416 | * size number of bytes to allocation | |
417 | * | |
418 | * output: | |
419 | * none | |
420 | * | |
d62a17ae | 421 | * return value: |
65efcfce LB |
422 | * rfp_cfg_group NULL or Pointer to configuration structure |
423 | --------------------------------------------*/ | |
d62a17ae | 424 | extern void *rfapi_rfp_init_group_config_ptr_vty(void *rfp_start_val, |
425 | rfapi_rfp_cfg_group_type type, | |
426 | struct vty *vty, | |
427 | uint32_t size); | |
65efcfce LB |
428 | |
429 | /*------------------------------------------ | |
430 | * rfapi_rfp_get_group_config_ptr_vty | |
431 | * | |
432 | * This is used to get group specific configuration pointer. | |
d62a17ae | 433 | * Group is identified by type and vty context. |
65efcfce LB |
434 | * RFAPI frees rfp_cfg_group when group is deleted during reconfig, |
435 | * bgp restart or shutdown. | |
436 | * | |
d62a17ae | 437 | * input: |
65efcfce LB |
438 | * rfp_start_val value returned by rfp_start |
439 | * type group type | |
440 | * vty quagga vty context | |
441 | * | |
442 | * output: | |
443 | * none | |
444 | * | |
445 | * return value: | |
d62a17ae | 446 | * rfp_cfg_group Pointer to configuration structure |
65efcfce | 447 | --------------------------------------------*/ |
d62a17ae | 448 | extern void *rfapi_rfp_get_group_config_ptr_vty(void *rfp_start_val, |
449 | rfapi_rfp_cfg_group_type type, | |
450 | struct vty *vty); | |
65efcfce LB |
451 | |
452 | /*------------------------------------------ | |
453 | * rfp_group_config_search_cb_t (callback typedef) | |
454 | * | |
d62a17ae | 455 | * This callback is used to called from within a |
65efcfce LB |
456 | * rfapi_rfp_get_group_config_ptr to check if the rfp_cfg_group |
457 | * matches the search criteria | |
458 | * | |
d62a17ae | 459 | * input: |
65efcfce LB |
460 | * criteria RFAPI caller provided serach criteria |
461 | * rfp_cfg_group Pointer to configuration structure | NULL | |
462 | * | |
463 | * output: | |
464 | * | |
d62a17ae | 465 | * return value: |
65efcfce LB |
466 | * 0 Match/Success |
467 | * ENOENT No matching | |
468 | --------------------------------------------*/ | |
d62a17ae | 469 | typedef int(rfp_group_config_search_cb_t)(void *criteria, void *rfp_cfg_group); |
65efcfce LB |
470 | |
471 | /*------------------------------------------ | |
472 | * rfapi_rfp_get_group_config_ptr_name | |
473 | * | |
474 | * This is used to get group specific configuration pointer. | |
d62a17ae | 475 | * Group is identified by type and name context. |
65efcfce LB |
476 | * RFAPI frees rfp_cfg_group when group is deleted during reconfig, |
477 | * bgp restart or shutdown. | |
478 | * | |
d62a17ae | 479 | * input: |
65efcfce LB |
480 | * rfp_start_val value returned by rfp_start |
481 | * type group type | |
482 | * name group name | |
483 | * criteria RFAPI caller provided serach criteria | |
484 | * search_cb optional rfp_group_config_search_cb_t | |
485 | * | |
486 | * output: | |
487 | * none | |
488 | * | |
489 | * return value: | |
d62a17ae | 490 | * rfp_cfg_group Pointer to configuration structure |
65efcfce | 491 | --------------------------------------------*/ |
d62a17ae | 492 | extern void *rfapi_rfp_get_group_config_ptr_name( |
493 | void *rfp_start_val, rfapi_rfp_cfg_group_type type, const char *name, | |
494 | void *criteria, rfp_group_config_search_cb_t *search_cb); | |
65efcfce LB |
495 | |
496 | /*------------------------------------------ | |
497 | * rfapi_rfp_get_l2_group_config_ptr_lni | |
498 | * | |
499 | * This is used to get group specific configuration pointer. | |
500 | * Group is identified by type and logical network identifier. | |
501 | * RFAPI frees rfp_cfg_group when group is deleted during reconfig, | |
d62a17ae | 502 | * bgp restart or shutdown. |
65efcfce | 503 | * |
d62a17ae | 504 | * input: |
65efcfce LB |
505 | * rfp_start_val value returned by rfp_start |
506 | * logical_net_id group logical network identifier | |
507 | * criteria RFAPI caller provided serach criteria | |
508 | * search_cb optional rfp_group_config_search_cb_t | |
509 | * | |
510 | * output: | |
511 | * none | |
512 | * | |
513 | * return value: | |
d62a17ae | 514 | * rfp_cfg_group Pointer to configuration structure |
65efcfce LB |
515 | --------------------------------------------*/ |
516 | extern void * | |
d62a17ae | 517 | rfapi_rfp_get_l2_group_config_ptr_lni(void *rfp_start_val, |
518 | uint32_t logical_net_id, void *criteria, | |
519 | rfp_group_config_search_cb_t *search_cb); | |
65efcfce LB |
520 | |
521 | /*********************************************************************** | |
522 | * NVE Sessions | |
523 | ***********************************************************************/ | |
524 | ||
525 | /*------------------------------------------ | |
526 | * rfapi_open | |
527 | * | |
528 | * This function initializes a NVE record and associates it with | |
529 | * the specified VN and underlay network addresses | |
530 | * | |
d62a17ae | 531 | * input: |
65efcfce LB |
532 | * rfp_start_val value returned by rfp_start |
533 | * vn NVE virtual network address | |
534 | * | |
535 | * un NVE underlay network address | |
536 | * | |
537 | * default_options Default options to use on registrations. | |
538 | * For now only tunnel type is supported. | |
539 | * May be overridden per-prefix in rfapi_register(). | |
540 | * Caller owns (rfapi_open() does not free) | |
541 | * | |
542 | * response_cb Pointer to next hop list update callback function or | |
543 | * NULL when no callbacks are desired. | |
544 | * | |
545 | * userdata Passed to subsequent response_cb invocations. | |
546 | * | |
547 | * output: | |
548 | * response_lifetime The length of time that responses sent to this | |
d62a17ae | 549 | * NVE are valid. |
65efcfce LB |
550 | * |
551 | * pHandle pointer to location to store rfapi handle. The | |
552 | * handle must be passed on subsequent rfapi_ calls. | |
553 | * | |
554 | * | |
d62a17ae | 555 | * return value: |
65efcfce LB |
556 | * 0 Success |
557 | * EEXIST NVE with this {vn,un} already open | |
558 | * ENOENT No matching nve group config | |
559 | * ENOMSG Matched nve group config was incomplete | |
560 | * ENXIO BGP or VNC not configured | |
561 | * EAFNOSUPPORT Matched nve group specifies auto-assignment of RD, | |
562 | * but underlay network address is not IPv4 | |
563 | * EDEADLK Called from within a callback procedure | |
564 | *------------------------------------------*/ | |
d62a17ae | 565 | extern int rfapi_open(void *rfp_start_val, struct rfapi_ip_addr *vn, |
566 | struct rfapi_ip_addr *un, | |
567 | struct rfapi_un_option *default_options, | |
568 | uint32_t *response_lifetime, void *userdata, | |
569 | rfapi_handle *pHandle); | |
65efcfce LB |
570 | |
571 | ||
572 | /*------------------------------------------ | |
573 | * rfapi_close | |
574 | * | |
575 | * Shut down NVE session and release associated data. Calling | |
576 | * from within a rfapi callback procedure is permitted (the close | |
577 | * will be completed asynchronously after the callback finishes). | |
578 | * | |
d62a17ae | 579 | * input: |
65efcfce LB |
580 | * rfd: rfapi descriptor returned by rfapi_open |
581 | * | |
582 | * output: | |
583 | * | |
584 | * return value: | |
585 | * 0 Success | |
586 | * EBADF invalid handle | |
587 | * ENXIO BGP or VNC not configured | |
588 | *------------------------------------------*/ | |
d62a17ae | 589 | extern int rfapi_close(rfapi_handle rfd); |
65efcfce LB |
590 | |
591 | /*------------------------------------------ | |
592 | * rfapi_check | |
593 | * | |
594 | * Test rfapi descriptor | |
595 | * | |
d62a17ae | 596 | * input: |
65efcfce LB |
597 | * rfd: rfapi descriptor returned by rfapi_open |
598 | * | |
599 | * output: | |
600 | * | |
601 | * return value: | |
602 | * 0 Success: handle is valid and usable | |
603 | * EINVAL null argument | |
604 | * ESTALE formerly valid handle invalidated by config, needs close | |
605 | * EBADF invalid handle | |
606 | * ENXIO BGP or VNC not configured | |
607 | * EAFNOSUPPORT Internal addressing error | |
608 | *------------------------------------------*/ | |
d62a17ae | 609 | extern int rfapi_check(rfapi_handle rfd); |
65efcfce LB |
610 | |
611 | /*********************************************************************** | |
612 | * NVE Routes | |
613 | ***********************************************************************/ | |
614 | ||
615 | /*------------------------------------------ | |
616 | * rfapi_query | |
617 | * | |
d62a17ae | 618 | * This function queries the RIB for a |
619 | * particular route. Note that this call may result in subsequent | |
65efcfce LB |
620 | * callbacks to response_cb. Response callbacks can be cancelled |
621 | * by calling rfapi_query_done. A duplicate query using the same target | |
622 | * will result in only one callback per change in next_hops. (i.e., | |
623 | * cancel/replace the prior query results.) | |
624 | * | |
d62a17ae | 625 | * input: |
65efcfce LB |
626 | * rfd: rfapi descriptor returned by rfapi_open |
627 | * target: the destination address | |
628 | * l2o ptr to L2 Options struct, NULL if not present in query | |
629 | * | |
630 | * output: | |
631 | * ppNextHopEntry pointer to a location to store a pointer | |
632 | * to the returned list of nexthops. It is the | |
633 | * caller's responsibility to free this list | |
634 | * via rfapi_free_next_hop_list(). | |
635 | * | |
636 | * | |
637 | * return value: | |
638 | * 0 Success | |
639 | * EBADF invalid handle | |
640 | * ENOENT no valid route | |
641 | * ENXIO BGP or VNC not configured | |
642 | * ESTALE descriptor is no longer usable; should be closed | |
643 | * EDEADLK Called from within a callback procedure | |
644 | --------------------------------------------*/ | |
d62a17ae | 645 | extern int rfapi_query(rfapi_handle rfd, struct rfapi_ip_addr *target, |
646 | struct rfapi_l2address_option *l2o, | |
647 | struct rfapi_next_hop_entry **ppNextHopEntry); | |
65efcfce LB |
648 | |
649 | /*------------------------------------------ | |
650 | * rfapi_query_done | |
651 | * | |
d62a17ae | 652 | * Notifies the rfapi that the user is no longer interested |
653 | * in the specified target. | |
65efcfce | 654 | * |
d62a17ae | 655 | * input: |
65efcfce LB |
656 | * rfd: rfapi descriptor returned by rfapi_open |
657 | * target: the destination address | |
658 | * | |
659 | * output: | |
660 | * | |
661 | * return value: | |
662 | * 0 Success | |
663 | * EBADF invalid handle | |
664 | * ENOENT no match found for target | |
665 | * ENXIO BGP or VNC not configured | |
666 | * ESTALE descriptor is no longer usable; should be closed | |
667 | * EDEADLK Called from within a callback procedure | |
668 | --------------------------------------------*/ | |
d62a17ae | 669 | extern int rfapi_query_done(rfapi_handle rfd, struct rfapi_ip_addr *target); |
65efcfce LB |
670 | |
671 | /*------------------------------------------ | |
672 | * rfapi_query_done_all | |
673 | * | |
d62a17ae | 674 | * Notifies the rfapi that the user is no longer interested |
675 | * in any target. | |
65efcfce | 676 | * |
d62a17ae | 677 | * input: |
65efcfce LB |
678 | * rfd: rfapi descriptor returned by rfapi_open |
679 | * | |
680 | * output: | |
681 | * count: number of queries cleared | |
682 | * | |
683 | * return value: | |
684 | * 0 Success | |
685 | * EBADF invalid handle | |
686 | * ENXIO BGP or VNC not configured | |
687 | * ESTALE descriptor is no longer usable; should be closed | |
688 | * EDEADLK Called from within a callback procedure | |
689 | --------------------------------------------*/ | |
d62a17ae | 690 | extern int rfapi_query_done_all(rfapi_handle rfd, int *count); |
65efcfce LB |
691 | |
692 | /*------------------------------------------ | |
693 | * rfapi_register | |
694 | * | |
695 | * Requests that reachability to the indicated prefix via this NVE | |
696 | * be advertised by BGP. If <unregister> is non-zero, then the previously- | |
697 | * advertised prefix should be withdrawn. | |
d62a17ae | 698 | * |
699 | * (This function should NOT be called if the rfapi_open() function | |
65efcfce LB |
700 | * returns NULL) |
701 | * | |
d62a17ae | 702 | * input: |
65efcfce LB |
703 | * rfd: rfapi descriptor returned by rfapi_open |
704 | * prefix: A prefix to be registered or deregistered | |
705 | * lifetime Prefix lifetime in seconds, host byte order | |
706 | * options_un underlay netowrk options, may include tunnel-type | |
707 | * Caller owns (rfapi_register() does not free). | |
708 | * options_vn virtual network options, may include layer 2 address | |
709 | * option and local-nexthop option | |
710 | * Caller owns (rfapi_register() does not free). | |
711 | * | |
712 | * action: RFAPI_REGISTER_ADD add the route | |
713 | * RFAPI_REGISTER_WITHDRAW withdraw route | |
714 | * RFAPI_REGISTER_KILL withdraw without holddown | |
715 | * | |
716 | * return value: | |
717 | * 0 Success | |
718 | * EBADF invalid handle | |
719 | * ENXIO BGP or VNC not configured | |
720 | * ESTALE descriptor is no longer usable; should be closed | |
721 | * EDEADLK Called from within a callback procedure | |
722 | --------------------------------------------*/ | |
723 | ||
d62a17ae | 724 | typedef enum { |
725 | RFAPI_REGISTER_ADD, | |
726 | RFAPI_REGISTER_WITHDRAW, | |
727 | RFAPI_REGISTER_KILL | |
65efcfce LB |
728 | } rfapi_register_action; |
729 | ||
d62a17ae | 730 | extern int rfapi_register(rfapi_handle rfd, struct rfapi_ip_prefix *prefix, |
731 | uint32_t lifetime, struct rfapi_un_option *options_un, | |
732 | struct rfapi_vn_option *options_vn, | |
733 | rfapi_register_action action); | |
65efcfce LB |
734 | |
735 | /*********************************************************************** | |
736 | * Helper / Utility functions | |
737 | ***********************************************************************/ | |
738 | ||
739 | /*------------------------------------------ | |
740 | * rfapi_get_vn_addr | |
741 | * | |
742 | * Get the virtual network address used by an NVE based on it's RFD | |
743 | * | |
d62a17ae | 744 | * input: |
65efcfce LB |
745 | * rfd: rfapi descriptor returned by rfapi_open or rfapi_create_generic |
746 | * | |
747 | * output: | |
748 | * | |
d62a17ae | 749 | * return value: |
65efcfce LB |
750 | * vn NVE virtual network address |
751 | *------------------------------------------*/ | |
d62a17ae | 752 | extern struct rfapi_ip_addr *rfapi_get_vn_addr(void *); |
65efcfce LB |
753 | |
754 | /*------------------------------------------ | |
755 | * rfapi_get_un_addr | |
756 | * | |
757 | * Get the underlay network address used by an NVE based on it's RFD | |
758 | * | |
d62a17ae | 759 | * input: |
65efcfce LB |
760 | * rfd: rfapi descriptor returned by rfapi_open or rfapi_create_generic |
761 | * | |
762 | * output: | |
763 | * | |
d62a17ae | 764 | * return value: |
65efcfce LB |
765 | * un NVE underlay network address |
766 | *------------------------------------------*/ | |
d62a17ae | 767 | extern struct rfapi_ip_addr *rfapi_get_un_addr(void *); |
65efcfce LB |
768 | |
769 | /*------------------------------------------ | |
770 | * rfapi_error_str | |
771 | * | |
772 | * Returns a string describing the rfapi error code. | |
773 | * | |
774 | * input: | |
775 | * | |
776 | * code Error code returned by rfapi function | |
777 | * | |
778 | * returns: | |
779 | * | |
780 | * const char * String | |
781 | *------------------------------------------*/ | |
d62a17ae | 782 | extern const char *rfapi_error_str(int code); |
65efcfce LB |
783 | |
784 | /*------------------------------------------ | |
785 | * rfapi_get_rfp_start_val | |
786 | * | |
787 | * Returns value passed to rfapi on rfp_start | |
788 | * | |
789 | * input: | |
790 | * void * bgp structure | |
791 | * | |
792 | * returns: | |
d62a17ae | 793 | * void * |
65efcfce | 794 | *------------------------------------------*/ |
d62a17ae | 795 | extern void *rfapi_get_rfp_start_val(void *bgpv); |
65efcfce LB |
796 | |
797 | /*------------------------------------------ | |
798 | * rfapi_compare_rfds | |
799 | * | |
800 | * Compare two generic rfapi descriptors. | |
801 | * | |
d62a17ae | 802 | * input: |
65efcfce LB |
803 | * rfd1: rfapi descriptor returned by rfapi_open or rfapi_create_generic |
804 | * rfd2: rfapi descriptor returned by rfapi_open or rfapi_create_generic | |
805 | * | |
806 | * output: | |
807 | * | |
808 | * return value: | |
809 | * 0 Mismatch | |
810 | * 1 Match | |
811 | *------------------------------------------*/ | |
d62a17ae | 812 | extern int rfapi_compare_rfds(void *rfd1, void *rfd2); |
65efcfce LB |
813 | |
814 | /*------------------------------------------ | |
815 | * rfapi_free_next_hop_list | |
816 | * | |
817 | * Frees a next_hop_list returned by a rfapi_query invocation | |
818 | * | |
d62a17ae | 819 | * input: |
820 | * list: a pointer to a response list (as a | |
65efcfce LB |
821 | * struct rfapi_next_hop_entry) to free. |
822 | * | |
823 | * output: | |
824 | * | |
825 | * return value: None | |
826 | --------------------------------------------*/ | |
d62a17ae | 827 | extern void rfapi_free_next_hop_list(struct rfapi_next_hop_entry *list); |
65efcfce LB |
828 | |
829 | /*------------------------------------------ | |
830 | * rfapi_get_response_lifetime_default | |
831 | * | |
832 | * Returns the default lifetime for a response. | |
833 | * rfp_start_val value returned by rfp_start or | |
834 | * NULL (=use default instance) | |
835 | * | |
d62a17ae | 836 | * input: |
65efcfce LB |
837 | * None |
838 | * | |
839 | * output: | |
840 | * | |
841 | * return value: The bgp instance default lifetime for a response. | |
842 | --------------------------------------------*/ | |
d62a17ae | 843 | extern int rfapi_get_response_lifetime_default(void *rfp_start_val); |
65efcfce LB |
844 | |
845 | /*------------------------------------------ | |
846 | * rfapi_is_vnc_configured | |
847 | * | |
00827590 | 848 | * Returns if VNC is configured |
65efcfce | 849 | * |
d62a17ae | 850 | * input: |
65efcfce LB |
851 | * rfp_start_val value returned by rfp_start or |
852 | * NULL (=use default instance) | |
853 | * | |
854 | * output: | |
855 | * | |
856 | * return value: If VNC is configured for the bgpd instance | |
857 | * 0 Success | |
858 | * ENXIO VNC not configured | |
859 | --------------------------------------------*/ | |
d62a17ae | 860 | extern int rfapi_is_vnc_configured(void *rfp_start_val); |
65efcfce LB |
861 | |
862 | /*------------------------------------------ | |
863 | * rfapi_bgp_lookup_by_rfp | |
864 | * | |
865 | * Find bgp instance pointer based on value returned by rfp_start | |
866 | * | |
d62a17ae | 867 | * input: |
65efcfce LB |
868 | * rfp_start_val value returned by rfp_startor |
869 | * NULL (=get default instance) | |
870 | * | |
871 | * output: | |
872 | * none | |
873 | * | |
874 | * return value: | |
875 | * bgp bgp instance pointer | |
876 | * NULL = not found | |
877 | * | |
878 | --------------------------------------------*/ | |
d62a17ae | 879 | extern struct bgp *rfapi_bgp_lookup_by_rfp(void *rfp_start_val); |
65efcfce LB |
880 | |
881 | /*------------------------------------------ | |
882 | * rfapi_get_rfp_start_val_by_bgp | |
883 | * | |
884 | * Find bgp instance pointer based on value returned by rfp_start | |
885 | * | |
d62a17ae | 886 | * input: |
65efcfce LB |
887 | * bgp bgp instance pointer |
888 | * | |
889 | * output: | |
890 | * none | |
891 | * | |
892 | * return value: | |
893 | * rfp_start_val | |
894 | * NULL = not found | |
895 | * | |
896 | --------------------------------------------*/ | |
d62a17ae | 897 | extern void *rfapi_get_rfp_start_val_by_bgp(struct bgp *bgp); |
65efcfce LB |
898 | |
899 | #endif /* ENABLE_BGP_VNC */ | |
900 | ||
901 | #endif /* _QUAGGA_BGP_RFAPI_H */ |