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