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