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