]>
Commit | Line | Data |
---|---|---|
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 | ||
9 | CF_HDR | |
10 | ||
11 | #include "proto/ospf/ospf.h" | |
12 | ||
3fa5722d OF |
13 | CF_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 | |
18 | static struct ospf_area_config *this_area; | |
e5b5d18c | 19 | static struct nbma_node *this_nbma; |
98ac6176 | 20 | static struct area_net_config *this_pref; |
38675202 | 21 | static struct ospf_stubnet_config *this_stubnet; |
3fa5722d | 22 | |
c3226991 | 23 | #ifdef OSPFv2 |
024c310b OZ |
24 | static void |
25 | finish_iface_config(struct ospf_iface_patt *ip) | |
26 | { | |
27 | ip->passwords = get_passwords(); | |
28 | ||
29 | if ((ip->autype == OSPF_AUTH_CRYPT) && (ip->helloint < 5)) | |
30 | log(L_WARN "Hello or poll interval less that 5 makes cryptographic authenication prone to replay attacks"); | |
31 | ||
32 | if ((ip->autype == OSPF_AUTH_NONE) && (ip->passwords != NULL)) | |
33 | log(L_WARN "Password option without authentication option does not make sense"); | |
34 | } | |
c3226991 OZ |
35 | #endif |
36 | ||
37 | #ifdef OSPFv3 | |
38 | static void | |
39 | finish_iface_config(struct ospf_iface_patt *ip) | |
40 | { | |
41 | if ((ip->autype != OSPF_AUTH_NONE) || (get_passwords() != NULL)) | |
e4a810b0 | 42 | cf_error("Authentication not supported in OSPFv3"); |
c3226991 OZ |
43 | } |
44 | #endif | |
024c310b | 45 | |
c1f8dc91 OF |
46 | CF_DECLS |
47 | ||
c27b2449 OZ |
48 | CF_KEYWORDS(OSPF, AREA, OSPF_METRIC1, OSPF_METRIC2, OSPF_TAG, OSPF_ROUTER_ID) |
49 | CF_KEYWORDS(BROADCAST, NEIGHBORS, RFC1583COMPAT, STUB, TICK, COST, RETRANSMIT) | |
bd457b8d | 50 | CF_KEYWORDS(HELLO, TRANSMIT, PRIORITY, DEAD, NONBROADCAST, POINTOPOINT, TYPE) |
ea357b8b | 51 | CF_KEYWORDS(NONE, SIMPLE, AUTHENTICATION, STRICT, CRYPTOGRAPHIC) |
98ac6176 | 52 | CF_KEYWORDS(ELIGIBLE, POLL, NETWORKS, HIDDEN, VIRTUAL, LINK) |
38675202 | 53 | CF_KEYWORDS(RX, BUFFER, LARGE, NORMAL, STUBNET, HIDDEN, SUMMARY) |
3f22fa9e | 54 | CF_KEYWORDS(WAIT, DELAY, LSADB) |
c1f8dc91 | 55 | |
c4f0f014 OF |
56 | %type <t> opttext |
57 | ||
c1f8dc91 OF |
58 | CF_GRAMMAR |
59 | ||
e3c460bc | 60 | CF_ADDTO(proto, ospf_proto '}') |
c1f8dc91 OF |
61 | |
62 | ospf_proto_start: proto_start OSPF { | |
63 | this_proto = proto_config_new(&proto_ospf, sizeof(struct ospf_config)); | |
916c8c0a | 64 | this_proto->preference = DEF_PREF_OSPF; |
b36a0a79 | 65 | init_list(&OSPF_CFG->area_list); |
d631698e | 66 | OSPF_CFG->rfc1583 = DEFAULT_RFC1583; |
b8f17cf1 | 67 | OSPF_CFG->tick = DEFAULT_OSPFTICK; |
c1f8dc91 OF |
68 | } |
69 | ; | |
70 | ||
71 | ospf_proto: | |
72 | ospf_proto_start proto_name '{' | |
f8032bbd MM |
73 | | ospf_proto ospf_proto_item ';' |
74 | ; | |
75 | ||
76 | ospf_proto_item: | |
77 | proto_item | |
002ecc06 | 78 | | RFC1583COMPAT bool { OSPF_CFG->rfc1583 = $2; } |
b8f17cf1 | 79 | | TICK expr { OSPF_CFG->tick = $2 ; if($2<=0) cf_error("Tick must be greater than zero"); } |
f8032bbd MM |
80 | | ospf_area '}' |
81 | ; | |
c1f8dc91 | 82 | |
b36a0a79 OF |
83 | ospf_area_start: AREA idval '{' { |
84 | this_area = cfg_allocz(sizeof(struct ospf_area_config)); | |
85 | add_tail(&OSPF_CFG->area_list, NODE this_area); | |
86 | this_area->areaid = $2; | |
b36a0a79 | 87 | this_area->stub = 0; |
89d6782d | 88 | init_list(&this_area->patt_list); |
3b16080c | 89 | init_list(&this_area->vlink_list); |
c926eee7 | 90 | init_list(&this_area->net_list); |
38675202 | 91 | init_list(&this_area->stubnet_list); |
c1f8dc91 | 92 | } |
f8032bbd | 93 | ; |
c4f0f014 | 94 | |
71f7d043 | 95 | ospf_area: ospf_area_start ospf_area_opts |
f8032bbd | 96 | ; |
a789d814 OF |
97 | |
98 | ospf_area_opts: | |
f8032bbd MM |
99 | /* empty */ |
100 | | ospf_area_opts ospf_area_item ';' | |
101 | ; | |
a789d814 | 102 | |
b36a0a79 | 103 | ospf_area_item: |
b2bdb406 | 104 | STUB COST expr { this_area->stub = $3 ; if($3<=0) cf_error("Stub cost must be greater than zero"); } |
8d94a524 | 105 | | STUB bool {if($2) { if(!this_area->stub) this_area->stub=DEFAULT_STUB_COST;}else{ this_area->stub=0;}} |
c926eee7 | 106 | | NETWORKS '{' pref_list '}' |
38675202 | 107 | | STUBNET ospf_stubnet |
20e94fb8 | 108 | | INTERFACE ospf_iface |
3b16080c | 109 | | ospf_vlink |
f8032bbd | 110 | ; |
89d6782d | 111 | |
38675202 OZ |
112 | ospf_stubnet: |
113 | ospf_stubnet_start '{' ospf_stubnet_opts '}' | |
114 | | ospf_stubnet_start | |
115 | ; | |
116 | ||
117 | ospf_stubnet_start: | |
118 | prefix { | |
1b3b3e34 | 119 | this_stubnet = cfg_allocz(sizeof(struct ospf_stubnet_config)); |
38675202 OZ |
120 | add_tail(&this_area->stubnet_list, NODE this_stubnet); |
121 | this_stubnet->px = $1; | |
122 | this_stubnet->cost = COST_D; | |
123 | } | |
124 | ; | |
125 | ||
126 | ospf_stubnet_opts: | |
127 | /* empty */ | |
128 | | ospf_stubnet_opts ospf_stubnet_item ';' | |
129 | ; | |
130 | ||
131 | ospf_stubnet_item: | |
132 | HIDDEN bool { this_stubnet->hidden = $2; } | |
133 | | SUMMARY bool { this_stubnet->summary = $2; } | |
134 | | COST expr { this_stubnet->cost = $2; } | |
135 | ; | |
136 | ||
3b16080c | 137 | ospf_vlink: |
024c310b | 138 | ospf_vlink_start '{' ospf_vlink_opts '}' { finish_iface_config(OSPF_PATT); } |
3b16080c | 139 | | ospf_vlink_start |
98ac6176 OF |
140 | ; |
141 | ||
142 | ospf_vlink_opts: | |
143 | /* empty */ | |
144 | | ospf_vlink_opts ospf_vlink_item ';' | |
145 | ; | |
146 | ||
147 | ospf_vlink_item: | |
3b16080c | 148 | | HELLO expr { OSPF_PATT->helloint = $2 ; if (($2<=0) || ($2>65535)) cf_error("Hello interval must be in range 1-65535"); } |
98ac6176 OF |
149 | | RETRANSMIT expr { OSPF_PATT->rxmtint = $2 ; if ($2<=0) cf_error("Retransmit int must be greater than zero"); } |
150 | | TRANSMIT DELAY expr { OSPF_PATT->inftransdelay = $3 ; if (($3<=0) || ($3>65535)) cf_error("Transmit delay must be in range 1-65535"); } | |
151 | | WAIT expr { OSPF_PATT->waitint = $2 ; } | |
d8c7d9e8 | 152 | | DEAD expr { OSPF_PATT->dead = $2 ; if ($2<=1) cf_error("Dead interval must be greater than one"); } |
98ac6176 | 153 | | DEAD COUNT expr { OSPF_PATT->deadc = $3 ; if ($3<=1) cf_error("Dead count must be greater than one"); } |
3e2bd0f1 OF |
154 | | AUTHENTICATION NONE { OSPF_PATT->autype = OSPF_AUTH_NONE ; } |
155 | | AUTHENTICATION SIMPLE { OSPF_PATT->autype = OSPF_AUTH_SIMPLE ; } | |
32d3228d | 156 | | AUTHENTICATION CRYPTOGRAPHIC { OSPF_PATT->autype = OSPF_AUTH_CRYPT ; } |
b21f68b4 | 157 | | password_list |
98ac6176 OF |
158 | ; |
159 | ||
3b16080c | 160 | ospf_vlink_start: VIRTUAL LINK idval |
98ac6176 OF |
161 | { |
162 | if (this_area->areaid == 0) cf_error("Virtual link cannot be in backbone"); | |
163 | this_ipatt = cfg_allocz(sizeof(struct ospf_iface_patt)); | |
3b16080c | 164 | add_tail(&this_area->vlink_list, NODE this_ipatt); |
20e94fb8 | 165 | init_list(&this_ipatt->ipn_list); |
3b16080c | 166 | OSPF_PATT->vid = $3; |
98ac6176 | 167 | OSPF_PATT->helloint = HELLOINT_D; |
98ac6176 OF |
168 | OSPF_PATT->rxmtint = RXMTINT_D; |
169 | OSPF_PATT->inftransdelay = INFTRANSDELAY_D; | |
170 | OSPF_PATT->waitint = WAIT_DMH*HELLOINT_D; | |
171 | OSPF_PATT->deadc = DEADC_D; | |
d8c7d9e8 | 172 | OSPF_PATT->dead = 0; |
98ac6176 | 173 | OSPF_PATT->type = OSPF_IT_VLINK; |
3b16080c | 174 | init_list(&OSPF_PATT->nbma_list); |
3e2bd0f1 | 175 | OSPF_PATT->autype = OSPF_AUTH_NONE; |
024c310b | 176 | reset_passwords(); |
98ac6176 OF |
177 | } |
178 | ; | |
179 | ||
89d6782d | 180 | ospf_iface_item: |
7df86c25 OF |
181 | COST expr { OSPF_PATT->cost = $2 ; if (($2<=0) || ($2>65535)) cf_error("Cost must be in range 1-65535"); } |
182 | | HELLO expr { OSPF_PATT->helloint = $2 ; if (($2<=0) || ($2>65535)) cf_error("Hello interval must be in range 1-65535"); } | |
183 | | POLL expr { OSPF_PATT->pollint = $2 ; if ($2<=0) cf_error("Poll int must be greater than zero"); } | |
184 | | RETRANSMIT expr { OSPF_PATT->rxmtint = $2 ; if ($2<=0) cf_error("Retransmit int must be greater than zero"); } | |
185 | | TRANSMIT DELAY expr { OSPF_PATT->inftransdelay = $3 ; if (($3<=0) || ($3>65535)) cf_error("Transmit delay must be in range 1-65535"); } | |
7715f9d9 | 186 | | PRIORITY expr { OSPF_PATT->priority = $2 ; if (($2<0) || ($2>255)) cf_error("Priority must be in range 0-255"); } |
bd457b8d | 187 | | WAIT expr { OSPF_PATT->waitint = $2 ; } |
d8c7d9e8 | 188 | | DEAD expr { OSPF_PATT->dead = $2 ; if ($2<=1) cf_error("Dead interval must be greater than one"); } |
7df86c25 | 189 | | DEAD COUNT expr { OSPF_PATT->deadc = $3 ; if ($3<=1) cf_error("Dead count must be greater than one"); } |
aaaff776 OF |
190 | | TYPE BROADCAST { OSPF_PATT->type = OSPF_IT_BCAST ; } |
191 | | TYPE NONBROADCAST { OSPF_PATT->type = OSPF_IT_NBMA ; } | |
192 | | TYPE POINTOPOINT { OSPF_PATT->type = OSPF_IT_PTP ; } | |
a190e720 | 193 | | STRICT NONBROADCAST bool { OSPF_PATT->strictnbma = $3 ; } |
e3bc10fd | 194 | | STUB bool { OSPF_PATT->stub = $2 ; } |
e5b5d18c | 195 | | NEIGHBORS '{' ipa_list '}' |
3e2bd0f1 OF |
196 | | AUTHENTICATION NONE { OSPF_PATT->autype = OSPF_AUTH_NONE ; } |
197 | | AUTHENTICATION SIMPLE { OSPF_PATT->autype = OSPF_AUTH_SIMPLE ; } | |
ea357b8b | 198 | | AUTHENTICATION CRYPTOGRAPHIC { OSPF_PATT->autype = OSPF_AUTH_CRYPT ; } |
94c42054 OF |
199 | | RX BUFFER LARGE { OSPF_PATT->rxbuf = OSPF_RXBUF_LARGE ; } |
200 | | RX BUFFER NORMAL { OSPF_PATT->rxbuf = OSPF_RXBUF_NORMAL ; } | |
201 | | RX BUFFER expr { OSPF_PATT->rxbuf = $3 ; if ($3 < OSPF_RXBUF_MINSIZE) cf_error("Buffer size is too small") ; } | |
b21f68b4 | 202 | | password_list |
f8032bbd | 203 | ; |
e5b5d18c | 204 | |
c926eee7 OF |
205 | pref_list: |
206 | /* empty */ | |
207 | | pref_list pref_item | |
208 | ; | |
209 | ||
210 | pref_item: | |
de259a41 | 211 | pref_el |
c926eee7 OF |
212 | | pref_hid; |
213 | ||
214 | pref_el: prefix ';' | |
215 | { | |
98ac6176 | 216 | this_pref = cfg_allocz(sizeof(struct area_net_config)); |
c926eee7 | 217 | add_tail(&this_area->net_list, NODE this_pref); |
66261211 OF |
218 | this_pref->px.addr = $1.addr; |
219 | this_pref->px.len = $1.len; | |
c926eee7 OF |
220 | } |
221 | ; | |
222 | ||
223 | pref_hid: prefix HIDDEN ';' | |
224 | { | |
98ac6176 | 225 | this_pref = cfg_allocz(sizeof(struct area_net_config)); |
c926eee7 | 226 | add_tail(&this_area->net_list, NODE this_pref); |
66261211 OF |
227 | this_pref->px.addr = $1.addr; |
228 | this_pref->px.len = $1.len; | |
c926eee7 OF |
229 | this_pref->hidden = 1; |
230 | } | |
231 | ; | |
232 | ||
e5b5d18c OF |
233 | ipa_list: |
234 | /* empty */ | |
235 | | ipa_list ipa_item | |
236 | ; | |
a190e720 OF |
237 | |
238 | ipa_item: | |
de259a41 | 239 | ipa_el |
a190e720 | 240 | | ipa_ne; |
e5b5d18c | 241 | |
a190e720 OF |
242 | ipa_el: IPA ';' |
243 | { | |
244 | this_nbma = cfg_allocz(sizeof(struct nbma_node)); | |
245 | add_tail(&OSPF_PATT->nbma_list, NODE this_nbma); | |
246 | this_nbma->ip=$1; | |
247 | this_nbma->eligible=0; | |
248 | } | |
249 | ; | |
250 | ||
251 | ipa_ne: IPA ELIGIBLE ';' | |
e5b5d18c OF |
252 | { |
253 | this_nbma = cfg_allocz(sizeof(struct nbma_node)); | |
254 | add_tail(&OSPF_PATT->nbma_list, NODE this_nbma); | |
255 | this_nbma->ip=$1; | |
a190e720 | 256 | this_nbma->eligible=1; |
e5b5d18c OF |
257 | } |
258 | ; | |
259 | ||
b36a0a79 | 260 | |
aaaff776 OF |
261 | ospf_iface_start: |
262 | { | |
263 | this_ipatt = cfg_allocz(sizeof(struct ospf_iface_patt)); | |
264 | add_tail(&this_area->patt_list, NODE this_ipatt); | |
20e94fb8 | 265 | init_list(&this_ipatt->ipn_list); |
aaaff776 OF |
266 | OSPF_PATT->cost = COST_D; |
267 | OSPF_PATT->helloint = HELLOINT_D; | |
a190e720 | 268 | OSPF_PATT->pollint = POLLINT_D; |
aaaff776 OF |
269 | OSPF_PATT->rxmtint = RXMTINT_D; |
270 | OSPF_PATT->inftransdelay = INFTRANSDELAY_D; | |
271 | OSPF_PATT->priority = PRIORITY_D; | |
272 | OSPF_PATT->waitint = WAIT_DMH*HELLOINT_D; | |
273 | OSPF_PATT->deadc = DEADC_D; | |
d8c7d9e8 | 274 | OSPF_PATT->dead = 0; |
aaaff776 | 275 | OSPF_PATT->type = OSPF_IT_UNDEF; |
a190e720 | 276 | OSPF_PATT->strictnbma = 0; |
e3bc10fd | 277 | OSPF_PATT->stub = 0; |
e5b5d18c | 278 | init_list(&OSPF_PATT->nbma_list); |
3e2bd0f1 | 279 | OSPF_PATT->autype = OSPF_AUTH_NONE; |
024c310b | 280 | reset_passwords(); |
aaaff776 OF |
281 | } |
282 | ; | |
283 | ||
89d6782d | 284 | ospf_iface_opts: |
f8032bbd | 285 | /* empty */ |
89d6782d OF |
286 | | ospf_iface_opts ospf_iface_item ';' |
287 | ; | |
288 | ||
f8032bbd MM |
289 | ospf_iface_opt_list: |
290 | /* empty */ | |
291 | | '{' ospf_iface_opts '}' | |
292 | ; | |
89d6782d | 293 | |
89d6782d | 294 | ospf_iface: |
20e94fb8 | 295 | ospf_iface_start iface_patt_list ospf_iface_opt_list { finish_iface_config(OSPF_PATT); } |
89d6782d OF |
296 | ; |
297 | ||
c4f0f014 OF |
298 | opttext: |
299 | TEXT | |
f8032bbd MM |
300 | | /* empty */ { $$ = NULL; } |
301 | ; | |
c1f8dc91 | 302 | |
5919c66e MM |
303 | CF_ADDTO(dynamic_attr, OSPF_METRIC1 { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF_TEMP, T_INT, EA_OSPF_METRIC1); }) |
304 | CF_ADDTO(dynamic_attr, OSPF_METRIC2 { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF_TEMP, T_INT, EA_OSPF_METRIC2); }) | |
305 | CF_ADDTO(dynamic_attr, OSPF_TAG { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF_TEMP, T_INT, EA_OSPF_TAG); }) | |
126683fe | 306 | CF_ADDTO(dynamic_attr, OSPF_ROUTER_ID { $$ = f_new_dynamic_attr(EAF_TYPE_ROUTER_ID | EAF_TEMP, T_QUAD, EA_OSPF_ROUTER_ID); }) |
5919c66e | 307 | |
ec423cc7 | 308 | CF_CLI(SHOW OSPF, optsym, [<name>], [[Show information about OSPF protocol]]) |
a3b70dc4 | 309 | { ospf_sh(proto_get_named($3, &proto_ospf)); }; |
4ab4e977 | 310 | |
ec423cc7 | 311 | CF_CLI(SHOW OSPF NEIGHBORS, optsym opttext, [<name>] [\"<interface>\"], [[Show information about OSPF neighbors]]) |
a3b70dc4 | 312 | { ospf_sh_neigh(proto_get_named($4, &proto_ospf), $5); }; |
c4f0f014 | 313 | |
ec423cc7 | 314 | CF_CLI(SHOW OSPF INTERFACE, optsym opttext, [<name>] [\"<interface>\"], [[Show information about interface]]) |
c4f0f014 | 315 | { ospf_sh_iface(proto_get_named($4, &proto_ospf), $5); }; |
a783e259 | 316 | |
0ea8fb4a | 317 | CF_CLI_HELP(SHOW OSPF TOPOLOGY, [all] [<name>], [[Show information about OSPF network topology]]) |
a3b70dc4 | 318 | |
0ea8fb4a OZ |
319 | CF_CLI(SHOW OSPF TOPOLOGY, optsym opttext, [<name>], [[Show information about reachable OSPF network topology]]) |
320 | { ospf_sh_state(proto_get_named($4, &proto_ospf), 0, 1); }; | |
321 | ||
322 | CF_CLI(SHOW OSPF TOPOLOGY ALL, optsym opttext, [<name>], [[Show information about all OSPF network topology]]) | |
323 | { ospf_sh_state(proto_get_named($5, &proto_ospf), 0, 0); }; | |
324 | ||
325 | CF_CLI_HELP(SHOW OSPF STATE, [all] [<name>], [[Show information about OSPF network state]]) | |
326 | ||
327 | CF_CLI(SHOW OSPF STATE, optsym opttext, [<name>], [[Show information about reachable OSPF network state]]) | |
328 | { ospf_sh_state(proto_get_named($4, &proto_ospf), 1, 1); }; | |
329 | ||
330 | CF_CLI(SHOW OSPF STATE ALL, optsym opttext, [<name>], [[Show information about all OSPF network state]]) | |
331 | { ospf_sh_state(proto_get_named($5, &proto_ospf), 1, 0); }; | |
a3b70dc4 | 332 | |
98899244 OZ |
333 | CF_CLI(SHOW OSPF LSADB, optsym opttext, [<name>], [[Show content of OSPF LSA database]]) |
334 | { ospf_sh_lsadb(proto_get_named($4, &proto_ospf)); }; | |
335 | ||
c1f8dc91 OF |
336 | CF_CODE |
337 | ||
338 | CF_END |