]> git.ipfire.org Git - thirdparty/bird.git/blame - proto/ospf/config.Y
Dynamic attributes definition split whether it is bitmask or not.
[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)
c1f8dc91 203
20ab192b 204%type <ld> lsadb_args
d3f4f92b
OZ
205%type <i> ospf_variant ospf_af_mc nbma_eligible
206%type <cc> ospf_channel_start ospf_channel
c4f0f014 207
c1f8dc91
OF
208CF_GRAMMAR
209
f851f0d7 210proto: ospf_proto '}' { ospf_proto_finish(); } ;
c1f8dc91 211
23c212e7 212ospf_variant:
da3cf9ea
OZ
213 OSPF { $$ = 1; }
214 | OSPF V2 { $$ = 1; }
215 | OSPF V3 { $$ = 0; }
23c212e7
OZ
216 ;
217
f4a60a9b
OZ
218ospf_proto_start: proto_start ospf_variant
219{
220 this_proto = proto_config_new(&proto_ospf, $1);
d3f4f92b 221 this_proto->net_type = $2 ? NET_IP4 : 0;
f4a60a9b
OZ
222
223 init_list(&OSPF_CFG->area_list);
224 init_list(&OSPF_CFG->vlink_list);
517d05df 225 OSPF_CFG->ecmp = rt_default_ecmp;
f4a60a9b
OZ
226 OSPF_CFG->tick = OSPF_DEFAULT_TICK;
227 OSPF_CFG->ospf2 = $2;
d3f4f92b 228 OSPF_CFG->af_ext = !$2;
f4a60a9b 229};
c1f8dc91
OF
230
231ospf_proto:
232 ospf_proto_start proto_name '{'
f8032bbd
MM
233 | ospf_proto ospf_proto_item ';'
234 ;
235
d3f4f92b
OZ
236ospf_af_mc:
237 { $$ = 0; }
238 | MULTICAST { $$ = 1; }
239 ;
240
241/* We redefine proto_channel to add multicast flag */
242ospf_channel_start: net_type ospf_af_mc
243{
72163bd5
OZ
244 /* TODO: change name for multicast channels */
245 $$ = this_channel = channel_config_get(NULL, net_label[$1], $1, this_proto);
d3f4f92b
OZ
246
247 /* Save the multicast flag */
248 if (this_channel == proto_cf_main_channel(this_proto))
249 OSPF_CFG->af_mc = $2;
250};
251
252ospf_channel: ospf_channel_start channel_opt_list channel_end;
253
f8032bbd
MM
254ospf_proto_item:
255 proto_item
d3f4f92b 256 | ospf_channel { this_proto->net_type = $1->net_type; }
002ecc06 257 | RFC1583COMPAT bool { OSPF_CFG->rfc1583 = $2; }
2d7fb19c 258 | RFC5838 bool { OSPF_CFG->af_ext = $2; if (!ospf_cfg_is_v3()) cf_error("RFC5838 option requires OSPFv3"); }
4a3f5b36 259 | VPN PE bool { OSPF_CFG->vpn_pe = $3; }
f623ab98 260 | STUB ROUTER bool { OSPF_CFG->stub_router = $3; }
70945cb6 261 | ECMP bool { OSPF_CFG->ecmp = $2 ? OSPF_DEFAULT_ECMP_LIMIT : 0; }
6aaaa635 262 | ECMP bool LIMIT expr { OSPF_CFG->ecmp = $2 ? $4 : 0; }
145368f5 263 | MERGE EXTERNAL bool { OSPF_CFG->merge_external = $3; }
6aaaa635 264 | TICK expr { OSPF_CFG->tick = $2; if($2 <= 0) cf_error("Tick must be greater than zero"); }
d3f4f92b 265 | 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 266 | ospf_area
f8032bbd 267 ;
c1f8dc91 268
8e48831a 269ospf_area_start: AREA idval {
b36a0a79
OF
270 this_area = cfg_allocz(sizeof(struct ospf_area_config));
271 add_tail(&OSPF_CFG->area_list, NODE this_area);
272 this_area->areaid = $2;
70945cb6 273 this_area->default_cost = OSPF_DEFAULT_STUB_COST;
41b612c3 274 this_area->type = OPT_E;
70945cb6 275 this_area->transint = OSPF_DEFAULT_TRANSINT;
41b612c3 276
89d6782d 277 init_list(&this_area->patt_list);
c926eee7 278 init_list(&this_area->net_list);
ed317862 279 init_list(&this_area->enet_list);
38675202 280 init_list(&this_area->stubnet_list);
c1f8dc91 281 }
f8032bbd 282 ;
c4f0f014 283
8e48831a 284ospf_area: ospf_area_start '{' ospf_area_opts '}' { ospf_area_finish(); }
f8032bbd 285 ;
a789d814
OF
286
287ospf_area_opts:
f8032bbd
MM
288 /* empty */
289 | ospf_area_opts ospf_area_item ';'
290 ;
a789d814 291
b36a0a79 292ospf_area_item:
2918e610 293 STUB bool { this_area->type = $2 ? 0 : OPT_E; /* We should remove the option */ }
41b612c3
OZ
294 | NSSA { this_area->type = OPT_N; }
295 | SUMMARY bool { this_area->summary = $2; }
2918e610 296 | DEFAULT NSSA bool { this_area->default_nssa = $3; }
70945cb6
OZ
297 | DEFAULT COST expr { this_area->default_cost = $3; ospf_check_defcost($3); }
298 | DEFAULT COST2 expr { this_area->default_cost = $3 | LSA_EXT3_EBIT; ospf_check_defcost($3); }
299 | STUB COST expr { this_area->default_cost = $3; ospf_check_defcost($3); }
4160a9dd 300 | TRANSLATOR bool { this_area->translator = $2; }
ed317862
OZ
301 | TRANSLATOR STABILITY expr { this_area->transint = $3; }
302 | NETWORKS { this_nets = &this_area->net_list; } '{' pref_list '}'
303 | EXTERNAL { this_nets = &this_area->enet_list; } '{' pref_list '}'
38675202 304 | STUBNET ospf_stubnet
20e94fb8 305 | INTERFACE ospf_iface
3b16080c 306 | ospf_vlink
f8032bbd 307 ;
89d6782d 308
38675202
OZ
309ospf_stubnet:
310 ospf_stubnet_start '{' ospf_stubnet_opts '}'
311 | ospf_stubnet_start
312 ;
313
314ospf_stubnet_start:
d44e686e 315 net_ip {
1b3b3e34 316 this_stubnet = cfg_allocz(sizeof(struct ospf_stubnet_config));
38675202 317 add_tail(&this_area->stubnet_list, NODE this_stubnet);
04632fd7 318 this_stubnet->prefix = $1;
38675202 319 this_stubnet->cost = COST_D;
178a197a 320 }
38675202
OZ
321 ;
322
323ospf_stubnet_opts:
324 /* empty */
325 | ospf_stubnet_opts ospf_stubnet_item ';'
326 ;
327
328ospf_stubnet_item:
329 HIDDEN bool { this_stubnet->hidden = $2; }
330 | SUMMARY bool { this_stubnet->summary = $2; }
331 | COST expr { this_stubnet->cost = $2; }
332 ;
333
3b16080c 334ospf_vlink:
0ec031f7
OZ
335 ospf_vlink_start ospf_instance_id '{' ospf_vlink_opts '}' { ospf_iface_finish(); }
336 | ospf_vlink_start ospf_instance_id { ospf_iface_finish(); }
98ac6176
OF
337 ;
338
339ospf_vlink_opts:
340 /* empty */
341 | ospf_vlink_opts ospf_vlink_item ';'
342 ;
343
344ospf_vlink_item:
3b16080c 345 | HELLO expr { OSPF_PATT->helloint = $2 ; if (($2<=0) || ($2>65535)) cf_error("Hello interval must be in range 1-65535"); }
178a197a 346 | RETRANSMIT expr { OSPF_PATT->rxmtint = $2 ; if ($2<=1) cf_error("Retransmit int must be greater than one"); }
98ac6176 347 | TRANSMIT DELAY expr { OSPF_PATT->inftransdelay = $3 ; if (($3<=0) || ($3>65535)) cf_error("Transmit delay must be in range 1-65535"); }
178a197a 348 | WAIT expr { OSPF_PATT->waitint = $2 ; if ($2<=1) cf_error("Wait interval must be greater than one"); }
8e48831a 349 | DEAD expr { OSPF_PATT->deadint = $2 ; if ($2<=1) cf_error("Dead interval must be greater than one"); }
98ac6176 350 | DEAD COUNT expr { OSPF_PATT->deadc = $3 ; if ($3<=1) cf_error("Dead count must be greater than one"); }
70945cb6
OZ
351 | AUTHENTICATION NONE { OSPF_PATT->autype = OSPF_AUTH_NONE; }
352 | AUTHENTICATION SIMPLE { OSPF_PATT->autype = OSPF_AUTH_SIMPLE; ospf_check_auth(); }
4727d1db
OZ
353 | AUTHENTICATION CRYPTOGRAPHIC { OSPF_PATT->autype = OSPF_AUTH_CRYPT; }
354 | password_list
98ac6176
OF
355 ;
356
3b16080c 357ospf_vlink_start: VIRTUAL LINK idval
98ac6176
OF
358 {
359 if (this_area->areaid == 0) cf_error("Virtual link cannot be in backbone");
360 this_ipatt = cfg_allocz(sizeof(struct ospf_iface_patt));
8e48831a 361 add_tail(&OSPF_CFG->vlink_list, NODE this_ipatt);
20e94fb8 362 init_list(&this_ipatt->ipn_list);
8e48831a 363 OSPF_PATT->voa = this_area->areaid;
3b16080c 364 OSPF_PATT->vid = $3;
98ac6176 365 OSPF_PATT->helloint = HELLOINT_D;
98ac6176
OF
366 OSPF_PATT->rxmtint = RXMTINT_D;
367 OSPF_PATT->inftransdelay = INFTRANSDELAY_D;
98ac6176
OF
368 OSPF_PATT->deadc = DEADC_D;
369 OSPF_PATT->type = OSPF_IT_VLINK;
3b16080c 370 init_list(&OSPF_PATT->nbma_list);
024c310b 371 reset_passwords();
98ac6176
OF
372 }
373;
374
89d6782d 375ospf_iface_item:
7df86c25
OF
376 COST expr { OSPF_PATT->cost = $2 ; if (($2<=0) || ($2>65535)) cf_error("Cost must be in range 1-65535"); }
377 | HELLO expr { OSPF_PATT->helloint = $2 ; if (($2<=0) || ($2>65535)) cf_error("Hello interval must be in range 1-65535"); }
378 | POLL expr { OSPF_PATT->pollint = $2 ; if ($2<=0) cf_error("Poll int must be greater than zero"); }
178a197a
OZ
379 | RETRANSMIT expr { OSPF_PATT->rxmtint = $2 ; if ($2<=1) cf_error("Retransmit int must be greater than one"); }
380 | WAIT expr { OSPF_PATT->waitint = $2 ; if ($2<=1) cf_error("Wait interval must be greater than one"); }
8e48831a 381 | DEAD expr { OSPF_PATT->deadint = $2 ; if ($2<=1) cf_error("Dead interval must be greater than one"); }
7df86c25 382 | DEAD COUNT expr { OSPF_PATT->deadc = $3 ; if ($3<=1) cf_error("Dead count must be greater than one"); }
aaaff776 383 | TYPE BROADCAST { OSPF_PATT->type = OSPF_IT_BCAST ; }
919f5411 384 | TYPE BCAST { OSPF_PATT->type = OSPF_IT_BCAST ; }
aaaff776 385 | TYPE NONBROADCAST { OSPF_PATT->type = OSPF_IT_NBMA ; }
919f5411 386 | TYPE NBMA { OSPF_PATT->type = OSPF_IT_NBMA ; }
aaaff776 387 | TYPE POINTOPOINT { OSPF_PATT->type = OSPF_IT_PTP ; }
919f5411
OZ
388 | TYPE PTP { OSPF_PATT->type = OSPF_IT_PTP ; }
389 | TYPE POINTOMULTIPOINT { OSPF_PATT->type = OSPF_IT_PTMP ; }
390 | TYPE PTMP { OSPF_PATT->type = OSPF_IT_PTMP ; }
70945cb6
OZ
391 | REAL BROADCAST bool { OSPF_PATT->real_bcast = $3; if (!ospf_cfg_is_v2()) cf_error("Real broadcast option requires OSPFv2"); }
392 | PTP NETMASK bool { OSPF_PATT->ptp_netmask = $3; if (!ospf_cfg_is_v2()) cf_error("PtP netmask option requires OSPFv2"); }
8e48831a 393 | TRANSMIT DELAY expr { OSPF_PATT->inftransdelay = $3 ; if (($3<=0) || ($3>65535)) cf_error("Transmit delay must be in range 1-65535"); }
6aaaa635 394 | PRIORITY expr { OSPF_PATT->priority = $2 ; if ($2>255) cf_error("Priority must be in range 0-255"); }
a190e720 395 | STRICT NONBROADCAST bool { OSPF_PATT->strictnbma = $3 ; }
e3bc10fd 396 | STUB bool { OSPF_PATT->stub = $2 ; }
391931d4 397 | CHECK LINK bool { OSPF_PATT->check_link = $3; }
57c574d8 398 | 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 399 | LINK LSA SUPPRESSION bool { OSPF_PATT->link_lsa_suppression = $4; if (!ospf_cfg_is_v3()) cf_error("Link LSA suppression option requires OSPFv3"); }
9ff52573 400 | NEIGHBORS '{' nbma_list '}'
70945cb6
OZ
401 | AUTHENTICATION NONE { OSPF_PATT->autype = OSPF_AUTH_NONE; }
402 | AUTHENTICATION SIMPLE { OSPF_PATT->autype = OSPF_AUTH_SIMPLE; ospf_check_auth(); }
4727d1db 403 | AUTHENTICATION CRYPTOGRAPHIC { OSPF_PATT->autype = OSPF_AUTH_CRYPT; }
178a197a
OZ
404 | RX BUFFER NORMAL { OSPF_PATT->rx_buffer = 0; }
405 | RX BUFFER LARGE { OSPF_PATT->rx_buffer = OSPF_MAX_PKT_SIZE; }
48e5f32d 406 | 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
407 | TX tos { OSPF_PATT->tx_tos = $2; }
408 | TX PRIORITY expr { OSPF_PATT->tx_priority = $3; }
48e5f32d 409 | 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
410 | TTL SECURITY bool { OSPF_PATT->ttl_security = $3; }
411 | TTL SECURITY TX ONLY { OSPF_PATT->ttl_security = 2; }
1ec52253 412 | BFD bool { OSPF_PATT->bfd = $2; cf_check_bfd($2); }
4727d1db 413 | password_list
f8032bbd 414 ;
e5b5d18c 415
c926eee7
OF
416pref_list:
417 /* empty */
418 | pref_list pref_item
419 ;
420
ed317862 421pref_item: pref_base pref_opt ';' ;
c926eee7 422
d44e686e 423pref_base: net_ip
c926eee7 424 {
98ac6176 425 this_pref = cfg_allocz(sizeof(struct area_net_config));
ed317862 426 add_tail(this_nets, NODE this_pref);
04632fd7 427 this_pref->prefix = $1;
c926eee7
OF
428 }
429;
430
ed317862
OZ
431pref_opt:
432 /* empty */
433 | HIDDEN { this_pref->hidden = 1; }
434 | TAG expr { this_pref->tag = $2; }
435 ;
c926eee7 436
9ff52573 437nbma_list:
e5b5d18c 438 /* empty */
9ff52573 439 | nbma_list nbma_item
e5b5d18c 440 ;
a190e720 441
9ff52573
OZ
442nbma_eligible:
443 /* empty */ { $$ = 0; }
444 | ELIGIBLE { $$ = 1; }
445 ;
178a197a 446
70945cb6 447nbma_item: ipa nbma_eligible ';'
a190e720
OF
448 {
449 this_nbma = cfg_allocz(sizeof(struct nbma_node));
450 add_tail(&OSPF_PATT->nbma_list, NODE this_nbma);
451 this_nbma->ip=$1;
9ff52573 452 this_nbma->eligible=$2;
a190e720
OF
453 }
454;
178a197a 455
aaaff776
OF
456ospf_iface_start:
457 {
458 this_ipatt = cfg_allocz(sizeof(struct ospf_iface_patt));
459 add_tail(&this_area->patt_list, NODE this_ipatt);
20e94fb8 460 init_list(&this_ipatt->ipn_list);
aaaff776
OF
461 OSPF_PATT->cost = COST_D;
462 OSPF_PATT->helloint = HELLOINT_D;
a190e720 463 OSPF_PATT->pollint = POLLINT_D;
aaaff776
OF
464 OSPF_PATT->rxmtint = RXMTINT_D;
465 OSPF_PATT->inftransdelay = INFTRANSDELAY_D;
466 OSPF_PATT->priority = PRIORITY_D;
aaaff776
OF
467 OSPF_PATT->deadc = DEADC_D;
468 OSPF_PATT->type = OSPF_IT_UNDEF;
e5b5d18c 469 init_list(&OSPF_PATT->nbma_list);
517d05df 470 OSPF_PATT->check_link = 1;
8df02847 471 OSPF_PATT->ptp_netmask = 2; /* not specified */
ef4a50be
OZ
472 OSPF_PATT->tx_tos = IP_PREC_INTERNET_CONTROL;
473 OSPF_PATT->tx_priority = sk_priority_control;
024c310b 474 reset_passwords();
aaaff776
OF
475 }
476;
477
0ec031f7
OZ
478ospf_instance_id:
479 /* empty */
d3f4f92b 480 | 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
481 ;
482
d7c06285 483ospf_iface_patt_list:
70945cb6 484 iface_patt_list { if (ospf_cfg_is_v3()) iface_patt_check(); } ospf_instance_id
178a197a 485 ;
d7c06285 486
89d6782d 487ospf_iface_opts:
f8032bbd 488 /* empty */
89d6782d
OF
489 | ospf_iface_opts ospf_iface_item ';'
490 ;
491
f8032bbd
MM
492ospf_iface_opt_list:
493 /* empty */
494 | '{' ospf_iface_opts '}'
495 ;
89d6782d 496
89d6782d 497ospf_iface:
d7c06285 498 ospf_iface_start ospf_iface_patt_list ospf_iface_opt_list { ospf_iface_finish(); }
89d6782d
OF
499 ;
500
78976974
MM
501dynamic_attr: OSPF_METRIC1 { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_OSPF_METRIC1); } ;
502dynamic_attr: OSPF_METRIC2 { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_OSPF_METRIC2); } ;
503dynamic_attr: OSPF_TAG { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_OSPF_TAG); } ;
504dynamic_attr: OSPF_ROUTER_ID { $$ = f_new_dynamic_attr(EAF_TYPE_ROUTER_ID, T_QUAD, EA_OSPF_ROUTER_ID); } ;
5919c66e 505
c47d037e 506CF_CLI_HELP(SHOW OSPF, ..., [[Show information about OSPF protocol]]);
c0e958e0 507CF_CLI(SHOW OSPF, optproto, [<name>], [[Show information about OSPF protocol]])
a3b70dc4 508{ ospf_sh(proto_get_named($3, &proto_ospf)); };
4ab4e977 509
c0e958e0 510CF_CLI(SHOW OSPF NEIGHBORS, optproto opttext, [<name>] [\"<interface>\"], [[Show information about OSPF neighbors]])
a3b70dc4 511{ ospf_sh_neigh(proto_get_named($4, &proto_ospf), $5); };
c4f0f014 512
c0e958e0 513CF_CLI(SHOW OSPF INTERFACE, optproto opttext, [<name>] [\"<interface>\"], [[Show information about interface]])
c4f0f014 514{ ospf_sh_iface(proto_get_named($4, &proto_ospf), $5); };
a783e259 515
0ea8fb4a 516CF_CLI_HELP(SHOW OSPF TOPOLOGY, [all] [<name>], [[Show information about OSPF network topology]])
a3b70dc4 517
c0e958e0 518CF_CLI(SHOW OSPF TOPOLOGY, optproto opttext, [<name>], [[Show information about reachable OSPF network topology]])
0ea8fb4a
OZ
519{ ospf_sh_state(proto_get_named($4, &proto_ospf), 0, 1); };
520
c0e958e0 521CF_CLI(SHOW OSPF TOPOLOGY ALL, optproto opttext, [<name>], [[Show information about all OSPF network topology]])
0ea8fb4a
OZ
522{ ospf_sh_state(proto_get_named($5, &proto_ospf), 0, 0); };
523
524CF_CLI_HELP(SHOW OSPF STATE, [all] [<name>], [[Show information about OSPF network state]])
525
c0e958e0 526CF_CLI(SHOW OSPF STATE, optproto opttext, [<name>], [[Show information about reachable OSPF network state]])
0ea8fb4a
OZ
527{ ospf_sh_state(proto_get_named($4, &proto_ospf), 1, 1); };
528
c0e958e0 529CF_CLI(SHOW OSPF STATE ALL, optproto opttext, [<name>], [[Show information about all OSPF network state]])
0ea8fb4a 530{ ospf_sh_state(proto_get_named($5, &proto_ospf), 1, 0); };
a3b70dc4 531
c47d037e 532CF_CLI_HELP(SHOW OSPF LSADB, ..., [[Show content of OSPF LSA database]]);
20ab192b
OZ
533CF_CLI(SHOW OSPF LSADB, lsadb_args, [global | area <id> | link] [type <num>] [lsid <id>] [self | router <id>] [<proto>], [[Show content of OSPF LSA database]])
534{ ospf_sh_lsadb($4); };
535
536lsadb_args:
537 /* empty */ {
538 $$ = cfg_allocz(sizeof(struct lsadb_show_data));
539 }
540 | lsadb_args GLOBAL { $$ = $1; $$->scope = LSA_SCOPE_AS; }
155134f3 541 | lsadb_args AREA idval { $$ = $1; $$->scope = LSA_SCOPE_AREA; $$->area = $3; }
20ab192b
OZ
542 | lsadb_args LINK { $$ = $1; $$->scope = 1; /* hack, 0 is no filter */ }
543 | lsadb_args TYPE NUM { $$ = $1; $$->type = $3; }
544 | lsadb_args LSID idval { $$ = $1; $$->lsid = $3; }
545 | lsadb_args SELF { $$ = $1; $$->router = SH_ROUTER_SELF; }
546 | lsadb_args ROUTER idval { $$ = $1; $$->router = $3; }
9eef9c64 547 | lsadb_args CF_SYM_KNOWN { cf_assert_symbol($2, SYM_PROTO); $$ = $1; $$->proto = (struct ospf_proto *) proto_get_named($2, &proto_ospf); }
20ab192b 548 ;
98899244 549
c1f8dc91
OF
550CF_CODE
551
552CF_END