]>
Commit | Line | Data |
---|---|---|
e9e2c950 RZ |
1 | /********************************************************************* |
2 | * Copyright 2014,2015,2016,2017 Cumulus Networks, Inc. All rights reserved. | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify it | |
5 | * under the terms of the GNU General Public License as published by the Free | |
6 | * Software Foundation; either version 2 of the License, or (at your option) | |
7 | * any later version. | |
8 | * | |
9 | * This program is distributed in the hope that it will be useful, but WITHOUT | |
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
12 | * more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License along | |
15 | * with this program; see the file COPYING; if not, write to the Free Software | |
16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
17 | * | |
18 | * bfd.h: implements the BFD protocol. | |
19 | */ | |
20 | ||
21 | #ifndef _BFD_H_ | |
22 | #define _BFD_H_ | |
23 | ||
24 | #include <netinet/in.h> | |
25 | ||
26 | #include <stdbool.h> | |
27 | #include <stdarg.h> | |
28 | #include <stdint.h> | |
29 | ||
30 | #include "lib/hash.h" | |
31 | #include "lib/libfrr.h" | |
32 | #include "lib/qobj.h" | |
33 | #include "lib/queue.h" | |
80edb675 | 34 | #include "lib/vrf.h" |
e9e2c950 RZ |
35 | |
36 | #include "bfdctl.h" | |
37 | ||
e9e2c950 RZ |
38 | #ifdef BFD_DEBUG |
39 | #define BFDD_JSON_CONV_OPTIONS (JSON_C_TO_STRING_PRETTY) | |
40 | #else | |
41 | #define BFDD_JSON_CONV_OPTIONS (0) | |
42 | #endif | |
43 | ||
44 | DECLARE_MGROUP(BFDD); | |
45 | DECLARE_MTYPE(BFDD_TMP); | |
46 | DECLARE_MTYPE(BFDD_CONFIG); | |
47 | DECLARE_MTYPE(BFDD_LABEL); | |
48 | DECLARE_MTYPE(BFDD_CONTROL); | |
d245e522 | 49 | DECLARE_MTYPE(BFDD_SESSION_OBSERVER); |
e9e2c950 RZ |
50 | DECLARE_MTYPE(BFDD_NOTIFICATION); |
51 | ||
e52a6383 PG |
52 | extern struct zebra_privs_t bfdd_privs; |
53 | ||
e9e2c950 RZ |
54 | struct bfd_timers { |
55 | uint32_t desired_min_tx; | |
56 | uint32_t required_min_rx; | |
57 | uint32_t required_min_echo; | |
58 | }; | |
59 | ||
60 | struct bfd_discrs { | |
61 | uint32_t my_discr; | |
62 | uint32_t remote_discr; | |
63 | }; | |
64 | ||
65 | /* | |
66 | * Format of control packet. From section 4) | |
67 | */ | |
68 | struct bfd_pkt { | |
69 | union { | |
70 | uint32_t byteFields; | |
71 | struct { | |
72 | uint8_t diag; | |
73 | uint8_t flags; | |
74 | uint8_t detect_mult; | |
75 | uint8_t len; | |
76 | }; | |
77 | }; | |
78 | struct bfd_discrs discrs; | |
79 | struct bfd_timers timers; | |
80 | }; | |
81 | ||
82 | /* | |
83 | * Format of Echo packet. | |
84 | */ | |
85 | struct bfd_echo_pkt { | |
86 | union { | |
87 | uint32_t byteFields; | |
88 | struct { | |
89 | uint8_t ver; | |
90 | uint8_t len; | |
91 | uint16_t reserved; | |
92 | }; | |
93 | }; | |
94 | uint32_t my_discr; | |
95 | uint8_t pad[16]; | |
96 | }; | |
97 | ||
98 | ||
99 | /* Macros for manipulating control packets */ | |
100 | #define BFD_VERMASK 0x03 | |
101 | #define BFD_DIAGMASK 0x1F | |
102 | #define BFD_GETVER(diag) ((diag >> 5) & BFD_VERMASK) | |
103 | #define BFD_SETVER(diag, val) ((diag) |= (val & BFD_VERMASK) << 5) | |
104 | #define BFD_VERSION 1 | |
105 | #define BFD_PBIT 0x20 | |
106 | #define BFD_FBIT 0x10 | |
107 | #define BFD_CBIT 0x08 | |
108 | #define BFD_ABIT 0x04 | |
109 | #define BFD_DEMANDBIT 0x02 | |
e9e2c950 RZ |
110 | #define BFD_SETDEMANDBIT(flags, val) \ |
111 | { \ | |
112 | if ((val)) \ | |
113 | flags |= BFD_DEMANDBIT; \ | |
114 | } | |
115 | #define BFD_SETPBIT(flags, val) \ | |
116 | { \ | |
117 | if ((val)) \ | |
118 | flags |= BFD_PBIT; \ | |
119 | } | |
120 | #define BFD_GETPBIT(flags) (flags & BFD_PBIT) | |
121 | #define BFD_SETFBIT(flags, val) \ | |
122 | { \ | |
123 | if ((val)) \ | |
124 | flags |= BFD_FBIT; \ | |
125 | } | |
126 | #define BFD_GETFBIT(flags) (flags & BFD_FBIT) | |
127 | #define BFD_SETSTATE(flags, val) \ | |
128 | { \ | |
129 | if ((val)) \ | |
130 | flags |= (val & 0x3) << 6; \ | |
131 | } | |
132 | #define BFD_GETSTATE(flags) ((flags >> 6) & 0x3) | |
133 | #define BFD_ECHO_VERSION 1 | |
134 | #define BFD_ECHO_PKT_LEN sizeof(struct bfd_echo_pkt) | |
e9e2c950 | 135 | |
40675ea9 RZ |
136 | enum bfd_diagnosticis { |
137 | BD_OK = 0, | |
138 | /* Control Detection Time Expired. */ | |
139 | BD_CONTROL_EXPIRED = 1, | |
140 | /* Echo Function Failed. */ | |
141 | BD_ECHO_FAILED = 2, | |
142 | /* Neighbor Signaled Session Down. */ | |
143 | BD_NEIGHBOR_DOWN = 3, | |
144 | /* Forwarding Plane Reset. */ | |
145 | BD_FORWARDING_RESET = 4, | |
146 | /* Path Down. */ | |
147 | BD_PATH_DOWN = 5, | |
148 | /* Concatenated Path Down. */ | |
149 | BD_CONCATPATH_DOWN = 6, | |
150 | /* Administratively Down. */ | |
151 | BD_ADMIN_DOWN = 7, | |
152 | /* Reverse Concatenated Path Down. */ | |
153 | BD_REVCONCATPATH_DOWN = 8, | |
154 | /* 9..31: reserved. */ | |
155 | }; | |
156 | ||
e9e2c950 RZ |
157 | /* BFD session flags */ |
158 | enum bfd_session_flags { | |
159 | BFD_SESS_FLAG_NONE = 0, | |
160 | BFD_SESS_FLAG_ECHO = 1 << 0, /* BFD Echo functionality */ | |
161 | BFD_SESS_FLAG_ECHO_ACTIVE = 1 << 1, /* BFD Echo Packets are being sent | |
162 | * actively | |
163 | */ | |
164 | BFD_SESS_FLAG_MH = 1 << 2, /* BFD Multi-hop session */ | |
e9e2c950 RZ |
165 | BFD_SESS_FLAG_IPV6 = 1 << 4, /* BFD IPv6 session */ |
166 | BFD_SESS_FLAG_SEND_EVT_ACTIVE = 1 << 5, /* send event timer active */ | |
167 | BFD_SESS_FLAG_SEND_EVT_IGNORE = 1 << 6, /* ignore send event when timer | |
168 | * expires | |
169 | */ | |
170 | BFD_SESS_FLAG_SHUTDOWN = 1 << 7, /* disable BGP peer function */ | |
6bdb4a42 | 171 | BFD_SESS_FLAG_CONFIG = 1 << 8, /* Session configured with bfd NB API */ |
e9e2c950 RZ |
172 | }; |
173 | ||
174 | #define BFD_SET_FLAG(field, flag) (field |= flag) | |
175 | #define BFD_UNSET_FLAG(field, flag) (field &= ~flag) | |
176 | #define BFD_CHECK_FLAG(field, flag) (field & flag) | |
177 | ||
178 | /* BFD session hash keys */ | |
79b4a6fc RZ |
179 | struct bfd_key { |
180 | uint16_t family; | |
181 | uint8_t mhop; | |
182 | struct in6_addr peer; | |
183 | struct in6_addr local; | |
184 | char ifname[MAXNAMELEN]; | |
185 | char vrfname[MAXNAMELEN]; | |
e9e2c950 RZ |
186 | }; |
187 | ||
188 | struct bfd_session_stats { | |
189 | uint64_t rx_ctrl_pkt; | |
190 | uint64_t tx_ctrl_pkt; | |
191 | uint64_t rx_echo_pkt; | |
192 | uint64_t tx_echo_pkt; | |
0684c9b1 RZ |
193 | uint64_t session_up; |
194 | uint64_t session_down; | |
195 | uint64_t znotification; | |
e9e2c950 RZ |
196 | }; |
197 | ||
e9e2c950 RZ |
198 | /* bfd_session shortcut label forwarding. */ |
199 | struct peer_label; | |
200 | ||
201 | /* | |
202 | * Session state information | |
203 | */ | |
204 | struct bfd_session { | |
205 | ||
206 | /* protocol state per RFC 5880*/ | |
207 | uint8_t ses_state; | |
208 | struct bfd_discrs discrs; | |
209 | uint8_t local_diag; | |
210 | uint8_t demand_mode; | |
211 | uint8_t detect_mult; | |
212 | uint8_t remote_detect_mult; | |
213 | uint8_t mh_ttl; | |
214 | ||
215 | /* Timers */ | |
216 | struct bfd_timers timers; | |
f43b9368 | 217 | struct bfd_timers cur_timers; |
e9e2c950 RZ |
218 | uint64_t detect_TO; |
219 | struct thread *echo_recvtimer_ev; | |
220 | struct thread *recvtimer_ev; | |
221 | uint64_t xmt_TO; | |
222 | uint64_t echo_xmt_TO; | |
223 | struct thread *xmttimer_ev; | |
224 | struct thread *echo_xmttimer_ev; | |
225 | uint64_t echo_detect_TO; | |
226 | ||
227 | /* software object state */ | |
228 | uint8_t polling; | |
229 | ||
230 | /* This and the localDiscr are the keys to state info */ | |
79b4a6fc | 231 | struct bfd_key key; |
e9e2c950 | 232 | struct peer_label *pl; |
e9e2c950 RZ |
233 | |
234 | struct sockaddr_any local_address; | |
80edb675 | 235 | struct interface *ifp; |
b333abc2 | 236 | struct vrf *vrf; |
79b4a6fc RZ |
237 | |
238 | int sock; | |
e9e2c950 RZ |
239 | |
240 | /* BFD session flags */ | |
241 | enum bfd_session_flags flags; | |
242 | ||
e9e2c950 | 243 | struct bfd_session_stats stats; |
e9e2c950 RZ |
244 | |
245 | struct timeval uptime; /* last up time */ | |
246 | struct timeval downtime; /* last down time */ | |
247 | ||
248 | /* Remote peer data (for debugging mostly) */ | |
249 | uint8_t remote_diag; | |
250 | struct bfd_timers remote_timers; | |
251 | ||
252 | uint64_t refcount; /* number of pointers referencing this. */ | |
253 | ||
254 | /* VTY context data. */ | |
255 | QOBJ_FIELDS; | |
256 | }; | |
257 | DECLARE_QOBJ_TYPE(bfd_session); | |
258 | ||
259 | struct peer_label { | |
260 | TAILQ_ENTRY(peer_label) pl_entry; | |
261 | ||
262 | struct bfd_session *pl_bs; | |
263 | char pl_label[MAXNAMELEN]; | |
264 | }; | |
265 | TAILQ_HEAD(pllist, peer_label); | |
266 | ||
267 | struct bfd_diag_str_list { | |
268 | const char *str; | |
269 | int type; | |
270 | }; | |
271 | ||
272 | struct bfd_state_str_list { | |
273 | const char *str; | |
274 | int type; | |
275 | }; | |
276 | ||
d245e522 RZ |
277 | struct bfd_session_observer { |
278 | struct bfd_session *bso_bs; | |
279 | bool bso_isinterface; | |
261e0ba9 RZ |
280 | bool bso_isaddress; |
281 | union { | |
282 | char bso_entryname[MAXNAMELEN]; | |
283 | struct prefix bso_addr; | |
284 | }; | |
d245e522 RZ |
285 | |
286 | TAILQ_ENTRY(bfd_session_observer) bso_entry; | |
287 | }; | |
288 | TAILQ_HEAD(obslist, bfd_session_observer); | |
289 | ||
e9e2c950 RZ |
290 | |
291 | /* States defined per 4.1 */ | |
292 | #define PTM_BFD_ADM_DOWN 0 | |
293 | #define PTM_BFD_DOWN 1 | |
294 | #define PTM_BFD_INIT 2 | |
295 | #define PTM_BFD_UP 3 | |
296 | ||
297 | ||
298 | /* Various constants */ | |
299 | /* Retrieved from ptm_timer.h from Cumulus PTM sources. */ | |
e9e2c950 RZ |
300 | #define BFD_DEF_DEMAND 0 |
301 | #define BFD_DEFDETECTMULT 3 | |
33400b46 RZ |
302 | #define BFD_DEFDESIREDMINTX (300 * 1000) /* microseconds. */ |
303 | #define BFD_DEFREQUIREDMINRX (300 * 1000) /* microseconds. */ | |
304 | #define BFD_DEF_REQ_MIN_ECHO (50 * 1000) /* microseconds. */ | |
305 | #define BFD_DEF_SLOWTX (1000 * 1000) /* microseconds. */ | |
e9e2c950 RZ |
306 | #define BFD_DEF_MHOP_TTL 5 |
307 | #define BFD_PKT_LEN 24 /* Length of control packet */ | |
308 | #define BFD_TTL_VAL 255 | |
309 | #define BFD_RCV_TTL_VAL 1 | |
310 | #define BFD_TOS_VAL 0xC0 | |
311 | #define BFD_PKT_INFO_VAL 1 | |
312 | #define BFD_IPV6_PKT_INFO_VAL 1 | |
313 | #define BFD_IPV6_ONLY_VAL 1 | |
545d3f70 RZ |
314 | #define BFD_SRCPORTINIT 49152 |
315 | #define BFD_SRCPORTMAX 65535 | |
e9e2c950 RZ |
316 | #define BFD_DEFDESTPORT 3784 |
317 | #define BFD_DEF_ECHO_PORT 3785 | |
318 | #define BFD_DEF_MHOP_DEST_PORT 4784 | |
e9e2c950 RZ |
319 | |
320 | /* | |
321 | * control.c | |
322 | * | |
323 | * Daemon control code to speak with local consumers. | |
324 | */ | |
325 | ||
326 | /* See 'bfdctrl.h' for client protocol definitions. */ | |
327 | ||
328 | struct bfd_control_buffer { | |
329 | size_t bcb_left; | |
330 | size_t bcb_pos; | |
331 | union { | |
332 | struct bfd_control_msg *bcb_bcm; | |
333 | uint8_t *bcb_buf; | |
334 | }; | |
335 | }; | |
336 | ||
337 | struct bfd_control_queue { | |
338 | TAILQ_ENTRY(bfd_control_queue) bcq_entry; | |
339 | ||
340 | struct bfd_control_buffer bcq_bcb; | |
341 | }; | |
342 | TAILQ_HEAD(bcqueue, bfd_control_queue); | |
343 | ||
344 | struct bfd_notify_peer { | |
345 | TAILQ_ENTRY(bfd_notify_peer) bnp_entry; | |
346 | ||
347 | struct bfd_session *bnp_bs; | |
348 | }; | |
349 | TAILQ_HEAD(bnplist, bfd_notify_peer); | |
350 | ||
351 | struct bfd_control_socket { | |
352 | TAILQ_ENTRY(bfd_control_socket) bcs_entry; | |
353 | ||
354 | int bcs_sd; | |
355 | struct thread *bcs_ev; | |
356 | struct thread *bcs_outev; | |
357 | struct bcqueue bcs_bcqueue; | |
358 | ||
359 | /* Notification data */ | |
360 | uint64_t bcs_notify; | |
361 | struct bnplist bcs_bnplist; | |
362 | ||
363 | enum bc_msg_version bcs_version; | |
364 | enum bc_msg_type bcs_type; | |
365 | ||
366 | /* Message buffering */ | |
367 | struct bfd_control_buffer bcs_bin; | |
368 | struct bfd_control_buffer *bcs_bout; | |
369 | }; | |
370 | TAILQ_HEAD(bcslist, bfd_control_socket); | |
371 | ||
372 | int control_init(const char *path); | |
373 | void control_shutdown(void); | |
374 | int control_notify(struct bfd_session *bs); | |
375 | int control_notify_config(const char *op, struct bfd_session *bs); | |
376 | int control_accept(struct thread *t); | |
377 | ||
378 | ||
379 | /* | |
380 | * bfdd.c | |
381 | * | |
382 | * Daemon specific code. | |
383 | */ | |
384 | struct bfd_global { | |
385 | int bg_shop; | |
386 | int bg_mhop; | |
387 | int bg_shop6; | |
388 | int bg_mhop6; | |
389 | int bg_echo; | |
2f11c53f | 390 | int bg_echov6; |
e9e2c950 RZ |
391 | struct thread *bg_ev[6]; |
392 | ||
393 | int bg_csock; | |
394 | struct thread *bg_csockev; | |
395 | struct bcslist bg_bcslist; | |
396 | ||
397 | struct pllist bg_pllist; | |
d245e522 RZ |
398 | |
399 | struct obslist bg_obslist; | |
e9e2c950 RZ |
400 | }; |
401 | extern struct bfd_global bglobal; | |
402 | extern struct bfd_diag_str_list diag_list[]; | |
403 | extern struct bfd_state_str_list state_list[]; | |
404 | ||
405 | void socket_close(int *s); | |
406 | ||
407 | ||
408 | /* | |
409 | * config.c | |
410 | * | |
411 | * Contains the code related with loading/reloading configuration. | |
412 | */ | |
413 | int parse_config(const char *fname); | |
414 | int config_request_add(const char *jsonstr); | |
415 | int config_request_del(const char *jsonstr); | |
416 | char *config_response(const char *status, const char *error); | |
417 | char *config_notify(struct bfd_session *bs); | |
418 | char *config_notify_config(const char *op, struct bfd_session *bs); | |
419 | ||
420 | typedef int (*bpc_handle)(struct bfd_peer_cfg *, void *arg); | |
421 | int config_notify_request(struct bfd_control_socket *bcs, const char *jsonstr, | |
422 | bpc_handle bh); | |
423 | ||
424 | struct peer_label *pl_new(const char *label, struct bfd_session *bs); | |
425 | struct peer_label *pl_find(const char *label); | |
426 | void pl_free(struct peer_label *pl); | |
427 | ||
428 | ||
429 | /* | |
430 | * log.c | |
431 | * | |
432 | * Contains code that does the logging procedures. Might implement multiple | |
433 | * backends (e.g. zebra log, syslog or other logging lib). | |
434 | */ | |
435 | enum blog_level { | |
436 | /* level vs syslog equivalent */ | |
437 | BLOG_DEBUG = 0, /* LOG_DEBUG */ | |
438 | BLOG_INFO = 1, /* LOG_INFO */ | |
439 | BLOG_WARNING = 2, /* LOG_WARNING */ | |
440 | BLOG_ERROR = 3, /* LOG_ERR */ | |
441 | BLOG_FATAL = 4, /* LOG_CRIT */ | |
442 | }; | |
443 | ||
444 | void log_init(int foreground, enum blog_level level, | |
445 | struct frr_daemon_info *fdi); | |
446 | void log_info(const char *fmt, ...); | |
447 | void log_debug(const char *fmt, ...); | |
448 | void log_warning(const char *fmt, ...); | |
449 | void log_error(const char *fmt, ...); | |
450 | void log_fatal(const char *fmt, ...); | |
451 | ||
e9e2c950 RZ |
452 | |
453 | /* | |
454 | * bfd_packet.c | |
455 | * | |
456 | * Contains the code related with receiving/seding, packing/unpacking BFD data. | |
457 | */ | |
6e01e275 RZ |
458 | int bp_set_ttlv6(int sd, uint8_t value); |
459 | int bp_set_ttl(int sd, uint8_t value); | |
460 | int bp_set_tosv6(int sd, uint8_t value); | |
461 | int bp_set_tos(int sd, uint8_t value); | |
e9e2c950 RZ |
462 | int bp_bind_dev(int sd, const char *dev); |
463 | ||
464 | int bp_udp_shop(void); | |
465 | int bp_udp_mhop(void); | |
466 | int bp_udp6_shop(void); | |
467 | int bp_udp6_mhop(void); | |
9f37770f RZ |
468 | int bp_peer_socket(const struct bfd_session *bs); |
469 | int bp_peer_socketv6(const struct bfd_session *bs); | |
2f11c53f RZ |
470 | int bp_echo_socket(void); |
471 | int bp_echov6_socket(void); | |
e9e2c950 RZ |
472 | |
473 | void ptm_bfd_snd(struct bfd_session *bfd, int fbit); | |
474 | void ptm_bfd_echo_snd(struct bfd_session *bfd); | |
475 | ||
476 | int bfd_recv_cb(struct thread *t); | |
477 | ||
e9e2c950 RZ |
478 | |
479 | /* | |
480 | * event.c | |
481 | * | |
482 | * Contains the code related with event loop. | |
483 | */ | |
484 | typedef void (*bfd_ev_cb)(struct thread *t); | |
485 | ||
486 | void bfd_recvtimer_update(struct bfd_session *bs); | |
487 | void bfd_echo_recvtimer_update(struct bfd_session *bs); | |
488 | void bfd_xmttimer_update(struct bfd_session *bs, uint64_t jitter); | |
489 | void bfd_echo_xmttimer_update(struct bfd_session *bs, uint64_t jitter); | |
490 | ||
491 | void bfd_xmttimer_delete(struct bfd_session *bs); | |
492 | void bfd_echo_xmttimer_delete(struct bfd_session *bs); | |
493 | void bfd_recvtimer_delete(struct bfd_session *bs); | |
494 | void bfd_echo_recvtimer_delete(struct bfd_session *bs); | |
495 | ||
496 | void bfd_recvtimer_assign(struct bfd_session *bs, bfd_ev_cb cb, int sd); | |
497 | void bfd_echo_recvtimer_assign(struct bfd_session *bs, bfd_ev_cb cb, int sd); | |
498 | void bfd_xmttimer_assign(struct bfd_session *bs, bfd_ev_cb cb); | |
499 | void bfd_echo_xmttimer_assign(struct bfd_session *bs, bfd_ev_cb cb); | |
500 | ||
501 | ||
502 | /* | |
503 | * bfd.c | |
504 | * | |
505 | * BFD protocol specific code. | |
506 | */ | |
9f37770f RZ |
507 | int bfd_session_enable(struct bfd_session *bs); |
508 | void bfd_session_disable(struct bfd_session *bs); | |
e9e2c950 | 509 | struct bfd_session *ptm_bfd_sess_new(struct bfd_peer_cfg *bpc); |
bc50bcc8 PG |
510 | int ptm_bfd_sess_del(struct bfd_peer_cfg *bpc); |
511 | void ptm_bfd_sess_dn(struct bfd_session *bfd, uint8_t diag); | |
512 | void ptm_bfd_sess_up(struct bfd_session *bfd); | |
8bd859f6 | 513 | void ptm_bfd_echo_stop(struct bfd_session *bfd); |
e9e2c950 RZ |
514 | void ptm_bfd_echo_start(struct bfd_session *bfd); |
515 | void ptm_bfd_xmt_TO(struct bfd_session *bfd, int fbit); | |
516 | void ptm_bfd_start_xmt_timer(struct bfd_session *bfd, bool is_echo); | |
9f37770f RZ |
517 | struct bfd_session *ptm_bfd_sess_find(struct bfd_pkt *cp, |
518 | struct sockaddr_any *peer, | |
519 | struct sockaddr_any *local, | |
520 | ifindex_t ifindex, vrf_id_t vrfid, | |
521 | bool is_mhop); | |
e9e2c950 RZ |
522 | |
523 | struct bfd_session *bs_peer_find(struct bfd_peer_cfg *bpc); | |
524 | int bfd_session_update_label(struct bfd_session *bs, const char *nlabel); | |
d3f3a2c4 | 525 | void bfd_set_polling(struct bfd_session *bs); |
9f37770f RZ |
526 | void bs_state_handler(struct bfd_session *bs, int nstate); |
527 | void bs_echo_timer_handler(struct bfd_session *bs); | |
528 | void bs_final_handler(struct bfd_session *bs); | |
b912b189 | 529 | void bs_set_slow_timers(struct bfd_session *bs); |
e9e2c950 RZ |
530 | const char *satostr(struct sockaddr_any *sa); |
531 | const char *diag2str(uint8_t diag); | |
532 | int strtosa(const char *addr, struct sockaddr_any *sa); | |
533 | void integer2timestr(uint64_t time, char *buf, size_t buflen); | |
79b4a6fc | 534 | const char *bs_to_string(const struct bfd_session *bs); |
e9e2c950 | 535 | |
9f37770f RZ |
536 | int bs_observer_add(struct bfd_session *bs); |
537 | void bs_observer_del(struct bfd_session_observer *bso); | |
d245e522 | 538 | |
79b4a6fc RZ |
539 | void bs_to_bpc(struct bfd_session *bs, struct bfd_peer_cfg *bpc); |
540 | ||
e9e2c950 RZ |
541 | /* BFD hash data structures interface */ |
542 | void bfd_initialize(void); | |
543 | void bfd_shutdown(void); | |
9fc0bc5c | 544 | void bfd_vrf_init(void); |
e9e2c950 | 545 | struct bfd_session *bfd_id_lookup(uint32_t id); |
79b4a6fc | 546 | struct bfd_session *bfd_key_lookup(struct bfd_key key); |
e9e2c950 RZ |
547 | |
548 | struct bfd_session *bfd_id_delete(uint32_t id); | |
79b4a6fc | 549 | struct bfd_session *bfd_key_delete(struct bfd_key key); |
e9e2c950 RZ |
550 | |
551 | bool bfd_id_insert(struct bfd_session *bs); | |
79b4a6fc | 552 | bool bfd_key_insert(struct bfd_session *bs); |
e9e2c950 | 553 | |
e3b78da8 | 554 | typedef void (*hash_iter_func)(struct hash_bucket *hb, void *arg); |
e9e2c950 | 555 | void bfd_id_iterate(hash_iter_func hif, void *arg); |
79b4a6fc | 556 | void bfd_key_iterate(hash_iter_func hif, void *arg); |
e9e2c950 RZ |
557 | |
558 | /* Export callback functions for `event.c`. */ | |
559 | extern struct thread_master *master; | |
560 | ||
561 | int bfd_recvtimer_cb(struct thread *t); | |
562 | int bfd_echo_recvtimer_cb(struct thread *t); | |
563 | int bfd_xmt_cb(struct thread *t); | |
564 | int bfd_echo_xmt_cb(struct thread *t); | |
565 | ||
79b4a6fc RZ |
566 | extern struct in6_addr zero_addr; |
567 | ||
e9e2c950 | 568 | |
c2f29cf3 RZ |
569 | /* |
570 | * bfdd_vty.c | |
571 | * | |
572 | * BFD daemon vty shell commands. | |
573 | */ | |
574 | void bfdd_vty_init(void); | |
575 | ||
576 | ||
d3af6147 RZ |
577 | /* |
578 | * ptm_adapter.c | |
579 | */ | |
580 | void bfdd_zclient_init(struct zebra_privs_t *bfdd_priv); | |
581 | void bfdd_zclient_stop(void); | |
582 | ||
583 | int ptm_bfd_notify(struct bfd_session *bs); | |
584 | ||
e9e2c950 | 585 | #endif /* _BFD_H_ */ |