]> git.proxmox.com Git - mirror_frr.git/blame - lib/bfd.h
lib: dont decode more nexthops than we can handle
[mirror_frr.git] / lib / bfd.h
CommitLineData
7f342629
DS
1/**
2 * bfd.h: BFD definitions and structures
3 *
4 * @copyright Copyright (C) 2015 Cumulus Networks, Inc.
5 *
6 * This file is part of GNU Zebra.
7 *
8 * GNU Zebra is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2, or (at your option) any
11 * later version.
12 *
13 * GNU Zebra is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
896014f4
DL
18 * You should have received a copy of the GNU General Public License along
19 * with this program; see the file COPYING; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
7f342629
DS
21 */
22
23#ifndef _ZEBRA_BFD_H
24#define _ZEBRA_BFD_H
25
68fe91d6 26#include "lib/json.h"
43e52561 27#include "lib/zclient.h"
68fe91d6 28
5e244469
RW
29#ifdef __cplusplus
30extern "C" {
31#endif
32
7f342629
DS
33#define BFD_DEF_MIN_RX 300
34#define BFD_MIN_MIN_RX 50
35#define BFD_MAX_MIN_RX 60000
36#define BFD_DEF_MIN_TX 300
37#define BFD_MIN_MIN_TX 50
38#define BFD_MAX_MIN_TX 60000
39#define BFD_DEF_DETECT_MULT 3
40#define BFD_MIN_DETECT_MULT 2
41#define BFD_MAX_DETECT_MULT 255
42
567b877d 43#define BFD_GBL_FLAG_IN_SHUTDOWN (1 << 0) /* The daemon in shutdown */
d62a17ae 44struct bfd_gbl {
d7c0a89a 45 uint16_t flags;
567b877d 46};
47
7f342629
DS
48#define BFD_FLAG_PARAM_CFG (1 << 0) /* parameters have been configured */
49#define BFD_FLAG_BFD_REG (1 << 1) /* Peer registered with BFD */
986aa00f 50#define BFD_FLAG_BFD_TYPE_MULTIHOP (1 << 2) /* Peer registered with BFD as multihop */
9beff0bd 51#define BFD_FLAG_BFD_CBIT_ON (1 << 3) /* Peer registered with CBIT set to on */
dcffea69 52#define BFD_FLAG_BFD_CHECK_CONTROLPLANE (1 << 4) /* BFD and controlplane daemon are linked */
7f342629 53
7555dc61
S
54#define BFD_STATUS_UNKNOWN (1 << 0) /* BFD session status never received */
55#define BFD_STATUS_DOWN (1 << 1) /* BFD session status is down */
56#define BFD_STATUS_UP (1 << 2) /* BFD session status is up */
57#define BFD_STATUS_ADMIN_DOWN (1 << 3) /* BFD session is admin down */
58
59#define BFD_SET_CLIENT_STATUS(current_status, new_status) \
60 do { \
61 (current_status) = \
62 (((new_status) == BFD_STATUS_ADMIN_DOWN) ? \
63 BFD_STATUS_DOWN : (new_status));\
64 } while (0)
68fe91d6 65
986aa00f 66enum bfd_sess_type {
d62a17ae 67 BFD_TYPE_NOT_CONFIGURED,
68 BFD_TYPE_SINGLEHOP,
69 BFD_TYPE_MULTIHOP
986aa00f 70};
71
d62a17ae 72struct bfd_info {
d7c0a89a
QY
73 uint16_t flags;
74 uint8_t detect_mult;
75 uint32_t desired_min_tx;
76 uint32_t required_min_rx;
d62a17ae 77 time_t last_update;
d7c0a89a 78 uint8_t status;
d62a17ae 79 enum bfd_sess_type type;
7f342629
DS
80};
81
d62a17ae 82extern struct bfd_info *bfd_info_create(void);
7f342629 83
d62a17ae 84extern void bfd_info_free(struct bfd_info **bfd_info);
7f342629 85
d62a17ae 86extern int bfd_validate_param(struct vty *vty, const char *dm_str,
87 const char *rx_str, const char *tx_str,
d7c0a89a
QY
88 uint8_t *dm_val, uint32_t *rx_val,
89 uint32_t *tx_val);
7f342629 90
d7c0a89a
QY
91extern void bfd_set_param(struct bfd_info **bfd_info, uint32_t min_rx,
92 uint32_t min_tx, uint8_t detect_mult, int defaults,
d62a17ae 93 int *command);
94extern void bfd_peer_sendmsg(struct zclient *zclient, struct bfd_info *bfd_info,
95 int family, void *dst_ip, void *src_ip,
9beff0bd
PG
96 char *if_name, int ttl, int multihop, int cbit,
97 int command, int set_flag, vrf_id_t vrf_id);
7f342629 98
d62a17ae 99extern const char *bfd_get_command_dbg_str(int command);
7f342629 100
d62a17ae 101extern struct interface *bfd_get_peer_info(struct stream *s, struct prefix *dp,
102 struct prefix *sp, int *status,
9beff0bd 103 int *remote_cbit,
d62a17ae 104 vrf_id_t vrf_id);
68fe91d6 105
d62a17ae 106const char *bfd_get_status_str(int status);
68fe91d6 107
d62a17ae 108extern void bfd_show_param(struct vty *vty, struct bfd_info *bfd_info,
9f049418 109 int bfd_tag, int extra_space, bool use_json,
d62a17ae 110 json_object *json_obj);
68fe91d6 111
d62a17ae 112extern void bfd_show_info(struct vty *vty, struct bfd_info *bfd_info,
9f049418 113 int multihop, int extra_space, bool use_json,
d62a17ae 114 json_object *json_obj);
7f342629 115
0945d5ed
PG
116extern void bfd_client_sendmsg(struct zclient *zclient, int command,
117 vrf_id_t vrf_id);
055c4dfc 118
d62a17ae 119extern void bfd_gbl_init(void);
567b877d 120
d62a17ae 121extern void bfd_gbl_exit(void);
567b877d 122
5e244469
RW
123#ifdef __cplusplus
124}
125#endif
126
7f342629 127#endif /* _ZEBRA_BFD_H */