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