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