| 
									
										
										
										
											2013-11-21 11:36:49 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  *	BIRD -- Bidirectional Forwarding Detection (BFD) | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *	Can be freely distributed and used under the terms of the GNU GPL. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef _BIRD_NBFD_H_
 | 
					
						
							|  |  |  | #define _BIRD_NBFD_H_
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "lib/lists.h"
 | 
					
						
							|  |  |  | #include "lib/resource.h"
 | 
					
						
							| 
									
										
										
										
											2020-11-08 15:33:22 +01:00
										 |  |  | #include "conf/conf.h"
 | 
					
						
							| 
									
										
										
										
											2013-11-21 11:36:49 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | struct bfd_session; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-08 15:33:22 +01:00
										 |  |  | struct bfd_options { | 
					
						
							|  |  |  |   u32 min_rx_int; | 
					
						
							|  |  |  |   u32 min_tx_int; | 
					
						
							|  |  |  |   u32 idle_tx_int; | 
					
						
							|  |  |  |   u8 multiplier; | 
					
						
							|  |  |  |   u8 passive; | 
					
						
							|  |  |  |   u8 passive_set; | 
					
						
							|  |  |  |   u8 mode; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-11-21 11:36:49 +01:00
										 |  |  | struct bfd_request { | 
					
						
							|  |  |  |   resource r; | 
					
						
							|  |  |  |   node n; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   ip_addr addr; | 
					
						
							|  |  |  |   ip_addr local; | 
					
						
							|  |  |  |   struct iface *iface; | 
					
						
							| 
									
										
										
										
											2019-07-17 16:20:35 +02:00
										 |  |  |   struct iface *vrf; | 
					
						
							| 
									
										
										
										
											2020-11-08 15:33:22 +01:00
										 |  |  |   struct bfd_options opts; | 
					
						
							| 
									
										
										
										
											2013-11-21 11:36:49 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |   void (*hook)(struct bfd_request *); | 
					
						
							|  |  |  |   void *data; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   struct bfd_session *session; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   u8 state; | 
					
						
							|  |  |  |   u8 diag; | 
					
						
							|  |  |  |   u8 old_state; | 
					
						
							|  |  |  |   u8 down; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-08 15:33:22 +01:00
										 |  |  | #define BGP_BFD_GRACEFUL	2	/* BFD down triggers graceful restart */
 | 
					
						
							| 
									
										
										
										
											2013-11-21 11:36:49 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-24 18:02:07 +02:00
										 |  |  | #define BFD_STATE_ADMIN_DOWN	0
 | 
					
						
							|  |  |  | #define BFD_STATE_DOWN		1
 | 
					
						
							|  |  |  | #define BFD_STATE_INIT		2
 | 
					
						
							|  |  |  | #define BFD_STATE_UP		3
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-08 15:33:22 +01:00
										 |  |  | static inline struct bfd_options * bfd_new_options(void) | 
					
						
							|  |  |  | { return cfg_allocz(sizeof(struct bfd_options)); } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-11-21 11:36:49 +01:00
										 |  |  | #ifdef CONFIG_BFD
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-08 15:33:22 +01:00
										 |  |  | struct bfd_request * bfd_request_session(pool *p, ip_addr addr, ip_addr local, struct iface *iface, struct iface *vrf, void (*hook)(struct bfd_request *), void *data, const struct bfd_options *opts); | 
					
						
							|  |  |  | void bfd_update_request(struct bfd_request *req, const struct bfd_options *opts); | 
					
						
							| 
									
										
										
										
											2013-11-21 11:36:49 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-14 15:37:04 +02:00
										 |  |  | static inline void cf_check_bfd(int use UNUSED) { } | 
					
						
							| 
									
										
										
										
											2013-11-21 11:36:49 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-08 15:33:22 +01:00
										 |  |  | static inline struct bfd_request * bfd_request_session(pool *p UNUSED, ip_addr addr UNUSED, ip_addr local UNUSED, struct iface *iface UNUSED, struct iface *vrf UNUSED, void (*hook)(struct bfd_request *) UNUSED, void *data UNUSED, const struct bfd_options *opts UNUSED) { return NULL; } | 
					
						
							|  |  |  | static inline void bfd_update_request(struct bfd_request *req UNUSED, const struct bfd_options *opts UNUSED) { }; | 
					
						
							| 
									
										
										
										
											2013-11-21 11:36:49 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | static inline void cf_check_bfd(int use) { if (use) cf_error("BFD not available"); } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif /* CONFIG_BFD */
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif /* _BIRD_NBFD_H_ */
 |