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