]> git.proxmox.com Git - mirror_frr.git/blob - bgpd/rfapi/rfapi.h
Merge pull request #5895 from patrasar/2404618
[mirror_frr.git] / bgpd / rfapi / rfapi.h
1 /*
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 *
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
19 */
20
21 #ifndef _QUAGGA_BGP_RFAPI_H
22 #define _QUAGGA_BGP_RFAPI_H
23
24 #ifdef ENABLE_BGP_VNC
25
26 #include <stdint.h>
27 #include <netinet/in.h>
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"
33
34 /* probably ought to have a field-specific define in config.h */
35 #ifndef s6_addr32 /* for solaris/bsd */
36 # define s6_addr32 __u6_addr.__u6_addr32
37 #endif
38
39 #define RFAPI_V4_ADDR 0x04
40 #define RFAPI_V6_ADDR 0x06
41 #define RFAPI_SHOW_STR "VNC information\n"
42
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;
49 };
50
51 struct rfapi_ip_prefix {
52 uint8_t length;
53 uint8_t cost; /* bgp local pref = 255 - cost */
54 struct rfapi_ip_addr prefix;
55 };
56
57 struct rfapi_nexthop {
58 struct prefix addr;
59 uint8_t cost;
60 };
61
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;
70 };
71
72 #define RFAPI_REMOVE_RESPONSE_LIFETIME 0
73 #define RFAPI_INFINITE_LIFETIME 0xFFFFFFFF
74
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 */
82 };
83
84 typedef enum {
85 RFAPI_UN_OPTION_TYPE_PROVISIONAL, /* internal use only */
86 RFAPI_UN_OPTION_TYPE_TUNNELTYPE,
87 } rfapi_un_option_type;
88
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;
111 };
112
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;
119 };
120
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 */
126 } rfapi_vn_option_type;
127
128 struct rfapi_vn_option {
129 struct rfapi_vn_option *next;
130
131 rfapi_vn_option_type type;
132
133 union {
134 struct rfapi_l2address_option l2addr;
135
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;
141
142 /*
143 * For rfapi internal use only
144 */
145 struct prefix_rd internal_rd;
146 } v;
147 };
148
149 struct rfapi_l2address_option_match {
150 struct rfapi_l2address_option o;
151 uint32_t flags;
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 *
169 * Callbacks of this type are used to provide asynchronous
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 *
188 * input:
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 *------------------------------------------*/
199 typedef void(rfapi_response_cb_t)(struct rfapi_next_hop_entry *next_hops,
200 void *userdata);
201
202 /*------------------------------------------
203 * rfapi_nve_close_cb_t (callback typedef)
204 *
205 * Callbacks of this type are used to provide asynchronous
206 * notification that an rfapi_handle was invalidated
207 *
208 * input:
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 *------------------------------------------*/
216 typedef void(rfapi_nve_close_cb_t)(rfapi_handle pHandle, int reason);
217
218 /*------------------------------------------
219 * rfp_cfg_write_cb_t (callback typedef)
220 *
221 * This callback is used to generate output for any config parameters
222 * that may supported by RFP via RFP defined vty commands at the bgp
223 * level. See loglevel as an example.
224 *
225 * input:
226 * vty -- quagga vty context
227 * rfp_start_val -- value returned by rfp_start
228 *
229 * output:
230 * to vty, rfp related configuration
231 *
232 * return value:
233 * lines written
234 --------------------------------------------*/
235 typedef int(rfp_cfg_write_cb_t)(struct vty *vty, void *rfp_start_val);
236
237 /*------------------------------------------
238 * rfp_cfg_group_write_cb_t (callback typedef)
239 *
240 * This callback is used to generate output for any config parameters
241 * that may supported by RFP via RFP defined vty commands at the
242 * L2 or NVE level. See loglevel as an example.
243 *
244 * input:
245 * vty quagga vty context
246 * rfp_start_val value returned by rfp_start
247 * type group type
248 * name group name
249 * rfp_cfg_group Pointer to configuration structure
250 *
251 * output:
252 * to vty, rfp related configuration
253 *
254 * return value:
255 * lines written
256 --------------------------------------------*/
257 typedef enum {
258 RFAPI_RFP_CFG_GROUP_DEFAULT,
259 RFAPI_RFP_CFG_GROUP_NVE,
260 RFAPI_RFP_CFG_GROUP_L2
261 } rfapi_rfp_cfg_group_type;
262
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);
266
267 /***********************************************************************
268 * Configuration related defines and structures
269 ***********************************************************************/
270
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 */
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
286 /*
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 /*
295 * This is used by rfapi to determine if RFP is using/supports
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
299 * rfapi_query. When partial table download is used, only
300 * information matching a query is passed.
301 */
302 typedef enum {
303 RFAPI_RFP_DOWNLOAD_PARTIAL = 0,
304 RFAPI_RFP_DOWNLOAD_FULL
305 } rfapi_rfp_download_type;
306
307 #define RFAPI_RFP_CFG_DEFAULT_FTD_ADVERTISEMENT_INTERVAL 1
308
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 */
329 };
330
331 /***********************************************************************
332 * Process related functions -- MUST be provided by the RFAPI user <<===
333 ***********************************************************************/
334
335 /*------------------------------------------
336 * rfp_start
337 *
338 * This function will start the RFP code
339 *
340 * input:
341 * master quagga thread_master to tie into bgpd threads
342 *
343 * output:
344 * cfgp Pointer to rfapi_rfp_cfg (null = use defaults),
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
348 * return value:
349 * rfp_start_val rfp returned value passed on rfp_stop and other rfapi calls
350 --------------------------------------------*/
351 extern void *rfp_start(struct thread_master *master,
352 struct rfapi_rfp_cfg **cfgp,
353 struct rfapi_rfp_cb_methods **cbmp);
354
355 /*------------------------------------------
356 * rfp_stop
357 *
358 * This function is called on shutdown to trigger RFP cleanup
359 *
360 * input:
361 * rfp_start_val
362 *
363 * output:
364 * none
365 *
366 * return value:
367 --------------------------------------------*/
368 extern void rfp_stop(void *rfp_start_val);
369
370 /***********************************************************************
371 * RFP processing behavior configuration
372 ***********************************************************************/
373
374 /*------------------------------------------
375 * rfapi_rfp_set_configuration
376 *
377 * This is used to change rfapi's processing behavior based on
378 * RFP requirements.
379 *
380 * input:
381 * rfp_start_val value returned by rfp_start
382 * rfapi_rfp_cfg Pointer to configuration structure
383 *
384 * output:
385 * none
386 *
387 * return value:
388 * 0 Success
389 * ENXIO Unabled to locate configured BGP/VNC
390 --------------------------------------------*/
391 extern int rfapi_rfp_set_configuration(void *rfp_start_val,
392 struct rfapi_rfp_cfg *rfp_cfg);
393
394 /*------------------------------------------
395 * rfapi_rfp_set_cb_methods
396 *
397 * Change registered callback functions for asynchronous notifications
398 * from RFAPI to the RFP client.
399 *
400 * input:
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 *
405 * return value:
406 * 0 Success
407 * ENXIO BGP or VNC not configured
408 *------------------------------------------*/
409 extern int rfapi_rfp_set_cb_methods(void *rfp_start_val,
410 struct rfapi_rfp_cb_methods *methods);
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
420 * configuration pointer. Group is identified by vty context.
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 *
425 * input:
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 *
434 * return value:
435 * rfp_cfg_group NULL or Pointer to configuration structure
436 --------------------------------------------*/
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);
441
442 /*------------------------------------------
443 * rfapi_rfp_get_group_config_ptr_vty
444 *
445 * This is used to get group specific configuration pointer.
446 * Group is identified by type and vty context.
447 * RFAPI frees rfp_cfg_group when group is deleted during reconfig,
448 * bgp restart or shutdown.
449 *
450 * input:
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:
459 * rfp_cfg_group Pointer to configuration structure
460 --------------------------------------------*/
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);
464
465 /*------------------------------------------
466 * rfp_group_config_search_cb_t (callback typedef)
467 *
468 * This callback is used to called from within a
469 * rfapi_rfp_get_group_config_ptr to check if the rfp_cfg_group
470 * matches the search criteria
471 *
472 * input:
473 * criteria RFAPI caller provided serach criteria
474 * rfp_cfg_group Pointer to configuration structure | NULL
475 *
476 * output:
477 *
478 * return value:
479 * 0 Match/Success
480 * ENOENT No matching
481 --------------------------------------------*/
482 typedef int(rfp_group_config_search_cb_t)(void *criteria, void *rfp_cfg_group);
483
484 /*------------------------------------------
485 * rfapi_rfp_get_group_config_ptr_name
486 *
487 * This is used to get group specific configuration pointer.
488 * Group is identified by type and name context.
489 * RFAPI frees rfp_cfg_group when group is deleted during reconfig,
490 * bgp restart or shutdown.
491 *
492 * input:
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:
503 * rfp_cfg_group Pointer to configuration structure
504 --------------------------------------------*/
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);
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,
515 * bgp restart or shutdown.
516 *
517 * input:
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:
527 * rfp_cfg_group Pointer to configuration structure
528 --------------------------------------------*/
529 extern void *
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);
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 *
544 * input:
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
562 * NVE are valid.
563 *
564 * pHandle pointer to location to store rfapi handle. The
565 * handle must be passed on subsequent rfapi_ calls.
566 *
567 *
568 * return value:
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 *------------------------------------------*/
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);
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 *
592 * input:
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 *------------------------------------------*/
602 extern int rfapi_close(rfapi_handle rfd);
603
604 /*------------------------------------------
605 * rfapi_check
606 *
607 * Test rfapi descriptor
608 *
609 * input:
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 *------------------------------------------*/
622 extern int rfapi_check(rfapi_handle rfd);
623
624 /***********************************************************************
625 * NVE Routes
626 ***********************************************************************/
627
628 /*------------------------------------------
629 * rfapi_query
630 *
631 * This function queries the RIB for a
632 * particular route. Note that this call may result in subsequent
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 *
638 * input:
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 --------------------------------------------*/
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);
661
662 /*------------------------------------------
663 * rfapi_query_done
664 *
665 * Notifies the rfapi that the user is no longer interested
666 * in the specified target.
667 *
668 * input:
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 --------------------------------------------*/
682 extern int rfapi_query_done(rfapi_handle rfd, struct rfapi_ip_addr *target);
683
684 /*------------------------------------------
685 * rfapi_query_done_all
686 *
687 * Notifies the rfapi that the user is no longer interested
688 * in any target.
689 *
690 * input:
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 --------------------------------------------*/
703 extern int rfapi_query_done_all(rfapi_handle rfd, int *count);
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.
711 *
712 * (This function should NOT be called if the rfapi_open() function
713 * returns NULL)
714 *
715 * input:
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
737 typedef enum {
738 RFAPI_REGISTER_ADD,
739 RFAPI_REGISTER_WITHDRAW,
740 RFAPI_REGISTER_KILL
741 } rfapi_register_action;
742
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);
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 *
757 * input:
758 * rfd: rfapi descriptor returned by rfapi_open or rfapi_create_generic
759 *
760 * output:
761 *
762 * return value:
763 * vn NVE virtual network address
764 *------------------------------------------*/
765 extern struct rfapi_ip_addr *rfapi_get_vn_addr(void *);
766
767 /*------------------------------------------
768 * rfapi_get_un_addr
769 *
770 * Get the underlay network address used by an NVE based on it's RFD
771 *
772 * input:
773 * rfd: rfapi descriptor returned by rfapi_open or rfapi_create_generic
774 *
775 * output:
776 *
777 * return value:
778 * un NVE underlay network address
779 *------------------------------------------*/
780 extern struct rfapi_ip_addr *rfapi_get_un_addr(void *);
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 *------------------------------------------*/
795 extern const char *rfapi_error_str(int code);
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:
806 * void *
807 *------------------------------------------*/
808 extern void *rfapi_get_rfp_start_val(void *bgpv);
809
810 /*------------------------------------------
811 * rfapi_compare_rfds
812 *
813 * Compare two generic rfapi descriptors.
814 *
815 * input:
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 *------------------------------------------*/
825 extern int rfapi_compare_rfds(void *rfd1, void *rfd2);
826
827 /*------------------------------------------
828 * rfapi_free_next_hop_list
829 *
830 * Frees a next_hop_list returned by a rfapi_query invocation
831 *
832 * input:
833 * list: a pointer to a response list (as a
834 * struct rfapi_next_hop_entry) to free.
835 *
836 * output:
837 *
838 * return value: None
839 --------------------------------------------*/
840 extern void rfapi_free_next_hop_list(struct rfapi_next_hop_entry *list);
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 *
849 * input:
850 * None
851 *
852 * output:
853 *
854 * return value: The bgp instance default lifetime for a response.
855 --------------------------------------------*/
856 extern int rfapi_get_response_lifetime_default(void *rfp_start_val);
857
858 /*------------------------------------------
859 * rfapi_is_vnc_configured
860 *
861 * Returns if VNC is configured
862 *
863 * input:
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 --------------------------------------------*/
873 extern int rfapi_is_vnc_configured(void *rfp_start_val);
874
875 /*------------------------------------------
876 * rfapi_bgp_lookup_by_rfp
877 *
878 * Find bgp instance pointer based on value returned by rfp_start
879 *
880 * input:
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 --------------------------------------------*/
892 extern struct bgp *rfapi_bgp_lookup_by_rfp(void *rfp_start_val);
893
894 /*------------------------------------------
895 * rfapi_get_rfp_start_val_by_bgp
896 *
897 * Find bgp instance pointer based on value returned by rfp_start
898 *
899 * input:
900 * bgp bgp instance pointer
901 *
902 * output:
903 * none
904 *
905 * return value:
906 * rfp_start_val
907 * NULL = not found
908 *
909 --------------------------------------------*/
910 extern void *rfapi_get_rfp_start_val_by_bgp(struct bgp *bgp);
911
912 #endif /* ENABLE_BGP_VNC */
913
914 #endif /* _QUAGGA_BGP_RFAPI_H */