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