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