]> git.ipfire.org Git - thirdparty/bird.git/blame - proto/ospf/config.Y
Merge branch 'master' into mq-filter-stack
[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))
024c310b
OZ
41 log(L_WARN "Hello or poll interval less that 5 makes cryptographic authenication prone to replay attacks");
42
43 if ((ip->autype == OSPF_AUTH_NONE) && (ip->passwords != NULL))
44 log(L_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
OZ
87 /* Define default channel */
88 if (EMPTY_LIST(this_proto->channels))
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)
122 log(L_WARN "Instance ID %d from unassigned/private range", ic->instance_id);
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
da3cf9ea
OZ
193CF_KEYWORDS(OSPF, V2, V3, OSPF_METRIC1, OSPF_METRIC2, OSPF_TAG, OSPF_ROUTER_ID)
194CF_KEYWORDS(AREA, NEIGHBORS, RFC1583COMPAT, STUB, TICK, COST, COST2, RETRANSMIT)
4df2019e 195CF_KEYWORDS(HELLO, TRANSMIT, PRIORITY, DEAD, TYPE, BROADCAST, BCAST, DEFAULT)
919f5411 196CF_KEYWORDS(NONBROADCAST, NBMA, POINTOPOINT, PTP, POINTOMULTIPOINT, PTMP)
70e212f9 197CF_KEYWORDS(NONE, SIMPLE, AUTHENTICATION, STRICT, CRYPTOGRAPHIC, TTL, SECURITY)
77e43c8b 198CF_KEYWORDS(ELIGIBLE, POLL, NETWORKS, HIDDEN, VIRTUAL, CHECK, LINK, ONLY, BFD)
ed317862 199CF_KEYWORDS(RX, BUFFER, LARGE, NORMAL, STUBNET, HIDDEN, SUMMARY, TAG, EXTERNAL)
4160a9dd 200CF_KEYWORDS(WAIT, DELAY, LSADB, ECMP, LIMIT, WEIGHT, NSSA, TRANSLATOR, STABILITY)
48e5f32d 201CF_KEYWORDS(GLOBAL, LSID, ROUTER, SELF, INSTANCE, REAL, NETMASK, TX, PRIORITY, LENGTH)
4a3f5b36 202CF_KEYWORDS(MERGE, LSA, SUPPRESSION, MULTICAST, RFC5838, VPN, PE)
1a2ad348 203CF_KEYWORDS(GRACEFUL, RESTART, AWARE, TIME)
c1f8dc91 204
20ab192b 205%type <ld> lsadb_args
d3f4f92b
OZ
206%type <i> ospf_variant ospf_af_mc nbma_eligible
207%type <cc> ospf_channel_start ospf_channel
c4f0f014 208
c1f8dc91
OF
209CF_GRAMMAR
210
f851f0d7 211proto: ospf_proto '}' { ospf_proto_finish(); } ;
c1f8dc91 212
23c212e7 213ospf_variant:
da3cf9ea
OZ
214 OSPF { $$ = 1; }
215 | OSPF V2 { $$ = 1; }
216 | OSPF V3 { $$ = 0; }
23c212e7
OZ
217 ;
218
f4a60a9b
OZ
219ospf_proto_start: proto_start ospf_variant
220{
221 this_proto = proto_config_new(&proto_ospf, $1);
d3f4f92b 222 this_proto->net_type = $2 ? NET_IP4 : 0;
f4a60a9b
OZ
223
224 init_list(&OSPF_CFG->area_list);
225 init_list(&OSPF_CFG->vlink_list);
517d05df 226 OSPF_CFG->ecmp = rt_default_ecmp;
f4a60a9b
OZ
227 OSPF_CFG->tick = OSPF_DEFAULT_TICK;
228 OSPF_CFG->ospf2 = $2;
d3f4f92b 229 OSPF_CFG->af_ext = !$2;
1a2ad348
OZ
230 OSPF_CFG->gr_mode = OSPF_GR_AWARE;
231 OSPF_CFG->gr_time = OSPF_DEFAULT_GR_TIME;
f4a60a9b 232};
c1f8dc91
OF
233
234ospf_proto:
235 ospf_proto_start proto_name '{'
f8032bbd
MM
236 | ospf_proto ospf_proto_item ';'
237 ;
238
d3f4f92b
OZ
239ospf_af_mc:
240 { $$ = 0; }
241 | MULTICAST { $$ = 1; }
242 ;
243
244/* We redefine proto_channel to add multicast flag */
245ospf_channel_start: net_type ospf_af_mc
246{
72163bd5
OZ
247 /* TODO: change name for multicast channels */
248 $$ = this_channel = channel_config_get(NULL, net_label[$1], $1, this_proto);
d3f4f92b
OZ
249
250 /* Save the multicast flag */
251 if (this_channel == proto_cf_main_channel(this_proto))
252 OSPF_CFG->af_mc = $2;
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"); }
8e48831a 399 | TRANSMIT DELAY expr { OSPF_PATT->inftransdelay = $3 ; if (($3<=0) || ($3>65535)) cf_error("Transmit delay must be in range 1-65535"); }
6aaaa635 400 | PRIORITY expr { OSPF_PATT->priority = $2 ; if ($2>255) cf_error("Priority must be in range 0-255"); }
a190e720 401 | STRICT NONBROADCAST bool { OSPF_PATT->strictnbma = $3 ; }
e3bc10fd 402 | STUB bool { OSPF_PATT->stub = $2 ; }
391931d4 403 | CHECK LINK bool { OSPF_PATT->check_link = $3; }
57c574d8 404 | 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 405 | LINK LSA SUPPRESSION bool { OSPF_PATT->link_lsa_suppression = $4; if (!ospf_cfg_is_v3()) cf_error("Link LSA suppression option requires OSPFv3"); }
9ff52573 406 | NEIGHBORS '{' nbma_list '}'
70945cb6
OZ
407 | AUTHENTICATION NONE { OSPF_PATT->autype = OSPF_AUTH_NONE; }
408 | AUTHENTICATION SIMPLE { OSPF_PATT->autype = OSPF_AUTH_SIMPLE; ospf_check_auth(); }
4727d1db 409 | AUTHENTICATION CRYPTOGRAPHIC { OSPF_PATT->autype = OSPF_AUTH_CRYPT; }
178a197a
OZ
410 | RX BUFFER NORMAL { OSPF_PATT->rx_buffer = 0; }
411 | RX BUFFER LARGE { OSPF_PATT->rx_buffer = OSPF_MAX_PKT_SIZE; }
48e5f32d 412 | 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
413 | TX tos { OSPF_PATT->tx_tos = $2; }
414 | TX PRIORITY expr { OSPF_PATT->tx_priority = $3; }
48e5f32d 415 | 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
416 | TTL SECURITY bool { OSPF_PATT->ttl_security = $3; }
417 | TTL SECURITY TX ONLY { OSPF_PATT->ttl_security = 2; }
1ec52253 418 | BFD bool { OSPF_PATT->bfd = $2; cf_check_bfd($2); }
4727d1db 419 | password_list
f8032bbd 420 ;
e5b5d18c 421
c926eee7
OF
422pref_list:
423 /* empty */
424 | pref_list pref_item
425 ;
426
ed317862 427pref_item: pref_base pref_opt ';' ;
c926eee7 428
d44e686e 429pref_base: net_ip
c926eee7 430 {
98ac6176 431 this_pref = cfg_allocz(sizeof(struct area_net_config));
ed317862 432 add_tail(this_nets, NODE this_pref);
04632fd7 433 this_pref->prefix = $1;
c926eee7
OF
434 }
435;
436
ed317862
OZ
437pref_opt:
438 /* empty */
439 | HIDDEN { this_pref->hidden = 1; }
440 | TAG expr { this_pref->tag = $2; }
441 ;
c926eee7 442
9ff52573 443nbma_list:
e5b5d18c 444 /* empty */
9ff52573 445 | nbma_list nbma_item
e5b5d18c 446 ;
a190e720 447
9ff52573
OZ
448nbma_eligible:
449 /* empty */ { $$ = 0; }
450 | ELIGIBLE { $$ = 1; }
451 ;
178a197a 452
70945cb6 453nbma_item: ipa nbma_eligible ';'
a190e720
OF
454 {
455 this_nbma = cfg_allocz(sizeof(struct nbma_node));
456 add_tail(&OSPF_PATT->nbma_list, NODE this_nbma);
457 this_nbma->ip=$1;
9ff52573 458 this_nbma->eligible=$2;
a190e720
OF
459 }
460;
178a197a 461
aaaff776
OF
462ospf_iface_start:
463 {
464 this_ipatt = cfg_allocz(sizeof(struct ospf_iface_patt));
465 add_tail(&this_area->patt_list, NODE this_ipatt);
20e94fb8 466 init_list(&this_ipatt->ipn_list);
aaaff776
OF
467 OSPF_PATT->cost = COST_D;
468 OSPF_PATT->helloint = HELLOINT_D;
a190e720 469 OSPF_PATT->pollint = POLLINT_D;
aaaff776
OF
470 OSPF_PATT->rxmtint = RXMTINT_D;
471 OSPF_PATT->inftransdelay = INFTRANSDELAY_D;
472 OSPF_PATT->priority = PRIORITY_D;
aaaff776
OF
473 OSPF_PATT->deadc = DEADC_D;
474 OSPF_PATT->type = OSPF_IT_UNDEF;
e5b5d18c 475 init_list(&OSPF_PATT->nbma_list);
517d05df 476 OSPF_PATT->check_link = 1;
8df02847 477 OSPF_PATT->ptp_netmask = 2; /* not specified */
ef4a50be
OZ
478 OSPF_PATT->tx_tos = IP_PREC_INTERNET_CONTROL;
479 OSPF_PATT->tx_priority = sk_priority_control;
024c310b 480 reset_passwords();
aaaff776
OF
481 }
482;
483
0ec031f7
OZ
484ospf_instance_id:
485 /* empty */
d3f4f92b 486 | 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
487 ;
488
d7c06285 489ospf_iface_patt_list:
70945cb6 490 iface_patt_list { if (ospf_cfg_is_v3()) iface_patt_check(); } ospf_instance_id
178a197a 491 ;
d7c06285 492
89d6782d 493ospf_iface_opts:
f8032bbd 494 /* empty */
89d6782d
OF
495 | ospf_iface_opts ospf_iface_item ';'
496 ;
497
f8032bbd
MM
498ospf_iface_opt_list:
499 /* empty */
500 | '{' ospf_iface_opts '}'
501 ;
89d6782d 502
89d6782d 503ospf_iface:
d7c06285 504 ospf_iface_start ospf_iface_patt_list ospf_iface_opt_list { ospf_iface_finish(); }
89d6782d
OF
505 ;
506
78976974
MM
507dynamic_attr: OSPF_METRIC1 { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_OSPF_METRIC1); } ;
508dynamic_attr: OSPF_METRIC2 { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_OSPF_METRIC2); } ;
509dynamic_attr: OSPF_TAG { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_OSPF_TAG); } ;
510dynamic_attr: OSPF_ROUTER_ID { $$ = f_new_dynamic_attr(EAF_TYPE_ROUTER_ID, T_QUAD, EA_OSPF_ROUTER_ID); } ;
5919c66e 511
c47d037e 512CF_CLI_HELP(SHOW OSPF, ..., [[Show information about OSPF protocol]]);
c0e958e0 513CF_CLI(SHOW OSPF, optproto, [<name>], [[Show information about OSPF protocol]])
a3b70dc4 514{ ospf_sh(proto_get_named($3, &proto_ospf)); };
4ab4e977 515
c0e958e0 516CF_CLI(SHOW OSPF NEIGHBORS, optproto opttext, [<name>] [\"<interface>\"], [[Show information about OSPF neighbors]])
a3b70dc4 517{ ospf_sh_neigh(proto_get_named($4, &proto_ospf), $5); };
c4f0f014 518
c0e958e0 519CF_CLI(SHOW OSPF INTERFACE, optproto opttext, [<name>] [\"<interface>\"], [[Show information about interface]])
c4f0f014 520{ ospf_sh_iface(proto_get_named($4, &proto_ospf), $5); };
a783e259 521
0ea8fb4a 522CF_CLI_HELP(SHOW OSPF TOPOLOGY, [all] [<name>], [[Show information about OSPF network topology]])
a3b70dc4 523
c0e958e0 524CF_CLI(SHOW OSPF TOPOLOGY, optproto opttext, [<name>], [[Show information about reachable OSPF network topology]])
0ea8fb4a
OZ
525{ ospf_sh_state(proto_get_named($4, &proto_ospf), 0, 1); };
526
c0e958e0 527CF_CLI(SHOW OSPF TOPOLOGY ALL, optproto opttext, [<name>], [[Show information about all OSPF network topology]])
0ea8fb4a
OZ
528{ ospf_sh_state(proto_get_named($5, &proto_ospf), 0, 0); };
529
530CF_CLI_HELP(SHOW OSPF STATE, [all] [<name>], [[Show information about OSPF network state]])
531
c0e958e0 532CF_CLI(SHOW OSPF STATE, optproto opttext, [<name>], [[Show information about reachable OSPF network state]])
0ea8fb4a
OZ
533{ ospf_sh_state(proto_get_named($4, &proto_ospf), 1, 1); };
534
c0e958e0 535CF_CLI(SHOW OSPF STATE ALL, optproto opttext, [<name>], [[Show information about all OSPF network state]])
0ea8fb4a 536{ ospf_sh_state(proto_get_named($5, &proto_ospf), 1, 0); };
a3b70dc4 537
c47d037e 538CF_CLI_HELP(SHOW OSPF LSADB, ..., [[Show content of OSPF LSA database]]);
20ab192b
OZ
539CF_CLI(SHOW OSPF LSADB, lsadb_args, [global | area <id> | link] [type <num>] [lsid <id>] [self | router <id>] [<proto>], [[Show content of OSPF LSA database]])
540{ ospf_sh_lsadb($4); };
541
542lsadb_args:
543 /* empty */ {
544 $$ = cfg_allocz(sizeof(struct lsadb_show_data));
545 }
546 | lsadb_args GLOBAL { $$ = $1; $$->scope = LSA_SCOPE_AS; }
155134f3 547 | lsadb_args AREA idval { $$ = $1; $$->scope = LSA_SCOPE_AREA; $$->area = $3; }
20ab192b
OZ
548 | lsadb_args LINK { $$ = $1; $$->scope = 1; /* hack, 0 is no filter */ }
549 | lsadb_args TYPE NUM { $$ = $1; $$->type = $3; }
550 | lsadb_args LSID idval { $$ = $1; $$->lsid = $3; }
551 | lsadb_args SELF { $$ = $1; $$->router = SH_ROUTER_SELF; }
552 | lsadb_args ROUTER idval { $$ = $1; $$->router = $3; }
9eef9c64 553 | lsadb_args CF_SYM_KNOWN { cf_assert_symbol($2, SYM_PROTO); $$ = $1; $$->proto = (struct ospf_proto *) proto_get_named($2, &proto_ospf); }
20ab192b 554 ;
98899244 555
c1f8dc91
OF
556CF_CODE
557
558CF_END