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