]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* OSPF VTY interface. |
ba682537 | 2 | * Copyright (C) 2005 6WIND <alain.ritoux@6wind.com> |
718e3744 | 3 | * Copyright (C) 2000 Toshiaki Takada |
4 | * | |
5 | * This file is part of GNU Zebra. | |
6 | * | |
7 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
8 | * under the terms of the GNU General Public License as published by the | |
9 | * Free Software Foundation; either version 2, or (at your option) any | |
10 | * later version. | |
11 | * | |
12 | * GNU Zebra is distributed in the hope that it will be useful, but | |
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with GNU Zebra; see the file COPYING. If not, write to the Free | |
19 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
20 | * 02111-1307, USA. | |
21 | */ | |
22 | ||
23 | #include <zebra.h> | |
24 | ||
25 | #include "memory.h" | |
26 | #include "thread.h" | |
27 | #include "prefix.h" | |
28 | #include "table.h" | |
29 | #include "vty.h" | |
30 | #include "command.h" | |
31 | #include "plist.h" | |
32 | #include "log.h" | |
33 | #include "zclient.h" | |
34 | ||
35 | #include "ospfd/ospfd.h" | |
36 | #include "ospfd/ospf_asbr.h" | |
37 | #include "ospfd/ospf_lsa.h" | |
38 | #include "ospfd/ospf_lsdb.h" | |
39 | #include "ospfd/ospf_ism.h" | |
40 | #include "ospfd/ospf_interface.h" | |
41 | #include "ospfd/ospf_nsm.h" | |
42 | #include "ospfd/ospf_neighbor.h" | |
43 | #include "ospfd/ospf_flood.h" | |
44 | #include "ospfd/ospf_abr.h" | |
45 | #include "ospfd/ospf_spf.h" | |
46 | #include "ospfd/ospf_route.h" | |
47 | #include "ospfd/ospf_zebra.h" | |
48 | /*#include "ospfd/ospf_routemap.h" */ | |
49 | #include "ospfd/ospf_vty.h" | |
50 | #include "ospfd/ospf_dump.h" | |
51 | ||
6b0655a2 | 52 | |
30a2231a | 53 | static const char *ospf_network_type_str[] = |
718e3744 | 54 | { |
55 | "Null", | |
56 | "POINTOPOINT", | |
57 | "BROADCAST", | |
58 | "NBMA", | |
59 | "POINTOMULTIPOINT", | |
60 | "VIRTUALLINK", | |
61 | "LOOPBACK" | |
62 | }; | |
63 | ||
6b0655a2 | 64 | |
718e3744 | 65 | /* Utility functions. */ |
4dadc291 | 66 | static int |
6c835671 | 67 | ospf_str2area_id (const char *str, struct in_addr *area_id, int *format) |
718e3744 | 68 | { |
69 | char *endptr = NULL; | |
70 | unsigned long ret; | |
71 | ||
72 | /* match "A.B.C.D". */ | |
73 | if (strchr (str, '.') != NULL) | |
74 | { | |
75 | ret = inet_aton (str, area_id); | |
76 | if (!ret) | |
77 | return -1; | |
78 | *format = OSPF_AREA_ID_FORMAT_ADDRESS; | |
79 | } | |
80 | /* match "<0-4294967295>". */ | |
81 | else | |
82 | { | |
664711c1 UW |
83 | if (*str == '-') |
84 | return -1; | |
85 | errno = 0; | |
718e3744 | 86 | ret = strtoul (str, &endptr, 10); |
664711c1 | 87 | if (*endptr != '\0' || errno || ret > UINT32_MAX) |
718e3744 | 88 | return -1; |
89 | ||
90 | area_id->s_addr = htonl (ret); | |
91 | *format = OSPF_AREA_ID_FORMAT_DECIMAL; | |
92 | } | |
93 | ||
94 | return 0; | |
95 | } | |
96 | ||
6b0655a2 | 97 | |
4dadc291 | 98 | static int |
6c835671 | 99 | str2metric (const char *str, int *metric) |
718e3744 | 100 | { |
101 | /* Sanity check. */ | |
102 | if (str == NULL) | |
103 | return 0; | |
104 | ||
105 | *metric = strtol (str, NULL, 10); | |
106 | if (*metric < 0 && *metric > 16777214) | |
107 | { | |
108 | /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */ | |
109 | return 0; | |
110 | } | |
111 | ||
112 | return 1; | |
113 | } | |
114 | ||
4dadc291 | 115 | static int |
6c835671 | 116 | str2metric_type (const char *str, int *metric_type) |
718e3744 | 117 | { |
118 | /* Sanity check. */ | |
119 | if (str == NULL) | |
120 | return 0; | |
121 | ||
122 | if (strncmp (str, "1", 1) == 0) | |
123 | *metric_type = EXTERNAL_METRIC_TYPE_1; | |
124 | else if (strncmp (str, "2", 1) == 0) | |
125 | *metric_type = EXTERNAL_METRIC_TYPE_2; | |
126 | else | |
127 | return 0; | |
128 | ||
129 | return 1; | |
130 | } | |
131 | ||
132 | int | |
133 | ospf_oi_count (struct interface *ifp) | |
134 | { | |
135 | struct route_node *rn; | |
136 | int i = 0; | |
137 | ||
138 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
139 | if (rn->info) | |
140 | i++; | |
141 | ||
142 | return i; | |
143 | } | |
144 | ||
6b0655a2 | 145 | |
718e3744 | 146 | DEFUN (router_ospf, |
147 | router_ospf_cmd, | |
148 | "router ospf", | |
149 | "Enable a routing process\n" | |
150 | "Start OSPF configuration\n") | |
151 | { | |
7c8ff89e DS |
152 | struct ospf *ospf; |
153 | u_short instance = 0; | |
154 | ||
155 | ospf = ospf_lookup(); | |
156 | if (!ospf) | |
157 | { | |
158 | vty_out (vty, "There isn't active ospf instance %s", VTY_NEWLINE); | |
159 | return CMD_WARNING; | |
160 | } | |
161 | ||
718e3744 | 162 | vty->node = OSPF_NODE; |
7c8ff89e DS |
163 | |
164 | if (argc) | |
165 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
166 | ||
167 | /* The following logic to set the vty->index is in place to be able | |
168 | to ignore the commands which dont belong to this instance. */ | |
169 | if (ospf->instance != instance) | |
170 | vty->index = NULL; | |
171 | else | |
0bad4851 DS |
172 | { |
173 | if (IS_DEBUG_OSPF_EVENT) | |
174 | zlog_debug ("Config command 'router ospf %d' received", instance); | |
175 | ospf->oi_running = 1; | |
176 | vty->index = ospf; | |
177 | ospf_router_id_update (ospf); | |
178 | } | |
718e3744 | 179 | |
180 | return CMD_SUCCESS; | |
181 | } | |
182 | ||
7c8ff89e DS |
183 | ALIAS (router_ospf, |
184 | router_ospf_instance_cmd, | |
185 | "router ospf <1-65535>", | |
186 | "Enable a routing process\n" | |
187 | "Start OSPF configuration\n" | |
188 | "Instance ID\n") | |
189 | ||
718e3744 | 190 | DEFUN (no_router_ospf, |
191 | no_router_ospf_cmd, | |
192 | "no router ospf", | |
193 | NO_STR | |
194 | "Enable a routing process\n" | |
195 | "Start OSPF configuration\n") | |
196 | { | |
020709f9 | 197 | struct ospf *ospf; |
7c8ff89e | 198 | u_short instance = 0; |
020709f9 | 199 | |
7c8ff89e DS |
200 | if (argc) |
201 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
202 | ||
203 | if ((ospf = ospf_lookup_instance (instance)) == NULL) | |
204 | return CMD_SUCCESS; | |
718e3744 | 205 | |
020709f9 | 206 | ospf_finish (ospf); |
718e3744 | 207 | |
208 | return CMD_SUCCESS; | |
209 | } | |
210 | ||
7c8ff89e DS |
211 | ALIAS (no_router_ospf, |
212 | no_router_ospf_instance_cmd, | |
213 | "no router ospf <1-65535>", | |
214 | NO_STR | |
215 | "Enable a routing process\n" | |
216 | "Start OSPF configuration\n" | |
217 | "Instance ID\n") | |
218 | ||
718e3744 | 219 | DEFUN (ospf_router_id, |
220 | ospf_router_id_cmd, | |
221 | "ospf router-id A.B.C.D", | |
222 | "OSPF specific commands\n" | |
223 | "router-id for the OSPF process\n" | |
224 | "OSPF router-id in IP address format\n") | |
225 | { | |
68980084 | 226 | struct ospf *ospf = vty->index; |
2c19a6ec DS |
227 | struct listnode *node; |
228 | struct ospf_area *area; | |
718e3744 | 229 | struct in_addr router_id; |
68980084 | 230 | int ret; |
718e3744 | 231 | |
7c8ff89e DS |
232 | if (!ospf) |
233 | return CMD_SUCCESS; | |
234 | ||
718e3744 | 235 | ret = inet_aton (argv[0], &router_id); |
236 | if (!ret) | |
237 | { | |
238 | vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE); | |
239 | return CMD_WARNING; | |
240 | } | |
241 | ||
68980084 | 242 | ospf->router_id_static = router_id; |
2c19a6ec DS |
243 | |
244 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) | |
245 | if (area->full_nbrs) | |
246 | { | |
247 | vty_out (vty, "For this router-id change to take effect," | |
248 | " save config and restart ospfd%s", VTY_NEWLINE); | |
249 | return CMD_SUCCESS; | |
250 | } | |
251 | ||
b29800a6 | 252 | ospf_router_id_update (ospf); |
253 | ||
718e3744 | 254 | return CMD_SUCCESS; |
255 | } | |
256 | ||
257 | ALIAS (ospf_router_id, | |
a2c62831 | 258 | router_ospf_id_cmd, |
718e3744 | 259 | "router-id A.B.C.D", |
260 | "router-id for the OSPF process\n" | |
261 | "OSPF router-id in IP address format\n") | |
262 | ||
263 | DEFUN (no_ospf_router_id, | |
264 | no_ospf_router_id_cmd, | |
265 | "no ospf router-id", | |
266 | NO_STR | |
267 | "OSPF specific commands\n" | |
268 | "router-id for the OSPF process\n") | |
269 | { | |
68980084 | 270 | struct ospf *ospf = vty->index; |
2c19a6ec DS |
271 | struct listnode *node; |
272 | struct ospf_area *area; | |
68980084 | 273 | |
7c8ff89e DS |
274 | if (!ospf) |
275 | return CMD_SUCCESS; | |
276 | ||
68980084 | 277 | ospf->router_id_static.s_addr = 0; |
718e3744 | 278 | |
2c19a6ec DS |
279 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
280 | if (area->full_nbrs) | |
281 | { | |
282 | vty_out (vty, "For this router-id change to take effect," | |
283 | " save config and restart ospfd%s", VTY_NEWLINE); | |
284 | return CMD_SUCCESS; | |
285 | } | |
286 | ||
68980084 | 287 | ospf_router_id_update (ospf); |
718e3744 | 288 | |
289 | return CMD_SUCCESS; | |
290 | } | |
291 | ||
292 | ALIAS (no_ospf_router_id, | |
a2c62831 | 293 | no_router_ospf_id_cmd, |
718e3744 | 294 | "no router-id", |
295 | NO_STR | |
296 | "router-id for the OSPF process\n") | |
297 | ||
7ffa8fa2 | 298 | static void |
43540886 | 299 | ospf_passive_interface_default (struct ospf *ospf, u_char newval) |
7ffa8fa2 PJ |
300 | { |
301 | struct listnode *ln; | |
302 | struct interface *ifp; | |
303 | struct ospf_interface *oi; | |
304 | ||
43540886 AS |
305 | ospf->passive_interface_default = newval; |
306 | ||
7ffa8fa2 PJ |
307 | for (ALL_LIST_ELEMENTS_RO (om->iflist, ln, ifp)) |
308 | { | |
309 | if (ifp && | |
310 | OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)) | |
311 | UNSET_IF_PARAM (IF_DEF_PARAMS (ifp), passive_interface); | |
312 | } | |
313 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, ln, oi)) | |
314 | { | |
315 | if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface)) | |
316 | UNSET_IF_PARAM (oi->params, passive_interface); | |
43540886 AS |
317 | /* update multicast memberships */ |
318 | ospf_if_set_multicast(oi); | |
7ffa8fa2 PJ |
319 | } |
320 | } | |
321 | ||
322 | static void | |
323 | ospf_passive_interface_update (struct ospf *ospf, struct interface *ifp, | |
324 | struct in_addr addr, | |
325 | struct ospf_if_params *params, u_char value) | |
326 | { | |
327 | u_char dflt; | |
328 | ||
329 | params->passive_interface = value; | |
330 | if (params != IF_DEF_PARAMS (ifp)) | |
331 | { | |
332 | if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)) | |
333 | dflt = IF_DEF_PARAMS (ifp)->passive_interface; | |
334 | else | |
335 | dflt = ospf->passive_interface_default; | |
336 | ||
337 | if (value != dflt) | |
338 | SET_IF_PARAM (params, passive_interface); | |
339 | else | |
340 | UNSET_IF_PARAM (params, passive_interface); | |
341 | ||
342 | ospf_free_if_params (ifp, addr); | |
343 | ospf_if_update_params (ifp, addr); | |
344 | } | |
345 | else | |
346 | { | |
347 | if (value != ospf->passive_interface_default) | |
348 | SET_IF_PARAM (params, passive_interface); | |
349 | else | |
350 | UNSET_IF_PARAM (params, passive_interface); | |
351 | } | |
352 | } | |
353 | ||
a2c62831 | 354 | DEFUN (ospf_passive_interface, |
355 | ospf_passive_interface_addr_cmd, | |
718e3744 | 356 | "passive-interface IFNAME A.B.C.D", |
357 | "Suppress routing updates on an interface\n" | |
358 | "Interface's name\n") | |
359 | { | |
7ffa8fa2 PJ |
360 | struct interface *ifp; |
361 | struct in_addr addr; | |
362 | int ret; | |
363 | struct ospf_if_params *params; | |
364 | struct route_node *rn; | |
365 | struct ospf *ospf = vty->index; | |
718e3744 | 366 | |
7c8ff89e DS |
367 | if (!ospf) |
368 | return CMD_SUCCESS; | |
369 | ||
43540886 AS |
370 | if (argc == 0) |
371 | { | |
372 | ospf_passive_interface_default (ospf, OSPF_IF_PASSIVE); | |
373 | return CMD_SUCCESS; | |
374 | } | |
375 | ||
7ffa8fa2 | 376 | ifp = if_get_by_name (argv[0]); |
718e3744 | 377 | |
378 | params = IF_DEF_PARAMS (ifp); | |
379 | ||
43540886 | 380 | if (argc == 2) |
718e3744 | 381 | { |
43540886 AS |
382 | ret = inet_aton(argv[1], &addr); |
383 | if (!ret) | |
384 | { | |
385 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
386 | VTY_NEWLINE); | |
387 | return CMD_WARNING; | |
388 | } | |
389 | ||
390 | params = ospf_get_if_params (ifp, addr); | |
391 | ospf_if_update_params (ifp, addr); | |
7ffa8fa2 | 392 | } |
43540886 AS |
393 | ospf_passive_interface_update (ospf, ifp, addr, params, OSPF_IF_PASSIVE); |
394 | ||
ba6454ec | 395 | /* XXX We should call ospf_if_set_multicast on exactly those |
396 | * interfaces for which the passive property changed. It is too much | |
397 | * work to determine this set, so we do this for every interface. | |
398 | * This is safe and reasonable because ospf_if_set_multicast uses a | |
399 | * record of joined groups to avoid systems calls if the desired | |
400 | * memberships match the current memership. | |
401 | */ | |
7ffa8fa2 | 402 | |
ba6454ec | 403 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn)) |
404 | { | |
405 | struct ospf_interface *oi = rn->info; | |
406 | ||
407 | if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE)) | |
43540886 | 408 | ospf_if_set_multicast(oi); |
ba6454ec | 409 | } |
410 | /* | |
411 | * XXX It is not clear what state transitions the interface needs to | |
412 | * undergo when going from active to passive. Fixing this will | |
413 | * require precise identification of interfaces having such a | |
414 | * transition. | |
415 | */ | |
416 | ||
718e3744 | 417 | return CMD_SUCCESS; |
418 | } | |
419 | ||
a2c62831 | 420 | ALIAS (ospf_passive_interface, |
421 | ospf_passive_interface_cmd, | |
718e3744 | 422 | "passive-interface IFNAME", |
423 | "Suppress routing updates on an interface\n" | |
424 | "Interface's name\n") | |
425 | ||
7ffa8fa2 PJ |
426 | ALIAS (ospf_passive_interface, |
427 | ospf_passive_interface_default_cmd, | |
428 | "passive-interface default", | |
429 | "Suppress routing updates on an interface\n" | |
430 | "Suppress routing updates on interfaces by default\n") | |
431 | ||
a2c62831 | 432 | DEFUN (no_ospf_passive_interface, |
433 | no_ospf_passive_interface_addr_cmd, | |
718e3744 | 434 | "no passive-interface IFNAME A.B.C.D", |
435 | NO_STR | |
436 | "Allow routing updates on an interface\n" | |
437 | "Interface's name\n") | |
438 | { | |
439 | struct interface *ifp; | |
440 | struct in_addr addr; | |
441 | struct ospf_if_params *params; | |
442 | int ret; | |
ba6454ec | 443 | struct route_node *rn; |
7ffa8fa2 | 444 | struct ospf *ospf = vty->index; |
43540886 | 445 | |
7c8ff89e DS |
446 | if (!ospf) |
447 | return CMD_SUCCESS; | |
448 | ||
43540886 AS |
449 | if (argc == 0) |
450 | { | |
451 | ospf_passive_interface_default (ospf, OSPF_IF_ACTIVE); | |
452 | return CMD_SUCCESS; | |
453 | } | |
718e3744 | 454 | |
6e72cb6a | 455 | ifp = if_get_by_name (argv[0]); |
718e3744 | 456 | |
457 | params = IF_DEF_PARAMS (ifp); | |
458 | ||
43540886 | 459 | if (argc == 2) |
718e3744 | 460 | { |
43540886 AS |
461 | ret = inet_aton(argv[1], &addr); |
462 | if (!ret) | |
463 | { | |
464 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
465 | VTY_NEWLINE); | |
466 | return CMD_WARNING; | |
467 | } | |
468 | ||
469 | params = ospf_lookup_if_params (ifp, addr); | |
470 | if (params == NULL) | |
471 | return CMD_SUCCESS; | |
718e3744 | 472 | } |
43540886 | 473 | ospf_passive_interface_update (ospf, ifp, addr, params, OSPF_IF_ACTIVE); |
ba6454ec | 474 | |
475 | /* XXX We should call ospf_if_set_multicast on exactly those | |
476 | * interfaces for which the passive property changed. It is too much | |
477 | * work to determine this set, so we do this for every interface. | |
478 | * This is safe and reasonable because ospf_if_set_multicast uses a | |
479 | * record of joined groups to avoid systems calls if the desired | |
480 | * memberships match the current memership. | |
481 | */ | |
482 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn)) | |
483 | { | |
484 | struct ospf_interface *oi = rn->info; | |
485 | ||
486 | if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE)) | |
487 | ospf_if_set_multicast(oi); | |
488 | } | |
489 | ||
718e3744 | 490 | return CMD_SUCCESS; |
491 | } | |
492 | ||
a2c62831 | 493 | ALIAS (no_ospf_passive_interface, |
494 | no_ospf_passive_interface_cmd, | |
718e3744 | 495 | "no passive-interface IFNAME", |
496 | NO_STR | |
497 | "Allow routing updates on an interface\n" | |
498 | "Interface's name\n") | |
499 | ||
7ffa8fa2 PJ |
500 | ALIAS (no_ospf_passive_interface, |
501 | no_ospf_passive_interface_default_cmd, | |
502 | "no passive-interface default", | |
503 | NO_STR | |
504 | "Allow routing updates on an interface\n" | |
505 | "Allow routing updates on interfaces by default\n") | |
506 | ||
a2c62831 | 507 | DEFUN (ospf_network_area, |
508 | ospf_network_area_cmd, | |
718e3744 | 509 | "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)", |
510 | "Enable routing on an IP network\n" | |
511 | "OSPF network prefix\n" | |
512 | "Set the OSPF area ID\n" | |
513 | "OSPF area ID in IP address format\n" | |
514 | "OSPF area ID as a decimal value\n") | |
515 | { | |
516 | struct ospf *ospf= vty->index; | |
517 | struct prefix_ipv4 p; | |
518 | struct in_addr area_id; | |
519 | int ret, format; | |
520 | ||
7c8ff89e DS |
521 | if (!ospf) |
522 | return CMD_SUCCESS; | |
523 | ||
524 | if (ospf->instance) | |
525 | { | |
526 | vty_out (vty, "The network command is not supported in multi-instance ospf%s", | |
527 | VTY_NEWLINE); | |
528 | return CMD_WARNING; | |
529 | } | |
530 | ||
e723861d DS |
531 | if (ospf->if_ospf_cli_count > 0) |
532 | { | |
533 | vty_out (vty, "Please remove all ip ospf area x.x.x.x commands first.%s", | |
534 | VTY_NEWLINE); | |
535 | return CMD_WARNING; | |
536 | } | |
537 | ||
718e3744 | 538 | /* Get network prefix and Area ID. */ |
539 | VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]); | |
540 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]); | |
541 | ||
542 | ret = ospf_network_set (ospf, &p, area_id); | |
543 | if (ret == 0) | |
544 | { | |
545 | vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE); | |
546 | return CMD_WARNING; | |
547 | } | |
548 | ||
549 | return CMD_SUCCESS; | |
550 | } | |
551 | ||
a2c62831 | 552 | DEFUN (no_ospf_network_area, |
553 | no_ospf_network_area_cmd, | |
718e3744 | 554 | "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)", |
555 | NO_STR | |
556 | "Enable routing on an IP network\n" | |
557 | "OSPF network prefix\n" | |
558 | "Set the OSPF area ID\n" | |
559 | "OSPF area ID in IP address format\n" | |
560 | "OSPF area ID as a decimal value\n") | |
561 | { | |
562 | struct ospf *ospf = (struct ospf *) vty->index; | |
563 | struct prefix_ipv4 p; | |
564 | struct in_addr area_id; | |
565 | int ret, format; | |
566 | ||
7c8ff89e DS |
567 | if (!ospf) |
568 | return CMD_SUCCESS; | |
569 | ||
570 | if (ospf->instance) | |
571 | { | |
572 | vty_out (vty, "The network command is not supported in multi-instance ospf%s", | |
573 | VTY_NEWLINE); | |
574 | return CMD_WARNING; | |
575 | } | |
576 | ||
718e3744 | 577 | /* Get network prefix and Area ID. */ |
578 | VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]); | |
579 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]); | |
580 | ||
581 | ret = ospf_network_unset (ospf, &p, area_id); | |
582 | if (ret == 0) | |
583 | { | |
584 | vty_out (vty, "Can't find specified network area configuration.%s", | |
585 | VTY_NEWLINE); | |
586 | return CMD_WARNING; | |
587 | } | |
588 | ||
589 | return CMD_SUCCESS; | |
590 | } | |
591 | ||
6b0655a2 | 592 | |
a2c62831 | 593 | DEFUN (ospf_area_range, |
594 | ospf_area_range_cmd, | |
718e3744 | 595 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M", |
596 | "OSPF area parameters\n" | |
597 | "OSPF area ID in IP address format\n" | |
598 | "OSPF area ID as a decimal value\n" | |
599 | "Summarize routes matching address/mask (border routers only)\n" | |
600 | "Area range prefix\n") | |
601 | { | |
602 | struct ospf *ospf = vty->index; | |
603 | struct prefix_ipv4 p; | |
604 | struct in_addr area_id; | |
605 | int format; | |
606 | u_int32_t cost; | |
607 | ||
7c8ff89e DS |
608 | if (!ospf) |
609 | return CMD_SUCCESS; | |
610 | ||
718e3744 | 611 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
612 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); | |
613 | ||
614 | ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE); | |
615 | if (argc > 2) | |
616 | { | |
4dadc291 | 617 | VTY_GET_INTEGER ("range cost", cost, argv[2]); |
718e3744 | 618 | ospf_area_range_cost_set (ospf, area_id, &p, cost); |
619 | } | |
620 | ||
621 | return CMD_SUCCESS; | |
622 | } | |
623 | ||
a2c62831 | 624 | ALIAS (ospf_area_range, |
625 | ospf_area_range_advertise_cmd, | |
718e3744 | 626 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise", |
627 | "OSPF area parameters\n" | |
628 | "OSPF area ID in IP address format\n" | |
629 | "OSPF area ID as a decimal value\n" | |
630 | "OSPF area range for route advertise (default)\n" | |
631 | "Area range prefix\n" | |
632 | "Advertise this range (default)\n") | |
633 | ||
a2c62831 | 634 | ALIAS (ospf_area_range, |
635 | ospf_area_range_cost_cmd, | |
718e3744 | 636 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>", |
637 | "OSPF area parameters\n" | |
638 | "OSPF area ID in IP address format\n" | |
639 | "OSPF area ID as a decimal value\n" | |
640 | "Summarize routes matching address/mask (border routers only)\n" | |
641 | "Area range prefix\n" | |
642 | "User specified metric for this range\n" | |
643 | "Advertised metric for this range\n") | |
644 | ||
a2c62831 | 645 | ALIAS (ospf_area_range, |
646 | ospf_area_range_advertise_cost_cmd, | |
718e3744 | 647 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>", |
648 | "OSPF area parameters\n" | |
649 | "OSPF area ID in IP address format\n" | |
650 | "OSPF area ID as a decimal value\n" | |
651 | "Summarize routes matching address/mask (border routers only)\n" | |
652 | "Area range prefix\n" | |
653 | "Advertise this range (default)\n" | |
654 | "User specified metric for this range\n" | |
655 | "Advertised metric for this range\n") | |
656 | ||
a2c62831 | 657 | DEFUN (ospf_area_range_not_advertise, |
658 | ospf_area_range_not_advertise_cmd, | |
718e3744 | 659 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise", |
660 | "OSPF area parameters\n" | |
661 | "OSPF area ID in IP address format\n" | |
662 | "OSPF area ID as a decimal value\n" | |
663 | "Summarize routes matching address/mask (border routers only)\n" | |
664 | "Area range prefix\n" | |
665 | "DoNotAdvertise this range\n") | |
666 | { | |
667 | struct ospf *ospf = vty->index; | |
668 | struct prefix_ipv4 p; | |
669 | struct in_addr area_id; | |
670 | int format; | |
671 | ||
7c8ff89e DS |
672 | if (!ospf) |
673 | return CMD_SUCCESS; | |
674 | ||
718e3744 | 675 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
676 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); | |
677 | ||
678 | ospf_area_range_set (ospf, area_id, &p, 0); | |
679 | ||
680 | return CMD_SUCCESS; | |
681 | } | |
682 | ||
a2c62831 | 683 | DEFUN (no_ospf_area_range, |
684 | no_ospf_area_range_cmd, | |
718e3744 | 685 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M", |
686 | NO_STR | |
687 | "OSPF area parameters\n" | |
688 | "OSPF area ID in IP address format\n" | |
689 | "OSPF area ID as a decimal value\n" | |
690 | "Summarize routes matching address/mask (border routers only)\n" | |
691 | "Area range prefix\n") | |
692 | { | |
693 | struct ospf *ospf = vty->index; | |
694 | struct prefix_ipv4 p; | |
695 | struct in_addr area_id; | |
696 | int format; | |
697 | ||
7c8ff89e DS |
698 | if (!ospf) |
699 | return CMD_SUCCESS; | |
700 | ||
718e3744 | 701 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
702 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); | |
703 | ||
704 | ospf_area_range_unset (ospf, area_id, &p); | |
705 | ||
706 | return CMD_SUCCESS; | |
707 | } | |
708 | ||
a2c62831 | 709 | ALIAS (no_ospf_area_range, |
710 | no_ospf_area_range_advertise_cmd, | |
718e3744 | 711 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)", |
712 | NO_STR | |
713 | "OSPF area parameters\n" | |
714 | "OSPF area ID in IP address format\n" | |
715 | "OSPF area ID as a decimal value\n" | |
716 | "Summarize routes matching address/mask (border routers only)\n" | |
717 | "Area range prefix\n" | |
718 | "Advertise this range (default)\n" | |
719 | "DoNotAdvertise this range\n") | |
720 | ||
a2c62831 | 721 | ALIAS (no_ospf_area_range, |
722 | no_ospf_area_range_cost_cmd, | |
718e3744 | 723 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>", |
724 | NO_STR | |
725 | "OSPF area parameters\n" | |
726 | "OSPF area ID in IP address format\n" | |
727 | "OSPF area ID as a decimal value\n" | |
728 | "Summarize routes matching address/mask (border routers only)\n" | |
729 | "Area range prefix\n" | |
730 | "User specified metric for this range\n" | |
731 | "Advertised metric for this range\n") | |
732 | ||
a2c62831 | 733 | ALIAS (no_ospf_area_range, |
734 | no_ospf_area_range_advertise_cost_cmd, | |
718e3744 | 735 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>", |
736 | NO_STR | |
737 | "OSPF area parameters\n" | |
738 | "OSPF area ID in IP address format\n" | |
739 | "OSPF area ID as a decimal value\n" | |
740 | "Summarize routes matching address/mask (border routers only)\n" | |
741 | "Area range prefix\n" | |
742 | "Advertise this range (default)\n" | |
743 | "User specified metric for this range\n" | |
744 | "Advertised metric for this range\n") | |
6b0655a2 | 745 | |
a2c62831 | 746 | DEFUN (ospf_area_range_substitute, |
747 | ospf_area_range_substitute_cmd, | |
718e3744 | 748 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M", |
749 | "OSPF area parameters\n" | |
750 | "OSPF area ID in IP address format\n" | |
751 | "OSPF area ID as a decimal value\n" | |
752 | "Summarize routes matching address/mask (border routers only)\n" | |
753 | "Area range prefix\n" | |
754 | "Announce area range as another prefix\n" | |
755 | "Network prefix to be announced instead of range\n") | |
756 | { | |
757 | struct ospf *ospf = vty->index; | |
758 | struct prefix_ipv4 p, s; | |
759 | struct in_addr area_id; | |
760 | int format; | |
761 | ||
7c8ff89e DS |
762 | if (!ospf) |
763 | return CMD_SUCCESS; | |
764 | ||
718e3744 | 765 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
766 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); | |
767 | VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]); | |
768 | ||
769 | ospf_area_range_substitute_set (ospf, area_id, &p, &s); | |
770 | ||
771 | return CMD_SUCCESS; | |
772 | } | |
773 | ||
a2c62831 | 774 | DEFUN (no_ospf_area_range_substitute, |
775 | no_ospf_area_range_substitute_cmd, | |
718e3744 | 776 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M", |
777 | NO_STR | |
778 | "OSPF area parameters\n" | |
779 | "OSPF area ID in IP address format\n" | |
780 | "OSPF area ID as a decimal value\n" | |
781 | "Summarize routes matching address/mask (border routers only)\n" | |
782 | "Area range prefix\n" | |
783 | "Announce area range as another prefix\n" | |
784 | "Network prefix to be announced instead of range\n") | |
785 | { | |
786 | struct ospf *ospf = vty->index; | |
787 | struct prefix_ipv4 p, s; | |
788 | struct in_addr area_id; | |
789 | int format; | |
790 | ||
7c8ff89e DS |
791 | if (!ospf) |
792 | return CMD_SUCCESS; | |
793 | ||
718e3744 | 794 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
795 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); | |
796 | VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]); | |
797 | ||
798 | ospf_area_range_substitute_unset (ospf, area_id, &p); | |
799 | ||
800 | return CMD_SUCCESS; | |
801 | } | |
802 | ||
6b0655a2 | 803 | |
718e3744 | 804 | /* Command Handler Logic in VLink stuff is delicate!! |
805 | ||
806 | ALTER AT YOUR OWN RISK!!!! | |
807 | ||
808 | Various dummy values are used to represent 'NoChange' state for | |
809 | VLink configuration NOT being changed by a VLink command, and | |
810 | special syntax is used within the command strings so that the | |
811 | typed in command verbs can be seen in the configuration command | |
812 | bacckend handler. This is to drastically reduce the verbeage | |
813 | required to coe up with a reasonably compatible Cisco VLink command | |
814 | ||
815 | - Matthew Grant <grantma@anathoth.gen.nz> | |
816 | Wed, 21 Feb 2001 15:13:52 +1300 | |
817 | */ | |
818 | ||
819 | ||
820 | /* Configuration data for virtual links | |
821 | */ | |
822 | struct ospf_vl_config_data { | |
823 | struct vty *vty; /* vty stuff */ | |
824 | struct in_addr area_id; /* area ID from command line */ | |
825 | int format; /* command line area ID format */ | |
826 | struct in_addr vl_peer; /* command line vl_peer */ | |
827 | int auth_type; /* Authehntication type, if given */ | |
828 | char *auth_key; /* simple password if present */ | |
829 | int crypto_key_id; /* Cryptographic key ID */ | |
830 | char *md5_key; /* MD5 authentication key */ | |
831 | int hello_interval; /* Obvious what these are... */ | |
832 | int retransmit_interval; | |
833 | int transmit_delay; | |
834 | int dead_interval; | |
835 | }; | |
836 | ||
4dadc291 | 837 | static void |
718e3744 | 838 | ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config, |
839 | struct vty *vty) | |
840 | { | |
841 | memset (vl_config, 0, sizeof (struct ospf_vl_config_data)); | |
842 | vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN; | |
843 | vl_config->vty = vty; | |
844 | } | |
845 | ||
4dadc291 | 846 | static struct ospf_vl_data * |
68980084 | 847 | ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config) |
718e3744 | 848 | { |
849 | struct ospf_area *area; | |
850 | struct ospf_vl_data *vl_data; | |
851 | struct vty *vty; | |
852 | struct in_addr area_id; | |
853 | ||
854 | vty = vl_config->vty; | |
855 | area_id = vl_config->area_id; | |
856 | ||
857 | if (area_id.s_addr == OSPF_AREA_BACKBONE) | |
858 | { | |
859 | vty_out (vty, | |
860 | "Configuring VLs over the backbone is not allowed%s", | |
861 | VTY_NEWLINE); | |
862 | return NULL; | |
863 | } | |
68980084 | 864 | area = ospf_area_get (ospf, area_id, vl_config->format); |
718e3744 | 865 | |
866 | if (area->external_routing != OSPF_AREA_DEFAULT) | |
867 | { | |
868 | if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS) | |
869 | vty_out (vty, "Area %s is %s%s", | |
870 | inet_ntoa (area_id), | |
718e3744 | 871 | area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", |
718e3744 | 872 | VTY_NEWLINE); |
873 | else | |
874 | vty_out (vty, "Area %ld is %s%s", | |
875 | (u_long)ntohl (area_id.s_addr), | |
718e3744 | 876 | area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", |
718e3744 | 877 | VTY_NEWLINE); |
878 | return NULL; | |
879 | } | |
880 | ||
9c27ef9b | 881 | if ((vl_data = ospf_vl_lookup (ospf, area, vl_config->vl_peer)) == NULL) |
718e3744 | 882 | { |
883 | vl_data = ospf_vl_data_new (area, vl_config->vl_peer); | |
884 | if (vl_data->vl_oi == NULL) | |
885 | { | |
68980084 | 886 | vl_data->vl_oi = ospf_vl_new (ospf, vl_data); |
887 | ospf_vl_add (ospf, vl_data); | |
888 | ospf_spf_calculate_schedule (ospf); | |
718e3744 | 889 | } |
890 | } | |
891 | return vl_data; | |
892 | } | |
893 | ||
894 | ||
4dadc291 | 895 | static int |
718e3744 | 896 | ospf_vl_set_security (struct ospf_vl_data *vl_data, |
897 | struct ospf_vl_config_data *vl_config) | |
898 | { | |
899 | struct crypt_key *ck; | |
900 | struct vty *vty; | |
901 | struct interface *ifp = vl_data->vl_oi->ifp; | |
902 | ||
903 | vty = vl_config->vty; | |
904 | ||
905 | if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN) | |
906 | { | |
907 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type); | |
908 | IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type; | |
909 | } | |
910 | ||
911 | if (vl_config->auth_key) | |
912 | { | |
913 | memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1); | |
c9e52be3 | 914 | strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key, |
718e3744 | 915 | OSPF_AUTH_SIMPLE_SIZE); |
916 | } | |
917 | else if (vl_config->md5_key) | |
918 | { | |
919 | if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id) | |
920 | != NULL) | |
921 | { | |
922 | vty_out (vty, "OSPF: Key %d already exists%s", | |
923 | vl_config->crypto_key_id, VTY_NEWLINE); | |
924 | return CMD_WARNING; | |
925 | } | |
926 | ck = ospf_crypt_key_new (); | |
927 | ck->key_id = vl_config->crypto_key_id; | |
928 | memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); | |
c9e52be3 | 929 | strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE); |
718e3744 | 930 | |
931 | ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck); | |
932 | } | |
933 | else if (vl_config->crypto_key_id != 0) | |
934 | { | |
935 | /* Delete a key */ | |
936 | ||
937 | if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, | |
938 | vl_config->crypto_key_id) == NULL) | |
939 | { | |
940 | vty_out (vty, "OSPF: Key %d does not exist%s", | |
941 | vl_config->crypto_key_id, VTY_NEWLINE); | |
942 | return CMD_WARNING; | |
943 | } | |
944 | ||
945 | ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id); | |
946 | ||
947 | } | |
948 | ||
949 | return CMD_SUCCESS; | |
950 | } | |
951 | ||
4dadc291 | 952 | static int |
718e3744 | 953 | ospf_vl_set_timers (struct ospf_vl_data *vl_data, |
954 | struct ospf_vl_config_data *vl_config) | |
955 | { | |
956 | struct interface *ifp = ifp = vl_data->vl_oi->ifp; | |
957 | /* Virtual Link data initialised to defaults, so only set | |
958 | if a value given */ | |
959 | if (vl_config->hello_interval) | |
960 | { | |
961 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello); | |
962 | IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval; | |
963 | } | |
964 | ||
965 | if (vl_config->dead_interval) | |
966 | { | |
967 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait); | |
968 | IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval; | |
969 | } | |
970 | ||
971 | if (vl_config->retransmit_interval) | |
972 | { | |
973 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval); | |
974 | IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval; | |
975 | } | |
976 | ||
977 | if (vl_config->transmit_delay) | |
978 | { | |
979 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay); | |
980 | IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay; | |
981 | } | |
982 | ||
983 | return CMD_SUCCESS; | |
984 | } | |
985 | ||
986 | ||
987 | ||
988 | /* The business end of all of the above */ | |
4dadc291 | 989 | static int |
68980084 | 990 | ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config) |
718e3744 | 991 | { |
992 | struct ospf_vl_data *vl_data; | |
993 | int ret; | |
994 | ||
68980084 | 995 | vl_data = ospf_find_vl_data (ospf, vl_config); |
718e3744 | 996 | if (!vl_data) |
997 | return CMD_WARNING; | |
998 | ||
999 | /* Process this one first as it can have a fatal result, which can | |
1000 | only logically occur if the virtual link exists already | |
1001 | Thus a command error does not result in a change to the | |
1002 | running configuration such as unexpectedly altered timer | |
1003 | values etc.*/ | |
1004 | ret = ospf_vl_set_security (vl_data, vl_config); | |
1005 | if (ret != CMD_SUCCESS) | |
1006 | return ret; | |
1007 | ||
1008 | /* Set any time based parameters, these area already range checked */ | |
1009 | ||
1010 | ret = ospf_vl_set_timers (vl_data, vl_config); | |
1011 | if (ret != CMD_SUCCESS) | |
1012 | return ret; | |
1013 | ||
1014 | return CMD_SUCCESS; | |
1015 | ||
1016 | } | |
1017 | ||
1018 | /* This stuff exists to make specifying all the alias commands A LOT simpler | |
1019 | */ | |
1020 | #define VLINK_HELPSTR_IPADDR \ | |
1021 | "OSPF area parameters\n" \ | |
1022 | "OSPF area ID in IP address format\n" \ | |
1023 | "OSPF area ID as a decimal value\n" \ | |
1024 | "Configure a virtual link\n" \ | |
1025 | "Router ID of the remote ABR\n" | |
1026 | ||
1027 | #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \ | |
1028 | "Enable authentication on this virtual link\n" \ | |
1029 | "dummy string \n" | |
1030 | ||
1031 | #define VLINK_HELPSTR_AUTHTYPE_ALL \ | |
1032 | VLINK_HELPSTR_AUTHTYPE_SIMPLE \ | |
1033 | "Use null authentication\n" \ | |
1034 | "Use message-digest authentication\n" | |
1035 | ||
1036 | #define VLINK_HELPSTR_TIME_PARAM_NOSECS \ | |
1037 | "Time between HELLO packets\n" \ | |
1038 | "Time between retransmitting lost link state advertisements\n" \ | |
1039 | "Link state transmit delay\n" \ | |
1040 | "Interval after which a neighbor is declared dead\n" | |
1041 | ||
1042 | #define VLINK_HELPSTR_TIME_PARAM \ | |
1043 | VLINK_HELPSTR_TIME_PARAM_NOSECS \ | |
1044 | "Seconds\n" | |
1045 | ||
1046 | #define VLINK_HELPSTR_AUTH_SIMPLE \ | |
1047 | "Authentication password (key)\n" \ | |
1048 | "The OSPF password (key)" | |
1049 | ||
1050 | #define VLINK_HELPSTR_AUTH_MD5 \ | |
1051 | "Message digest authentication password (key)\n" \ | |
1052 | "dummy string \n" \ | |
1053 | "Key ID\n" \ | |
1054 | "Use MD5 algorithm\n" \ | |
1055 | "The OSPF password (key)" | |
1056 | ||
a2c62831 | 1057 | DEFUN (ospf_area_vlink, |
1058 | ospf_area_vlink_cmd, | |
718e3744 | 1059 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D", |
1060 | VLINK_HELPSTR_IPADDR) | |
1061 | { | |
68980084 | 1062 | struct ospf *ospf = vty->index; |
718e3744 | 1063 | struct ospf_vl_config_data vl_config; |
1064 | char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; | |
1065 | char md5_key[OSPF_AUTH_MD5_SIZE+1]; | |
1066 | int i; | |
1067 | int ret; | |
1068 | ||
7c8ff89e DS |
1069 | if (!ospf) |
1070 | return CMD_SUCCESS; | |
1071 | ||
718e3744 | 1072 | ospf_vl_config_data_init(&vl_config, vty); |
1073 | ||
1074 | /* Read off first 2 parameters and check them */ | |
1075 | ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format); | |
1076 | if (ret < 0) | |
1077 | { | |
1078 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); | |
1079 | return CMD_WARNING; | |
1080 | } | |
1081 | ||
1082 | ret = inet_aton (argv[1], &vl_config.vl_peer); | |
1083 | if (! ret) | |
1084 | { | |
1085 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", | |
1086 | VTY_NEWLINE); | |
1087 | return CMD_WARNING; | |
1088 | } | |
1089 | ||
1090 | if (argc <=2) | |
1091 | { | |
1092 | /* Thats all folks! - BUGS B. strikes again!!!*/ | |
1093 | ||
68980084 | 1094 | return ospf_vl_set (ospf, &vl_config); |
718e3744 | 1095 | } |
1096 | ||
1097 | /* Deal with other parameters */ | |
1098 | for (i=2; i < argc; i++) | |
1099 | { | |
1100 | ||
1101 | /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */ | |
1102 | ||
1103 | switch (argv[i][0]) | |
1104 | { | |
1105 | ||
1106 | case 'a': | |
1107 | if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0) | |
1108 | { | |
1109 | /* authentication-key - this option can occur anywhere on | |
1110 | command line. At start of command line | |
1111 | must check for authentication option. */ | |
1112 | memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); | |
1113 | strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE); | |
1114 | vl_config.auth_key = auth_key; | |
1115 | i++; | |
1116 | } | |
1117 | else if (strncmp (argv[i], "authentication", 14) == 0) | |
1118 | { | |
1119 | /* authentication - this option can only occur at start | |
1120 | of command line */ | |
1121 | vl_config.auth_type = OSPF_AUTH_SIMPLE; | |
1122 | if ((i+1) < argc) | |
1123 | { | |
1124 | if (strncmp (argv[i+1], "n", 1) == 0) | |
1125 | { | |
1126 | /* "authentication null" */ | |
1127 | vl_config.auth_type = OSPF_AUTH_NULL; | |
1128 | i++; | |
1129 | } | |
1130 | else if (strncmp (argv[i+1], "m", 1) == 0 | |
1131 | && strcmp (argv[i+1], "message-digest-") != 0) | |
1132 | { | |
1133 | /* "authentication message-digest" */ | |
1134 | vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC; | |
1135 | i++; | |
1136 | } | |
1137 | } | |
1138 | } | |
1139 | break; | |
1140 | ||
1141 | case 'm': | |
1142 | /* message-digest-key */ | |
1143 | i++; | |
1144 | vl_config.crypto_key_id = strtol (argv[i], NULL, 10); | |
1145 | if (vl_config.crypto_key_id < 0) | |
1146 | return CMD_WARNING; | |
1147 | i++; | |
1148 | memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1); | |
1149 | strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE); | |
1150 | vl_config.md5_key = md5_key; | |
1151 | break; | |
1152 | ||
1153 | case 'h': | |
1154 | /* Hello interval */ | |
1155 | i++; | |
1156 | vl_config.hello_interval = strtol (argv[i], NULL, 10); | |
1157 | if (vl_config.hello_interval < 0) | |
1158 | return CMD_WARNING; | |
1159 | break; | |
1160 | ||
1161 | case 'r': | |
1162 | /* Retransmit Interval */ | |
1163 | i++; | |
1164 | vl_config.retransmit_interval = strtol (argv[i], NULL, 10); | |
1165 | if (vl_config.retransmit_interval < 0) | |
1166 | return CMD_WARNING; | |
1167 | break; | |
1168 | ||
1169 | case 't': | |
1170 | /* Transmit Delay */ | |
1171 | i++; | |
1172 | vl_config.transmit_delay = strtol (argv[i], NULL, 10); | |
1173 | if (vl_config.transmit_delay < 0) | |
1174 | return CMD_WARNING; | |
1175 | break; | |
1176 | ||
1177 | case 'd': | |
1178 | /* Dead Interval */ | |
1179 | i++; | |
1180 | vl_config.dead_interval = strtol (argv[i], NULL, 10); | |
1181 | if (vl_config.dead_interval < 0) | |
1182 | return CMD_WARNING; | |
1183 | break; | |
1184 | } | |
1185 | } | |
1186 | ||
1187 | ||
1188 | /* Action configuration */ | |
1189 | ||
68980084 | 1190 | return ospf_vl_set (ospf, &vl_config); |
718e3744 | 1191 | |
1192 | } | |
1193 | ||
a2c62831 | 1194 | DEFUN (no_ospf_area_vlink, |
1195 | no_ospf_area_vlink_cmd, | |
718e3744 | 1196 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D", |
1197 | NO_STR | |
1198 | VLINK_HELPSTR_IPADDR) | |
1199 | { | |
68980084 | 1200 | struct ospf *ospf = vty->index; |
718e3744 | 1201 | struct ospf_area *area; |
1202 | struct ospf_vl_config_data vl_config; | |
1203 | struct ospf_vl_data *vl_data = NULL; | |
1204 | char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; | |
1205 | int i; | |
1206 | int ret, format; | |
1207 | ||
7c8ff89e DS |
1208 | if (!ospf) |
1209 | return CMD_SUCCESS; | |
1210 | ||
718e3744 | 1211 | ospf_vl_config_data_init(&vl_config, vty); |
1212 | ||
1213 | ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format); | |
1214 | if (ret < 0) | |
1215 | { | |
1216 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); | |
1217 | return CMD_WARNING; | |
1218 | } | |
1219 | ||
68980084 | 1220 | area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id); |
718e3744 | 1221 | if (!area) |
1222 | { | |
1223 | vty_out (vty, "Area does not exist%s", VTY_NEWLINE); | |
1224 | return CMD_WARNING; | |
1225 | } | |
1226 | ||
1227 | ret = inet_aton (argv[1], &vl_config.vl_peer); | |
1228 | if (! ret) | |
1229 | { | |
1230 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", | |
1231 | VTY_NEWLINE); | |
1232 | return CMD_WARNING; | |
1233 | } | |
1234 | ||
1235 | if (argc <=2) | |
1236 | { | |
1237 | /* Basic VLink no command */ | |
1238 | /* Thats all folks! - BUGS B. strikes again!!!*/ | |
9c27ef9b | 1239 | if ((vl_data = ospf_vl_lookup (ospf, area, vl_config.vl_peer))) |
68980084 | 1240 | ospf_vl_delete (ospf, vl_data); |
718e3744 | 1241 | |
68980084 | 1242 | ospf_area_check_free (ospf, vl_config.area_id); |
718e3744 | 1243 | |
1244 | return CMD_SUCCESS; | |
1245 | } | |
1246 | ||
1247 | /* If we are down here, we are reseting parameters */ | |
1248 | ||
1249 | /* Deal with other parameters */ | |
1250 | for (i=2; i < argc; i++) | |
1251 | { | |
718e3744 | 1252 | /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */ |
1253 | ||
1254 | switch (argv[i][0]) | |
1255 | { | |
1256 | ||
1257 | case 'a': | |
1258 | if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0) | |
1259 | { | |
1260 | /* authentication-key - this option can occur anywhere on | |
1261 | command line. At start of command line | |
1262 | must check for authentication option. */ | |
1263 | memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); | |
1264 | vl_config.auth_key = auth_key; | |
1265 | } | |
1266 | else if (strncmp (argv[i], "authentication", 14) == 0) | |
1267 | { | |
1268 | /* authentication - this option can only occur at start | |
1269 | of command line */ | |
1270 | vl_config.auth_type = OSPF_AUTH_NOTSET; | |
1271 | } | |
1272 | break; | |
1273 | ||
1274 | case 'm': | |
1275 | /* message-digest-key */ | |
1276 | /* Delete one key */ | |
1277 | i++; | |
1278 | vl_config.crypto_key_id = strtol (argv[i], NULL, 10); | |
1279 | if (vl_config.crypto_key_id < 0) | |
1280 | return CMD_WARNING; | |
1281 | vl_config.md5_key = NULL; | |
1282 | break; | |
1283 | ||
1284 | case 'h': | |
1285 | /* Hello interval */ | |
1286 | vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT; | |
1287 | break; | |
1288 | ||
1289 | case 'r': | |
1290 | /* Retransmit Interval */ | |
1291 | vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; | |
1292 | break; | |
1293 | ||
1294 | case 't': | |
1295 | /* Transmit Delay */ | |
1296 | vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; | |
1297 | break; | |
1298 | ||
1299 | case 'd': | |
1300 | /* Dead Interval */ | |
1301 | i++; | |
1302 | vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; | |
1303 | break; | |
1304 | } | |
1305 | } | |
1306 | ||
1307 | ||
1308 | /* Action configuration */ | |
1309 | ||
68980084 | 1310 | return ospf_vl_set (ospf, &vl_config); |
718e3744 | 1311 | } |
1312 | ||
a2c62831 | 1313 | ALIAS (ospf_area_vlink, |
1314 | ospf_area_vlink_param1_cmd, | |
718e3744 | 1315 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1316 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", | |
1317 | VLINK_HELPSTR_IPADDR | |
1318 | VLINK_HELPSTR_TIME_PARAM) | |
1319 | ||
a2c62831 | 1320 | ALIAS (no_ospf_area_vlink, |
1321 | no_ospf_area_vlink_param1_cmd, | |
718e3744 | 1322 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1323 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", | |
1324 | NO_STR | |
1325 | VLINK_HELPSTR_IPADDR | |
1326 | VLINK_HELPSTR_TIME_PARAM) | |
1327 | ||
a2c62831 | 1328 | ALIAS (ospf_area_vlink, |
1329 | ospf_area_vlink_param2_cmd, | |
718e3744 | 1330 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1331 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1332 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", | |
1333 | VLINK_HELPSTR_IPADDR | |
1334 | VLINK_HELPSTR_TIME_PARAM | |
1335 | VLINK_HELPSTR_TIME_PARAM) | |
1336 | ||
a2c62831 | 1337 | ALIAS (no_ospf_area_vlink, |
1338 | no_ospf_area_vlink_param2_cmd, | |
718e3744 | 1339 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1340 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " | |
1341 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", | |
1342 | NO_STR | |
1343 | VLINK_HELPSTR_IPADDR | |
1344 | VLINK_HELPSTR_TIME_PARAM | |
1345 | VLINK_HELPSTR_TIME_PARAM) | |
1346 | ||
a2c62831 | 1347 | ALIAS (ospf_area_vlink, |
1348 | ospf_area_vlink_param3_cmd, | |
718e3744 | 1349 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1350 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1351 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1352 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", | |
1353 | VLINK_HELPSTR_IPADDR | |
1354 | VLINK_HELPSTR_TIME_PARAM | |
1355 | VLINK_HELPSTR_TIME_PARAM | |
1356 | VLINK_HELPSTR_TIME_PARAM) | |
1357 | ||
a2c62831 | 1358 | ALIAS (no_ospf_area_vlink, |
1359 | no_ospf_area_vlink_param3_cmd, | |
718e3744 | 1360 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1361 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " | |
1362 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " | |
1363 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", | |
1364 | NO_STR | |
1365 | VLINK_HELPSTR_IPADDR | |
1366 | VLINK_HELPSTR_TIME_PARAM | |
1367 | VLINK_HELPSTR_TIME_PARAM | |
1368 | VLINK_HELPSTR_TIME_PARAM) | |
1369 | ||
a2c62831 | 1370 | ALIAS (ospf_area_vlink, |
1371 | ospf_area_vlink_param4_cmd, | |
718e3744 | 1372 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1373 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1374 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1375 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1376 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", | |
1377 | VLINK_HELPSTR_IPADDR | |
1378 | VLINK_HELPSTR_TIME_PARAM | |
1379 | VLINK_HELPSTR_TIME_PARAM | |
1380 | VLINK_HELPSTR_TIME_PARAM | |
1381 | VLINK_HELPSTR_TIME_PARAM) | |
1382 | ||
a2c62831 | 1383 | ALIAS (no_ospf_area_vlink, |
1384 | no_ospf_area_vlink_param4_cmd, | |
718e3744 | 1385 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1386 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " | |
1387 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " | |
1388 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " | |
1389 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", | |
1390 | NO_STR | |
1391 | VLINK_HELPSTR_IPADDR | |
1392 | VLINK_HELPSTR_TIME_PARAM | |
1393 | VLINK_HELPSTR_TIME_PARAM | |
1394 | VLINK_HELPSTR_TIME_PARAM | |
1395 | VLINK_HELPSTR_TIME_PARAM) | |
1396 | ||
a2c62831 | 1397 | ALIAS (ospf_area_vlink, |
1398 | ospf_area_vlink_authtype_args_cmd, | |
718e3744 | 1399 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1400 | "(authentication|) (message-digest|null)", | |
1401 | VLINK_HELPSTR_IPADDR | |
1402 | VLINK_HELPSTR_AUTHTYPE_ALL) | |
1403 | ||
a2c62831 | 1404 | ALIAS (ospf_area_vlink, |
1405 | ospf_area_vlink_authtype_cmd, | |
718e3744 | 1406 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1407 | "(authentication|)", | |
1408 | VLINK_HELPSTR_IPADDR | |
1409 | VLINK_HELPSTR_AUTHTYPE_SIMPLE) | |
1410 | ||
a2c62831 | 1411 | ALIAS (no_ospf_area_vlink, |
1412 | no_ospf_area_vlink_authtype_cmd, | |
718e3744 | 1413 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1414 | "(authentication|)", | |
1415 | NO_STR | |
1416 | VLINK_HELPSTR_IPADDR | |
1417 | VLINK_HELPSTR_AUTHTYPE_SIMPLE) | |
1418 | ||
a2c62831 | 1419 | ALIAS (ospf_area_vlink, |
1420 | ospf_area_vlink_md5_cmd, | |
718e3744 | 1421 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1422 | "(message-digest-key|) <1-255> md5 KEY", | |
1423 | VLINK_HELPSTR_IPADDR | |
1424 | VLINK_HELPSTR_AUTH_MD5) | |
1425 | ||
a2c62831 | 1426 | ALIAS (no_ospf_area_vlink, |
1427 | no_ospf_area_vlink_md5_cmd, | |
718e3744 | 1428 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1429 | "(message-digest-key|) <1-255>", | |
1430 | NO_STR | |
1431 | VLINK_HELPSTR_IPADDR | |
1432 | VLINK_HELPSTR_AUTH_MD5) | |
1433 | ||
a2c62831 | 1434 | ALIAS (ospf_area_vlink, |
1435 | ospf_area_vlink_authkey_cmd, | |
718e3744 | 1436 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1437 | "(authentication-key|) AUTH_KEY", | |
1438 | VLINK_HELPSTR_IPADDR | |
1439 | VLINK_HELPSTR_AUTH_SIMPLE) | |
1440 | ||
a2c62831 | 1441 | ALIAS (no_ospf_area_vlink, |
1442 | no_ospf_area_vlink_authkey_cmd, | |
718e3744 | 1443 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1444 | "(authentication-key|)", | |
1445 | NO_STR | |
1446 | VLINK_HELPSTR_IPADDR | |
1447 | VLINK_HELPSTR_AUTH_SIMPLE) | |
1448 | ||
a2c62831 | 1449 | ALIAS (ospf_area_vlink, |
1450 | ospf_area_vlink_authtype_args_authkey_cmd, | |
718e3744 | 1451 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1452 | "(authentication|) (message-digest|null) " | |
1453 | "(authentication-key|) AUTH_KEY", | |
1454 | VLINK_HELPSTR_IPADDR | |
1455 | VLINK_HELPSTR_AUTHTYPE_ALL | |
1456 | VLINK_HELPSTR_AUTH_SIMPLE) | |
1457 | ||
a2c62831 | 1458 | ALIAS (ospf_area_vlink, |
1459 | ospf_area_vlink_authtype_authkey_cmd, | |
718e3744 | 1460 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1461 | "(authentication|) " | |
1462 | "(authentication-key|) AUTH_KEY", | |
1463 | VLINK_HELPSTR_IPADDR | |
1464 | VLINK_HELPSTR_AUTHTYPE_SIMPLE | |
1465 | VLINK_HELPSTR_AUTH_SIMPLE) | |
1466 | ||
a2c62831 | 1467 | ALIAS (no_ospf_area_vlink, |
1468 | no_ospf_area_vlink_authtype_authkey_cmd, | |
718e3744 | 1469 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1470 | "(authentication|) " | |
1471 | "(authentication-key|)", | |
1472 | NO_STR | |
1473 | VLINK_HELPSTR_IPADDR | |
1474 | VLINK_HELPSTR_AUTHTYPE_SIMPLE | |
1475 | VLINK_HELPSTR_AUTH_SIMPLE) | |
1476 | ||
a2c62831 | 1477 | ALIAS (ospf_area_vlink, |
1478 | ospf_area_vlink_authtype_args_md5_cmd, | |
718e3744 | 1479 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1480 | "(authentication|) (message-digest|null) " | |
1481 | "(message-digest-key|) <1-255> md5 KEY", | |
1482 | VLINK_HELPSTR_IPADDR | |
1483 | VLINK_HELPSTR_AUTHTYPE_ALL | |
1484 | VLINK_HELPSTR_AUTH_MD5) | |
1485 | ||
a2c62831 | 1486 | ALIAS (ospf_area_vlink, |
1487 | ospf_area_vlink_authtype_md5_cmd, | |
718e3744 | 1488 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1489 | "(authentication|) " | |
1490 | "(message-digest-key|) <1-255> md5 KEY", | |
1491 | VLINK_HELPSTR_IPADDR | |
1492 | VLINK_HELPSTR_AUTHTYPE_SIMPLE | |
1493 | VLINK_HELPSTR_AUTH_MD5) | |
1494 | ||
a2c62831 | 1495 | ALIAS (no_ospf_area_vlink, |
1496 | no_ospf_area_vlink_authtype_md5_cmd, | |
718e3744 | 1497 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1498 | "(authentication|) " | |
1499 | "(message-digest-key|)", | |
1500 | NO_STR | |
1501 | VLINK_HELPSTR_IPADDR | |
1502 | VLINK_HELPSTR_AUTHTYPE_SIMPLE | |
1503 | VLINK_HELPSTR_AUTH_MD5) | |
1504 | ||
6b0655a2 | 1505 | |
a2c62831 | 1506 | DEFUN (ospf_area_shortcut, |
1507 | ospf_area_shortcut_cmd, | |
718e3744 | 1508 | "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)", |
1509 | "OSPF area parameters\n" | |
1510 | "OSPF area ID in IP address format\n" | |
1511 | "OSPF area ID as a decimal value\n" | |
1512 | "Configure the area's shortcutting mode\n" | |
1513 | "Set default shortcutting behavior\n" | |
1514 | "Enable shortcutting through the area\n" | |
1515 | "Disable shortcutting through the area\n") | |
1516 | { | |
68980084 | 1517 | struct ospf *ospf = vty->index; |
718e3744 | 1518 | struct ospf_area *area; |
1519 | struct in_addr area_id; | |
1520 | int mode; | |
1521 | int format; | |
1522 | ||
7c8ff89e DS |
1523 | if (!ospf) |
1524 | return CMD_SUCCESS; | |
1525 | ||
718e3744 | 1526 | VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]); |
1527 | ||
68980084 | 1528 | area = ospf_area_get (ospf, area_id, format); |
718e3744 | 1529 | |
1530 | if (strncmp (argv[1], "de", 2) == 0) | |
1531 | mode = OSPF_SHORTCUT_DEFAULT; | |
1532 | else if (strncmp (argv[1], "di", 2) == 0) | |
1533 | mode = OSPF_SHORTCUT_DISABLE; | |
1534 | else if (strncmp (argv[1], "e", 1) == 0) | |
1535 | mode = OSPF_SHORTCUT_ENABLE; | |
1536 | else | |
1537 | return CMD_WARNING; | |
1538 | ||
68980084 | 1539 | ospf_area_shortcut_set (ospf, area, mode); |
718e3744 | 1540 | |
68980084 | 1541 | if (ospf->abr_type != OSPF_ABR_SHORTCUT) |
718e3744 | 1542 | vty_out (vty, "Shortcut area setting will take effect " |
1543 | "only when the router is configured as Shortcut ABR%s", | |
1544 | VTY_NEWLINE); | |
1545 | ||
1546 | return CMD_SUCCESS; | |
1547 | } | |
1548 | ||
a2c62831 | 1549 | DEFUN (no_ospf_area_shortcut, |
1550 | no_ospf_area_shortcut_cmd, | |
718e3744 | 1551 | "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)", |
1552 | NO_STR | |
1553 | "OSPF area parameters\n" | |
1554 | "OSPF area ID in IP address format\n" | |
1555 | "OSPF area ID as a decimal value\n" | |
1556 | "Deconfigure the area's shortcutting mode\n" | |
1557 | "Deconfigure enabled shortcutting through the area\n" | |
1558 | "Deconfigure disabled shortcutting through the area\n") | |
1559 | { | |
68980084 | 1560 | struct ospf *ospf = vty->index; |
718e3744 | 1561 | struct ospf_area *area; |
1562 | struct in_addr area_id; | |
1563 | int format; | |
1564 | ||
7c8ff89e DS |
1565 | if (!ospf) |
1566 | return CMD_SUCCESS; | |
1567 | ||
718e3744 | 1568 | VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]); |
1569 | ||
68980084 | 1570 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 1571 | if (!area) |
1572 | return CMD_SUCCESS; | |
1573 | ||
68980084 | 1574 | ospf_area_shortcut_unset (ospf, area); |
718e3744 | 1575 | |
1576 | return CMD_SUCCESS; | |
1577 | } | |
1578 | ||
6b0655a2 | 1579 | |
a2c62831 | 1580 | DEFUN (ospf_area_stub, |
1581 | ospf_area_stub_cmd, | |
718e3744 | 1582 | "area (A.B.C.D|<0-4294967295>) stub", |
1583 | "OSPF area parameters\n" | |
1584 | "OSPF area ID in IP address format\n" | |
1585 | "OSPF area ID as a decimal value\n" | |
1586 | "Configure OSPF area as stub\n") | |
1587 | { | |
1588 | struct ospf *ospf = vty->index; | |
1589 | struct in_addr area_id; | |
1590 | int ret, format; | |
1591 | ||
7c8ff89e DS |
1592 | if (!ospf) |
1593 | return CMD_SUCCESS; | |
1594 | ||
718e3744 | 1595 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
1596 | ||
1597 | ret = ospf_area_stub_set (ospf, area_id); | |
1598 | if (ret == 0) | |
1599 | { | |
1600 | vty_out (vty, "First deconfigure all virtual link through this area%s", | |
1601 | VTY_NEWLINE); | |
1602 | return CMD_WARNING; | |
1603 | } | |
1604 | ||
1605 | ospf_area_no_summary_unset (ospf, area_id); | |
1606 | ||
1607 | return CMD_SUCCESS; | |
1608 | } | |
1609 | ||
a2c62831 | 1610 | DEFUN (ospf_area_stub_no_summary, |
1611 | ospf_area_stub_no_summary_cmd, | |
718e3744 | 1612 | "area (A.B.C.D|<0-4294967295>) stub no-summary", |
1613 | "OSPF stub parameters\n" | |
1614 | "OSPF area ID in IP address format\n" | |
1615 | "OSPF area ID as a decimal value\n" | |
1616 | "Configure OSPF area as stub\n" | |
1617 | "Do not inject inter-area routes into stub\n") | |
1618 | { | |
1619 | struct ospf *ospf = vty->index; | |
1620 | struct in_addr area_id; | |
1621 | int ret, format; | |
1622 | ||
7c8ff89e DS |
1623 | if (!ospf) |
1624 | return CMD_SUCCESS; | |
1625 | ||
718e3744 | 1626 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
1627 | ||
1628 | ret = ospf_area_stub_set (ospf, area_id); | |
1629 | if (ret == 0) | |
1630 | { | |
b0a053be | 1631 | vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s", |
718e3744 | 1632 | VTY_NEWLINE); |
1633 | return CMD_WARNING; | |
1634 | } | |
1635 | ||
1636 | ospf_area_no_summary_set (ospf, area_id); | |
1637 | ||
1638 | return CMD_SUCCESS; | |
1639 | } | |
1640 | ||
a2c62831 | 1641 | DEFUN (no_ospf_area_stub, |
1642 | no_ospf_area_stub_cmd, | |
718e3744 | 1643 | "no area (A.B.C.D|<0-4294967295>) stub", |
1644 | NO_STR | |
1645 | "OSPF area parameters\n" | |
1646 | "OSPF area ID in IP address format\n" | |
1647 | "OSPF area ID as a decimal value\n" | |
1648 | "Configure OSPF area as stub\n") | |
1649 | { | |
1650 | struct ospf *ospf = vty->index; | |
1651 | struct in_addr area_id; | |
1652 | int format; | |
1653 | ||
7c8ff89e DS |
1654 | if (!ospf) |
1655 | return CMD_SUCCESS; | |
1656 | ||
718e3744 | 1657 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
1658 | ||
1659 | ospf_area_stub_unset (ospf, area_id); | |
1660 | ospf_area_no_summary_unset (ospf, area_id); | |
1661 | ||
1662 | return CMD_SUCCESS; | |
1663 | } | |
1664 | ||
a2c62831 | 1665 | DEFUN (no_ospf_area_stub_no_summary, |
1666 | no_ospf_area_stub_no_summary_cmd, | |
718e3744 | 1667 | "no area (A.B.C.D|<0-4294967295>) stub no-summary", |
1668 | NO_STR | |
1669 | "OSPF area parameters\n" | |
1670 | "OSPF area ID in IP address format\n" | |
1671 | "OSPF area ID as a decimal value\n" | |
1672 | "Configure OSPF area as stub\n" | |
1673 | "Do not inject inter-area routes into area\n") | |
1674 | { | |
1675 | struct ospf *ospf = vty->index; | |
1676 | struct in_addr area_id; | |
1677 | int format; | |
1678 | ||
7c8ff89e DS |
1679 | if (!ospf) |
1680 | return CMD_SUCCESS; | |
1681 | ||
718e3744 | 1682 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
1683 | ospf_area_no_summary_unset (ospf, area_id); | |
1684 | ||
1685 | return CMD_SUCCESS; | |
1686 | } | |
1687 | ||
4dadc291 | 1688 | static int |
6c835671 | 1689 | ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[], |
1690 | int nosum) | |
718e3744 | 1691 | { |
1692 | struct ospf *ospf = vty->index; | |
1693 | struct in_addr area_id; | |
1694 | int ret, format; | |
1695 | ||
7c8ff89e DS |
1696 | if (!ospf) |
1697 | return CMD_SUCCESS; | |
1698 | ||
718e3744 | 1699 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
1700 | ||
1701 | ret = ospf_area_nssa_set (ospf, area_id); | |
1702 | if (ret == 0) | |
1703 | { | |
1704 | vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s", | |
1705 | VTY_NEWLINE); | |
1706 | return CMD_WARNING; | |
1707 | } | |
1708 | ||
1709 | if (argc > 1) | |
1710 | { | |
1711 | if (strncmp (argv[1], "translate-c", 11) == 0) | |
b0a053be | 1712 | ospf_area_nssa_translator_role_set (ospf, area_id, |
718e3744 | 1713 | OSPF_NSSA_ROLE_CANDIDATE); |
1714 | else if (strncmp (argv[1], "translate-n", 11) == 0) | |
b0a053be | 1715 | ospf_area_nssa_translator_role_set (ospf, area_id, |
718e3744 | 1716 | OSPF_NSSA_ROLE_NEVER); |
1717 | else if (strncmp (argv[1], "translate-a", 11) == 0) | |
b0a053be | 1718 | ospf_area_nssa_translator_role_set (ospf, area_id, |
718e3744 | 1719 | OSPF_NSSA_ROLE_ALWAYS); |
1720 | } | |
b0a053be | 1721 | else |
1722 | { | |
1723 | ospf_area_nssa_translator_role_set (ospf, area_id, | |
1724 | OSPF_NSSA_ROLE_CANDIDATE); | |
1725 | } | |
718e3744 | 1726 | |
b0a053be | 1727 | if (nosum) |
718e3744 | 1728 | ospf_area_no_summary_set (ospf, area_id); |
b0a053be | 1729 | else |
1730 | ospf_area_no_summary_unset (ospf, area_id); | |
718e3744 | 1731 | |
b0a053be | 1732 | ospf_schedule_abr_task (ospf); |
1733 | ||
718e3744 | 1734 | return CMD_SUCCESS; |
1735 | } | |
1736 | ||
b0a053be | 1737 | DEFUN (ospf_area_nssa_translate_no_summary, |
a2c62831 | 1738 | ospf_area_nssa_translate_no_summary_cmd, |
b0a053be | 1739 | "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary", |
718e3744 | 1740 | "OSPF area parameters\n" |
1741 | "OSPF area ID in IP address format\n" | |
1742 | "OSPF area ID as a decimal value\n" | |
1743 | "Configure OSPF area as nssa\n" | |
1744 | "Configure NSSA-ABR for translate election (default)\n" | |
1745 | "Configure NSSA-ABR to never translate\n" | |
1746 | "Configure NSSA-ABR to always translate\n" | |
b0a053be | 1747 | "Do not inject inter-area routes into nssa\n") |
1748 | { | |
1749 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 1); | |
1750 | } | |
718e3744 | 1751 | |
b0a053be | 1752 | DEFUN (ospf_area_nssa_translate, |
a2c62831 | 1753 | ospf_area_nssa_translate_cmd, |
718e3744 | 1754 | "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)", |
1755 | "OSPF area parameters\n" | |
1756 | "OSPF area ID in IP address format\n" | |
1757 | "OSPF area ID as a decimal value\n" | |
1758 | "Configure OSPF area as nssa\n" | |
1759 | "Configure NSSA-ABR for translate election (default)\n" | |
1760 | "Configure NSSA-ABR to never translate\n" | |
1761 | "Configure NSSA-ABR to always translate\n") | |
b0a053be | 1762 | { |
1763 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 0); | |
1764 | } | |
1765 | ||
1766 | DEFUN (ospf_area_nssa, | |
1767 | ospf_area_nssa_cmd, | |
1768 | "area (A.B.C.D|<0-4294967295>) nssa", | |
1769 | "OSPF area parameters\n" | |
1770 | "OSPF area ID in IP address format\n" | |
1771 | "OSPF area ID as a decimal value\n" | |
1772 | "Configure OSPF area as nssa\n") | |
1773 | { | |
1774 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 0); | |
1775 | } | |
718e3744 | 1776 | |
a2c62831 | 1777 | DEFUN (ospf_area_nssa_no_summary, |
1778 | ospf_area_nssa_no_summary_cmd, | |
718e3744 | 1779 | "area (A.B.C.D|<0-4294967295>) nssa no-summary", |
1780 | "OSPF area parameters\n" | |
1781 | "OSPF area ID in IP address format\n" | |
1782 | "OSPF area ID as a decimal value\n" | |
1783 | "Configure OSPF area as nssa\n" | |
1784 | "Do not inject inter-area routes into nssa\n") | |
1785 | { | |
b0a053be | 1786 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 1); |
718e3744 | 1787 | } |
1788 | ||
a2c62831 | 1789 | DEFUN (no_ospf_area_nssa, |
1790 | no_ospf_area_nssa_cmd, | |
718e3744 | 1791 | "no area (A.B.C.D|<0-4294967295>) nssa", |
1792 | NO_STR | |
1793 | "OSPF area parameters\n" | |
1794 | "OSPF area ID in IP address format\n" | |
1795 | "OSPF area ID as a decimal value\n" | |
1796 | "Configure OSPF area as nssa\n") | |
1797 | { | |
1798 | struct ospf *ospf = vty->index; | |
1799 | struct in_addr area_id; | |
1800 | int format; | |
1801 | ||
7c8ff89e DS |
1802 | if (!ospf) |
1803 | return CMD_SUCCESS; | |
1804 | ||
718e3744 | 1805 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
1806 | ||
1807 | ospf_area_nssa_unset (ospf, area_id); | |
1808 | ospf_area_no_summary_unset (ospf, area_id); | |
1809 | ||
b0a053be | 1810 | ospf_schedule_abr_task (ospf); |
1811 | ||
718e3744 | 1812 | return CMD_SUCCESS; |
1813 | } | |
1814 | ||
a2c62831 | 1815 | DEFUN (no_ospf_area_nssa_no_summary, |
1816 | no_ospf_area_nssa_no_summary_cmd, | |
718e3744 | 1817 | "no area (A.B.C.D|<0-4294967295>) nssa no-summary", |
1818 | NO_STR | |
1819 | "OSPF area parameters\n" | |
1820 | "OSPF area ID in IP address format\n" | |
1821 | "OSPF area ID as a decimal value\n" | |
1822 | "Configure OSPF area as nssa\n" | |
1823 | "Do not inject inter-area routes into nssa\n") | |
1824 | { | |
1825 | struct ospf *ospf = vty->index; | |
1826 | struct in_addr area_id; | |
1827 | int format; | |
1828 | ||
7c8ff89e DS |
1829 | if (!ospf) |
1830 | return CMD_SUCCESS; | |
1831 | ||
718e3744 | 1832 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
1833 | ospf_area_no_summary_unset (ospf, area_id); | |
1834 | ||
1835 | return CMD_SUCCESS; | |
1836 | } | |
1837 | ||
a2c62831 | 1838 | DEFUN (ospf_area_default_cost, |
1839 | ospf_area_default_cost_cmd, | |
718e3744 | 1840 | "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>", |
1841 | "OSPF area parameters\n" | |
1842 | "OSPF area ID in IP address format\n" | |
1843 | "OSPF area ID as a decimal value\n" | |
1844 | "Set the summary-default cost of a NSSA or stub area\n" | |
1845 | "Stub's advertised default summary cost\n") | |
1846 | { | |
68980084 | 1847 | struct ospf *ospf = vty->index; |
718e3744 | 1848 | struct ospf_area *area; |
1849 | struct in_addr area_id; | |
1850 | u_int32_t cost; | |
1851 | int format; | |
ba682537 | 1852 | struct prefix_ipv4 p; |
718e3744 | 1853 | |
7c8ff89e DS |
1854 | if (!ospf) |
1855 | return CMD_SUCCESS; | |
1856 | ||
718e3744 | 1857 | VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]); |
1858 | VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215); | |
1859 | ||
68980084 | 1860 | area = ospf_area_get (ospf, area_id, format); |
718e3744 | 1861 | |
1862 | if (area->external_routing == OSPF_AREA_DEFAULT) | |
1863 | { | |
1864 | vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE); | |
1865 | return CMD_WARNING; | |
1866 | } | |
1867 | ||
1868 | area->default_cost = cost; | |
1869 | ||
ba682537 | 1870 | p.family = AF_INET; |
1871 | p.prefix.s_addr = OSPF_DEFAULT_DESTINATION; | |
1872 | p.prefixlen = 0; | |
1873 | if (IS_DEBUG_OSPF_EVENT) | |
1874 | zlog_debug ("ospf_abr_announce_stub_defaults(): " | |
1875 | "announcing 0.0.0.0/0 to area %s", | |
1876 | inet_ntoa (area->area_id)); | |
1877 | ospf_abr_announce_network_to_area (&p, area->default_cost, area); | |
1878 | ||
718e3744 | 1879 | return CMD_SUCCESS; |
1880 | } | |
1881 | ||
a2c62831 | 1882 | DEFUN (no_ospf_area_default_cost, |
1883 | no_ospf_area_default_cost_cmd, | |
718e3744 | 1884 | "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>", |
1885 | NO_STR | |
1886 | "OSPF area parameters\n" | |
1887 | "OSPF area ID in IP address format\n" | |
1888 | "OSPF area ID as a decimal value\n" | |
1889 | "Set the summary-default cost of a NSSA or stub area\n" | |
1890 | "Stub's advertised default summary cost\n") | |
1891 | { | |
68980084 | 1892 | struct ospf *ospf = vty->index; |
718e3744 | 1893 | struct ospf_area *area; |
1894 | struct in_addr area_id; | |
718e3744 | 1895 | int format; |
ba682537 | 1896 | struct prefix_ipv4 p; |
718e3744 | 1897 | |
7c8ff89e DS |
1898 | if (!ospf) |
1899 | return CMD_SUCCESS; | |
1900 | ||
718e3744 | 1901 | VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]); |
0798cee3 | 1902 | VTY_CHECK_INTEGER_RANGE ("stub default cost", argv[1], 0, OSPF_LS_INFINITY); |
718e3744 | 1903 | |
68980084 | 1904 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 1905 | if (area == NULL) |
1906 | return CMD_SUCCESS; | |
1907 | ||
1908 | if (area->external_routing == OSPF_AREA_DEFAULT) | |
1909 | { | |
1910 | vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE); | |
1911 | return CMD_WARNING; | |
1912 | } | |
1913 | ||
1914 | area->default_cost = 1; | |
1915 | ||
ba682537 | 1916 | p.family = AF_INET; |
1917 | p.prefix.s_addr = OSPF_DEFAULT_DESTINATION; | |
1918 | p.prefixlen = 0; | |
1919 | if (IS_DEBUG_OSPF_EVENT) | |
1920 | zlog_debug ("ospf_abr_announce_stub_defaults(): " | |
1921 | "announcing 0.0.0.0/0 to area %s", | |
1922 | inet_ntoa (area->area_id)); | |
1923 | ospf_abr_announce_network_to_area (&p, area->default_cost, area); | |
1924 | ||
1925 | ||
68980084 | 1926 | ospf_area_check_free (ospf, area_id); |
718e3744 | 1927 | |
1928 | return CMD_SUCCESS; | |
1929 | } | |
1930 | ||
a2c62831 | 1931 | DEFUN (ospf_area_export_list, |
1932 | ospf_area_export_list_cmd, | |
718e3744 | 1933 | "area (A.B.C.D|<0-4294967295>) export-list NAME", |
1934 | "OSPF area parameters\n" | |
1935 | "OSPF area ID in IP address format\n" | |
1936 | "OSPF area ID as a decimal value\n" | |
1937 | "Set the filter for networks announced to other areas\n" | |
1938 | "Name of the access-list\n") | |
1939 | { | |
68980084 | 1940 | struct ospf *ospf = vty->index; |
718e3744 | 1941 | struct ospf_area *area; |
1942 | struct in_addr area_id; | |
1943 | int format; | |
1944 | ||
7c8ff89e DS |
1945 | if (!ospf) |
1946 | return CMD_SUCCESS; | |
1947 | ||
52930766 | 1948 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
1949 | ||
68980084 | 1950 | area = ospf_area_get (ospf, area_id, format); |
1951 | ospf_area_export_list_set (ospf, area, argv[1]); | |
718e3744 | 1952 | |
1953 | return CMD_SUCCESS; | |
1954 | } | |
1955 | ||
a2c62831 | 1956 | DEFUN (no_ospf_area_export_list, |
1957 | no_ospf_area_export_list_cmd, | |
718e3744 | 1958 | "no area (A.B.C.D|<0-4294967295>) export-list NAME", |
1959 | NO_STR | |
1960 | "OSPF area parameters\n" | |
1961 | "OSPF area ID in IP address format\n" | |
1962 | "OSPF area ID as a decimal value\n" | |
1963 | "Unset the filter for networks announced to other areas\n" | |
1964 | "Name of the access-list\n") | |
1965 | { | |
68980084 | 1966 | struct ospf *ospf = vty->index; |
718e3744 | 1967 | struct ospf_area *area; |
1968 | struct in_addr area_id; | |
1969 | int format; | |
1970 | ||
7c8ff89e DS |
1971 | if (!ospf) |
1972 | return CMD_SUCCESS; | |
1973 | ||
52930766 | 1974 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
1975 | ||
68980084 | 1976 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 1977 | if (area == NULL) |
1978 | return CMD_SUCCESS; | |
1979 | ||
68980084 | 1980 | ospf_area_export_list_unset (ospf, area); |
718e3744 | 1981 | |
1982 | return CMD_SUCCESS; | |
1983 | } | |
1984 | ||
1985 | ||
a2c62831 | 1986 | DEFUN (ospf_area_import_list, |
1987 | ospf_area_import_list_cmd, | |
718e3744 | 1988 | "area (A.B.C.D|<0-4294967295>) import-list NAME", |
1989 | "OSPF area parameters\n" | |
1990 | "OSPF area ID in IP address format\n" | |
1991 | "OSPF area ID as a decimal value\n" | |
1992 | "Set the filter for networks from other areas announced to the specified one\n" | |
1993 | "Name of the access-list\n") | |
1994 | { | |
68980084 | 1995 | struct ospf *ospf = vty->index; |
718e3744 | 1996 | struct ospf_area *area; |
1997 | struct in_addr area_id; | |
1998 | int format; | |
1999 | ||
7c8ff89e DS |
2000 | if (!ospf) |
2001 | return CMD_SUCCESS; | |
2002 | ||
52930766 | 2003 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
2004 | ||
68980084 | 2005 | area = ospf_area_get (ospf, area_id, format); |
2006 | ospf_area_import_list_set (ospf, area, argv[1]); | |
718e3744 | 2007 | |
2008 | return CMD_SUCCESS; | |
2009 | } | |
2010 | ||
a2c62831 | 2011 | DEFUN (no_ospf_area_import_list, |
2012 | no_ospf_area_import_list_cmd, | |
718e3744 | 2013 | "no area (A.B.C.D|<0-4294967295>) import-list NAME", |
2014 | NO_STR | |
2015 | "OSPF area parameters\n" | |
2016 | "OSPF area ID in IP address format\n" | |
2017 | "OSPF area ID as a decimal value\n" | |
2018 | "Unset the filter for networks announced to other areas\n" | |
2019 | "Name of the access-list\n") | |
2020 | { | |
68980084 | 2021 | struct ospf *ospf = vty->index; |
718e3744 | 2022 | struct ospf_area *area; |
2023 | struct in_addr area_id; | |
2024 | int format; | |
2025 | ||
7c8ff89e DS |
2026 | if (!ospf) |
2027 | return CMD_SUCCESS; | |
2028 | ||
52930766 | 2029 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
2030 | ||
68980084 | 2031 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 2032 | if (area == NULL) |
2033 | return CMD_SUCCESS; | |
2034 | ||
68980084 | 2035 | ospf_area_import_list_unset (ospf, area); |
718e3744 | 2036 | |
2037 | return CMD_SUCCESS; | |
2038 | } | |
2039 | ||
a2c62831 | 2040 | DEFUN (ospf_area_filter_list, |
2041 | ospf_area_filter_list_cmd, | |
718e3744 | 2042 | "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)", |
2043 | "OSPF area parameters\n" | |
2044 | "OSPF area ID in IP address format\n" | |
2045 | "OSPF area ID as a decimal value\n" | |
2046 | "Filter networks between OSPF areas\n" | |
2047 | "Filter prefixes between OSPF areas\n" | |
2048 | "Name of an IP prefix-list\n" | |
2049 | "Filter networks sent to this area\n" | |
2050 | "Filter networks sent from this area\n") | |
2051 | { | |
68980084 | 2052 | struct ospf *ospf = vty->index; |
718e3744 | 2053 | struct ospf_area *area; |
2054 | struct in_addr area_id; | |
2055 | struct prefix_list *plist; | |
2056 | int format; | |
2057 | ||
7c8ff89e DS |
2058 | if (!ospf) |
2059 | return CMD_SUCCESS; | |
2060 | ||
718e3744 | 2061 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
2062 | ||
68980084 | 2063 | area = ospf_area_get (ospf, area_id, format); |
718e3744 | 2064 | plist = prefix_list_lookup (AFI_IP, argv[1]); |
2065 | if (strncmp (argv[2], "in", 2) == 0) | |
2066 | { | |
2067 | PREFIX_LIST_IN (area) = plist; | |
2068 | if (PREFIX_NAME_IN (area)) | |
2069 | free (PREFIX_NAME_IN (area)); | |
2070 | ||
2071 | PREFIX_NAME_IN (area) = strdup (argv[1]); | |
68980084 | 2072 | ospf_schedule_abr_task (ospf); |
718e3744 | 2073 | } |
2074 | else | |
2075 | { | |
2076 | PREFIX_LIST_OUT (area) = plist; | |
2077 | if (PREFIX_NAME_OUT (area)) | |
2078 | free (PREFIX_NAME_OUT (area)); | |
2079 | ||
2080 | PREFIX_NAME_OUT (area) = strdup (argv[1]); | |
68980084 | 2081 | ospf_schedule_abr_task (ospf); |
718e3744 | 2082 | } |
2083 | ||
2084 | return CMD_SUCCESS; | |
2085 | } | |
2086 | ||
a2c62831 | 2087 | DEFUN (no_ospf_area_filter_list, |
2088 | no_ospf_area_filter_list_cmd, | |
718e3744 | 2089 | "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)", |
2090 | NO_STR | |
2091 | "OSPF area parameters\n" | |
2092 | "OSPF area ID in IP address format\n" | |
2093 | "OSPF area ID as a decimal value\n" | |
2094 | "Filter networks between OSPF areas\n" | |
2095 | "Filter prefixes between OSPF areas\n" | |
2096 | "Name of an IP prefix-list\n" | |
2097 | "Filter networks sent to this area\n" | |
2098 | "Filter networks sent from this area\n") | |
2099 | { | |
68980084 | 2100 | struct ospf *ospf = vty->index; |
718e3744 | 2101 | struct ospf_area *area; |
2102 | struct in_addr area_id; | |
718e3744 | 2103 | int format; |
2104 | ||
7c8ff89e DS |
2105 | if (!ospf) |
2106 | return CMD_SUCCESS; | |
2107 | ||
718e3744 | 2108 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
2109 | ||
1a8ec2b9 PJ |
2110 | if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL) |
2111 | return CMD_SUCCESS; | |
2112 | ||
718e3744 | 2113 | if (strncmp (argv[2], "in", 2) == 0) |
2114 | { | |
2115 | if (PREFIX_NAME_IN (area)) | |
2116 | if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0) | |
2117 | return CMD_SUCCESS; | |
2118 | ||
2119 | PREFIX_LIST_IN (area) = NULL; | |
2120 | if (PREFIX_NAME_IN (area)) | |
2121 | free (PREFIX_NAME_IN (area)); | |
2122 | ||
2123 | PREFIX_NAME_IN (area) = NULL; | |
2124 | ||
68980084 | 2125 | ospf_schedule_abr_task (ospf); |
718e3744 | 2126 | } |
2127 | else | |
2128 | { | |
2129 | if (PREFIX_NAME_OUT (area)) | |
2130 | if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0) | |
2131 | return CMD_SUCCESS; | |
2132 | ||
2133 | PREFIX_LIST_OUT (area) = NULL; | |
2134 | if (PREFIX_NAME_OUT (area)) | |
2135 | free (PREFIX_NAME_OUT (area)); | |
2136 | ||
2137 | PREFIX_NAME_OUT (area) = NULL; | |
2138 | ||
68980084 | 2139 | ospf_schedule_abr_task (ospf); |
718e3744 | 2140 | } |
2141 | ||
2142 | return CMD_SUCCESS; | |
2143 | } | |
2144 | ||
6b0655a2 | 2145 | |
a2c62831 | 2146 | DEFUN (ospf_area_authentication_message_digest, |
2147 | ospf_area_authentication_message_digest_cmd, | |
718e3744 | 2148 | "area (A.B.C.D|<0-4294967295>) authentication message-digest", |
2149 | "OSPF area parameters\n" | |
2b00515a CF |
2150 | "OSPF area ID in IP address format\n" |
2151 | "OSPF area ID as a decimal value\n" | |
718e3744 | 2152 | "Enable authentication\n" |
2153 | "Use message-digest authentication\n") | |
2154 | { | |
68980084 | 2155 | struct ospf *ospf = vty->index; |
718e3744 | 2156 | struct ospf_area *area; |
2157 | struct in_addr area_id; | |
2158 | int format; | |
2159 | ||
7c8ff89e DS |
2160 | if (!ospf) |
2161 | return CMD_SUCCESS; | |
2162 | ||
718e3744 | 2163 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
2164 | ||
68980084 | 2165 | area = ospf_area_get (ospf, area_id, format); |
718e3744 | 2166 | area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
2167 | ||
2168 | return CMD_SUCCESS; | |
2169 | } | |
2170 | ||
a2c62831 | 2171 | DEFUN (ospf_area_authentication, |
2172 | ospf_area_authentication_cmd, | |
718e3744 | 2173 | "area (A.B.C.D|<0-4294967295>) authentication", |
2174 | "OSPF area parameters\n" | |
2175 | "OSPF area ID in IP address format\n" | |
2176 | "OSPF area ID as a decimal value\n" | |
2177 | "Enable authentication\n") | |
2178 | { | |
68980084 | 2179 | struct ospf *ospf = vty->index; |
718e3744 | 2180 | struct ospf_area *area; |
2181 | struct in_addr area_id; | |
2182 | int format; | |
2183 | ||
7c8ff89e DS |
2184 | if (!ospf) |
2185 | return CMD_SUCCESS; | |
2186 | ||
718e3744 | 2187 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
2188 | ||
68980084 | 2189 | area = ospf_area_get (ospf, area_id, format); |
718e3744 | 2190 | area->auth_type = OSPF_AUTH_SIMPLE; |
2191 | ||
2192 | return CMD_SUCCESS; | |
2193 | } | |
2194 | ||
a2c62831 | 2195 | DEFUN (no_ospf_area_authentication, |
2196 | no_ospf_area_authentication_cmd, | |
718e3744 | 2197 | "no area (A.B.C.D|<0-4294967295>) authentication", |
2198 | NO_STR | |
2199 | "OSPF area parameters\n" | |
2200 | "OSPF area ID in IP address format\n" | |
2201 | "OSPF area ID as a decimal value\n" | |
2202 | "Enable authentication\n") | |
2203 | { | |
68980084 | 2204 | struct ospf *ospf = vty->index; |
718e3744 | 2205 | struct ospf_area *area; |
2206 | struct in_addr area_id; | |
2207 | int format; | |
2208 | ||
7c8ff89e DS |
2209 | if (!ospf) |
2210 | return CMD_SUCCESS; | |
2211 | ||
718e3744 | 2212 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
2213 | ||
68980084 | 2214 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 2215 | if (area == NULL) |
2216 | return CMD_SUCCESS; | |
2217 | ||
2218 | area->auth_type = OSPF_AUTH_NULL; | |
2219 | ||
68980084 | 2220 | ospf_area_check_free (ospf, area_id); |
718e3744 | 2221 | |
2222 | return CMD_SUCCESS; | |
2223 | } | |
2224 | ||
6b0655a2 | 2225 | |
718e3744 | 2226 | DEFUN (ospf_abr_type, |
2227 | ospf_abr_type_cmd, | |
2228 | "ospf abr-type (cisco|ibm|shortcut|standard)", | |
2229 | "OSPF specific commands\n" | |
2230 | "Set OSPF ABR type\n" | |
2231 | "Alternative ABR, cisco implementation\n" | |
2232 | "Alternative ABR, IBM implementation\n" | |
2233 | "Shortcut ABR\n" | |
2234 | "Standard behavior (RFC2328)\n") | |
2235 | { | |
68980084 | 2236 | struct ospf *ospf = vty->index; |
718e3744 | 2237 | u_char abr_type = OSPF_ABR_UNKNOWN; |
2238 | ||
7c8ff89e DS |
2239 | if (!ospf) |
2240 | return CMD_SUCCESS; | |
2241 | ||
718e3744 | 2242 | if (strncmp (argv[0], "c", 1) == 0) |
2243 | abr_type = OSPF_ABR_CISCO; | |
2244 | else if (strncmp (argv[0], "i", 1) == 0) | |
2245 | abr_type = OSPF_ABR_IBM; | |
2246 | else if (strncmp (argv[0], "sh", 2) == 0) | |
2247 | abr_type = OSPF_ABR_SHORTCUT; | |
2248 | else if (strncmp (argv[0], "st", 2) == 0) | |
2249 | abr_type = OSPF_ABR_STAND; | |
2250 | else | |
2251 | return CMD_WARNING; | |
2252 | ||
2253 | /* If ABR type value is changed, schedule ABR task. */ | |
68980084 | 2254 | if (ospf->abr_type != abr_type) |
718e3744 | 2255 | { |
68980084 | 2256 | ospf->abr_type = abr_type; |
2257 | ospf_schedule_abr_task (ospf); | |
718e3744 | 2258 | } |
2259 | ||
2260 | return CMD_SUCCESS; | |
2261 | } | |
2262 | ||
2263 | DEFUN (no_ospf_abr_type, | |
2264 | no_ospf_abr_type_cmd, | |
d57834f6 | 2265 | "no ospf abr-type (cisco|ibm|shortcut|standard)", |
718e3744 | 2266 | NO_STR |
2267 | "OSPF specific commands\n" | |
2268 | "Set OSPF ABR type\n" | |
2269 | "Alternative ABR, cisco implementation\n" | |
2270 | "Alternative ABR, IBM implementation\n" | |
2271 | "Shortcut ABR\n") | |
2272 | { | |
68980084 | 2273 | struct ospf *ospf = vty->index; |
718e3744 | 2274 | u_char abr_type = OSPF_ABR_UNKNOWN; |
2275 | ||
7c8ff89e DS |
2276 | if (!ospf) |
2277 | return CMD_SUCCESS; | |
2278 | ||
718e3744 | 2279 | if (strncmp (argv[0], "c", 1) == 0) |
2280 | abr_type = OSPF_ABR_CISCO; | |
2281 | else if (strncmp (argv[0], "i", 1) == 0) | |
2282 | abr_type = OSPF_ABR_IBM; | |
04d23314 | 2283 | else if (strncmp (argv[0], "sh", 2) == 0) |
718e3744 | 2284 | abr_type = OSPF_ABR_SHORTCUT; |
04d23314 FD |
2285 | else if (strncmp (argv[0], "st", 2) == 0) |
2286 | abr_type = OSPF_ABR_STAND; | |
718e3744 | 2287 | else |
2288 | return CMD_WARNING; | |
2289 | ||
2290 | /* If ABR type value is changed, schedule ABR task. */ | |
68980084 | 2291 | if (ospf->abr_type == abr_type) |
718e3744 | 2292 | { |
d57834f6 | 2293 | ospf->abr_type = OSPF_ABR_DEFAULT; |
68980084 | 2294 | ospf_schedule_abr_task (ospf); |
718e3744 | 2295 | } |
2296 | ||
2297 | return CMD_SUCCESS; | |
2298 | } | |
2299 | ||
d7e60dd7 AS |
2300 | DEFUN (ospf_log_adjacency_changes, |
2301 | ospf_log_adjacency_changes_cmd, | |
2302 | "log-adjacency-changes", | |
2303 | "Log changes in adjacency state\n") | |
2304 | { | |
2305 | struct ospf *ospf = vty->index; | |
2306 | ||
7c8ff89e DS |
2307 | if (!ospf) |
2308 | return CMD_SUCCESS; | |
2309 | ||
d7e60dd7 AS |
2310 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); |
2311 | return CMD_SUCCESS; | |
2312 | } | |
2313 | ||
2314 | DEFUN (ospf_log_adjacency_changes_detail, | |
2315 | ospf_log_adjacency_changes_detail_cmd, | |
2316 | "log-adjacency-changes detail", | |
2317 | "Log changes in adjacency state\n" | |
2318 | "Log all state changes\n") | |
2319 | { | |
2320 | struct ospf *ospf = vty->index; | |
2321 | ||
7c8ff89e DS |
2322 | if (!ospf) |
2323 | return CMD_SUCCESS; | |
2324 | ||
d7e60dd7 AS |
2325 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); |
2326 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); | |
2327 | return CMD_SUCCESS; | |
2328 | } | |
2329 | ||
2330 | DEFUN (no_ospf_log_adjacency_changes, | |
2331 | no_ospf_log_adjacency_changes_cmd, | |
2332 | "no log-adjacency-changes", | |
2333 | NO_STR | |
2334 | "Log changes in adjacency state\n") | |
2335 | { | |
2336 | struct ospf *ospf = vty->index; | |
2337 | ||
7c8ff89e DS |
2338 | if (!ospf) |
2339 | return CMD_SUCCESS; | |
2340 | ||
d7e60dd7 AS |
2341 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); |
2342 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); | |
2343 | return CMD_SUCCESS; | |
2344 | } | |
2345 | ||
2346 | DEFUN (no_ospf_log_adjacency_changes_detail, | |
2347 | no_ospf_log_adjacency_changes_detail_cmd, | |
2348 | "no log-adjacency-changes detail", | |
2349 | NO_STR | |
2350 | "Log changes in adjacency state\n" | |
2351 | "Log all state changes\n") | |
2352 | { | |
2353 | struct ospf *ospf = vty->index; | |
2354 | ||
7c8ff89e DS |
2355 | if (!ospf) |
2356 | return CMD_SUCCESS; | |
2357 | ||
d7e60dd7 AS |
2358 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); |
2359 | return CMD_SUCCESS; | |
2360 | } | |
2361 | ||
718e3744 | 2362 | DEFUN (ospf_compatible_rfc1583, |
2363 | ospf_compatible_rfc1583_cmd, | |
2364 | "compatible rfc1583", | |
2365 | "OSPF compatibility list\n" | |
2366 | "compatible with RFC 1583\n") | |
2367 | { | |
2368 | struct ospf *ospf = vty->index; | |
2369 | ||
7c8ff89e DS |
2370 | if (!ospf) |
2371 | return CMD_SUCCESS; | |
2372 | ||
718e3744 | 2373 | if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
2374 | { | |
2375 | SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); | |
68980084 | 2376 | ospf_spf_calculate_schedule (ospf); |
718e3744 | 2377 | } |
2378 | return CMD_SUCCESS; | |
2379 | } | |
2380 | ||
2381 | DEFUN (no_ospf_compatible_rfc1583, | |
2382 | no_ospf_compatible_rfc1583_cmd, | |
2383 | "no compatible rfc1583", | |
2384 | NO_STR | |
2385 | "OSPF compatibility list\n" | |
2386 | "compatible with RFC 1583\n") | |
2387 | { | |
2388 | struct ospf *ospf = vty->index; | |
2389 | ||
7c8ff89e DS |
2390 | if (!ospf) |
2391 | return CMD_SUCCESS; | |
2392 | ||
718e3744 | 2393 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
2394 | { | |
2395 | UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); | |
68980084 | 2396 | ospf_spf_calculate_schedule (ospf); |
718e3744 | 2397 | } |
2398 | return CMD_SUCCESS; | |
2399 | } | |
2400 | ||
2401 | ALIAS (ospf_compatible_rfc1583, | |
2402 | ospf_rfc1583_flag_cmd, | |
2403 | "ospf rfc1583compatibility", | |
2404 | "OSPF specific commands\n" | |
2405 | "Enable the RFC1583Compatibility flag\n") | |
2406 | ||
2407 | ALIAS (no_ospf_compatible_rfc1583, | |
2408 | no_ospf_rfc1583_flag_cmd, | |
2409 | "no ospf rfc1583compatibility", | |
2410 | NO_STR | |
2411 | "OSPF specific commands\n" | |
2412 | "Disable the RFC1583Compatibility flag\n") | |
6b0655a2 | 2413 | |
d24f6e2a | 2414 | static int |
2415 | ospf_timers_spf_set (struct vty *vty, unsigned int delay, | |
2416 | unsigned int hold, | |
2417 | unsigned int max) | |
2418 | { | |
2419 | struct ospf *ospf = vty->index; | |
2420 | ||
7c8ff89e DS |
2421 | if (!ospf) |
2422 | return CMD_SUCCESS; | |
2423 | ||
d24f6e2a | 2424 | ospf->spf_delay = delay; |
2425 | ospf->spf_holdtime = hold; | |
2426 | ospf->spf_max_holdtime = max; | |
2427 | ||
2428 | return CMD_SUCCESS; | |
2429 | } | |
718e3744 | 2430 | |
d24f6e2a | 2431 | DEFUN (ospf_timers_throttle_spf, |
2432 | ospf_timers_throttle_spf_cmd, | |
2433 | "timers throttle spf <0-600000> <0-600000> <0-600000>", | |
2434 | "Adjust routing timers\n" | |
2435 | "Throttling adaptive timer\n" | |
2436 | "OSPF SPF timers\n" | |
2437 | "Delay (msec) from first change received till SPF calculation\n" | |
2438 | "Initial hold time (msec) between consecutive SPF calculations\n" | |
2439 | "Maximum hold time (msec)\n") | |
2440 | { | |
2441 | unsigned int delay, hold, max; | |
2442 | ||
2443 | if (argc != 3) | |
2444 | { | |
2445 | vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); | |
2446 | return CMD_WARNING; | |
2447 | } | |
2448 | ||
2449 | VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000); | |
2450 | VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000); | |
2451 | VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000); | |
2452 | ||
2453 | return ospf_timers_spf_set (vty, delay, hold, max); | |
2454 | } | |
2455 | ||
2456 | DEFUN_DEPRECATED (ospf_timers_spf, | |
a2c62831 | 2457 | ospf_timers_spf_cmd, |
718e3744 | 2458 | "timers spf <0-4294967295> <0-4294967295>", |
2459 | "Adjust routing timers\n" | |
2460 | "OSPF SPF timers\n" | |
d24f6e2a | 2461 | "Delay (s) between receiving a change to SPF calculation\n" |
2462 | "Hold time (s) between consecutive SPF calculations\n") | |
718e3744 | 2463 | { |
d24f6e2a | 2464 | unsigned int delay, hold; |
2465 | ||
2466 | if (argc != 2) | |
2467 | { | |
2468 | vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE); | |
2469 | return CMD_WARNING; | |
2470 | } | |
2471 | ||
4dadc291 | 2472 | VTY_GET_INTEGER ("SPF delay timer", delay, argv[0]); |
2473 | VTY_GET_INTEGER ("SPF hold timer", hold, argv[1]); | |
d24f6e2a | 2474 | |
2475 | /* truncate down the second values if they're greater than 600000ms */ | |
2476 | if (delay > (600000 / 1000)) | |
2477 | delay = 600000; | |
2478 | else if (delay == 0) | |
2479 | /* 0s delay was probably specified because of lack of ms resolution */ | |
2480 | delay = OSPF_SPF_DELAY_DEFAULT; | |
2481 | if (hold > (600000 / 1000)) | |
2482 | hold = 600000; | |
2483 | ||
2484 | return ospf_timers_spf_set (vty, delay * 1000, hold * 1000, hold * 1000); | |
718e3744 | 2485 | } |
2486 | ||
d24f6e2a | 2487 | DEFUN (no_ospf_timers_throttle_spf, |
2488 | no_ospf_timers_throttle_spf_cmd, | |
2489 | "no timers throttle spf", | |
718e3744 | 2490 | NO_STR |
2491 | "Adjust routing timers\n" | |
d24f6e2a | 2492 | "Throttling adaptive timer\n" |
718e3744 | 2493 | "OSPF SPF timers\n") |
2494 | { | |
d24f6e2a | 2495 | return ospf_timers_spf_set (vty, |
2496 | OSPF_SPF_DELAY_DEFAULT, | |
2497 | OSPF_SPF_HOLDTIME_DEFAULT, | |
2498 | OSPF_SPF_MAX_HOLDTIME_DEFAULT); | |
718e3744 | 2499 | } |
2500 | ||
d24f6e2a | 2501 | ALIAS_DEPRECATED (no_ospf_timers_throttle_spf, |
2502 | no_ospf_timers_spf_cmd, | |
2503 | "no timers spf", | |
2504 | NO_STR | |
2505 | "Adjust routing timers\n" | |
2506 | "OSPF SPF timers\n") | |
6b0655a2 | 2507 | |
a2c62831 | 2508 | DEFUN (ospf_neighbor, |
2509 | ospf_neighbor_cmd, | |
718e3744 | 2510 | "neighbor A.B.C.D", |
2511 | NEIGHBOR_STR | |
2512 | "Neighbor IP address\n") | |
2513 | { | |
2514 | struct ospf *ospf = vty->index; | |
2515 | struct in_addr nbr_addr; | |
eb1ce605 | 2516 | unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
2517 | unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; | |
718e3744 | 2518 | |
7c8ff89e DS |
2519 | if (!ospf) |
2520 | return CMD_SUCCESS; | |
2521 | ||
718e3744 | 2522 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
2523 | ||
2524 | if (argc > 1) | |
2525 | VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255); | |
2526 | ||
2527 | if (argc > 2) | |
2528 | VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535); | |
2529 | ||
2530 | ospf_nbr_nbma_set (ospf, nbr_addr); | |
2531 | if (argc > 1) | |
2532 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); | |
2533 | if (argc > 2) | |
1a61ad10 | 2534 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval); |
718e3744 | 2535 | |
2536 | return CMD_SUCCESS; | |
2537 | } | |
2538 | ||
a2c62831 | 2539 | ALIAS (ospf_neighbor, |
2540 | ospf_neighbor_priority_poll_interval_cmd, | |
718e3744 | 2541 | "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", |
2542 | NEIGHBOR_STR | |
2543 | "Neighbor IP address\n" | |
2544 | "Neighbor Priority\n" | |
2545 | "Priority\n" | |
2546 | "Dead Neighbor Polling interval\n" | |
2547 | "Seconds\n") | |
2548 | ||
a2c62831 | 2549 | ALIAS (ospf_neighbor, |
2550 | ospf_neighbor_priority_cmd, | |
718e3744 | 2551 | "neighbor A.B.C.D priority <0-255>", |
2552 | NEIGHBOR_STR | |
2553 | "Neighbor IP address\n" | |
2554 | "Neighbor Priority\n" | |
2555 | "Seconds\n") | |
2556 | ||
a2c62831 | 2557 | DEFUN (ospf_neighbor_poll_interval, |
2558 | ospf_neighbor_poll_interval_cmd, | |
718e3744 | 2559 | "neighbor A.B.C.D poll-interval <1-65535>", |
2560 | NEIGHBOR_STR | |
2561 | "Neighbor IP address\n" | |
2562 | "Dead Neighbor Polling interval\n" | |
2563 | "Seconds\n") | |
2564 | { | |
2565 | struct ospf *ospf = vty->index; | |
2566 | struct in_addr nbr_addr; | |
eb1ce605 | 2567 | unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
2568 | unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; | |
718e3744 | 2569 | |
7c8ff89e DS |
2570 | if (!ospf) |
2571 | return CMD_SUCCESS; | |
2572 | ||
718e3744 | 2573 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
2574 | ||
2575 | if (argc > 1) | |
2576 | VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535); | |
2577 | ||
2578 | if (argc > 2) | |
2579 | VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255); | |
2580 | ||
2581 | ospf_nbr_nbma_set (ospf, nbr_addr); | |
2582 | if (argc > 1) | |
2583 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval); | |
2584 | if (argc > 2) | |
2585 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); | |
2586 | ||
2587 | return CMD_SUCCESS; | |
2588 | } | |
2589 | ||
a2c62831 | 2590 | ALIAS (ospf_neighbor_poll_interval, |
2591 | ospf_neighbor_poll_interval_priority_cmd, | |
718e3744 | 2592 | "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>", |
2593 | NEIGHBOR_STR | |
2594 | "Neighbor address\n" | |
2595 | "OSPF dead-router polling interval\n" | |
2596 | "Seconds\n" | |
2597 | "OSPF priority of non-broadcast neighbor\n" | |
2598 | "Priority\n") | |
2599 | ||
a2c62831 | 2600 | DEFUN (no_ospf_neighbor, |
2601 | no_ospf_neighbor_cmd, | |
718e3744 | 2602 | "no neighbor A.B.C.D", |
2603 | NO_STR | |
2604 | NEIGHBOR_STR | |
2605 | "Neighbor IP address\n") | |
2606 | { | |
2607 | struct ospf *ospf = vty->index; | |
2608 | struct in_addr nbr_addr; | |
718e3744 | 2609 | |
7c8ff89e DS |
2610 | if (!ospf) |
2611 | return CMD_SUCCESS; | |
2612 | ||
718e3744 | 2613 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
2614 | ||
0798cee3 | 2615 | (void)ospf_nbr_nbma_unset (ospf, nbr_addr); |
718e3744 | 2616 | |
2617 | return CMD_SUCCESS; | |
2618 | } | |
2619 | ||
a2c62831 | 2620 | ALIAS (no_ospf_neighbor, |
2621 | no_ospf_neighbor_priority_cmd, | |
718e3744 | 2622 | "no neighbor A.B.C.D priority <0-255>", |
2623 | NO_STR | |
2624 | NEIGHBOR_STR | |
2625 | "Neighbor IP address\n" | |
2626 | "Neighbor Priority\n" | |
2627 | "Priority\n") | |
2628 | ||
a2c62831 | 2629 | ALIAS (no_ospf_neighbor, |
2630 | no_ospf_neighbor_poll_interval_cmd, | |
718e3744 | 2631 | "no neighbor A.B.C.D poll-interval <1-65535>", |
2632 | NO_STR | |
2633 | NEIGHBOR_STR | |
2634 | "Neighbor IP address\n" | |
2635 | "Dead Neighbor Polling interval\n" | |
2636 | "Seconds\n") | |
2637 | ||
a2c62831 | 2638 | ALIAS (no_ospf_neighbor, |
2639 | no_ospf_neighbor_priority_pollinterval_cmd, | |
718e3744 | 2640 | "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", |
2641 | NO_STR | |
2642 | NEIGHBOR_STR | |
2643 | "Neighbor IP address\n" | |
2644 | "Neighbor Priority\n" | |
2645 | "Priority\n" | |
2646 | "Dead Neighbor Polling interval\n" | |
2647 | "Seconds\n") | |
2648 | ||
6b0655a2 | 2649 | |
a2c62831 | 2650 | DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd, |
718e3744 | 2651 | "refresh timer <10-1800>", |
2652 | "Adjust refresh parameters\n" | |
2653 | "Set refresh timer\n" | |
2654 | "Timer value in seconds\n") | |
2655 | { | |
2656 | struct ospf *ospf = vty->index; | |
eb1ce605 | 2657 | unsigned int interval; |
718e3744 | 2658 | |
7c8ff89e DS |
2659 | if (!ospf) |
2660 | return CMD_SUCCESS; | |
2661 | ||
718e3744 | 2662 | VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800); |
2663 | interval = (interval / 10) * 10; | |
2664 | ||
2665 | ospf_timers_refresh_set (ospf, interval); | |
2666 | ||
2667 | return CMD_SUCCESS; | |
2668 | } | |
2669 | ||
a2c62831 | 2670 | DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd, |
718e3744 | 2671 | "no refresh timer <10-1800>", |
2672 | "Adjust refresh parameters\n" | |
2673 | "Unset refresh timer\n" | |
2674 | "Timer value in seconds\n") | |
2675 | { | |
2676 | struct ospf *ospf = vty->index; | |
eb1ce605 | 2677 | unsigned int interval; |
718e3744 | 2678 | |
7c8ff89e DS |
2679 | if (!ospf) |
2680 | return CMD_SUCCESS; | |
2681 | ||
718e3744 | 2682 | if (argc == 1) |
2683 | { | |
2684 | VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800); | |
2685 | ||
2686 | if (ospf->lsa_refresh_interval != interval || | |
2687 | interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT) | |
2688 | return CMD_SUCCESS; | |
2689 | } | |
2690 | ||
2691 | ospf_timers_refresh_unset (ospf); | |
2692 | ||
2693 | return CMD_SUCCESS; | |
2694 | } | |
2695 | ||
a2c62831 | 2696 | ALIAS (no_ospf_refresh_timer, |
2697 | no_ospf_refresh_timer_cmd, | |
718e3744 | 2698 | "no refresh timer", |
2699 | "Adjust refresh parameters\n" | |
2700 | "Unset refresh timer\n") | |
2701 | ||
a2c62831 | 2702 | DEFUN (ospf_auto_cost_reference_bandwidth, |
2703 | ospf_auto_cost_reference_bandwidth_cmd, | |
718e3744 | 2704 | "auto-cost reference-bandwidth <1-4294967>", |
2705 | "Calculate OSPF interface cost according to bandwidth\n" | |
2706 | "Use reference bandwidth method to assign OSPF cost\n" | |
2707 | "The reference bandwidth in terms of Mbits per second\n") | |
2708 | { | |
68980084 | 2709 | struct ospf *ospf = vty->index; |
718e3744 | 2710 | u_int32_t refbw; |
52dc7ee6 | 2711 | struct listnode *node; |
1eb8ef25 | 2712 | struct interface *ifp; |
718e3744 | 2713 | |
7c8ff89e DS |
2714 | if (!ospf) |
2715 | return CMD_SUCCESS; | |
2716 | ||
718e3744 | 2717 | refbw = strtol (argv[0], NULL, 10); |
2718 | if (refbw < 1 || refbw > 4294967) | |
2719 | { | |
2720 | vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE); | |
2721 | return CMD_WARNING; | |
2722 | } | |
2723 | ||
2724 | /* If reference bandwidth is changed. */ | |
68980084 | 2725 | if ((refbw * 1000) == ospf->ref_bandwidth) |
718e3744 | 2726 | return CMD_SUCCESS; |
2727 | ||
68980084 | 2728 | ospf->ref_bandwidth = refbw * 1000; |
1eb8ef25 | 2729 | for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp)) |
2730 | ospf_if_recalculate_output_cost (ifp); | |
718e3744 | 2731 | |
2732 | return CMD_SUCCESS; | |
2733 | } | |
2734 | ||
a2c62831 | 2735 | DEFUN (no_ospf_auto_cost_reference_bandwidth, |
2736 | no_ospf_auto_cost_reference_bandwidth_cmd, | |
718e3744 | 2737 | "no auto-cost reference-bandwidth", |
2738 | NO_STR | |
2739 | "Calculate OSPF interface cost according to bandwidth\n" | |
2740 | "Use reference bandwidth method to assign OSPF cost\n") | |
2741 | { | |
68980084 | 2742 | struct ospf *ospf = vty->index; |
1eb8ef25 | 2743 | struct listnode *node, *nnode; |
2744 | struct interface *ifp; | |
718e3744 | 2745 | |
7c8ff89e DS |
2746 | if (!ospf) |
2747 | return CMD_SUCCESS; | |
2748 | ||
68980084 | 2749 | if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH) |
718e3744 | 2750 | return CMD_SUCCESS; |
2751 | ||
68980084 | 2752 | ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH; |
718e3744 | 2753 | vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE); |
2754 | vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE); | |
2755 | ||
1eb8ef25 | 2756 | for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp)) |
2757 | ospf_if_recalculate_output_cost (ifp); | |
718e3744 | 2758 | |
2759 | return CMD_SUCCESS; | |
2760 | } | |
2761 | ||
2f8f370e DS |
2762 | DEFUN (ospf_write_multiplier, |
2763 | ospf_write_multiplier_cmd, | |
e8f45e82 DS |
2764 | "ospf write-multiplier <1-100>", |
2765 | "OSPF specific commands\n" | |
2766 | "Write multiplier\n" | |
2767 | "Maximum number of interface serviced per write\n") | |
2f8f370e DS |
2768 | { |
2769 | struct ospf *ospf = vty->index; | |
e8f45e82 | 2770 | u_int32_t write_oi_count; |
2f8f370e | 2771 | |
7c8ff89e DS |
2772 | if (!ospf) |
2773 | return CMD_SUCCESS; | |
2774 | ||
e8f45e82 DS |
2775 | write_oi_count = strtol (argv[0], NULL, 10); |
2776 | if (write_oi_count < 1 || write_oi_count > 100) | |
2f8f370e DS |
2777 | { |
2778 | vty_out (vty, "write-multiplier value is invalid%s", VTY_NEWLINE); | |
2779 | return CMD_WARNING; | |
2780 | } | |
2781 | ||
e8f45e82 | 2782 | ospf->write_oi_count = write_oi_count; |
2f8f370e DS |
2783 | return CMD_SUCCESS; |
2784 | } | |
2785 | ||
e8f45e82 DS |
2786 | ALIAS (ospf_write_multiplier, |
2787 | write_multiplier_cmd, | |
2788 | "write-multiplier <1-100>", | |
2789 | "Write multiplier\n" | |
2790 | "Maximum number of interface serviced per write\n") | |
2791 | ||
2f8f370e DS |
2792 | DEFUN (no_ospf_write_multiplier, |
2793 | no_ospf_write_multiplier_cmd, | |
e8f45e82 | 2794 | "no ospf write-multiplier", |
2f8f370e | 2795 | NO_STR |
e8f45e82 DS |
2796 | "OSPF specific commands\n" |
2797 | "Write multiplier\n") | |
2f8f370e DS |
2798 | { |
2799 | struct ospf *ospf = vty->index; | |
2800 | ||
7c8ff89e DS |
2801 | if (!ospf) |
2802 | return CMD_SUCCESS; | |
2803 | ||
e8f45e82 | 2804 | ospf->write_oi_count = OSPF_WRITE_INTERFACE_COUNT_DEFAULT; |
2f8f370e DS |
2805 | return CMD_SUCCESS; |
2806 | } | |
2807 | ||
e8f45e82 DS |
2808 | ALIAS (no_ospf_write_multiplier, |
2809 | no_write_multiplier_cmd, | |
2810 | "no write-multiplier", | |
2811 | NO_STR | |
2812 | "Write multiplier\n") | |
2813 | ||
eb1ce605 | 2814 | const char *ospf_abr_type_descr_str[] = |
718e3744 | 2815 | { |
2816 | "Unknown", | |
2817 | "Standard (RFC2328)", | |
2818 | "Alternative IBM", | |
2819 | "Alternative Cisco", | |
2820 | "Alternative Shortcut" | |
2821 | }; | |
2822 | ||
eb1ce605 | 2823 | const char *ospf_shortcut_mode_descr_str[] = |
718e3744 | 2824 | { |
2825 | "Default", | |
2826 | "Enabled", | |
2827 | "Disabled" | |
2828 | }; | |
2829 | ||
2830 | ||
6b0655a2 | 2831 | |
4dadc291 | 2832 | static void |
718e3744 | 2833 | show_ip_ospf_area (struct vty *vty, struct ospf_area *area) |
2834 | { | |
2835 | /* Show Area ID. */ | |
2836 | vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id)); | |
2837 | ||
2838 | /* Show Area type/mode. */ | |
2839 | if (OSPF_IS_AREA_BACKBONE (area)) | |
2840 | vty_out (vty, " (Backbone)%s", VTY_NEWLINE); | |
2841 | else | |
2842 | { | |
2843 | if (area->external_routing == OSPF_AREA_STUB) | |
b0a053be | 2844 | vty_out (vty, " (Stub%s%s)", |
2845 | area->no_summary ? ", no summary" : "", | |
2846 | area->shortcut_configured ? "; " : ""); | |
718e3744 | 2847 | |
b0a053be | 2848 | else if (area->external_routing == OSPF_AREA_NSSA) |
2849 | vty_out (vty, " (NSSA%s%s)", | |
2850 | area->no_summary ? ", no summary" : "", | |
2851 | area->shortcut_configured ? "; " : ""); | |
718e3744 | 2852 | |
2853 | vty_out (vty, "%s", VTY_NEWLINE); | |
2854 | vty_out (vty, " Shortcutting mode: %s", | |
b0a053be | 2855 | ospf_shortcut_mode_descr_str[area->shortcut_configured]); |
718e3744 | 2856 | vty_out (vty, ", S-bit consensus: %s%s", |
b0a053be | 2857 | area->shortcut_capability ? "ok" : "no", VTY_NEWLINE); |
718e3744 | 2858 | } |
2859 | ||
2860 | /* Show number of interfaces. */ | |
2861 | vty_out (vty, " Number of interfaces in this area: Total: %d, " | |
2862 | "Active: %d%s", listcount (area->oiflist), | |
2863 | area->act_ints, VTY_NEWLINE); | |
2864 | ||
718e3744 | 2865 | if (area->external_routing == OSPF_AREA_NSSA) |
2866 | { | |
2867 | vty_out (vty, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE, VTY_NEWLINE); | |
020709f9 | 2868 | if (! IS_OSPF_ABR (area->ospf)) |
b0a053be | 2869 | vty_out (vty, " It is not ABR, therefore not Translator. %s", |
2870 | VTY_NEWLINE); | |
2871 | else if (area->NSSATranslatorState) | |
2872 | { | |
2873 | vty_out (vty, " We are an ABR and "); | |
2874 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) | |
2875 | vty_out (vty, "the NSSA Elected Translator. %s", | |
2876 | VTY_NEWLINE); | |
2877 | else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS) | |
2878 | vty_out (vty, "always an NSSA Translator. %s", | |
2879 | VTY_NEWLINE); | |
2880 | } | |
718e3744 | 2881 | else |
b0a053be | 2882 | { |
2883 | vty_out (vty, " We are an ABR, but "); | |
2884 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) | |
2885 | vty_out (vty, "not the NSSA Elected Translator. %s", | |
2886 | VTY_NEWLINE); | |
2887 | else | |
c6b87819 | 2888 | vty_out (vty, "never an NSSA Translator. %s", |
b0a053be | 2889 | VTY_NEWLINE); |
2890 | } | |
718e3744 | 2891 | } |
88d6cf37 | 2892 | /* Stub-router state for this area */ |
2893 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)) | |
2894 | { | |
649654ab | 2895 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
88d6cf37 | 2896 | vty_out (vty, " Originating stub / maximum-distance Router-LSA%s", |
2897 | VTY_NEWLINE); | |
2898 | if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) | |
2899 | vty_out (vty, " Administratively activated (indefinitely)%s", | |
2900 | VTY_NEWLINE); | |
2901 | if (area->t_stub_router) | |
2902 | vty_out (vty, " Active from startup, %s remaining%s", | |
2903 | ospf_timer_dump (area->t_stub_router, timebuf, | |
2904 | sizeof(timebuf)), VTY_NEWLINE); | |
2905 | } | |
2906 | ||
718e3744 | 2907 | /* Show number of fully adjacent neighbors. */ |
2908 | vty_out (vty, " Number of fully adjacent neighbors in this area:" | |
b0a053be | 2909 | " %d%s", area->full_nbrs, VTY_NEWLINE); |
718e3744 | 2910 | |
2911 | /* Show authentication type. */ | |
2912 | vty_out (vty, " Area has "); | |
2913 | if (area->auth_type == OSPF_AUTH_NULL) | |
2914 | vty_out (vty, "no authentication%s", VTY_NEWLINE); | |
2915 | else if (area->auth_type == OSPF_AUTH_SIMPLE) | |
2916 | vty_out (vty, "simple password authentication%s", VTY_NEWLINE); | |
2917 | else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) | |
2918 | vty_out (vty, "message digest authentication%s", VTY_NEWLINE); | |
2919 | ||
2920 | if (!OSPF_IS_AREA_BACKBONE (area)) | |
2921 | vty_out (vty, " Number of full virtual adjacencies going through" | |
2922 | " this area: %d%s", area->full_vls, VTY_NEWLINE); | |
2923 | ||
2924 | /* Show SPF calculation times. */ | |
2925 | vty_out (vty, " SPF algorithm executed %d times%s", | |
2926 | area->spf_calculation, VTY_NEWLINE); | |
2927 | ||
2928 | /* Show number of LSA. */ | |
2929 | vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE); | |
fe71a97d | 2930 | vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s", |
2931 | ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA), | |
2932 | ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE); | |
2933 | vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s", | |
2934 | ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA), | |
2935 | ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE); | |
2936 | vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s", | |
2937 | ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA), | |
2938 | ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE); | |
2939 | vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s", | |
2940 | ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA), | |
2941 | ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE); | |
2942 | vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s", | |
2943 | ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA), | |
2944 | ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE); | |
2945 | #ifdef HAVE_OPAQUE_LSA | |
2946 | vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s", | |
2947 | ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA), | |
2948 | ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE); | |
2949 | vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s", | |
2950 | ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA), | |
2951 | ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE); | |
2952 | #endif /* HAVE_OPAQUE_LSA */ | |
718e3744 | 2953 | vty_out (vty, "%s", VTY_NEWLINE); |
2954 | } | |
2955 | ||
7c8ff89e DS |
2956 | static int |
2957 | show_ip_ospf_common (struct vty *vty, struct ospf *ospf) | |
718e3744 | 2958 | { |
1eb8ef25 | 2959 | struct listnode *node, *nnode; |
718e3744 | 2960 | struct ospf_area * area; |
d24f6e2a | 2961 | struct timeval result; |
649654ab | 2962 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
718e3744 | 2963 | |
7c8ff89e DS |
2964 | if (ospf->instance) |
2965 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
2966 | VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 2967 | |
2968 | /* Show Router ID. */ | |
2969 | vty_out (vty, " OSPF Routing Process, Router ID: %s%s", | |
68980084 | 2970 | inet_ntoa (ospf->router_id), |
718e3744 | 2971 | VTY_NEWLINE); |
7c8ff89e | 2972 | |
88d6cf37 | 2973 | /* Graceful shutdown */ |
c9c93d50 | 2974 | if (ospf->t_deferred_shutdown) |
2975 | vty_out (vty, " Deferred shutdown in progress, %s remaining%s", | |
2976 | ospf_timer_dump (ospf->t_deferred_shutdown, | |
88d6cf37 | 2977 | timebuf, sizeof (timebuf)), VTY_NEWLINE); |
718e3744 | 2978 | /* Show capability. */ |
2979 | vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE); | |
2980 | vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE); | |
2981 | vty_out (vty, " RFC1583Compatibility flag is %s%s", | |
68980084 | 2982 | CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ? |
718e3744 | 2983 | "enabled" : "disabled", VTY_NEWLINE); |
2984 | #ifdef HAVE_OPAQUE_LSA | |
2985 | vty_out (vty, " OpaqueCapability flag is %s%s%s", | |
68980084 | 2986 | CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ? |
718e3744 | 2987 | "enabled" : "disabled", |
68980084 | 2988 | IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ? |
718e3744 | 2989 | " (origination blocked)" : "", |
2990 | VTY_NEWLINE); | |
2991 | #endif /* HAVE_OPAQUE_LSA */ | |
88d6cf37 | 2992 | |
2993 | /* Show stub-router configuration */ | |
2994 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED | |
2995 | || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
2996 | { | |
2997 | vty_out (vty, " Stub router advertisement is configured%s", | |
2998 | VTY_NEWLINE); | |
2999 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3000 | vty_out (vty, " Enabled for %us after start-up%s", | |
3001 | ospf->stub_router_startup_time, VTY_NEWLINE); | |
3002 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3003 | vty_out (vty, " Enabled for %us prior to full shutdown%s", | |
3004 | ospf->stub_router_shutdown_time, VTY_NEWLINE); | |
3005 | } | |
3006 | ||
718e3744 | 3007 | /* Show SPF timers. */ |
d24f6e2a | 3008 | vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s" |
3009 | " Minimum hold time between consecutive SPFs %d millisec(s)%s" | |
3010 | " Maximum hold time between consecutive SPFs %d millisec(s)%s" | |
3011 | " Hold time multiplier is currently %d%s", | |
3012 | ospf->spf_delay, VTY_NEWLINE, | |
3013 | ospf->spf_holdtime, VTY_NEWLINE, | |
3014 | ospf->spf_max_holdtime, VTY_NEWLINE, | |
3015 | ospf->spf_hold_multiplier, VTY_NEWLINE); | |
b8ad39d4 | 3016 | vty_out (vty, " SPF algorithm "); |
3017 | if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec) | |
3018 | { | |
2518efd1 | 3019 | result = tv_sub (recent_relative_time (), ospf->ts_spf); |
b8ad39d4 | 3020 | vty_out (vty, "last executed %s ago%s", |
3021 | ospf_timeval_dump (&result, timebuf, sizeof (timebuf)), | |
3022 | VTY_NEWLINE); | |
cf744958 DS |
3023 | vty_out (vty, " Last SPF duration %s%s", |
3024 | ospf_timeval_dump (&ospf->ts_spf_duration, timebuf, sizeof (timebuf)), | |
3025 | VTY_NEWLINE); | |
b8ad39d4 | 3026 | } |
3027 | else | |
3028 | vty_out (vty, "has not been run%s", VTY_NEWLINE); | |
d24f6e2a | 3029 | vty_out (vty, " SPF timer %s%s%s", |
3030 | (ospf->t_spf_calc ? "due in " : "is "), | |
3031 | ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)), | |
3032 | VTY_NEWLINE); | |
3033 | ||
2f8f370e DS |
3034 | /* Show write multiplier values */ |
3035 | vty_out (vty, " Write Multiplier set to %d %s", | |
e8f45e82 | 3036 | ospf->write_oi_count, VTY_NEWLINE); |
2f8f370e | 3037 | |
718e3744 | 3038 | /* Show refresh parameters. */ |
3039 | vty_out (vty, " Refresh timer %d secs%s", | |
68980084 | 3040 | ospf->lsa_refresh_interval, VTY_NEWLINE); |
718e3744 | 3041 | |
3042 | /* Show ABR/ASBR flags. */ | |
68980084 | 3043 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR)) |
718e3744 | 3044 | vty_out (vty, " This router is an ABR, ABR type is: %s%s", |
68980084 | 3045 | ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE); |
718e3744 | 3046 | |
68980084 | 3047 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR)) |
718e3744 | 3048 | vty_out (vty, " This router is an ASBR " |
3049 | "(injecting external routing information)%s", VTY_NEWLINE); | |
3050 | ||
3051 | /* Show Number of AS-external-LSAs. */ | |
fe71a97d | 3052 | vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s", |
3053 | ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), | |
3054 | ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE); | |
3055 | #ifdef HAVE_OPAQUE_LSA | |
3056 | vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s", | |
3057 | ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA), | |
3058 | ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE); | |
3059 | #endif /* HAVE_OPAQUE_LSA */ | |
718e3744 | 3060 | /* Show number of areas attached. */ |
d7e60dd7 AS |
3061 | vty_out (vty, " Number of areas attached to this router: %d%s", |
3062 | listcount (ospf->areas), VTY_NEWLINE); | |
3063 | ||
3064 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES)) | |
3065 | { | |
3066 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) | |
3067 | vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE); | |
3068 | else | |
3069 | vty_out(vty, " Adjacency changes are logged%s",VTY_NEWLINE); | |
3070 | } | |
3071 | ||
3072 | vty_out (vty, "%s",VTY_NEWLINE); | |
718e3744 | 3073 | |
3074 | /* Show each area status. */ | |
1eb8ef25 | 3075 | for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area)) |
3076 | show_ip_ospf_area (vty, area); | |
718e3744 | 3077 | |
3078 | return CMD_SUCCESS; | |
3079 | } | |
3080 | ||
7c8ff89e DS |
3081 | DEFUN (show_ip_ospf, |
3082 | show_ip_ospf_cmd, | |
3083 | "show ip ospf", | |
3084 | SHOW_STR | |
3085 | IP_STR | |
3086 | "OSPF information\n") | |
3087 | ||
3088 | { | |
3089 | struct ospf *ospf; | |
3090 | ||
0bad4851 | 3091 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3092 | return CMD_SUCCESS; |
3093 | ||
3094 | return (show_ip_ospf_common(vty, ospf)); | |
3095 | } | |
3096 | ||
3097 | DEFUN (show_ip_ospf_instance, | |
3098 | show_ip_ospf_instance_cmd, | |
3099 | "show ip ospf <1-65535>", | |
3100 | SHOW_STR | |
3101 | IP_STR | |
3102 | "OSPF information\n" | |
3103 | "Instance ID\n") | |
3104 | { | |
3105 | struct ospf *ospf; | |
3106 | u_short instance = 0; | |
3107 | ||
3108 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 3109 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3110 | return CMD_SUCCESS; |
3111 | ||
3112 | return (show_ip_ospf_common(vty, ospf)); | |
3113 | } | |
3114 | ||
6b0655a2 | 3115 | |
fd651fa6 | 3116 | static void |
68980084 | 3117 | show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, |
3118 | struct interface *ifp) | |
718e3744 | 3119 | { |
fd651fa6 | 3120 | int is_up; |
718e3744 | 3121 | struct ospf_neighbor *nbr; |
718e3744 | 3122 | struct route_node *rn; |
718e3744 | 3123 | |
718e3744 | 3124 | /* Is interface up? */ |
fd651fa6 | 3125 | vty_out (vty, "%s is %s%s", ifp->name, |
3126 | ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE); | |
d2fc8896 | 3127 | vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s", |
3128 | ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags), | |
3129 | VTY_NEWLINE); | |
718e3744 | 3130 | |
3131 | /* Is interface OSPF enabled? */ | |
fd651fa6 | 3132 | if (ospf_oi_count(ifp) == 0) |
718e3744 | 3133 | { |
3134 | vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE); | |
3135 | return; | |
3136 | } | |
fd651fa6 | 3137 | else if (!is_up) |
3138 | { | |
3139 | vty_out (vty, " OSPF is enabled, but not running on this interface%s", | |
3140 | VTY_NEWLINE); | |
3141 | return; | |
3142 | } | |
3143 | ||
718e3744 | 3144 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
3145 | { | |
3146 | struct ospf_interface *oi = rn->info; | |
3147 | ||
3148 | if (oi == NULL) | |
3149 | continue; | |
3150 | ||
525c1839 DS |
3151 | if (CHECK_FLAG(oi->connected->flags, ZEBRA_IFA_UNNUMBERED)) |
3152 | { | |
3153 | vty_out (vty, " This interface is UNNUMBERED,"); | |
3154 | } | |
3155 | else | |
9c27ef9b | 3156 | { |
525c1839 DS |
3157 | /* Show OSPF interface information. */ |
3158 | vty_out (vty, " Internet Address %s/%d,", | |
3159 | inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen); | |
3160 | ||
3161 | if (oi->connected->destination || oi->type == OSPF_IFTYPE_VIRTUALLINK) | |
3162 | { | |
3163 | struct in_addr *dest; | |
3164 | const char *dstr; | |
3165 | ||
3166 | if (CONNECTED_PEER(oi->connected) | |
3167 | || oi->type == OSPF_IFTYPE_VIRTUALLINK) | |
3168 | dstr = "Peer"; | |
3169 | else | |
3170 | dstr = "Broadcast"; | |
3171 | ||
3172 | /* For Vlinks, showing the peer address is probably more | |
3173 | * informative than the local interface that is being used | |
3174 | */ | |
3175 | if (oi->type == OSPF_IFTYPE_VIRTUALLINK) | |
3176 | dest = &oi->vl_data->peer_addr; | |
3177 | else | |
3178 | dest = &oi->connected->destination->u.prefix4; | |
3179 | ||
3180 | vty_out (vty, " %s %s,", dstr, inet_ntoa (*dest)); | |
3181 | } | |
9c27ef9b | 3182 | } |
3fb9cd6e | 3183 | |
718e3744 | 3184 | vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area), |
3185 | VTY_NEWLINE); | |
3186 | ||
ba682537 | 3187 | vty_out (vty, " MTU mismatch detection:%s%s", |
3188 | OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE); | |
3189 | ||
718e3744 | 3190 | vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s", |
68980084 | 3191 | inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type], |
718e3744 | 3192 | oi->output_cost, VTY_NEWLINE); |
3193 | ||
3194 | vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s", | |
3195 | OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state), | |
3196 | PRIORITY (oi), VTY_NEWLINE); | |
3197 | ||
3198 | /* Show DR information. */ | |
3199 | if (DR (oi).s_addr == 0) | |
3200 | vty_out (vty, " No designated router on this network%s", VTY_NEWLINE); | |
3201 | else | |
3202 | { | |
3203 | nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi)); | |
3204 | if (nbr == NULL) | |
3205 | vty_out (vty, " No designated router on this network%s", VTY_NEWLINE); | |
3206 | else | |
3207 | { | |
3208 | vty_out (vty, " Designated Router (ID) %s,", | |
3209 | inet_ntoa (nbr->router_id)); | |
3210 | vty_out (vty, " Interface Address %s%s", | |
3211 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); | |
3212 | } | |
3213 | } | |
3214 | ||
3215 | /* Show BDR information. */ | |
3216 | if (BDR (oi).s_addr == 0) | |
3217 | vty_out (vty, " No backup designated router on this network%s", | |
3218 | VTY_NEWLINE); | |
3219 | else | |
3220 | { | |
3221 | nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi)); | |
3222 | if (nbr == NULL) | |
3223 | vty_out (vty, " No backup designated router on this network%s", | |
3224 | VTY_NEWLINE); | |
3225 | else | |
3226 | { | |
3227 | vty_out (vty, " Backup Designated Router (ID) %s,", | |
3228 | inet_ntoa (nbr->router_id)); | |
3229 | vty_out (vty, " Interface Address %s%s", | |
3230 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); | |
3231 | } | |
3232 | } | |
525c1839 | 3233 | |
7eb5b47e PJ |
3234 | /* Next network-LSA sequence number we'll use, if we're elected DR */ |
3235 | if (oi->params && ntohl (oi->params->network_lsa_seqnum) | |
3236 | != OSPF_INITIAL_SEQUENCE_NUMBER) | |
3237 | vty_out (vty, " Saved Network-LSA sequence number 0x%x%s", | |
3238 | ntohl (oi->params->network_lsa_seqnum), VTY_NEWLINE); | |
3239 | ||
ba6454ec | 3240 | vty_out (vty, " Multicast group memberships:"); |
429ac78c PJ |
3241 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS) |
3242 | || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) | |
3243 | { | |
3244 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)) | |
3245 | vty_out (vty, " OSPFAllRouters"); | |
3246 | if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) | |
3247 | vty_out (vty, " OSPFDesignatedRouters"); | |
3248 | } | |
3249 | else | |
ba6454ec | 3250 | vty_out (vty, " <None>"); |
3251 | vty_out (vty, "%s", VTY_NEWLINE); | |
3252 | ||
718e3744 | 3253 | vty_out (vty, " Timer intervals configured,"); |
f9ad937f | 3254 | vty_out (vty, " Hello "); |
3255 | if (OSPF_IF_PARAM (oi, fast_hello) == 0) | |
3256 | vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello)); | |
3257 | else | |
3258 | vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello)); | |
3259 | vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s", | |
3260 | OSPF_IF_PARAM (oi, v_wait), | |
718e3744 | 3261 | OSPF_IF_PARAM (oi, v_wait), |
3262 | OSPF_IF_PARAM (oi, retransmit_interval), | |
3263 | VTY_NEWLINE); | |
3264 | ||
7ffa8fa2 | 3265 | if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_ACTIVE) |
f9ad937f | 3266 | { |
649654ab | 3267 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
f9ad937f | 3268 | vty_out (vty, " Hello due in %s%s", |
649654ab | 3269 | ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)), |
f9ad937f | 3270 | VTY_NEWLINE); |
3271 | } | |
7ffa8fa2 | 3272 | else /* passive-interface is set */ |
718e3744 | 3273 | vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE); |
3274 | ||
3275 | vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s", | |
68980084 | 3276 | ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full), |
718e3744 | 3277 | VTY_NEWLINE); |
3278 | } | |
3279 | } | |
3280 | ||
7c8ff89e DS |
3281 | static int |
3282 | show_ip_ospf_interface_common (struct vty *vty, struct ospf *ospf, int arg_base, | |
3283 | int argc, const char **argv) | |
718e3744 | 3284 | { |
3285 | struct interface *ifp; | |
52dc7ee6 | 3286 | struct listnode *node; |
718e3744 | 3287 | |
7c8ff89e DS |
3288 | if (ospf->instance) |
3289 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
3290 | VTY_NEWLINE, VTY_NEWLINE); | |
3291 | ||
3292 | if (argc == arg_base + 0) | |
cac3b5c4 | 3293 | { |
7c8ff89e DS |
3294 | /* Show All Interfaces. */ |
3295 | for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) | |
3296 | if (ospf_oi_count(ifp)) | |
3297 | show_ip_ospf_interface_sub (vty, ospf, ifp); | |
cac3b5c4 | 3298 | } |
718e3744 | 3299 | else |
3300 | { | |
7c8ff89e DS |
3301 | /* Interface name is specified. */ |
3302 | if ((ifp = if_lookup_by_name (argv[arg_base + 0])) == NULL) | |
718e3744 | 3303 | vty_out (vty, "No such interface name%s", VTY_NEWLINE); |
3304 | else | |
68980084 | 3305 | show_ip_ospf_interface_sub (vty, ospf, ifp); |
718e3744 | 3306 | } |
3307 | ||
7c8ff89e DS |
3308 | vty_out (vty, "%s", VTY_NEWLINE); |
3309 | ||
718e3744 | 3310 | return CMD_SUCCESS; |
3311 | } | |
3312 | ||
7c8ff89e DS |
3313 | DEFUN (show_ip_ospf_interface, |
3314 | show_ip_ospf_interface_cmd, | |
3315 | "show ip ospf interface [INTERFACE]", | |
3316 | SHOW_STR | |
3317 | IP_STR | |
3318 | "OSPF information\n" | |
3319 | "Interface information\n" | |
3320 | "Interface name\n") | |
3321 | { | |
3322 | struct ospf *ospf; | |
3323 | ||
0bad4851 | 3324 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3325 | return CMD_SUCCESS; |
3326 | ||
3327 | return show_ip_ospf_interface_common(vty, ospf, 0, argc, argv); | |
3328 | } | |
3329 | ||
3330 | DEFUN (show_ip_ospf_instance_interface, | |
3331 | show_ip_ospf_instance_interface_cmd, | |
3332 | "show ip ospf <1-65535> interface [INTERFACE]", | |
3333 | SHOW_STR | |
3334 | IP_STR | |
3335 | "OSPF information\n" | |
3336 | "Instance ID\n" | |
3337 | "Interface information\n" | |
3338 | "Interface name\n") | |
3339 | { | |
3340 | struct ospf *ospf; | |
3341 | u_short instance = 0; | |
3342 | ||
3343 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 3344 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3345 | return CMD_SUCCESS; |
3346 | ||
3347 | return show_ip_ospf_interface_common(vty, ospf, 1, argc, argv); | |
3348 | } | |
3349 | ||
d24f6e2a | 3350 | static void |
3351 | show_ip_ospf_neighbour_header (struct vty *vty) | |
3352 | { | |
490578f3 | 3353 | vty_out (vty, "%s%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s", |
d24f6e2a | 3354 | VTY_NEWLINE, |
3355 | "Neighbor ID", "Pri", "State", "Dead Time", | |
3356 | "Address", "Interface", "RXmtL", "RqstL", "DBsmL", | |
3357 | VTY_NEWLINE); | |
3358 | } | |
3359 | ||
4dadc291 | 3360 | static void |
718e3744 | 3361 | show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi) |
3362 | { | |
3363 | struct route_node *rn; | |
3364 | struct ospf_neighbor *nbr; | |
3365 | char msgbuf[16]; | |
649654ab | 3366 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
718e3744 | 3367 | |
3368 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) | |
3369 | if ((nbr = rn->info)) | |
3370 | /* Do not show myself. */ | |
3371 | if (nbr != oi->nbr_self) | |
3372 | /* Down state is not shown. */ | |
3373 | if (nbr->state != NSM_Down) | |
3374 | { | |
3375 | ospf_nbr_state_message (nbr, msgbuf, 16); | |
3376 | ||
3377 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) | |
d24f6e2a | 3378 | vty_out (vty, "%-15s %3d %-15s ", |
3379 | "-", nbr->priority, | |
3380 | msgbuf); | |
3381 | else | |
3382 | vty_out (vty, "%-15s %3d %-15s ", | |
3383 | inet_ntoa (nbr->router_id), nbr->priority, | |
3384 | msgbuf); | |
3385 | ||
3386 | vty_out (vty, "%9s ", | |
3387 | ospf_timer_dump (nbr->t_inactivity, timebuf, | |
3388 | sizeof(timebuf))); | |
3389 | ||
718e3744 | 3390 | vty_out (vty, "%-15s ", inet_ntoa (nbr->src)); |
d24f6e2a | 3391 | vty_out (vty, "%-20s %5ld %5ld %5d%s", |
718e3744 | 3392 | IF_NAME (oi), ospf_ls_retransmit_count (nbr), |
3393 | ospf_ls_request_count (nbr), ospf_db_summary_count (nbr), | |
3394 | VTY_NEWLINE); | |
3395 | } | |
3396 | } | |
3397 | ||
7c8ff89e DS |
3398 | static int |
3399 | show_ip_ospf_neighbor_common (struct vty *vty, struct ospf *ospf) | |
718e3744 | 3400 | { |
1eb8ef25 | 3401 | struct ospf_interface *oi; |
52dc7ee6 | 3402 | struct listnode *node; |
718e3744 | 3403 | |
7c8ff89e DS |
3404 | if (ospf->instance) |
3405 | vty_out (vty, "%sOSPF Instance: %d%s", VTY_NEWLINE, ospf->instance, VTY_NEWLINE); | |
718e3744 | 3406 | |
d24f6e2a | 3407 | show_ip_ospf_neighbour_header (vty); |
718e3744 | 3408 | |
1eb8ef25 | 3409 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
3410 | show_ip_ospf_neighbor_sub (vty, oi); | |
718e3744 | 3411 | |
7c8ff89e DS |
3412 | vty_out (vty, "%s", VTY_NEWLINE); |
3413 | ||
718e3744 | 3414 | return CMD_SUCCESS; |
3415 | } | |
3416 | ||
7c8ff89e DS |
3417 | DEFUN (show_ip_ospf_neighbor, |
3418 | show_ip_ospf_neighbor_cmd, | |
3419 | "show ip ospf neighbor", | |
718e3744 | 3420 | SHOW_STR |
3421 | IP_STR | |
3422 | "OSPF information\n" | |
7c8ff89e | 3423 | "Neighbor list\n") |
718e3744 | 3424 | { |
7c8ff89e | 3425 | struct ospf *ospf; |
718e3744 | 3426 | |
0bad4851 | 3427 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3428 | return CMD_SUCCESS; |
3429 | ||
3430 | return show_ip_ospf_neighbor_common(vty, ospf); | |
3431 | } | |
3432 | ||
3433 | ||
3434 | DEFUN (show_ip_ospf_instance_neighbor, | |
3435 | show_ip_ospf_instance_neighbor_cmd, | |
3436 | "show ip ospf <1-65535> neighbor", | |
3437 | SHOW_STR | |
3438 | IP_STR | |
3439 | "OSPF information\n" | |
3440 | "Instance ID\n" | |
3441 | "Neighbor list\n") | |
3442 | { | |
3443 | struct ospf *ospf; | |
3444 | u_short instance = 0; | |
3445 | ||
3446 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 3447 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3448 | return CMD_SUCCESS; |
3449 | ||
3450 | return show_ip_ospf_neighbor_common(vty, ospf); | |
3451 | } | |
3452 | ||
3453 | static int | |
3454 | show_ip_ospf_neighbor_all_common (struct vty *vty, struct ospf *ospf) | |
3455 | { | |
3456 | struct listnode *node; | |
3457 | struct ospf_interface *oi; | |
3458 | ||
3459 | if (ospf->instance) | |
3460 | vty_out (vty, "%sOSPF Instance: %d%s", VTY_NEWLINE, ospf->instance, VTY_NEWLINE); | |
3461 | ||
3462 | show_ip_ospf_neighbour_header (vty); | |
3463 | ||
3464 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) | |
3465 | { | |
52dc7ee6 | 3466 | struct listnode *nbr_node; |
1eb8ef25 | 3467 | struct ospf_nbr_nbma *nbr_nbma; |
718e3744 | 3468 | |
3469 | show_ip_ospf_neighbor_sub (vty, oi); | |
3470 | ||
3471 | /* print Down neighbor status */ | |
1eb8ef25 | 3472 | for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma)) |
718e3744 | 3473 | { |
718e3744 | 3474 | if (nbr_nbma->nbr == NULL |
3475 | || nbr_nbma->nbr->state == NSM_Down) | |
3476 | { | |
d24f6e2a | 3477 | vty_out (vty, "%-15s %3d %-15s %9s ", |
718e3744 | 3478 | "-", nbr_nbma->priority, "Down", "-"); |
d24f6e2a | 3479 | vty_out (vty, "%-15s %-20s %5d %5d %5d%s", |
718e3744 | 3480 | inet_ntoa (nbr_nbma->addr), IF_NAME (oi), |
3481 | 0, 0, 0, VTY_NEWLINE); | |
3482 | } | |
3483 | } | |
3484 | } | |
3485 | ||
7c8ff89e DS |
3486 | vty_out (vty, "%s", VTY_NEWLINE); |
3487 | ||
718e3744 | 3488 | return CMD_SUCCESS; |
3489 | } | |
3490 | ||
7c8ff89e DS |
3491 | DEFUN (show_ip_ospf_neighbor_all, |
3492 | show_ip_ospf_neighbor_all_cmd, | |
3493 | "show ip ospf neighbor all", | |
718e3744 | 3494 | SHOW_STR |
3495 | IP_STR | |
3496 | "OSPF information\n" | |
3497 | "Neighbor list\n" | |
7c8ff89e DS |
3498 | "include down status neighbor\n") |
3499 | { | |
3500 | struct ospf *ospf; | |
3501 | ||
0bad4851 | 3502 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3503 | return CMD_SUCCESS; |
3504 | ||
3505 | return show_ip_ospf_neighbor_all_common(vty, ospf); | |
3506 | } | |
3507 | ||
3508 | DEFUN (show_ip_ospf_instance_neighbor_all, | |
3509 | show_ip_ospf_instance_neighbor_all_cmd, | |
3510 | "show ip ospf <1-65535> neighbor all", | |
3511 | SHOW_STR | |
3512 | IP_STR | |
3513 | "OSPF information\n" | |
3514 | "Instance ID\n" | |
3515 | "Neighbor list\n" | |
3516 | "include down status neighbor\n") | |
718e3744 | 3517 | { |
020709f9 | 3518 | struct ospf *ospf; |
7c8ff89e DS |
3519 | u_short instance = 0; |
3520 | ||
3521 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 3522 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3523 | return CMD_SUCCESS; |
3524 | ||
3525 | return show_ip_ospf_neighbor_all_common(vty, ospf); | |
3526 | } | |
3527 | ||
3528 | static int | |
3529 | show_ip_ospf_neighbor_int_common (struct vty *vty, struct ospf *ospf, int arg_base, | |
3530 | const char **argv) | |
3531 | { | |
bb5b7552 | 3532 | struct interface *ifp; |
3533 | struct route_node *rn; | |
7c8ff89e DS |
3534 | |
3535 | if (ospf->instance) | |
3536 | vty_out (vty, "%sOSPF Instance: %d%s", VTY_NEWLINE, ospf->instance, VTY_NEWLINE); | |
3537 | ||
3538 | ifp = if_lookup_by_name (argv[arg_base + 0]); | |
bb5b7552 | 3539 | if (!ifp) |
718e3744 | 3540 | { |
bb5b7552 | 3541 | vty_out (vty, "No such interface.%s", VTY_NEWLINE); |
718e3744 | 3542 | return CMD_WARNING; |
3543 | } | |
d24f6e2a | 3544 | |
3545 | show_ip_ospf_neighbour_header (vty); | |
3546 | ||
bb5b7552 | 3547 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
718e3744 | 3548 | { |
bb5b7552 | 3549 | struct ospf_interface *oi = rn->info; |
3550 | ||
3551 | if (oi == NULL) | |
3552 | continue; | |
3553 | ||
718e3744 | 3554 | show_ip_ospf_neighbor_sub (vty, oi); |
3555 | } | |
3556 | ||
3557 | return CMD_SUCCESS; | |
3558 | } | |
3559 | ||
7c8ff89e DS |
3560 | DEFUN (show_ip_ospf_neighbor_int, |
3561 | show_ip_ospf_neighbor_int_cmd, | |
3562 | "show ip ospf neighbor IFNAME", | |
3563 | SHOW_STR | |
3564 | IP_STR | |
3565 | "OSPF information\n" | |
3566 | "Neighbor list\n" | |
3567 | "Interface name\n") | |
3568 | { | |
3569 | struct ospf *ospf; | |
3570 | ||
0bad4851 | 3571 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3572 | return CMD_SUCCESS; |
3573 | ||
3574 | return show_ip_ospf_neighbor_int_common(vty, ospf, 0, argv); | |
3575 | } | |
3576 | ||
3577 | DEFUN (show_ip_ospf_instance_neighbor_int, | |
3578 | show_ip_ospf_instance_neighbor_int_cmd, | |
3579 | "show ip ospf <1-65535> neighbor IFNAME", | |
3580 | SHOW_STR | |
3581 | IP_STR | |
3582 | "OSPF information\n" | |
3583 | "Instance ID\n" | |
3584 | "Neighbor list\n" | |
3585 | "Interface name\n") | |
3586 | { | |
3587 | struct ospf *ospf; | |
3588 | u_short instance = 0; | |
3589 | ||
3590 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 3591 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3592 | return CMD_SUCCESS; |
3593 | ||
3594 | return show_ip_ospf_neighbor_int_common(vty, ospf, 1, argv); | |
3595 | } | |
3596 | ||
4dadc291 | 3597 | static void |
718e3744 | 3598 | show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi, |
3599 | struct ospf_nbr_nbma *nbr_nbma) | |
3600 | { | |
649654ab | 3601 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
718e3744 | 3602 | |
3603 | /* Show neighbor ID. */ | |
3604 | vty_out (vty, " Neighbor %s,", "-"); | |
3605 | ||
3606 | /* Show interface address. */ | |
3607 | vty_out (vty, " interface address %s%s", | |
3608 | inet_ntoa (nbr_nbma->addr), VTY_NEWLINE); | |
3609 | /* Show Area ID. */ | |
3610 | vty_out (vty, " In the area %s via interface %s%s", | |
3611 | ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE); | |
3612 | /* Show neighbor priority and state. */ | |
3613 | vty_out (vty, " Neighbor priority is %d, State is %s,", | |
3614 | nbr_nbma->priority, "Down"); | |
3615 | /* Show state changes. */ | |
3616 | vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE); | |
3617 | ||
3618 | /* Show PollInterval */ | |
3619 | vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE); | |
3620 | ||
3621 | /* Show poll-interval timer. */ | |
3622 | vty_out (vty, " Poll timer due in %s%s", | |
d24f6e2a | 3623 | ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)), |
3624 | VTY_NEWLINE); | |
718e3744 | 3625 | |
3626 | /* Show poll-interval timer thread. */ | |
3627 | vty_out (vty, " Thread Poll Timer %s%s", | |
3628 | nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE); | |
3629 | } | |
3630 | ||
4dadc291 | 3631 | static void |
718e3744 | 3632 | show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, |
3633 | struct ospf_neighbor *nbr) | |
3634 | { | |
649654ab | 3635 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
718e3744 | 3636 | |
3637 | /* Show neighbor ID. */ | |
3638 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) | |
3639 | vty_out (vty, " Neighbor %s,", "-"); | |
3640 | else | |
3641 | vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id)); | |
3642 | ||
3643 | /* Show interface address. */ | |
3644 | vty_out (vty, " interface address %s%s", | |
3645 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); | |
3646 | /* Show Area ID. */ | |
3647 | vty_out (vty, " In the area %s via interface %s%s", | |
3648 | ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE); | |
3649 | /* Show neighbor priority and state. */ | |
3650 | vty_out (vty, " Neighbor priority is %d, State is %s,", | |
3651 | nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state)); | |
3652 | /* Show state changes. */ | |
3653 | vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE); | |
3fed4160 | 3654 | if (nbr->ts_last_progress.tv_sec || nbr->ts_last_progress.tv_usec) |
90c33177 | 3655 | { |
2518efd1 PJ |
3656 | struct timeval res |
3657 | = tv_sub (recent_relative_time (), nbr->ts_last_progress); | |
3fed4160 PJ |
3658 | vty_out (vty, " Most recent state change statistics:%s", |
3659 | VTY_NEWLINE); | |
3660 | vty_out (vty, " Progressive change %s ago%s", | |
3661 | ospf_timeval_dump (&res, timebuf, sizeof(timebuf)), | |
3662 | VTY_NEWLINE); | |
3663 | } | |
3664 | if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec) | |
3665 | { | |
2518efd1 PJ |
3666 | struct timeval res |
3667 | = tv_sub (recent_relative_time (), nbr->ts_last_regress); | |
3fed4160 | 3668 | vty_out (vty, " Regressive change %s ago, due to %s%s", |
90c33177 | 3669 | ospf_timeval_dump (&res, timebuf, sizeof(timebuf)), |
3fed4160 | 3670 | (nbr->last_regress_str ? nbr->last_regress_str : "??"), |
90c33177 PJ |
3671 | VTY_NEWLINE); |
3672 | } | |
718e3744 | 3673 | /* Show Designated Rotuer ID. */ |
3674 | vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router)); | |
3675 | /* Show Backup Designated Rotuer ID. */ | |
3676 | vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE); | |
3677 | /* Show options. */ | |
3678 | vty_out (vty, " Options %d %s%s", nbr->options, | |
3679 | ospf_options_dump (nbr->options), VTY_NEWLINE); | |
3680 | /* Show Router Dead interval timer. */ | |
3681 | vty_out (vty, " Dead timer due in %s%s", | |
d24f6e2a | 3682 | ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)), |
3683 | VTY_NEWLINE); | |
718e3744 | 3684 | /* Show Database Summary list. */ |
3685 | vty_out (vty, " Database Summary List %d%s", | |
3686 | ospf_db_summary_count (nbr), VTY_NEWLINE); | |
3687 | /* Show Link State Request list. */ | |
3688 | vty_out (vty, " Link State Request List %ld%s", | |
3689 | ospf_ls_request_count (nbr), VTY_NEWLINE); | |
3690 | /* Show Link State Retransmission list. */ | |
3691 | vty_out (vty, " Link State Retransmission List %ld%s", | |
3692 | ospf_ls_retransmit_count (nbr), VTY_NEWLINE); | |
3693 | /* Show inactivity timer thread. */ | |
3694 | vty_out (vty, " Thread Inactivity Timer %s%s", | |
3695 | nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE); | |
3696 | /* Show Database Description retransmission thread. */ | |
3697 | vty_out (vty, " Thread Database Description Retransmision %s%s", | |
3698 | nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE); | |
3699 | /* Show Link State Request Retransmission thread. */ | |
3700 | vty_out (vty, " Thread Link State Request Retransmission %s%s", | |
3701 | nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE); | |
3702 | /* Show Link State Update Retransmission thread. */ | |
3703 | vty_out (vty, " Thread Link State Update Retransmission %s%s%s", | |
3704 | nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE); | |
3705 | } | |
3706 | ||
7c8ff89e DS |
3707 | static int |
3708 | show_ip_ospf_neighbor_id_common (struct vty *vty, struct ospf *ospf, | |
3709 | int arg_base, const char **argv) | |
718e3744 | 3710 | { |
52dc7ee6 | 3711 | struct listnode *node; |
718e3744 | 3712 | struct ospf_neighbor *nbr; |
1eb8ef25 | 3713 | struct ospf_interface *oi; |
718e3744 | 3714 | struct in_addr router_id; |
3715 | int ret; | |
3716 | ||
7c8ff89e DS |
3717 | if (ospf->instance) |
3718 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
3719 | VTY_NEWLINE, VTY_NEWLINE); | |
3720 | ||
3721 | ret = inet_aton (argv[arg_base + 0], &router_id); | |
718e3744 | 3722 | if (!ret) |
3723 | { | |
3724 | vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE); | |
3725 | return CMD_WARNING; | |
3726 | } | |
3727 | ||
1eb8ef25 | 3728 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
3729 | if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id))) | |
1c066bfe | 3730 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); |
718e3744 | 3731 | |
718e3744 | 3732 | return CMD_SUCCESS; |
3733 | } | |
3734 | ||
7c8ff89e DS |
3735 | DEFUN (show_ip_ospf_neighbor_id, |
3736 | show_ip_ospf_neighbor_id_cmd, | |
3737 | "show ip ospf neighbor A.B.C.D", | |
718e3744 | 3738 | SHOW_STR |
3739 | IP_STR | |
3740 | "OSPF information\n" | |
3741 | "Neighbor list\n" | |
7c8ff89e | 3742 | "Neighbor ID\n") |
718e3744 | 3743 | { |
020709f9 | 3744 | struct ospf *ospf; |
7c8ff89e | 3745 | |
0bad4851 | 3746 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3747 | return CMD_SUCCESS; |
3748 | ||
3749 | return show_ip_ospf_neighbor_id_common(vty, ospf, 0, argv); | |
3750 | } | |
3751 | ||
3752 | DEFUN (show_ip_ospf_instance_neighbor_id, | |
3753 | show_ip_ospf_instance_neighbor_id_cmd, | |
3754 | "show ip ospf <1-65535> neighbor A.B.C.D", | |
3755 | SHOW_STR | |
3756 | IP_STR | |
3757 | "OSPF information\n" | |
3758 | "Instance ID\n" | |
3759 | "Neighbor list\n" | |
3760 | "Neighbor ID\n") | |
3761 | { | |
3762 | struct ospf *ospf; | |
3763 | u_short instance = 0; | |
3764 | ||
3765 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 3766 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3767 | return CMD_SUCCESS; |
3768 | ||
3769 | return show_ip_ospf_neighbor_id_common(vty, ospf, 1, argv); | |
3770 | } | |
3771 | ||
3772 | static int | |
3773 | show_ip_ospf_neighbor_detail_common (struct vty *vty, struct ospf *ospf) | |
3774 | { | |
1eb8ef25 | 3775 | struct ospf_interface *oi; |
52dc7ee6 | 3776 | struct listnode *node; |
718e3744 | 3777 | |
7c8ff89e DS |
3778 | if (ospf->instance) |
3779 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
3780 | VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 3781 | |
1eb8ef25 | 3782 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
718e3744 | 3783 | { |
718e3744 | 3784 | struct route_node *rn; |
3785 | struct ospf_neighbor *nbr; | |
3786 | ||
3787 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) | |
3788 | if ((nbr = rn->info)) | |
3789 | if (nbr != oi->nbr_self) | |
3790 | if (nbr->state != NSM_Down) | |
3791 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); | |
3792 | } | |
3793 | ||
3794 | return CMD_SUCCESS; | |
3795 | } | |
3796 | ||
7c8ff89e DS |
3797 | DEFUN (show_ip_ospf_neighbor_detail, |
3798 | show_ip_ospf_neighbor_detail_cmd, | |
3799 | "show ip ospf neighbor detail", | |
718e3744 | 3800 | SHOW_STR |
3801 | IP_STR | |
3802 | "OSPF information\n" | |
3803 | "Neighbor list\n" | |
7c8ff89e | 3804 | "detail of all neighbors\n") |
718e3744 | 3805 | { |
020709f9 | 3806 | struct ospf *ospf; |
7c8ff89e | 3807 | |
0bad4851 | 3808 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3809 | return CMD_SUCCESS; |
3810 | ||
3811 | return show_ip_ospf_neighbor_detail_common(vty, ospf); | |
3812 | } | |
3813 | ||
3814 | DEFUN (show_ip_ospf_instance_neighbor_detail, | |
3815 | show_ip_ospf_instance_neighbor_detail_cmd, | |
3816 | "show ip ospf <1-65535> neighbor detail", | |
3817 | SHOW_STR | |
3818 | IP_STR | |
3819 | "OSPF information\n" | |
3820 | "Instance ID\n" | |
3821 | "Neighbor list\n" | |
3822 | "detail of all neighbors\n") | |
3823 | { | |
3824 | struct ospf *ospf; | |
3825 | u_short instance = 0; | |
3826 | ||
3827 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 3828 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3829 | return CMD_SUCCESS; |
3830 | ||
3831 | return show_ip_ospf_neighbor_detail_common(vty, ospf); | |
3832 | } | |
3833 | ||
3834 | static int | |
3835 | show_ip_ospf_neighbor_detail_all_common (struct vty *vty, struct ospf *ospf) | |
3836 | { | |
52dc7ee6 | 3837 | struct listnode *node; |
1eb8ef25 | 3838 | struct ospf_interface *oi; |
718e3744 | 3839 | |
7c8ff89e DS |
3840 | if (ospf->instance) |
3841 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
3842 | VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 3843 | |
1eb8ef25 | 3844 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
718e3744 | 3845 | { |
718e3744 | 3846 | struct route_node *rn; |
3847 | struct ospf_neighbor *nbr; | |
1eb8ef25 | 3848 | struct ospf_nbr_nbma *nbr_nbma; |
718e3744 | 3849 | |
3850 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) | |
3851 | if ((nbr = rn->info)) | |
3852 | if (nbr != oi->nbr_self) | |
3853 | if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down) | |
3854 | show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info); | |
3855 | ||
3856 | if (oi->type == OSPF_IFTYPE_NBMA) | |
3857 | { | |
52dc7ee6 | 3858 | struct listnode *nd; |
718e3744 | 3859 | |
1eb8ef25 | 3860 | for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma)) |
3861 | if (nbr_nbma->nbr == NULL | |
3862 | || nbr_nbma->nbr->state == NSM_Down) | |
3863 | show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma); | |
718e3744 | 3864 | } |
3865 | } | |
3866 | ||
3867 | return CMD_SUCCESS; | |
3868 | } | |
3869 | ||
7c8ff89e DS |
3870 | DEFUN (show_ip_ospf_neighbor_detail_all, |
3871 | show_ip_ospf_neighbor_detail_all_cmd, | |
3872 | "show ip ospf neighbor detail all", | |
718e3744 | 3873 | SHOW_STR |
3874 | IP_STR | |
3875 | "OSPF information\n" | |
3876 | "Neighbor list\n" | |
7c8ff89e DS |
3877 | "detail of all neighbors\n" |
3878 | "include down status neighbor\n") | |
718e3744 | 3879 | { |
020709f9 | 3880 | struct ospf *ospf; |
7c8ff89e | 3881 | |
0bad4851 | 3882 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3883 | return CMD_SUCCESS; |
3884 | ||
3885 | return show_ip_ospf_neighbor_detail_all_common(vty, ospf); | |
3886 | } | |
3887 | ||
3888 | DEFUN (show_ip_ospf_instance_neighbor_detail_all, | |
3889 | show_ip_ospf_instance_neighbor_detail_all_cmd, | |
3890 | "show ip ospf <1-65535> neighbor detail all", | |
3891 | SHOW_STR | |
3892 | IP_STR | |
3893 | "OSPF information\n" | |
3894 | "Instance ID\n" | |
3895 | "Neighbor list\n" | |
3896 | "detail of all neighbors\n" | |
3897 | "include down status neighbor\n") | |
3898 | { | |
3899 | struct ospf *ospf; | |
3900 | u_short instance = 0; | |
3901 | ||
3902 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 3903 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3904 | return CMD_SUCCESS; |
3905 | ||
3906 | return show_ip_ospf_neighbor_detail_all_common(vty, ospf); | |
3907 | } | |
3908 | ||
3909 | static int | |
3910 | show_ip_ospf_neighbor_int_detail_common (struct vty *vty, struct ospf *ospf, | |
3911 | int arg_base, const char **argv) | |
3912 | { | |
718e3744 | 3913 | struct ospf_interface *oi; |
bb5b7552 | 3914 | struct interface *ifp; |
3915 | struct route_node *rn, *nrn; | |
3916 | struct ospf_neighbor *nbr; | |
3917 | ||
7c8ff89e DS |
3918 | if (ospf->instance) |
3919 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
3920 | VTY_NEWLINE, VTY_NEWLINE); | |
3921 | ||
3922 | ifp = if_lookup_by_name (argv[arg_base + 0]); | |
bb5b7552 | 3923 | if (!ifp) |
718e3744 | 3924 | { |
bb5b7552 | 3925 | vty_out (vty, "No such interface.%s", VTY_NEWLINE); |
718e3744 | 3926 | return CMD_WARNING; |
3927 | } | |
3928 | ||
bb5b7552 | 3929 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
3930 | if ((oi = rn->info)) | |
3931 | for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn)) | |
3932 | if ((nbr = nrn->info)) | |
718e3744 | 3933 | if (nbr != oi->nbr_self) |
3934 | if (nbr->state != NSM_Down) | |
3935 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); | |
718e3744 | 3936 | |
3937 | return CMD_SUCCESS; | |
3938 | } | |
3939 | ||
7c8ff89e DS |
3940 | DEFUN (show_ip_ospf_neighbor_int_detail, |
3941 | show_ip_ospf_neighbor_int_detail_cmd, | |
3942 | "show ip ospf neighbor IFNAME detail", | |
3943 | SHOW_STR | |
3944 | IP_STR | |
3945 | "OSPF information\n" | |
3946 | "Neighbor list\n" | |
3947 | "Interface name\n" | |
3948 | "detail of all neighbors") | |
3949 | { | |
3950 | struct ospf *ospf; | |
3951 | ||
0bad4851 | 3952 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3953 | return CMD_SUCCESS; |
3954 | ||
3955 | return show_ip_ospf_neighbor_int_detail_common(vty, ospf, 0, argv); | |
3956 | } | |
3957 | ||
3958 | DEFUN (show_ip_ospf_instance_neighbor_int_detail, | |
3959 | show_ip_ospf_instance_neighbor_int_detail_cmd, | |
3960 | "show ip ospf <1-65535> neighbor IFNAME detail", | |
3961 | SHOW_STR | |
3962 | IP_STR | |
3963 | "OSPF information\n" | |
3964 | "Instance ID\n" | |
3965 | "Neighbor list\n" | |
3966 | "Interface name\n" | |
3967 | "detail of all neighbors") | |
3968 | { | |
3969 | struct ospf *ospf; | |
3970 | u_short instance = 0; | |
3971 | ||
3972 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 3973 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3974 | return CMD_SUCCESS; |
3975 | ||
3976 | return show_ip_ospf_neighbor_int_detail_common(vty, ospf, 1, argv); | |
3977 | } | |
6b0655a2 | 3978 | |
718e3744 | 3979 | /* Show functions */ |
4dadc291 | 3980 | static int |
020709f9 | 3981 | show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self) |
718e3744 | 3982 | { |
718e3744 | 3983 | struct router_lsa *rl; |
3984 | struct summary_lsa *sl; | |
3985 | struct as_external_lsa *asel; | |
3986 | struct prefix_ipv4 p; | |
3987 | ||
3988 | if (lsa != NULL) | |
3989 | /* If self option is set, check LSA self flag. */ | |
3990 | if (self == 0 || IS_LSA_SELF (lsa)) | |
3991 | { | |
3992 | /* LSA common part show. */ | |
3993 | vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id)); | |
3994 | vty_out (vty, "%-15s %4d 0x%08lx 0x%04x", | |
3995 | inet_ntoa (lsa->data->adv_router), LS_AGE (lsa), | |
3996 | (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum)); | |
3997 | /* LSA specific part show. */ | |
3998 | switch (lsa->data->type) | |
3999 | { | |
4000 | case OSPF_ROUTER_LSA: | |
4001 | rl = (struct router_lsa *) lsa->data; | |
4002 | vty_out (vty, " %-d", ntohs (rl->links)); | |
4003 | break; | |
4004 | case OSPF_SUMMARY_LSA: | |
4005 | sl = (struct summary_lsa *) lsa->data; | |
4006 | ||
4007 | p.family = AF_INET; | |
4008 | p.prefix = sl->header.id; | |
4009 | p.prefixlen = ip_masklen (sl->mask); | |
4010 | apply_mask_ipv4 (&p); | |
4011 | ||
4012 | vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen); | |
4013 | break; | |
4014 | case OSPF_AS_EXTERNAL_LSA: | |
551a8979 | 4015 | case OSPF_AS_NSSA_LSA: |
718e3744 | 4016 | asel = (struct as_external_lsa *) lsa->data; |
4017 | ||
4018 | p.family = AF_INET; | |
4019 | p.prefix = asel->header.id; | |
4020 | p.prefixlen = ip_masklen (asel->mask); | |
4021 | apply_mask_ipv4 (&p); | |
4022 | ||
4023 | vty_out (vty, " %s %s/%d [0x%lx]", | |
4024 | IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1", | |
4025 | inet_ntoa (p.prefix), p.prefixlen, | |
4026 | (u_long)ntohl (asel->e[0].route_tag)); | |
4027 | break; | |
4028 | case OSPF_NETWORK_LSA: | |
4029 | case OSPF_ASBR_SUMMARY_LSA: | |
4030 | #ifdef HAVE_OPAQUE_LSA | |
4031 | case OSPF_OPAQUE_LINK_LSA: | |
4032 | case OSPF_OPAQUE_AREA_LSA: | |
4033 | case OSPF_OPAQUE_AS_LSA: | |
4034 | #endif /* HAVE_OPAQUE_LSA */ | |
4035 | default: | |
4036 | break; | |
4037 | } | |
4038 | vty_out (vty, VTY_NEWLINE); | |
4039 | } | |
4040 | ||
4041 | return 0; | |
4042 | } | |
4043 | ||
8b6a15b2 | 4044 | static const char *show_database_desc[] = |
718e3744 | 4045 | { |
4046 | "unknown", | |
4047 | "Router Link States", | |
4048 | "Net Link States", | |
4049 | "Summary Link States", | |
4050 | "ASBR-Summary Link States", | |
4051 | "AS External Link States", | |
718e3744 | 4052 | "Group Membership LSA", |
4053 | "NSSA-external Link States", | |
718e3744 | 4054 | #ifdef HAVE_OPAQUE_LSA |
4055 | "Type-8 LSA", | |
4056 | "Link-Local Opaque-LSA", | |
4057 | "Area-Local Opaque-LSA", | |
4058 | "AS-external Opaque-LSA", | |
4059 | #endif /* HAVE_OPAQUE_LSA */ | |
4060 | }; | |
4061 | ||
8b6a15b2 | 4062 | static const char *show_database_header[] = |
718e3744 | 4063 | { |
4064 | "", | |
4065 | "Link ID ADV Router Age Seq# CkSum Link count", | |
4066 | "Link ID ADV Router Age Seq# CkSum", | |
4067 | "Link ID ADV Router Age Seq# CkSum Route", | |
4068 | "Link ID ADV Router Age Seq# CkSum", | |
4069 | "Link ID ADV Router Age Seq# CkSum Route", | |
718e3744 | 4070 | " --- header for Group Member ----", |
4071 | "Link ID ADV Router Age Seq# CkSum Route", | |
718e3744 | 4072 | #ifdef HAVE_OPAQUE_LSA |
718e3744 | 4073 | " --- type-8 ---", |
4074 | "Opaque-Type/Id ADV Router Age Seq# CkSum", | |
4075 | "Opaque-Type/Id ADV Router Age Seq# CkSum", | |
4076 | "Opaque-Type/Id ADV Router Age Seq# CkSum", | |
4077 | #endif /* HAVE_OPAQUE_LSA */ | |
4078 | }; | |
4079 | ||
4dadc291 | 4080 | static void |
718e3744 | 4081 | show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa) |
4082 | { | |
4083 | struct router_lsa *rlsa = (struct router_lsa*) lsa->data; | |
4957f494 | 4084 | |
718e3744 | 4085 | vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE); |
4957f494 | 4086 | vty_out (vty, " Options: 0x%-2x : %s%s", |
4087 | lsa->data->options, | |
4088 | ospf_options_dump(lsa->data->options), | |
4089 | VTY_NEWLINE); | |
4090 | vty_out (vty, " LS Flags: 0x%-2x %s%s", | |
9d526037 | 4091 | lsa->flags, |
4957f494 | 4092 | ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""), |
4093 | VTY_NEWLINE); | |
718e3744 | 4094 | |
4095 | if (lsa->data->type == OSPF_ROUTER_LSA) | |
4096 | { | |
4097 | vty_out (vty, " Flags: 0x%x" , rlsa->flags); | |
4098 | ||
4099 | if (rlsa->flags) | |
4100 | vty_out (vty, " :%s%s%s%s", | |
4101 | IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "", | |
4102 | IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "", | |
4103 | IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "", | |
4104 | IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : ""); | |
4105 | ||
4106 | vty_out (vty, "%s", VTY_NEWLINE); | |
4107 | } | |
4108 | vty_out (vty, " LS Type: %s%s", | |
4109 | LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE); | |
4110 | vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id), | |
4111 | LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE); | |
4112 | vty_out (vty, " Advertising Router: %s%s", | |
4113 | inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); | |
4114 | vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum), | |
4115 | VTY_NEWLINE); | |
4116 | vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum), | |
4117 | VTY_NEWLINE); | |
4118 | vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE); | |
4119 | } | |
4120 | ||
eb1ce605 | 4121 | const char *link_type_desc[] = |
718e3744 | 4122 | { |
4123 | "(null)", | |
4124 | "another Router (point-to-point)", | |
4125 | "a Transit Network", | |
4126 | "Stub Network", | |
4127 | "a Virtual Link", | |
4128 | }; | |
4129 | ||
eb1ce605 | 4130 | const char *link_id_desc[] = |
718e3744 | 4131 | { |
4132 | "(null)", | |
4133 | "Neighboring Router ID", | |
4134 | "Designated Router address", | |
68980084 | 4135 | "Net", |
718e3744 | 4136 | "Neighboring Router ID", |
4137 | }; | |
4138 | ||
eb1ce605 | 4139 | const char *link_data_desc[] = |
718e3744 | 4140 | { |
4141 | "(null)", | |
4142 | "Router Interface address", | |
4143 | "Router Interface address", | |
4144 | "Network Mask", | |
4145 | "Router Interface address", | |
4146 | }; | |
4147 | ||
4148 | /* Show router-LSA each Link information. */ | |
4dadc291 | 4149 | static void |
718e3744 | 4150 | show_ip_ospf_database_router_links (struct vty *vty, |
4151 | struct router_lsa *rl) | |
4152 | { | |
4153 | int len, i, type; | |
4154 | ||
4155 | len = ntohs (rl->header.length) - 4; | |
4156 | for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++) | |
4157 | { | |
4158 | type = rl->link[i].type; | |
4159 | ||
4160 | vty_out (vty, " Link connected to: %s%s", | |
4161 | link_type_desc[type], VTY_NEWLINE); | |
4162 | vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type], | |
4163 | inet_ntoa (rl->link[i].link_id), VTY_NEWLINE); | |
4164 | vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type], | |
4165 | inet_ntoa (rl->link[i].link_data), VTY_NEWLINE); | |
4166 | vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE); | |
4167 | vty_out (vty, " TOS 0 Metric: %d%s", | |
4168 | ntohs (rl->link[i].metric), VTY_NEWLINE); | |
4169 | vty_out (vty, "%s", VTY_NEWLINE); | |
4170 | } | |
4171 | } | |
4172 | ||
4173 | /* Show router-LSA detail information. */ | |
4dadc291 | 4174 | static int |
718e3744 | 4175 | show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
4176 | { | |
4177 | if (lsa != NULL) | |
4178 | { | |
4179 | struct router_lsa *rl = (struct router_lsa *) lsa->data; | |
4180 | ||
4181 | show_ip_ospf_database_header (vty, lsa); | |
4182 | ||
4183 | vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links), | |
4184 | VTY_NEWLINE, VTY_NEWLINE); | |
4185 | ||
4186 | show_ip_ospf_database_router_links (vty, rl); | |
b0a053be | 4187 | vty_out (vty, "%s", VTY_NEWLINE); |
718e3744 | 4188 | } |
4189 | ||
4190 | return 0; | |
4191 | } | |
4192 | ||
4193 | /* Show network-LSA detail information. */ | |
4dadc291 | 4194 | static int |
718e3744 | 4195 | show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
4196 | { | |
4197 | int length, i; | |
4198 | ||
4199 | if (lsa != NULL) | |
4200 | { | |
4201 | struct network_lsa *nl = (struct network_lsa *) lsa->data; | |
4202 | ||
4203 | show_ip_ospf_database_header (vty, lsa); | |
4204 | ||
4205 | vty_out (vty, " Network Mask: /%d%s", | |
4206 | ip_masklen (nl->mask), VTY_NEWLINE); | |
4207 | ||
4208 | length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4; | |
4209 | ||
4210 | for (i = 0; length > 0; i++, length -= 4) | |
4211 | vty_out (vty, " Attached Router: %s%s", | |
4212 | inet_ntoa (nl->routers[i]), VTY_NEWLINE); | |
4213 | ||
4214 | vty_out (vty, "%s", VTY_NEWLINE); | |
4215 | } | |
4216 | ||
4217 | return 0; | |
4218 | } | |
4219 | ||
4220 | /* Show summary-LSA detail information. */ | |
4dadc291 | 4221 | static int |
718e3744 | 4222 | show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
4223 | { | |
4224 | if (lsa != NULL) | |
4225 | { | |
4226 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; | |
4227 | ||
4228 | show_ip_ospf_database_header (vty, lsa); | |
4229 | ||
4230 | vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask), | |
4231 | VTY_NEWLINE); | |
4232 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), | |
4233 | VTY_NEWLINE); | |
b0a053be | 4234 | vty_out (vty, "%s", VTY_NEWLINE); |
718e3744 | 4235 | } |
4236 | ||
4237 | return 0; | |
4238 | } | |
4239 | ||
4240 | /* Show summary-ASBR-LSA detail information. */ | |
4dadc291 | 4241 | static int |
718e3744 | 4242 | show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
4243 | { | |
4244 | if (lsa != NULL) | |
4245 | { | |
4246 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; | |
4247 | ||
4248 | show_ip_ospf_database_header (vty, lsa); | |
4249 | ||
4250 | vty_out (vty, " Network Mask: /%d%s", | |
4251 | ip_masklen (sl->mask), VTY_NEWLINE); | |
4252 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), | |
4253 | VTY_NEWLINE); | |
b0a053be | 4254 | vty_out (vty, "%s", VTY_NEWLINE); |
718e3744 | 4255 | } |
4256 | ||
4257 | return 0; | |
4258 | } | |
4259 | ||
4260 | /* Show AS-external-LSA detail information. */ | |
4dadc291 | 4261 | static int |
718e3744 | 4262 | show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
4263 | { | |
4264 | if (lsa != NULL) | |
4265 | { | |
4266 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; | |
4267 | ||
4268 | show_ip_ospf_database_header (vty, lsa); | |
4269 | ||
4270 | vty_out (vty, " Network Mask: /%d%s", | |
4271 | ip_masklen (al->mask), VTY_NEWLINE); | |
4272 | vty_out (vty, " Metric Type: %s%s", | |
4273 | IS_EXTERNAL_METRIC (al->e[0].tos) ? | |
4274 | "2 (Larger than any link state path)" : "1", VTY_NEWLINE); | |
4275 | vty_out (vty, " TOS: 0%s", VTY_NEWLINE); | |
4276 | vty_out (vty, " Metric: %d%s", | |
4277 | GET_METRIC (al->e[0].metric), VTY_NEWLINE); | |
4278 | vty_out (vty, " Forward Address: %s%s", | |
4279 | inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); | |
4280 | ||
4281 | vty_out (vty, " External Route Tag: %lu%s%s", | |
4282 | (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); | |
4283 | } | |
4284 | ||
4285 | return 0; | |
4286 | } | |
4287 | ||
075e12f5 | 4288 | #if 0 |
4dadc291 | 4289 | static int |
718e3744 | 4290 | show_as_external_lsa_stdvty (struct ospf_lsa *lsa) |
4291 | { | |
4292 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; | |
4293 | ||
4294 | /* show_ip_ospf_database_header (vty, lsa); */ | |
4295 | ||
2a42e285 | 4296 | zlog_debug( " Network Mask: /%d%s", |
718e3744 | 4297 | ip_masklen (al->mask), "\n"); |
2a42e285 | 4298 | zlog_debug( " Metric Type: %s%s", |
718e3744 | 4299 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
4300 | "2 (Larger than any link state path)" : "1", "\n"); | |
2a42e285 | 4301 | zlog_debug( " TOS: 0%s", "\n"); |
4302 | zlog_debug( " Metric: %d%s", | |
718e3744 | 4303 | GET_METRIC (al->e[0].metric), "\n"); |
2a42e285 | 4304 | zlog_debug( " Forward Address: %s%s", |
718e3744 | 4305 | inet_ntoa (al->e[0].fwd_addr), "\n"); |
4306 | ||
2a42e285 | 4307 | zlog_debug( " External Route Tag: %u%s%s", |
718e3744 | 4308 | ntohl (al->e[0].route_tag), "\n", "\n"); |
4309 | ||
4310 | return 0; | |
4311 | } | |
075e12f5 | 4312 | #endif |
718e3744 | 4313 | |
4314 | /* Show AS-NSSA-LSA detail information. */ | |
4dadc291 | 4315 | static int |
718e3744 | 4316 | show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
4317 | { | |
4318 | if (lsa != NULL) | |
4319 | { | |
4320 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; | |
4321 | ||
4322 | show_ip_ospf_database_header (vty, lsa); | |
4323 | ||
4324 | vty_out (vty, " Network Mask: /%d%s", | |
4325 | ip_masklen (al->mask), VTY_NEWLINE); | |
4326 | vty_out (vty, " Metric Type: %s%s", | |
4327 | IS_EXTERNAL_METRIC (al->e[0].tos) ? | |
4328 | "2 (Larger than any link state path)" : "1", VTY_NEWLINE); | |
4329 | vty_out (vty, " TOS: 0%s", VTY_NEWLINE); | |
4330 | vty_out (vty, " Metric: %d%s", | |
4331 | GET_METRIC (al->e[0].metric), VTY_NEWLINE); | |
4332 | vty_out (vty, " NSSA: Forward Address: %s%s", | |
4333 | inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); | |
4334 | ||
4335 | vty_out (vty, " External Route Tag: %u%s%s", | |
4336 | ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); | |
4337 | } | |
4338 | ||
4339 | return 0; | |
4340 | } | |
4341 | ||
4dadc291 | 4342 | static int |
718e3744 | 4343 | show_func_dummy (struct vty *vty, struct ospf_lsa *lsa) |
4344 | { | |
4345 | return 0; | |
4346 | } | |
4347 | ||
4348 | #ifdef HAVE_OPAQUE_LSA | |
4dadc291 | 4349 | static int |
718e3744 | 4350 | show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
4351 | { | |
4352 | if (lsa != NULL) | |
4353 | { | |
4354 | show_ip_ospf_database_header (vty, lsa); | |
4355 | show_opaque_info_detail (vty, lsa); | |
4356 | ||
4357 | vty_out (vty, "%s", VTY_NEWLINE); | |
4358 | } | |
4359 | return 0; | |
4360 | } | |
4361 | #endif /* HAVE_OPAQUE_LSA */ | |
4362 | ||
4363 | int (*show_function[])(struct vty *, struct ospf_lsa *) = | |
4364 | { | |
4365 | NULL, | |
4366 | show_router_lsa_detail, | |
4367 | show_network_lsa_detail, | |
4368 | show_summary_lsa_detail, | |
4369 | show_summary_asbr_lsa_detail, | |
4370 | show_as_external_lsa_detail, | |
718e3744 | 4371 | show_func_dummy, |
4372 | show_as_nssa_lsa_detail, /* almost same as external */ | |
718e3744 | 4373 | #ifdef HAVE_OPAQUE_LSA |
718e3744 | 4374 | NULL, /* type-8 */ |
4375 | show_opaque_lsa_detail, | |
4376 | show_opaque_lsa_detail, | |
4377 | show_opaque_lsa_detail, | |
4378 | #endif /* HAVE_OPAQUE_LSA */ | |
4379 | }; | |
4380 | ||
4dadc291 | 4381 | static void |
718e3744 | 4382 | show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id, |
4383 | struct in_addr *adv_router) | |
4384 | { | |
4385 | memset (lp, 0, sizeof (struct prefix_ls)); | |
4386 | lp->family = 0; | |
4387 | if (id == NULL) | |
4388 | lp->prefixlen = 0; | |
4389 | else if (adv_router == NULL) | |
4390 | { | |
4391 | lp->prefixlen = 32; | |
4392 | lp->id = *id; | |
4393 | } | |
4394 | else | |
4395 | { | |
4396 | lp->prefixlen = 64; | |
4397 | lp->id = *id; | |
4398 | lp->adv_router = *adv_router; | |
4399 | } | |
4400 | } | |
4401 | ||
4dadc291 | 4402 | static void |
718e3744 | 4403 | show_lsa_detail_proc (struct vty *vty, struct route_table *rt, |
4404 | struct in_addr *id, struct in_addr *adv_router) | |
4405 | { | |
4406 | struct prefix_ls lp; | |
4407 | struct route_node *rn, *start; | |
4408 | struct ospf_lsa *lsa; | |
4409 | ||
4410 | show_lsa_prefix_set (vty, &lp, id, adv_router); | |
4411 | start = route_node_get (rt, (struct prefix *) &lp); | |
4412 | if (start) | |
4413 | { | |
4414 | route_lock_node (start); | |
4415 | for (rn = start; rn; rn = route_next_until (rn, start)) | |
4416 | if ((lsa = rn->info)) | |
4417 | { | |
718e3744 | 4418 | if (show_function[lsa->data->type] != NULL) |
4419 | show_function[lsa->data->type] (vty, lsa); | |
4420 | } | |
4421 | route_unlock_node (start); | |
4422 | } | |
4423 | } | |
4424 | ||
4425 | /* Show detail LSA information | |
4426 | -- if id is NULL then show all LSAs. */ | |
4dadc291 | 4427 | static void |
020709f9 | 4428 | show_lsa_detail (struct vty *vty, struct ospf *ospf, int type, |
718e3744 | 4429 | struct in_addr *id, struct in_addr *adv_router) |
4430 | { | |
52dc7ee6 | 4431 | struct listnode *node; |
1eb8ef25 | 4432 | struct ospf_area *area; |
4433 | ||
718e3744 | 4434 | switch (type) |
4435 | { | |
4436 | case OSPF_AS_EXTERNAL_LSA: | |
4437 | #ifdef HAVE_OPAQUE_LSA | |
4438 | case OSPF_OPAQUE_AS_LSA: | |
4439 | #endif /* HAVE_OPAQUE_LSA */ | |
4440 | vty_out (vty, " %s %s%s", | |
4441 | show_database_desc[type], | |
4442 | VTY_NEWLINE, VTY_NEWLINE); | |
68980084 | 4443 | show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router); |
718e3744 | 4444 | break; |
4445 | default: | |
1eb8ef25 | 4446 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
718e3744 | 4447 | { |
718e3744 | 4448 | vty_out (vty, "%s %s (Area %s)%s%s", |
4449 | VTY_NEWLINE, show_database_desc[type], | |
4450 | ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); | |
4451 | show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router); | |
4452 | } | |
4453 | break; | |
4454 | } | |
4455 | } | |
4456 | ||
4dadc291 | 4457 | static void |
718e3744 | 4458 | show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt, |
4459 | struct in_addr *adv_router) | |
4460 | { | |
4461 | struct route_node *rn; | |
4462 | struct ospf_lsa *lsa; | |
4463 | ||
4464 | for (rn = route_top (rt); rn; rn = route_next (rn)) | |
4465 | if ((lsa = rn->info)) | |
4466 | if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router)) | |
4467 | { | |
718e3744 | 4468 | if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT)) |
4469 | continue; | |
718e3744 | 4470 | if (show_function[lsa->data->type] != NULL) |
4471 | show_function[lsa->data->type] (vty, lsa); | |
4472 | } | |
4473 | } | |
4474 | ||
4475 | /* Show detail LSA information. */ | |
4dadc291 | 4476 | static void |
020709f9 | 4477 | show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type, |
718e3744 | 4478 | struct in_addr *adv_router) |
4479 | { | |
52dc7ee6 | 4480 | struct listnode *node; |
1eb8ef25 | 4481 | struct ospf_area *area; |
718e3744 | 4482 | |
4483 | switch (type) | |
4484 | { | |
4485 | case OSPF_AS_EXTERNAL_LSA: | |
4486 | #ifdef HAVE_OPAQUE_LSA | |
4487 | case OSPF_OPAQUE_AS_LSA: | |
4488 | #endif /* HAVE_OPAQUE_LSA */ | |
4489 | vty_out (vty, " %s %s%s", | |
4490 | show_database_desc[type], | |
4491 | VTY_NEWLINE, VTY_NEWLINE); | |
68980084 | 4492 | show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type), |
718e3744 | 4493 | adv_router); |
4494 | break; | |
4495 | default: | |
1eb8ef25 | 4496 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
718e3744 | 4497 | { |
718e3744 | 4498 | vty_out (vty, "%s %s (Area %s)%s%s", |
4499 | VTY_NEWLINE, show_database_desc[type], | |
4500 | ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); | |
4501 | show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type), | |
4502 | adv_router); | |
4503 | } | |
4504 | break; | |
4505 | } | |
4506 | } | |
4507 | ||
4dadc291 | 4508 | static void |
020709f9 | 4509 | show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self) |
718e3744 | 4510 | { |
020709f9 | 4511 | struct ospf_lsa *lsa; |
4512 | struct route_node *rn; | |
1eb8ef25 | 4513 | struct ospf_area *area; |
52dc7ee6 | 4514 | struct listnode *node; |
718e3744 | 4515 | int type; |
4516 | ||
1eb8ef25 | 4517 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
718e3744 | 4518 | { |
718e3744 | 4519 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) |
4520 | { | |
4521 | switch (type) | |
4522 | { | |
4523 | case OSPF_AS_EXTERNAL_LSA: | |
4524 | #ifdef HAVE_OPAQUE_LSA | |
4525 | case OSPF_OPAQUE_AS_LSA: | |
4526 | #endif /* HAVE_OPAQUE_LSA */ | |
4527 | continue; | |
4528 | default: | |
4529 | break; | |
4530 | } | |
4531 | if (ospf_lsdb_count_self (area->lsdb, type) > 0 || | |
4532 | (!self && ospf_lsdb_count (area->lsdb, type) > 0)) | |
4533 | { | |
4534 | vty_out (vty, " %s (Area %s)%s%s", | |
4535 | show_database_desc[type], | |
4536 | ospf_area_desc_string (area), | |
4537 | VTY_NEWLINE, VTY_NEWLINE); | |
4538 | vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE); | |
4539 | ||
020709f9 | 4540 | LSDB_LOOP (AREA_LSDB (area, type), rn, lsa) |
4541 | show_lsa_summary (vty, lsa, self); | |
718e3744 | 4542 | |
4543 | vty_out (vty, "%s", VTY_NEWLINE); | |
4544 | } | |
4545 | } | |
4546 | } | |
4547 | ||
4548 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) | |
4549 | { | |
4550 | switch (type) | |
4551 | { | |
4552 | case OSPF_AS_EXTERNAL_LSA: | |
4553 | #ifdef HAVE_OPAQUE_LSA | |
4554 | case OSPF_OPAQUE_AS_LSA: | |
4555 | #endif /* HAVE_OPAQUE_LSA */ | |
e8e1946e | 4556 | break; |
718e3744 | 4557 | default: |
4558 | continue; | |
4559 | } | |
68980084 | 4560 | if (ospf_lsdb_count_self (ospf->lsdb, type) || |
4561 | (!self && ospf_lsdb_count (ospf->lsdb, type))) | |
718e3744 | 4562 | { |
4563 | vty_out (vty, " %s%s%s", | |
4564 | show_database_desc[type], | |
4565 | VTY_NEWLINE, VTY_NEWLINE); | |
4566 | vty_out (vty, "%s%s", show_database_header[type], | |
4567 | VTY_NEWLINE); | |
020709f9 | 4568 | |
4569 | LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa) | |
4570 | show_lsa_summary (vty, lsa, self); | |
4571 | ||
718e3744 | 4572 | vty_out (vty, "%s", VTY_NEWLINE); |
4573 | } | |
4574 | } | |
4575 | ||
4576 | vty_out (vty, "%s", VTY_NEWLINE); | |
4577 | } | |
4578 | ||
4dadc291 | 4579 | static void |
020709f9 | 4580 | show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf) |
718e3744 | 4581 | { |
91e6a0e5 | 4582 | struct route_node *rn; |
718e3744 | 4583 | struct ospf_lsa *lsa; |
4584 | ||
4585 | vty_out (vty, "%s MaxAge Link States:%s%s", | |
4586 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); | |
4587 | ||
91e6a0e5 | 4588 | for (rn = route_top (ospf->maxage_lsa); rn; rn = route_next (rn)) |
1eb8ef25 | 4589 | { |
91e6a0e5 DD |
4590 | struct ospf_lsa *lsa; |
4591 | ||
4592 | if ((lsa = rn->info) != NULL) | |
4593 | { | |
4594 | vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE); | |
4595 | vty_out (vty, "Link State ID: %s%s", | |
4596 | inet_ntoa (lsa->data->id), VTY_NEWLINE); | |
4597 | vty_out (vty, "Advertising Router: %s%s", | |
4598 | inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); | |
4599 | vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE); | |
4600 | vty_out (vty, "%s", VTY_NEWLINE); | |
4601 | } | |
1eb8ef25 | 4602 | } |
718e3744 | 4603 | } |
4604 | ||
718e3744 | 4605 | #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n" |
4606 | #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external" | |
718e3744 | 4607 | |
4608 | #ifdef HAVE_OPAQUE_LSA | |
4609 | #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n" | |
4610 | #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n" | |
4611 | #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n" | |
4612 | #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as" | |
4613 | #else /* HAVE_OPAQUE_LSA */ | |
4614 | #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "" | |
4615 | #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "" | |
4616 | #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "" | |
4617 | #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "" | |
4618 | #endif /* HAVE_OPAQUE_LSA */ | |
4619 | ||
4620 | #define OSPF_LSA_TYPES_CMD_STR \ | |
4621 | "asbr-summary|external|network|router|summary" \ | |
4622 | OSPF_LSA_TYPE_NSSA_CMD_STR \ | |
4623 | OSPF_LSA_TYPE_OPAQUE_CMD_STR | |
4624 | ||
4625 | #define OSPF_LSA_TYPES_DESC \ | |
4626 | "ASBR summary link states\n" \ | |
4627 | "External link states\n" \ | |
4628 | "Network link states\n" \ | |
4629 | "Router link states\n" \ | |
4630 | "Network summary link states\n" \ | |
4631 | OSPF_LSA_TYPE_NSSA_DESC \ | |
4632 | OSPF_LSA_TYPE_OPAQUE_LINK_DESC \ | |
4633 | OSPF_LSA_TYPE_OPAQUE_AREA_DESC \ | |
4634 | OSPF_LSA_TYPE_OPAQUE_AS_DESC | |
4635 | ||
7c8ff89e DS |
4636 | static int |
4637 | show_ip_ospf_database_common (struct vty *vty, struct ospf *ospf, | |
4638 | int arg_base, int argc, const char **argv) | |
718e3744 | 4639 | { |
4640 | int type, ret; | |
4641 | struct in_addr id, adv_router; | |
4642 | ||
7c8ff89e DS |
4643 | if (ospf->instance) |
4644 | vty_out (vty, "%sOSPF Instance: %d%s", VTY_NEWLINE, ospf->instance, | |
4645 | VTY_NEWLINE); | |
718e3744 | 4646 | |
4647 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, | |
68980084 | 4648 | inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); |
718e3744 | 4649 | |
4650 | /* Show all LSA. */ | |
7c8ff89e | 4651 | if (argc == arg_base + 0) |
718e3744 | 4652 | { |
020709f9 | 4653 | show_ip_ospf_database_summary (vty, ospf, 0); |
718e3744 | 4654 | return CMD_SUCCESS; |
4655 | } | |
4656 | ||
4657 | /* Set database type to show. */ | |
7c8ff89e | 4658 | if (strncmp (argv[arg_base + 0], "r", 1) == 0) |
718e3744 | 4659 | type = OSPF_ROUTER_LSA; |
7c8ff89e | 4660 | else if (strncmp (argv[arg_base + 0], "ne", 2) == 0) |
718e3744 | 4661 | type = OSPF_NETWORK_LSA; |
7c8ff89e | 4662 | else if (strncmp (argv[arg_base + 0], "ns", 2) == 0) |
718e3744 | 4663 | type = OSPF_AS_NSSA_LSA; |
7c8ff89e | 4664 | else if (strncmp (argv[arg_base + 0], "su", 2) == 0) |
718e3744 | 4665 | type = OSPF_SUMMARY_LSA; |
7c8ff89e | 4666 | else if (strncmp (argv[arg_base + 0], "a", 1) == 0) |
718e3744 | 4667 | type = OSPF_ASBR_SUMMARY_LSA; |
7c8ff89e | 4668 | else if (strncmp (argv[arg_base + 0], "e", 1) == 0) |
718e3744 | 4669 | type = OSPF_AS_EXTERNAL_LSA; |
7c8ff89e | 4670 | else if (strncmp (argv[arg_base + 0], "se", 2) == 0) |
718e3744 | 4671 | { |
020709f9 | 4672 | show_ip_ospf_database_summary (vty, ospf, 1); |
718e3744 | 4673 | return CMD_SUCCESS; |
4674 | } | |
7c8ff89e | 4675 | else if (strncmp (argv[arg_base + 0], "m", 1) == 0) |
718e3744 | 4676 | { |
020709f9 | 4677 | show_ip_ospf_database_maxage (vty, ospf); |
718e3744 | 4678 | return CMD_SUCCESS; |
4679 | } | |
4680 | #ifdef HAVE_OPAQUE_LSA | |
7c8ff89e | 4681 | else if (strncmp (argv[arg_base + 0], "opaque-l", 8) == 0) |
718e3744 | 4682 | type = OSPF_OPAQUE_LINK_LSA; |
7c8ff89e | 4683 | else if (strncmp (argv[arg_base + 0], "opaque-ar", 9) == 0) |
718e3744 | 4684 | type = OSPF_OPAQUE_AREA_LSA; |
7c8ff89e | 4685 | else if (strncmp (argv[arg_base + 0], "opaque-as", 9) == 0) |
718e3744 | 4686 | type = OSPF_OPAQUE_AS_LSA; |
4687 | #endif /* HAVE_OPAQUE_LSA */ | |
4688 | else | |
4689 | return CMD_WARNING; | |
4690 | ||
4691 | /* `show ip ospf database LSA'. */ | |
7c8ff89e | 4692 | if (argc == arg_base + 1) |
020709f9 | 4693 | show_lsa_detail (vty, ospf, type, NULL, NULL); |
7c8ff89e | 4694 | else if (argc >= arg_base + 2) |
718e3744 | 4695 | { |
7c8ff89e | 4696 | ret = inet_aton (argv[arg_base + 1], &id); |
718e3744 | 4697 | if (!ret) |
4698 | return CMD_WARNING; | |
4699 | ||
4700 | /* `show ip ospf database LSA ID'. */ | |
7c8ff89e | 4701 | if (argc == arg_base + 2) |
020709f9 | 4702 | show_lsa_detail (vty, ospf, type, &id, NULL); |
718e3744 | 4703 | /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */ |
7c8ff89e | 4704 | else if (argc == arg_base + 3) |
718e3744 | 4705 | { |
7c8ff89e | 4706 | if (strncmp (argv[arg_base + 2], "s", 1) == 0) |
68980084 | 4707 | adv_router = ospf->router_id; |
718e3744 | 4708 | else |
4709 | { | |
7c8ff89e | 4710 | ret = inet_aton (argv[arg_base + 2], &adv_router); |
718e3744 | 4711 | if (!ret) |
4712 | return CMD_WARNING; | |
4713 | } | |
020709f9 | 4714 | show_lsa_detail (vty, ospf, type, &id, &adv_router); |
718e3744 | 4715 | } |
4716 | } | |
4717 | ||
4718 | return CMD_SUCCESS; | |
4719 | } | |
4720 | ||
7c8ff89e DS |
4721 | DEFUN (show_ip_ospf_database, |
4722 | show_ip_ospf_database_cmd, | |
4723 | "show ip ospf database", | |
4724 | SHOW_STR | |
4725 | IP_STR | |
4726 | "OSPF information\n" | |
4727 | "Database summary\n") | |
4728 | { | |
4729 | struct ospf *ospf; | |
4730 | ||
0bad4851 | 4731 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4732 | return CMD_SUCCESS; |
4733 | ||
4734 | return (show_ip_ospf_database_common(vty, ospf, 0, argc, argv)); | |
4735 | } | |
4736 | ||
718e3744 | 4737 | ALIAS (show_ip_ospf_database, |
4738 | show_ip_ospf_database_type_cmd, | |
4739 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)", | |
4740 | SHOW_STR | |
4741 | IP_STR | |
4742 | "OSPF information\n" | |
4743 | "Database summary\n" | |
4744 | OSPF_LSA_TYPES_DESC | |
4745 | "LSAs in MaxAge list\n" | |
4746 | "Self-originated link states\n") | |
4747 | ||
4748 | ALIAS (show_ip_ospf_database, | |
4749 | show_ip_ospf_database_type_id_cmd, | |
4750 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D", | |
4751 | SHOW_STR | |
4752 | IP_STR | |
4753 | "OSPF information\n" | |
4754 | "Database summary\n" | |
4755 | OSPF_LSA_TYPES_DESC | |
4756 | "Link State ID (as an IP address)\n") | |
4757 | ||
4758 | ALIAS (show_ip_ospf_database, | |
4759 | show_ip_ospf_database_type_id_adv_router_cmd, | |
4760 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D", | |
4761 | SHOW_STR | |
4762 | IP_STR | |
4763 | "OSPF information\n" | |
4764 | "Database summary\n" | |
4765 | OSPF_LSA_TYPES_DESC | |
4766 | "Link State ID (as an IP address)\n" | |
4767 | "Advertising Router link states\n" | |
4768 | "Advertising Router (as an IP address)\n") | |
4769 | ||
4770 | ALIAS (show_ip_ospf_database, | |
4771 | show_ip_ospf_database_type_id_self_cmd, | |
4772 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)", | |
4773 | SHOW_STR | |
4774 | IP_STR | |
4775 | "OSPF information\n" | |
4776 | "Database summary\n" | |
4777 | OSPF_LSA_TYPES_DESC | |
4778 | "Link State ID (as an IP address)\n" | |
4779 | "Self-originated link states\n" | |
4780 | "\n") | |
4781 | ||
7c8ff89e DS |
4782 | DEFUN (show_ip_ospf_instance_database, |
4783 | show_ip_ospf_instance_database_cmd, | |
4784 | "show ip ospf <1-65535> database", | |
718e3744 | 4785 | SHOW_STR |
4786 | IP_STR | |
4787 | "OSPF information\n" | |
7c8ff89e DS |
4788 | "Instance ID\n" |
4789 | "Database summary\n") | |
4790 | { | |
4791 | struct ospf *ospf; | |
4792 | u_short instance = 0; | |
4793 | ||
4794 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
4795 | ||
0bad4851 | 4796 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4797 | return CMD_SUCCESS; |
4798 | ||
4799 | return (show_ip_ospf_database_common(vty, ospf, 1, argc, argv)); | |
4800 | } | |
4801 | ||
4802 | ALIAS (show_ip_ospf_instance_database, | |
4803 | show_ip_ospf_instance_database_type_cmd, | |
4804 | "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)", | |
4805 | SHOW_STR | |
4806 | IP_STR | |
4807 | "OSPF information\n" | |
4808 | "Instance ID\n" | |
4809 | "Database summary\n" | |
4810 | OSPF_LSA_TYPES_DESC | |
4811 | "LSAs in MaxAge list\n" | |
4812 | "Self-originated link states\n") | |
4813 | ||
4814 | ALIAS (show_ip_ospf_instance_database, | |
4815 | show_ip_ospf_instance_database_type_id_cmd, | |
4816 | "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D", | |
4817 | SHOW_STR | |
4818 | IP_STR | |
4819 | "OSPF information\n" | |
4820 | "Instance ID\n" | |
4821 | "Database summary\n" | |
4822 | OSPF_LSA_TYPES_DESC | |
4823 | "Link State ID (as an IP address)\n") | |
4824 | ||
4825 | ALIAS (show_ip_ospf_instance_database, | |
4826 | show_ip_ospf_instance_database_type_id_adv_router_cmd, | |
4827 | "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D", | |
4828 | SHOW_STR | |
4829 | IP_STR | |
4830 | "OSPF information\n" | |
4831 | "Instance ID\n" | |
718e3744 | 4832 | "Database summary\n" |
4833 | OSPF_LSA_TYPES_DESC | |
7c8ff89e | 4834 | "Link State ID (as an IP address)\n" |
718e3744 | 4835 | "Advertising Router link states\n" |
4836 | "Advertising Router (as an IP address)\n") | |
7c8ff89e DS |
4837 | |
4838 | ALIAS (show_ip_ospf_instance_database, | |
4839 | show_ip_ospf_instance_database_type_id_self_cmd, | |
4840 | "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)", | |
4841 | SHOW_STR | |
4842 | IP_STR | |
4843 | "OSPF information\n" | |
4844 | "Instance ID\n" | |
4845 | "Database summary\n" | |
4846 | OSPF_LSA_TYPES_DESC | |
4847 | "Link State ID (as an IP address)\n" | |
4848 | "Self-originated link states\n" | |
4849 | "\n") | |
4850 | ||
4851 | ||
4852 | static int | |
4853 | show_ip_ospf_database_type_adv_router_common (struct vty *vty, struct ospf *ospf, | |
4854 | int arg_base, int argc, const char **argv) | |
718e3744 | 4855 | { |
4856 | int type, ret; | |
4857 | struct in_addr adv_router; | |
4858 | ||
7c8ff89e DS |
4859 | if (ospf->instance) |
4860 | vty_out (vty, "%sOSPF Instance: %d%s", VTY_NEWLINE, ospf->instance, | |
4861 | VTY_NEWLINE); | |
718e3744 | 4862 | |
4863 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, | |
68980084 | 4864 | inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); |
718e3744 | 4865 | |
7c8ff89e | 4866 | if (argc != arg_base + 2) |
718e3744 | 4867 | return CMD_WARNING; |
4868 | ||
4869 | /* Set database type to show. */ | |
7c8ff89e | 4870 | if (strncmp (argv[arg_base + 0], "r", 1) == 0) |
718e3744 | 4871 | type = OSPF_ROUTER_LSA; |
7c8ff89e | 4872 | else if (strncmp (argv[arg_base + 0], "ne", 2) == 0) |
718e3744 | 4873 | type = OSPF_NETWORK_LSA; |
7c8ff89e | 4874 | else if (strncmp (argv[arg_base + 0], "ns", 2) == 0) |
718e3744 | 4875 | type = OSPF_AS_NSSA_LSA; |
7c8ff89e | 4876 | else if (strncmp (argv[arg_base + 0], "s", 1) == 0) |
718e3744 | 4877 | type = OSPF_SUMMARY_LSA; |
7c8ff89e | 4878 | else if (strncmp (argv[arg_base + 0], "a", 1) == 0) |
718e3744 | 4879 | type = OSPF_ASBR_SUMMARY_LSA; |
7c8ff89e | 4880 | else if (strncmp (argv[arg_base + 0], "e", 1) == 0) |
718e3744 | 4881 | type = OSPF_AS_EXTERNAL_LSA; |
4882 | #ifdef HAVE_OPAQUE_LSA | |
7c8ff89e | 4883 | else if (strncmp (argv[arg_base + 0], "opaque-l", 8) == 0) |
718e3744 | 4884 | type = OSPF_OPAQUE_LINK_LSA; |
7c8ff89e | 4885 | else if (strncmp (argv[arg_base + 0], "opaque-ar", 9) == 0) |
718e3744 | 4886 | type = OSPF_OPAQUE_AREA_LSA; |
7c8ff89e | 4887 | else if (strncmp (argv[arg_base + 0], "opaque-as", 9) == 0) |
718e3744 | 4888 | type = OSPF_OPAQUE_AS_LSA; |
4889 | #endif /* HAVE_OPAQUE_LSA */ | |
4890 | else | |
4891 | return CMD_WARNING; | |
4892 | ||
7c8ff89e DS |
4893 | /* `show ip ospf database LSA adv-router ADV_ROUTER'. */ |
4894 | if (strncmp (argv[arg_base + 1], "s", 1) == 0) | |
4895 | adv_router = ospf->router_id; | |
4896 | else | |
4897 | { | |
4898 | ret = inet_aton (argv[arg_base + 1], &adv_router); | |
4899 | if (!ret) | |
4900 | return CMD_WARNING; | |
4901 | } | |
4902 | ||
4903 | show_lsa_detail_adv_router (vty, ospf, type, &adv_router); | |
4904 | ||
4905 | return CMD_SUCCESS; | |
4906 | } | |
4907 | ||
4908 | DEFUN (show_ip_ospf_database_type_adv_router, | |
4909 | show_ip_ospf_database_type_adv_router_cmd, | |
4910 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D", | |
4911 | SHOW_STR | |
4912 | IP_STR | |
4913 | "OSPF information\n" | |
4914 | "Database summary\n" | |
4915 | OSPF_LSA_TYPES_DESC | |
4916 | "Advertising Router link states\n" | |
4917 | "Advertising Router (as an IP address)\n") | |
4918 | { | |
4919 | struct ospf *ospf; | |
4920 | ||
0bad4851 | 4921 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4922 | return CMD_SUCCESS; |
4923 | ||
4924 | return (show_ip_ospf_database_type_adv_router_common(vty, ospf, 0, argc, argv)); | |
4925 | } | |
4926 | ||
4927 | ALIAS (show_ip_ospf_database_type_adv_router, | |
4928 | show_ip_ospf_database_type_self_cmd, | |
4929 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)", | |
4930 | SHOW_STR | |
4931 | IP_STR | |
4932 | "OSPF information\n" | |
4933 | "Database summary\n" | |
4934 | OSPF_LSA_TYPES_DESC | |
4935 | "Self-originated link states\n") | |
4936 | ||
4937 | DEFUN (show_ip_ospf_instance_database_type_adv_router, | |
4938 | show_ip_ospf_instance_database_type_adv_router_cmd, | |
4939 | "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D", | |
4940 | SHOW_STR | |
4941 | IP_STR | |
4942 | "OSPF information\n" | |
4943 | "Instance ID\n" | |
4944 | "Database summary\n" | |
4945 | OSPF_LSA_TYPES_DESC | |
4946 | "Advertising Router link states\n" | |
4947 | "Advertising Router (as an IP address)\n") | |
4948 | { | |
4949 | struct ospf *ospf; | |
4950 | u_short instance = 0; | |
4951 | ||
4952 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
718e3744 | 4953 | |
0bad4851 | 4954 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e | 4955 | return CMD_SUCCESS; |
718e3744 | 4956 | |
7c8ff89e | 4957 | return (show_ip_ospf_database_type_adv_router_common(vty, ospf, 1, argc, argv)); |
718e3744 | 4958 | } |
4959 | ||
7c8ff89e DS |
4960 | ALIAS (show_ip_ospf_instance_database_type_adv_router, |
4961 | show_ip_ospf_instance_database_type_self_cmd, | |
4962 | "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)", | |
718e3744 | 4963 | SHOW_STR |
4964 | IP_STR | |
4965 | "OSPF information\n" | |
7c8ff89e | 4966 | "Instance ID\n" |
718e3744 | 4967 | "Database summary\n" |
4968 | OSPF_LSA_TYPES_DESC | |
4969 | "Self-originated link states\n") | |
4970 | ||
718e3744 | 4971 | DEFUN (ip_ospf_authentication_args, |
4972 | ip_ospf_authentication_args_addr_cmd, | |
4973 | "ip ospf authentication (null|message-digest) A.B.C.D", | |
4974 | "IP Information\n" | |
4975 | "OSPF interface commands\n" | |
4976 | "Enable authentication on this interface\n" | |
4977 | "Use null authentication\n" | |
4978 | "Use message-digest authentication\n" | |
4979 | "Address of interface") | |
4980 | { | |
4981 | struct interface *ifp; | |
4982 | struct in_addr addr; | |
4983 | int ret; | |
4984 | struct ospf_if_params *params; | |
4985 | ||
4986 | ifp = vty->index; | |
4987 | params = IF_DEF_PARAMS (ifp); | |
4988 | ||
4989 | if (argc == 2) | |
4990 | { | |
4991 | ret = inet_aton(argv[1], &addr); | |
4992 | if (!ret) | |
4993 | { | |
4994 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
4995 | VTY_NEWLINE); | |
4996 | return CMD_WARNING; | |
4997 | } | |
4998 | ||
4999 | params = ospf_get_if_params (ifp, addr); | |
5000 | ospf_if_update_params (ifp, addr); | |
5001 | } | |
5002 | ||
5003 | /* Handle null authentication */ | |
5004 | if ( argv[0][0] == 'n' ) | |
5005 | { | |
5006 | SET_IF_PARAM (params, auth_type); | |
5007 | params->auth_type = OSPF_AUTH_NULL; | |
5008 | return CMD_SUCCESS; | |
5009 | } | |
5010 | ||
5011 | /* Handle message-digest authentication */ | |
5012 | if ( argv[0][0] == 'm' ) | |
5013 | { | |
5014 | SET_IF_PARAM (params, auth_type); | |
5015 | params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; | |
5016 | return CMD_SUCCESS; | |
5017 | } | |
5018 | ||
5019 | vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE); | |
5020 | return CMD_WARNING; | |
5021 | } | |
5022 | ||
5023 | ALIAS (ip_ospf_authentication_args, | |
5024 | ip_ospf_authentication_args_cmd, | |
5025 | "ip ospf authentication (null|message-digest)", | |
5026 | "IP Information\n" | |
5027 | "OSPF interface commands\n" | |
5028 | "Enable authentication on this interface\n" | |
5029 | "Use null authentication\n" | |
5030 | "Use message-digest authentication\n") | |
5031 | ||
5032 | DEFUN (ip_ospf_authentication, | |
5033 | ip_ospf_authentication_addr_cmd, | |
5034 | "ip ospf authentication A.B.C.D", | |
5035 | "IP Information\n" | |
5036 | "OSPF interface commands\n" | |
5037 | "Enable authentication on this interface\n" | |
5038 | "Address of interface") | |
5039 | { | |
5040 | struct interface *ifp; | |
5041 | struct in_addr addr; | |
5042 | int ret; | |
5043 | struct ospf_if_params *params; | |
5044 | ||
5045 | ifp = vty->index; | |
5046 | params = IF_DEF_PARAMS (ifp); | |
5047 | ||
5048 | if (argc == 1) | |
5049 | { | |
5dcf71df | 5050 | ret = inet_aton(argv[0], &addr); |
718e3744 | 5051 | if (!ret) |
5052 | { | |
5053 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
5054 | VTY_NEWLINE); | |
5055 | return CMD_WARNING; | |
5056 | } | |
5057 | ||
5058 | params = ospf_get_if_params (ifp, addr); | |
5059 | ospf_if_update_params (ifp, addr); | |
5060 | } | |
5061 | ||
5062 | SET_IF_PARAM (params, auth_type); | |
5063 | params->auth_type = OSPF_AUTH_SIMPLE; | |
5064 | ||
5065 | return CMD_SUCCESS; | |
5066 | } | |
5067 | ||
5068 | ALIAS (ip_ospf_authentication, | |
5069 | ip_ospf_authentication_cmd, | |
5070 | "ip ospf authentication", | |
5071 | "IP Information\n" | |
5072 | "OSPF interface commands\n" | |
5073 | "Enable authentication on this interface\n") | |
5074 | ||
5075 | DEFUN (no_ip_ospf_authentication, | |
5076 | no_ip_ospf_authentication_addr_cmd, | |
5077 | "no ip ospf authentication A.B.C.D", | |
5078 | NO_STR | |
5079 | "IP Information\n" | |
5080 | "OSPF interface commands\n" | |
5081 | "Enable authentication on this interface\n" | |
5082 | "Address of interface") | |
5083 | { | |
5084 | struct interface *ifp; | |
5085 | struct in_addr addr; | |
5086 | int ret; | |
5087 | struct ospf_if_params *params; | |
5088 | ||
5089 | ifp = vty->index; | |
5090 | params = IF_DEF_PARAMS (ifp); | |
5091 | ||
5092 | if (argc == 1) | |
5093 | { | |
5dcf71df | 5094 | ret = inet_aton(argv[0], &addr); |
718e3744 | 5095 | if (!ret) |
5096 | { | |
5097 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
5098 | VTY_NEWLINE); | |
5099 | return CMD_WARNING; | |
5100 | } | |
5101 | ||
5102 | params = ospf_lookup_if_params (ifp, addr); | |
5103 | if (params == NULL) | |
5104 | return CMD_SUCCESS; | |
5105 | } | |
5106 | ||
5107 | params->auth_type = OSPF_AUTH_NOTSET; | |
5108 | UNSET_IF_PARAM (params, auth_type); | |
5109 | ||
5110 | if (params != IF_DEF_PARAMS (ifp)) | |
5111 | { | |
5112 | ospf_free_if_params (ifp, addr); | |
5113 | ospf_if_update_params (ifp, addr); | |
5114 | } | |
5115 | ||
5116 | return CMD_SUCCESS; | |
5117 | } | |
5118 | ||
5119 | ALIAS (no_ip_ospf_authentication, | |
5120 | no_ip_ospf_authentication_cmd, | |
5121 | "no ip ospf authentication", | |
5122 | NO_STR | |
5123 | "IP Information\n" | |
5124 | "OSPF interface commands\n" | |
5125 | "Enable authentication on this interface\n") | |
5126 | ||
5127 | DEFUN (ip_ospf_authentication_key, | |
5128 | ip_ospf_authentication_key_addr_cmd, | |
5129 | "ip ospf authentication-key AUTH_KEY A.B.C.D", | |
5130 | "IP Information\n" | |
5131 | "OSPF interface commands\n" | |
5132 | "Authentication password (key)\n" | |
5133 | "The OSPF password (key)\n" | |
5134 | "Address of interface") | |
5135 | { | |
5136 | struct interface *ifp; | |
5137 | struct in_addr addr; | |
5138 | int ret; | |
5139 | struct ospf_if_params *params; | |
5140 | ||
5141 | ifp = vty->index; | |
5142 | params = IF_DEF_PARAMS (ifp); | |
5143 | ||
5144 | if (argc == 2) | |
5145 | { | |
5146 | ret = inet_aton(argv[1], &addr); | |
5147 | if (!ret) | |
5148 | { | |
5149 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
5150 | VTY_NEWLINE); | |
5151 | return CMD_WARNING; | |
5152 | } | |
5153 | ||
5154 | params = ospf_get_if_params (ifp, addr); | |
5155 | ospf_if_update_params (ifp, addr); | |
5156 | } | |
5157 | ||
5158 | ||
5159 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1); | |
c9e52be3 | 5160 | strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE); |
718e3744 | 5161 | SET_IF_PARAM (params, auth_simple); |
5162 | ||
5163 | return CMD_SUCCESS; | |
5164 | } | |
5165 | ||
5166 | ALIAS (ip_ospf_authentication_key, | |
5167 | ip_ospf_authentication_key_cmd, | |
5168 | "ip ospf authentication-key AUTH_KEY", | |
5169 | "IP Information\n" | |
5170 | "OSPF interface commands\n" | |
5171 | "Authentication password (key)\n" | |
5172 | "The OSPF password (key)") | |
5173 | ||
5174 | ALIAS (ip_ospf_authentication_key, | |
5175 | ospf_authentication_key_cmd, | |
5176 | "ospf authentication-key AUTH_KEY", | |
5177 | "OSPF interface commands\n" | |
5178 | "Authentication password (key)\n" | |
5179 | "The OSPF password (key)") | |
5180 | ||
5181 | DEFUN (no_ip_ospf_authentication_key, | |
5182 | no_ip_ospf_authentication_key_addr_cmd, | |
5183 | "no ip ospf authentication-key A.B.C.D", | |
5184 | NO_STR | |
5185 | "IP Information\n" | |
5186 | "OSPF interface commands\n" | |
5187 | "Authentication password (key)\n" | |
5188 | "Address of interface") | |
5189 | { | |
5190 | struct interface *ifp; | |
5191 | struct in_addr addr; | |
5192 | int ret; | |
5193 | struct ospf_if_params *params; | |
5194 | ||
5195 | ifp = vty->index; | |
5196 | params = IF_DEF_PARAMS (ifp); | |
5197 | ||
5dcf71df | 5198 | if (argc == 1) |
718e3744 | 5199 | { |
5dcf71df | 5200 | ret = inet_aton(argv[0], &addr); |
718e3744 | 5201 | if (!ret) |
5202 | { | |
5203 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
5204 | VTY_NEWLINE); | |
5205 | return CMD_WARNING; | |
5206 | } | |
5207 | ||
5208 | params = ospf_lookup_if_params (ifp, addr); | |
5209 | if (params == NULL) | |
5210 | return CMD_SUCCESS; | |
5211 | } | |
5212 | ||
5213 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE); | |
5214 | UNSET_IF_PARAM (params, auth_simple); | |
5215 | ||
5216 | if (params != IF_DEF_PARAMS (ifp)) | |
5217 | { | |
5218 | ospf_free_if_params (ifp, addr); | |
5219 | ospf_if_update_params (ifp, addr); | |
5220 | } | |
5221 | ||
5222 | return CMD_SUCCESS; | |
5223 | } | |
5224 | ||
5225 | ALIAS (no_ip_ospf_authentication_key, | |
5226 | no_ip_ospf_authentication_key_cmd, | |
5227 | "no ip ospf authentication-key", | |
5228 | NO_STR | |
5229 | "IP Information\n" | |
5230 | "OSPF interface commands\n" | |
5231 | "Authentication password (key)\n") | |
5232 | ||
5233 | ALIAS (no_ip_ospf_authentication_key, | |
5234 | no_ospf_authentication_key_cmd, | |
5235 | "no ospf authentication-key", | |
5236 | NO_STR | |
5237 | "OSPF interface commands\n" | |
5238 | "Authentication password (key)\n") | |
5239 | ||
5240 | DEFUN (ip_ospf_message_digest_key, | |
5241 | ip_ospf_message_digest_key_addr_cmd, | |
5242 | "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D", | |
5243 | "IP Information\n" | |
5244 | "OSPF interface commands\n" | |
5245 | "Message digest authentication password (key)\n" | |
5246 | "Key ID\n" | |
5247 | "Use MD5 algorithm\n" | |
5248 | "The OSPF password (key)" | |
5249 | "Address of interface") | |
5250 | { | |
5251 | struct interface *ifp; | |
5252 | struct crypt_key *ck; | |
5253 | u_char key_id; | |
5254 | struct in_addr addr; | |
5255 | int ret; | |
5256 | struct ospf_if_params *params; | |
5257 | ||
5258 | ifp = vty->index; | |
5259 | params = IF_DEF_PARAMS (ifp); | |
5260 | ||
5261 | if (argc == 3) | |
5262 | { | |
5263 | ret = inet_aton(argv[2], &addr); | |
5264 | if (!ret) | |
5265 | { | |
5266 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
5267 | VTY_NEWLINE); | |
5268 | return CMD_WARNING; | |
5269 | } | |
5270 | ||
5271 | params = ospf_get_if_params (ifp, addr); | |
5272 | ospf_if_update_params (ifp, addr); | |
5273 | } | |
5274 | ||
5275 | key_id = strtol (argv[0], NULL, 10); | |
5276 | if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL) | |
5277 | { | |
5278 | vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE); | |
5279 | return CMD_WARNING; | |
5280 | } | |
5281 | ||
5282 | ck = ospf_crypt_key_new (); | |
5283 | ck->key_id = (u_char) key_id; | |
5284 | memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); | |
c9e52be3 | 5285 | strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE); |
718e3744 | 5286 | |
5287 | ospf_crypt_key_add (params->auth_crypt, ck); | |
5288 | SET_IF_PARAM (params, auth_crypt); | |
5289 | ||
5290 | return CMD_SUCCESS; | |
5291 | } | |
5292 | ||
5293 | ALIAS (ip_ospf_message_digest_key, | |
5294 | ip_ospf_message_digest_key_cmd, | |
5295 | "ip ospf message-digest-key <1-255> md5 KEY", | |
5296 | "IP Information\n" | |
5297 | "OSPF interface commands\n" | |
5298 | "Message digest authentication password (key)\n" | |
5299 | "Key ID\n" | |
5300 | "Use MD5 algorithm\n" | |
5301 | "The OSPF password (key)") | |
5302 | ||
5303 | ALIAS (ip_ospf_message_digest_key, | |
5304 | ospf_message_digest_key_cmd, | |
5305 | "ospf message-digest-key <1-255> md5 KEY", | |
5306 | "OSPF interface commands\n" | |
5307 | "Message digest authentication password (key)\n" | |
5308 | "Key ID\n" | |
5309 | "Use MD5 algorithm\n" | |
5310 | "The OSPF password (key)") | |
5311 | ||
5312 | DEFUN (no_ip_ospf_message_digest_key, | |
5313 | no_ip_ospf_message_digest_key_addr_cmd, | |
5314 | "no ip ospf message-digest-key <1-255> A.B.C.D", | |
5315 | NO_STR | |
5316 | "IP Information\n" | |
5317 | "OSPF interface commands\n" | |
5318 | "Message digest authentication password (key)\n" | |
5319 | "Key ID\n" | |
5320 | "Address of interface") | |
5321 | { | |
5322 | struct interface *ifp; | |
5323 | struct crypt_key *ck; | |
5324 | int key_id; | |
5325 | struct in_addr addr; | |
5326 | int ret; | |
5327 | struct ospf_if_params *params; | |
5328 | ||
5329 | ifp = vty->index; | |
5330 | params = IF_DEF_PARAMS (ifp); | |
5331 | ||
5332 | if (argc == 2) | |
5333 | { | |
5334 | ret = inet_aton(argv[1], &addr); | |
5335 | if (!ret) | |
5336 | { | |
5337 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
5338 | VTY_NEWLINE); | |
5339 | return CMD_WARNING; | |
5340 | } | |
5341 | ||
5342 | params = ospf_lookup_if_params (ifp, addr); | |
5343 | if (params == NULL) | |
5344 | return CMD_SUCCESS; | |
5345 | } | |
5346 | ||
5347 | key_id = strtol (argv[0], NULL, 10); | |
5348 | ck = ospf_crypt_key_lookup (params->auth_crypt, key_id); | |
5349 | if (ck == NULL) | |
5350 | { | |
5351 | vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE); | |
5352 | return CMD_WARNING; | |
5353 | } | |
5354 | ||
5355 | ospf_crypt_key_delete (params->auth_crypt, key_id); | |
5356 | ||
5357 | if (params != IF_DEF_PARAMS (ifp)) | |
5358 | { | |
5359 | ospf_free_if_params (ifp, addr); | |
5360 | ospf_if_update_params (ifp, addr); | |
5361 | } | |
5362 | ||
5363 | return CMD_SUCCESS; | |
5364 | } | |
5365 | ||
5366 | ALIAS (no_ip_ospf_message_digest_key, | |
5367 | no_ip_ospf_message_digest_key_cmd, | |
5368 | "no ip ospf message-digest-key <1-255>", | |
5369 | NO_STR | |
5370 | "IP Information\n" | |
5371 | "OSPF interface commands\n" | |
5372 | "Message digest authentication password (key)\n" | |
5373 | "Key ID\n") | |
5374 | ||
5375 | ALIAS (no_ip_ospf_message_digest_key, | |
5376 | no_ospf_message_digest_key_cmd, | |
5377 | "no ospf message-digest-key <1-255>", | |
5378 | NO_STR | |
5379 | "OSPF interface commands\n" | |
5380 | "Message digest authentication password (key)\n" | |
5381 | "Key ID\n") | |
5382 | ||
5383 | DEFUN (ip_ospf_cost, | |
9eff36b3 | 5384 | ip_ospf_cost_u32_inet4_cmd, |
718e3744 | 5385 | "ip ospf cost <1-65535> A.B.C.D", |
5386 | "IP Information\n" | |
5387 | "OSPF interface commands\n" | |
5388 | "Interface cost\n" | |
5389 | "Cost\n" | |
5390 | "Address of interface") | |
5391 | { | |
5392 | struct interface *ifp = vty->index; | |
5393 | u_int32_t cost; | |
5394 | struct in_addr addr; | |
5395 | int ret; | |
5396 | struct ospf_if_params *params; | |
5397 | ||
5398 | params = IF_DEF_PARAMS (ifp); | |
5399 | ||
5400 | cost = strtol (argv[0], NULL, 10); | |
5401 | ||
5402 | /* cost range is <1-65535>. */ | |
5403 | if (cost < 1 || cost > 65535) | |
5404 | { | |
5405 | vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE); | |
5406 | return CMD_WARNING; | |
5407 | } | |
5408 | ||
5409 | if (argc == 2) | |
5410 | { | |
5411 | ret = inet_aton(argv[1], &addr); | |
5412 | if (!ret) | |
5413 | { | |
5414 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
5415 | VTY_NEWLINE); | |
5416 | return CMD_WARNING; | |
5417 | } | |
5418 | ||
5419 | params = ospf_get_if_params (ifp, addr); | |
5420 | ospf_if_update_params (ifp, addr); | |
5421 | } | |
5422 | ||
5423 | SET_IF_PARAM (params, output_cost_cmd); | |
5424 | params->output_cost_cmd = cost; | |
5425 | ||
5426 | ospf_if_recalculate_output_cost (ifp); | |
5427 | ||
5428 | return CMD_SUCCESS; | |
5429 | } | |
5430 | ||
5431 | ALIAS (ip_ospf_cost, | |
9eff36b3 | 5432 | ip_ospf_cost_u32_cmd, |
718e3744 | 5433 | "ip ospf cost <1-65535>", |
5434 | "IP Information\n" | |
5435 | "OSPF interface commands\n" | |
5436 | "Interface cost\n" | |
5437 | "Cost") | |
5438 | ||
5439 | ALIAS (ip_ospf_cost, | |
9eff36b3 | 5440 | ospf_cost_u32_cmd, |
718e3744 | 5441 | "ospf cost <1-65535>", |
5442 | "OSPF interface commands\n" | |
5443 | "Interface cost\n" | |
5444 | "Cost") | |
5445 | ||
9eff36b3 DO |
5446 | ALIAS (ip_ospf_cost, |
5447 | ospf_cost_u32_inet4_cmd, | |
5448 | "ospf cost <1-65535> A.B.C.D", | |
5449 | "OSPF interface commands\n" | |
5450 | "Interface cost\n" | |
5451 | "Cost\n" | |
5452 | "Address of interface") | |
5453 | ||
718e3744 | 5454 | DEFUN (no_ip_ospf_cost, |
9eff36b3 | 5455 | no_ip_ospf_cost_inet4_cmd, |
718e3744 | 5456 | "no ip ospf cost A.B.C.D", |
5457 | NO_STR | |
5458 | "IP Information\n" | |
5459 | "OSPF interface commands\n" | |
5460 | "Interface cost\n" | |
5461 | "Address of interface") | |
5462 | { | |
5463 | struct interface *ifp = vty->index; | |
5464 | struct in_addr addr; | |
5465 | int ret; | |
5466 | struct ospf_if_params *params; | |
5467 | ||
5468 | ifp = vty->index; | |
5469 | params = IF_DEF_PARAMS (ifp); | |
5470 | ||
5471 | if (argc == 1) | |
5472 | { | |
5473 | ret = inet_aton(argv[0], &addr); | |
5474 | if (!ret) | |
5475 | { | |
5476 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
5477 | VTY_NEWLINE); | |
5478 | return CMD_WARNING; | |
5479 | } | |
5480 | ||
5481 | params = ospf_lookup_if_params (ifp, addr); | |
5482 | if (params == NULL) | |
5483 | return CMD_SUCCESS; | |
5484 | } | |
5485 | ||
5486 | UNSET_IF_PARAM (params, output_cost_cmd); | |
5487 | ||
5488 | if (params != IF_DEF_PARAMS (ifp)) | |
5489 | { | |
5490 | ospf_free_if_params (ifp, addr); | |
5491 | ospf_if_update_params (ifp, addr); | |
5492 | } | |
5493 | ||
5494 | ospf_if_recalculate_output_cost (ifp); | |
5495 | ||
5496 | return CMD_SUCCESS; | |
5497 | } | |
5498 | ||
5499 | ALIAS (no_ip_ospf_cost, | |
5500 | no_ip_ospf_cost_cmd, | |
5501 | "no ip ospf cost", | |
5502 | NO_STR | |
5503 | "IP Information\n" | |
5504 | "OSPF interface commands\n" | |
5505 | "Interface cost\n") | |
5506 | ||
5507 | ALIAS (no_ip_ospf_cost, | |
5508 | no_ospf_cost_cmd, | |
5509 | "no ospf cost", | |
5510 | NO_STR | |
5511 | "OSPF interface commands\n" | |
5512 | "Interface cost\n") | |
5513 | ||
9eff36b3 DO |
5514 | ALIAS (no_ip_ospf_cost, |
5515 | no_ospf_cost_inet4_cmd, | |
5516 | "no ospf cost A.B.C.D", | |
5517 | NO_STR | |
5518 | "OSPF interface commands\n" | |
5519 | "Interface cost\n" | |
5520 | "Address of interface") | |
5521 | ||
827341b7 DO |
5522 | DEFUN (no_ip_ospf_cost2, |
5523 | no_ip_ospf_cost_u32_cmd, | |
5524 | "no ip ospf cost <1-65535>", | |
5525 | NO_STR | |
5526 | "IP Information\n" | |
5527 | "OSPF interface commands\n" | |
5528 | "Interface cost\n" | |
5529 | "Cost") | |
5530 | { | |
5531 | struct interface *ifp = vty->index; | |
5532 | struct in_addr addr; | |
5533 | u_int32_t cost; | |
5534 | int ret; | |
5535 | struct ospf_if_params *params; | |
5536 | ||
5537 | ifp = vty->index; | |
5538 | params = IF_DEF_PARAMS (ifp); | |
5539 | ||
5540 | /* According to the semantics we are mimicking "no ip ospf cost N" is | |
5541 | * always treated as "no ip ospf cost" regardless of the actual value | |
5542 | * of N already configured for the interface. Thus the first argument | |
5543 | * is always checked to be a number, but is ignored after that. | |
5544 | */ | |
5545 | cost = strtol (argv[0], NULL, 10); | |
5546 | if (cost < 1 || cost > 65535) | |
5547 | { | |
5548 | vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE); | |
5549 | return CMD_WARNING; | |
5550 | } | |
5551 | ||
5552 | if (argc == 2) | |
5553 | { | |
5554 | ret = inet_aton(argv[1], &addr); | |
5555 | if (!ret) | |
5556 | { | |
5557 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
5558 | VTY_NEWLINE); | |
5559 | return CMD_WARNING; | |
5560 | } | |
5561 | ||
5562 | params = ospf_lookup_if_params (ifp, addr); | |
5563 | if (params == NULL) | |
5564 | return CMD_SUCCESS; | |
5565 | } | |
5566 | ||
5567 | UNSET_IF_PARAM (params, output_cost_cmd); | |
5568 | ||
5569 | if (params != IF_DEF_PARAMS (ifp)) | |
5570 | { | |
5571 | ospf_free_if_params (ifp, addr); | |
5572 | ospf_if_update_params (ifp, addr); | |
5573 | } | |
5574 | ||
5575 | ospf_if_recalculate_output_cost (ifp); | |
5576 | ||
5577 | return CMD_SUCCESS; | |
5578 | } | |
5579 | ||
5580 | ALIAS (no_ip_ospf_cost2, | |
5581 | no_ospf_cost_u32_cmd, | |
5582 | "no ospf cost <1-65535>", | |
5583 | NO_STR | |
5584 | "OSPF interface commands\n" | |
5585 | "Interface cost\n" | |
5586 | "Cost") | |
5587 | ||
5588 | ALIAS (no_ip_ospf_cost2, | |
5589 | no_ip_ospf_cost_u32_inet4_cmd, | |
5590 | "no ip ospf cost <1-65535> A.B.C.D", | |
5591 | NO_STR | |
5592 | "IP Information\n" | |
5593 | "OSPF interface commands\n" | |
5594 | "Interface cost\n" | |
5595 | "Cost\n" | |
5596 | "Address of interface") | |
5597 | ||
5598 | ALIAS (no_ip_ospf_cost2, | |
5599 | no_ospf_cost_u32_inet4_cmd, | |
5600 | "no ospf cost <1-65535> A.B.C.D", | |
5601 | NO_STR | |
5602 | "OSPF interface commands\n" | |
5603 | "Interface cost\n" | |
5604 | "Cost\n" | |
5605 | "Address of interface") | |
9eff36b3 | 5606 | |
4dadc291 | 5607 | static void |
718e3744 | 5608 | ospf_nbr_timer_update (struct ospf_interface *oi) |
5609 | { | |
5610 | struct route_node *rn; | |
5611 | struct ospf_neighbor *nbr; | |
5612 | ||
5613 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) | |
5614 | if ((nbr = rn->info)) | |
5615 | { | |
5616 | nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait); | |
5617 | nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval); | |
5618 | nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval); | |
5619 | nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval); | |
5620 | } | |
5621 | } | |
5622 | ||
f9ad937f | 5623 | static int |
5624 | ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str, | |
5625 | const char *nbr_str, | |
5626 | const char *fast_hello_str) | |
718e3744 | 5627 | { |
5628 | struct interface *ifp = vty->index; | |
5629 | u_int32_t seconds; | |
f9ad937f | 5630 | u_char hellomult; |
718e3744 | 5631 | struct in_addr addr; |
5632 | int ret; | |
5633 | struct ospf_if_params *params; | |
5634 | struct ospf_interface *oi; | |
5635 | struct route_node *rn; | |
5636 | ||
5637 | params = IF_DEF_PARAMS (ifp); | |
f9ad937f | 5638 | |
5639 | if (nbr_str) | |
718e3744 | 5640 | { |
f9ad937f | 5641 | ret = inet_aton(nbr_str, &addr); |
718e3744 | 5642 | if (!ret) |
5643 | { | |
5644 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
5645 | VTY_NEWLINE); | |
5646 | return CMD_WARNING; | |
5647 | } | |
5648 | ||
5649 | params = ospf_get_if_params (ifp, addr); | |
5650 | ospf_if_update_params (ifp, addr); | |
5651 | } | |
5652 | ||
f9ad937f | 5653 | if (interval_str) |
5654 | { | |
5655 | VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str, | |
5656 | 1, 65535); | |
5657 | ||
5658 | /* reset fast_hello too, just to be sure */ | |
5659 | UNSET_IF_PARAM (params, fast_hello); | |
5660 | params->fast_hello = OSPF_FAST_HELLO_DEFAULT; | |
5661 | } | |
5662 | else if (fast_hello_str) | |
5663 | { | |
5664 | VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str, | |
5665 | 1, 10); | |
5666 | /* 1s dead-interval with sub-second hellos desired */ | |
5667 | seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL; | |
5668 | SET_IF_PARAM (params, fast_hello); | |
5669 | params->fast_hello = hellomult; | |
5670 | } | |
5671 | else | |
5672 | { | |
5673 | vty_out (vty, "Please specify dead-interval or hello-multiplier%s", | |
5674 | VTY_NEWLINE); | |
5675 | return CMD_WARNING; | |
5676 | } | |
5677 | ||
718e3744 | 5678 | SET_IF_PARAM (params, v_wait); |
5679 | params->v_wait = seconds; | |
5680 | ||
5681 | /* Update timer values in neighbor structure. */ | |
f9ad937f | 5682 | if (nbr_str) |
718e3744 | 5683 | { |
cac3b5c4 PJ |
5684 | struct ospf *ospf; |
5685 | if ((ospf = ospf_lookup())) | |
68980084 | 5686 | { |
5687 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); | |
5688 | if (oi) | |
5689 | ospf_nbr_timer_update (oi); | |
5690 | } | |
718e3744 | 5691 | } |
5692 | else | |
5693 | { | |
5694 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
5695 | if ((oi = rn->info)) | |
5696 | ospf_nbr_timer_update (oi); | |
5697 | } | |
5698 | ||
5699 | return CMD_SUCCESS; | |
5700 | } | |
5701 | ||
f9ad937f | 5702 | |
5703 | DEFUN (ip_ospf_dead_interval, | |
5704 | ip_ospf_dead_interval_addr_cmd, | |
5705 | "ip ospf dead-interval <1-65535> A.B.C.D", | |
5706 | "IP Information\n" | |
5707 | "OSPF interface commands\n" | |
5708 | "Interval after which a neighbor is declared dead\n" | |
5709 | "Seconds\n" | |
5710 | "Address of interface\n") | |
5711 | { | |
5712 | if (argc == 2) | |
5713 | return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL); | |
5714 | else | |
5715 | return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL); | |
5716 | } | |
5717 | ||
718e3744 | 5718 | ALIAS (ip_ospf_dead_interval, |
5719 | ip_ospf_dead_interval_cmd, | |
5720 | "ip ospf dead-interval <1-65535>", | |
5721 | "IP Information\n" | |
5722 | "OSPF interface commands\n" | |
5723 | "Interval after which a neighbor is declared dead\n" | |
5724 | "Seconds\n") | |
5725 | ||
5726 | ALIAS (ip_ospf_dead_interval, | |
5727 | ospf_dead_interval_cmd, | |
5728 | "ospf dead-interval <1-65535>", | |
5729 | "OSPF interface commands\n" | |
5730 | "Interval after which a neighbor is declared dead\n" | |
5731 | "Seconds\n") | |
5732 | ||
f9ad937f | 5733 | DEFUN (ip_ospf_dead_interval_minimal, |
5734 | ip_ospf_dead_interval_minimal_addr_cmd, | |
5735 | "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D", | |
5736 | "IP Information\n" | |
5737 | "OSPF interface commands\n" | |
5738 | "Interval after which a neighbor is declared dead\n" | |
5739 | "Minimal 1s dead-interval with fast sub-second hellos\n" | |
5740 | "Hello multiplier factor\n" | |
5741 | "Number of Hellos to send each second\n" | |
5742 | "Address of interface\n") | |
5743 | { | |
5744 | if (argc == 2) | |
5745 | return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]); | |
5746 | else | |
5747 | return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]); | |
5748 | } | |
5749 | ||
5750 | ALIAS (ip_ospf_dead_interval_minimal, | |
5751 | ip_ospf_dead_interval_minimal_cmd, | |
5752 | "ip ospf dead-interval minimal hello-multiplier <1-10>", | |
5753 | "IP Information\n" | |
5754 | "OSPF interface commands\n" | |
5755 | "Interval after which a neighbor is declared dead\n" | |
5756 | "Minimal 1s dead-interval with fast sub-second hellos\n" | |
5757 | "Hello multiplier factor\n" | |
5758 | "Number of Hellos to send each second\n") | |
5759 | ||
718e3744 | 5760 | DEFUN (no_ip_ospf_dead_interval, |
5761 | no_ip_ospf_dead_interval_addr_cmd, | |
f9dfba8d | 5762 | "no ip ospf dead-interval <1-65535> A.B.C.D", |
718e3744 | 5763 | NO_STR |
5764 | "IP Information\n" | |
5765 | "OSPF interface commands\n" | |
5766 | "Interval after which a neighbor is declared dead\n" | |
f9dfba8d | 5767 | "Seconds\n" |
718e3744 | 5768 | "Address of interface") |
5769 | { | |
5770 | struct interface *ifp = vty->index; | |
5771 | struct in_addr addr; | |
5772 | int ret; | |
5773 | struct ospf_if_params *params; | |
5774 | struct ospf_interface *oi; | |
5775 | struct route_node *rn; | |
020709f9 | 5776 | |
718e3744 | 5777 | ifp = vty->index; |
5778 | params = IF_DEF_PARAMS (ifp); | |
5779 | ||
f9dfba8d | 5780 | if (argc == 2) |
718e3744 | 5781 | { |
f9dfba8d | 5782 | ret = inet_aton(argv[1], &addr); |
718e3744 | 5783 | if (!ret) |
5784 | { | |
5785 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
5786 | VTY_NEWLINE); | |
5787 | return CMD_WARNING; | |
5788 | } | |
5789 | ||
5790 | params = ospf_lookup_if_params (ifp, addr); | |
5791 | if (params == NULL) | |
5792 | return CMD_SUCCESS; | |
5793 | } | |
5794 | ||
5795 | UNSET_IF_PARAM (params, v_wait); | |
5796 | params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; | |
f9ad937f | 5797 | |
5798 | UNSET_IF_PARAM (params, fast_hello); | |
5799 | params->fast_hello = OSPF_FAST_HELLO_DEFAULT; | |
5800 | ||
718e3744 | 5801 | if (params != IF_DEF_PARAMS (ifp)) |
5802 | { | |
5803 | ospf_free_if_params (ifp, addr); | |
5804 | ospf_if_update_params (ifp, addr); | |
5805 | } | |
5806 | ||
5807 | /* Update timer values in neighbor structure. */ | |
5808 | if (argc == 1) | |
5809 | { | |
cac3b5c4 PJ |
5810 | struct ospf *ospf; |
5811 | ||
5812 | if ((ospf = ospf_lookup())) | |
68980084 | 5813 | { |
5814 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); | |
5815 | if (oi) | |
5816 | ospf_nbr_timer_update (oi); | |
5817 | } | |
718e3744 | 5818 | } |
5819 | else | |
5820 | { | |
5821 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
5822 | if ((oi = rn->info)) | |
5823 | ospf_nbr_timer_update (oi); | |
5824 | } | |
5825 | ||
5826 | return CMD_SUCCESS; | |
5827 | } | |
5828 | ||
f9dfba8d DS |
5829 | ALIAS (no_ip_ospf_dead_interval, |
5830 | no_ip_ospf_dead_interval_seconds_cmd, | |
5831 | "no ip ospf dead-interval <1-65535>", | |
5832 | NO_STR | |
5833 | "IP Information\n" | |
5834 | "OSPF interface commands\n" | |
5835 | "Interval after which a neighbor is declared dead\n" | |
5836 | "Seconds\n") | |
5837 | ||
718e3744 | 5838 | ALIAS (no_ip_ospf_dead_interval, |
5839 | no_ip_ospf_dead_interval_cmd, | |
5840 | "no ip ospf dead-interval", | |
5841 | NO_STR | |
5842 | "IP Information\n" | |
5843 | "OSPF interface commands\n" | |
5844 | "Interval after which a neighbor is declared dead\n") | |
5845 | ||
5846 | ALIAS (no_ip_ospf_dead_interval, | |
5847 | no_ospf_dead_interval_cmd, | |
5848 | "no ospf dead-interval", | |
5849 | NO_STR | |
5850 | "OSPF interface commands\n" | |
5851 | "Interval after which a neighbor is declared dead\n") | |
5852 | ||
5853 | DEFUN (ip_ospf_hello_interval, | |
5854 | ip_ospf_hello_interval_addr_cmd, | |
5855 | "ip ospf hello-interval <1-65535> A.B.C.D", | |
5856 | "IP Information\n" | |
5857 | "OSPF interface commands\n" | |
5858 | "Time between HELLO packets\n" | |
5859 | "Seconds\n" | |
5860 | "Address of interface") | |
5861 | { | |
5862 | struct interface *ifp = vty->index; | |
5863 | u_int32_t seconds; | |
5864 | struct in_addr addr; | |
5865 | int ret; | |
5866 | struct ospf_if_params *params; | |
5867 | ||
5868 | params = IF_DEF_PARAMS (ifp); | |
5869 | ||
5870 | seconds = strtol (argv[0], NULL, 10); | |
5871 | ||
5872 | /* HelloInterval range is <1-65535>. */ | |
5873 | if (seconds < 1 || seconds > 65535) | |
5874 | { | |
5875 | vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE); | |
5876 | return CMD_WARNING; | |
5877 | } | |
5878 | ||
5879 | if (argc == 2) | |
5880 | { | |
5881 | ret = inet_aton(argv[1], &addr); | |
5882 | if (!ret) | |
5883 | { | |
5884 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
5885 | VTY_NEWLINE); | |
5886 | return CMD_WARNING; | |
5887 | } | |
5888 | ||
5889 | params = ospf_get_if_params (ifp, addr); | |
5890 | ospf_if_update_params (ifp, addr); | |
5891 | } | |
5892 | ||
f9ad937f | 5893 | SET_IF_PARAM (params, v_hello); |
718e3744 | 5894 | params->v_hello = seconds; |
5895 | ||
5896 | return CMD_SUCCESS; | |
5897 | } | |
5898 | ||
5899 | ALIAS (ip_ospf_hello_interval, | |
5900 | ip_ospf_hello_interval_cmd, | |
5901 | "ip ospf hello-interval <1-65535>", | |
5902 | "IP Information\n" | |
5903 | "OSPF interface commands\n" | |
5904 | "Time between HELLO packets\n" | |
5905 | "Seconds\n") | |
5906 | ||
5907 | ALIAS (ip_ospf_hello_interval, | |
5908 | ospf_hello_interval_cmd, | |
5909 | "ospf hello-interval <1-65535>", | |
5910 | "OSPF interface commands\n" | |
5911 | "Time between HELLO packets\n" | |
5912 | "Seconds\n") | |
5913 | ||
5914 | DEFUN (no_ip_ospf_hello_interval, | |
5915 | no_ip_ospf_hello_interval_addr_cmd, | |
f9dfba8d | 5916 | "no ip ospf hello-interval <1-65535> A.B.C.D", |
718e3744 | 5917 | NO_STR |
5918 | "IP Information\n" | |
5919 | "OSPF interface commands\n" | |
5920 | "Time between HELLO packets\n" | |
f9dfba8d | 5921 | "Seconds\n" |
718e3744 | 5922 | "Address of interface") |
5923 | { | |
5924 | struct interface *ifp = vty->index; | |
5925 | struct in_addr addr; | |
5926 | int ret; | |
5927 | struct ospf_if_params *params; | |
5928 | ||
5929 | ifp = vty->index; | |
5930 | params = IF_DEF_PARAMS (ifp); | |
5931 | ||
f9dfba8d | 5932 | if (argc == 2) |
718e3744 | 5933 | { |
f9dfba8d | 5934 | ret = inet_aton(argv[1], &addr); |
718e3744 | 5935 | if (!ret) |
5936 | { | |
5937 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
5938 | VTY_NEWLINE); | |
5939 | return CMD_WARNING; | |
5940 | } | |
5941 | ||
5942 | params = ospf_lookup_if_params (ifp, addr); | |
5943 | if (params == NULL) | |
5944 | return CMD_SUCCESS; | |
5945 | } | |
5946 | ||
5947 | UNSET_IF_PARAM (params, v_hello); | |
f9ad937f | 5948 | params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT; |
718e3744 | 5949 | |
5950 | if (params != IF_DEF_PARAMS (ifp)) | |
5951 | { | |
5952 | ospf_free_if_params (ifp, addr); | |
5953 | ospf_if_update_params (ifp, addr); | |
5954 | } | |
5955 | ||
5956 | return CMD_SUCCESS; | |
5957 | } | |
5958 | ||
f9dfba8d DS |
5959 | ALIAS (no_ip_ospf_hello_interval, |
5960 | no_ip_ospf_hello_interval_seconds_cmd, | |
5961 | "no ip ospf hello-interval <1-65535>", | |
5962 | NO_STR | |
5963 | "IP Information\n" | |
5964 | "OSPF interface commands\n" | |
5965 | "Time between HELLO packets\n" | |
5966 | "Seconds\n") | |
5967 | ||
718e3744 | 5968 | ALIAS (no_ip_ospf_hello_interval, |
5969 | no_ip_ospf_hello_interval_cmd, | |
5970 | "no ip ospf hello-interval", | |
5971 | NO_STR | |
5972 | "IP Information\n" | |
5973 | "OSPF interface commands\n" | |
5974 | "Time between HELLO packets\n") | |
5975 | ||
5976 | ALIAS (no_ip_ospf_hello_interval, | |
5977 | no_ospf_hello_interval_cmd, | |
5978 | "no ospf hello-interval", | |
5979 | NO_STR | |
5980 | "OSPF interface commands\n" | |
5981 | "Time between HELLO packets\n") | |
5982 | ||
5983 | DEFUN (ip_ospf_network, | |
5984 | ip_ospf_network_cmd, | |
5985 | "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", | |
5986 | "IP Information\n" | |
5987 | "OSPF interface commands\n" | |
5988 | "Network type\n" | |
5989 | "Specify OSPF broadcast multi-access network\n" | |
5990 | "Specify OSPF NBMA network\n" | |
5991 | "Specify OSPF point-to-multipoint network\n" | |
5992 | "Specify OSPF point-to-point network\n") | |
5993 | { | |
5994 | struct interface *ifp = vty->index; | |
5995 | int old_type = IF_DEF_PARAMS (ifp)->type; | |
5996 | struct route_node *rn; | |
4b4bda9b CF |
5997 | |
5998 | if (old_type == OSPF_IFTYPE_LOOPBACK) | |
5999 | { | |
6000 | vty_out (vty, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE); | |
6001 | return CMD_WARNING; | |
6002 | } | |
6003 | ||
718e3744 | 6004 | if (strncmp (argv[0], "b", 1) == 0) |
6005 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST; | |
6006 | else if (strncmp (argv[0], "n", 1) == 0) | |
6007 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA; | |
6008 | else if (strncmp (argv[0], "point-to-m", 10) == 0) | |
6009 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT; | |
6010 | else if (strncmp (argv[0], "point-to-p", 10) == 0) | |
6011 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT; | |
6012 | ||
6013 | if (IF_DEF_PARAMS (ifp)->type == old_type) | |
6014 | return CMD_SUCCESS; | |
6015 | ||
6016 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), type); | |
6017 | ||
6018 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
6019 | { | |
6020 | struct ospf_interface *oi = rn->info; | |
6021 | ||
6022 | if (!oi) | |
6023 | continue; | |
6024 | ||
6025 | oi->type = IF_DEF_PARAMS (ifp)->type; | |
6026 | ||
6027 | if (oi->state > ISM_Down) | |
6028 | { | |
6029 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); | |
6030 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); | |
6031 | } | |
6032 | } | |
6033 | ||
6034 | return CMD_SUCCESS; | |
6035 | } | |
6036 | ||
6037 | ALIAS (ip_ospf_network, | |
6038 | ospf_network_cmd, | |
6039 | "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", | |
6040 | "OSPF interface commands\n" | |
6041 | "Network type\n" | |
6042 | "Specify OSPF broadcast multi-access network\n" | |
6043 | "Specify OSPF NBMA network\n" | |
6044 | "Specify OSPF point-to-multipoint network\n" | |
6045 | "Specify OSPF point-to-point network\n") | |
6046 | ||
6047 | DEFUN (no_ip_ospf_network, | |
6048 | no_ip_ospf_network_cmd, | |
6049 | "no ip ospf network", | |
6050 | NO_STR | |
6051 | "IP Information\n" | |
6052 | "OSPF interface commands\n" | |
6053 | "Network type\n") | |
6054 | { | |
6055 | struct interface *ifp = vty->index; | |
6056 | int old_type = IF_DEF_PARAMS (ifp)->type; | |
6057 | struct route_node *rn; | |
6058 | ||
bc18d616 | 6059 | IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp); |
718e3744 | 6060 | |
6061 | if (IF_DEF_PARAMS (ifp)->type == old_type) | |
6062 | return CMD_SUCCESS; | |
6063 | ||
6064 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
6065 | { | |
6066 | struct ospf_interface *oi = rn->info; | |
6067 | ||
6068 | if (!oi) | |
6069 | continue; | |
6070 | ||
6071 | oi->type = IF_DEF_PARAMS (ifp)->type; | |
6072 | ||
6073 | if (oi->state > ISM_Down) | |
6074 | { | |
6075 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); | |
6076 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); | |
6077 | } | |
6078 | } | |
6079 | ||
6080 | return CMD_SUCCESS; | |
6081 | } | |
6082 | ||
6083 | ALIAS (no_ip_ospf_network, | |
6084 | no_ospf_network_cmd, | |
6085 | "no ospf network", | |
6086 | NO_STR | |
6087 | "OSPF interface commands\n" | |
6088 | "Network type\n") | |
6089 | ||
6090 | DEFUN (ip_ospf_priority, | |
6091 | ip_ospf_priority_addr_cmd, | |
6092 | "ip ospf priority <0-255> A.B.C.D", | |
6093 | "IP Information\n" | |
6094 | "OSPF interface commands\n" | |
6095 | "Router priority\n" | |
6096 | "Priority\n" | |
6097 | "Address of interface") | |
6098 | { | |
6099 | struct interface *ifp = vty->index; | |
0798cee3 | 6100 | long priority; |
718e3744 | 6101 | struct route_node *rn; |
6102 | struct in_addr addr; | |
6103 | int ret; | |
6104 | struct ospf_if_params *params; | |
6105 | ||
6106 | params = IF_DEF_PARAMS (ifp); | |
6107 | ||
6108 | priority = strtol (argv[0], NULL, 10); | |
6109 | ||
6110 | /* Router Priority range is <0-255>. */ | |
6111 | if (priority < 0 || priority > 255) | |
6112 | { | |
6113 | vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE); | |
6114 | return CMD_WARNING; | |
6115 | } | |
6116 | ||
6117 | if (argc == 2) | |
6118 | { | |
6119 | ret = inet_aton(argv[1], &addr); | |
6120 | if (!ret) | |
6121 | { | |
6122 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6123 | VTY_NEWLINE); | |
6124 | return CMD_WARNING; | |
6125 | } | |
6126 | ||
6127 | params = ospf_get_if_params (ifp, addr); | |
6128 | ospf_if_update_params (ifp, addr); | |
6129 | } | |
6130 | ||
6131 | SET_IF_PARAM (params, priority); | |
6132 | params->priority = priority; | |
6133 | ||
6134 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
6135 | { | |
6136 | struct ospf_interface *oi = rn->info; | |
6137 | ||
6138 | if (!oi) | |
6139 | continue; | |
6140 | ||
6141 | ||
6142 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) | |
6143 | { | |
6144 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); | |
6145 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); | |
6146 | } | |
6147 | } | |
6148 | ||
6149 | return CMD_SUCCESS; | |
6150 | } | |
6151 | ||
6152 | ALIAS (ip_ospf_priority, | |
6153 | ip_ospf_priority_cmd, | |
6154 | "ip ospf priority <0-255>", | |
6155 | "IP Information\n" | |
6156 | "OSPF interface commands\n" | |
6157 | "Router priority\n" | |
6158 | "Priority\n") | |
6159 | ||
6160 | ALIAS (ip_ospf_priority, | |
6161 | ospf_priority_cmd, | |
6162 | "ospf priority <0-255>", | |
6163 | "OSPF interface commands\n" | |
6164 | "Router priority\n" | |
6165 | "Priority\n") | |
6166 | ||
6167 | DEFUN (no_ip_ospf_priority, | |
6168 | no_ip_ospf_priority_addr_cmd, | |
6169 | "no ip ospf priority A.B.C.D", | |
6170 | NO_STR | |
6171 | "IP Information\n" | |
6172 | "OSPF interface commands\n" | |
6173 | "Router priority\n" | |
6174 | "Address of interface") | |
6175 | { | |
6176 | struct interface *ifp = vty->index; | |
6177 | struct route_node *rn; | |
6178 | struct in_addr addr; | |
6179 | int ret; | |
6180 | struct ospf_if_params *params; | |
6181 | ||
6182 | ifp = vty->index; | |
6183 | params = IF_DEF_PARAMS (ifp); | |
6184 | ||
6185 | if (argc == 1) | |
6186 | { | |
6187 | ret = inet_aton(argv[0], &addr); | |
6188 | if (!ret) | |
6189 | { | |
6190 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6191 | VTY_NEWLINE); | |
6192 | return CMD_WARNING; | |
6193 | } | |
6194 | ||
6195 | params = ospf_lookup_if_params (ifp, addr); | |
6196 | if (params == NULL) | |
6197 | return CMD_SUCCESS; | |
6198 | } | |
6199 | ||
6200 | UNSET_IF_PARAM (params, priority); | |
6201 | params->priority = OSPF_ROUTER_PRIORITY_DEFAULT; | |
6202 | ||
6203 | if (params != IF_DEF_PARAMS (ifp)) | |
6204 | { | |
6205 | ospf_free_if_params (ifp, addr); | |
6206 | ospf_if_update_params (ifp, addr); | |
6207 | } | |
6208 | ||
6209 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
6210 | { | |
6211 | struct ospf_interface *oi = rn->info; | |
6212 | ||
6213 | if (!oi) | |
6214 | continue; | |
6215 | ||
6216 | ||
6217 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) | |
6218 | { | |
6219 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); | |
6220 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); | |
6221 | } | |
6222 | } | |
6223 | ||
6224 | return CMD_SUCCESS; | |
6225 | } | |
6226 | ||
6227 | ALIAS (no_ip_ospf_priority, | |
6228 | no_ip_ospf_priority_cmd, | |
6229 | "no ip ospf priority", | |
6230 | NO_STR | |
6231 | "IP Information\n" | |
6232 | "OSPF interface commands\n" | |
6233 | "Router priority\n") | |
6234 | ||
6235 | ALIAS (no_ip_ospf_priority, | |
6236 | no_ospf_priority_cmd, | |
6237 | "no ospf priority", | |
6238 | NO_STR | |
6239 | "OSPF interface commands\n" | |
6240 | "Router priority\n") | |
6241 | ||
d5a5c8f0 DS |
6242 | DEFUN (ip_ospf_bfd, |
6243 | ip_ospf_bfd_cmd, | |
6244 | "ip ospf bfd", | |
6245 | "IP Information\n" | |
6246 | "OSPF interface commands\n" | |
6247 | "Respond to BFD session event\n") | |
6248 | { | |
6249 | struct interface *ifp = vty->index; | |
6250 | struct ospf_if_params *params; | |
6251 | ||
6252 | params = IF_DEF_PARAMS (ifp); | |
6253 | SET_IF_PARAM (params, bfd); | |
6254 | ||
6255 | return CMD_SUCCESS; | |
6256 | } | |
6257 | ||
6258 | DEFUN (no_ip_ospf_bfd, | |
6259 | no_ip_ospf_bfd_cmd, | |
6260 | "no ip ospf bfd", | |
6261 | NO_STR | |
6262 | "IP Information\n" | |
6263 | "OSPF interface commands\n" | |
6264 | "Respond to BFD session event\n") | |
6265 | { | |
6266 | struct interface *ifp = vty->index; | |
6267 | struct ospf_if_params *params; | |
6268 | ||
6269 | params = IF_DEF_PARAMS (ifp); | |
6270 | UNSET_IF_PARAM (params, bfd); | |
6271 | ||
6272 | return CMD_SUCCESS; | |
6273 | } | |
6274 | ||
6275 | ||
718e3744 | 6276 | DEFUN (ip_ospf_retransmit_interval, |
6277 | ip_ospf_retransmit_interval_addr_cmd, | |
6278 | "ip ospf retransmit-interval <3-65535> A.B.C.D", | |
6279 | "IP Information\n" | |
6280 | "OSPF interface commands\n" | |
6281 | "Time between retransmitting lost link state advertisements\n" | |
6282 | "Seconds\n" | |
6283 | "Address of interface") | |
6284 | { | |
6285 | struct interface *ifp = vty->index; | |
6286 | u_int32_t seconds; | |
6287 | struct in_addr addr; | |
6288 | int ret; | |
6289 | struct ospf_if_params *params; | |
6290 | ||
6291 | params = IF_DEF_PARAMS (ifp); | |
6292 | seconds = strtol (argv[0], NULL, 10); | |
6293 | ||
6294 | /* Retransmit Interval range is <3-65535>. */ | |
6295 | if (seconds < 3 || seconds > 65535) | |
6296 | { | |
6297 | vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE); | |
6298 | return CMD_WARNING; | |
6299 | } | |
6300 | ||
6301 | ||
6302 | if (argc == 2) | |
6303 | { | |
6304 | ret = inet_aton(argv[1], &addr); | |
6305 | if (!ret) | |
6306 | { | |
6307 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6308 | VTY_NEWLINE); | |
6309 | return CMD_WARNING; | |
6310 | } | |
6311 | ||
6312 | params = ospf_get_if_params (ifp, addr); | |
6313 | ospf_if_update_params (ifp, addr); | |
6314 | } | |
6315 | ||
6316 | SET_IF_PARAM (params, retransmit_interval); | |
6317 | params->retransmit_interval = seconds; | |
6318 | ||
6319 | return CMD_SUCCESS; | |
6320 | } | |
6321 | ||
6322 | ALIAS (ip_ospf_retransmit_interval, | |
6323 | ip_ospf_retransmit_interval_cmd, | |
6324 | "ip ospf retransmit-interval <3-65535>", | |
6325 | "IP Information\n" | |
6326 | "OSPF interface commands\n" | |
6327 | "Time between retransmitting lost link state advertisements\n" | |
6328 | "Seconds\n") | |
6329 | ||
6330 | ALIAS (ip_ospf_retransmit_interval, | |
6331 | ospf_retransmit_interval_cmd, | |
6332 | "ospf retransmit-interval <3-65535>", | |
6333 | "OSPF interface commands\n" | |
6334 | "Time between retransmitting lost link state advertisements\n" | |
6335 | "Seconds\n") | |
6336 | ||
6337 | DEFUN (no_ip_ospf_retransmit_interval, | |
6338 | no_ip_ospf_retransmit_interval_addr_cmd, | |
6339 | "no ip ospf retransmit-interval A.B.C.D", | |
6340 | NO_STR | |
6341 | "IP Information\n" | |
6342 | "OSPF interface commands\n" | |
6343 | "Time between retransmitting lost link state advertisements\n" | |
6344 | "Address of interface") | |
6345 | { | |
6346 | struct interface *ifp = vty->index; | |
6347 | struct in_addr addr; | |
6348 | int ret; | |
6349 | struct ospf_if_params *params; | |
6350 | ||
6351 | ifp = vty->index; | |
6352 | params = IF_DEF_PARAMS (ifp); | |
6353 | ||
6354 | if (argc == 1) | |
6355 | { | |
6356 | ret = inet_aton(argv[0], &addr); | |
6357 | if (!ret) | |
6358 | { | |
6359 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6360 | VTY_NEWLINE); | |
6361 | return CMD_WARNING; | |
6362 | } | |
6363 | ||
6364 | params = ospf_lookup_if_params (ifp, addr); | |
6365 | if (params == NULL) | |
6366 | return CMD_SUCCESS; | |
6367 | } | |
6368 | ||
6369 | UNSET_IF_PARAM (params, retransmit_interval); | |
6370 | params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; | |
6371 | ||
6372 | if (params != IF_DEF_PARAMS (ifp)) | |
6373 | { | |
6374 | ospf_free_if_params (ifp, addr); | |
6375 | ospf_if_update_params (ifp, addr); | |
6376 | } | |
6377 | ||
6378 | return CMD_SUCCESS; | |
6379 | } | |
6380 | ||
6381 | ALIAS (no_ip_ospf_retransmit_interval, | |
6382 | no_ip_ospf_retransmit_interval_cmd, | |
6383 | "no ip ospf retransmit-interval", | |
6384 | NO_STR | |
6385 | "IP Information\n" | |
6386 | "OSPF interface commands\n" | |
6387 | "Time between retransmitting lost link state advertisements\n") | |
6388 | ||
6389 | ALIAS (no_ip_ospf_retransmit_interval, | |
6390 | no_ospf_retransmit_interval_cmd, | |
6391 | "no ospf retransmit-interval", | |
6392 | NO_STR | |
6393 | "OSPF interface commands\n" | |
6394 | "Time between retransmitting lost link state advertisements\n") | |
6395 | ||
6396 | DEFUN (ip_ospf_transmit_delay, | |
6397 | ip_ospf_transmit_delay_addr_cmd, | |
6398 | "ip ospf transmit-delay <1-65535> A.B.C.D", | |
6399 | "IP Information\n" | |
6400 | "OSPF interface commands\n" | |
6401 | "Link state transmit delay\n" | |
6402 | "Seconds\n" | |
6403 | "Address of interface") | |
6404 | { | |
6405 | struct interface *ifp = vty->index; | |
6406 | u_int32_t seconds; | |
6407 | struct in_addr addr; | |
6408 | int ret; | |
6409 | struct ospf_if_params *params; | |
6410 | ||
6411 | params = IF_DEF_PARAMS (ifp); | |
6412 | seconds = strtol (argv[0], NULL, 10); | |
6413 | ||
6414 | /* Transmit Delay range is <1-65535>. */ | |
6415 | if (seconds < 1 || seconds > 65535) | |
6416 | { | |
6417 | vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE); | |
6418 | return CMD_WARNING; | |
6419 | } | |
6420 | ||
6421 | if (argc == 2) | |
6422 | { | |
6423 | ret = inet_aton(argv[1], &addr); | |
6424 | if (!ret) | |
6425 | { | |
6426 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6427 | VTY_NEWLINE); | |
6428 | return CMD_WARNING; | |
6429 | } | |
6430 | ||
6431 | params = ospf_get_if_params (ifp, addr); | |
6432 | ospf_if_update_params (ifp, addr); | |
6433 | } | |
6434 | ||
6435 | SET_IF_PARAM (params, transmit_delay); | |
6436 | params->transmit_delay = seconds; | |
6437 | ||
6438 | return CMD_SUCCESS; | |
6439 | } | |
6440 | ||
6441 | ALIAS (ip_ospf_transmit_delay, | |
6442 | ip_ospf_transmit_delay_cmd, | |
6443 | "ip ospf transmit-delay <1-65535>", | |
6444 | "IP Information\n" | |
6445 | "OSPF interface commands\n" | |
6446 | "Link state transmit delay\n" | |
6447 | "Seconds\n") | |
6448 | ||
6449 | ALIAS (ip_ospf_transmit_delay, | |
6450 | ospf_transmit_delay_cmd, | |
6451 | "ospf transmit-delay <1-65535>", | |
6452 | "OSPF interface commands\n" | |
6453 | "Link state transmit delay\n" | |
6454 | "Seconds\n") | |
6455 | ||
6456 | DEFUN (no_ip_ospf_transmit_delay, | |
6457 | no_ip_ospf_transmit_delay_addr_cmd, | |
6458 | "no ip ospf transmit-delay A.B.C.D", | |
6459 | NO_STR | |
6460 | "IP Information\n" | |
6461 | "OSPF interface commands\n" | |
6462 | "Link state transmit delay\n" | |
6463 | "Address of interface") | |
6464 | { | |
6465 | struct interface *ifp = vty->index; | |
6466 | struct in_addr addr; | |
6467 | int ret; | |
6468 | struct ospf_if_params *params; | |
6469 | ||
6470 | ifp = vty->index; | |
6471 | params = IF_DEF_PARAMS (ifp); | |
6472 | ||
6473 | if (argc == 1) | |
6474 | { | |
6475 | ret = inet_aton(argv[0], &addr); | |
6476 | if (!ret) | |
6477 | { | |
6478 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6479 | VTY_NEWLINE); | |
6480 | return CMD_WARNING; | |
6481 | } | |
6482 | ||
6483 | params = ospf_lookup_if_params (ifp, addr); | |
6484 | if (params == NULL) | |
6485 | return CMD_SUCCESS; | |
6486 | } | |
6487 | ||
6488 | UNSET_IF_PARAM (params, transmit_delay); | |
6489 | params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; | |
6490 | ||
6491 | if (params != IF_DEF_PARAMS (ifp)) | |
6492 | { | |
6493 | ospf_free_if_params (ifp, addr); | |
6494 | ospf_if_update_params (ifp, addr); | |
6495 | } | |
6496 | ||
6497 | return CMD_SUCCESS; | |
6498 | } | |
6499 | ||
6500 | ALIAS (no_ip_ospf_transmit_delay, | |
6501 | no_ip_ospf_transmit_delay_cmd, | |
6502 | "no ip ospf transmit-delay", | |
6503 | NO_STR | |
6504 | "IP Information\n" | |
6505 | "OSPF interface commands\n" | |
6506 | "Link state transmit delay\n") | |
6507 | ||
6508 | ALIAS (no_ip_ospf_transmit_delay, | |
6509 | no_ospf_transmit_delay_cmd, | |
6510 | "no ospf transmit-delay", | |
6511 | NO_STR | |
6512 | "OSPF interface commands\n" | |
6513 | "Link state transmit delay\n") | |
6514 | ||
e723861d DS |
6515 | DEFUN (ip_ospf_area, |
6516 | ip_ospf_area_cmd, | |
6517 | "ip ospf area (A.B.C.D|<0-4294967295>)", | |
6518 | "IP Information\n" | |
6519 | "OSPF interface commands\n" | |
6520 | "Enable OSPF on this interface\n" | |
6521 | "OSPF area ID in IP address format\n" | |
6522 | "OSPF area ID as a decimal value\n") | |
6523 | { | |
6524 | struct interface *ifp = vty->index; | |
6525 | int format, ret; | |
6526 | struct in_addr area_id; | |
6527 | struct ospf *ospf; | |
6528 | struct ospf_if_params *params; | |
6529 | struct route_node *rn; | |
7c8ff89e | 6530 | u_short instance = 0; |
e723861d | 6531 | |
7c8ff89e DS |
6532 | if (argc == 2) |
6533 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
6534 | ||
6535 | ospf = ospf_lookup_instance (instance); | |
e723861d DS |
6536 | if (ospf == NULL) |
6537 | { | |
7c8ff89e DS |
6538 | params = IF_DEF_PARAMS (ifp); |
6539 | if (OSPF_IF_PARAM_CONFIGURED(params, if_area)) | |
6540 | { | |
6541 | ospf_interface_unset (ifp); | |
6542 | ospf = ospf_lookup(); | |
6543 | ospf->if_ospf_cli_count--; | |
6544 | } | |
e723861d DS |
6545 | return CMD_SUCCESS; |
6546 | } | |
6547 | ||
7c8ff89e | 6548 | ret = ospf_str2area_id (argv[instance ? 1 : 0], &area_id, &format); |
e723861d DS |
6549 | if (ret < 0) |
6550 | { | |
6551 | vty_out (vty, "Please specify area by A.B.C.D|<0-4294967295>%s", | |
6552 | VTY_NEWLINE); | |
6553 | return CMD_WARNING; | |
6554 | } | |
6555 | if (memcmp (ifp->name, "VLINK", 5) == 0) | |
6556 | { | |
6557 | vty_out (vty, "Cannot enable OSPF on a virtual link.%s", VTY_NEWLINE); | |
6558 | return CMD_WARNING; | |
6559 | } | |
6560 | ||
6561 | params = IF_DEF_PARAMS (ifp); | |
6562 | if (OSPF_IF_PARAM_CONFIGURED(params, if_area)) | |
6563 | { | |
6564 | return CMD_WARNING; | |
6565 | } | |
6566 | ||
6567 | for (rn = route_top (ospf->networks); rn; rn = route_next (rn)) | |
6568 | { | |
6569 | if (rn->info != NULL) | |
6570 | { | |
6571 | vty_out (vty, "Please remove all network commands first.%s", VTY_NEWLINE); | |
6572 | return CMD_WARNING; | |
6573 | } | |
6574 | } | |
6575 | ||
6576 | /* enable ospf on this interface with area_id */ | |
6577 | ospf_interface_set (ifp, area_id); | |
6578 | ospf->if_ospf_cli_count++; | |
6579 | ||
6580 | return CMD_SUCCESS; | |
6581 | } | |
6582 | ||
7c8ff89e DS |
6583 | ALIAS (ip_ospf_area, |
6584 | ip_ospf_instance_area_cmd, | |
6585 | "ip ospf <1-65535> area (A.B.C.D|<0-4294967295>)", | |
6586 | "IP Information\n" | |
6587 | "OSPF interface commands\n" | |
6588 | "Instance ID\n" | |
6589 | "Enable OSPF on this interface\n" | |
6590 | "OSPF area ID in IP address format\n" | |
6591 | "OSPF area ID as a decimal value\n") | |
6592 | ||
e723861d DS |
6593 | DEFUN (no_ip_ospf_area, |
6594 | no_ip_ospf_area_cmd, | |
6595 | "no ip ospf area", | |
6596 | NO_STR | |
6597 | "IP Information\n" | |
6598 | "OSPF interface commands\n" | |
6599 | "Disable OSPF on this interface\n") | |
6600 | { | |
6601 | struct interface *ifp = vty->index; | |
6602 | struct ospf *ospf; | |
6603 | struct ospf_if_params *params; | |
7c8ff89e | 6604 | u_short instance = 0; |
e723861d | 6605 | |
7c8ff89e DS |
6606 | if (argc) |
6607 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
6608 | ||
6609 | if ((ospf = ospf_lookup_instance (instance)) == NULL) | |
6610 | return CMD_SUCCESS; | |
e723861d DS |
6611 | |
6612 | params = IF_DEF_PARAMS (ifp); | |
6613 | if (!OSPF_IF_PARAM_CONFIGURED(params, if_area)) | |
6614 | { | |
6615 | vty_out (vty, "Can't find specified inteface area configuration.%s", VTY_NEWLINE); | |
6616 | return CMD_WARNING; | |
6617 | } | |
6618 | ||
6619 | ospf_interface_unset (ifp); | |
6620 | ospf->if_ospf_cli_count--; | |
6621 | return CMD_SUCCESS; | |
6622 | } | |
6623 | ||
7c8ff89e DS |
6624 | ALIAS (no_ip_ospf_area, |
6625 | no_ip_ospf_instance_area_cmd, | |
6626 | "no ip ospf <1-65535> area", | |
6627 | NO_STR | |
6628 | "IP Information\n" | |
6629 | "OSPF interface commands\n" | |
6630 | "Instance ID\n" | |
6631 | "Disable OSPF on this interface\n") | |
6632 | ||
6f2a6703 CF |
6633 | DEFUN (ospf_redistribute_source, |
6634 | ospf_redistribute_source_cmd, | |
6635 | "redistribute " QUAGGA_REDIST_STR_OSPFD | |
6636 | " {metric <0-16777214>|metric-type (1|2)|route-map WORD}", | |
d1c65c21 PJ |
6637 | REDIST_STR |
6638 | QUAGGA_REDIST_HELP_STR_OSPFD | |
718e3744 | 6639 | "Metric for redistributed routes\n" |
6640 | "OSPF default metric\n" | |
6641 | "OSPF exterior metric type for redistributed routes\n" | |
6642 | "Set OSPF External Type 1 metrics\n" | |
6643 | "Set OSPF External Type 2 metrics\n" | |
6644 | "Route map reference\n" | |
6645 | "Pointer to route-map entries\n") | |
6646 | { | |
020709f9 | 6647 | struct ospf *ospf = vty->index; |
718e3744 | 6648 | int source; |
6649 | int type = -1; | |
6650 | int metric = -1; | |
7c8ff89e | 6651 | struct ospf_redist *red; |
718e3744 | 6652 | |
6f2a6703 CF |
6653 | if (argc < 4) |
6654 | return CMD_WARNING; /* should not happen */ | |
6655 | ||
7c8ff89e DS |
6656 | if (!ospf) |
6657 | return CMD_SUCCESS; | |
6658 | ||
718e3744 | 6659 | /* Get distribute source. */ |
e0ca5fde DL |
6660 | source = proto_redistnum(AFI_IP, argv[0]); |
6661 | if (source < 0 || source == ZEBRA_ROUTE_OSPF) | |
718e3744 | 6662 | return CMD_WARNING; |
6663 | ||
6664 | /* Get metric value. */ | |
6f2a6703 | 6665 | if (argv[1] != NULL) |
718e3744 | 6666 | if (!str2metric (argv[1], &metric)) |
6667 | return CMD_WARNING; | |
6668 | ||
6669 | /* Get metric type. */ | |
6f2a6703 | 6670 | if (argv[2] != NULL) |
718e3744 | 6671 | if (!str2metric_type (argv[2], &type)) |
6672 | return CMD_WARNING; | |
6673 | ||
7c8ff89e DS |
6674 | red = ospf_redist_add(ospf, source, 0); |
6675 | ||
6f2a6703 | 6676 | if (argv[3] != NULL) |
7c8ff89e | 6677 | ospf_routemap_set (red, argv[3]); |
718e3744 | 6678 | else |
7c8ff89e | 6679 | ospf_routemap_unset (red); |
718e3744 | 6680 | |
7c8ff89e | 6681 | return ospf_redistribute_set (ospf, source, 0, type, metric); |
718e3744 | 6682 | } |
6683 | ||
718e3744 | 6684 | DEFUN (no_ospf_redistribute_source, |
6685 | no_ospf_redistribute_source_cmd, | |
d1c65c21 | 6686 | "no redistribute " QUAGGA_REDIST_STR_OSPFD, |
718e3744 | 6687 | NO_STR |
d1c65c21 PJ |
6688 | REDIST_STR |
6689 | QUAGGA_REDIST_HELP_STR_OSPFD) | |
718e3744 | 6690 | { |
020709f9 | 6691 | struct ospf *ospf = vty->index; |
718e3744 | 6692 | int source; |
7c8ff89e DS |
6693 | struct ospf_redist *red; |
6694 | if (!ospf) | |
6695 | return CMD_SUCCESS; | |
718e3744 | 6696 | |
e0ca5fde DL |
6697 | source = proto_redistnum(AFI_IP, argv[0]); |
6698 | if (source < 0 || source == ZEBRA_ROUTE_OSPF) | |
718e3744 | 6699 | return CMD_WARNING; |
6700 | ||
7c8ff89e DS |
6701 | red = ospf_redist_lookup(ospf, source, 0); |
6702 | if (!red) | |
6703 | return CMD_SUCCESS; | |
6704 | ||
6705 | ospf_routemap_unset (red); | |
6706 | return ospf_redistribute_unset (ospf, source, 0); | |
6707 | } | |
6708 | ||
6709 | DEFUN (ospf_redistribute_instance_source, | |
6710 | ospf_redistribute_instance_source_cmd, | |
6711 | "redistribute ospf <1-65535>" | |
6712 | " {metric <0-16777214>|metric-type (1|2)|route-map WORD}", | |
6713 | REDIST_STR | |
6714 | "Open Shortest Path First\n" | |
6715 | "Instance ID\n" | |
6716 | "Metric for redistributed routes\n" | |
6717 | "OSPF default metric\n" | |
6718 | "OSPF exterior metric type for redistributed routes\n" | |
6719 | "Set OSPF External Type 1 metrics\n" | |
6720 | "Set OSPF External Type 2 metrics\n" | |
6721 | "Route map reference\n" | |
6722 | "Pointer to route-map entries\n") | |
6723 | { | |
6724 | struct ospf *ospf = vty->index; | |
6725 | int source; | |
6726 | int type = -1; | |
6727 | int metric = -1; | |
6728 | u_short instance; | |
6729 | struct ospf_redist *red; | |
6730 | ||
6731 | VTY_GET_INTEGER ("Instance ID", instance, argv[0]); | |
6732 | ||
6733 | if (!ospf) | |
6734 | return CMD_SUCCESS; | |
6735 | ||
6736 | if (!ospf->instance) | |
6737 | { | |
6738 | vty_out (vty, "Instance redistribution in non-instanced OSPF not allowed%s", | |
6739 | VTY_NEWLINE); | |
6740 | return CMD_WARNING; | |
6741 | } | |
6742 | ||
6743 | if (ospf->instance == instance) | |
6744 | { | |
6745 | vty_out (vty, "Same instance OSPF redistribution not allowed%s", | |
6746 | VTY_NEWLINE); | |
6747 | return CMD_WARNING; | |
6748 | } | |
6749 | ||
6750 | source = ZEBRA_ROUTE_OSPF; | |
6751 | ||
6752 | /* Get metric value. */ | |
6753 | if (argv[1] != NULL) | |
6754 | if (!str2metric (argv[1], &metric)) | |
6755 | return CMD_WARNING; | |
6756 | ||
6757 | /* Get metric type. */ | |
6758 | if (argv[2] != NULL) | |
6759 | if (!str2metric_type (argv[2], &type)) | |
6760 | return CMD_WARNING; | |
6761 | ||
6762 | red = ospf_redist_add(ospf, source, instance); | |
6763 | if (argv[3] != NULL) | |
6764 | ospf_routemap_set (red, argv[3]); | |
6765 | else | |
6766 | ospf_routemap_unset (red); | |
6767 | ||
6768 | return ospf_redistribute_set (ospf, source, instance, type, metric); | |
6769 | } | |
6770 | ||
6771 | DEFUN (no_ospf_redistribute_instance_source, | |
6772 | no_ospf_redistribute_instance_source_cmd, | |
6773 | "no redistribute ospf <1-65535>" | |
6774 | " {metric <0-16777214>|metric-type (1|2)|route-map WORD}", | |
6775 | NO_STR | |
6776 | REDIST_STR | |
6777 | "Open Shortest Path First\n" | |
6778 | "Instance ID\n" | |
6779 | "Metric for redistributed routes\n" | |
6780 | "OSPF default metric\n" | |
6781 | "OSPF exterior metric type for redistributed routes\n" | |
6782 | "Set OSPF External Type 1 metrics\n" | |
6783 | "Set OSPF External Type 2 metrics\n" | |
6784 | "Route map reference\n" | |
6785 | "Pointer to route-map entries\n") | |
6786 | { | |
6787 | struct ospf *ospf = vty->index; | |
6788 | u_int instance; | |
6789 | struct ospf_redist *red; | |
6790 | int source; | |
6791 | ||
6792 | if (!ospf) | |
6793 | return CMD_SUCCESS; | |
6794 | ||
6795 | VTY_GET_INTEGER ("Instance ID", instance, argv[0]); | |
6796 | ||
6797 | if (!ospf->instance) | |
6798 | { | |
6799 | vty_out (vty, "Instance redistribution in non-instanced OSPF not allowed%s", | |
6800 | VTY_NEWLINE); | |
6801 | return CMD_WARNING; | |
6802 | } | |
6803 | ||
6804 | if (ospf->instance == instance) | |
6805 | { | |
6806 | vty_out (vty, "Same instance OSPF redistribution not allowed%s", | |
6807 | VTY_NEWLINE); | |
6808 | return CMD_WARNING; | |
6809 | } | |
6810 | ||
6811 | source = ZEBRA_ROUTE_OSPF; | |
6812 | red = ospf_redist_lookup(ospf, source, instance); | |
6813 | if (!red) | |
6814 | return CMD_SUCCESS; | |
6815 | ||
6816 | ospf_routemap_unset (red); | |
6817 | return ospf_redistribute_unset (ospf, source, instance); | |
718e3744 | 6818 | } |
6819 | ||
6820 | DEFUN (ospf_distribute_list_out, | |
6821 | ospf_distribute_list_out_cmd, | |
d1c65c21 | 6822 | "distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD, |
718e3744 | 6823 | "Filter networks in routing updates\n" |
6f2a6703 CF |
6824 | "Access-list name\n" |
6825 | OUT_STR | |
6826 | QUAGGA_REDIST_HELP_STR_OSPFD) | |
718e3744 | 6827 | { |
020709f9 | 6828 | struct ospf *ospf = vty->index; |
6f2a6703 | 6829 | int source; |
718e3744 | 6830 | |
7c8ff89e DS |
6831 | if (!ospf) |
6832 | return CMD_SUCCESS; | |
6833 | ||
6f2a6703 CF |
6834 | /* Get distribute source. */ |
6835 | source = proto_redistnum(AFI_IP, argv[1]); | |
6836 | if (source < 0 || source == ZEBRA_ROUTE_OSPF) | |
6837 | return CMD_WARNING; | |
718e3744 | 6838 | |
6f2a6703 | 6839 | return ospf_distribute_list_out_set (ospf, source, argv[0]); |
718e3744 | 6840 | } |
6841 | ||
6f2a6703 CF |
6842 | DEFUN (no_ospf_distribute_list_out, |
6843 | no_ospf_distribute_list_out_cmd, | |
6844 | "no distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD, | |
6845 | NO_STR | |
6846 | "Filter networks in routing updates\n" | |
6847 | "Access-list name\n" | |
6848 | OUT_STR | |
6849 | QUAGGA_REDIST_HELP_STR_OSPFD) | |
718e3744 | 6850 | { |
020709f9 | 6851 | struct ospf *ospf = vty->index; |
6f2a6703 | 6852 | int source; |
020709f9 | 6853 | |
7c8ff89e DS |
6854 | if (!ospf) |
6855 | return CMD_SUCCESS; | |
6856 | ||
6f2a6703 CF |
6857 | source = proto_redistnum(AFI_IP, argv[1]); |
6858 | if (source < 0 || source == ZEBRA_ROUTE_OSPF) | |
6859 | return CMD_WARNING; | |
718e3744 | 6860 | |
6f2a6703 | 6861 | return ospf_distribute_list_out_unset (ospf, source, argv[0]); |
718e3744 | 6862 | } |
6863 | ||
6f2a6703 CF |
6864 | /* Default information originate. */ |
6865 | DEFUN (ospf_default_information_originate, | |
6866 | ospf_default_information_originate_cmd, | |
6867 | "default-information originate " | |
6868 | "{always|metric <0-16777214>|metric-type (1|2)|route-map WORD}", | |
718e3744 | 6869 | "Control distribution of default information\n" |
6870 | "Distribute a default route\n" | |
6871 | "Always advertise default route\n" | |
6f2a6703 CF |
6872 | "OSPF default metric\n" |
6873 | "OSPF metric\n" | |
718e3744 | 6874 | "OSPF metric type for default routes\n" |
6875 | "Set OSPF External Type 1 metrics\n" | |
6876 | "Set OSPF External Type 2 metrics\n" | |
718e3744 | 6877 | "Route map reference\n" |
6878 | "Pointer to route-map entries\n") | |
6879 | { | |
020709f9 | 6880 | struct ospf *ospf = vty->index; |
6f2a6703 | 6881 | int default_originate = DEFAULT_ORIGINATE_ZEBRA; |
718e3744 | 6882 | int type = -1; |
6883 | int metric = -1; | |
7c8ff89e DS |
6884 | struct ospf_redist *red; |
6885 | ||
6886 | if (!ospf) | |
6887 | return CMD_SUCCESS; | |
718e3744 | 6888 | |
6f2a6703 CF |
6889 | if (argc < 4) |
6890 | return CMD_WARNING; /* this should not happen */ | |
6891 | ||
6892 | /* Check whether "always" was specified */ | |
6893 | if (argv[0] != NULL) | |
6894 | default_originate = DEFAULT_ORIGINATE_ALWAYS; | |
718e3744 | 6895 | |
7c8ff89e DS |
6896 | red = ospf_redist_add(ospf, DEFAULT_ROUTE, 0); |
6897 | ||
718e3744 | 6898 | /* Get metric value. */ |
6f2a6703 | 6899 | if (argv[1] != NULL) |
718e3744 | 6900 | if (!str2metric (argv[1], &metric)) |
6901 | return CMD_WARNING; | |
6902 | ||
718e3744 | 6903 | /* Get metric type. */ |
6f2a6703 CF |
6904 | if (argv[2] != NULL) |
6905 | if (!str2metric_type (argv[2], &type)) | |
718e3744 | 6906 | return CMD_WARNING; |
6907 | ||
6f2a6703 | 6908 | if (argv[3] != NULL) |
7c8ff89e | 6909 | ospf_routemap_set (red, argv[3]); |
718e3744 | 6910 | else |
7c8ff89e | 6911 | ospf_routemap_unset (red); |
718e3744 | 6912 | |
6f2a6703 CF |
6913 | return ospf_redistribute_default_set (ospf, default_originate, |
6914 | type, metric); | |
718e3744 | 6915 | } |
6916 | ||
6917 | DEFUN (no_ospf_default_information_originate, | |
6918 | no_ospf_default_information_originate_cmd, | |
6919 | "no default-information originate", | |
6920 | NO_STR | |
6921 | "Control distribution of default information\n" | |
6922 | "Distribute a default route\n") | |
6923 | { | |
68980084 | 6924 | struct ospf *ospf = vty->index; |
718e3744 | 6925 | struct prefix_ipv4 p; |
7c8ff89e DS |
6926 | struct ospf_external *ext; |
6927 | struct ospf_redist *red; | |
718e3744 | 6928 | |
7c8ff89e DS |
6929 | if (!ospf) |
6930 | return CMD_SUCCESS; | |
6931 | ||
718e3744 | 6932 | p.family = AF_INET; |
6933 | p.prefix.s_addr = 0; | |
6934 | p.prefixlen = 0; | |
6935 | ||
5339cfdb | 6936 | ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0); |
718e3744 | 6937 | |
7c8ff89e DS |
6938 | if ((ext = ospf_external_lookup(DEFAULT_ROUTE, 0)) && |
6939 | EXTERNAL_INFO (ext)) { | |
6940 | ospf_external_info_delete (DEFAULT_ROUTE, 0, p); | |
6941 | ospf_external_del (DEFAULT_ROUTE, 0); | |
718e3744 | 6942 | } |
6943 | ||
7c8ff89e DS |
6944 | red = ospf_redist_lookup(ospf, DEFAULT_ROUTE, 0); |
6945 | if (!red) | |
6946 | return CMD_SUCCESS; | |
6947 | ||
6948 | ospf_routemap_unset (red); | |
020709f9 | 6949 | return ospf_redistribute_default_unset (ospf); |
718e3744 | 6950 | } |
6951 | ||
6952 | DEFUN (ospf_default_metric, | |
6953 | ospf_default_metric_cmd, | |
6954 | "default-metric <0-16777214>", | |
6955 | "Set metric of redistributed routes\n" | |
6956 | "Default metric\n") | |
6957 | { | |
68980084 | 6958 | struct ospf *ospf = vty->index; |
718e3744 | 6959 | int metric = -1; |
6960 | ||
7c8ff89e DS |
6961 | if (!ospf) |
6962 | return CMD_SUCCESS; | |
6963 | ||
718e3744 | 6964 | if (!str2metric (argv[0], &metric)) |
6965 | return CMD_WARNING; | |
6966 | ||
68980084 | 6967 | ospf->default_metric = metric; |
718e3744 | 6968 | |
6969 | return CMD_SUCCESS; | |
6970 | } | |
6971 | ||
6972 | DEFUN (no_ospf_default_metric, | |
6973 | no_ospf_default_metric_cmd, | |
6974 | "no default-metric", | |
6975 | NO_STR | |
6976 | "Set metric of redistributed routes\n") | |
6977 | { | |
68980084 | 6978 | struct ospf *ospf = vty->index; |
6979 | ||
7c8ff89e DS |
6980 | if (!ospf) |
6981 | return CMD_SUCCESS; | |
6982 | ||
68980084 | 6983 | ospf->default_metric = -1; |
6984 | ||
718e3744 | 6985 | return CMD_SUCCESS; |
6986 | } | |
6987 | ||
6988 | ALIAS (no_ospf_default_metric, | |
6989 | no_ospf_default_metric_val_cmd, | |
6990 | "no default-metric <0-16777214>", | |
6991 | NO_STR | |
6992 | "Set metric of redistributed routes\n" | |
6993 | "Default metric\n") | |
6994 | ||
6995 | DEFUN (ospf_distance, | |
6996 | ospf_distance_cmd, | |
6997 | "distance <1-255>", | |
6998 | "Define an administrative distance\n" | |
6999 | "OSPF Administrative distance\n") | |
7000 | { | |
68980084 | 7001 | struct ospf *ospf = vty->index; |
7002 | ||
7c8ff89e DS |
7003 | if (!ospf) |
7004 | return CMD_SUCCESS; | |
7005 | ||
68980084 | 7006 | ospf->distance_all = atoi (argv[0]); |
7007 | ||
718e3744 | 7008 | return CMD_SUCCESS; |
7009 | } | |
7010 | ||
7011 | DEFUN (no_ospf_distance, | |
7012 | no_ospf_distance_cmd, | |
7013 | "no distance <1-255>", | |
7014 | NO_STR | |
7015 | "Define an administrative distance\n" | |
7016 | "OSPF Administrative distance\n") | |
7017 | { | |
68980084 | 7018 | struct ospf *ospf = vty->index; |
7019 | ||
7c8ff89e DS |
7020 | if (!ospf) |
7021 | return CMD_SUCCESS; | |
7022 | ||
68980084 | 7023 | ospf->distance_all = 0; |
7024 | ||
718e3744 | 7025 | return CMD_SUCCESS; |
7026 | } | |
7027 | ||
7028 | DEFUN (no_ospf_distance_ospf, | |
7029 | no_ospf_distance_ospf_cmd, | |
6f2a6703 | 7030 | "no distance ospf {intra-area|inter-area|external}", |
718e3744 | 7031 | NO_STR |
7032 | "Define an administrative distance\n" | |
7033 | "OSPF Administrative distance\n" | |
6f2a6703 | 7034 | "OSPF Distance\n" |
718e3744 | 7035 | "Intra-area routes\n" |
718e3744 | 7036 | "Inter-area routes\n" |
6f2a6703 | 7037 | "External routes\n") |
718e3744 | 7038 | { |
68980084 | 7039 | struct ospf *ospf = vty->index; |
7040 | ||
6f2a6703 CF |
7041 | if (argc < 3) |
7042 | return CMD_WARNING; | |
718e3744 | 7043 | |
7c8ff89e DS |
7044 | if (!ospf) |
7045 | return CMD_SUCCESS; | |
7046 | ||
6f2a6703 CF |
7047 | if (argv[0] != NULL) |
7048 | ospf->distance_intra = 0; | |
68980084 | 7049 | |
6f2a6703 CF |
7050 | if (argv[1] != NULL) |
7051 | ospf->distance_inter = 0; | |
68980084 | 7052 | |
6f2a6703 CF |
7053 | if (argv[2] != NULL) |
7054 | ospf->distance_external = 0; | |
718e3744 | 7055 | |
6f2a6703 CF |
7056 | if (argv[0] || argv[1] || argv[2]) |
7057 | return CMD_SUCCESS; | |
68980084 | 7058 | |
6f2a6703 CF |
7059 | /* If no arguments are given, clear all distance information */ |
7060 | ospf->distance_intra = 0; | |
7061 | ospf->distance_inter = 0; | |
7062 | ospf->distance_external = 0; | |
68980084 | 7063 | |
718e3744 | 7064 | return CMD_SUCCESS; |
7065 | } | |
7066 | ||
6f2a6703 CF |
7067 | DEFUN (ospf_distance_ospf, |
7068 | ospf_distance_ospf_cmd, | |
7069 | "distance ospf " | |
7070 | "{intra-area <1-255>|inter-area <1-255>|external <1-255>}", | |
718e3744 | 7071 | "Define an administrative distance\n" |
7072 | "OSPF Administrative distance\n" | |
718e3744 | 7073 | "Intra-area routes\n" |
7074 | "Distance for intra-area routes\n" | |
718e3744 | 7075 | "Inter-area routes\n" |
7076 | "Distance for inter-area routes\n" | |
7077 | "External routes\n" | |
718e3744 | 7078 | "Distance for external routes\n") |
7079 | { | |
68980084 | 7080 | struct ospf *ospf = vty->index; |
7081 | ||
6f2a6703 CF |
7082 | if (argc < 3) /* should not happen */ |
7083 | return CMD_WARNING; | |
68980084 | 7084 | |
6f2a6703 CF |
7085 | if (!argv[0] && !argv[1] && !argv[2]) |
7086 | { | |
7087 | vty_out(vty, "%% Command incomplete. (Arguments required)%s", | |
7088 | VTY_NEWLINE); | |
7089 | return CMD_WARNING; | |
7090 | } | |
68980084 | 7091 | |
6f2a6703 CF |
7092 | if (argv[0] != NULL) |
7093 | ospf->distance_intra = atoi(argv[0]); | |
718e3744 | 7094 | |
6f2a6703 CF |
7095 | if (argv[1] != NULL) |
7096 | ospf->distance_inter = atoi(argv[1]); | |
68980084 | 7097 | |
6f2a6703 CF |
7098 | if (argv[2] != NULL) |
7099 | ospf->distance_external = atoi(argv[2]); | |
68980084 | 7100 | |
718e3744 | 7101 | return CMD_SUCCESS; |
7102 | } | |
7103 | ||
7104 | DEFUN (ospf_distance_source, | |
7105 | ospf_distance_source_cmd, | |
7106 | "distance <1-255> A.B.C.D/M", | |
7107 | "Administrative distance\n" | |
7108 | "Distance value\n" | |
7109 | "IP source prefix\n") | |
7110 | { | |
020709f9 | 7111 | struct ospf *ospf = vty->index; |
7112 | ||
7c8ff89e DS |
7113 | if (!ospf) |
7114 | return CMD_SUCCESS; | |
7115 | ||
020709f9 | 7116 | ospf_distance_set (vty, ospf, argv[0], argv[1], NULL); |
68980084 | 7117 | |
718e3744 | 7118 | return CMD_SUCCESS; |
7119 | } | |
7120 | ||
7121 | DEFUN (no_ospf_distance_source, | |
7122 | no_ospf_distance_source_cmd, | |
7123 | "no distance <1-255> A.B.C.D/M", | |
7124 | NO_STR | |
7125 | "Administrative distance\n" | |
7126 | "Distance value\n" | |
7127 | "IP source prefix\n") | |
7128 | { | |
020709f9 | 7129 | struct ospf *ospf = vty->index; |
7130 | ||
7c8ff89e DS |
7131 | if (!ospf) |
7132 | return CMD_SUCCESS; | |
7133 | ||
020709f9 | 7134 | ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL); |
7135 | ||
718e3744 | 7136 | return CMD_SUCCESS; |
7137 | } | |
7138 | ||
7139 | DEFUN (ospf_distance_source_access_list, | |
7140 | ospf_distance_source_access_list_cmd, | |
7141 | "distance <1-255> A.B.C.D/M WORD", | |
7142 | "Administrative distance\n" | |
7143 | "Distance value\n" | |
7144 | "IP source prefix\n" | |
7145 | "Access list name\n") | |
7146 | { | |
020709f9 | 7147 | struct ospf *ospf = vty->index; |
7148 | ||
7c8ff89e DS |
7149 | if (!ospf) |
7150 | return CMD_SUCCESS; | |
7151 | ||
020709f9 | 7152 | ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]); |
7153 | ||
718e3744 | 7154 | return CMD_SUCCESS; |
7155 | } | |
7156 | ||
7157 | DEFUN (no_ospf_distance_source_access_list, | |
7158 | no_ospf_distance_source_access_list_cmd, | |
7159 | "no distance <1-255> A.B.C.D/M WORD", | |
7160 | NO_STR | |
7161 | "Administrative distance\n" | |
7162 | "Distance value\n" | |
7163 | "IP source prefix\n" | |
7164 | "Access list name\n") | |
7165 | { | |
020709f9 | 7166 | struct ospf *ospf = vty->index; |
7167 | ||
7c8ff89e DS |
7168 | if (!ospf) |
7169 | return CMD_SUCCESS; | |
7170 | ||
020709f9 | 7171 | ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]); |
7172 | ||
718e3744 | 7173 | return CMD_SUCCESS; |
7174 | } | |
7175 | ||
ba682537 | 7176 | DEFUN (ip_ospf_mtu_ignore, |
7177 | ip_ospf_mtu_ignore_addr_cmd, | |
7178 | "ip ospf mtu-ignore A.B.C.D", | |
7179 | "IP Information\n" | |
7180 | "OSPF interface commands\n" | |
7181 | "Disable mtu mismatch detection\n" | |
7182 | "Address of interface") | |
7183 | { | |
7184 | struct interface *ifp = vty->index; | |
7185 | struct in_addr addr; | |
7186 | int ret; | |
7187 | ||
7188 | struct ospf_if_params *params; | |
7189 | params = IF_DEF_PARAMS (ifp); | |
7190 | ||
7191 | if (argc == 1) | |
7192 | { | |
7193 | ret = inet_aton(argv[0], &addr); | |
7194 | if (!ret) | |
7195 | { | |
7196 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7197 | VTY_NEWLINE); | |
7198 | return CMD_WARNING; | |
7199 | } | |
7200 | params = ospf_get_if_params (ifp, addr); | |
7201 | ospf_if_update_params (ifp, addr); | |
7202 | } | |
7203 | params->mtu_ignore = 1; | |
7204 | if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) | |
7205 | SET_IF_PARAM (params, mtu_ignore); | |
7206 | else | |
7207 | { | |
7208 | UNSET_IF_PARAM (params, mtu_ignore); | |
7209 | if (params != IF_DEF_PARAMS (ifp)) | |
7210 | { | |
7211 | ospf_free_if_params (ifp, addr); | |
7212 | ospf_if_update_params (ifp, addr); | |
7213 | } | |
7214 | } | |
7215 | return CMD_SUCCESS; | |
7216 | } | |
7217 | ||
7218 | ALIAS (ip_ospf_mtu_ignore, | |
7219 | ip_ospf_mtu_ignore_cmd, | |
7220 | "ip ospf mtu-ignore", | |
7221 | "IP Information\n" | |
7222 | "OSPF interface commands\n" | |
7223 | "Disable mtu mismatch detection\n") | |
7224 | ||
7225 | ||
7226 | DEFUN (no_ip_ospf_mtu_ignore, | |
7227 | no_ip_ospf_mtu_ignore_addr_cmd, | |
7228 | "no ip ospf mtu-ignore A.B.C.D", | |
7229 | "IP Information\n" | |
7230 | "OSPF interface commands\n" | |
7231 | "Disable mtu mismatch detection\n" | |
7232 | "Address of interface") | |
7233 | { | |
7234 | struct interface *ifp = vty->index; | |
7235 | struct in_addr addr; | |
7236 | int ret; | |
7237 | ||
7238 | struct ospf_if_params *params; | |
7239 | params = IF_DEF_PARAMS (ifp); | |
7240 | ||
7241 | if (argc == 1) | |
7242 | { | |
7243 | ret = inet_aton(argv[0], &addr); | |
7244 | if (!ret) | |
7245 | { | |
7246 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7247 | VTY_NEWLINE); | |
7248 | return CMD_WARNING; | |
7249 | } | |
7250 | params = ospf_get_if_params (ifp, addr); | |
7251 | ospf_if_update_params (ifp, addr); | |
7252 | } | |
7253 | params->mtu_ignore = 0; | |
7254 | if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) | |
7255 | SET_IF_PARAM (params, mtu_ignore); | |
7256 | else | |
7257 | { | |
7258 | UNSET_IF_PARAM (params, mtu_ignore); | |
7259 | if (params != IF_DEF_PARAMS (ifp)) | |
7260 | { | |
7261 | ospf_free_if_params (ifp, addr); | |
7262 | ospf_if_update_params (ifp, addr); | |
7263 | } | |
7264 | } | |
7265 | return CMD_SUCCESS; | |
7266 | } | |
7267 | ||
7268 | ALIAS (no_ip_ospf_mtu_ignore, | |
7269 | no_ip_ospf_mtu_ignore_cmd, | |
7270 | "no ip ospf mtu-ignore", | |
7271 | "IP Information\n" | |
7272 | "OSPF interface commands\n" | |
7273 | "Disable mtu mismatch detection\n") | |
6b0655a2 | 7274 | |
88d6cf37 | 7275 | DEFUN (ospf_max_metric_router_lsa_admin, |
7276 | ospf_max_metric_router_lsa_admin_cmd, | |
7277 | "max-metric router-lsa administrative", | |
7278 | "OSPF maximum / infinite-distance metric\n" | |
7279 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
7280 | "Administratively applied, for an indefinite period\n") | |
7281 | { | |
7282 | struct listnode *ln; | |
7283 | struct ospf_area *area; | |
7284 | struct ospf *ospf = vty->index; | |
ba682537 | 7285 | |
7c8ff89e DS |
7286 | if (!ospf) |
7287 | return CMD_SUCCESS; | |
7288 | ||
88d6cf37 | 7289 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
7290 | { | |
7291 | SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED); | |
7292 | ||
7293 | if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)) | |
c363d386 | 7294 | ospf_router_lsa_update_area (area); |
88d6cf37 | 7295 | } |
4ba4fc85 AB |
7296 | |
7297 | /* Allows for areas configured later to get the property */ | |
7298 | ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_SET; | |
7299 | ||
88d6cf37 | 7300 | return CMD_SUCCESS; |
7301 | } | |
7302 | ||
7303 | DEFUN (no_ospf_max_metric_router_lsa_admin, | |
7304 | no_ospf_max_metric_router_lsa_admin_cmd, | |
7305 | "no max-metric router-lsa administrative", | |
7306 | NO_STR | |
7307 | "OSPF maximum / infinite-distance metric\n" | |
7308 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
7309 | "Administratively applied, for an indefinite period\n") | |
7310 | { | |
7311 | struct listnode *ln; | |
7312 | struct ospf_area *area; | |
7313 | struct ospf *ospf = vty->index; | |
7314 | ||
7c8ff89e DS |
7315 | if (!ospf) |
7316 | return CMD_SUCCESS; | |
7317 | ||
88d6cf37 | 7318 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
7319 | { | |
7320 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED); | |
7321 | ||
7322 | /* Don't trample on the start-up stub timer */ | |
7323 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED) | |
7324 | && !area->t_stub_router) | |
7325 | { | |
7326 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED); | |
c363d386 | 7327 | ospf_router_lsa_update_area (area); |
88d6cf37 | 7328 | } |
7329 | } | |
4ba4fc85 | 7330 | ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET; |
88d6cf37 | 7331 | return CMD_SUCCESS; |
7332 | } | |
7333 | ||
7334 | DEFUN (ospf_max_metric_router_lsa_startup, | |
7335 | ospf_max_metric_router_lsa_startup_cmd, | |
7336 | "max-metric router-lsa on-startup <5-86400>", | |
7337 | "OSPF maximum / infinite-distance metric\n" | |
7338 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
7339 | "Automatically advertise stub Router-LSA on startup of OSPF\n" | |
7340 | "Time (seconds) to advertise self as stub-router\n") | |
7341 | { | |
7342 | unsigned int seconds; | |
7343 | struct ospf *ospf = vty->index; | |
7344 | ||
7c8ff89e DS |
7345 | if (!ospf) |
7346 | return CMD_SUCCESS; | |
7347 | ||
88d6cf37 | 7348 | if (argc != 1) |
7349 | { | |
7350 | vty_out (vty, "%% Must supply stub-router period"); | |
7351 | return CMD_WARNING; | |
7352 | } | |
7353 | ||
7354 | VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]); | |
7355 | ||
7356 | ospf->stub_router_startup_time = seconds; | |
7357 | ||
7358 | return CMD_SUCCESS; | |
7359 | } | |
7360 | ||
7361 | DEFUN (no_ospf_max_metric_router_lsa_startup, | |
7362 | no_ospf_max_metric_router_lsa_startup_cmd, | |
7363 | "no max-metric router-lsa on-startup", | |
7364 | NO_STR | |
7365 | "OSPF maximum / infinite-distance metric\n" | |
7366 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
7367 | "Automatically advertise stub Router-LSA on startup of OSPF\n") | |
7368 | { | |
7369 | struct listnode *ln; | |
7370 | struct ospf_area *area; | |
7371 | struct ospf *ospf = vty->index; | |
7372 | ||
7c8ff89e DS |
7373 | if (!ospf) |
7374 | return CMD_SUCCESS; | |
7375 | ||
88d6cf37 | 7376 | ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED; |
7377 | ||
7378 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) | |
7379 | { | |
7380 | SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED); | |
7381 | OSPF_TIMER_OFF (area->t_stub_router); | |
7382 | ||
7383 | /* Don't trample on admin stub routed */ | |
7384 | if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) | |
7385 | { | |
7386 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED); | |
c363d386 | 7387 | ospf_router_lsa_update_area (area); |
88d6cf37 | 7388 | } |
7389 | } | |
7390 | return CMD_SUCCESS; | |
7391 | } | |
7392 | ||
7393 | DEFUN (ospf_max_metric_router_lsa_shutdown, | |
7394 | ospf_max_metric_router_lsa_shutdown_cmd, | |
804fb5c1 | 7395 | "max-metric router-lsa on-shutdown <5-100>", |
88d6cf37 | 7396 | "OSPF maximum / infinite-distance metric\n" |
7397 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
7398 | "Advertise stub-router prior to full shutdown of OSPF\n" | |
7399 | "Time (seconds) to wait till full shutdown\n") | |
7400 | { | |
7401 | unsigned int seconds; | |
7402 | struct ospf *ospf = vty->index; | |
7403 | ||
7c8ff89e DS |
7404 | if (!ospf) |
7405 | return CMD_SUCCESS; | |
7406 | ||
88d6cf37 | 7407 | if (argc != 1) |
7408 | { | |
7409 | vty_out (vty, "%% Must supply stub-router shutdown period"); | |
7410 | return CMD_WARNING; | |
7411 | } | |
7412 | ||
7413 | VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]); | |
7414 | ||
7415 | ospf->stub_router_shutdown_time = seconds; | |
7416 | ||
7417 | return CMD_SUCCESS; | |
7418 | } | |
7419 | ||
7420 | DEFUN (no_ospf_max_metric_router_lsa_shutdown, | |
7421 | no_ospf_max_metric_router_lsa_shutdown_cmd, | |
7422 | "no max-metric router-lsa on-shutdown", | |
7423 | NO_STR | |
7424 | "OSPF maximum / infinite-distance metric\n" | |
7425 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
7426 | "Advertise stub-router prior to full shutdown of OSPF\n") | |
7427 | { | |
7428 | struct ospf *ospf = vty->index; | |
7429 | ||
7c8ff89e DS |
7430 | if (!ospf) |
7431 | return CMD_SUCCESS; | |
7432 | ||
88d6cf37 | 7433 | ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED; |
7434 | ||
7435 | return CMD_SUCCESS; | |
7436 | } | |
7437 | ||
7438 | static void | |
7439 | config_write_stub_router (struct vty *vty, struct ospf *ospf) | |
7440 | { | |
7441 | struct listnode *ln; | |
7442 | struct ospf_area *area; | |
7443 | ||
7444 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
7445 | vty_out (vty, " max-metric router-lsa on-startup %u%s", | |
7446 | ospf->stub_router_startup_time, VTY_NEWLINE); | |
7447 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
7448 | vty_out (vty, " max-metric router-lsa on-shutdown %u%s", | |
7449 | ospf->stub_router_shutdown_time, VTY_NEWLINE); | |
7450 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) | |
7451 | { | |
7452 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) | |
7453 | { | |
7454 | vty_out (vty, " max-metric router-lsa administrative%s", | |
7455 | VTY_NEWLINE); | |
7456 | break; | |
7457 | } | |
7458 | } | |
7459 | return; | |
7460 | } | |
6b0655a2 | 7461 | |
4dadc291 | 7462 | static void |
718e3744 | 7463 | show_ip_ospf_route_network (struct vty *vty, struct route_table *rt) |
7464 | { | |
7465 | struct route_node *rn; | |
7466 | struct ospf_route *or; | |
1eb8ef25 | 7467 | struct listnode *pnode, *pnnode; |
718e3744 | 7468 | struct ospf_path *path; |
7469 | ||
7470 | vty_out (vty, "============ OSPF network routing table ============%s", | |
7471 | VTY_NEWLINE); | |
7472 | ||
7473 | for (rn = route_top (rt); rn; rn = route_next (rn)) | |
7474 | if ((or = rn->info) != NULL) | |
7475 | { | |
7476 | char buf1[19]; | |
7477 | snprintf (buf1, 19, "%s/%d", | |
7478 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); | |
7479 | ||
7480 | switch (or->path_type) | |
7481 | { | |
7482 | case OSPF_PATH_INTER_AREA: | |
7483 | if (or->type == OSPF_DESTINATION_NETWORK) | |
7484 | vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost, | |
7485 | inet_ntoa (or->u.std.area_id), VTY_NEWLINE); | |
7486 | else if (or->type == OSPF_DESTINATION_DISCARD) | |
7487 | vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE); | |
7488 | break; | |
7489 | case OSPF_PATH_INTRA_AREA: | |
7490 | vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost, | |
7491 | inet_ntoa (or->u.std.area_id), VTY_NEWLINE); | |
7492 | break; | |
7493 | default: | |
7494 | break; | |
7495 | } | |
7496 | ||
7497 | if (or->type == OSPF_DESTINATION_NETWORK) | |
1eb8ef25 | 7498 | for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path)) |
96735eea | 7499 | { |
a8ba847f | 7500 | if (if_lookup_by_index(path->ifindex)) |
96735eea | 7501 | { |
7502 | if (path->nexthop.s_addr == 0) | |
7503 | vty_out (vty, "%24s directly attached to %s%s", | |
a8ba847f | 7504 | "", ifindex2ifname (path->ifindex), VTY_NEWLINE); |
96735eea | 7505 | else |
7506 | vty_out (vty, "%24s via %s, %s%s", "", | |
a8ba847f JT |
7507 | inet_ntoa (path->nexthop), |
7508 | ifindex2ifname (path->ifindex), VTY_NEWLINE); | |
96735eea | 7509 | } |
7510 | } | |
718e3744 | 7511 | } |
7512 | vty_out (vty, "%s", VTY_NEWLINE); | |
7513 | } | |
7514 | ||
4dadc291 | 7515 | static void |
718e3744 | 7516 | show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs) |
7517 | { | |
7518 | struct route_node *rn; | |
7519 | struct ospf_route *or; | |
1eb8ef25 | 7520 | struct listnode *pnode; |
7521 | struct listnode *node; | |
718e3744 | 7522 | struct ospf_path *path; |
7523 | ||
7524 | vty_out (vty, "============ OSPF router routing table =============%s", | |
7525 | VTY_NEWLINE); | |
7526 | for (rn = route_top (rtrs); rn; rn = route_next (rn)) | |
7527 | if (rn->info) | |
7528 | { | |
7529 | int flag = 0; | |
7530 | ||
7531 | vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4)); | |
7532 | ||
1eb8ef25 | 7533 | for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or)) |
7534 | { | |
7535 | if (flag++) | |
7536 | vty_out (vty, "%24s", ""); | |
7537 | ||
7538 | /* Show path. */ | |
7539 | vty_out (vty, "%s [%d] area: %s", | |
7540 | (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "), | |
7541 | or->cost, inet_ntoa (or->u.std.area_id)); | |
7542 | /* Show flags. */ | |
7543 | vty_out (vty, "%s%s%s", | |
7544 | (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""), | |
7545 | (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""), | |
7546 | VTY_NEWLINE); | |
7547 | ||
7548 | for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path)) | |
7549 | { | |
a8ba847f | 7550 | if (if_lookup_by_index(path->ifindex)) |
54bedb55 | 7551 | { |
7552 | if (path->nexthop.s_addr == 0) | |
7553 | vty_out (vty, "%24s directly attached to %s%s", | |
a8ba847f JT |
7554 | "", ifindex2ifname (path->ifindex), |
7555 | VTY_NEWLINE); | |
54bedb55 | 7556 | else |
7557 | vty_out (vty, "%24s via %s, %s%s", "", | |
7558 | inet_ntoa (path->nexthop), | |
a8ba847f JT |
7559 | ifindex2ifname (path->ifindex), |
7560 | VTY_NEWLINE); | |
54bedb55 | 7561 | } |
1eb8ef25 | 7562 | } |
7563 | } | |
718e3744 | 7564 | } |
7565 | vty_out (vty, "%s", VTY_NEWLINE); | |
7566 | } | |
7567 | ||
4dadc291 | 7568 | static void |
718e3744 | 7569 | show_ip_ospf_route_external (struct vty *vty, struct route_table *rt) |
7570 | { | |
7571 | struct route_node *rn; | |
7572 | struct ospf_route *er; | |
1eb8ef25 | 7573 | struct listnode *pnode, *pnnode; |
718e3744 | 7574 | struct ospf_path *path; |
7575 | ||
7576 | vty_out (vty, "============ OSPF external routing table ===========%s", | |
7577 | VTY_NEWLINE); | |
7578 | for (rn = route_top (rt); rn; rn = route_next (rn)) | |
7579 | if ((er = rn->info) != NULL) | |
7580 | { | |
7581 | char buf1[19]; | |
7582 | snprintf (buf1, 19, "%s/%d", | |
7583 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); | |
7584 | ||
7585 | switch (er->path_type) | |
7586 | { | |
7587 | case OSPF_PATH_TYPE1_EXTERNAL: | |
7588 | vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1, | |
7589 | er->cost, er->u.ext.tag, VTY_NEWLINE); | |
7590 | break; | |
7591 | case OSPF_PATH_TYPE2_EXTERNAL: | |
7592 | vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost, | |
7593 | er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE); | |
7594 | break; | |
7595 | } | |
7596 | ||
1eb8ef25 | 7597 | for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path)) |
718e3744 | 7598 | { |
a8ba847f | 7599 | if (if_lookup_by_index(path->ifindex)) |
718e3744 | 7600 | { |
7601 | if (path->nexthop.s_addr == 0) | |
96735eea | 7602 | vty_out (vty, "%24s directly attached to %s%s", |
a8ba847f | 7603 | "", ifindex2ifname (path->ifindex), VTY_NEWLINE); |
96735eea | 7604 | else |
7605 | vty_out (vty, "%24s via %s, %s%s", "", | |
a8ba847f JT |
7606 | inet_ntoa (path->nexthop), |
7607 | ifindex2ifname (path->ifindex), | |
96735eea | 7608 | VTY_NEWLINE); |
718e3744 | 7609 | } |
7610 | } | |
7611 | } | |
7612 | vty_out (vty, "%s", VTY_NEWLINE); | |
7613 | } | |
7614 | ||
7c8ff89e DS |
7615 | static int |
7616 | show_ip_ospf_border_routers_common (struct vty *vty, struct ospf *ospf) | |
718e3744 | 7617 | { |
7c8ff89e DS |
7618 | if (ospf->instance) |
7619 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
7620 | VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 7621 | |
68980084 | 7622 | if (ospf->new_table == NULL) |
718e3744 | 7623 | { |
7624 | vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); | |
7625 | return CMD_SUCCESS; | |
7626 | } | |
7627 | ||
7628 | /* Show Network routes. | |
020709f9 | 7629 | show_ip_ospf_route_network (vty, ospf->new_table); */ |
718e3744 | 7630 | |
7631 | /* Show Router routes. */ | |
68980084 | 7632 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
718e3744 | 7633 | |
7c8ff89e DS |
7634 | vty_out (vty, "%s", VTY_NEWLINE); |
7635 | ||
718e3744 | 7636 | return CMD_SUCCESS; |
7637 | } | |
718e3744 | 7638 | |
7c8ff89e DS |
7639 | DEFUN (show_ip_ospf_border_routers, |
7640 | show_ip_ospf_border_routers_cmd, | |
7641 | "show ip ospf border-routers", | |
718e3744 | 7642 | SHOW_STR |
7643 | IP_STR | |
7644 | "OSPF information\n" | |
7c8ff89e | 7645 | "Show all the ABR's and ASBR's\n") |
718e3744 | 7646 | { |
020709f9 | 7647 | struct ospf *ospf; |
68980084 | 7648 | |
0bad4851 | 7649 | if ((ospf = ospf_lookup ()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
7650 | return CMD_SUCCESS; |
7651 | ||
7652 | return show_ip_ospf_border_routers_common(vty, ospf); | |
7653 | } | |
7654 | ||
7655 | DEFUN (show_ip_ospf_instance_border_routers, | |
7656 | show_ip_ospf_instance_border_routers_cmd, | |
7657 | "show ip ospf <1-65535> border-routers", | |
7658 | SHOW_STR | |
7659 | IP_STR | |
7660 | "OSPF information\n" | |
7661 | "Instance ID\n" | |
7662 | "Show all the ABR's and ASBR's\n") | |
7663 | { | |
7664 | struct ospf *ospf; | |
7665 | u_short instance = 0; | |
7666 | ||
7667 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 7668 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
7669 | return CMD_SUCCESS; |
7670 | ||
7671 | return show_ip_ospf_border_routers_common(vty, ospf); | |
7672 | } | |
7673 | ||
7674 | static int | |
7675 | show_ip_ospf_route_common (struct vty *vty, struct ospf *ospf) | |
7676 | { | |
7677 | if (ospf->instance) | |
7678 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
7679 | VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 7680 | |
68980084 | 7681 | if (ospf->new_table == NULL) |
718e3744 | 7682 | { |
7683 | vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); | |
7684 | return CMD_SUCCESS; | |
7685 | } | |
7686 | ||
7687 | /* Show Network routes. */ | |
68980084 | 7688 | show_ip_ospf_route_network (vty, ospf->new_table); |
718e3744 | 7689 | |
7690 | /* Show Router routes. */ | |
68980084 | 7691 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
718e3744 | 7692 | |
7693 | /* Show AS External routes. */ | |
68980084 | 7694 | show_ip_ospf_route_external (vty, ospf->old_external_route); |
718e3744 | 7695 | |
7c8ff89e DS |
7696 | vty_out (vty, "%s", VTY_NEWLINE); |
7697 | ||
718e3744 | 7698 | return CMD_SUCCESS; |
7699 | } | |
7700 | ||
7c8ff89e DS |
7701 | DEFUN (show_ip_ospf_route, |
7702 | show_ip_ospf_route_cmd, | |
7703 | "show ip ospf route", | |
7704 | SHOW_STR | |
7705 | IP_STR | |
7706 | "OSPF information\n" | |
7707 | "OSPF routing table\n") | |
7708 | { | |
7709 | struct ospf *ospf; | |
7710 | ||
0bad4851 | 7711 | if ((ospf = ospf_lookup ()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
7712 | return CMD_SUCCESS; |
7713 | ||
7714 | return show_ip_ospf_route_common(vty, ospf); | |
7715 | } | |
7716 | ||
7717 | DEFUN (show_ip_ospf_instance_route, | |
7718 | show_ip_ospf_instance_route_cmd, | |
7719 | "show ip ospf <1-65535> route", | |
7720 | SHOW_STR | |
7721 | IP_STR | |
7722 | "OSPF information\n" | |
7723 | "Instance ID\n" | |
7724 | "OSPF routing table\n") | |
7725 | { | |
7726 | struct ospf *ospf; | |
7727 | u_short instance = 0; | |
7728 | ||
7729 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 7730 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
7731 | return CMD_SUCCESS; |
7732 | ||
7733 | return show_ip_ospf_route_common(vty, ospf); | |
7734 | } | |
6b0655a2 | 7735 | |
eb1ce605 | 7736 | const char *ospf_abr_type_str[] = |
718e3744 | 7737 | { |
7738 | "unknown", | |
7739 | "standard", | |
7740 | "ibm", | |
7741 | "cisco", | |
7742 | "shortcut" | |
7743 | }; | |
7744 | ||
eb1ce605 | 7745 | const char *ospf_shortcut_mode_str[] = |
718e3744 | 7746 | { |
7747 | "default", | |
7748 | "enable", | |
7749 | "disable" | |
7750 | }; | |
7751 | ||
7752 | ||
4dadc291 | 7753 | static void |
718e3744 | 7754 | area_id2str (char *buf, int length, struct ospf_area *area) |
7755 | { | |
7756 | memset (buf, 0, length); | |
7757 | ||
7758 | if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS) | |
7759 | strncpy (buf, inet_ntoa (area->area_id), length); | |
7760 | else | |
7761 | sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr)); | |
7762 | } | |
7763 | ||
6b0655a2 | 7764 | |
eb1ce605 | 7765 | const char *ospf_int_type_str[] = |
718e3744 | 7766 | { |
7767 | "unknown", /* should never be used. */ | |
7768 | "point-to-point", | |
7769 | "broadcast", | |
7770 | "non-broadcast", | |
7771 | "point-to-multipoint", | |
7772 | "virtual-link", /* should never be used. */ | |
7773 | "loopback" | |
7774 | }; | |
7775 | ||
7776 | /* Configuration write function for ospfd. */ | |
4dadc291 | 7777 | static int |
718e3744 | 7778 | config_write_interface (struct vty *vty) |
7779 | { | |
52dc7ee6 | 7780 | struct listnode *n1, *n2; |
718e3744 | 7781 | struct interface *ifp; |
7782 | struct crypt_key *ck; | |
7783 | int write = 0; | |
7784 | struct route_node *rn = NULL; | |
7785 | struct ospf_if_params *params; | |
7c8ff89e | 7786 | struct ospf *ospf = ospf_lookup(); |
718e3744 | 7787 | |
1eb8ef25 | 7788 | for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp)) |
718e3744 | 7789 | { |
718e3744 | 7790 | if (memcmp (ifp->name, "VLINK", 5) == 0) |
7791 | continue; | |
7792 | ||
7793 | vty_out (vty, "!%s", VTY_NEWLINE); | |
7794 | vty_out (vty, "interface %s%s", ifp->name, | |
7795 | VTY_NEWLINE); | |
7796 | if (ifp->desc) | |
7797 | vty_out (vty, " description %s%s", ifp->desc, | |
7798 | VTY_NEWLINE); | |
7799 | ||
7800 | write++; | |
7801 | ||
7802 | params = IF_DEF_PARAMS (ifp); | |
7803 | ||
7804 | do { | |
7805 | /* Interface Network print. */ | |
7806 | if (OSPF_IF_PARAM_CONFIGURED (params, type) && | |
718e3744 | 7807 | params->type != OSPF_IFTYPE_LOOPBACK) |
7808 | { | |
bc18d616 | 7809 | if (params->type != ospf_default_iftype(ifp)) |
7b90143f | 7810 | { |
7811 | vty_out (vty, " ip ospf network %s", | |
7812 | ospf_int_type_str[params->type]); | |
7813 | if (params != IF_DEF_PARAMS (ifp)) | |
7814 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
7815 | vty_out (vty, "%s", VTY_NEWLINE); | |
7816 | } | |
718e3744 | 7817 | } |
7818 | ||
7819 | /* OSPF interface authentication print */ | |
7820 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) && | |
7821 | params->auth_type != OSPF_AUTH_NOTSET) | |
7822 | { | |
eb1ce605 | 7823 | const char *auth_str; |
718e3744 | 7824 | |
7825 | /* Translation tables are not that much help here due to syntax | |
7826 | of the simple option */ | |
7827 | switch (params->auth_type) | |
7828 | { | |
7829 | ||
7830 | case OSPF_AUTH_NULL: | |
7831 | auth_str = " null"; | |
7832 | break; | |
7833 | ||
7834 | case OSPF_AUTH_SIMPLE: | |
7835 | auth_str = ""; | |
7836 | break; | |
7837 | ||
7838 | case OSPF_AUTH_CRYPTOGRAPHIC: | |
7839 | auth_str = " message-digest"; | |
7840 | break; | |
7841 | ||
7842 | default: | |
7843 | auth_str = ""; | |
7844 | break; | |
7845 | } | |
7846 | ||
7847 | vty_out (vty, " ip ospf authentication%s", auth_str); | |
7848 | if (params != IF_DEF_PARAMS (ifp)) | |
7849 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
7850 | vty_out (vty, "%s", VTY_NEWLINE); | |
7851 | } | |
7852 | ||
7853 | /* Simple Authentication Password print. */ | |
7854 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) && | |
7855 | params->auth_simple[0] != '\0') | |
7856 | { | |
7857 | vty_out (vty, " ip ospf authentication-key %s", | |
7858 | params->auth_simple); | |
7859 | if (params != IF_DEF_PARAMS (ifp)) | |
7860 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
7861 | vty_out (vty, "%s", VTY_NEWLINE); | |
7862 | } | |
7863 | ||
7864 | /* Cryptographic Authentication Key print. */ | |
1eb8ef25 | 7865 | for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck)) |
718e3744 | 7866 | { |
718e3744 | 7867 | vty_out (vty, " ip ospf message-digest-key %d md5 %s", |
7c8ff89e | 7868 | ck->key_id, ck->auth_key); |
718e3744 | 7869 | if (params != IF_DEF_PARAMS (ifp)) |
7870 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
7871 | vty_out (vty, "%s", VTY_NEWLINE); | |
7872 | } | |
7873 | ||
7874 | /* Interface Output Cost print. */ | |
7875 | if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd)) | |
7876 | { | |
7877 | vty_out (vty, " ip ospf cost %u", params->output_cost_cmd); | |
7878 | if (params != IF_DEF_PARAMS (ifp)) | |
7879 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
7880 | vty_out (vty, "%s", VTY_NEWLINE); | |
7881 | } | |
7882 | ||
7883 | /* Hello Interval print. */ | |
7884 | if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) && | |
7885 | params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT) | |
7886 | { | |
7887 | vty_out (vty, " ip ospf hello-interval %u", params->v_hello); | |
7888 | if (params != IF_DEF_PARAMS (ifp)) | |
7889 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
7890 | vty_out (vty, "%s", VTY_NEWLINE); | |
7891 | } | |
7892 | ||
7893 | ||
7894 | /* Router Dead Interval print. */ | |
7895 | if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) && | |
7896 | params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT) | |
7897 | { | |
f9ad937f | 7898 | vty_out (vty, " ip ospf dead-interval "); |
7899 | ||
7900 | /* fast hello ? */ | |
7901 | if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello)) | |
7902 | vty_out (vty, "minimal hello-multiplier %d", | |
7903 | params->fast_hello); | |
7904 | else | |
7905 | vty_out (vty, "%u", params->v_wait); | |
7906 | ||
718e3744 | 7907 | if (params != IF_DEF_PARAMS (ifp)) |
7908 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
7909 | vty_out (vty, "%s", VTY_NEWLINE); | |
7910 | } | |
7911 | ||
7912 | /* Router Priority print. */ | |
7913 | if (OSPF_IF_PARAM_CONFIGURED (params, priority) && | |
7914 | params->priority != OSPF_ROUTER_PRIORITY_DEFAULT) | |
7915 | { | |
7916 | vty_out (vty, " ip ospf priority %u", params->priority); | |
7917 | if (params != IF_DEF_PARAMS (ifp)) | |
7918 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
7919 | vty_out (vty, "%s", VTY_NEWLINE); | |
7920 | } | |
7921 | ||
7922 | /* Retransmit Interval print. */ | |
7923 | if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) && | |
7924 | params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT) | |
7925 | { | |
7926 | vty_out (vty, " ip ospf retransmit-interval %u", | |
7927 | params->retransmit_interval); | |
7928 | if (params != IF_DEF_PARAMS (ifp)) | |
7929 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
7930 | vty_out (vty, "%s", VTY_NEWLINE); | |
7931 | } | |
7932 | ||
7933 | /* Transmit Delay print. */ | |
7934 | if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) && | |
7935 | params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT) | |
7936 | { | |
7937 | vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay); | |
7938 | if (params != IF_DEF_PARAMS (ifp)) | |
7939 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
7940 | vty_out (vty, "%s", VTY_NEWLINE); | |
7941 | } | |
7942 | ||
e723861d DS |
7943 | /* Area print. */ |
7944 | if (OSPF_IF_PARAM_CONFIGURED (params, if_area)) | |
7945 | { | |
7c8ff89e DS |
7946 | if (ospf->instance) |
7947 | vty_out (vty, " ip ospf %d area %s%s", ospf->instance, | |
7948 | inet_ntoa (params->if_area), VTY_NEWLINE); | |
7949 | else | |
7950 | vty_out (vty, " ip ospf area %s%s", | |
7951 | inet_ntoa (params->if_area), VTY_NEWLINE); | |
e723861d DS |
7952 | |
7953 | } | |
7954 | ||
d5a5c8f0 DS |
7955 | /* bfd print. */ |
7956 | if (OSPF_IF_PARAM_CONFIGURED (params, bfd)) | |
7957 | vty_out (vty, " ip ospf bfd%s", VTY_NEWLINE); | |
7958 | ||
ba682537 | 7959 | /* MTU ignore print. */ |
7960 | if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) && | |
7961 | params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) | |
7962 | { | |
7963 | if (params->mtu_ignore == 0) | |
7964 | vty_out (vty, " no ip ospf mtu-ignore"); | |
7965 | else | |
7966 | vty_out (vty, " ip ospf mtu-ignore"); | |
7967 | if (params != IF_DEF_PARAMS (ifp)) | |
7968 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
7969 | vty_out (vty, "%s", VTY_NEWLINE); | |
7970 | } | |
7971 | ||
7972 | ||
718e3744 | 7973 | while (1) |
7974 | { | |
7975 | if (rn == NULL) | |
7976 | rn = route_top (IF_OIFS_PARAMS (ifp)); | |
7977 | else | |
7978 | rn = route_next (rn); | |
7979 | ||
7980 | if (rn == NULL) | |
7981 | break; | |
7982 | params = rn->info; | |
7983 | if (params != NULL) | |
7984 | break; | |
7985 | } | |
7986 | } while (rn); | |
7987 | ||
7988 | #ifdef HAVE_OPAQUE_LSA | |
7989 | ospf_opaque_config_write_if (vty, ifp); | |
7990 | #endif /* HAVE_OPAQUE_LSA */ | |
7991 | } | |
7992 | ||
7993 | return write; | |
7994 | } | |
7995 | ||
4dadc291 | 7996 | static int |
68980084 | 7997 | config_write_network_area (struct vty *vty, struct ospf *ospf) |
718e3744 | 7998 | { |
7999 | struct route_node *rn; | |
8000 | u_char buf[INET_ADDRSTRLEN]; | |
8001 | ||
8002 | /* `network area' print. */ | |
68980084 | 8003 | for (rn = route_top (ospf->networks); rn; rn = route_next (rn)) |
718e3744 | 8004 | if (rn->info) |
8005 | { | |
8006 | struct ospf_network *n = rn->info; | |
8007 | ||
8008 | memset (buf, 0, INET_ADDRSTRLEN); | |
8009 | ||
8010 | /* Create Area ID string by specified Area ID format. */ | |
8011 | if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS) | |
c9e52be3 | 8012 | strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN); |
718e3744 | 8013 | else |
c9e52be3 | 8014 | sprintf ((char *) buf, "%lu", |
718e3744 | 8015 | (unsigned long int) ntohl (n->area_id.s_addr)); |
8016 | ||
8017 | /* Network print. */ | |
8018 | vty_out (vty, " network %s/%d area %s%s", | |
8019 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, | |
8020 | buf, VTY_NEWLINE); | |
8021 | } | |
8022 | ||
8023 | return 0; | |
8024 | } | |
8025 | ||
4dadc291 | 8026 | static int |
68980084 | 8027 | config_write_ospf_area (struct vty *vty, struct ospf *ospf) |
718e3744 | 8028 | { |
52dc7ee6 | 8029 | struct listnode *node; |
1eb8ef25 | 8030 | struct ospf_area *area; |
718e3744 | 8031 | u_char buf[INET_ADDRSTRLEN]; |
8032 | ||
8033 | /* Area configuration print. */ | |
1eb8ef25 | 8034 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
718e3744 | 8035 | { |
718e3744 | 8036 | struct route_node *rn1; |
8037 | ||
c9e52be3 | 8038 | area_id2str ((char *) buf, INET_ADDRSTRLEN, area); |
718e3744 | 8039 | |
8040 | if (area->auth_type != OSPF_AUTH_NULL) | |
8041 | { | |
8042 | if (area->auth_type == OSPF_AUTH_SIMPLE) | |
8043 | vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE); | |
8044 | else | |
8045 | vty_out (vty, " area %s authentication message-digest%s", | |
8046 | buf, VTY_NEWLINE); | |
8047 | } | |
8048 | ||
8049 | if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT) | |
8050 | vty_out (vty, " area %s shortcut %s%s", buf, | |
8051 | ospf_shortcut_mode_str[area->shortcut_configured], | |
8052 | VTY_NEWLINE); | |
8053 | ||
8054 | if ((area->external_routing == OSPF_AREA_STUB) | |
718e3744 | 8055 | || (area->external_routing == OSPF_AREA_NSSA) |
718e3744 | 8056 | ) |
8057 | { | |
b0a053be | 8058 | if (area->external_routing == OSPF_AREA_STUB) |
8059 | vty_out (vty, " area %s stub", buf); | |
b0a053be | 8060 | else if (area->external_routing == OSPF_AREA_NSSA) |
8061 | { | |
8062 | vty_out (vty, " area %s nssa", buf); | |
8063 | switch (area->NSSATranslatorRole) | |
8064 | { | |
8065 | case OSPF_NSSA_ROLE_NEVER: | |
8066 | vty_out (vty, " translate-never"); | |
8067 | break; | |
8068 | case OSPF_NSSA_ROLE_ALWAYS: | |
8069 | vty_out (vty, " translate-always"); | |
8070 | break; | |
8071 | case OSPF_NSSA_ROLE_CANDIDATE: | |
8072 | default: | |
8073 | vty_out (vty, " translate-candidate"); | |
8074 | } | |
8075 | } | |
718e3744 | 8076 | |
8077 | if (area->no_summary) | |
8078 | vty_out (vty, " no-summary"); | |
8079 | ||
8080 | vty_out (vty, "%s", VTY_NEWLINE); | |
8081 | ||
8082 | if (area->default_cost != 1) | |
8083 | vty_out (vty, " area %s default-cost %d%s", buf, | |
8084 | area->default_cost, VTY_NEWLINE); | |
8085 | } | |
8086 | ||
8087 | for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1)) | |
8088 | if (rn1->info) | |
8089 | { | |
8090 | struct ospf_area_range *range = rn1->info; | |
8091 | ||
8092 | vty_out (vty, " area %s range %s/%d", buf, | |
8093 | inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen); | |
8094 | ||
6c835671 | 8095 | if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC) |
718e3744 | 8096 | vty_out (vty, " cost %d", range->cost_config); |
8097 | ||
8098 | if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE)) | |
8099 | vty_out (vty, " not-advertise"); | |
8100 | ||
8101 | if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE)) | |
8102 | vty_out (vty, " substitute %s/%d", | |
8103 | inet_ntoa (range->subst_addr), range->subst_masklen); | |
8104 | ||
8105 | vty_out (vty, "%s", VTY_NEWLINE); | |
8106 | } | |
8107 | ||
8108 | if (EXPORT_NAME (area)) | |
8109 | vty_out (vty, " area %s export-list %s%s", buf, | |
8110 | EXPORT_NAME (area), VTY_NEWLINE); | |
8111 | ||
8112 | if (IMPORT_NAME (area)) | |
8113 | vty_out (vty, " area %s import-list %s%s", buf, | |
8114 | IMPORT_NAME (area), VTY_NEWLINE); | |
8115 | ||
8116 | if (PREFIX_NAME_IN (area)) | |
8117 | vty_out (vty, " area %s filter-list prefix %s in%s", buf, | |
8118 | PREFIX_NAME_IN (area), VTY_NEWLINE); | |
8119 | ||
8120 | if (PREFIX_NAME_OUT (area)) | |
8121 | vty_out (vty, " area %s filter-list prefix %s out%s", buf, | |
8122 | PREFIX_NAME_OUT (area), VTY_NEWLINE); | |
8123 | } | |
8124 | ||
8125 | return 0; | |
8126 | } | |
8127 | ||
4dadc291 | 8128 | static int |
68980084 | 8129 | config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf) |
718e3744 | 8130 | { |
8131 | struct ospf_nbr_nbma *nbr_nbma; | |
8132 | struct route_node *rn; | |
8133 | ||
8134 | /* Static Neighbor configuration print. */ | |
68980084 | 8135 | for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn)) |
718e3744 | 8136 | if ((nbr_nbma = rn->info)) |
8137 | { | |
8138 | vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr)); | |
8139 | ||
8140 | if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT) | |
8141 | vty_out (vty, " priority %d", nbr_nbma->priority); | |
8142 | ||
8143 | if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT) | |
8144 | vty_out (vty, " poll-interval %d", nbr_nbma->v_poll); | |
8145 | ||
8146 | vty_out (vty, "%s", VTY_NEWLINE); | |
8147 | } | |
8148 | ||
8149 | return 0; | |
8150 | } | |
8151 | ||
4dadc291 | 8152 | static int |
68980084 | 8153 | config_write_virtual_link (struct vty *vty, struct ospf *ospf) |
718e3744 | 8154 | { |
52dc7ee6 | 8155 | struct listnode *node; |
1eb8ef25 | 8156 | struct ospf_vl_data *vl_data; |
718e3744 | 8157 | u_char buf[INET_ADDRSTRLEN]; |
8158 | ||
8159 | /* Virtual-Link print */ | |
1eb8ef25 | 8160 | for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data)) |
718e3744 | 8161 | { |
52dc7ee6 | 8162 | struct listnode *n2; |
718e3744 | 8163 | struct crypt_key *ck; |
718e3744 | 8164 | struct ospf_interface *oi; |
8165 | ||
8166 | if (vl_data != NULL) | |
8167 | { | |
8168 | memset (buf, 0, INET_ADDRSTRLEN); | |
8169 | ||
8170 | if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS) | |
c9e52be3 | 8171 | strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN); |
718e3744 | 8172 | else |
c9e52be3 | 8173 | sprintf ((char *) buf, "%lu", |
718e3744 | 8174 | (unsigned long int) ntohl (vl_data->vl_area_id.s_addr)); |
8175 | oi = vl_data->vl_oi; | |
8176 | ||
8177 | /* timers */ | |
8178 | if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT || | |
8179 | OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT || | |
8180 | OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT || | |
8181 | OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT) | |
8182 | vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s", | |
8183 | buf, | |
8184 | inet_ntoa (vl_data->vl_peer), | |
8185 | OSPF_IF_PARAM (oi, v_hello), | |
8186 | OSPF_IF_PARAM (oi, retransmit_interval), | |
8187 | OSPF_IF_PARAM (oi, transmit_delay), | |
8188 | OSPF_IF_PARAM (oi, v_wait), | |
8189 | VTY_NEWLINE); | |
8190 | else | |
8191 | vty_out (vty, " area %s virtual-link %s%s", buf, | |
8192 | inet_ntoa (vl_data->vl_peer), VTY_NEWLINE); | |
8193 | /* Auth key */ | |
8194 | if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0') | |
8195 | vty_out (vty, " area %s virtual-link %s authentication-key %s%s", | |
8196 | buf, | |
8197 | inet_ntoa (vl_data->vl_peer), | |
8198 | IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple, | |
8199 | VTY_NEWLINE); | |
8200 | /* md5 keys */ | |
1eb8ef25 | 8201 | for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt, |
8202 | n2, ck)) | |
8203 | vty_out (vty, " area %s virtual-link %s" | |
8204 | " message-digest-key %d md5 %s%s", | |
8205 | buf, | |
8206 | inet_ntoa (vl_data->vl_peer), | |
8207 | ck->key_id, ck->auth_key, VTY_NEWLINE); | |
718e3744 | 8208 | |
8209 | } | |
8210 | } | |
8211 | ||
8212 | return 0; | |
8213 | } | |
8214 | ||
6b0655a2 | 8215 | |
4dadc291 | 8216 | static int |
68980084 | 8217 | config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf) |
718e3744 | 8218 | { |
8219 | int type; | |
8220 | ||
8221 | /* redistribute print. */ | |
8222 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) | |
7c8ff89e DS |
8223 | { |
8224 | struct list *red_list; | |
8225 | struct listnode *node; | |
8226 | struct ospf_redist *red; | |
718e3744 | 8227 | |
7c8ff89e DS |
8228 | red_list = ospf->redist[type]; |
8229 | if (!red_list) | |
8230 | continue; | |
8231 | ||
8232 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) | |
8233 | { | |
8234 | vty_out (vty, " redistribute %s", zebra_route_string(type)); | |
8235 | if (red->instance) | |
8236 | vty_out (vty, " %d", red->instance); | |
8237 | ||
8238 | if (red->dmetric.value >= 0) | |
8239 | vty_out (vty, " metric %d", red->dmetric.value); | |
8240 | ||
8241 | if (red->dmetric.type == EXTERNAL_METRIC_TYPE_1) | |
8242 | vty_out (vty, " metric-type 1"); | |
8243 | ||
8244 | if (ROUTEMAP_NAME (red)) | |
8245 | vty_out (vty, " route-map %s", ROUTEMAP_NAME (red)); | |
8246 | ||
8247 | vty_out (vty, "%s", VTY_NEWLINE); | |
8248 | } | |
8249 | } | |
718e3744 | 8250 | |
8251 | return 0; | |
8252 | } | |
8253 | ||
4dadc291 | 8254 | static int |
68980084 | 8255 | config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf) |
718e3744 | 8256 | { |
68980084 | 8257 | if (ospf->default_metric != -1) |
8258 | vty_out (vty, " default-metric %d%s", ospf->default_metric, | |
718e3744 | 8259 | VTY_NEWLINE); |
8260 | return 0; | |
8261 | } | |
8262 | ||
4dadc291 | 8263 | static int |
68980084 | 8264 | config_write_ospf_distribute (struct vty *vty, struct ospf *ospf) |
718e3744 | 8265 | { |
8266 | int type; | |
7c8ff89e | 8267 | struct ospf_redist *red; |
718e3744 | 8268 | |
68980084 | 8269 | if (ospf) |
718e3744 | 8270 | { |
8271 | /* distribute-list print. */ | |
8272 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) | |
171c9a99 | 8273 | if (DISTRIBUTE_NAME (ospf, type)) |
718e3744 | 8274 | vty_out (vty, " distribute-list %s out %s%s", |
171c9a99 | 8275 | DISTRIBUTE_NAME (ospf, type), |
f52d13cb | 8276 | zebra_route_string(type), VTY_NEWLINE); |
718e3744 | 8277 | |
8278 | /* default-information print. */ | |
68980084 | 8279 | if (ospf->default_originate != DEFAULT_ORIGINATE_NONE) |
718e3744 | 8280 | { |
c42c177d | 8281 | vty_out (vty, " default-information originate"); |
8282 | if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS) | |
8283 | vty_out (vty, " always"); | |
718e3744 | 8284 | |
7c8ff89e DS |
8285 | red = ospf_redist_lookup(ospf, DEFAULT_ROUTE, 0); |
8286 | if (red) | |
8287 | { | |
8288 | if (red->dmetric.value >= 0) | |
8289 | vty_out (vty, " metric %d", | |
8290 | red->dmetric.value); | |
8291 | if (red->dmetric.type == EXTERNAL_METRIC_TYPE_1) | |
8292 | vty_out (vty, " metric-type 1"); | |
8293 | ||
8294 | if (ROUTEMAP_NAME (red)) | |
8295 | vty_out (vty, " route-map %s", | |
8296 | ROUTEMAP_NAME (red)); | |
8297 | } | |
718e3744 | 8298 | |
8299 | vty_out (vty, "%s", VTY_NEWLINE); | |
8300 | } | |
8301 | ||
8302 | } | |
8303 | ||
8304 | return 0; | |
8305 | } | |
8306 | ||
4dadc291 | 8307 | static int |
68980084 | 8308 | config_write_ospf_distance (struct vty *vty, struct ospf *ospf) |
718e3744 | 8309 | { |
8310 | struct route_node *rn; | |
8311 | struct ospf_distance *odistance; | |
8312 | ||
68980084 | 8313 | if (ospf->distance_all) |
8314 | vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE); | |
718e3744 | 8315 | |
68980084 | 8316 | if (ospf->distance_intra |
8317 | || ospf->distance_inter | |
8318 | || ospf->distance_external) | |
718e3744 | 8319 | { |
8320 | vty_out (vty, " distance ospf"); | |
8321 | ||
68980084 | 8322 | if (ospf->distance_intra) |
8323 | vty_out (vty, " intra-area %d", ospf->distance_intra); | |
8324 | if (ospf->distance_inter) | |
8325 | vty_out (vty, " inter-area %d", ospf->distance_inter); | |
8326 | if (ospf->distance_external) | |
8327 | vty_out (vty, " external %d", ospf->distance_external); | |
718e3744 | 8328 | |
8329 | vty_out (vty, "%s", VTY_NEWLINE); | |
8330 | } | |
8331 | ||
68980084 | 8332 | for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn)) |
718e3744 | 8333 | if ((odistance = rn->info) != NULL) |
8334 | { | |
8335 | vty_out (vty, " distance %d %s/%d %s%s", odistance->distance, | |
8336 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, | |
8337 | odistance->access_list ? odistance->access_list : "", | |
8338 | VTY_NEWLINE); | |
8339 | } | |
8340 | return 0; | |
8341 | } | |
8342 | ||
8343 | /* OSPF configuration write function. */ | |
4dadc291 | 8344 | static int |
718e3744 | 8345 | ospf_config_write (struct vty *vty) |
8346 | { | |
020709f9 | 8347 | struct ospf *ospf; |
1eb8ef25 | 8348 | struct interface *ifp; |
8349 | struct ospf_interface *oi; | |
52dc7ee6 | 8350 | struct listnode *node; |
718e3744 | 8351 | int write = 0; |
8352 | ||
020709f9 | 8353 | ospf = ospf_lookup (); |
0bad4851 | 8354 | if (ospf != NULL && ospf->oi_running) |
718e3744 | 8355 | { |
8356 | /* `router ospf' print. */ | |
7c8ff89e DS |
8357 | if (ospf->instance) |
8358 | vty_out (vty, "router ospf %d%s", ospf->instance, VTY_NEWLINE); | |
8359 | else | |
8360 | vty_out (vty, "router ospf%s", VTY_NEWLINE); | |
718e3744 | 8361 | |
8362 | write++; | |
8363 | ||
68980084 | 8364 | if (!ospf->networks) |
718e3744 | 8365 | return write; |
8366 | ||
8367 | /* Router ID print. */ | |
68980084 | 8368 | if (ospf->router_id_static.s_addr != 0) |
718e3744 | 8369 | vty_out (vty, " ospf router-id %s%s", |
68980084 | 8370 | inet_ntoa (ospf->router_id_static), VTY_NEWLINE); |
718e3744 | 8371 | |
8372 | /* ABR type print. */ | |
d57834f6 | 8373 | if (ospf->abr_type != OSPF_ABR_DEFAULT) |
718e3744 | 8374 | vty_out (vty, " ospf abr-type %s%s", |
68980084 | 8375 | ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE); |
718e3744 | 8376 | |
d7e60dd7 AS |
8377 | /* log-adjacency-changes flag print. */ |
8378 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES)) | |
8379 | { | |
8380 | vty_out(vty, " log-adjacency-changes"); | |
8381 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) | |
8382 | vty_out(vty, " detail"); | |
8383 | vty_out(vty, "%s", VTY_NEWLINE); | |
8384 | } | |
8385 | ||
718e3744 | 8386 | /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */ |
68980084 | 8387 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
718e3744 | 8388 | vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE); |
8389 | ||
8390 | /* auto-cost reference-bandwidth configuration. */ | |
68980084 | 8391 | if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH) |
f9ad937f | 8392 | { |
8393 | vty_out (vty, "! Important: ensure reference bandwidth " | |
8394 | "is consistent across all routers%s", VTY_NEWLINE); | |
8395 | vty_out (vty, " auto-cost reference-bandwidth %d%s", | |
8396 | ospf->ref_bandwidth / 1000, VTY_NEWLINE); | |
8397 | } | |
718e3744 | 8398 | |
8399 | /* SPF timers print. */ | |
68980084 | 8400 | if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT || |
ea4ffc90 | 8401 | ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT || |
8402 | ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT) | |
8403 | vty_out (vty, " timers throttle spf %d %d %d%s", | |
88d6cf37 | 8404 | ospf->spf_delay, ospf->spf_holdtime, |
ea4ffc90 | 8405 | ospf->spf_max_holdtime, VTY_NEWLINE); |
88d6cf37 | 8406 | |
2f8f370e | 8407 | /* Write multiplier print. */ |
e8f45e82 | 8408 | if (ospf->write_oi_count != OSPF_WRITE_INTERFACE_COUNT_DEFAULT) |
2f8f370e | 8409 | vty_out (vty, " ospf write-multiplier %d%s", |
e8f45e82 | 8410 | ospf->write_oi_count, VTY_NEWLINE); |
2f8f370e | 8411 | |
88d6cf37 | 8412 | /* Max-metric router-lsa print */ |
8413 | config_write_stub_router (vty, ospf); | |
8414 | ||
718e3744 | 8415 | /* SPF refresh parameters print. */ |
68980084 | 8416 | if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT) |
718e3744 | 8417 | vty_out (vty, " refresh timer %d%s", |
68980084 | 8418 | ospf->lsa_refresh_interval, VTY_NEWLINE); |
718e3744 | 8419 | |
8420 | /* Redistribute information print. */ | |
68980084 | 8421 | config_write_ospf_redistribute (vty, ospf); |
718e3744 | 8422 | |
8423 | /* passive-interface print. */ | |
7ffa8fa2 PJ |
8424 | if (ospf->passive_interface_default == OSPF_IF_PASSIVE) |
8425 | vty_out (vty, " passive-interface default%s", VTY_NEWLINE); | |
8426 | ||
1eb8ef25 | 8427 | for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp)) |
7ffa8fa2 PJ |
8428 | if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface) |
8429 | && IF_DEF_PARAMS (ifp)->passive_interface != | |
8430 | ospf->passive_interface_default) | |
8431 | { | |
8432 | vty_out (vty, " %spassive-interface %s%s", | |
8433 | IF_DEF_PARAMS (ifp)->passive_interface ? "" : "no ", | |
8434 | ifp->name, VTY_NEWLINE); | |
8435 | } | |
1eb8ef25 | 8436 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
7ffa8fa2 PJ |
8437 | { |
8438 | if (!OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface)) | |
8439 | continue; | |
8440 | if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi->ifp), | |
8441 | passive_interface)) | |
8442 | { | |
8443 | if (oi->params->passive_interface == IF_DEF_PARAMS (oi->ifp)->passive_interface) | |
8444 | continue; | |
8445 | } | |
8446 | else if (oi->params->passive_interface == ospf->passive_interface_default) | |
8447 | continue; | |
8448 | ||
8449 | vty_out (vty, " %spassive-interface %s %s%s", | |
8450 | oi->params->passive_interface ? "" : "no ", | |
1eb8ef25 | 8451 | oi->ifp->name, |
8452 | inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE); | |
7ffa8fa2 | 8453 | } |
718e3744 | 8454 | |
8455 | /* Network area print. */ | |
68980084 | 8456 | config_write_network_area (vty, ospf); |
718e3744 | 8457 | |
8458 | /* Area config print. */ | |
68980084 | 8459 | config_write_ospf_area (vty, ospf); |
718e3744 | 8460 | |
8461 | /* static neighbor print. */ | |
68980084 | 8462 | config_write_ospf_nbr_nbma (vty, ospf); |
718e3744 | 8463 | |
8464 | /* Virtual-Link print. */ | |
68980084 | 8465 | config_write_virtual_link (vty, ospf); |
718e3744 | 8466 | |
8467 | /* Default metric configuration. */ | |
68980084 | 8468 | config_write_ospf_default_metric (vty, ospf); |
718e3744 | 8469 | |
8470 | /* Distribute-list and default-information print. */ | |
68980084 | 8471 | config_write_ospf_distribute (vty, ospf); |
718e3744 | 8472 | |
8473 | /* Distance configuration. */ | |
68980084 | 8474 | config_write_ospf_distance (vty, ospf); |
718e3744 | 8475 | |
8476 | #ifdef HAVE_OPAQUE_LSA | |
68980084 | 8477 | ospf_opaque_config_write_router (vty, ospf); |
718e3744 | 8478 | #endif /* HAVE_OPAQUE_LSA */ |
8479 | } | |
8480 | ||
8481 | return write; | |
8482 | } | |
8483 | ||
8484 | void | |
4dadc291 | 8485 | ospf_vty_show_init (void) |
718e3744 | 8486 | { |
8487 | /* "show ip ospf" commands. */ | |
8488 | install_element (VIEW_NODE, &show_ip_ospf_cmd); | |
8489 | install_element (ENABLE_NODE, &show_ip_ospf_cmd); | |
8490 | ||
7c8ff89e DS |
8491 | install_element (VIEW_NODE, &show_ip_ospf_instance_cmd); |
8492 | install_element (ENABLE_NODE, &show_ip_ospf_instance_cmd); | |
8493 | ||
718e3744 | 8494 | /* "show ip ospf database" commands. */ |
8495 | install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd); | |
8496 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd); | |
8497 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd); | |
8498 | install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd); | |
8499 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd); | |
8500 | install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd); | |
8501 | install_element (VIEW_NODE, &show_ip_ospf_database_cmd); | |
8502 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd); | |
8503 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd); | |
8504 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd); | |
8505 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd); | |
8506 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd); | |
8507 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd); | |
8508 | install_element (ENABLE_NODE, &show_ip_ospf_database_cmd); | |
8509 | ||
7c8ff89e DS |
8510 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_cmd); |
8511 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_id_cmd); | |
8512 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_id_adv_router_cmd); | |
8513 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_adv_router_cmd); | |
8514 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_id_self_cmd); | |
8515 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_self_cmd); | |
8516 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_cmd); | |
8517 | install_element (ENABLE_NODE, &show_ip_ospf_instance_database_type_cmd); | |
8518 | install_element (ENABLE_NODE, &show_ip_ospf_instance_database_type_id_cmd); | |
8519 | install_element (ENABLE_NODE, &show_ip_ospf_instance_database_type_id_adv_router_cmd); | |
8520 | install_element (ENABLE_NODE, &show_ip_ospf_instance_database_type_adv_router_cmd); | |
8521 | install_element (ENABLE_NODE, &show_ip_ospf_instance_database_type_id_self_cmd); | |
8522 | install_element (ENABLE_NODE, &show_ip_ospf_instance_database_type_self_cmd); | |
8523 | install_element (ENABLE_NODE, &show_ip_ospf_instance_database_cmd); | |
8524 | ||
718e3744 | 8525 | /* "show ip ospf interface" commands. */ |
8526 | install_element (VIEW_NODE, &show_ip_ospf_interface_cmd); | |
8527 | install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd); | |
8528 | ||
7c8ff89e DS |
8529 | install_element (VIEW_NODE, &show_ip_ospf_instance_interface_cmd); |
8530 | install_element (ENABLE_NODE, &show_ip_ospf_instance_interface_cmd); | |
8531 | ||
718e3744 | 8532 | /* "show ip ospf neighbor" commands. */ |
8533 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd); | |
8534 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd); | |
8535 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd); | |
8536 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd); | |
8537 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd); | |
8538 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd); | |
8539 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd); | |
8540 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd); | |
8541 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd); | |
8542 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd); | |
8543 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd); | |
8544 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd); | |
8545 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd); | |
8546 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd); | |
8547 | ||
7c8ff89e DS |
8548 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_int_detail_cmd); |
8549 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_int_cmd); | |
8550 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_id_cmd); | |
8551 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_detail_all_cmd); | |
8552 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_detail_cmd); | |
8553 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_cmd); | |
8554 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_all_cmd); | |
8555 | install_element (ENABLE_NODE, &show_ip_ospf_instance_neighbor_int_detail_cmd); | |
8556 | install_element (ENABLE_NODE, &show_ip_ospf_instance_neighbor_int_cmd); | |
8557 | install_element (ENABLE_NODE, &show_ip_ospf_instance_neighbor_id_cmd); | |
8558 | install_element (ENABLE_NODE, &show_ip_ospf_instance_neighbor_detail_all_cmd); | |
8559 | install_element (ENABLE_NODE, &show_ip_ospf_instance_neighbor_detail_cmd); | |
8560 | install_element (ENABLE_NODE, &show_ip_ospf_instance_neighbor_cmd); | |
8561 | install_element (ENABLE_NODE, &show_ip_ospf_instance_neighbor_all_cmd); | |
8562 | ||
718e3744 | 8563 | /* "show ip ospf route" commands. */ |
8564 | install_element (VIEW_NODE, &show_ip_ospf_route_cmd); | |
8565 | install_element (ENABLE_NODE, &show_ip_ospf_route_cmd); | |
718e3744 | 8566 | install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd); |
8567 | install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd); | |
7c8ff89e DS |
8568 | |
8569 | install_element (VIEW_NODE, &show_ip_ospf_instance_route_cmd); | |
8570 | install_element (ENABLE_NODE, &show_ip_ospf_instance_route_cmd); | |
8571 | install_element (VIEW_NODE, &show_ip_ospf_instance_border_routers_cmd); | |
8572 | install_element (ENABLE_NODE, &show_ip_ospf_instance_border_routers_cmd); | |
718e3744 | 8573 | } |
8574 | ||
6b0655a2 | 8575 | |
718e3744 | 8576 | /* ospfd's interface node. */ |
7fc626de | 8577 | static struct cmd_node interface_node = |
718e3744 | 8578 | { |
8579 | INTERFACE_NODE, | |
8580 | "%s(config-if)# ", | |
8581 | 1 | |
8582 | }; | |
8583 | ||
8584 | /* Initialization of OSPF interface. */ | |
4dadc291 | 8585 | static void |
8586 | ospf_vty_if_init (void) | |
718e3744 | 8587 | { |
8588 | /* Install interface node. */ | |
8589 | install_node (&interface_node, config_write_interface); | |
8590 | ||
8591 | install_element (CONFIG_NODE, &interface_cmd); | |
32d2463c | 8592 | install_element (CONFIG_NODE, &no_interface_cmd); |
718e3744 | 8593 | install_default (INTERFACE_NODE); |
8594 | ||
8595 | /* "description" commands. */ | |
8596 | install_element (INTERFACE_NODE, &interface_desc_cmd); | |
8597 | install_element (INTERFACE_NODE, &no_interface_desc_cmd); | |
8598 | ||
8599 | /* "ip ospf authentication" commands. */ | |
8600 | install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd); | |
8601 | install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd); | |
8602 | install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd); | |
8603 | install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd); | |
8604 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd); | |
8605 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd); | |
8606 | install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd); | |
8607 | install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd); | |
8608 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd); | |
8609 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd); | |
8610 | ||
8611 | /* "ip ospf message-digest-key" commands. */ | |
8612 | install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd); | |
8613 | install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd); | |
8614 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd); | |
8615 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd); | |
8616 | ||
8617 | /* "ip ospf cost" commands. */ | |
9eff36b3 DO |
8618 | install_element (INTERFACE_NODE, &ip_ospf_cost_u32_inet4_cmd); |
8619 | install_element (INTERFACE_NODE, &ip_ospf_cost_u32_cmd); | |
827341b7 DO |
8620 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_cmd); |
8621 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_inet4_cmd); | |
9eff36b3 | 8622 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_inet4_cmd); |
718e3744 | 8623 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd); |
8624 | ||
ba682537 | 8625 | /* "ip ospf mtu-ignore" commands. */ |
8626 | install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd); | |
8627 | install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd); | |
8628 | install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd); | |
8629 | install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd); | |
8630 | ||
718e3744 | 8631 | /* "ip ospf dead-interval" commands. */ |
8632 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd); | |
8633 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd); | |
f9ad937f | 8634 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd); |
8635 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd); | |
718e3744 | 8636 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd); |
8637 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd); | |
f9dfba8d | 8638 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_seconds_cmd); |
f9ad937f | 8639 | |
718e3744 | 8640 | /* "ip ospf hello-interval" commands. */ |
8641 | install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd); | |
8642 | install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd); | |
8643 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd); | |
8644 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd); | |
f9dfba8d | 8645 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_seconds_cmd); |
718e3744 | 8646 | |
8647 | /* "ip ospf network" commands. */ | |
8648 | install_element (INTERFACE_NODE, &ip_ospf_network_cmd); | |
8649 | install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd); | |
8650 | ||
8651 | /* "ip ospf priority" commands. */ | |
8652 | install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd); | |
8653 | install_element (INTERFACE_NODE, &ip_ospf_priority_cmd); | |
8654 | install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd); | |
8655 | install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd); | |
8656 | ||
8657 | /* "ip ospf retransmit-interval" commands. */ | |
8658 | install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd); | |
8659 | install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd); | |
8660 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd); | |
8661 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd); | |
8662 | ||
8663 | /* "ip ospf transmit-delay" commands. */ | |
8664 | install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd); | |
8665 | install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd); | |
8666 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd); | |
8667 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd); | |
8668 | ||
e723861d DS |
8669 | /* "ip ospf area" commands. */ |
8670 | install_element (INTERFACE_NODE, &ip_ospf_area_cmd); | |
8671 | install_element (INTERFACE_NODE, &no_ip_ospf_area_cmd); | |
7c8ff89e DS |
8672 | install_element (INTERFACE_NODE, &ip_ospf_instance_area_cmd); |
8673 | install_element (INTERFACE_NODE, &no_ip_ospf_instance_area_cmd); | |
e723861d | 8674 | |
718e3744 | 8675 | /* These commands are compatibitliy for previous version. */ |
8676 | install_element (INTERFACE_NODE, &ospf_authentication_key_cmd); | |
8677 | install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd); | |
8678 | install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd); | |
8679 | install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd); | |
9eff36b3 DO |
8680 | install_element (INTERFACE_NODE, &ospf_cost_u32_cmd); |
8681 | install_element (INTERFACE_NODE, &ospf_cost_u32_inet4_cmd); | |
718e3744 | 8682 | install_element (INTERFACE_NODE, &no_ospf_cost_cmd); |
827341b7 DO |
8683 | install_element (INTERFACE_NODE, &no_ospf_cost_u32_cmd); |
8684 | install_element (INTERFACE_NODE, &no_ospf_cost_u32_inet4_cmd); | |
9eff36b3 | 8685 | install_element (INTERFACE_NODE, &no_ospf_cost_inet4_cmd); |
718e3744 | 8686 | install_element (INTERFACE_NODE, &ospf_dead_interval_cmd); |
8687 | install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd); | |
8688 | install_element (INTERFACE_NODE, &ospf_hello_interval_cmd); | |
8689 | install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd); | |
8690 | install_element (INTERFACE_NODE, &ospf_network_cmd); | |
8691 | install_element (INTERFACE_NODE, &no_ospf_network_cmd); | |
8692 | install_element (INTERFACE_NODE, &ospf_priority_cmd); | |
8693 | install_element (INTERFACE_NODE, &no_ospf_priority_cmd); | |
8694 | install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd); | |
8695 | install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd); | |
8696 | install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd); | |
8697 | install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd); | |
d5a5c8f0 DS |
8698 | install_element (INTERFACE_NODE, &ip_ospf_bfd_cmd); |
8699 | install_element (INTERFACE_NODE, &no_ip_ospf_bfd_cmd); | |
718e3744 | 8700 | } |
8701 | ||
4dadc291 | 8702 | static void |
8703 | ospf_vty_zebra_init (void) | |
718e3744 | 8704 | { |
718e3744 | 8705 | install_element (OSPF_NODE, &ospf_redistribute_source_cmd); |
718e3744 | 8706 | install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd); |
7c8ff89e DS |
8707 | install_element (OSPF_NODE, &ospf_redistribute_instance_source_cmd); |
8708 | install_element (OSPF_NODE, &no_ospf_redistribute_instance_source_cmd); | |
718e3744 | 8709 | |
8710 | install_element (OSPF_NODE, &ospf_distribute_list_out_cmd); | |
8711 | install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd); | |
8712 | ||
718e3744 | 8713 | install_element (OSPF_NODE, &ospf_default_information_originate_cmd); |
718e3744 | 8714 | install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd); |
8715 | ||
8716 | install_element (OSPF_NODE, &ospf_default_metric_cmd); | |
8717 | install_element (OSPF_NODE, &no_ospf_default_metric_cmd); | |
8718 | install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd); | |
8719 | ||
8720 | install_element (OSPF_NODE, &ospf_distance_cmd); | |
8721 | install_element (OSPF_NODE, &no_ospf_distance_cmd); | |
8722 | install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd); | |
6f2a6703 | 8723 | install_element (OSPF_NODE, &ospf_distance_ospf_cmd); |
718e3744 | 8724 | #if 0 |
8725 | install_element (OSPF_NODE, &ospf_distance_source_cmd); | |
8726 | install_element (OSPF_NODE, &no_ospf_distance_source_cmd); | |
8727 | install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd); | |
8728 | install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd); | |
8729 | #endif /* 0 */ | |
8730 | } | |
8731 | ||
7fc626de | 8732 | static struct cmd_node ospf_node = |
718e3744 | 8733 | { |
8734 | OSPF_NODE, | |
8735 | "%s(config-router)# ", | |
8736 | 1 | |
8737 | }; | |
8738 | ||
09f35f8c DS |
8739 | static void |
8740 | ospf_interface_clear (struct interface *ifp) | |
8741 | { | |
8742 | if (!if_is_operative (ifp)) return; | |
8743 | ||
8744 | if (IS_DEBUG_OSPF (ism, ISM_EVENTS)) | |
8745 | zlog (NULL, LOG_DEBUG, "ISM[%s]: clear by reset", ifp->name); | |
8746 | ||
8747 | ospf_if_reset(ifp); | |
8748 | } | |
8749 | ||
8750 | DEFUN (clear_ip_ospf_interface, | |
8751 | clear_ip_ospf_interface_cmd, | |
8752 | "clear ip ospf interface [IFNAME]", | |
8753 | CLEAR_STR | |
8754 | IP_STR | |
8755 | "OSPF information\n" | |
8756 | "Interface information\n" | |
8757 | "Interface name\n") | |
8758 | { | |
8759 | struct interface *ifp; | |
8760 | struct listnode *node; | |
8761 | ||
8762 | if (argc == 0) /* Clear all the ospfv2 interfaces. */ | |
8763 | { | |
8764 | for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) | |
8765 | ospf_interface_clear(ifp); | |
8766 | } | |
8767 | else /* Interface name is specified. */ | |
8768 | { | |
8769 | if ((ifp = if_lookup_by_name (argv[0])) == NULL) | |
8770 | vty_out (vty, "No such interface name%s", VTY_NEWLINE); | |
8771 | else | |
8772 | ospf_interface_clear(ifp); | |
8773 | } | |
8774 | ||
8775 | return CMD_SUCCESS; | |
8776 | } | |
8777 | ||
8778 | void | |
8779 | ospf_vty_clear_init (void) | |
8780 | { | |
8781 | install_element (ENABLE_NODE, &clear_ip_ospf_interface_cmd); | |
8782 | } | |
8783 | ||
6b0655a2 | 8784 | |
718e3744 | 8785 | /* Install OSPF related vty commands. */ |
8786 | void | |
4dadc291 | 8787 | ospf_vty_init (void) |
718e3744 | 8788 | { |
8789 | /* Install ospf top node. */ | |
8790 | install_node (&ospf_node, ospf_config_write); | |
8791 | ||
8792 | /* "router ospf" commands. */ | |
8793 | install_element (CONFIG_NODE, &router_ospf_cmd); | |
8794 | install_element (CONFIG_NODE, &no_router_ospf_cmd); | |
8795 | ||
7c8ff89e DS |
8796 | install_element (CONFIG_NODE, &router_ospf_instance_cmd); |
8797 | install_element (CONFIG_NODE, &no_router_ospf_instance_cmd); | |
8798 | ||
718e3744 | 8799 | install_default (OSPF_NODE); |
8800 | ||
8801 | /* "ospf router-id" commands. */ | |
8802 | install_element (OSPF_NODE, &ospf_router_id_cmd); | |
8803 | install_element (OSPF_NODE, &no_ospf_router_id_cmd); | |
a2c62831 | 8804 | install_element (OSPF_NODE, &router_ospf_id_cmd); |
8805 | install_element (OSPF_NODE, &no_router_ospf_id_cmd); | |
718e3744 | 8806 | |
8807 | /* "passive-interface" commands. */ | |
a2c62831 | 8808 | install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd); |
8809 | install_element (OSPF_NODE, &ospf_passive_interface_cmd); | |
7ffa8fa2 | 8810 | install_element (OSPF_NODE, &ospf_passive_interface_default_cmd); |
a2c62831 | 8811 | install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd); |
8812 | install_element (OSPF_NODE, &no_ospf_passive_interface_cmd); | |
7ffa8fa2 | 8813 | install_element (OSPF_NODE, &no_ospf_passive_interface_default_cmd); |
718e3744 | 8814 | |
8815 | /* "ospf abr-type" commands. */ | |
8816 | install_element (OSPF_NODE, &ospf_abr_type_cmd); | |
8817 | install_element (OSPF_NODE, &no_ospf_abr_type_cmd); | |
8818 | ||
d7e60dd7 AS |
8819 | /* "ospf log-adjacency-changes" commands. */ |
8820 | install_element (OSPF_NODE, &ospf_log_adjacency_changes_cmd); | |
8821 | install_element (OSPF_NODE, &ospf_log_adjacency_changes_detail_cmd); | |
8822 | install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_cmd); | |
8823 | install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd); | |
8824 | ||
718e3744 | 8825 | /* "ospf rfc1583-compatible" commands. */ |
8826 | install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd); | |
8827 | install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd); | |
8828 | install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd); | |
8829 | install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd); | |
8830 | ||
8831 | /* "network area" commands. */ | |
a2c62831 | 8832 | install_element (OSPF_NODE, &ospf_network_area_cmd); |
8833 | install_element (OSPF_NODE, &no_ospf_network_area_cmd); | |
718e3744 | 8834 | |
8835 | /* "area authentication" commands. */ | |
a2c62831 | 8836 | install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd); |
8837 | install_element (OSPF_NODE, &ospf_area_authentication_cmd); | |
8838 | install_element (OSPF_NODE, &no_ospf_area_authentication_cmd); | |
718e3744 | 8839 | |
8840 | /* "area range" commands. */ | |
a2c62831 | 8841 | install_element (OSPF_NODE, &ospf_area_range_cmd); |
8842 | install_element (OSPF_NODE, &ospf_area_range_advertise_cmd); | |
8843 | install_element (OSPF_NODE, &ospf_area_range_cost_cmd); | |
8844 | install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd); | |
8845 | install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd); | |
8846 | install_element (OSPF_NODE, &no_ospf_area_range_cmd); | |
8847 | install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd); | |
8848 | install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd); | |
8849 | install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd); | |
8850 | install_element (OSPF_NODE, &ospf_area_range_substitute_cmd); | |
8851 | install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd); | |
718e3744 | 8852 | |
8853 | /* "area virtual-link" commands. */ | |
a2c62831 | 8854 | install_element (OSPF_NODE, &ospf_area_vlink_cmd); |
8855 | install_element (OSPF_NODE, &no_ospf_area_vlink_cmd); | |
718e3744 | 8856 | |
a2c62831 | 8857 | install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd); |
8858 | install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd); | |
718e3744 | 8859 | |
a2c62831 | 8860 | install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd); |
8861 | install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd); | |
718e3744 | 8862 | |
a2c62831 | 8863 | install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd); |
8864 | install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd); | |
718e3744 | 8865 | |
a2c62831 | 8866 | install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd); |
8867 | install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd); | |
718e3744 | 8868 | |
a2c62831 | 8869 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd); |
8870 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd); | |
8871 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd); | |
718e3744 | 8872 | |
a2c62831 | 8873 | install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd); |
8874 | install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd); | |
718e3744 | 8875 | |
a2c62831 | 8876 | install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd); |
8877 | install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd); | |
718e3744 | 8878 | |
a2c62831 | 8879 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd); |
8880 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd); | |
8881 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd); | |
718e3744 | 8882 | |
a2c62831 | 8883 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd); |
8884 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd); | |
8885 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd); | |
718e3744 | 8886 | |
8887 | /* "area stub" commands. */ | |
a2c62831 | 8888 | install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd); |
8889 | install_element (OSPF_NODE, &ospf_area_stub_cmd); | |
8890 | install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd); | |
8891 | install_element (OSPF_NODE, &no_ospf_area_stub_cmd); | |
718e3744 | 8892 | |
718e3744 | 8893 | /* "area nssa" commands. */ |
a2c62831 | 8894 | install_element (OSPF_NODE, &ospf_area_nssa_cmd); |
8895 | install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd); | |
8896 | install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd); | |
8897 | install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd); | |
8898 | install_element (OSPF_NODE, &no_ospf_area_nssa_cmd); | |
8899 | install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd); | |
718e3744 | 8900 | |
a2c62831 | 8901 | install_element (OSPF_NODE, &ospf_area_default_cost_cmd); |
8902 | install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd); | |
718e3744 | 8903 | |
a2c62831 | 8904 | install_element (OSPF_NODE, &ospf_area_shortcut_cmd); |
8905 | install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd); | |
718e3744 | 8906 | |
a2c62831 | 8907 | install_element (OSPF_NODE, &ospf_area_export_list_cmd); |
8908 | install_element (OSPF_NODE, &no_ospf_area_export_list_cmd); | |
718e3744 | 8909 | |
a2c62831 | 8910 | install_element (OSPF_NODE, &ospf_area_filter_list_cmd); |
8911 | install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd); | |
718e3744 | 8912 | |
a2c62831 | 8913 | install_element (OSPF_NODE, &ospf_area_import_list_cmd); |
8914 | install_element (OSPF_NODE, &no_ospf_area_import_list_cmd); | |
88d6cf37 | 8915 | |
8916 | /* SPF timer commands */ | |
a2c62831 | 8917 | install_element (OSPF_NODE, &ospf_timers_spf_cmd); |
8918 | install_element (OSPF_NODE, &no_ospf_timers_spf_cmd); | |
d24f6e2a | 8919 | install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd); |
8920 | install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd); | |
8921 | ||
88d6cf37 | 8922 | /* refresh timer commands */ |
a2c62831 | 8923 | install_element (OSPF_NODE, &ospf_refresh_timer_cmd); |
8924 | install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd); | |
8925 | install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd); | |
718e3744 | 8926 | |
88d6cf37 | 8927 | /* max-metric commands */ |
8928 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd); | |
8929 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd); | |
8930 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd); | |
8931 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd); | |
8932 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd); | |
8933 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd); | |
8934 | ||
8935 | /* reference bandwidth commands */ | |
a2c62831 | 8936 | install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd); |
8937 | install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd); | |
718e3744 | 8938 | |
8939 | /* "neighbor" commands. */ | |
a2c62831 | 8940 | install_element (OSPF_NODE, &ospf_neighbor_cmd); |
8941 | install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd); | |
8942 | install_element (OSPF_NODE, &ospf_neighbor_priority_cmd); | |
8943 | install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd); | |
8944 | install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd); | |
8945 | install_element (OSPF_NODE, &no_ospf_neighbor_cmd); | |
8946 | install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd); | |
8947 | install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd); | |
718e3744 | 8948 | |
2f8f370e DS |
8949 | /* write multiplier commands */ |
8950 | install_element (OSPF_NODE, &ospf_write_multiplier_cmd); | |
8951 | install_element (OSPF_NODE, &no_ospf_write_multiplier_cmd); | |
e8f45e82 DS |
8952 | install_element (OSPF_NODE, &write_multiplier_cmd); |
8953 | install_element (OSPF_NODE, &no_write_multiplier_cmd); | |
2f8f370e | 8954 | |
718e3744 | 8955 | /* Init interface related vty commands. */ |
8956 | ospf_vty_if_init (); | |
8957 | ||
8958 | /* Init zebra related vty commands. */ | |
8959 | ospf_vty_zebra_init (); | |
8960 | } |