]> git.ipfire.org Git - thirdparty/bird.git/blame - proto/ospf/config.Y
Client: Add support for completion of command options
[thirdparty/bird.git] / proto / ospf / config.Y
CommitLineData
c1f8dc91
OF
1/*
2 * BIRD -- OSPF Configuration
3 *
32d3228d 4 * (c) 1999--2004 Ondrej Filip <feela@network.cz>
c1f8dc91
OF
5 *
6 * Can be freely distributed and used under the terms of the GNU GPL.
7 */
8
9CF_HDR
10
11#include "proto/ospf/ospf.h"
12
3fa5722d
OF
13CF_DEFINES
14
15#define OSPF_CFG ((struct ospf_config *) this_proto)
89d6782d 16#define OSPF_PATT ((struct ospf_iface_patt *) this_ipatt)
20e94fb8
OZ
17
18static struct ospf_area_config *this_area;
e5b5d18c 19static struct nbma_node *this_nbma;
ed317862 20static list *this_nets;
98ac6176 21static struct area_net_config *this_pref;
178a197a 22static struct ospf_stubnet_config *this_stubnet;
3fa5722d 23
70945cb6
OZ
24static inline int ospf_cfg_is_v2(void) { return OSPF_CFG->ospf2; }
25static inline int ospf_cfg_is_v3(void) { return ! OSPF_CFG->ospf2; }
26
024c310b 27static void
8e48831a 28ospf_iface_finish(void)
024c310b 29{
8e48831a
OZ
30 struct ospf_iface_patt *ip = OSPF_PATT;
31
32 if (ip->deadint == 0)
33 ip->deadint = ip->deadc * ip->helloint;
34
178a197a
OZ
35 if (ip->waitint == 0)
36 ip->waitint = ip->deadc * ip->helloint;
37
024c310b
OZ
38 ip->passwords = get_passwords();
39
4727d1db 40 if (ospf_cfg_is_v2() && (ip->autype == OSPF_AUTH_CRYPT) && (ip->helloint < 5))
6f798683 41 cf_warn("Hello or poll interval less that 5 makes cryptographic authenication prone to replay attacks");
024c310b
OZ
42
43 if ((ip->autype == OSPF_AUTH_NONE) && (ip->passwords != NULL))
6f798683 44 cf_warn("Password option without authentication option does not make sense");
29239ba2
OZ
45
46 if (ip->passwords)
47 {
48 struct password_item *pass;
49 WALK_LIST(pass, *ip->passwords)
50 {
51 if (pass->alg && (ip->autype != OSPF_AUTH_CRYPT))
52 cf_error("Password algorithm option requires cryptographic authentication");
53
54 /* Set default OSPF crypto algorithms */
55 if (!pass->alg && (ip->autype == OSPF_AUTH_CRYPT))
56 pass->alg = ospf_cfg_is_v2() ? ALG_MD5 : ALG_HMAC_SHA256;
4727d1db
OZ
57
58 if (ospf_cfg_is_v3() && ip->autype && (pass->alg < ALG_HMAC))
59 cf_error("Keyed hash algorithms are not allowed, use HMAC algorithms");
29239ba2
OZ
60 }
61 }
024c310b
OZ
62}
63
8e48831a
OZ
64static void
65ospf_area_finish(void)
66{
41b612c3 67 if ((this_area->areaid == 0) && (this_area->type != OPT_E))
2918e610
OZ
68 cf_error("Backbone area cannot be stub/NSSA");
69
70 if (this_area->summary && (this_area->type == OPT_E))
70945cb6 71 cf_error("Only stub/NSSA areas can use summary propagation");
2918e610
OZ
72
73 if (this_area->default_nssa && ((this_area->type != OPT_N) || ! this_area->summary))
74 cf_error("Only NSSA areas with summary propagation can use NSSA default route");
75
70945cb6 76 if ((this_area->default_cost & LSA_EXT3_EBIT) && ! this_area->default_nssa)
2918e610 77 cf_error("Only NSSA default route can use type 2 metric");
8e48831a
OZ
78}
79
80static void
81ospf_proto_finish(void)
82{
83 struct ospf_config *cf = OSPF_CFG;
d3f4f92b
OZ
84 struct ospf_area_config *ac;
85 struct ospf_iface_patt *ic;
8e48831a 86
f4a60a9b 87 /* Define default channel */
f761be6b 88 if (! proto_cf_main_channel(this_proto))
d3f4f92b 89 {
72163bd5
OZ
90 uint net_type = this_proto->net_type = ospf_cfg_is_v2() ? NET_IP4 : NET_IP6;
91 channel_config_new(NULL, net_label[net_type], net_type, this_proto);
d3f4f92b
OZ
92 }
93
94 /* Propagate global instance ID to interfaces */
95 if (cf->instance_id_set)
96 {
97 WALK_LIST(ac, cf->area_list)
98 WALK_LIST(ic, ac->patt_list)
99 if (!ic->instance_id_set)
100 { ic->instance_id = cf->instance_id; ic->instance_id_set = 1; }
101
102 WALK_LIST(ic, cf->vlink_list)
103 if (!ic->instance_id_set)
104 { ic->instance_id = cf->instance_id; ic->instance_id_set = 1; }
105 }
106
107 if (ospf_cfg_is_v3())
108 {
109 uint ipv4 = (this_proto->net_type == NET_IP4);
110 uint base = (ipv4 ? 64 : 0) + (cf->af_mc ? 32 : 0);
111
112 /* RFC 5838 - OSPFv3-AF */
113 if (cf->af_ext)
114 {
115 /* RFC 5838 2.1 - instance IDs based on AFs */
116 WALK_LIST(ac, cf->area_list)
117 WALK_LIST(ic, ac->patt_list)
118 {
119 if (!ic->instance_id_set)
120 ic->instance_id = base;
121 else if (ic->instance_id >= 128)
6f798683 122 cf_warn("Instance ID %d from unassigned/private range", ic->instance_id);
d3f4f92b
OZ
123 else if ((ic->instance_id < base) || (ic->instance_id >= (base + 32)))
124 cf_error("Instance ID %d invalid for given channel type", ic->instance_id);
125 }
126
127 /* RFC 5838 2.8 - vlinks limited to IPv6 unicast */
128 if ((ipv4 || cf->af_mc) && !EMPTY_LIST(cf->vlink_list))
129 cf_error("Vlinks not supported in AFs other than IPv6 unicast");
130 }
131 else
132 {
133 if (ipv4 || cf->af_mc)
134 cf_error("Different channel type");
135 }
136 }
137
138 if (EMPTY_LIST(cf->area_list))
139 cf_error("No configured areas in OSPF");
f4a60a9b 140
8e48831a
OZ
141 int areano = 0;
142 int backbone = 0;
70945cb6 143 int nssa = 0;
8e48831a
OZ
144 WALK_LIST(ac, cf->area_list)
145 {
146 areano++;
147 if (ac->areaid == 0)
70945cb6
OZ
148 backbone = 1;
149 if (ac->type == OPT_N)
150 nssa = 1;
8e48831a 151 }
70945cb6 152
8e48831a
OZ
153 cf->abr = areano > 1;
154
70945cb6 155 /* Route export or NSSA translation (RFC 3101 3.1) */
f4a60a9b 156 cf->asbr = (proto_cf_main_channel(this_proto)->out_filter != FILTER_REJECT) || (nssa && cf->abr);
70945cb6 157
8e48831a
OZ
158 if (cf->abr && !backbone)
159 {
160 struct ospf_area_config *ac = cfg_allocz(sizeof(struct ospf_area_config));
e4404cef 161 ac->type = OPT_E; /* Backbone is non-stub */
8e48831a
OZ
162 add_head(&cf->area_list, NODE ac);
163 init_list(&ac->patt_list);
164 init_list(&ac->net_list);
ed317862 165 init_list(&ac->enet_list);
8e48831a
OZ
166 init_list(&ac->stubnet_list);
167 }
168
169 if (!cf->abr && !EMPTY_LIST(cf->vlink_list))
70945cb6
OZ
170 cf_error("Vlinks cannot be used on single area router");
171
172 if (cf->asbr && (areano == 1) && (this_area->type == 0))
173 cf_error("ASBR must be in non-stub area");
8e48831a
OZ
174}
175
2918e610 176static inline void
70945cb6 177ospf_check_defcost(int cost)
2918e610
OZ
178{
179 if ((cost <= 0) || (cost >= LSINFINITY))
6aaaa635 180 cf_error("Default cost must be in range 1-%u", LSINFINITY-1);
0ec031f7
OZ
181}
182
183static inline void
70945cb6 184ospf_check_auth(void)
0ec031f7 185{
70945cb6 186 if (ospf_cfg_is_v3())
4727d1db 187 cf_error("Plaintext authentication not supported in OSPFv3");
2918e610
OZ
188}
189
70945cb6 190
c1f8dc91
OF
191CF_DECLS
192
f5140d10
OZ
193CF_KEYWORDS_EXCLUSIVE(V2, V3)
194CF_KEYWORDS(OSPF, OSPF_METRIC1, OSPF_METRIC2, OSPF_TAG, OSPF_ROUTER_ID)
da3cf9ea 195CF_KEYWORDS(AREA, NEIGHBORS, RFC1583COMPAT, STUB, TICK, COST, COST2, RETRANSMIT)
4df2019e 196CF_KEYWORDS(HELLO, TRANSMIT, PRIORITY, DEAD, TYPE, BROADCAST, BCAST, DEFAULT)
919f5411 197CF_KEYWORDS(NONBROADCAST, NBMA, POINTOPOINT, PTP, POINTOMULTIPOINT, PTMP)
70e212f9 198CF_KEYWORDS(NONE, SIMPLE, AUTHENTICATION, STRICT, CRYPTOGRAPHIC, TTL, SECURITY)
77e43c8b 199CF_KEYWORDS(ELIGIBLE, POLL, NETWORKS, HIDDEN, VIRTUAL, CHECK, LINK, ONLY, BFD)
ed317862 200CF_KEYWORDS(RX, BUFFER, LARGE, NORMAL, STUBNET, HIDDEN, SUMMARY, TAG, EXTERNAL)
4160a9dd 201CF_KEYWORDS(WAIT, DELAY, LSADB, ECMP, LIMIT, WEIGHT, NSSA, TRANSLATOR, STABILITY)
48e5f32d 202CF_KEYWORDS(GLOBAL, LSID, ROUTER, SELF, INSTANCE, REAL, NETMASK, TX, PRIORITY, LENGTH)
c1632ad0 203CF_KEYWORDS(MERGE, LSA, SUPPRESSION, MULTICAST, RFC5838, VPN, PE, ADDRESS)
1a2ad348 204CF_KEYWORDS(GRACEFUL, RESTART, AWARE, TIME)
c1f8dc91 205
20ab192b 206%type <ld> lsadb_args
d3f4f92b
OZ
207%type <i> ospf_variant ospf_af_mc nbma_eligible
208%type <cc> ospf_channel_start ospf_channel
c4f0f014 209
c1f8dc91
OF
210CF_GRAMMAR
211
f851f0d7 212proto: ospf_proto '}' { ospf_proto_finish(); } ;
c1f8dc91 213
23c212e7 214ospf_variant:
da3cf9ea
OZ
215 OSPF { $$ = 1; }
216 | OSPF V2 { $$ = 1; }
217 | OSPF V3 { $$ = 0; }
23c212e7
OZ
218 ;
219
f4a60a9b
OZ
220ospf_proto_start: proto_start ospf_variant
221{
222 this_proto = proto_config_new(&proto_ospf, $1);
d3f4f92b 223 this_proto->net_type = $2 ? NET_IP4 : 0;
f4a60a9b
OZ
224
225 init_list(&OSPF_CFG->area_list);
226 init_list(&OSPF_CFG->vlink_list);
517d05df 227 OSPF_CFG->ecmp = rt_default_ecmp;
f4a60a9b
OZ
228 OSPF_CFG->tick = OSPF_DEFAULT_TICK;
229 OSPF_CFG->ospf2 = $2;
d3f4f92b 230 OSPF_CFG->af_ext = !$2;
1a2ad348
OZ
231 OSPF_CFG->gr_mode = OSPF_GR_AWARE;
232 OSPF_CFG->gr_time = OSPF_DEFAULT_GR_TIME;
f4a60a9b 233};
c1f8dc91
OF
234
235ospf_proto:
236 ospf_proto_start proto_name '{'
f8032bbd
MM
237 | ospf_proto ospf_proto_item ';'
238 ;
239
d3f4f92b
OZ
240ospf_af_mc:
241 { $$ = 0; }
242 | MULTICAST { $$ = 1; }
243 ;
244
245/* We redefine proto_channel to add multicast flag */
246ospf_channel_start: net_type ospf_af_mc
247{
72163bd5
OZ
248 /* TODO: change name for multicast channels */
249 $$ = this_channel = channel_config_get(NULL, net_label[$1], $1, this_proto);
d3f4f92b
OZ
250
251 /* Save the multicast flag */
f761be6b 252 OSPF_CFG->af_mc = $2;
d3f4f92b
OZ
253};
254
255ospf_channel: ospf_channel_start channel_opt_list channel_end;
256
f8032bbd
MM
257ospf_proto_item:
258 proto_item
d3f4f92b 259 | ospf_channel { this_proto->net_type = $1->net_type; }
002ecc06 260 | RFC1583COMPAT bool { OSPF_CFG->rfc1583 = $2; }
2d7fb19c 261 | RFC5838 bool { OSPF_CFG->af_ext = $2; if (!ospf_cfg_is_v3()) cf_error("RFC5838 option requires OSPFv3"); }
4a3f5b36 262 | VPN PE bool { OSPF_CFG->vpn_pe = $3; }
f623ab98 263 | STUB ROUTER bool { OSPF_CFG->stub_router = $3; }
1a2ad348
OZ
264 | GRACEFUL RESTART bool { OSPF_CFG->gr_mode = $3; }
265 | GRACEFUL RESTART AWARE { OSPF_CFG->gr_mode = OSPF_GR_AWARE; }
266 | GRACEFUL RESTART TIME expr { OSPF_CFG->gr_time = $4; if (($4 < 1) || ($4 > 1800)) cf_error("Graceful restart time must be in range 1-1800"); }
70945cb6 267 | ECMP bool { OSPF_CFG->ecmp = $2 ? OSPF_DEFAULT_ECMP_LIMIT : 0; }
6aaaa635 268 | ECMP bool LIMIT expr { OSPF_CFG->ecmp = $2 ? $4 : 0; }
145368f5 269 | MERGE EXTERNAL bool { OSPF_CFG->merge_external = $3; }
6aaaa635 270 | TICK expr { OSPF_CFG->tick = $2; if($2 <= 0) cf_error("Tick must be greater than zero"); }
d3f4f92b 271 | INSTANCE ID expr { OSPF_CFG->instance_id = $3; OSPF_CFG->instance_id_set = 1; if ($3 > 255) cf_error("Instance ID must be in range 0-255"); }
8e48831a 272 | ospf_area
f8032bbd 273 ;
c1f8dc91 274
8e48831a 275ospf_area_start: AREA idval {
b36a0a79
OF
276 this_area = cfg_allocz(sizeof(struct ospf_area_config));
277 add_tail(&OSPF_CFG->area_list, NODE this_area);
278 this_area->areaid = $2;
70945cb6 279 this_area->default_cost = OSPF_DEFAULT_STUB_COST;
41b612c3 280 this_area->type = OPT_E;
70945cb6 281 this_area->transint = OSPF_DEFAULT_TRANSINT;
41b612c3 282
89d6782d 283 init_list(&this_area->patt_list);
c926eee7 284 init_list(&this_area->net_list);
ed317862 285 init_list(&this_area->enet_list);
38675202 286 init_list(&this_area->stubnet_list);
c1f8dc91 287 }
f8032bbd 288 ;
c4f0f014 289
8e48831a 290ospf_area: ospf_area_start '{' ospf_area_opts '}' { ospf_area_finish(); }
f8032bbd 291 ;
a789d814
OF
292
293ospf_area_opts:
f8032bbd
MM
294 /* empty */
295 | ospf_area_opts ospf_area_item ';'
296 ;
a789d814 297
b36a0a79 298ospf_area_item:
2918e610 299 STUB bool { this_area->type = $2 ? 0 : OPT_E; /* We should remove the option */ }
41b612c3
OZ
300 | NSSA { this_area->type = OPT_N; }
301 | SUMMARY bool { this_area->summary = $2; }
2918e610 302 | DEFAULT NSSA bool { this_area->default_nssa = $3; }
70945cb6
OZ
303 | DEFAULT COST expr { this_area->default_cost = $3; ospf_check_defcost($3); }
304 | DEFAULT COST2 expr { this_area->default_cost = $3 | LSA_EXT3_EBIT; ospf_check_defcost($3); }
305 | STUB COST expr { this_area->default_cost = $3; ospf_check_defcost($3); }
4160a9dd 306 | TRANSLATOR bool { this_area->translator = $2; }
ed317862
OZ
307 | TRANSLATOR STABILITY expr { this_area->transint = $3; }
308 | NETWORKS { this_nets = &this_area->net_list; } '{' pref_list '}'
309 | EXTERNAL { this_nets = &this_area->enet_list; } '{' pref_list '}'
38675202 310 | STUBNET ospf_stubnet
20e94fb8 311 | INTERFACE ospf_iface
3b16080c 312 | ospf_vlink
f8032bbd 313 ;
89d6782d 314
38675202
OZ
315ospf_stubnet:
316 ospf_stubnet_start '{' ospf_stubnet_opts '}'
317 | ospf_stubnet_start
318 ;
319
320ospf_stubnet_start:
d44e686e 321 net_ip {
1b3b3e34 322 this_stubnet = cfg_allocz(sizeof(struct ospf_stubnet_config));
38675202 323 add_tail(&this_area->stubnet_list, NODE this_stubnet);
04632fd7 324 this_stubnet->prefix = $1;
38675202 325 this_stubnet->cost = COST_D;
178a197a 326 }
38675202
OZ
327 ;
328
329ospf_stubnet_opts:
330 /* empty */
331 | ospf_stubnet_opts ospf_stubnet_item ';'
332 ;
333
334ospf_stubnet_item:
335 HIDDEN bool { this_stubnet->hidden = $2; }
336 | SUMMARY bool { this_stubnet->summary = $2; }
337 | COST expr { this_stubnet->cost = $2; }
338 ;
339
3b16080c 340ospf_vlink:
0ec031f7
OZ
341 ospf_vlink_start ospf_instance_id '{' ospf_vlink_opts '}' { ospf_iface_finish(); }
342 | ospf_vlink_start ospf_instance_id { ospf_iface_finish(); }
98ac6176
OF
343 ;
344
345ospf_vlink_opts:
346 /* empty */
347 | ospf_vlink_opts ospf_vlink_item ';'
348 ;
349
350ospf_vlink_item:
3b16080c 351 | HELLO expr { OSPF_PATT->helloint = $2 ; if (($2<=0) || ($2>65535)) cf_error("Hello interval must be in range 1-65535"); }
178a197a 352 | RETRANSMIT expr { OSPF_PATT->rxmtint = $2 ; if ($2<=1) cf_error("Retransmit int must be greater than one"); }
98ac6176 353 | TRANSMIT DELAY expr { OSPF_PATT->inftransdelay = $3 ; if (($3<=0) || ($3>65535)) cf_error("Transmit delay must be in range 1-65535"); }
178a197a 354 | WAIT expr { OSPF_PATT->waitint = $2 ; if ($2<=1) cf_error("Wait interval must be greater than one"); }
8e48831a 355 | DEAD expr { OSPF_PATT->deadint = $2 ; if ($2<=1) cf_error("Dead interval must be greater than one"); }
98ac6176 356 | DEAD COUNT expr { OSPF_PATT->deadc = $3 ; if ($3<=1) cf_error("Dead count must be greater than one"); }
70945cb6
OZ
357 | AUTHENTICATION NONE { OSPF_PATT->autype = OSPF_AUTH_NONE; }
358 | AUTHENTICATION SIMPLE { OSPF_PATT->autype = OSPF_AUTH_SIMPLE; ospf_check_auth(); }
4727d1db
OZ
359 | AUTHENTICATION CRYPTOGRAPHIC { OSPF_PATT->autype = OSPF_AUTH_CRYPT; }
360 | password_list
98ac6176
OF
361 ;
362
3b16080c 363ospf_vlink_start: VIRTUAL LINK idval
98ac6176
OF
364 {
365 if (this_area->areaid == 0) cf_error("Virtual link cannot be in backbone");
366 this_ipatt = cfg_allocz(sizeof(struct ospf_iface_patt));
8e48831a 367 add_tail(&OSPF_CFG->vlink_list, NODE this_ipatt);
20e94fb8 368 init_list(&this_ipatt->ipn_list);
8e48831a 369 OSPF_PATT->voa = this_area->areaid;
3b16080c 370 OSPF_PATT->vid = $3;
98ac6176 371 OSPF_PATT->helloint = HELLOINT_D;
98ac6176
OF
372 OSPF_PATT->rxmtint = RXMTINT_D;
373 OSPF_PATT->inftransdelay = INFTRANSDELAY_D;
98ac6176
OF
374 OSPF_PATT->deadc = DEADC_D;
375 OSPF_PATT->type = OSPF_IT_VLINK;
3b16080c 376 init_list(&OSPF_PATT->nbma_list);
024c310b 377 reset_passwords();
98ac6176
OF
378 }
379;
380
89d6782d 381ospf_iface_item:
7df86c25
OF
382 COST expr { OSPF_PATT->cost = $2 ; if (($2<=0) || ($2>65535)) cf_error("Cost must be in range 1-65535"); }
383 | HELLO expr { OSPF_PATT->helloint = $2 ; if (($2<=0) || ($2>65535)) cf_error("Hello interval must be in range 1-65535"); }
384 | POLL expr { OSPF_PATT->pollint = $2 ; if ($2<=0) cf_error("Poll int must be greater than zero"); }
178a197a
OZ
385 | RETRANSMIT expr { OSPF_PATT->rxmtint = $2 ; if ($2<=1) cf_error("Retransmit int must be greater than one"); }
386 | WAIT expr { OSPF_PATT->waitint = $2 ; if ($2<=1) cf_error("Wait interval must be greater than one"); }
8e48831a 387 | DEAD expr { OSPF_PATT->deadint = $2 ; if ($2<=1) cf_error("Dead interval must be greater than one"); }
7df86c25 388 | DEAD COUNT expr { OSPF_PATT->deadc = $3 ; if ($3<=1) cf_error("Dead count must be greater than one"); }
aaaff776 389 | TYPE BROADCAST { OSPF_PATT->type = OSPF_IT_BCAST ; }
919f5411 390 | TYPE BCAST { OSPF_PATT->type = OSPF_IT_BCAST ; }
aaaff776 391 | TYPE NONBROADCAST { OSPF_PATT->type = OSPF_IT_NBMA ; }
919f5411 392 | TYPE NBMA { OSPF_PATT->type = OSPF_IT_NBMA ; }
aaaff776 393 | TYPE POINTOPOINT { OSPF_PATT->type = OSPF_IT_PTP ; }
919f5411
OZ
394 | TYPE PTP { OSPF_PATT->type = OSPF_IT_PTP ; }
395 | TYPE POINTOMULTIPOINT { OSPF_PATT->type = OSPF_IT_PTMP ; }
396 | TYPE PTMP { OSPF_PATT->type = OSPF_IT_PTMP ; }
70945cb6
OZ
397 | REAL BROADCAST bool { OSPF_PATT->real_bcast = $3; if (!ospf_cfg_is_v2()) cf_error("Real broadcast option requires OSPFv2"); }
398 | PTP NETMASK bool { OSPF_PATT->ptp_netmask = $3; if (!ospf_cfg_is_v2()) cf_error("PtP netmask option requires OSPFv2"); }
c1632ad0 399 | PTP ADDRESS bool { OSPF_PATT->ptp_address = $3; if (!ospf_cfg_is_v2()) cf_error("PtP address option requires OSPFv2"); }
8e48831a 400 | TRANSMIT DELAY expr { OSPF_PATT->inftransdelay = $3 ; if (($3<=0) || ($3>65535)) cf_error("Transmit delay must be in range 1-65535"); }
6aaaa635 401 | PRIORITY expr { OSPF_PATT->priority = $2 ; if ($2>255) cf_error("Priority must be in range 0-255"); }
a190e720 402 | STRICT NONBROADCAST bool { OSPF_PATT->strictnbma = $3 ; }
e3bc10fd 403 | STUB bool { OSPF_PATT->stub = $2 ; }
391931d4 404 | CHECK LINK bool { OSPF_PATT->check_link = $3; }
57c574d8 405 | ECMP WEIGHT expr { OSPF_PATT->ecmp_weight = $3 - 1; if (($3<1) || ($3>256)) cf_error("ECMP weight must be in range 1-256"); }
70945cb6 406 | LINK LSA SUPPRESSION bool { OSPF_PATT->link_lsa_suppression = $4; if (!ospf_cfg_is_v3()) cf_error("Link LSA suppression option requires OSPFv3"); }
9ff52573 407 | NEIGHBORS '{' nbma_list '}'
70945cb6
OZ
408 | AUTHENTICATION NONE { OSPF_PATT->autype = OSPF_AUTH_NONE; }
409 | AUTHENTICATION SIMPLE { OSPF_PATT->autype = OSPF_AUTH_SIMPLE; ospf_check_auth(); }
4727d1db 410 | AUTHENTICATION CRYPTOGRAPHIC { OSPF_PATT->autype = OSPF_AUTH_CRYPT; }
178a197a
OZ
411 | RX BUFFER NORMAL { OSPF_PATT->rx_buffer = 0; }
412 | RX BUFFER LARGE { OSPF_PATT->rx_buffer = OSPF_MAX_PKT_SIZE; }
48e5f32d 413 | RX BUFFER expr { OSPF_PATT->rx_buffer = $3; if (($3 < OSPF_MIN_PKT_SIZE) || ($3 > OSPF_MAX_PKT_SIZE)) cf_error("Buffer size must be in range 256-65535"); }
ef4a50be
OZ
414 | TX tos { OSPF_PATT->tx_tos = $2; }
415 | TX PRIORITY expr { OSPF_PATT->tx_priority = $3; }
48e5f32d 416 | TX LENGTH expr { OSPF_PATT->tx_length = $3; if (($3 < OSPF_MIN_PKT_SIZE) || ($3 > OSPF_MAX_PKT_SIZE)) cf_error("TX length must be in range 256-65535"); }
70e212f9
OZ
417 | TTL SECURITY bool { OSPF_PATT->ttl_security = $3; }
418 | TTL SECURITY TX ONLY { OSPF_PATT->ttl_security = 2; }
1ec52253 419 | BFD bool { OSPF_PATT->bfd = $2; cf_check_bfd($2); }
4727d1db 420 | password_list
f8032bbd 421 ;
e5b5d18c 422
c926eee7
OF
423pref_list:
424 /* empty */
425 | pref_list pref_item
426 ;
427
ed317862 428pref_item: pref_base pref_opt ';' ;
c926eee7 429
d44e686e 430pref_base: net_ip
c926eee7 431 {
98ac6176 432 this_pref = cfg_allocz(sizeof(struct area_net_config));
ed317862 433 add_tail(this_nets, NODE this_pref);
04632fd7 434 this_pref->prefix = $1;
c926eee7
OF
435 }
436;
437
ed317862
OZ
438pref_opt:
439 /* empty */
440 | HIDDEN { this_pref->hidden = 1; }
441 | TAG expr { this_pref->tag = $2; }
442 ;
c926eee7 443
9ff52573 444nbma_list:
e5b5d18c 445 /* empty */
9ff52573 446 | nbma_list nbma_item
e5b5d18c 447 ;
a190e720 448
9ff52573
OZ
449nbma_eligible:
450 /* empty */ { $$ = 0; }
451 | ELIGIBLE { $$ = 1; }
452 ;
178a197a 453
70945cb6 454nbma_item: ipa nbma_eligible ';'
a190e720
OF
455 {
456 this_nbma = cfg_allocz(sizeof(struct nbma_node));
457 add_tail(&OSPF_PATT->nbma_list, NODE this_nbma);
458 this_nbma->ip=$1;
9ff52573 459 this_nbma->eligible=$2;
a190e720
OF
460 }
461;
178a197a 462
aaaff776
OF
463ospf_iface_start:
464 {
465 this_ipatt = cfg_allocz(sizeof(struct ospf_iface_patt));
466 add_tail(&this_area->patt_list, NODE this_ipatt);
20e94fb8 467 init_list(&this_ipatt->ipn_list);
aaaff776
OF
468 OSPF_PATT->cost = COST_D;
469 OSPF_PATT->helloint = HELLOINT_D;
a190e720 470 OSPF_PATT->pollint = POLLINT_D;
aaaff776
OF
471 OSPF_PATT->rxmtint = RXMTINT_D;
472 OSPF_PATT->inftransdelay = INFTRANSDELAY_D;
473 OSPF_PATT->priority = PRIORITY_D;
aaaff776
OF
474 OSPF_PATT->deadc = DEADC_D;
475 OSPF_PATT->type = OSPF_IT_UNDEF;
e5b5d18c 476 init_list(&OSPF_PATT->nbma_list);
517d05df 477 OSPF_PATT->check_link = 1;
8df02847 478 OSPF_PATT->ptp_netmask = 2; /* not specified */
c1632ad0 479 OSPF_PATT->ptp_address = 2; /* not specified */
ef4a50be
OZ
480 OSPF_PATT->tx_tos = IP_PREC_INTERNET_CONTROL;
481 OSPF_PATT->tx_priority = sk_priority_control;
024c310b 482 reset_passwords();
aaaff776
OF
483 }
484;
485
0ec031f7
OZ
486ospf_instance_id:
487 /* empty */
d3f4f92b 488 | INSTANCE expr { OSPF_PATT->instance_id = $2; OSPF_PATT->instance_id_set = 1; if ($2 > 255) cf_error("Instance ID must be in range 0-255"); }
0ec031f7
OZ
489 ;
490
d7c06285 491ospf_iface_patt_list:
70945cb6 492 iface_patt_list { if (ospf_cfg_is_v3()) iface_patt_check(); } ospf_instance_id
178a197a 493 ;
d7c06285 494
89d6782d 495ospf_iface_opts:
f8032bbd 496 /* empty */
89d6782d
OF
497 | ospf_iface_opts ospf_iface_item ';'
498 ;
499
f8032bbd
MM
500ospf_iface_opt_list:
501 /* empty */
502 | '{' ospf_iface_opts '}'
503 ;
89d6782d 504
89d6782d 505ospf_iface:
d7c06285 506 ospf_iface_start ospf_iface_patt_list ospf_iface_opt_list { ospf_iface_finish(); }
89d6782d
OF
507 ;
508
78976974
MM
509dynamic_attr: OSPF_METRIC1 { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_OSPF_METRIC1); } ;
510dynamic_attr: OSPF_METRIC2 { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_OSPF_METRIC2); } ;
511dynamic_attr: OSPF_TAG { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_OSPF_TAG); } ;
512dynamic_attr: OSPF_ROUTER_ID { $$ = f_new_dynamic_attr(EAF_TYPE_ROUTER_ID, T_QUAD, EA_OSPF_ROUTER_ID); } ;
5919c66e 513
c47d037e 514CF_CLI_HELP(SHOW OSPF, ..., [[Show information about OSPF protocol]]);
c0e958e0 515CF_CLI(SHOW OSPF, optproto, [<name>], [[Show information about OSPF protocol]])
c26c6bc2 516{ PROTO_WALK_CMD($3, &proto_ospf, p) ospf_sh(p); };
4ab4e977 517
c0e958e0 518CF_CLI(SHOW OSPF NEIGHBORS, optproto opttext, [<name>] [\"<interface>\"], [[Show information about OSPF neighbors]])
c26c6bc2 519{ PROTO_WALK_CMD($4, &proto_ospf, p) ospf_sh_neigh(p, $5); };
c4f0f014 520
c0e958e0 521CF_CLI(SHOW OSPF INTERFACE, optproto opttext, [<name>] [\"<interface>\"], [[Show information about interface]])
c26c6bc2 522{ PROTO_WALK_CMD($4, &proto_ospf, p) ospf_sh_iface(p, $5); };
a783e259 523
0ea8fb4a 524CF_CLI_HELP(SHOW OSPF TOPOLOGY, [all] [<name>], [[Show information about OSPF network topology]])
a3b70dc4 525
c0e958e0 526CF_CLI(SHOW OSPF TOPOLOGY, optproto opttext, [<name>], [[Show information about reachable OSPF network topology]])
0ea8fb4a
OZ
527{ ospf_sh_state(proto_get_named($4, &proto_ospf), 0, 1); };
528
c0e958e0 529CF_CLI(SHOW OSPF TOPOLOGY ALL, optproto opttext, [<name>], [[Show information about all OSPF network topology]])
0ea8fb4a
OZ
530{ ospf_sh_state(proto_get_named($5, &proto_ospf), 0, 0); };
531
532CF_CLI_HELP(SHOW OSPF STATE, [all] [<name>], [[Show information about OSPF network state]])
533
c0e958e0 534CF_CLI(SHOW OSPF STATE, optproto opttext, [<name>], [[Show information about reachable OSPF network state]])
0ea8fb4a
OZ
535{ ospf_sh_state(proto_get_named($4, &proto_ospf), 1, 1); };
536
c0e958e0 537CF_CLI(SHOW OSPF STATE ALL, optproto opttext, [<name>], [[Show information about all OSPF network state]])
0ea8fb4a 538{ ospf_sh_state(proto_get_named($5, &proto_ospf), 1, 0); };
a3b70dc4 539
c47d037e 540CF_CLI_HELP(SHOW OSPF LSADB, ..., [[Show content of OSPF LSA database]]);
20ab192b 541CF_CLI(SHOW OSPF LSADB, lsadb_args, [global | area <id> | link] [type <num>] [lsid <id>] [self | router <id>] [<proto>], [[Show content of OSPF LSA database]])
56d8b1e7
OZ
542{
543 if (!$4->proto)
544 $4->proto = (struct ospf_proto *) proto_get_named(NULL, &proto_ospf);
545
546 ospf_sh_lsadb($4);
547};
20ab192b 548
1b064355
OZ
549CF_CLI_OPT(SHOW OSPF LSADB GLOBAL)
550CF_CLI_OPT(SHOW OSPF LSADB AREA, <id>)
551CF_CLI_OPT(SHOW OSPF LSADB LINK)
552CF_CLI_OPT(SHOW OSPF LSADB TYPE, <num>)
553CF_CLI_OPT(SHOW OSPF LSADB LSID, <id>)
554CF_CLI_OPT(SHOW OSPF LSADB SELF)
555CF_CLI_OPT(SHOW OSPF LSADB ROUTER, <id>)
556
20ab192b
OZ
557lsadb_args:
558 /* empty */ {
559 $$ = cfg_allocz(sizeof(struct lsadb_show_data));
560 }
561 | lsadb_args GLOBAL { $$ = $1; $$->scope = LSA_SCOPE_AS; }
155134f3 562 | lsadb_args AREA idval { $$ = $1; $$->scope = LSA_SCOPE_AREA; $$->area = $3; }
20ab192b
OZ
563 | lsadb_args LINK { $$ = $1; $$->scope = 1; /* hack, 0 is no filter */ }
564 | lsadb_args TYPE NUM { $$ = $1; $$->type = $3; }
565 | lsadb_args LSID idval { $$ = $1; $$->lsid = $3; }
566 | lsadb_args SELF { $$ = $1; $$->router = SH_ROUTER_SELF; }
567 | lsadb_args ROUTER idval { $$ = $1; $$->router = $3; }
9eef9c64 568 | lsadb_args CF_SYM_KNOWN { cf_assert_symbol($2, SYM_PROTO); $$ = $1; $$->proto = (struct ospf_proto *) proto_get_named($2, &proto_ospf); }
20ab192b 569 ;
98899244 570
c1f8dc91
OF
571CF_CODE
572
573CF_END