]>
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 | --------------------------------------------*/ | |
cd9d0537 | 338 | extern void *rfp_start(struct event_loop *master, struct rfapi_rfp_cfg **cfgp, |
d62a17ae | 339 | struct rfapi_rfp_cb_methods **cbmp); |
65efcfce LB |
340 | |
341 | /*------------------------------------------ | |
342 | * rfp_stop | |
343 | * | |
344 | * This function is called on shutdown to trigger RFP cleanup | |
345 | * | |
d62a17ae | 346 | * input: |
65efcfce LB |
347 | * rfp_start_val |
348 | * | |
349 | * output: | |
350 | * none | |
351 | * | |
d62a17ae | 352 | * return value: |
65efcfce | 353 | --------------------------------------------*/ |
d62a17ae | 354 | extern void rfp_stop(void *rfp_start_val); |
65efcfce LB |
355 | |
356 | /*********************************************************************** | |
357 | * RFP processing behavior configuration | |
358 | ***********************************************************************/ | |
359 | ||
360 | /*------------------------------------------ | |
361 | * rfapi_rfp_set_configuration | |
362 | * | |
d62a17ae | 363 | * This is used to change rfapi's processing behavior based on |
364 | * RFP requirements. | |
65efcfce | 365 | * |
d62a17ae | 366 | * input: |
65efcfce LB |
367 | * rfp_start_val value returned by rfp_start |
368 | * rfapi_rfp_cfg Pointer to configuration structure | |
369 | * | |
370 | * output: | |
371 | * none | |
372 | * | |
d62a17ae | 373 | * return value: |
65efcfce LB |
374 | * 0 Success |
375 | * ENXIO Unabled to locate configured BGP/VNC | |
376 | --------------------------------------------*/ | |
d62a17ae | 377 | extern int rfapi_rfp_set_configuration(void *rfp_start_val, |
378 | struct rfapi_rfp_cfg *rfp_cfg); | |
65efcfce LB |
379 | |
380 | /*------------------------------------------ | |
381 | * rfapi_rfp_set_cb_methods | |
382 | * | |
d62a17ae | 383 | * Change registered callback functions for asynchronous notifications |
65efcfce LB |
384 | * from RFAPI to the RFP client. |
385 | * | |
d62a17ae | 386 | * input: |
65efcfce LB |
387 | * rfp_start_val value by rfp_start |
388 | * methods Pointer to struct rfapi_rfp_cb_methods containing | |
389 | * pointers to callback methods as described above | |
390 | * | |
d62a17ae | 391 | * return value: |
65efcfce LB |
392 | * 0 Success |
393 | * ENXIO BGP or VNC not configured | |
394 | *------------------------------------------*/ | |
d62a17ae | 395 | extern int rfapi_rfp_set_cb_methods(void *rfp_start_val, |
396 | struct rfapi_rfp_cb_methods *methods); | |
65efcfce LB |
397 | |
398 | /*********************************************************************** | |
399 | * RFP group specific configuration | |
400 | ***********************************************************************/ | |
401 | ||
402 | /*------------------------------------------ | |
403 | * rfapi_rfp_init_group_config_ptr_vty | |
404 | * | |
405 | * This is used to init or return a previously init'ed group specific | |
d62a17ae | 406 | * configuration pointer. Group is identified by vty context. |
65efcfce LB |
407 | * NOTE: size is ignored when a previously init'ed value is returned. |
408 | * RFAPI frees rfp_cfg_group when group is deleted during reconfig, | |
409 | * bgp restart or shutdown. | |
410 | * | |
d62a17ae | 411 | * input: |
65efcfce LB |
412 | * rfp_start_val value returned by rfp_start |
413 | * type group type | |
414 | * vty quagga vty context | |
415 | * size number of bytes to allocation | |
416 | * | |
417 | * output: | |
418 | * none | |
419 | * | |
d62a17ae | 420 | * return value: |
65efcfce LB |
421 | * rfp_cfg_group NULL or Pointer to configuration structure |
422 | --------------------------------------------*/ | |
d62a17ae | 423 | extern void *rfapi_rfp_init_group_config_ptr_vty(void *rfp_start_val, |
424 | rfapi_rfp_cfg_group_type type, | |
425 | struct vty *vty, | |
426 | uint32_t size); | |
65efcfce LB |
427 | |
428 | /*------------------------------------------ | |
429 | * rfapi_rfp_get_group_config_ptr_vty | |
430 | * | |
431 | * This is used to get group specific configuration pointer. | |
d62a17ae | 432 | * Group is identified by type and vty context. |
65efcfce LB |
433 | * RFAPI frees rfp_cfg_group when group is deleted during reconfig, |
434 | * bgp restart or shutdown. | |
435 | * | |
d62a17ae | 436 | * input: |
65efcfce LB |
437 | * rfp_start_val value returned by rfp_start |
438 | * type group type | |
439 | * vty quagga vty context | |
440 | * | |
441 | * output: | |
442 | * none | |
443 | * | |
444 | * return value: | |
d62a17ae | 445 | * rfp_cfg_group Pointer to configuration structure |
65efcfce | 446 | --------------------------------------------*/ |
d62a17ae | 447 | extern void *rfapi_rfp_get_group_config_ptr_vty(void *rfp_start_val, |
448 | rfapi_rfp_cfg_group_type type, | |
449 | struct vty *vty); | |
65efcfce LB |
450 | |
451 | /*------------------------------------------ | |
452 | * rfp_group_config_search_cb_t (callback typedef) | |
453 | * | |
d62a17ae | 454 | * This callback is used to called from within a |
65efcfce LB |
455 | * rfapi_rfp_get_group_config_ptr to check if the rfp_cfg_group |
456 | * matches the search criteria | |
457 | * | |
d62a17ae | 458 | * input: |
65efcfce LB |
459 | * criteria RFAPI caller provided serach criteria |
460 | * rfp_cfg_group Pointer to configuration structure | NULL | |
461 | * | |
462 | * output: | |
463 | * | |
d62a17ae | 464 | * return value: |
65efcfce LB |
465 | * 0 Match/Success |
466 | * ENOENT No matching | |
467 | --------------------------------------------*/ | |
d62a17ae | 468 | typedef int(rfp_group_config_search_cb_t)(void *criteria, void *rfp_cfg_group); |
65efcfce LB |
469 | |
470 | /*------------------------------------------ | |
471 | * rfapi_rfp_get_group_config_ptr_name | |
472 | * | |
473 | * This is used to get group specific configuration pointer. | |
d62a17ae | 474 | * Group is identified by type and name context. |
65efcfce LB |
475 | * RFAPI frees rfp_cfg_group when group is deleted during reconfig, |
476 | * bgp restart or shutdown. | |
477 | * | |
d62a17ae | 478 | * input: |
65efcfce LB |
479 | * rfp_start_val value returned by rfp_start |
480 | * type group type | |
481 | * name group name | |
482 | * criteria RFAPI caller provided serach criteria | |
483 | * search_cb optional rfp_group_config_search_cb_t | |
484 | * | |
485 | * output: | |
486 | * none | |
487 | * | |
488 | * return value: | |
d62a17ae | 489 | * rfp_cfg_group Pointer to configuration structure |
65efcfce | 490 | --------------------------------------------*/ |
d62a17ae | 491 | extern void *rfapi_rfp_get_group_config_ptr_name( |
492 | void *rfp_start_val, rfapi_rfp_cfg_group_type type, const char *name, | |
493 | void *criteria, rfp_group_config_search_cb_t *search_cb); | |
65efcfce LB |
494 | |
495 | /*------------------------------------------ | |
496 | * rfapi_rfp_get_l2_group_config_ptr_lni | |
497 | * | |
498 | * This is used to get group specific configuration pointer. | |
499 | * Group is identified by type and logical network identifier. | |
500 | * RFAPI frees rfp_cfg_group when group is deleted during reconfig, | |
d62a17ae | 501 | * bgp restart or shutdown. |
65efcfce | 502 | * |
d62a17ae | 503 | * input: |
65efcfce LB |
504 | * rfp_start_val value returned by rfp_start |
505 | * logical_net_id group logical network identifier | |
506 | * criteria RFAPI caller provided serach criteria | |
507 | * search_cb optional rfp_group_config_search_cb_t | |
508 | * | |
509 | * output: | |
510 | * none | |
511 | * | |
512 | * return value: | |
d62a17ae | 513 | * rfp_cfg_group Pointer to configuration structure |
65efcfce LB |
514 | --------------------------------------------*/ |
515 | extern void * | |
d62a17ae | 516 | rfapi_rfp_get_l2_group_config_ptr_lni(void *rfp_start_val, |
517 | uint32_t logical_net_id, void *criteria, | |
518 | rfp_group_config_search_cb_t *search_cb); | |
65efcfce LB |
519 | |
520 | /*********************************************************************** | |
521 | * NVE Sessions | |
522 | ***********************************************************************/ | |
523 | ||
524 | /*------------------------------------------ | |
525 | * rfapi_open | |
526 | * | |
527 | * This function initializes a NVE record and associates it with | |
528 | * the specified VN and underlay network addresses | |
529 | * | |
d62a17ae | 530 | * input: |
65efcfce LB |
531 | * rfp_start_val value returned by rfp_start |
532 | * vn NVE virtual network address | |
533 | * | |
534 | * un NVE underlay network address | |
535 | * | |
536 | * default_options Default options to use on registrations. | |
537 | * For now only tunnel type is supported. | |
538 | * May be overridden per-prefix in rfapi_register(). | |
539 | * Caller owns (rfapi_open() does not free) | |
540 | * | |
541 | * response_cb Pointer to next hop list update callback function or | |
542 | * NULL when no callbacks are desired. | |
543 | * | |
544 | * userdata Passed to subsequent response_cb invocations. | |
545 | * | |
546 | * output: | |
547 | * response_lifetime The length of time that responses sent to this | |
d62a17ae | 548 | * NVE are valid. |
65efcfce LB |
549 | * |
550 | * pHandle pointer to location to store rfapi handle. The | |
551 | * handle must be passed on subsequent rfapi_ calls. | |
552 | * | |
553 | * | |
d62a17ae | 554 | * return value: |
65efcfce LB |
555 | * 0 Success |
556 | * EEXIST NVE with this {vn,un} already open | |
557 | * ENOENT No matching nve group config | |
558 | * ENOMSG Matched nve group config was incomplete | |
559 | * ENXIO BGP or VNC not configured | |
560 | * EAFNOSUPPORT Matched nve group specifies auto-assignment of RD, | |
561 | * but underlay network address is not IPv4 | |
562 | * EDEADLK Called from within a callback procedure | |
563 | *------------------------------------------*/ | |
d62a17ae | 564 | extern int rfapi_open(void *rfp_start_val, struct rfapi_ip_addr *vn, |
565 | struct rfapi_ip_addr *un, | |
566 | struct rfapi_un_option *default_options, | |
567 | uint32_t *response_lifetime, void *userdata, | |
568 | rfapi_handle *pHandle); | |
65efcfce LB |
569 | |
570 | ||
571 | /*------------------------------------------ | |
572 | * rfapi_close | |
573 | * | |
574 | * Shut down NVE session and release associated data. Calling | |
575 | * from within a rfapi callback procedure is permitted (the close | |
576 | * will be completed asynchronously after the callback finishes). | |
577 | * | |
d62a17ae | 578 | * input: |
65efcfce LB |
579 | * rfd: rfapi descriptor returned by rfapi_open |
580 | * | |
581 | * output: | |
582 | * | |
583 | * return value: | |
584 | * 0 Success | |
585 | * EBADF invalid handle | |
586 | * ENXIO BGP or VNC not configured | |
587 | *------------------------------------------*/ | |
d62a17ae | 588 | extern int rfapi_close(rfapi_handle rfd); |
65efcfce LB |
589 | |
590 | /*------------------------------------------ | |
591 | * rfapi_check | |
592 | * | |
593 | * Test rfapi descriptor | |
594 | * | |
d62a17ae | 595 | * input: |
65efcfce LB |
596 | * rfd: rfapi descriptor returned by rfapi_open |
597 | * | |
598 | * output: | |
599 | * | |
600 | * return value: | |
601 | * 0 Success: handle is valid and usable | |
602 | * EINVAL null argument | |
603 | * ESTALE formerly valid handle invalidated by config, needs close | |
604 | * EBADF invalid handle | |
605 | * ENXIO BGP or VNC not configured | |
606 | * EAFNOSUPPORT Internal addressing error | |
607 | *------------------------------------------*/ | |
d62a17ae | 608 | extern int rfapi_check(rfapi_handle rfd); |
65efcfce LB |
609 | |
610 | /*********************************************************************** | |
611 | * NVE Routes | |
612 | ***********************************************************************/ | |
613 | ||
614 | /*------------------------------------------ | |
615 | * rfapi_query | |
616 | * | |
d62a17ae | 617 | * This function queries the RIB for a |
618 | * particular route. Note that this call may result in subsequent | |
65efcfce LB |
619 | * callbacks to response_cb. Response callbacks can be cancelled |
620 | * by calling rfapi_query_done. A duplicate query using the same target | |
621 | * will result in only one callback per change in next_hops. (i.e., | |
622 | * cancel/replace the prior query results.) | |
623 | * | |
d62a17ae | 624 | * input: |
65efcfce LB |
625 | * rfd: rfapi descriptor returned by rfapi_open |
626 | * target: the destination address | |
627 | * l2o ptr to L2 Options struct, NULL if not present in query | |
628 | * | |
629 | * output: | |
630 | * ppNextHopEntry pointer to a location to store a pointer | |
631 | * to the returned list of nexthops. It is the | |
632 | * caller's responsibility to free this list | |
633 | * via rfapi_free_next_hop_list(). | |
634 | * | |
635 | * | |
636 | * return value: | |
637 | * 0 Success | |
638 | * EBADF invalid handle | |
639 | * ENOENT no valid route | |
640 | * ENXIO BGP or VNC not configured | |
641 | * ESTALE descriptor is no longer usable; should be closed | |
642 | * EDEADLK Called from within a callback procedure | |
643 | --------------------------------------------*/ | |
d62a17ae | 644 | extern int rfapi_query(rfapi_handle rfd, struct rfapi_ip_addr *target, |
645 | struct rfapi_l2address_option *l2o, | |
646 | struct rfapi_next_hop_entry **ppNextHopEntry); | |
65efcfce LB |
647 | |
648 | /*------------------------------------------ | |
649 | * rfapi_query_done | |
650 | * | |
d62a17ae | 651 | * Notifies the rfapi that the user is no longer interested |
652 | * in the specified target. | |
65efcfce | 653 | * |
d62a17ae | 654 | * input: |
65efcfce LB |
655 | * rfd: rfapi descriptor returned by rfapi_open |
656 | * target: the destination address | |
657 | * | |
658 | * output: | |
659 | * | |
660 | * return value: | |
661 | * 0 Success | |
662 | * EBADF invalid handle | |
663 | * ENOENT no match found for target | |
664 | * ENXIO BGP or VNC not configured | |
665 | * ESTALE descriptor is no longer usable; should be closed | |
666 | * EDEADLK Called from within a callback procedure | |
667 | --------------------------------------------*/ | |
d62a17ae | 668 | extern int rfapi_query_done(rfapi_handle rfd, struct rfapi_ip_addr *target); |
65efcfce LB |
669 | |
670 | /*------------------------------------------ | |
671 | * rfapi_query_done_all | |
672 | * | |
d62a17ae | 673 | * Notifies the rfapi that the user is no longer interested |
674 | * in any target. | |
65efcfce | 675 | * |
d62a17ae | 676 | * input: |
65efcfce LB |
677 | * rfd: rfapi descriptor returned by rfapi_open |
678 | * | |
679 | * output: | |
680 | * count: number of queries cleared | |
681 | * | |
682 | * return value: | |
683 | * 0 Success | |
684 | * EBADF invalid handle | |
685 | * ENXIO BGP or VNC not configured | |
686 | * ESTALE descriptor is no longer usable; should be closed | |
687 | * EDEADLK Called from within a callback procedure | |
688 | --------------------------------------------*/ | |
d62a17ae | 689 | extern int rfapi_query_done_all(rfapi_handle rfd, int *count); |
65efcfce LB |
690 | |
691 | /*------------------------------------------ | |
692 | * rfapi_register | |
693 | * | |
694 | * Requests that reachability to the indicated prefix via this NVE | |
695 | * be advertised by BGP. If <unregister> is non-zero, then the previously- | |
696 | * advertised prefix should be withdrawn. | |
d62a17ae | 697 | * |
698 | * (This function should NOT be called if the rfapi_open() function | |
65efcfce LB |
699 | * returns NULL) |
700 | * | |
d62a17ae | 701 | * input: |
65efcfce LB |
702 | * rfd: rfapi descriptor returned by rfapi_open |
703 | * prefix: A prefix to be registered or deregistered | |
704 | * lifetime Prefix lifetime in seconds, host byte order | |
705 | * options_un underlay netowrk options, may include tunnel-type | |
706 | * Caller owns (rfapi_register() does not free). | |
707 | * options_vn virtual network options, may include layer 2 address | |
708 | * option and local-nexthop option | |
709 | * Caller owns (rfapi_register() does not free). | |
710 | * | |
711 | * action: RFAPI_REGISTER_ADD add the route | |
712 | * RFAPI_REGISTER_WITHDRAW withdraw route | |
713 | * RFAPI_REGISTER_KILL withdraw without holddown | |
714 | * | |
715 | * return value: | |
716 | * 0 Success | |
717 | * EBADF invalid handle | |
718 | * ENXIO BGP or VNC not configured | |
719 | * ESTALE descriptor is no longer usable; should be closed | |
720 | * EDEADLK Called from within a callback procedure | |
721 | --------------------------------------------*/ | |
722 | ||
d62a17ae | 723 | typedef enum { |
724 | RFAPI_REGISTER_ADD, | |
725 | RFAPI_REGISTER_WITHDRAW, | |
726 | RFAPI_REGISTER_KILL | |
65efcfce LB |
727 | } rfapi_register_action; |
728 | ||
d62a17ae | 729 | extern int rfapi_register(rfapi_handle rfd, struct rfapi_ip_prefix *prefix, |
730 | uint32_t lifetime, struct rfapi_un_option *options_un, | |
731 | struct rfapi_vn_option *options_vn, | |
732 | rfapi_register_action action); | |
65efcfce LB |
733 | |
734 | /*********************************************************************** | |
735 | * Helper / Utility functions | |
736 | ***********************************************************************/ | |
737 | ||
738 | /*------------------------------------------ | |
739 | * rfapi_get_vn_addr | |
740 | * | |
741 | * Get the virtual network address used by an NVE based on it's RFD | |
742 | * | |
d62a17ae | 743 | * input: |
65efcfce LB |
744 | * rfd: rfapi descriptor returned by rfapi_open or rfapi_create_generic |
745 | * | |
746 | * output: | |
747 | * | |
d62a17ae | 748 | * return value: |
65efcfce LB |
749 | * vn NVE virtual network address |
750 | *------------------------------------------*/ | |
d62a17ae | 751 | extern struct rfapi_ip_addr *rfapi_get_vn_addr(void *); |
65efcfce LB |
752 | |
753 | /*------------------------------------------ | |
754 | * rfapi_get_un_addr | |
755 | * | |
756 | * Get the underlay network address used by an NVE based on it's RFD | |
757 | * | |
d62a17ae | 758 | * input: |
65efcfce LB |
759 | * rfd: rfapi descriptor returned by rfapi_open or rfapi_create_generic |
760 | * | |
761 | * output: | |
762 | * | |
d62a17ae | 763 | * return value: |
65efcfce LB |
764 | * un NVE underlay network address |
765 | *------------------------------------------*/ | |
d62a17ae | 766 | extern struct rfapi_ip_addr *rfapi_get_un_addr(void *); |
65efcfce LB |
767 | |
768 | /*------------------------------------------ | |
769 | * rfapi_error_str | |
770 | * | |
771 | * Returns a string describing the rfapi error code. | |
772 | * | |
773 | * input: | |
774 | * | |
775 | * code Error code returned by rfapi function | |
776 | * | |
777 | * returns: | |
778 | * | |
779 | * const char * String | |
780 | *------------------------------------------*/ | |
d62a17ae | 781 | extern const char *rfapi_error_str(int code); |
65efcfce LB |
782 | |
783 | /*------------------------------------------ | |
784 | * rfapi_get_rfp_start_val | |
785 | * | |
786 | * Returns value passed to rfapi on rfp_start | |
787 | * | |
788 | * input: | |
789 | * void * bgp structure | |
790 | * | |
791 | * returns: | |
d62a17ae | 792 | * void * |
65efcfce | 793 | *------------------------------------------*/ |
d62a17ae | 794 | extern void *rfapi_get_rfp_start_val(void *bgpv); |
65efcfce LB |
795 | |
796 | /*------------------------------------------ | |
797 | * rfapi_compare_rfds | |
798 | * | |
799 | * Compare two generic rfapi descriptors. | |
800 | * | |
d62a17ae | 801 | * input: |
65efcfce LB |
802 | * rfd1: rfapi descriptor returned by rfapi_open or rfapi_create_generic |
803 | * rfd2: rfapi descriptor returned by rfapi_open or rfapi_create_generic | |
804 | * | |
805 | * output: | |
806 | * | |
807 | * return value: | |
808 | * 0 Mismatch | |
809 | * 1 Match | |
810 | *------------------------------------------*/ | |
d62a17ae | 811 | extern int rfapi_compare_rfds(void *rfd1, void *rfd2); |
65efcfce LB |
812 | |
813 | /*------------------------------------------ | |
814 | * rfapi_free_next_hop_list | |
815 | * | |
816 | * Frees a next_hop_list returned by a rfapi_query invocation | |
817 | * | |
d62a17ae | 818 | * input: |
819 | * list: a pointer to a response list (as a | |
65efcfce LB |
820 | * struct rfapi_next_hop_entry) to free. |
821 | * | |
822 | * output: | |
823 | * | |
824 | * return value: None | |
825 | --------------------------------------------*/ | |
d62a17ae | 826 | extern void rfapi_free_next_hop_list(struct rfapi_next_hop_entry *list); |
65efcfce LB |
827 | |
828 | /*------------------------------------------ | |
829 | * rfapi_get_response_lifetime_default | |
830 | * | |
831 | * Returns the default lifetime for a response. | |
832 | * rfp_start_val value returned by rfp_start or | |
833 | * NULL (=use default instance) | |
834 | * | |
d62a17ae | 835 | * input: |
65efcfce LB |
836 | * None |
837 | * | |
838 | * output: | |
839 | * | |
840 | * return value: The bgp instance default lifetime for a response. | |
841 | --------------------------------------------*/ | |
d62a17ae | 842 | extern int rfapi_get_response_lifetime_default(void *rfp_start_val); |
65efcfce LB |
843 | |
844 | /*------------------------------------------ | |
845 | * rfapi_is_vnc_configured | |
846 | * | |
00827590 | 847 | * Returns if VNC is configured |
65efcfce | 848 | * |
d62a17ae | 849 | * input: |
65efcfce LB |
850 | * rfp_start_val value returned by rfp_start or |
851 | * NULL (=use default instance) | |
852 | * | |
853 | * output: | |
854 | * | |
855 | * return value: If VNC is configured for the bgpd instance | |
856 | * 0 Success | |
857 | * ENXIO VNC not configured | |
858 | --------------------------------------------*/ | |
d62a17ae | 859 | extern int rfapi_is_vnc_configured(void *rfp_start_val); |
65efcfce LB |
860 | |
861 | /*------------------------------------------ | |
862 | * rfapi_bgp_lookup_by_rfp | |
863 | * | |
864 | * Find bgp instance pointer based on value returned by rfp_start | |
865 | * | |
d62a17ae | 866 | * input: |
65efcfce LB |
867 | * rfp_start_val value returned by rfp_startor |
868 | * NULL (=get default instance) | |
869 | * | |
870 | * output: | |
871 | * none | |
872 | * | |
873 | * return value: | |
874 | * bgp bgp instance pointer | |
875 | * NULL = not found | |
876 | * | |
877 | --------------------------------------------*/ | |
d62a17ae | 878 | extern struct bgp *rfapi_bgp_lookup_by_rfp(void *rfp_start_val); |
65efcfce LB |
879 | |
880 | /*------------------------------------------ | |
881 | * rfapi_get_rfp_start_val_by_bgp | |
882 | * | |
883 | * Find bgp instance pointer based on value returned by rfp_start | |
884 | * | |
d62a17ae | 885 | * input: |
65efcfce LB |
886 | * bgp bgp instance pointer |
887 | * | |
888 | * output: | |
889 | * none | |
890 | * | |
891 | * return value: | |
892 | * rfp_start_val | |
893 | * NULL = not found | |
894 | * | |
895 | --------------------------------------------*/ | |
d62a17ae | 896 | extern void *rfapi_get_rfp_start_val_by_bgp(struct bgp *bgp); |
65efcfce LB |
897 | |
898 | #endif /* ENABLE_BGP_VNC */ | |
899 | ||
900 | #endif /* _QUAGGA_BGP_RFAPI_H */ |