]> git.ipfire.org Git - thirdparty/bird.git/blame - proto/bfd/config.Y
BFD: Add arguments to 'show bfd sessions' command
[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
26dd61ee 32%type <bssc> bfd_show_sessions_args
bf139664
OZ
33
34CF_GRAMMAR
35
f851f0d7 36proto: bfd_proto ;
bf139664
OZ
37
38bfd_proto_start: proto_start BFD
39{
2bbc3083 40 this_proto = proto_config_new(&proto_bfd, $1);
1ec52253 41 init_list(&BFD_CFG->patt_list);
6a8d3f1c 42 init_list(&BFD_CFG->neigh_list);
7f9adafc
OZ
43 BFD_CFG->accept_ipv4 = BFD_CFG->accept_ipv6 = 1;
44 BFD_CFG->accept_direct = BFD_CFG->accept_multihop = 1;
bf139664
OZ
45};
46
47bfd_proto_item:
48 proto_item
7f9adafc 49 | ACCEPT bfd_accept
1ec52253
OZ
50 | INTERFACE bfd_iface
51 | MULTIHOP bfd_multihop
52 | NEIGHBOR bfd_neighbor
692055e3 53 | STRICT BIND bool { BFD_CFG->strict_bind = $3; }
bf139664
OZ
54 ;
55
56bfd_proto_opts:
57 /* empty */
58 | bfd_proto_opts bfd_proto_item ';'
59 ;
60
61bfd_proto:
62 bfd_proto_start proto_name '{' bfd_proto_opts '}';
63
64
7f9adafc
OZ
65bfd_accept_item:
66 IPV4 { BFD_CFG->accept_ipv4 = 1; BFD_CFG->accept_ipv6 = 0; }
67 | IPV6 { BFD_CFG->accept_ipv4 = 0; BFD_CFG->accept_ipv6 = 1; }
68 | DIRECT { BFD_CFG->accept_direct = 1; BFD_CFG->accept_multihop = 0; }
69 | MULTIHOP { BFD_CFG->accept_direct = 0; BFD_CFG->accept_multihop = 1; }
70 ;
71
72bfd_accept:
73 {
74 BFD_CFG->accept_ipv4 = BFD_CFG->accept_ipv6 = 1;
75 BFD_CFG->accept_direct = BFD_CFG->accept_multihop = 1;
76 }
77 | bfd_accept bfd_accept_item
78
79
1ec52253 80bfd_iface_start:
bf139664 81{
1ec52253 82 this_ipatt = cfg_allocz(sizeof(struct bfd_iface_config));
e03dc6a9 83 add_tail(&BFD_CFG->patt_list, NODE this_ipatt);
1ec52253 84 init_list(&this_ipatt->ipn_list);
bf139664 85
1ec52253
OZ
86 BFD_IFACE->min_rx_int = BFD_DEFAULT_MIN_RX_INT;
87 BFD_IFACE->min_tx_int = BFD_DEFAULT_MIN_TX_INT;
88 BFD_IFACE->idle_tx_int = BFD_DEFAULT_IDLE_TX_INT;
89 BFD_IFACE->multiplier = BFD_DEFAULT_MULTIPLIER;
e03dc6a9
OZ
90
91 reset_passwords();
92};
93
94bfd_iface_finish:
95{
96 BFD_IFACE->passwords = get_passwords();
97
98 if (!BFD_IFACE->auth_type != !BFD_IFACE->passwords)
6f798683 99 cf_warn("Authentication and password options should be used together");
e03dc6a9
OZ
100
101 if (BFD_IFACE->passwords)
102 {
103 struct password_item *pass;
104 WALK_LIST(pass, *BFD_IFACE->passwords)
105 {
106 if (pass->alg)
107 cf_error("Password algorithm option not available in BFD protocol");
108
109 pass->alg = bfd_auth_type_to_hash_alg[BFD_IFACE->auth_type];
110 }
111 }
bf139664
OZ
112};
113
1ec52253
OZ
114bfd_iface_item:
115 INTERVAL expr_us { BFD_IFACE->min_rx_int = BFD_IFACE->min_tx_int = $2; }
116 | MIN RX INTERVAL expr_us { BFD_IFACE->min_rx_int = $4; }
117 | MIN TX INTERVAL expr_us { BFD_IFACE->min_tx_int = $4; }
118 | IDLE TX INTERVAL expr_us { BFD_IFACE->idle_tx_int = $4; }
119 | MULTIPLIER expr { BFD_IFACE->multiplier = $2; }
120 | PASSIVE bool { BFD_IFACE->passive = $2; }
e03dc6a9
OZ
121 | AUTHENTICATION bfd_auth_type { BFD_IFACE->auth_type = $2; }
122 | password_list {}
123 ;
124
125bfd_auth_type:
126 NONE { $$ = BFD_AUTH_NONE; }
127 | SIMPLE { $$ = BFD_AUTH_SIMPLE; }
128 | KEYED MD5 { $$ = BFD_AUTH_KEYED_MD5; }
129 | KEYED SHA1 { $$ = BFD_AUTH_KEYED_SHA1; }
130 | METICULOUS KEYED MD5 { $$ = BFD_AUTH_METICULOUS_KEYED_MD5; }
131 | METICULOUS KEYED SHA1 { $$ = BFD_AUTH_METICULOUS_KEYED_SHA1; }
bf139664
OZ
132 ;
133
1ec52253 134bfd_iface_opts:
bf139664 135 /* empty */
1ec52253 136 | bfd_iface_opts bfd_iface_item ';'
bf139664
OZ
137 ;
138
1ec52253 139bfd_iface_opt_list:
bf139664 140 /* empty */
1ec52253 141 | '{' bfd_iface_opts '}'
bf139664
OZ
142 ;
143
e03dc6a9
OZ
144bfd_iface:
145 bfd_iface_start iface_patt_list_nopx bfd_iface_opt_list bfd_iface_finish;
1ec52253 146
e03dc6a9
OZ
147bfd_multihop:
148 bfd_iface_start bfd_iface_opt_list bfd_iface_finish
1ec52253 149{ BFD_CFG->multihop = BFD_IFACE; };
bf139664
OZ
150
151
152bfd_neigh_iface:
153 /* empty */ { $$ = NULL; }
c0e958e0 154 | '%' symbol { $$ = if_get_by_name($2->name); }
9eceab33 155 | DEV text { $$ = if_get_by_name($2); }
bf139664
OZ
156 ;
157
158bfd_neigh_local:
159 /* empty */ { $$ = IPA_NONE; }
160 | LOCAL ipa { $$ = $2; }
161 ;
162
1ec52253
OZ
163bfd_neigh_multihop:
164 /* empty */ { $$ = 0; }
165 | MULTIHOP bool { $$ = $2; }
166 ;
167
168bfd_neighbor: ipa bfd_neigh_iface bfd_neigh_local bfd_neigh_multihop
bf139664
OZ
169{
170 this_bfd_neighbor = cfg_allocz(sizeof(struct bfd_neighbor));
6a8d3f1c 171 add_tail(&BFD_CFG->neigh_list, NODE this_bfd_neighbor);
bf139664 172
1ec52253
OZ
173 BFD_NEIGHBOR->addr = $1;
174 BFD_NEIGHBOR->local = $3;
175 BFD_NEIGHBOR->iface = $2;
176 BFD_NEIGHBOR->multihop = $4;
177
178 if ($4 && $2)
179 cf_error("Neighbor cannot set both interface and multihop");
180
181 if ($4 && ipa_zero($3))
182 cf_error("Multihop neighbor requires specified local address");
bf139664
OZ
183};
184
185
2750b248 186CF_CLI_HELP(SHOW BFD, ..., [[Show information about BFD protocol]]);
37bf2078 187
26dd61ee
OZ
188CF_CLI_HELP(SHOW BFD SESSIONS, ..., [[Show information about BFD sessions]]);
189CF_CLI(SHOW BFD SESSIONS, bfd_show_sessions_args, [<name>] [address <ip|prefix>] [(interface|dev) \"<name>\"] [ipv4|ipv6] [direct|multihop] [all], [[Show information about BFD sessions]])
190{ PROTO_WALK_CMD($4->name, &proto_bfd, p) bfd_show_sessions(p, $4); };
191
192bfd_show_sessions_args:
193 /* empty */ { $$ = cfg_allocz(sizeof(struct bfd_show_sessions_cmd)); }
194 | bfd_show_sessions_args CF_SYM_KNOWN { cf_assert_symbol($2, SYM_PROTO); $$->name = $2; }
195 | bfd_show_sessions_args ADDRESS net_or_ipa { net_copy(&($$->address), &($3)); }
196 | bfd_show_sessions_args INTERFACE text { $$->iface = if_get_by_name($3); }
197 | bfd_show_sessions_args DEV text { $$->iface = if_get_by_name($3); }
198 | bfd_show_sessions_args ALL { $$->verbose = 1; }
199 | bfd_show_sessions_args IPV4 { $$->ipv4 = 1; if ($$->ipv6) cf_error("Options 'ipv4' and 'ipv6' are mutually exclusive"); }
200 | bfd_show_sessions_args IPV6 { $$->ipv6 = 1; if ($$->ipv4) cf_error("Options 'ipv4' and 'ipv6' are mutually exclusive"); }
201 | bfd_show_sessions_args DIRECT { $$->direct = 1; if ($$->multihop) cf_error("Options 'direct' and 'multihop' are mutually exclusive"); }
202 | bfd_show_sessions_args MULTIHOP { $$->multihop = 1; if ($$->direct) cf_error("Options 'direct' and 'multihop' are mutually exclusive"); }
203 ;
204
6a8d3f1c 205
bf139664
OZ
206CF_CODE
207
208CF_END