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