]> git.ipfire.org Git - thirdparty/bird.git/blame - proto/bfd/config.Y
BFD: show bfd sessions all
[thirdparty/bird.git] / proto / bfd / config.Y
CommitLineData
bf139664
OZ
1/*
2 * BIRD -- Router Advertisement Configuration
3 *
4 *
5 * Can be freely distributed and used under the terms of the GNU GPL.
6 */
7
8CF_HDR
9
10#include "proto/bfd/bfd.h"
11
12CF_DEFINES
13
14#define BFD_CFG ((struct bfd_config *) this_proto)
1ec52253 15#define BFD_IFACE ((struct bfd_iface_config *) this_ipatt)
bf139664
OZ
16#define BFD_NEIGHBOR this_bfd_neighbor
17
bf139664
OZ
18static struct bfd_neighbor *this_bfd_neighbor;
19
1ec52253 20extern struct bfd_config *bfd_cf;
bf139664
OZ
21
22CF_DECLS
23
1ec52253 24CF_KEYWORDS(BFD, MIN, IDLE, RX, TX, INTERVAL, MULTIPLIER, PASSIVE,
e03dc6a9 25 INTERFACE, MULTIHOP, NEIGHBOR, DEV, LOCAL, AUTHENTICATION,
692055e3
OZ
26 NONE, SIMPLE, METICULOUS, KEYED, MD5, SHA1, IPV4, IPV6, DIRECT,
27 STRICT, BIND)
bf139664
OZ
28
29%type <iface> bfd_neigh_iface
30%type <a> bfd_neigh_local
e03dc6a9 31%type <i> bfd_neigh_multihop bfd_auth_type
bf139664
OZ
32
33CF_GRAMMAR
34
f851f0d7 35proto: bfd_proto ;
bf139664
OZ
36
37bfd_proto_start: proto_start BFD
38{
2bbc3083 39 this_proto = proto_config_new(&proto_bfd, $1);
1ec52253 40 init_list(&BFD_CFG->patt_list);
6a8d3f1c 41 init_list(&BFD_CFG->neigh_list);
7f9adafc
OZ
42 BFD_CFG->accept_ipv4 = BFD_CFG->accept_ipv6 = 1;
43 BFD_CFG->accept_direct = BFD_CFG->accept_multihop = 1;
bf139664
OZ
44};
45
46bfd_proto_item:
47 proto_item
7f9adafc 48 | ACCEPT bfd_accept
1ec52253
OZ
49 | INTERFACE bfd_iface
50 | MULTIHOP bfd_multihop
51 | NEIGHBOR bfd_neighbor
692055e3 52 | STRICT BIND bool { BFD_CFG->strict_bind = $3; }
bf139664
OZ
53 ;
54
55bfd_proto_opts:
56 /* empty */
57 | bfd_proto_opts bfd_proto_item ';'
58 ;
59
60bfd_proto:
61 bfd_proto_start proto_name '{' bfd_proto_opts '}';
62
63
7f9adafc
OZ
64bfd_accept_item:
65 IPV4 { BFD_CFG->accept_ipv4 = 1; BFD_CFG->accept_ipv6 = 0; }
66 | IPV6 { BFD_CFG->accept_ipv4 = 0; BFD_CFG->accept_ipv6 = 1; }
67 | DIRECT { BFD_CFG->accept_direct = 1; BFD_CFG->accept_multihop = 0; }
68 | MULTIHOP { BFD_CFG->accept_direct = 0; BFD_CFG->accept_multihop = 1; }
69 ;
70
71bfd_accept:
72 {
73 BFD_CFG->accept_ipv4 = BFD_CFG->accept_ipv6 = 1;
74 BFD_CFG->accept_direct = BFD_CFG->accept_multihop = 1;
75 }
76 | bfd_accept bfd_accept_item
77
78
1ec52253 79bfd_iface_start:
bf139664 80{
1ec52253 81 this_ipatt = cfg_allocz(sizeof(struct bfd_iface_config));
e03dc6a9 82 add_tail(&BFD_CFG->patt_list, NODE this_ipatt);
1ec52253 83 init_list(&this_ipatt->ipn_list);
bf139664 84
1ec52253
OZ
85 BFD_IFACE->min_rx_int = BFD_DEFAULT_MIN_RX_INT;
86 BFD_IFACE->min_tx_int = BFD_DEFAULT_MIN_TX_INT;
87 BFD_IFACE->idle_tx_int = BFD_DEFAULT_IDLE_TX_INT;
88 BFD_IFACE->multiplier = BFD_DEFAULT_MULTIPLIER;
e03dc6a9
OZ
89
90 reset_passwords();
91};
92
93bfd_iface_finish:
94{
95 BFD_IFACE->passwords = get_passwords();
96
97 if (!BFD_IFACE->auth_type != !BFD_IFACE->passwords)
6f798683 98 cf_warn("Authentication and password options should be used together");
e03dc6a9
OZ
99
100 if (BFD_IFACE->passwords)
101 {
102 struct password_item *pass;
103 WALK_LIST(pass, *BFD_IFACE->passwords)
104 {
105 if (pass->alg)
106 cf_error("Password algorithm option not available in BFD protocol");
107
108 pass->alg = bfd_auth_type_to_hash_alg[BFD_IFACE->auth_type];
109 }
110 }
bf139664
OZ
111};
112
1ec52253
OZ
113bfd_iface_item:
114 INTERVAL expr_us { BFD_IFACE->min_rx_int = BFD_IFACE->min_tx_int = $2; }
115 | MIN RX INTERVAL expr_us { BFD_IFACE->min_rx_int = $4; }
116 | MIN TX INTERVAL expr_us { BFD_IFACE->min_tx_int = $4; }
117 | IDLE TX INTERVAL expr_us { BFD_IFACE->idle_tx_int = $4; }
118 | MULTIPLIER expr { BFD_IFACE->multiplier = $2; }
119 | PASSIVE bool { BFD_IFACE->passive = $2; }
e03dc6a9
OZ
120 | AUTHENTICATION bfd_auth_type { BFD_IFACE->auth_type = $2; }
121 | password_list {}
122 ;
123
124bfd_auth_type:
125 NONE { $$ = BFD_AUTH_NONE; }
126 | SIMPLE { $$ = BFD_AUTH_SIMPLE; }
127 | KEYED MD5 { $$ = BFD_AUTH_KEYED_MD5; }
128 | KEYED SHA1 { $$ = BFD_AUTH_KEYED_SHA1; }
129 | METICULOUS KEYED MD5 { $$ = BFD_AUTH_METICULOUS_KEYED_MD5; }
130 | METICULOUS KEYED SHA1 { $$ = BFD_AUTH_METICULOUS_KEYED_SHA1; }
bf139664
OZ
131 ;
132
1ec52253 133bfd_iface_opts:
bf139664 134 /* empty */
1ec52253 135 | bfd_iface_opts bfd_iface_item ';'
bf139664
OZ
136 ;
137
1ec52253 138bfd_iface_opt_list:
bf139664 139 /* empty */
1ec52253 140 | '{' bfd_iface_opts '}'
bf139664
OZ
141 ;
142
e03dc6a9
OZ
143bfd_iface:
144 bfd_iface_start iface_patt_list_nopx bfd_iface_opt_list bfd_iface_finish;
1ec52253 145
e03dc6a9
OZ
146bfd_multihop:
147 bfd_iface_start bfd_iface_opt_list bfd_iface_finish
1ec52253 148{ BFD_CFG->multihop = BFD_IFACE; };
bf139664
OZ
149
150
151bfd_neigh_iface:
152 /* empty */ { $$ = NULL; }
c0e958e0 153 | '%' symbol { $$ = if_get_by_name($2->name); }
9eceab33 154 | DEV text { $$ = if_get_by_name($2); }
bf139664
OZ
155 ;
156
157bfd_neigh_local:
158 /* empty */ { $$ = IPA_NONE; }
159 | LOCAL ipa { $$ = $2; }
160 ;
161
1ec52253
OZ
162bfd_neigh_multihop:
163 /* empty */ { $$ = 0; }
164 | MULTIHOP bool { $$ = $2; }
165 ;
166
167bfd_neighbor: ipa bfd_neigh_iface bfd_neigh_local bfd_neigh_multihop
bf139664
OZ
168{
169 this_bfd_neighbor = cfg_allocz(sizeof(struct bfd_neighbor));
6a8d3f1c 170 add_tail(&BFD_CFG->neigh_list, NODE this_bfd_neighbor);
bf139664 171
1ec52253
OZ
172 BFD_NEIGHBOR->addr = $1;
173 BFD_NEIGHBOR->local = $3;
174 BFD_NEIGHBOR->iface = $2;
175 BFD_NEIGHBOR->multihop = $4;
176
177 if ($4 && $2)
178 cf_error("Neighbor cannot set both interface and multihop");
179
180 if ($4 && ipa_zero($3))
181 cf_error("Multihop neighbor requires specified local address");
bf139664
OZ
182};
183
184
2750b248 185CF_CLI_HELP(SHOW BFD, ..., [[Show information about BFD protocol]]);
c0e958e0 186CF_CLI(SHOW BFD SESSIONS, optproto, [<name>], [[Show information about BFD sessions]])
37bf2078
KK
187{ PROTO_WALK_CMD($4, &proto_bfd, p) bfd_show_sessions(p, 0); };
188
189CF_CLI(SHOW BFD SESSIONS ALL, optproto, [<name>], [[Show information about BFD sessions]])
190{ PROTO_WALK_CMD($5, &proto_bfd, p) bfd_show_sessions(p, 1); };
6a8d3f1c 191
bf139664
OZ
192CF_CODE
193
194CF_END