ospfd: Tighten up the connected check for redistribution
[jleu-quagga.git] / ospfd / ospf_vty.c
blob7c3dec8cea03bb0fe36bfeaa97e212c436ffeb33
1 /* OSPF VTY interface.
2 * Copyright (C) 2005 6WIND <alain.ritoux@6wind.com>
3 * Copyright (C) 2000 Toshiaki Takada
5 * This file is part of GNU Zebra.
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.
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.
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.
23 #include <zebra.h>
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"
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"
53 static const char *ospf_network_type_str[] =
55 "Null",
56 "POINTOPOINT",
57 "BROADCAST",
58 "NBMA",
59 "POINTOMULTIPOINT",
60 "VIRTUALLINK",
61 "LOOPBACK"
65 /* Utility functions. */
66 static int
67 ospf_str2area_id (const char *str, struct in_addr *area_id, int *format)
69 char *endptr = NULL;
70 unsigned long ret;
72 /* match "A.B.C.D". */
73 if (strchr (str, '.') != NULL)
75 ret = inet_aton (str, area_id);
76 if (!ret)
77 return -1;
78 *format = OSPF_AREA_ID_FORMAT_ADDRESS;
80 /* match "<0-4294967295>". */
81 else
83 ret = strtoul (str, &endptr, 10);
84 if (*endptr != '\0' || (ret == ULONG_MAX && errno == ERANGE))
85 return -1;
87 area_id->s_addr = htonl (ret);
88 *format = OSPF_AREA_ID_FORMAT_DECIMAL;
91 return 0;
95 static int
96 str2distribute_source (const char *str, int *source)
98 /* Sanity check. */
99 if (str == NULL)
100 return 0;
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;
115 return 1;
118 static int
119 str2metric (const char *str, int *metric)
121 /* Sanity check. */
122 if (str == NULL)
123 return 0;
125 *metric = strtol (str, NULL, 10);
126 if (*metric < 0 && *metric > 16777214)
128 /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */
129 return 0;
132 return 1;
135 static int
136 str2metric_type (const char *str, int *metric_type)
138 /* Sanity check. */
139 if (str == NULL)
140 return 0;
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;
149 return 1;
153 ospf_oi_count (struct interface *ifp)
155 struct route_node *rn;
156 int i = 0;
158 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
159 if (rn->info)
160 i++;
162 return i;
166 DEFUN (router_ospf,
167 router_ospf_cmd,
168 "router ospf",
169 "Enable a routing process\n"
170 "Start OSPF configuration\n")
172 vty->node = OSPF_NODE;
173 vty->index = ospf_get ();
175 return CMD_SUCCESS;
178 DEFUN (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")
185 struct ospf *ospf;
187 ospf = ospf_lookup ();
188 if (ospf == NULL)
190 vty_out (vty, "There isn't active ospf instance%s", VTY_NEWLINE);
191 return CMD_WARNING;
194 ospf_finish (ospf);
196 return CMD_SUCCESS;
199 DEFUN (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")
206 struct ospf *ospf = vty->index;
207 struct in_addr router_id;
208 int ret;
210 ret = inet_aton (argv[0], &router_id);
211 if (!ret)
213 vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE);
214 return CMD_WARNING;
217 ospf->router_id_static = router_id;
219 ospf_router_id_update (ospf);
221 return CMD_SUCCESS;
224 ALIAS (ospf_router_id,
225 router_ospf_id_cmd,
226 "router-id A.B.C.D",
227 "router-id for the OSPF process\n"
228 "OSPF router-id in IP address format\n")
230 DEFUN (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")
237 struct ospf *ospf = vty->index;
239 ospf->router_id_static.s_addr = 0;
241 ospf_router_id_update (ospf);
243 return CMD_SUCCESS;
246 ALIAS (no_ospf_router_id,
247 no_router_ospf_id_cmd,
248 "no router-id",
249 NO_STR
250 "router-id for the OSPF process\n")
252 static void
253 ospf_passive_interface_default (struct ospf *ospf, u_char newval)
255 struct listnode *ln;
256 struct interface *ifp;
257 struct ospf_interface *oi;
259 ospf->passive_interface_default = newval;
261 for (ALL_LIST_ELEMENTS_RO (om->iflist, ln, ifp))
263 if (ifp &&
264 OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface))
265 UNSET_IF_PARAM (IF_DEF_PARAMS (ifp), passive_interface);
267 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, ln, oi))
269 if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface))
270 UNSET_IF_PARAM (oi->params, passive_interface);
271 /* update multicast memberships */
272 ospf_if_set_multicast(oi);
276 static void
277 ospf_passive_interface_update (struct ospf *ospf, struct interface *ifp,
278 struct in_addr addr,
279 struct ospf_if_params *params, u_char value)
281 u_char dflt;
283 params->passive_interface = value;
284 if (params != IF_DEF_PARAMS (ifp))
286 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface))
287 dflt = IF_DEF_PARAMS (ifp)->passive_interface;
288 else
289 dflt = ospf->passive_interface_default;
291 if (value != dflt)
292 SET_IF_PARAM (params, passive_interface);
293 else
294 UNSET_IF_PARAM (params, passive_interface);
296 ospf_free_if_params (ifp, addr);
297 ospf_if_update_params (ifp, addr);
299 else
301 if (value != ospf->passive_interface_default)
302 SET_IF_PARAM (params, passive_interface);
303 else
304 UNSET_IF_PARAM (params, passive_interface);
308 DEFUN (ospf_passive_interface,
309 ospf_passive_interface_addr_cmd,
310 "passive-interface IFNAME A.B.C.D",
311 "Suppress routing updates on an interface\n"
312 "Interface's name\n")
314 struct interface *ifp;
315 struct in_addr addr;
316 int ret;
317 struct ospf_if_params *params;
318 struct route_node *rn;
319 struct ospf *ospf = vty->index;
321 if (argc == 0)
323 ospf_passive_interface_default (ospf, OSPF_IF_PASSIVE);
324 return CMD_SUCCESS;
327 ifp = if_get_by_name (argv[0]);
329 params = IF_DEF_PARAMS (ifp);
331 if (argc == 2)
333 ret = inet_aton(argv[1], &addr);
334 if (!ret)
336 vty_out (vty, "Please specify interface address by A.B.C.D%s",
337 VTY_NEWLINE);
338 return CMD_WARNING;
341 params = ospf_get_if_params (ifp, addr);
342 ospf_if_update_params (ifp, addr);
344 ospf_passive_interface_update (ospf, ifp, addr, params, OSPF_IF_PASSIVE);
346 /* XXX We should call ospf_if_set_multicast on exactly those
347 * interfaces for which the passive property changed. It is too much
348 * work to determine this set, so we do this for every interface.
349 * This is safe and reasonable because ospf_if_set_multicast uses a
350 * record of joined groups to avoid systems calls if the desired
351 * memberships match the current memership.
354 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
356 struct ospf_interface *oi = rn->info;
358 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE))
359 ospf_if_set_multicast(oi);
362 * XXX It is not clear what state transitions the interface needs to
363 * undergo when going from active to passive. Fixing this will
364 * require precise identification of interfaces having such a
365 * transition.
368 return CMD_SUCCESS;
371 ALIAS (ospf_passive_interface,
372 ospf_passive_interface_cmd,
373 "passive-interface IFNAME",
374 "Suppress routing updates on an interface\n"
375 "Interface's name\n")
377 ALIAS (ospf_passive_interface,
378 ospf_passive_interface_default_cmd,
379 "passive-interface default",
380 "Suppress routing updates on an interface\n"
381 "Suppress routing updates on interfaces by default\n")
383 DEFUN (no_ospf_passive_interface,
384 no_ospf_passive_interface_addr_cmd,
385 "no passive-interface IFNAME A.B.C.D",
386 NO_STR
387 "Allow routing updates on an interface\n"
388 "Interface's name\n")
390 struct interface *ifp;
391 struct in_addr addr;
392 struct ospf_if_params *params;
393 int ret;
394 struct route_node *rn;
395 struct ospf *ospf = vty->index;
397 if (argc == 0)
399 ospf_passive_interface_default (ospf, OSPF_IF_ACTIVE);
400 return CMD_SUCCESS;
403 ifp = if_get_by_name (argv[0]);
405 params = IF_DEF_PARAMS (ifp);
407 if (argc == 2)
409 ret = inet_aton(argv[1], &addr);
410 if (!ret)
412 vty_out (vty, "Please specify interface address by A.B.C.D%s",
413 VTY_NEWLINE);
414 return CMD_WARNING;
417 params = ospf_lookup_if_params (ifp, addr);
418 if (params == NULL)
419 return CMD_SUCCESS;
421 ospf_passive_interface_update (ospf, ifp, addr, params, OSPF_IF_ACTIVE);
423 /* XXX We should call ospf_if_set_multicast on exactly those
424 * interfaces for which the passive property changed. It is too much
425 * work to determine this set, so we do this for every interface.
426 * This is safe and reasonable because ospf_if_set_multicast uses a
427 * record of joined groups to avoid systems calls if the desired
428 * memberships match the current memership.
430 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
432 struct ospf_interface *oi = rn->info;
434 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE))
435 ospf_if_set_multicast(oi);
438 return CMD_SUCCESS;
441 ALIAS (no_ospf_passive_interface,
442 no_ospf_passive_interface_cmd,
443 "no passive-interface IFNAME",
444 NO_STR
445 "Allow routing updates on an interface\n"
446 "Interface's name\n")
448 ALIAS (no_ospf_passive_interface,
449 no_ospf_passive_interface_default_cmd,
450 "no passive-interface default",
451 NO_STR
452 "Allow routing updates on an interface\n"
453 "Allow routing updates on interfaces by default\n")
455 DEFUN (ospf_network_area,
456 ospf_network_area_cmd,
457 "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
458 "Enable routing on an IP network\n"
459 "OSPF network prefix\n"
460 "Set the OSPF area ID\n"
461 "OSPF area ID in IP address format\n"
462 "OSPF area ID as a decimal value\n")
464 struct ospf *ospf= vty->index;
465 struct prefix_ipv4 p;
466 struct in_addr area_id;
467 int ret, format;
469 /* Get network prefix and Area ID. */
470 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
471 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
473 ret = ospf_network_set (ospf, &p, area_id);
474 if (ret == 0)
476 vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE);
477 return CMD_WARNING;
480 return CMD_SUCCESS;
483 DEFUN (no_ospf_network_area,
484 no_ospf_network_area_cmd,
485 "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
486 NO_STR
487 "Enable routing on an IP network\n"
488 "OSPF network prefix\n"
489 "Set the OSPF area ID\n"
490 "OSPF area ID in IP address format\n"
491 "OSPF area ID as a decimal value\n")
493 struct ospf *ospf = (struct ospf *) vty->index;
494 struct prefix_ipv4 p;
495 struct in_addr area_id;
496 int ret, format;
498 /* Get network prefix and Area ID. */
499 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
500 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
502 ret = ospf_network_unset (ospf, &p, area_id);
503 if (ret == 0)
505 vty_out (vty, "Can't find specified network area configuration.%s",
506 VTY_NEWLINE);
507 return CMD_WARNING;
510 return CMD_SUCCESS;
514 DEFUN (ospf_area_range,
515 ospf_area_range_cmd,
516 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
517 "OSPF area parameters\n"
518 "OSPF area ID in IP address format\n"
519 "OSPF area ID as a decimal value\n"
520 "Summarize routes matching address/mask (border routers only)\n"
521 "Area range prefix\n")
523 struct ospf *ospf = vty->index;
524 struct prefix_ipv4 p;
525 struct in_addr area_id;
526 int format;
527 u_int32_t cost;
529 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
530 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
532 ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE);
533 if (argc > 2)
535 VTY_GET_INTEGER ("range cost", cost, argv[2]);
536 ospf_area_range_cost_set (ospf, area_id, &p, cost);
539 return CMD_SUCCESS;
542 ALIAS (ospf_area_range,
543 ospf_area_range_advertise_cmd,
544 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise",
545 "OSPF area parameters\n"
546 "OSPF area ID in IP address format\n"
547 "OSPF area ID as a decimal value\n"
548 "OSPF area range for route advertise (default)\n"
549 "Area range prefix\n"
550 "Advertise this range (default)\n")
552 ALIAS (ospf_area_range,
553 ospf_area_range_cost_cmd,
554 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
555 "OSPF area parameters\n"
556 "OSPF area ID in IP address format\n"
557 "OSPF area ID as a decimal value\n"
558 "Summarize routes matching address/mask (border routers only)\n"
559 "Area range prefix\n"
560 "User specified metric for this range\n"
561 "Advertised metric for this range\n")
563 ALIAS (ospf_area_range,
564 ospf_area_range_advertise_cost_cmd,
565 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
566 "OSPF area parameters\n"
567 "OSPF area ID in IP address format\n"
568 "OSPF area ID as a decimal value\n"
569 "Summarize routes matching address/mask (border routers only)\n"
570 "Area range prefix\n"
571 "Advertise this range (default)\n"
572 "User specified metric for this range\n"
573 "Advertised metric for this range\n")
575 DEFUN (ospf_area_range_not_advertise,
576 ospf_area_range_not_advertise_cmd,
577 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise",
578 "OSPF area parameters\n"
579 "OSPF area ID in IP address format\n"
580 "OSPF area ID as a decimal value\n"
581 "Summarize routes matching address/mask (border routers only)\n"
582 "Area range prefix\n"
583 "DoNotAdvertise this range\n")
585 struct ospf *ospf = vty->index;
586 struct prefix_ipv4 p;
587 struct in_addr area_id;
588 int format;
590 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
591 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
593 ospf_area_range_set (ospf, area_id, &p, 0);
595 return CMD_SUCCESS;
598 DEFUN (no_ospf_area_range,
599 no_ospf_area_range_cmd,
600 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
601 NO_STR
602 "OSPF area parameters\n"
603 "OSPF area ID in IP address format\n"
604 "OSPF area ID as a decimal value\n"
605 "Summarize routes matching address/mask (border routers only)\n"
606 "Area range prefix\n")
608 struct ospf *ospf = vty->index;
609 struct prefix_ipv4 p;
610 struct in_addr area_id;
611 int format;
613 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
614 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
616 ospf_area_range_unset (ospf, area_id, &p);
618 return CMD_SUCCESS;
621 ALIAS (no_ospf_area_range,
622 no_ospf_area_range_advertise_cmd,
623 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)",
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 "Advertise this range (default)\n"
631 "DoNotAdvertise this range\n")
633 ALIAS (no_ospf_area_range,
634 no_ospf_area_range_cost_cmd,
635 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
636 NO_STR
637 "OSPF area parameters\n"
638 "OSPF area ID in IP address format\n"
639 "OSPF area ID as a decimal value\n"
640 "Summarize routes matching address/mask (border routers only)\n"
641 "Area range prefix\n"
642 "User specified metric for this range\n"
643 "Advertised metric for this range\n")
645 ALIAS (no_ospf_area_range,
646 no_ospf_area_range_advertise_cost_cmd,
647 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
648 NO_STR
649 "OSPF area parameters\n"
650 "OSPF area ID in IP address format\n"
651 "OSPF area ID as a decimal value\n"
652 "Summarize routes matching address/mask (border routers only)\n"
653 "Area range prefix\n"
654 "Advertise this range (default)\n"
655 "User specified metric for this range\n"
656 "Advertised metric for this range\n")
658 DEFUN (ospf_area_range_substitute,
659 ospf_area_range_substitute_cmd,
660 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
661 "OSPF area parameters\n"
662 "OSPF area ID in IP address format\n"
663 "OSPF area ID as a decimal value\n"
664 "Summarize routes matching address/mask (border routers only)\n"
665 "Area range prefix\n"
666 "Announce area range as another prefix\n"
667 "Network prefix to be announced instead of range\n")
669 struct ospf *ospf = vty->index;
670 struct prefix_ipv4 p, s;
671 struct in_addr area_id;
672 int format;
674 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
675 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
676 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
678 ospf_area_range_substitute_set (ospf, area_id, &p, &s);
680 return CMD_SUCCESS;
683 DEFUN (no_ospf_area_range_substitute,
684 no_ospf_area_range_substitute_cmd,
685 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
686 NO_STR
687 "OSPF area parameters\n"
688 "OSPF area ID in IP address format\n"
689 "OSPF area ID as a decimal value\n"
690 "Summarize routes matching address/mask (border routers only)\n"
691 "Area range prefix\n"
692 "Announce area range as another prefix\n"
693 "Network prefix to be announced instead of range\n")
695 struct ospf *ospf = vty->index;
696 struct prefix_ipv4 p, s;
697 struct in_addr area_id;
698 int format;
700 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
701 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
702 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
704 ospf_area_range_substitute_unset (ospf, area_id, &p);
706 return CMD_SUCCESS;
710 /* Command Handler Logic in VLink stuff is delicate!!
712 ALTER AT YOUR OWN RISK!!!!
714 Various dummy values are used to represent 'NoChange' state for
715 VLink configuration NOT being changed by a VLink command, and
716 special syntax is used within the command strings so that the
717 typed in command verbs can be seen in the configuration command
718 bacckend handler. This is to drastically reduce the verbeage
719 required to coe up with a reasonably compatible Cisco VLink command
721 - Matthew Grant <grantma@anathoth.gen.nz>
722 Wed, 21 Feb 2001 15:13:52 +1300
726 /* Configuration data for virtual links
728 struct ospf_vl_config_data {
729 struct vty *vty; /* vty stuff */
730 struct in_addr area_id; /* area ID from command line */
731 int format; /* command line area ID format */
732 struct in_addr vl_peer; /* command line vl_peer */
733 int auth_type; /* Authehntication type, if given */
734 char *auth_key; /* simple password if present */
735 int crypto_key_id; /* Cryptographic key ID */
736 char *md5_key; /* MD5 authentication key */
737 int hello_interval; /* Obvious what these are... */
738 int retransmit_interval;
739 int transmit_delay;
740 int dead_interval;
743 static void
744 ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config,
745 struct vty *vty)
747 memset (vl_config, 0, sizeof (struct ospf_vl_config_data));
748 vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN;
749 vl_config->vty = vty;
752 static struct ospf_vl_data *
753 ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
755 struct ospf_area *area;
756 struct ospf_vl_data *vl_data;
757 struct vty *vty;
758 struct in_addr area_id;
760 vty = vl_config->vty;
761 area_id = vl_config->area_id;
763 if (area_id.s_addr == OSPF_AREA_BACKBONE)
765 vty_out (vty,
766 "Configuring VLs over the backbone is not allowed%s",
767 VTY_NEWLINE);
768 return NULL;
770 area = ospf_area_get (ospf, area_id, vl_config->format);
772 if (area->external_routing != OSPF_AREA_DEFAULT)
774 if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS)
775 vty_out (vty, "Area %s is %s%s",
776 inet_ntoa (area_id),
777 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
778 VTY_NEWLINE);
779 else
780 vty_out (vty, "Area %ld is %s%s",
781 (u_long)ntohl (area_id.s_addr),
782 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
783 VTY_NEWLINE);
784 return NULL;
787 if ((vl_data = ospf_vl_lookup (ospf, area, vl_config->vl_peer)) == NULL)
789 vl_data = ospf_vl_data_new (area, vl_config->vl_peer);
790 if (vl_data->vl_oi == NULL)
792 vl_data->vl_oi = ospf_vl_new (ospf, vl_data);
793 ospf_vl_add (ospf, vl_data);
794 ospf_spf_calculate_schedule (ospf);
797 return vl_data;
801 static int
802 ospf_vl_set_security (struct ospf_vl_data *vl_data,
803 struct ospf_vl_config_data *vl_config)
805 struct crypt_key *ck;
806 struct vty *vty;
807 struct interface *ifp = vl_data->vl_oi->ifp;
809 vty = vl_config->vty;
811 if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN)
813 SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type);
814 IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type;
817 if (vl_config->auth_key)
819 memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1);
820 strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key,
821 OSPF_AUTH_SIMPLE_SIZE);
823 else if (vl_config->md5_key)
825 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id)
826 != NULL)
828 vty_out (vty, "OSPF: Key %d already exists%s",
829 vl_config->crypto_key_id, VTY_NEWLINE);
830 return CMD_WARNING;
832 ck = ospf_crypt_key_new ();
833 ck->key_id = vl_config->crypto_key_id;
834 memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
835 strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE);
837 ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck);
839 else if (vl_config->crypto_key_id != 0)
841 /* Delete a key */
843 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt,
844 vl_config->crypto_key_id) == NULL)
846 vty_out (vty, "OSPF: Key %d does not exist%s",
847 vl_config->crypto_key_id, VTY_NEWLINE);
848 return CMD_WARNING;
851 ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id);
855 return CMD_SUCCESS;
858 static int
859 ospf_vl_set_timers (struct ospf_vl_data *vl_data,
860 struct ospf_vl_config_data *vl_config)
862 struct interface *ifp = ifp = vl_data->vl_oi->ifp;
863 /* Virtual Link data initialised to defaults, so only set
864 if a value given */
865 if (vl_config->hello_interval)
867 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello);
868 IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval;
871 if (vl_config->dead_interval)
873 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait);
874 IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval;
877 if (vl_config->retransmit_interval)
879 SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval);
880 IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval;
883 if (vl_config->transmit_delay)
885 SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay);
886 IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay;
889 return CMD_SUCCESS;
894 /* The business end of all of the above */
895 static int
896 ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
898 struct ospf_vl_data *vl_data;
899 int ret;
901 vl_data = ospf_find_vl_data (ospf, vl_config);
902 if (!vl_data)
903 return CMD_WARNING;
905 /* Process this one first as it can have a fatal result, which can
906 only logically occur if the virtual link exists already
907 Thus a command error does not result in a change to the
908 running configuration such as unexpectedly altered timer
909 values etc.*/
910 ret = ospf_vl_set_security (vl_data, vl_config);
911 if (ret != CMD_SUCCESS)
912 return ret;
914 /* Set any time based parameters, these area already range checked */
916 ret = ospf_vl_set_timers (vl_data, vl_config);
917 if (ret != CMD_SUCCESS)
918 return ret;
920 return CMD_SUCCESS;
924 /* This stuff exists to make specifying all the alias commands A LOT simpler
926 #define VLINK_HELPSTR_IPADDR \
927 "OSPF area parameters\n" \
928 "OSPF area ID in IP address format\n" \
929 "OSPF area ID as a decimal value\n" \
930 "Configure a virtual link\n" \
931 "Router ID of the remote ABR\n"
933 #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
934 "Enable authentication on this virtual link\n" \
935 "dummy string \n"
937 #define VLINK_HELPSTR_AUTHTYPE_ALL \
938 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
939 "Use null authentication\n" \
940 "Use message-digest authentication\n"
942 #define VLINK_HELPSTR_TIME_PARAM_NOSECS \
943 "Time between HELLO packets\n" \
944 "Time between retransmitting lost link state advertisements\n" \
945 "Link state transmit delay\n" \
946 "Interval after which a neighbor is declared dead\n"
948 #define VLINK_HELPSTR_TIME_PARAM \
949 VLINK_HELPSTR_TIME_PARAM_NOSECS \
950 "Seconds\n"
952 #define VLINK_HELPSTR_AUTH_SIMPLE \
953 "Authentication password (key)\n" \
954 "The OSPF password (key)"
956 #define VLINK_HELPSTR_AUTH_MD5 \
957 "Message digest authentication password (key)\n" \
958 "dummy string \n" \
959 "Key ID\n" \
960 "Use MD5 algorithm\n" \
961 "The OSPF password (key)"
963 DEFUN (ospf_area_vlink,
964 ospf_area_vlink_cmd,
965 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
966 VLINK_HELPSTR_IPADDR)
968 struct ospf *ospf = vty->index;
969 struct ospf_vl_config_data vl_config;
970 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
971 char md5_key[OSPF_AUTH_MD5_SIZE+1];
972 int i;
973 int ret;
975 ospf_vl_config_data_init(&vl_config, vty);
977 /* Read off first 2 parameters and check them */
978 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format);
979 if (ret < 0)
981 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
982 return CMD_WARNING;
985 ret = inet_aton (argv[1], &vl_config.vl_peer);
986 if (! ret)
988 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
989 VTY_NEWLINE);
990 return CMD_WARNING;
993 if (argc <=2)
995 /* Thats all folks! - BUGS B. strikes again!!!*/
997 return ospf_vl_set (ospf, &vl_config);
1000 /* Deal with other parameters */
1001 for (i=2; i < argc; i++)
1004 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1006 switch (argv[i][0])
1009 case 'a':
1010 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
1012 /* authentication-key - this option can occur anywhere on
1013 command line. At start of command line
1014 must check for authentication option. */
1015 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
1016 strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE);
1017 vl_config.auth_key = auth_key;
1018 i++;
1020 else if (strncmp (argv[i], "authentication", 14) == 0)
1022 /* authentication - this option can only occur at start
1023 of command line */
1024 vl_config.auth_type = OSPF_AUTH_SIMPLE;
1025 if ((i+1) < argc)
1027 if (strncmp (argv[i+1], "n", 1) == 0)
1029 /* "authentication null" */
1030 vl_config.auth_type = OSPF_AUTH_NULL;
1031 i++;
1033 else if (strncmp (argv[i+1], "m", 1) == 0
1034 && strcmp (argv[i+1], "message-digest-") != 0)
1036 /* "authentication message-digest" */
1037 vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
1038 i++;
1042 break;
1044 case 'm':
1045 /* message-digest-key */
1046 i++;
1047 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
1048 if (vl_config.crypto_key_id < 0)
1049 return CMD_WARNING;
1050 i++;
1051 memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1);
1052 strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE);
1053 vl_config.md5_key = md5_key;
1054 break;
1056 case 'h':
1057 /* Hello interval */
1058 i++;
1059 vl_config.hello_interval = strtol (argv[i], NULL, 10);
1060 if (vl_config.hello_interval < 0)
1061 return CMD_WARNING;
1062 break;
1064 case 'r':
1065 /* Retransmit Interval */
1066 i++;
1067 vl_config.retransmit_interval = strtol (argv[i], NULL, 10);
1068 if (vl_config.retransmit_interval < 0)
1069 return CMD_WARNING;
1070 break;
1072 case 't':
1073 /* Transmit Delay */
1074 i++;
1075 vl_config.transmit_delay = strtol (argv[i], NULL, 10);
1076 if (vl_config.transmit_delay < 0)
1077 return CMD_WARNING;
1078 break;
1080 case 'd':
1081 /* Dead Interval */
1082 i++;
1083 vl_config.dead_interval = strtol (argv[i], NULL, 10);
1084 if (vl_config.dead_interval < 0)
1085 return CMD_WARNING;
1086 break;
1091 /* Action configuration */
1093 return ospf_vl_set (ospf, &vl_config);
1097 DEFUN (no_ospf_area_vlink,
1098 no_ospf_area_vlink_cmd,
1099 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
1100 NO_STR
1101 VLINK_HELPSTR_IPADDR)
1103 struct ospf *ospf = vty->index;
1104 struct ospf_area *area;
1105 struct ospf_vl_config_data vl_config;
1106 struct ospf_vl_data *vl_data = NULL;
1107 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
1108 int i;
1109 int ret, format;
1111 ospf_vl_config_data_init(&vl_config, vty);
1113 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format);
1114 if (ret < 0)
1116 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
1117 return CMD_WARNING;
1120 area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id);
1121 if (!area)
1123 vty_out (vty, "Area does not exist%s", VTY_NEWLINE);
1124 return CMD_WARNING;
1127 ret = inet_aton (argv[1], &vl_config.vl_peer);
1128 if (! ret)
1130 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
1131 VTY_NEWLINE);
1132 return CMD_WARNING;
1135 if (argc <=2)
1137 /* Basic VLink no command */
1138 /* Thats all folks! - BUGS B. strikes again!!!*/
1139 if ((vl_data = ospf_vl_lookup (ospf, area, vl_config.vl_peer)))
1140 ospf_vl_delete (ospf, vl_data);
1142 ospf_area_check_free (ospf, vl_config.area_id);
1144 return CMD_SUCCESS;
1147 /* If we are down here, we are reseting parameters */
1149 /* Deal with other parameters */
1150 for (i=2; i < argc; i++)
1152 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1154 switch (argv[i][0])
1157 case 'a':
1158 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
1160 /* authentication-key - this option can occur anywhere on
1161 command line. At start of command line
1162 must check for authentication option. */
1163 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
1164 vl_config.auth_key = auth_key;
1166 else if (strncmp (argv[i], "authentication", 14) == 0)
1168 /* authentication - this option can only occur at start
1169 of command line */
1170 vl_config.auth_type = OSPF_AUTH_NOTSET;
1172 break;
1174 case 'm':
1175 /* message-digest-key */
1176 /* Delete one key */
1177 i++;
1178 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
1179 if (vl_config.crypto_key_id < 0)
1180 return CMD_WARNING;
1181 vl_config.md5_key = NULL;
1182 break;
1184 case 'h':
1185 /* Hello interval */
1186 vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
1187 break;
1189 case 'r':
1190 /* Retransmit Interval */
1191 vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
1192 break;
1194 case 't':
1195 /* Transmit Delay */
1196 vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
1197 break;
1199 case 'd':
1200 /* Dead Interval */
1201 i++;
1202 vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
1203 break;
1208 /* Action configuration */
1210 return ospf_vl_set (ospf, &vl_config);
1213 ALIAS (ospf_area_vlink,
1214 ospf_area_vlink_param1_cmd,
1215 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1216 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1217 VLINK_HELPSTR_IPADDR
1218 VLINK_HELPSTR_TIME_PARAM)
1220 ALIAS (no_ospf_area_vlink,
1221 no_ospf_area_vlink_param1_cmd,
1222 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1223 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1224 NO_STR
1225 VLINK_HELPSTR_IPADDR
1226 VLINK_HELPSTR_TIME_PARAM)
1228 ALIAS (ospf_area_vlink,
1229 ospf_area_vlink_param2_cmd,
1230 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1231 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1232 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1233 VLINK_HELPSTR_IPADDR
1234 VLINK_HELPSTR_TIME_PARAM
1235 VLINK_HELPSTR_TIME_PARAM)
1237 ALIAS (no_ospf_area_vlink,
1238 no_ospf_area_vlink_param2_cmd,
1239 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1240 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1241 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1242 NO_STR
1243 VLINK_HELPSTR_IPADDR
1244 VLINK_HELPSTR_TIME_PARAM
1245 VLINK_HELPSTR_TIME_PARAM)
1247 ALIAS (ospf_area_vlink,
1248 ospf_area_vlink_param3_cmd,
1249 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1250 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1251 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1252 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1253 VLINK_HELPSTR_IPADDR
1254 VLINK_HELPSTR_TIME_PARAM
1255 VLINK_HELPSTR_TIME_PARAM
1256 VLINK_HELPSTR_TIME_PARAM)
1258 ALIAS (no_ospf_area_vlink,
1259 no_ospf_area_vlink_param3_cmd,
1260 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1261 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1262 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1263 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1264 NO_STR
1265 VLINK_HELPSTR_IPADDR
1266 VLINK_HELPSTR_TIME_PARAM
1267 VLINK_HELPSTR_TIME_PARAM
1268 VLINK_HELPSTR_TIME_PARAM)
1270 ALIAS (ospf_area_vlink,
1271 ospf_area_vlink_param4_cmd,
1272 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1273 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1274 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1275 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1276 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1277 VLINK_HELPSTR_IPADDR
1278 VLINK_HELPSTR_TIME_PARAM
1279 VLINK_HELPSTR_TIME_PARAM
1280 VLINK_HELPSTR_TIME_PARAM
1281 VLINK_HELPSTR_TIME_PARAM)
1283 ALIAS (no_ospf_area_vlink,
1284 no_ospf_area_vlink_param4_cmd,
1285 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1286 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1287 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1288 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1289 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1290 NO_STR
1291 VLINK_HELPSTR_IPADDR
1292 VLINK_HELPSTR_TIME_PARAM
1293 VLINK_HELPSTR_TIME_PARAM
1294 VLINK_HELPSTR_TIME_PARAM
1295 VLINK_HELPSTR_TIME_PARAM)
1297 ALIAS (ospf_area_vlink,
1298 ospf_area_vlink_authtype_args_cmd,
1299 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1300 "(authentication|) (message-digest|null)",
1301 VLINK_HELPSTR_IPADDR
1302 VLINK_HELPSTR_AUTHTYPE_ALL)
1304 ALIAS (ospf_area_vlink,
1305 ospf_area_vlink_authtype_cmd,
1306 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1307 "(authentication|)",
1308 VLINK_HELPSTR_IPADDR
1309 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1311 ALIAS (no_ospf_area_vlink,
1312 no_ospf_area_vlink_authtype_cmd,
1313 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1314 "(authentication|)",
1315 NO_STR
1316 VLINK_HELPSTR_IPADDR
1317 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1319 ALIAS (ospf_area_vlink,
1320 ospf_area_vlink_md5_cmd,
1321 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1322 "(message-digest-key|) <1-255> md5 KEY",
1323 VLINK_HELPSTR_IPADDR
1324 VLINK_HELPSTR_AUTH_MD5)
1326 ALIAS (no_ospf_area_vlink,
1327 no_ospf_area_vlink_md5_cmd,
1328 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1329 "(message-digest-key|) <1-255>",
1330 NO_STR
1331 VLINK_HELPSTR_IPADDR
1332 VLINK_HELPSTR_AUTH_MD5)
1334 ALIAS (ospf_area_vlink,
1335 ospf_area_vlink_authkey_cmd,
1336 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1337 "(authentication-key|) AUTH_KEY",
1338 VLINK_HELPSTR_IPADDR
1339 VLINK_HELPSTR_AUTH_SIMPLE)
1341 ALIAS (no_ospf_area_vlink,
1342 no_ospf_area_vlink_authkey_cmd,
1343 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1344 "(authentication-key|)",
1345 NO_STR
1346 VLINK_HELPSTR_IPADDR
1347 VLINK_HELPSTR_AUTH_SIMPLE)
1349 ALIAS (ospf_area_vlink,
1350 ospf_area_vlink_authtype_args_authkey_cmd,
1351 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1352 "(authentication|) (message-digest|null) "
1353 "(authentication-key|) AUTH_KEY",
1354 VLINK_HELPSTR_IPADDR
1355 VLINK_HELPSTR_AUTHTYPE_ALL
1356 VLINK_HELPSTR_AUTH_SIMPLE)
1358 ALIAS (ospf_area_vlink,
1359 ospf_area_vlink_authtype_authkey_cmd,
1360 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1361 "(authentication|) "
1362 "(authentication-key|) AUTH_KEY",
1363 VLINK_HELPSTR_IPADDR
1364 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1365 VLINK_HELPSTR_AUTH_SIMPLE)
1367 ALIAS (no_ospf_area_vlink,
1368 no_ospf_area_vlink_authtype_authkey_cmd,
1369 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1370 "(authentication|) "
1371 "(authentication-key|)",
1372 NO_STR
1373 VLINK_HELPSTR_IPADDR
1374 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1375 VLINK_HELPSTR_AUTH_SIMPLE)
1377 ALIAS (ospf_area_vlink,
1378 ospf_area_vlink_authtype_args_md5_cmd,
1379 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1380 "(authentication|) (message-digest|null) "
1381 "(message-digest-key|) <1-255> md5 KEY",
1382 VLINK_HELPSTR_IPADDR
1383 VLINK_HELPSTR_AUTHTYPE_ALL
1384 VLINK_HELPSTR_AUTH_MD5)
1386 ALIAS (ospf_area_vlink,
1387 ospf_area_vlink_authtype_md5_cmd,
1388 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1389 "(authentication|) "
1390 "(message-digest-key|) <1-255> md5 KEY",
1391 VLINK_HELPSTR_IPADDR
1392 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1393 VLINK_HELPSTR_AUTH_MD5)
1395 ALIAS (no_ospf_area_vlink,
1396 no_ospf_area_vlink_authtype_md5_cmd,
1397 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1398 "(authentication|) "
1399 "(message-digest-key|)",
1400 NO_STR
1401 VLINK_HELPSTR_IPADDR
1402 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1403 VLINK_HELPSTR_AUTH_MD5)
1406 DEFUN (ospf_area_shortcut,
1407 ospf_area_shortcut_cmd,
1408 "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)",
1409 "OSPF area parameters\n"
1410 "OSPF area ID in IP address format\n"
1411 "OSPF area ID as a decimal value\n"
1412 "Configure the area's shortcutting mode\n"
1413 "Set default shortcutting behavior\n"
1414 "Enable shortcutting through the area\n"
1415 "Disable shortcutting through the area\n")
1417 struct ospf *ospf = vty->index;
1418 struct ospf_area *area;
1419 struct in_addr area_id;
1420 int mode;
1421 int format;
1423 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1425 area = ospf_area_get (ospf, area_id, format);
1427 if (strncmp (argv[1], "de", 2) == 0)
1428 mode = OSPF_SHORTCUT_DEFAULT;
1429 else if (strncmp (argv[1], "di", 2) == 0)
1430 mode = OSPF_SHORTCUT_DISABLE;
1431 else if (strncmp (argv[1], "e", 1) == 0)
1432 mode = OSPF_SHORTCUT_ENABLE;
1433 else
1434 return CMD_WARNING;
1436 ospf_area_shortcut_set (ospf, area, mode);
1438 if (ospf->abr_type != OSPF_ABR_SHORTCUT)
1439 vty_out (vty, "Shortcut area setting will take effect "
1440 "only when the router is configured as Shortcut ABR%s",
1441 VTY_NEWLINE);
1443 return CMD_SUCCESS;
1446 DEFUN (no_ospf_area_shortcut,
1447 no_ospf_area_shortcut_cmd,
1448 "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)",
1449 NO_STR
1450 "OSPF area parameters\n"
1451 "OSPF area ID in IP address format\n"
1452 "OSPF area ID as a decimal value\n"
1453 "Deconfigure the area's shortcutting mode\n"
1454 "Deconfigure enabled shortcutting through the area\n"
1455 "Deconfigure disabled shortcutting through the area\n")
1457 struct ospf *ospf = vty->index;
1458 struct ospf_area *area;
1459 struct in_addr area_id;
1460 int format;
1462 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1464 area = ospf_area_lookup_by_area_id (ospf, area_id);
1465 if (!area)
1466 return CMD_SUCCESS;
1468 ospf_area_shortcut_unset (ospf, area);
1470 return CMD_SUCCESS;
1474 DEFUN (ospf_area_stub,
1475 ospf_area_stub_cmd,
1476 "area (A.B.C.D|<0-4294967295>) stub",
1477 "OSPF area parameters\n"
1478 "OSPF area ID in IP address format\n"
1479 "OSPF area ID as a decimal value\n"
1480 "Configure OSPF area as stub\n")
1482 struct ospf *ospf = vty->index;
1483 struct in_addr area_id;
1484 int ret, format;
1486 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1488 ret = ospf_area_stub_set (ospf, area_id);
1489 if (ret == 0)
1491 vty_out (vty, "First deconfigure all virtual link through this area%s",
1492 VTY_NEWLINE);
1493 return CMD_WARNING;
1496 ospf_area_no_summary_unset (ospf, area_id);
1498 return CMD_SUCCESS;
1501 DEFUN (ospf_area_stub_no_summary,
1502 ospf_area_stub_no_summary_cmd,
1503 "area (A.B.C.D|<0-4294967295>) stub no-summary",
1504 "OSPF stub parameters\n"
1505 "OSPF area ID in IP address format\n"
1506 "OSPF area ID as a decimal value\n"
1507 "Configure OSPF area as stub\n"
1508 "Do not inject inter-area routes into stub\n")
1510 struct ospf *ospf = vty->index;
1511 struct in_addr area_id;
1512 int ret, format;
1514 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1516 ret = ospf_area_stub_set (ospf, area_id);
1517 if (ret == 0)
1519 vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s",
1520 VTY_NEWLINE);
1521 return CMD_WARNING;
1524 ospf_area_no_summary_set (ospf, area_id);
1526 return CMD_SUCCESS;
1529 DEFUN (no_ospf_area_stub,
1530 no_ospf_area_stub_cmd,
1531 "no area (A.B.C.D|<0-4294967295>) stub",
1532 NO_STR
1533 "OSPF area parameters\n"
1534 "OSPF area ID in IP address format\n"
1535 "OSPF area ID as a decimal value\n"
1536 "Configure OSPF area as stub\n")
1538 struct ospf *ospf = vty->index;
1539 struct in_addr area_id;
1540 int format;
1542 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1544 ospf_area_stub_unset (ospf, area_id);
1545 ospf_area_no_summary_unset (ospf, area_id);
1547 return CMD_SUCCESS;
1550 DEFUN (no_ospf_area_stub_no_summary,
1551 no_ospf_area_stub_no_summary_cmd,
1552 "no area (A.B.C.D|<0-4294967295>) stub no-summary",
1553 NO_STR
1554 "OSPF area parameters\n"
1555 "OSPF area ID in IP address format\n"
1556 "OSPF area ID as a decimal value\n"
1557 "Configure OSPF area as stub\n"
1558 "Do not inject inter-area routes into area\n")
1560 struct ospf *ospf = vty->index;
1561 struct in_addr area_id;
1562 int format;
1564 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1565 ospf_area_no_summary_unset (ospf, area_id);
1567 return CMD_SUCCESS;
1570 static int
1571 ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[],
1572 int nosum)
1574 struct ospf *ospf = vty->index;
1575 struct in_addr area_id;
1576 int ret, format;
1578 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1580 ret = ospf_area_nssa_set (ospf, area_id);
1581 if (ret == 0)
1583 vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s",
1584 VTY_NEWLINE);
1585 return CMD_WARNING;
1588 if (argc > 1)
1590 if (strncmp (argv[1], "translate-c", 11) == 0)
1591 ospf_area_nssa_translator_role_set (ospf, area_id,
1592 OSPF_NSSA_ROLE_CANDIDATE);
1593 else if (strncmp (argv[1], "translate-n", 11) == 0)
1594 ospf_area_nssa_translator_role_set (ospf, area_id,
1595 OSPF_NSSA_ROLE_NEVER);
1596 else if (strncmp (argv[1], "translate-a", 11) == 0)
1597 ospf_area_nssa_translator_role_set (ospf, area_id,
1598 OSPF_NSSA_ROLE_ALWAYS);
1600 else
1602 ospf_area_nssa_translator_role_set (ospf, area_id,
1603 OSPF_NSSA_ROLE_CANDIDATE);
1606 if (nosum)
1607 ospf_area_no_summary_set (ospf, area_id);
1608 else
1609 ospf_area_no_summary_unset (ospf, area_id);
1611 ospf_schedule_abr_task (ospf);
1613 return CMD_SUCCESS;
1616 DEFUN (ospf_area_nssa_translate_no_summary,
1617 ospf_area_nssa_translate_no_summary_cmd,
1618 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary",
1619 "OSPF area parameters\n"
1620 "OSPF area ID in IP address format\n"
1621 "OSPF area ID as a decimal value\n"
1622 "Configure OSPF area as nssa\n"
1623 "Configure NSSA-ABR for translate election (default)\n"
1624 "Configure NSSA-ABR to never translate\n"
1625 "Configure NSSA-ABR to always translate\n"
1626 "Do not inject inter-area routes into nssa\n")
1628 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
1631 DEFUN (ospf_area_nssa_translate,
1632 ospf_area_nssa_translate_cmd,
1633 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)",
1634 "OSPF area parameters\n"
1635 "OSPF area ID in IP address format\n"
1636 "OSPF area ID as a decimal value\n"
1637 "Configure OSPF area as nssa\n"
1638 "Configure NSSA-ABR for translate election (default)\n"
1639 "Configure NSSA-ABR to never translate\n"
1640 "Configure NSSA-ABR to always translate\n")
1642 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1645 DEFUN (ospf_area_nssa,
1646 ospf_area_nssa_cmd,
1647 "area (A.B.C.D|<0-4294967295>) nssa",
1648 "OSPF area parameters\n"
1649 "OSPF area ID in IP address format\n"
1650 "OSPF area ID as a decimal value\n"
1651 "Configure OSPF area as nssa\n")
1653 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1656 DEFUN (ospf_area_nssa_no_summary,
1657 ospf_area_nssa_no_summary_cmd,
1658 "area (A.B.C.D|<0-4294967295>) nssa no-summary",
1659 "OSPF area parameters\n"
1660 "OSPF area ID in IP address format\n"
1661 "OSPF area ID as a decimal value\n"
1662 "Configure OSPF area as nssa\n"
1663 "Do not inject inter-area routes into nssa\n")
1665 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
1668 DEFUN (no_ospf_area_nssa,
1669 no_ospf_area_nssa_cmd,
1670 "no area (A.B.C.D|<0-4294967295>) nssa",
1671 NO_STR
1672 "OSPF area parameters\n"
1673 "OSPF area ID in IP address format\n"
1674 "OSPF area ID as a decimal value\n"
1675 "Configure OSPF area as nssa\n")
1677 struct ospf *ospf = vty->index;
1678 struct in_addr area_id;
1679 int format;
1681 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1683 ospf_area_nssa_unset (ospf, area_id);
1684 ospf_area_no_summary_unset (ospf, area_id);
1686 ospf_schedule_abr_task (ospf);
1688 return CMD_SUCCESS;
1691 DEFUN (no_ospf_area_nssa_no_summary,
1692 no_ospf_area_nssa_no_summary_cmd,
1693 "no area (A.B.C.D|<0-4294967295>) nssa no-summary",
1694 NO_STR
1695 "OSPF area parameters\n"
1696 "OSPF area ID in IP address format\n"
1697 "OSPF area ID as a decimal value\n"
1698 "Configure OSPF area as nssa\n"
1699 "Do not inject inter-area routes into nssa\n")
1701 struct ospf *ospf = vty->index;
1702 struct in_addr area_id;
1703 int format;
1705 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1706 ospf_area_no_summary_unset (ospf, area_id);
1708 return CMD_SUCCESS;
1711 DEFUN (ospf_area_default_cost,
1712 ospf_area_default_cost_cmd,
1713 "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1714 "OSPF area parameters\n"
1715 "OSPF area ID in IP address format\n"
1716 "OSPF area ID as a decimal value\n"
1717 "Set the summary-default cost of a NSSA or stub area\n"
1718 "Stub's advertised default summary cost\n")
1720 struct ospf *ospf = vty->index;
1721 struct ospf_area *area;
1722 struct in_addr area_id;
1723 u_int32_t cost;
1724 int format;
1725 struct prefix_ipv4 p;
1727 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1728 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1730 area = ospf_area_get (ospf, area_id, format);
1732 if (area->external_routing == OSPF_AREA_DEFAULT)
1734 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1735 return CMD_WARNING;
1738 area->default_cost = cost;
1740 p.family = AF_INET;
1741 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1742 p.prefixlen = 0;
1743 if (IS_DEBUG_OSPF_EVENT)
1744 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1745 "announcing 0.0.0.0/0 to area %s",
1746 inet_ntoa (area->area_id));
1747 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1749 return CMD_SUCCESS;
1752 DEFUN (no_ospf_area_default_cost,
1753 no_ospf_area_default_cost_cmd,
1754 "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1755 NO_STR
1756 "OSPF area parameters\n"
1757 "OSPF area ID in IP address format\n"
1758 "OSPF area ID as a decimal value\n"
1759 "Set the summary-default cost of a NSSA or stub area\n"
1760 "Stub's advertised default summary cost\n")
1762 struct ospf *ospf = vty->index;
1763 struct ospf_area *area;
1764 struct in_addr area_id;
1765 u_int32_t cost;
1766 int format;
1767 struct prefix_ipv4 p;
1769 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1770 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1772 area = ospf_area_lookup_by_area_id (ospf, area_id);
1773 if (area == NULL)
1774 return CMD_SUCCESS;
1776 if (area->external_routing == OSPF_AREA_DEFAULT)
1778 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1779 return CMD_WARNING;
1782 area->default_cost = 1;
1784 p.family = AF_INET;
1785 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1786 p.prefixlen = 0;
1787 if (IS_DEBUG_OSPF_EVENT)
1788 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1789 "announcing 0.0.0.0/0 to area %s",
1790 inet_ntoa (area->area_id));
1791 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1794 ospf_area_check_free (ospf, area_id);
1796 return CMD_SUCCESS;
1799 DEFUN (ospf_area_export_list,
1800 ospf_area_export_list_cmd,
1801 "area (A.B.C.D|<0-4294967295>) export-list NAME",
1802 "OSPF area parameters\n"
1803 "OSPF area ID in IP address format\n"
1804 "OSPF area ID as a decimal value\n"
1805 "Set the filter for networks announced to other areas\n"
1806 "Name of the access-list\n")
1808 struct ospf *ospf = vty->index;
1809 struct ospf_area *area;
1810 struct in_addr area_id;
1811 int format;
1813 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1815 area = ospf_area_get (ospf, area_id, format);
1816 ospf_area_export_list_set (ospf, area, argv[1]);
1818 return CMD_SUCCESS;
1821 DEFUN (no_ospf_area_export_list,
1822 no_ospf_area_export_list_cmd,
1823 "no area (A.B.C.D|<0-4294967295>) export-list NAME",
1824 NO_STR
1825 "OSPF area parameters\n"
1826 "OSPF area ID in IP address format\n"
1827 "OSPF area ID as a decimal value\n"
1828 "Unset the filter for networks announced to other areas\n"
1829 "Name of the access-list\n")
1831 struct ospf *ospf = vty->index;
1832 struct ospf_area *area;
1833 struct in_addr area_id;
1834 int format;
1836 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1838 area = ospf_area_lookup_by_area_id (ospf, area_id);
1839 if (area == NULL)
1840 return CMD_SUCCESS;
1842 ospf_area_export_list_unset (ospf, area);
1844 return CMD_SUCCESS;
1848 DEFUN (ospf_area_import_list,
1849 ospf_area_import_list_cmd,
1850 "area (A.B.C.D|<0-4294967295>) import-list NAME",
1851 "OSPF area parameters\n"
1852 "OSPF area ID in IP address format\n"
1853 "OSPF area ID as a decimal value\n"
1854 "Set the filter for networks from other areas announced to the specified one\n"
1855 "Name of the access-list\n")
1857 struct ospf *ospf = vty->index;
1858 struct ospf_area *area;
1859 struct in_addr area_id;
1860 int format;
1862 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1864 area = ospf_area_get (ospf, area_id, format);
1865 ospf_area_import_list_set (ospf, area, argv[1]);
1867 return CMD_SUCCESS;
1870 DEFUN (no_ospf_area_import_list,
1871 no_ospf_area_import_list_cmd,
1872 "no area (A.B.C.D|<0-4294967295>) import-list NAME",
1873 NO_STR
1874 "OSPF area parameters\n"
1875 "OSPF area ID in IP address format\n"
1876 "OSPF area ID as a decimal value\n"
1877 "Unset the filter for networks announced to other areas\n"
1878 "Name of the access-list\n")
1880 struct ospf *ospf = vty->index;
1881 struct ospf_area *area;
1882 struct in_addr area_id;
1883 int format;
1885 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1887 area = ospf_area_lookup_by_area_id (ospf, area_id);
1888 if (area == NULL)
1889 return CMD_SUCCESS;
1891 ospf_area_import_list_unset (ospf, area);
1893 return CMD_SUCCESS;
1896 DEFUN (ospf_area_filter_list,
1897 ospf_area_filter_list_cmd,
1898 "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1899 "OSPF area parameters\n"
1900 "OSPF area ID in IP address format\n"
1901 "OSPF area ID as a decimal value\n"
1902 "Filter networks between OSPF areas\n"
1903 "Filter prefixes between OSPF areas\n"
1904 "Name of an IP prefix-list\n"
1905 "Filter networks sent to this area\n"
1906 "Filter networks sent from this area\n")
1908 struct ospf *ospf = vty->index;
1909 struct ospf_area *area;
1910 struct in_addr area_id;
1911 struct prefix_list *plist;
1912 int format;
1914 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1916 area = ospf_area_get (ospf, area_id, format);
1917 plist = prefix_list_lookup (AFI_IP, argv[1]);
1918 if (strncmp (argv[2], "in", 2) == 0)
1920 PREFIX_LIST_IN (area) = plist;
1921 if (PREFIX_NAME_IN (area))
1922 free (PREFIX_NAME_IN (area));
1924 PREFIX_NAME_IN (area) = strdup (argv[1]);
1925 ospf_schedule_abr_task (ospf);
1927 else
1929 PREFIX_LIST_OUT (area) = plist;
1930 if (PREFIX_NAME_OUT (area))
1931 free (PREFIX_NAME_OUT (area));
1933 PREFIX_NAME_OUT (area) = strdup (argv[1]);
1934 ospf_schedule_abr_task (ospf);
1937 return CMD_SUCCESS;
1940 DEFUN (no_ospf_area_filter_list,
1941 no_ospf_area_filter_list_cmd,
1942 "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1943 NO_STR
1944 "OSPF area parameters\n"
1945 "OSPF area ID in IP address format\n"
1946 "OSPF area ID as a decimal value\n"
1947 "Filter networks between OSPF areas\n"
1948 "Filter prefixes between OSPF areas\n"
1949 "Name of an IP prefix-list\n"
1950 "Filter networks sent to this area\n"
1951 "Filter networks sent from this area\n")
1953 struct ospf *ospf = vty->index;
1954 struct ospf_area *area;
1955 struct in_addr area_id;
1956 struct prefix_list *plist;
1957 int format;
1959 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1961 if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL)
1962 return CMD_SUCCESS;
1964 plist = prefix_list_lookup (AFI_IP, argv[1]);
1965 if (strncmp (argv[2], "in", 2) == 0)
1967 if (PREFIX_NAME_IN (area))
1968 if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0)
1969 return CMD_SUCCESS;
1971 PREFIX_LIST_IN (area) = NULL;
1972 if (PREFIX_NAME_IN (area))
1973 free (PREFIX_NAME_IN (area));
1975 PREFIX_NAME_IN (area) = NULL;
1977 ospf_schedule_abr_task (ospf);
1979 else
1981 if (PREFIX_NAME_OUT (area))
1982 if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0)
1983 return CMD_SUCCESS;
1985 PREFIX_LIST_OUT (area) = NULL;
1986 if (PREFIX_NAME_OUT (area))
1987 free (PREFIX_NAME_OUT (area));
1989 PREFIX_NAME_OUT (area) = NULL;
1991 ospf_schedule_abr_task (ospf);
1994 return CMD_SUCCESS;
1998 DEFUN (ospf_area_authentication_message_digest,
1999 ospf_area_authentication_message_digest_cmd,
2000 "area (A.B.C.D|<0-4294967295>) authentication message-digest",
2001 "OSPF area parameters\n"
2002 "Enable authentication\n"
2003 "Use message-digest authentication\n")
2005 struct ospf *ospf = vty->index;
2006 struct ospf_area *area;
2007 struct in_addr area_id;
2008 int format;
2010 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2012 area = ospf_area_get (ospf, area_id, format);
2013 area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
2015 return CMD_SUCCESS;
2018 DEFUN (ospf_area_authentication,
2019 ospf_area_authentication_cmd,
2020 "area (A.B.C.D|<0-4294967295>) authentication",
2021 "OSPF area parameters\n"
2022 "OSPF area ID in IP address format\n"
2023 "OSPF area ID as a decimal value\n"
2024 "Enable authentication\n")
2026 struct ospf *ospf = vty->index;
2027 struct ospf_area *area;
2028 struct in_addr area_id;
2029 int format;
2031 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2033 area = ospf_area_get (ospf, area_id, format);
2034 area->auth_type = OSPF_AUTH_SIMPLE;
2036 return CMD_SUCCESS;
2039 DEFUN (no_ospf_area_authentication,
2040 no_ospf_area_authentication_cmd,
2041 "no area (A.B.C.D|<0-4294967295>) authentication",
2042 NO_STR
2043 "OSPF area parameters\n"
2044 "OSPF area ID in IP address format\n"
2045 "OSPF area ID as a decimal value\n"
2046 "Enable authentication\n")
2048 struct ospf *ospf = vty->index;
2049 struct ospf_area *area;
2050 struct in_addr area_id;
2051 int format;
2053 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2055 area = ospf_area_lookup_by_area_id (ospf, area_id);
2056 if (area == NULL)
2057 return CMD_SUCCESS;
2059 area->auth_type = OSPF_AUTH_NULL;
2061 ospf_area_check_free (ospf, area_id);
2063 return CMD_SUCCESS;
2067 DEFUN (ospf_abr_type,
2068 ospf_abr_type_cmd,
2069 "ospf abr-type (cisco|ibm|shortcut|standard)",
2070 "OSPF specific commands\n"
2071 "Set OSPF ABR type\n"
2072 "Alternative ABR, cisco implementation\n"
2073 "Alternative ABR, IBM implementation\n"
2074 "Shortcut ABR\n"
2075 "Standard behavior (RFC2328)\n")
2077 struct ospf *ospf = vty->index;
2078 u_char abr_type = OSPF_ABR_UNKNOWN;
2080 if (strncmp (argv[0], "c", 1) == 0)
2081 abr_type = OSPF_ABR_CISCO;
2082 else if (strncmp (argv[0], "i", 1) == 0)
2083 abr_type = OSPF_ABR_IBM;
2084 else if (strncmp (argv[0], "sh", 2) == 0)
2085 abr_type = OSPF_ABR_SHORTCUT;
2086 else if (strncmp (argv[0], "st", 2) == 0)
2087 abr_type = OSPF_ABR_STAND;
2088 else
2089 return CMD_WARNING;
2091 /* If ABR type value is changed, schedule ABR task. */
2092 if (ospf->abr_type != abr_type)
2094 ospf->abr_type = abr_type;
2095 ospf_schedule_abr_task (ospf);
2098 return CMD_SUCCESS;
2101 DEFUN (no_ospf_abr_type,
2102 no_ospf_abr_type_cmd,
2103 "no ospf abr-type (cisco|ibm|shortcut|standard)",
2104 NO_STR
2105 "OSPF specific commands\n"
2106 "Set OSPF ABR type\n"
2107 "Alternative ABR, cisco implementation\n"
2108 "Alternative ABR, IBM implementation\n"
2109 "Shortcut ABR\n")
2111 struct ospf *ospf = vty->index;
2112 u_char abr_type = OSPF_ABR_UNKNOWN;
2114 if (strncmp (argv[0], "c", 1) == 0)
2115 abr_type = OSPF_ABR_CISCO;
2116 else if (strncmp (argv[0], "i", 1) == 0)
2117 abr_type = OSPF_ABR_IBM;
2118 else if (strncmp (argv[0], "sh", 2) == 0)
2119 abr_type = OSPF_ABR_SHORTCUT;
2120 else if (strncmp (argv[0], "st", 2) == 0)
2121 abr_type = OSPF_ABR_STAND;
2122 else
2123 return CMD_WARNING;
2125 /* If ABR type value is changed, schedule ABR task. */
2126 if (ospf->abr_type == abr_type)
2128 ospf->abr_type = OSPF_ABR_DEFAULT;
2129 ospf_schedule_abr_task (ospf);
2132 return CMD_SUCCESS;
2135 DEFUN (ospf_log_adjacency_changes,
2136 ospf_log_adjacency_changes_cmd,
2137 "log-adjacency-changes",
2138 "Log changes in adjacency state\n")
2140 struct ospf *ospf = vty->index;
2142 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2143 return CMD_SUCCESS;
2146 DEFUN (ospf_log_adjacency_changes_detail,
2147 ospf_log_adjacency_changes_detail_cmd,
2148 "log-adjacency-changes detail",
2149 "Log changes in adjacency state\n"
2150 "Log all state changes\n")
2152 struct ospf *ospf = vty->index;
2154 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2155 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2156 return CMD_SUCCESS;
2159 DEFUN (no_ospf_log_adjacency_changes,
2160 no_ospf_log_adjacency_changes_cmd,
2161 "no log-adjacency-changes",
2162 NO_STR
2163 "Log changes in adjacency state\n")
2165 struct ospf *ospf = vty->index;
2167 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2168 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2169 return CMD_SUCCESS;
2172 DEFUN (no_ospf_log_adjacency_changes_detail,
2173 no_ospf_log_adjacency_changes_detail_cmd,
2174 "no log-adjacency-changes detail",
2175 NO_STR
2176 "Log changes in adjacency state\n"
2177 "Log all state changes\n")
2179 struct ospf *ospf = vty->index;
2181 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2182 return CMD_SUCCESS;
2185 DEFUN (ospf_compatible_rfc1583,
2186 ospf_compatible_rfc1583_cmd,
2187 "compatible rfc1583",
2188 "OSPF compatibility list\n"
2189 "compatible with RFC 1583\n")
2191 struct ospf *ospf = vty->index;
2193 if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2195 SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
2196 ospf_spf_calculate_schedule (ospf);
2198 return CMD_SUCCESS;
2201 DEFUN (no_ospf_compatible_rfc1583,
2202 no_ospf_compatible_rfc1583_cmd,
2203 "no compatible rfc1583",
2204 NO_STR
2205 "OSPF compatibility list\n"
2206 "compatible with RFC 1583\n")
2208 struct ospf *ospf = vty->index;
2210 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2212 UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
2213 ospf_spf_calculate_schedule (ospf);
2215 return CMD_SUCCESS;
2218 ALIAS (ospf_compatible_rfc1583,
2219 ospf_rfc1583_flag_cmd,
2220 "ospf rfc1583compatibility",
2221 "OSPF specific commands\n"
2222 "Enable the RFC1583Compatibility flag\n")
2224 ALIAS (no_ospf_compatible_rfc1583,
2225 no_ospf_rfc1583_flag_cmd,
2226 "no ospf rfc1583compatibility",
2227 NO_STR
2228 "OSPF specific commands\n"
2229 "Disable the RFC1583Compatibility flag\n")
2231 static int
2232 ospf_timers_spf_set (struct vty *vty, unsigned int delay,
2233 unsigned int hold,
2234 unsigned int max)
2236 struct ospf *ospf = vty->index;
2238 ospf->spf_delay = delay;
2239 ospf->spf_holdtime = hold;
2240 ospf->spf_max_holdtime = max;
2242 return CMD_SUCCESS;
2245 DEFUN (ospf_timers_throttle_spf,
2246 ospf_timers_throttle_spf_cmd,
2247 "timers throttle spf <0-600000> <0-600000> <0-600000>",
2248 "Adjust routing timers\n"
2249 "Throttling adaptive timer\n"
2250 "OSPF SPF timers\n"
2251 "Delay (msec) from first change received till SPF calculation\n"
2252 "Initial hold time (msec) between consecutive SPF calculations\n"
2253 "Maximum hold time (msec)\n")
2255 unsigned int delay, hold, max;
2257 if (argc != 3)
2259 vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
2260 return CMD_WARNING;
2263 VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000);
2264 VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000);
2265 VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000);
2267 return ospf_timers_spf_set (vty, delay, hold, max);
2270 DEFUN_DEPRECATED (ospf_timers_spf,
2271 ospf_timers_spf_cmd,
2272 "timers spf <0-4294967295> <0-4294967295>",
2273 "Adjust routing timers\n"
2274 "OSPF SPF timers\n"
2275 "Delay (s) between receiving a change to SPF calculation\n"
2276 "Hold time (s) between consecutive SPF calculations\n")
2278 unsigned int delay, hold;
2280 if (argc != 2)
2282 vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE);
2283 return CMD_WARNING;
2286 VTY_GET_INTEGER ("SPF delay timer", delay, argv[0]);
2287 VTY_GET_INTEGER ("SPF hold timer", hold, argv[1]);
2289 /* truncate down the second values if they're greater than 600000ms */
2290 if (delay > (600000 / 1000))
2291 delay = 600000;
2292 else if (delay == 0)
2293 /* 0s delay was probably specified because of lack of ms resolution */
2294 delay = OSPF_SPF_DELAY_DEFAULT;
2295 if (hold > (600000 / 1000))
2296 hold = 600000;
2298 return ospf_timers_spf_set (vty, delay * 1000, hold * 1000, hold * 1000);
2301 DEFUN (no_ospf_timers_throttle_spf,
2302 no_ospf_timers_throttle_spf_cmd,
2303 "no timers throttle spf",
2304 NO_STR
2305 "Adjust routing timers\n"
2306 "Throttling adaptive timer\n"
2307 "OSPF SPF timers\n")
2309 return ospf_timers_spf_set (vty,
2310 OSPF_SPF_DELAY_DEFAULT,
2311 OSPF_SPF_HOLDTIME_DEFAULT,
2312 OSPF_SPF_MAX_HOLDTIME_DEFAULT);
2315 ALIAS_DEPRECATED (no_ospf_timers_throttle_spf,
2316 no_ospf_timers_spf_cmd,
2317 "no timers spf",
2318 NO_STR
2319 "Adjust routing timers\n"
2320 "OSPF SPF timers\n")
2322 DEFUN (ospf_neighbor,
2323 ospf_neighbor_cmd,
2324 "neighbor A.B.C.D",
2325 NEIGHBOR_STR
2326 "Neighbor IP address\n")
2328 struct ospf *ospf = vty->index;
2329 struct in_addr nbr_addr;
2330 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2331 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
2333 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2335 if (argc > 1)
2336 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255);
2338 if (argc > 2)
2339 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535);
2341 ospf_nbr_nbma_set (ospf, nbr_addr);
2342 if (argc > 1)
2343 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2344 if (argc > 2)
2345 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, priority);
2347 return CMD_SUCCESS;
2350 ALIAS (ospf_neighbor,
2351 ospf_neighbor_priority_poll_interval_cmd,
2352 "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2353 NEIGHBOR_STR
2354 "Neighbor IP address\n"
2355 "Neighbor Priority\n"
2356 "Priority\n"
2357 "Dead Neighbor Polling interval\n"
2358 "Seconds\n")
2360 ALIAS (ospf_neighbor,
2361 ospf_neighbor_priority_cmd,
2362 "neighbor A.B.C.D priority <0-255>",
2363 NEIGHBOR_STR
2364 "Neighbor IP address\n"
2365 "Neighbor Priority\n"
2366 "Seconds\n")
2368 DEFUN (ospf_neighbor_poll_interval,
2369 ospf_neighbor_poll_interval_cmd,
2370 "neighbor A.B.C.D poll-interval <1-65535>",
2371 NEIGHBOR_STR
2372 "Neighbor IP address\n"
2373 "Dead Neighbor Polling interval\n"
2374 "Seconds\n")
2376 struct ospf *ospf = vty->index;
2377 struct in_addr nbr_addr;
2378 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2379 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
2381 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2383 if (argc > 1)
2384 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535);
2386 if (argc > 2)
2387 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255);
2389 ospf_nbr_nbma_set (ospf, nbr_addr);
2390 if (argc > 1)
2391 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
2392 if (argc > 2)
2393 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2395 return CMD_SUCCESS;
2398 ALIAS (ospf_neighbor_poll_interval,
2399 ospf_neighbor_poll_interval_priority_cmd,
2400 "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2401 NEIGHBOR_STR
2402 "Neighbor address\n"
2403 "OSPF dead-router polling interval\n"
2404 "Seconds\n"
2405 "OSPF priority of non-broadcast neighbor\n"
2406 "Priority\n")
2408 DEFUN (no_ospf_neighbor,
2409 no_ospf_neighbor_cmd,
2410 "no neighbor A.B.C.D",
2411 NO_STR
2412 NEIGHBOR_STR
2413 "Neighbor IP address\n")
2415 struct ospf *ospf = vty->index;
2416 struct in_addr nbr_addr;
2417 int ret;
2419 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2421 ret = ospf_nbr_nbma_unset (ospf, nbr_addr);
2423 return CMD_SUCCESS;
2426 ALIAS (no_ospf_neighbor,
2427 no_ospf_neighbor_priority_cmd,
2428 "no neighbor A.B.C.D priority <0-255>",
2429 NO_STR
2430 NEIGHBOR_STR
2431 "Neighbor IP address\n"
2432 "Neighbor Priority\n"
2433 "Priority\n")
2435 ALIAS (no_ospf_neighbor,
2436 no_ospf_neighbor_poll_interval_cmd,
2437 "no neighbor A.B.C.D poll-interval <1-65535>",
2438 NO_STR
2439 NEIGHBOR_STR
2440 "Neighbor IP address\n"
2441 "Dead Neighbor Polling interval\n"
2442 "Seconds\n")
2444 ALIAS (no_ospf_neighbor,
2445 no_ospf_neighbor_priority_pollinterval_cmd,
2446 "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2447 NO_STR
2448 NEIGHBOR_STR
2449 "Neighbor IP address\n"
2450 "Neighbor Priority\n"
2451 "Priority\n"
2452 "Dead Neighbor Polling interval\n"
2453 "Seconds\n")
2456 DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd,
2457 "refresh timer <10-1800>",
2458 "Adjust refresh parameters\n"
2459 "Set refresh timer\n"
2460 "Timer value in seconds\n")
2462 struct ospf *ospf = vty->index;
2463 unsigned int interval;
2465 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2466 interval = (interval / 10) * 10;
2468 ospf_timers_refresh_set (ospf, interval);
2470 return CMD_SUCCESS;
2473 DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd,
2474 "no refresh timer <10-1800>",
2475 "Adjust refresh parameters\n"
2476 "Unset refresh timer\n"
2477 "Timer value in seconds\n")
2479 struct ospf *ospf = vty->index;
2480 unsigned int interval;
2482 if (argc == 1)
2484 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2486 if (ospf->lsa_refresh_interval != interval ||
2487 interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
2488 return CMD_SUCCESS;
2491 ospf_timers_refresh_unset (ospf);
2493 return CMD_SUCCESS;
2496 ALIAS (no_ospf_refresh_timer,
2497 no_ospf_refresh_timer_cmd,
2498 "no refresh timer",
2499 "Adjust refresh parameters\n"
2500 "Unset refresh timer\n")
2502 DEFUN (ospf_auto_cost_reference_bandwidth,
2503 ospf_auto_cost_reference_bandwidth_cmd,
2504 "auto-cost reference-bandwidth <1-4294967>",
2505 "Calculate OSPF interface cost according to bandwidth\n"
2506 "Use reference bandwidth method to assign OSPF cost\n"
2507 "The reference bandwidth in terms of Mbits per second\n")
2509 struct ospf *ospf = vty->index;
2510 u_int32_t refbw;
2511 struct listnode *node;
2512 struct interface *ifp;
2514 refbw = strtol (argv[0], NULL, 10);
2515 if (refbw < 1 || refbw > 4294967)
2517 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
2518 return CMD_WARNING;
2521 /* If reference bandwidth is changed. */
2522 if ((refbw * 1000) == ospf->ref_bandwidth)
2523 return CMD_SUCCESS;
2525 ospf->ref_bandwidth = refbw * 1000;
2526 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
2527 ospf_if_recalculate_output_cost (ifp);
2529 return CMD_SUCCESS;
2532 DEFUN (no_ospf_auto_cost_reference_bandwidth,
2533 no_ospf_auto_cost_reference_bandwidth_cmd,
2534 "no auto-cost reference-bandwidth",
2535 NO_STR
2536 "Calculate OSPF interface cost according to bandwidth\n"
2537 "Use reference bandwidth method to assign OSPF cost\n")
2539 struct ospf *ospf = vty->index;
2540 struct listnode *node, *nnode;
2541 struct interface *ifp;
2543 if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
2544 return CMD_SUCCESS;
2546 ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
2547 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2548 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2550 for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp))
2551 ospf_if_recalculate_output_cost (ifp);
2553 return CMD_SUCCESS;
2556 const char *ospf_abr_type_descr_str[] =
2558 "Unknown",
2559 "Standard (RFC2328)",
2560 "Alternative IBM",
2561 "Alternative Cisco",
2562 "Alternative Shortcut"
2565 const char *ospf_shortcut_mode_descr_str[] =
2567 "Default",
2568 "Enabled",
2569 "Disabled"
2574 static void
2575 show_ip_ospf_area (struct vty *vty, struct ospf_area *area)
2577 /* Show Area ID. */
2578 vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id));
2580 /* Show Area type/mode. */
2581 if (OSPF_IS_AREA_BACKBONE (area))
2582 vty_out (vty, " (Backbone)%s", VTY_NEWLINE);
2583 else
2585 if (area->external_routing == OSPF_AREA_STUB)
2586 vty_out (vty, " (Stub%s%s)",
2587 area->no_summary ? ", no summary" : "",
2588 area->shortcut_configured ? "; " : "");
2590 else if (area->external_routing == OSPF_AREA_NSSA)
2591 vty_out (vty, " (NSSA%s%s)",
2592 area->no_summary ? ", no summary" : "",
2593 area->shortcut_configured ? "; " : "");
2595 vty_out (vty, "%s", VTY_NEWLINE);
2596 vty_out (vty, " Shortcutting mode: %s",
2597 ospf_shortcut_mode_descr_str[area->shortcut_configured]);
2598 vty_out (vty, ", S-bit consensus: %s%s",
2599 area->shortcut_capability ? "ok" : "no", VTY_NEWLINE);
2602 /* Show number of interfaces. */
2603 vty_out (vty, " Number of interfaces in this area: Total: %d, "
2604 "Active: %d%s", listcount (area->oiflist),
2605 area->act_ints, VTY_NEWLINE);
2607 if (area->external_routing == OSPF_AREA_NSSA)
2609 vty_out (vty, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE, VTY_NEWLINE);
2610 if (! IS_OSPF_ABR (area->ospf))
2611 vty_out (vty, " It is not ABR, therefore not Translator. %s",
2612 VTY_NEWLINE);
2613 else if (area->NSSATranslatorState)
2615 vty_out (vty, " We are an ABR and ");
2616 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2617 vty_out (vty, "the NSSA Elected Translator. %s",
2618 VTY_NEWLINE);
2619 else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS)
2620 vty_out (vty, "always an NSSA Translator. %s",
2621 VTY_NEWLINE);
2623 else
2625 vty_out (vty, " We are an ABR, but ");
2626 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2627 vty_out (vty, "not the NSSA Elected Translator. %s",
2628 VTY_NEWLINE);
2629 else
2630 vty_out (vty, "never an NSSA Translator. %s",
2631 VTY_NEWLINE);
2634 /* Stub-router state for this area */
2635 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
2637 char timebuf[OSPF_TIME_DUMP_SIZE];
2638 vty_out (vty, " Originating stub / maximum-distance Router-LSA%s",
2639 VTY_NEWLINE);
2640 if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
2641 vty_out (vty, " Administratively activated (indefinitely)%s",
2642 VTY_NEWLINE);
2643 if (area->t_stub_router)
2644 vty_out (vty, " Active from startup, %s remaining%s",
2645 ospf_timer_dump (area->t_stub_router, timebuf,
2646 sizeof(timebuf)), VTY_NEWLINE);
2649 /* Show number of fully adjacent neighbors. */
2650 vty_out (vty, " Number of fully adjacent neighbors in this area:"
2651 " %d%s", area->full_nbrs, VTY_NEWLINE);
2653 /* Show authentication type. */
2654 vty_out (vty, " Area has ");
2655 if (area->auth_type == OSPF_AUTH_NULL)
2656 vty_out (vty, "no authentication%s", VTY_NEWLINE);
2657 else if (area->auth_type == OSPF_AUTH_SIMPLE)
2658 vty_out (vty, "simple password authentication%s", VTY_NEWLINE);
2659 else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC)
2660 vty_out (vty, "message digest authentication%s", VTY_NEWLINE);
2662 if (!OSPF_IS_AREA_BACKBONE (area))
2663 vty_out (vty, " Number of full virtual adjacencies going through"
2664 " this area: %d%s", area->full_vls, VTY_NEWLINE);
2666 /* Show SPF calculation times. */
2667 vty_out (vty, " SPF algorithm executed %d times%s",
2668 area->spf_calculation, VTY_NEWLINE);
2670 /* Show number of LSA. */
2671 vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE);
2672 vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
2673 ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA),
2674 ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE);
2675 vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
2676 ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA),
2677 ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE);
2678 vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
2679 ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA),
2680 ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE);
2681 vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
2682 ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA),
2683 ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE);
2684 vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
2685 ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA),
2686 ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE);
2687 #ifdef HAVE_OPAQUE_LSA
2688 vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
2689 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA),
2690 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE);
2691 vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
2692 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA),
2693 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE);
2694 #endif /* HAVE_OPAQUE_LSA */
2695 vty_out (vty, "%s", VTY_NEWLINE);
2698 DEFUN (show_ip_ospf,
2699 show_ip_ospf_cmd,
2700 "show ip ospf",
2701 SHOW_STR
2702 IP_STR
2703 "OSPF information\n")
2705 struct listnode *node, *nnode;
2706 struct ospf_area * area;
2707 struct ospf *ospf;
2708 struct timeval result;
2709 char timebuf[OSPF_TIME_DUMP_SIZE];
2711 /* Check OSPF is enable. */
2712 ospf = ospf_lookup ();
2713 if (ospf == NULL)
2715 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2716 return CMD_SUCCESS;
2719 /* Show Router ID. */
2720 vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
2721 inet_ntoa (ospf->router_id),
2722 VTY_NEWLINE);
2724 /* Graceful shutdown */
2725 if (ospf->t_deferred_shutdown)
2726 vty_out (vty, " Deferred shutdown in progress, %s remaining%s",
2727 ospf_timer_dump (ospf->t_deferred_shutdown,
2728 timebuf, sizeof (timebuf)), VTY_NEWLINE);
2729 /* Show capability. */
2730 vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
2731 vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
2732 vty_out (vty, " RFC1583Compatibility flag is %s%s",
2733 CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ?
2734 "enabled" : "disabled", VTY_NEWLINE);
2735 #ifdef HAVE_OPAQUE_LSA
2736 vty_out (vty, " OpaqueCapability flag is %s%s%s",
2737 CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ?
2738 "enabled" : "disabled",
2739 IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ?
2740 " (origination blocked)" : "",
2741 VTY_NEWLINE);
2742 #endif /* HAVE_OPAQUE_LSA */
2744 /* Show stub-router configuration */
2745 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED
2746 || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2748 vty_out (vty, " Stub router advertisement is configured%s",
2749 VTY_NEWLINE);
2750 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2751 vty_out (vty, " Enabled for %us after start-up%s",
2752 ospf->stub_router_startup_time, VTY_NEWLINE);
2753 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2754 vty_out (vty, " Enabled for %us prior to full shutdown%s",
2755 ospf->stub_router_shutdown_time, VTY_NEWLINE);
2758 /* Show SPF timers. */
2759 vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s"
2760 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
2761 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
2762 " Hold time multiplier is currently %d%s",
2763 ospf->spf_delay, VTY_NEWLINE,
2764 ospf->spf_holdtime, VTY_NEWLINE,
2765 ospf->spf_max_holdtime, VTY_NEWLINE,
2766 ospf->spf_hold_multiplier, VTY_NEWLINE);
2767 vty_out (vty, " SPF algorithm ");
2768 if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec)
2770 result = tv_sub (recent_relative_time (), ospf->ts_spf);
2771 vty_out (vty, "last executed %s ago%s",
2772 ospf_timeval_dump (&result, timebuf, sizeof (timebuf)),
2773 VTY_NEWLINE);
2775 else
2776 vty_out (vty, "has not been run%s", VTY_NEWLINE);
2777 vty_out (vty, " SPF timer %s%s%s",
2778 (ospf->t_spf_calc ? "due in " : "is "),
2779 ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)),
2780 VTY_NEWLINE);
2782 /* Show refresh parameters. */
2783 vty_out (vty, " Refresh timer %d secs%s",
2784 ospf->lsa_refresh_interval, VTY_NEWLINE);
2786 /* Show ABR/ASBR flags. */
2787 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
2788 vty_out (vty, " This router is an ABR, ABR type is: %s%s",
2789 ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE);
2791 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
2792 vty_out (vty, " This router is an ASBR "
2793 "(injecting external routing information)%s", VTY_NEWLINE);
2795 /* Show Number of AS-external-LSAs. */
2796 vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
2797 ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA),
2798 ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE);
2799 #ifdef HAVE_OPAQUE_LSA
2800 vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
2801 ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA),
2802 ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE);
2803 #endif /* HAVE_OPAQUE_LSA */
2804 /* Show number of areas attached. */
2805 vty_out (vty, " Number of areas attached to this router: %d%s",
2806 listcount (ospf->areas), VTY_NEWLINE);
2808 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
2810 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
2811 vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE);
2812 else
2813 vty_out(vty, " Adjacency changes are logged%s",VTY_NEWLINE);
2816 vty_out (vty, "%s",VTY_NEWLINE);
2818 /* Show each area status. */
2819 for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
2820 show_ip_ospf_area (vty, area);
2822 return CMD_SUCCESS;
2826 static void
2827 show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
2828 struct interface *ifp)
2830 int is_up;
2831 struct ospf_neighbor *nbr;
2832 struct route_node *rn;
2834 /* Is interface up? */
2835 vty_out (vty, "%s is %s%s", ifp->name,
2836 ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE);
2837 vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s",
2838 ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags),
2839 VTY_NEWLINE);
2841 /* Is interface OSPF enabled? */
2842 if (ospf_oi_count(ifp) == 0)
2844 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2845 return;
2847 else if (!is_up)
2849 vty_out (vty, " OSPF is enabled, but not running on this interface%s",
2850 VTY_NEWLINE);
2851 return;
2854 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
2856 struct ospf_interface *oi = rn->info;
2858 if (oi == NULL)
2859 continue;
2861 /* Show OSPF interface information. */
2862 vty_out (vty, " Internet Address %s/%d,",
2863 inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
2865 if (oi->connected->destination || oi->type == OSPF_IFTYPE_VIRTUALLINK)
2867 struct in_addr *dest;
2868 const char *dstr;
2870 if (CONNECTED_PEER(oi->connected)
2871 || oi->type == OSPF_IFTYPE_VIRTUALLINK)
2872 dstr = "Peer";
2873 else
2874 dstr = "Broadcast";
2876 /* For Vlinks, showing the peer address is probably more
2877 * informative than the local interface that is being used
2879 if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
2880 dest = &oi->vl_data->peer_addr;
2881 else
2882 dest = &oi->connected->destination->u.prefix4;
2884 vty_out (vty, " %s %s,", dstr, inet_ntoa (*dest));
2887 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
2888 VTY_NEWLINE);
2890 vty_out (vty, " MTU mismatch detection:%s%s",
2891 OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE);
2893 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
2894 inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
2895 oi->output_cost, VTY_NEWLINE);
2897 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
2898 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
2899 PRIORITY (oi), VTY_NEWLINE);
2901 /* Show DR information. */
2902 if (DR (oi).s_addr == 0)
2903 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2904 else
2906 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
2907 if (nbr == NULL)
2908 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2909 else
2911 vty_out (vty, " Designated Router (ID) %s,",
2912 inet_ntoa (nbr->router_id));
2913 vty_out (vty, " Interface Address %s%s",
2914 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2918 /* Show BDR information. */
2919 if (BDR (oi).s_addr == 0)
2920 vty_out (vty, " No backup designated router on this network%s",
2921 VTY_NEWLINE);
2922 else
2924 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
2925 if (nbr == NULL)
2926 vty_out (vty, " No backup designated router on this network%s",
2927 VTY_NEWLINE);
2928 else
2930 vty_out (vty, " Backup Designated Router (ID) %s,",
2931 inet_ntoa (nbr->router_id));
2932 vty_out (vty, " Interface Address %s%s",
2933 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2937 vty_out (vty, " Multicast group memberships:");
2938 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)
2939 || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
2941 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS))
2942 vty_out (vty, " OSPFAllRouters");
2943 if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
2944 vty_out (vty, " OSPFDesignatedRouters");
2946 else
2947 vty_out (vty, " <None>");
2948 vty_out (vty, "%s", VTY_NEWLINE);
2950 vty_out (vty, " Timer intervals configured,");
2951 vty_out (vty, " Hello ");
2952 if (OSPF_IF_PARAM (oi, fast_hello) == 0)
2953 vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello));
2954 else
2955 vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello));
2956 vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s",
2957 OSPF_IF_PARAM (oi, v_wait),
2958 OSPF_IF_PARAM (oi, v_wait),
2959 OSPF_IF_PARAM (oi, retransmit_interval),
2960 VTY_NEWLINE);
2962 if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_ACTIVE)
2964 char timebuf[OSPF_TIME_DUMP_SIZE];
2965 vty_out (vty, " Hello due in %s%s",
2966 ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)),
2967 VTY_NEWLINE);
2969 else /* passive-interface is set */
2970 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
2972 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
2973 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
2974 VTY_NEWLINE);
2978 DEFUN (show_ip_ospf_interface,
2979 show_ip_ospf_interface_cmd,
2980 "show ip ospf interface [INTERFACE]",
2981 SHOW_STR
2982 IP_STR
2983 "OSPF information\n"
2984 "Interface information\n"
2985 "Interface name\n")
2987 struct interface *ifp;
2988 struct ospf *ospf;
2989 struct listnode *node;
2991 ospf = ospf_lookup ();
2992 if (ospf == NULL)
2994 vty_out (vty, "OSPF Routing Process not enabled%s", VTY_NEWLINE);
2995 return CMD_SUCCESS;
2998 /* Show All Interfaces. */
2999 if (argc == 0)
3000 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
3001 show_ip_ospf_interface_sub (vty, ospf, ifp);
3002 /* Interface name is specified. */
3003 else
3005 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
3006 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
3007 else
3008 show_ip_ospf_interface_sub (vty, ospf, ifp);
3011 return CMD_SUCCESS;
3014 static void
3015 show_ip_ospf_neighbour_header (struct vty *vty)
3017 vty_out (vty, "%s%15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
3018 VTY_NEWLINE,
3019 "Neighbor ID", "Pri", "State", "Dead Time",
3020 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
3021 VTY_NEWLINE);
3024 static void
3025 show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
3027 struct route_node *rn;
3028 struct ospf_neighbor *nbr;
3029 char msgbuf[16];
3030 char timebuf[OSPF_TIME_DUMP_SIZE];
3032 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3033 if ((nbr = rn->info))
3034 /* Do not show myself. */
3035 if (nbr != oi->nbr_self)
3036 /* Down state is not shown. */
3037 if (nbr->state != NSM_Down)
3039 ospf_nbr_state_message (nbr, msgbuf, 16);
3041 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
3042 vty_out (vty, "%-15s %3d %-15s ",
3043 "-", nbr->priority,
3044 msgbuf);
3045 else
3046 vty_out (vty, "%-15s %3d %-15s ",
3047 inet_ntoa (nbr->router_id), nbr->priority,
3048 msgbuf);
3050 vty_out (vty, "%9s ",
3051 ospf_timer_dump (nbr->t_inactivity, timebuf,
3052 sizeof(timebuf)));
3054 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
3055 vty_out (vty, "%-20s %5ld %5ld %5d%s",
3056 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
3057 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
3058 VTY_NEWLINE);
3062 DEFUN (show_ip_ospf_neighbor,
3063 show_ip_ospf_neighbor_cmd,
3064 "show ip ospf neighbor",
3065 SHOW_STR
3066 IP_STR
3067 "OSPF information\n"
3068 "Neighbor list\n")
3070 struct ospf *ospf;
3071 struct ospf_interface *oi;
3072 struct listnode *node;
3074 ospf = ospf_lookup ();
3075 if (ospf == NULL)
3077 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3078 return CMD_SUCCESS;
3081 show_ip_ospf_neighbour_header (vty);
3083 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3084 show_ip_ospf_neighbor_sub (vty, oi);
3086 return CMD_SUCCESS;
3089 DEFUN (show_ip_ospf_neighbor_all,
3090 show_ip_ospf_neighbor_all_cmd,
3091 "show ip ospf neighbor all",
3092 SHOW_STR
3093 IP_STR
3094 "OSPF information\n"
3095 "Neighbor list\n"
3096 "include down status neighbor\n")
3098 struct ospf *ospf = ospf_lookup ();
3099 struct listnode *node;
3100 struct ospf_interface *oi;
3102 if (ospf == NULL)
3104 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3105 return CMD_SUCCESS;
3108 show_ip_ospf_neighbour_header (vty);
3110 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3112 struct listnode *nbr_node;
3113 struct ospf_nbr_nbma *nbr_nbma;
3115 show_ip_ospf_neighbor_sub (vty, oi);
3117 /* print Down neighbor status */
3118 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma))
3120 if (nbr_nbma->nbr == NULL
3121 || nbr_nbma->nbr->state == NSM_Down)
3123 vty_out (vty, "%-15s %3d %-15s %9s ",
3124 "-", nbr_nbma->priority, "Down", "-");
3125 vty_out (vty, "%-15s %-20s %5d %5d %5d%s",
3126 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
3127 0, 0, 0, VTY_NEWLINE);
3132 return CMD_SUCCESS;
3135 DEFUN (show_ip_ospf_neighbor_int,
3136 show_ip_ospf_neighbor_int_cmd,
3137 "show ip ospf neighbor IFNAME",
3138 SHOW_STR
3139 IP_STR
3140 "OSPF information\n"
3141 "Neighbor list\n"
3142 "Interface name\n")
3144 struct ospf *ospf;
3145 struct interface *ifp;
3146 struct route_node *rn;
3148 ifp = if_lookup_by_name (argv[0]);
3149 if (!ifp)
3151 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
3152 return CMD_WARNING;
3155 ospf = ospf_lookup ();
3156 if (ospf == NULL)
3158 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3159 return CMD_SUCCESS;
3162 show_ip_ospf_neighbour_header (vty);
3164 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
3166 struct ospf_interface *oi = rn->info;
3168 if (oi == NULL)
3169 continue;
3171 show_ip_ospf_neighbor_sub (vty, oi);
3174 return CMD_SUCCESS;
3177 static void
3178 show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
3179 struct ospf_nbr_nbma *nbr_nbma)
3181 char timebuf[OSPF_TIME_DUMP_SIZE];
3183 /* Show neighbor ID. */
3184 vty_out (vty, " Neighbor %s,", "-");
3186 /* Show interface address. */
3187 vty_out (vty, " interface address %s%s",
3188 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
3189 /* Show Area ID. */
3190 vty_out (vty, " In the area %s via interface %s%s",
3191 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
3192 /* Show neighbor priority and state. */
3193 vty_out (vty, " Neighbor priority is %d, State is %s,",
3194 nbr_nbma->priority, "Down");
3195 /* Show state changes. */
3196 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
3198 /* Show PollInterval */
3199 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
3201 /* Show poll-interval timer. */
3202 vty_out (vty, " Poll timer due in %s%s",
3203 ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)),
3204 VTY_NEWLINE);
3206 /* Show poll-interval timer thread. */
3207 vty_out (vty, " Thread Poll Timer %s%s",
3208 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
3211 static void
3212 show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
3213 struct ospf_neighbor *nbr)
3215 char timebuf[OSPF_TIME_DUMP_SIZE];
3217 /* Show neighbor ID. */
3218 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
3219 vty_out (vty, " Neighbor %s,", "-");
3220 else
3221 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
3223 /* Show interface address. */
3224 vty_out (vty, " interface address %s%s",
3225 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
3226 /* Show Area ID. */
3227 vty_out (vty, " In the area %s via interface %s%s",
3228 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
3229 /* Show neighbor priority and state. */
3230 vty_out (vty, " Neighbor priority is %d, State is %s,",
3231 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
3232 /* Show state changes. */
3233 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
3234 if (nbr->ts_last_progress.tv_sec || nbr->ts_last_progress.tv_usec)
3236 struct timeval res
3237 = tv_sub (recent_relative_time (), nbr->ts_last_progress);
3238 vty_out (vty, " Most recent state change statistics:%s",
3239 VTY_NEWLINE);
3240 vty_out (vty, " Progressive change %s ago%s",
3241 ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
3242 VTY_NEWLINE);
3244 if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec)
3246 struct timeval res
3247 = tv_sub (recent_relative_time (), nbr->ts_last_regress);
3248 vty_out (vty, " Regressive change %s ago, due to %s%s",
3249 ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
3250 (nbr->last_regress_str ? nbr->last_regress_str : "??"),
3251 VTY_NEWLINE);
3253 /* Show Designated Rotuer ID. */
3254 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
3255 /* Show Backup Designated Rotuer ID. */
3256 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
3257 /* Show options. */
3258 vty_out (vty, " Options %d %s%s", nbr->options,
3259 ospf_options_dump (nbr->options), VTY_NEWLINE);
3260 /* Show Router Dead interval timer. */
3261 vty_out (vty, " Dead timer due in %s%s",
3262 ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)),
3263 VTY_NEWLINE);
3264 /* Show Database Summary list. */
3265 vty_out (vty, " Database Summary List %d%s",
3266 ospf_db_summary_count (nbr), VTY_NEWLINE);
3267 /* Show Link State Request list. */
3268 vty_out (vty, " Link State Request List %ld%s",
3269 ospf_ls_request_count (nbr), VTY_NEWLINE);
3270 /* Show Link State Retransmission list. */
3271 vty_out (vty, " Link State Retransmission List %ld%s",
3272 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
3273 /* Show inactivity timer thread. */
3274 vty_out (vty, " Thread Inactivity Timer %s%s",
3275 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
3276 /* Show Database Description retransmission thread. */
3277 vty_out (vty, " Thread Database Description Retransmision %s%s",
3278 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
3279 /* Show Link State Request Retransmission thread. */
3280 vty_out (vty, " Thread Link State Request Retransmission %s%s",
3281 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
3282 /* Show Link State Update Retransmission thread. */
3283 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
3284 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
3287 DEFUN (show_ip_ospf_neighbor_id,
3288 show_ip_ospf_neighbor_id_cmd,
3289 "show ip ospf neighbor A.B.C.D",
3290 SHOW_STR
3291 IP_STR
3292 "OSPF information\n"
3293 "Neighbor list\n"
3294 "Neighbor ID\n")
3296 struct ospf *ospf;
3297 struct listnode *node;
3298 struct ospf_neighbor *nbr;
3299 struct ospf_interface *oi;
3300 struct in_addr router_id;
3301 int ret;
3303 ret = inet_aton (argv[0], &router_id);
3304 if (!ret)
3306 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
3307 return CMD_WARNING;
3310 ospf = ospf_lookup ();
3311 if (ospf == NULL)
3313 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3314 return CMD_SUCCESS;
3317 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3318 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
3319 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3321 return CMD_SUCCESS;
3324 DEFUN (show_ip_ospf_neighbor_detail,
3325 show_ip_ospf_neighbor_detail_cmd,
3326 "show ip ospf neighbor detail",
3327 SHOW_STR
3328 IP_STR
3329 "OSPF information\n"
3330 "Neighbor list\n"
3331 "detail of all neighbors\n")
3333 struct ospf *ospf;
3334 struct ospf_interface *oi;
3335 struct listnode *node;
3337 ospf = ospf_lookup ();
3338 if (ospf == NULL)
3340 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3341 return CMD_SUCCESS;
3344 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3346 struct route_node *rn;
3347 struct ospf_neighbor *nbr;
3349 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3350 if ((nbr = rn->info))
3351 if (nbr != oi->nbr_self)
3352 if (nbr->state != NSM_Down)
3353 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3356 return CMD_SUCCESS;
3359 DEFUN (show_ip_ospf_neighbor_detail_all,
3360 show_ip_ospf_neighbor_detail_all_cmd,
3361 "show ip ospf neighbor detail all",
3362 SHOW_STR
3363 IP_STR
3364 "OSPF information\n"
3365 "Neighbor list\n"
3366 "detail of all neighbors\n"
3367 "include down status neighbor\n")
3369 struct ospf *ospf;
3370 struct listnode *node;
3371 struct ospf_interface *oi;
3373 ospf = ospf_lookup ();
3374 if (ospf == NULL)
3376 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3377 return CMD_SUCCESS;
3380 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3382 struct route_node *rn;
3383 struct ospf_neighbor *nbr;
3384 struct ospf_nbr_nbma *nbr_nbma;
3386 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3387 if ((nbr = rn->info))
3388 if (nbr != oi->nbr_self)
3389 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3390 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3392 if (oi->type == OSPF_IFTYPE_NBMA)
3394 struct listnode *nd;
3396 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma))
3397 if (nbr_nbma->nbr == NULL
3398 || nbr_nbma->nbr->state == NSM_Down)
3399 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
3403 return CMD_SUCCESS;
3406 DEFUN (show_ip_ospf_neighbor_int_detail,
3407 show_ip_ospf_neighbor_int_detail_cmd,
3408 "show ip ospf neighbor IFNAME detail",
3409 SHOW_STR
3410 IP_STR
3411 "OSPF information\n"
3412 "Neighbor list\n"
3413 "Interface name\n"
3414 "detail of all neighbors")
3416 struct ospf *ospf;
3417 struct ospf_interface *oi;
3418 struct interface *ifp;
3419 struct route_node *rn, *nrn;
3420 struct ospf_neighbor *nbr;
3422 ifp = if_lookup_by_name (argv[0]);
3423 if (!ifp)
3425 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
3426 return CMD_WARNING;
3429 ospf = ospf_lookup ();
3430 if (ospf == NULL)
3432 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3433 return CMD_SUCCESS;
3437 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
3438 if ((oi = rn->info))
3439 for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn))
3440 if ((nbr = nrn->info))
3441 if (nbr != oi->nbr_self)
3442 if (nbr->state != NSM_Down)
3443 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3445 return CMD_SUCCESS;
3449 /* Show functions */
3450 static int
3451 show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
3453 struct router_lsa *rl;
3454 struct summary_lsa *sl;
3455 struct as_external_lsa *asel;
3456 struct prefix_ipv4 p;
3458 if (lsa != NULL)
3459 /* If self option is set, check LSA self flag. */
3460 if (self == 0 || IS_LSA_SELF (lsa))
3462 /* LSA common part show. */
3463 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3464 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3465 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3466 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3467 /* LSA specific part show. */
3468 switch (lsa->data->type)
3470 case OSPF_ROUTER_LSA:
3471 rl = (struct router_lsa *) lsa->data;
3472 vty_out (vty, " %-d", ntohs (rl->links));
3473 break;
3474 case OSPF_SUMMARY_LSA:
3475 sl = (struct summary_lsa *) lsa->data;
3477 p.family = AF_INET;
3478 p.prefix = sl->header.id;
3479 p.prefixlen = ip_masklen (sl->mask);
3480 apply_mask_ipv4 (&p);
3482 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3483 break;
3484 case OSPF_AS_EXTERNAL_LSA:
3485 case OSPF_AS_NSSA_LSA:
3486 asel = (struct as_external_lsa *) lsa->data;
3488 p.family = AF_INET;
3489 p.prefix = asel->header.id;
3490 p.prefixlen = ip_masklen (asel->mask);
3491 apply_mask_ipv4 (&p);
3493 vty_out (vty, " %s %s/%d [0x%lx]",
3494 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3495 inet_ntoa (p.prefix), p.prefixlen,
3496 (u_long)ntohl (asel->e[0].route_tag));
3497 break;
3498 case OSPF_NETWORK_LSA:
3499 case OSPF_ASBR_SUMMARY_LSA:
3500 #ifdef HAVE_OPAQUE_LSA
3501 case OSPF_OPAQUE_LINK_LSA:
3502 case OSPF_OPAQUE_AREA_LSA:
3503 case OSPF_OPAQUE_AS_LSA:
3504 #endif /* HAVE_OPAQUE_LSA */
3505 default:
3506 break;
3508 vty_out (vty, VTY_NEWLINE);
3511 return 0;
3514 const char *show_database_desc[] =
3516 "unknown",
3517 "Router Link States",
3518 "Net Link States",
3519 "Summary Link States",
3520 "ASBR-Summary Link States",
3521 "AS External Link States",
3522 "Group Membership LSA",
3523 "NSSA-external Link States",
3524 #ifdef HAVE_OPAQUE_LSA
3525 "Type-8 LSA",
3526 "Link-Local Opaque-LSA",
3527 "Area-Local Opaque-LSA",
3528 "AS-external Opaque-LSA",
3529 #endif /* HAVE_OPAQUE_LSA */
3532 #define SHOW_OSPF_COMMON_HEADER \
3533 "Link ID ADV Router Age Seq# CkSum"
3535 const char *show_database_header[] =
3538 "Link ID ADV Router Age Seq# CkSum Link count",
3539 "Link ID ADV Router Age Seq# CkSum",
3540 "Link ID ADV Router Age Seq# CkSum Route",
3541 "Link ID ADV Router Age Seq# CkSum",
3542 "Link ID ADV Router Age Seq# CkSum Route",
3543 " --- header for Group Member ----",
3544 "Link ID ADV Router Age Seq# CkSum Route",
3545 #ifdef HAVE_OPAQUE_LSA
3546 " --- type-8 ---",
3547 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3548 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3549 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3550 #endif /* HAVE_OPAQUE_LSA */
3553 const char *show_lsa_flags[] =
3555 "Self-originated",
3556 "Checked",
3557 "Received",
3558 "Approved",
3559 "Discard",
3560 "Translated",
3563 static void
3564 show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3566 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
3568 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
3569 vty_out (vty, " Options: 0x%-2x : %s%s",
3570 lsa->data->options,
3571 ospf_options_dump(lsa->data->options),
3572 VTY_NEWLINE);
3573 vty_out (vty, " LS Flags: 0x%-2x %s%s",
3574 lsa->flags,
3575 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
3576 VTY_NEWLINE);
3578 if (lsa->data->type == OSPF_ROUTER_LSA)
3580 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3582 if (rlsa->flags)
3583 vty_out (vty, " :%s%s%s%s",
3584 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3585 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3586 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3587 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3589 vty_out (vty, "%s", VTY_NEWLINE);
3591 vty_out (vty, " LS Type: %s%s",
3592 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3593 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3594 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3595 vty_out (vty, " Advertising Router: %s%s",
3596 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3597 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3598 VTY_NEWLINE);
3599 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3600 VTY_NEWLINE);
3601 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3604 const char *link_type_desc[] =
3606 "(null)",
3607 "another Router (point-to-point)",
3608 "a Transit Network",
3609 "Stub Network",
3610 "a Virtual Link",
3613 const char *link_id_desc[] =
3615 "(null)",
3616 "Neighboring Router ID",
3617 "Designated Router address",
3618 "Net",
3619 "Neighboring Router ID",
3622 const char *link_data_desc[] =
3624 "(null)",
3625 "Router Interface address",
3626 "Router Interface address",
3627 "Network Mask",
3628 "Router Interface address",
3631 /* Show router-LSA each Link information. */
3632 static void
3633 show_ip_ospf_database_router_links (struct vty *vty,
3634 struct router_lsa *rl)
3636 int len, i, type;
3638 len = ntohs (rl->header.length) - 4;
3639 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3641 type = rl->link[i].type;
3643 vty_out (vty, " Link connected to: %s%s",
3644 link_type_desc[type], VTY_NEWLINE);
3645 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3646 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3647 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3648 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3649 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3650 vty_out (vty, " TOS 0 Metric: %d%s",
3651 ntohs (rl->link[i].metric), VTY_NEWLINE);
3652 vty_out (vty, "%s", VTY_NEWLINE);
3656 /* Show router-LSA detail information. */
3657 static int
3658 show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3660 if (lsa != NULL)
3662 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3664 show_ip_ospf_database_header (vty, lsa);
3666 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3667 VTY_NEWLINE, VTY_NEWLINE);
3669 show_ip_ospf_database_router_links (vty, rl);
3670 vty_out (vty, "%s", VTY_NEWLINE);
3673 return 0;
3676 /* Show network-LSA detail information. */
3677 static int
3678 show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3680 int length, i;
3682 if (lsa != NULL)
3684 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3686 show_ip_ospf_database_header (vty, lsa);
3688 vty_out (vty, " Network Mask: /%d%s",
3689 ip_masklen (nl->mask), VTY_NEWLINE);
3691 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3693 for (i = 0; length > 0; i++, length -= 4)
3694 vty_out (vty, " Attached Router: %s%s",
3695 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3697 vty_out (vty, "%s", VTY_NEWLINE);
3700 return 0;
3703 /* Show summary-LSA detail information. */
3704 static int
3705 show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3707 if (lsa != NULL)
3709 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3711 show_ip_ospf_database_header (vty, lsa);
3713 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3714 VTY_NEWLINE);
3715 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3716 VTY_NEWLINE);
3717 vty_out (vty, "%s", VTY_NEWLINE);
3720 return 0;
3723 /* Show summary-ASBR-LSA detail information. */
3724 static int
3725 show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3727 if (lsa != NULL)
3729 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3731 show_ip_ospf_database_header (vty, lsa);
3733 vty_out (vty, " Network Mask: /%d%s",
3734 ip_masklen (sl->mask), VTY_NEWLINE);
3735 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3736 VTY_NEWLINE);
3737 vty_out (vty, "%s", VTY_NEWLINE);
3740 return 0;
3743 /* Show AS-external-LSA detail information. */
3744 static int
3745 show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3747 if (lsa != NULL)
3749 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3751 show_ip_ospf_database_header (vty, lsa);
3753 vty_out (vty, " Network Mask: /%d%s",
3754 ip_masklen (al->mask), VTY_NEWLINE);
3755 vty_out (vty, " Metric Type: %s%s",
3756 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3757 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3758 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3759 vty_out (vty, " Metric: %d%s",
3760 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3761 vty_out (vty, " Forward Address: %s%s",
3762 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3764 vty_out (vty, " External Route Tag: %lu%s%s",
3765 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3768 return 0;
3771 /* N.B. This function currently seems to be unused. */
3772 static int
3773 show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3775 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3777 /* show_ip_ospf_database_header (vty, lsa); */
3779 zlog_debug( " Network Mask: /%d%s",
3780 ip_masklen (al->mask), "\n");
3781 zlog_debug( " Metric Type: %s%s",
3782 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3783 "2 (Larger than any link state path)" : "1", "\n");
3784 zlog_debug( " TOS: 0%s", "\n");
3785 zlog_debug( " Metric: %d%s",
3786 GET_METRIC (al->e[0].metric), "\n");
3787 zlog_debug( " Forward Address: %s%s",
3788 inet_ntoa (al->e[0].fwd_addr), "\n");
3790 zlog_debug( " External Route Tag: %u%s%s",
3791 ntohl (al->e[0].route_tag), "\n", "\n");
3793 return 0;
3796 /* Show AS-NSSA-LSA detail information. */
3797 static int
3798 show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3800 if (lsa != NULL)
3802 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3804 show_ip_ospf_database_header (vty, lsa);
3806 vty_out (vty, " Network Mask: /%d%s",
3807 ip_masklen (al->mask), VTY_NEWLINE);
3808 vty_out (vty, " Metric Type: %s%s",
3809 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3810 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3811 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3812 vty_out (vty, " Metric: %d%s",
3813 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3814 vty_out (vty, " NSSA: Forward Address: %s%s",
3815 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3817 vty_out (vty, " External Route Tag: %u%s%s",
3818 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3821 return 0;
3824 static int
3825 show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3827 return 0;
3830 #ifdef HAVE_OPAQUE_LSA
3831 static int
3832 show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3834 if (lsa != NULL)
3836 show_ip_ospf_database_header (vty, lsa);
3837 show_opaque_info_detail (vty, lsa);
3839 vty_out (vty, "%s", VTY_NEWLINE);
3841 return 0;
3843 #endif /* HAVE_OPAQUE_LSA */
3845 int (*show_function[])(struct vty *, struct ospf_lsa *) =
3847 NULL,
3848 show_router_lsa_detail,
3849 show_network_lsa_detail,
3850 show_summary_lsa_detail,
3851 show_summary_asbr_lsa_detail,
3852 show_as_external_lsa_detail,
3853 show_func_dummy,
3854 show_as_nssa_lsa_detail, /* almost same as external */
3855 #ifdef HAVE_OPAQUE_LSA
3856 NULL, /* type-8 */
3857 show_opaque_lsa_detail,
3858 show_opaque_lsa_detail,
3859 show_opaque_lsa_detail,
3860 #endif /* HAVE_OPAQUE_LSA */
3863 static void
3864 show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3865 struct in_addr *adv_router)
3867 memset (lp, 0, sizeof (struct prefix_ls));
3868 lp->family = 0;
3869 if (id == NULL)
3870 lp->prefixlen = 0;
3871 else if (adv_router == NULL)
3873 lp->prefixlen = 32;
3874 lp->id = *id;
3876 else
3878 lp->prefixlen = 64;
3879 lp->id = *id;
3880 lp->adv_router = *adv_router;
3884 static void
3885 show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3886 struct in_addr *id, struct in_addr *adv_router)
3888 struct prefix_ls lp;
3889 struct route_node *rn, *start;
3890 struct ospf_lsa *lsa;
3892 show_lsa_prefix_set (vty, &lp, id, adv_router);
3893 start = route_node_get (rt, (struct prefix *) &lp);
3894 if (start)
3896 route_lock_node (start);
3897 for (rn = start; rn; rn = route_next_until (rn, start))
3898 if ((lsa = rn->info))
3900 if (show_function[lsa->data->type] != NULL)
3901 show_function[lsa->data->type] (vty, lsa);
3903 route_unlock_node (start);
3907 /* Show detail LSA information
3908 -- if id is NULL then show all LSAs. */
3909 static void
3910 show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
3911 struct in_addr *id, struct in_addr *adv_router)
3913 struct listnode *node;
3914 struct ospf_area *area;
3916 switch (type)
3918 case OSPF_AS_EXTERNAL_LSA:
3919 #ifdef HAVE_OPAQUE_LSA
3920 case OSPF_OPAQUE_AS_LSA:
3921 #endif /* HAVE_OPAQUE_LSA */
3922 vty_out (vty, " %s %s%s",
3923 show_database_desc[type],
3924 VTY_NEWLINE, VTY_NEWLINE);
3925 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
3926 break;
3927 default:
3928 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
3930 vty_out (vty, "%s %s (Area %s)%s%s",
3931 VTY_NEWLINE, show_database_desc[type],
3932 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3933 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3935 break;
3939 static void
3940 show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3941 struct in_addr *adv_router)
3943 struct route_node *rn;
3944 struct ospf_lsa *lsa;
3946 for (rn = route_top (rt); rn; rn = route_next (rn))
3947 if ((lsa = rn->info))
3948 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3950 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3951 continue;
3952 if (show_function[lsa->data->type] != NULL)
3953 show_function[lsa->data->type] (vty, lsa);
3957 /* Show detail LSA information. */
3958 static void
3959 show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
3960 struct in_addr *adv_router)
3962 struct listnode *node;
3963 struct ospf_area *area;
3965 switch (type)
3967 case OSPF_AS_EXTERNAL_LSA:
3968 #ifdef HAVE_OPAQUE_LSA
3969 case OSPF_OPAQUE_AS_LSA:
3970 #endif /* HAVE_OPAQUE_LSA */
3971 vty_out (vty, " %s %s%s",
3972 show_database_desc[type],
3973 VTY_NEWLINE, VTY_NEWLINE);
3974 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
3975 adv_router);
3976 break;
3977 default:
3978 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
3980 vty_out (vty, "%s %s (Area %s)%s%s",
3981 VTY_NEWLINE, show_database_desc[type],
3982 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3983 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3984 adv_router);
3986 break;
3990 static void
3991 show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
3993 struct ospf_lsa *lsa;
3994 struct route_node *rn;
3995 struct ospf_area *area;
3996 struct listnode *node;
3997 int type;
3999 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
4001 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
4003 switch (type)
4005 case OSPF_AS_EXTERNAL_LSA:
4006 #ifdef HAVE_OPAQUE_LSA
4007 case OSPF_OPAQUE_AS_LSA:
4008 #endif /* HAVE_OPAQUE_LSA */
4009 continue;
4010 default:
4011 break;
4013 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
4014 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
4016 vty_out (vty, " %s (Area %s)%s%s",
4017 show_database_desc[type],
4018 ospf_area_desc_string (area),
4019 VTY_NEWLINE, VTY_NEWLINE);
4020 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
4022 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
4023 show_lsa_summary (vty, lsa, self);
4025 vty_out (vty, "%s", VTY_NEWLINE);
4030 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
4032 switch (type)
4034 case OSPF_AS_EXTERNAL_LSA:
4035 #ifdef HAVE_OPAQUE_LSA
4036 case OSPF_OPAQUE_AS_LSA:
4037 #endif /* HAVE_OPAQUE_LSA */
4038 break;
4039 default:
4040 continue;
4042 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
4043 (!self && ospf_lsdb_count (ospf->lsdb, type)))
4045 vty_out (vty, " %s%s%s",
4046 show_database_desc[type],
4047 VTY_NEWLINE, VTY_NEWLINE);
4048 vty_out (vty, "%s%s", show_database_header[type],
4049 VTY_NEWLINE);
4051 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
4052 show_lsa_summary (vty, lsa, self);
4054 vty_out (vty, "%s", VTY_NEWLINE);
4058 vty_out (vty, "%s", VTY_NEWLINE);
4061 static void
4062 show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
4064 struct listnode *node;
4065 struct ospf_lsa *lsa;
4067 vty_out (vty, "%s MaxAge Link States:%s%s",
4068 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
4070 for (ALL_LIST_ELEMENTS_RO (ospf->maxage_lsa, node, lsa))
4072 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
4073 vty_out (vty, "Link State ID: %s%s",
4074 inet_ntoa (lsa->data->id), VTY_NEWLINE);
4075 vty_out (vty, "Advertising Router: %s%s",
4076 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
4077 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
4078 vty_out (vty, "%s", VTY_NEWLINE);
4082 #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
4083 #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
4085 #ifdef HAVE_OPAQUE_LSA
4086 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
4087 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
4088 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
4089 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
4090 #else /* HAVE_OPAQUE_LSA */
4091 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
4092 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
4093 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
4094 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
4095 #endif /* HAVE_OPAQUE_LSA */
4097 #define OSPF_LSA_TYPES_CMD_STR \
4098 "asbr-summary|external|network|router|summary" \
4099 OSPF_LSA_TYPE_NSSA_CMD_STR \
4100 OSPF_LSA_TYPE_OPAQUE_CMD_STR
4102 #define OSPF_LSA_TYPES_DESC \
4103 "ASBR summary link states\n" \
4104 "External link states\n" \
4105 "Network link states\n" \
4106 "Router link states\n" \
4107 "Network summary link states\n" \
4108 OSPF_LSA_TYPE_NSSA_DESC \
4109 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
4110 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
4111 OSPF_LSA_TYPE_OPAQUE_AS_DESC
4113 DEFUN (show_ip_ospf_database,
4114 show_ip_ospf_database_cmd,
4115 "show ip ospf database",
4116 SHOW_STR
4117 IP_STR
4118 "OSPF information\n"
4119 "Database summary\n")
4121 struct ospf *ospf;
4122 int type, ret;
4123 struct in_addr id, adv_router;
4125 ospf = ospf_lookup ();
4126 if (ospf == NULL)
4128 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4129 return CMD_SUCCESS;
4132 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
4133 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
4135 /* Show all LSA. */
4136 if (argc == 0)
4138 show_ip_ospf_database_summary (vty, ospf, 0);
4139 return CMD_SUCCESS;
4142 /* Set database type to show. */
4143 if (strncmp (argv[0], "r", 1) == 0)
4144 type = OSPF_ROUTER_LSA;
4145 else if (strncmp (argv[0], "ne", 2) == 0)
4146 type = OSPF_NETWORK_LSA;
4147 else if (strncmp (argv[0], "ns", 2) == 0)
4148 type = OSPF_AS_NSSA_LSA;
4149 else if (strncmp (argv[0], "su", 2) == 0)
4150 type = OSPF_SUMMARY_LSA;
4151 else if (strncmp (argv[0], "a", 1) == 0)
4152 type = OSPF_ASBR_SUMMARY_LSA;
4153 else if (strncmp (argv[0], "e", 1) == 0)
4154 type = OSPF_AS_EXTERNAL_LSA;
4155 else if (strncmp (argv[0], "se", 2) == 0)
4157 show_ip_ospf_database_summary (vty, ospf, 1);
4158 return CMD_SUCCESS;
4160 else if (strncmp (argv[0], "m", 1) == 0)
4162 show_ip_ospf_database_maxage (vty, ospf);
4163 return CMD_SUCCESS;
4165 #ifdef HAVE_OPAQUE_LSA
4166 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4167 type = OSPF_OPAQUE_LINK_LSA;
4168 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4169 type = OSPF_OPAQUE_AREA_LSA;
4170 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4171 type = OSPF_OPAQUE_AS_LSA;
4172 #endif /* HAVE_OPAQUE_LSA */
4173 else
4174 return CMD_WARNING;
4176 /* `show ip ospf database LSA'. */
4177 if (argc == 1)
4178 show_lsa_detail (vty, ospf, type, NULL, NULL);
4179 else if (argc >= 2)
4181 ret = inet_aton (argv[1], &id);
4182 if (!ret)
4183 return CMD_WARNING;
4185 /* `show ip ospf database LSA ID'. */
4186 if (argc == 2)
4187 show_lsa_detail (vty, ospf, type, &id, NULL);
4188 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
4189 else if (argc == 3)
4191 if (strncmp (argv[2], "s", 1) == 0)
4192 adv_router = ospf->router_id;
4193 else
4195 ret = inet_aton (argv[2], &adv_router);
4196 if (!ret)
4197 return CMD_WARNING;
4199 show_lsa_detail (vty, ospf, type, &id, &adv_router);
4203 return CMD_SUCCESS;
4206 ALIAS (show_ip_ospf_database,
4207 show_ip_ospf_database_type_cmd,
4208 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
4209 SHOW_STR
4210 IP_STR
4211 "OSPF information\n"
4212 "Database summary\n"
4213 OSPF_LSA_TYPES_DESC
4214 "LSAs in MaxAge list\n"
4215 "Self-originated link states\n")
4217 ALIAS (show_ip_ospf_database,
4218 show_ip_ospf_database_type_id_cmd,
4219 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
4220 SHOW_STR
4221 IP_STR
4222 "OSPF information\n"
4223 "Database summary\n"
4224 OSPF_LSA_TYPES_DESC
4225 "Link State ID (as an IP address)\n")
4227 ALIAS (show_ip_ospf_database,
4228 show_ip_ospf_database_type_id_adv_router_cmd,
4229 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
4230 SHOW_STR
4231 IP_STR
4232 "OSPF information\n"
4233 "Database summary\n"
4234 OSPF_LSA_TYPES_DESC
4235 "Link State ID (as an IP address)\n"
4236 "Advertising Router link states\n"
4237 "Advertising Router (as an IP address)\n")
4239 ALIAS (show_ip_ospf_database,
4240 show_ip_ospf_database_type_id_self_cmd,
4241 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
4242 SHOW_STR
4243 IP_STR
4244 "OSPF information\n"
4245 "Database summary\n"
4246 OSPF_LSA_TYPES_DESC
4247 "Link State ID (as an IP address)\n"
4248 "Self-originated link states\n"
4249 "\n")
4251 DEFUN (show_ip_ospf_database_type_adv_router,
4252 show_ip_ospf_database_type_adv_router_cmd,
4253 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
4254 SHOW_STR
4255 IP_STR
4256 "OSPF information\n"
4257 "Database summary\n"
4258 OSPF_LSA_TYPES_DESC
4259 "Advertising Router link states\n"
4260 "Advertising Router (as an IP address)\n")
4262 struct ospf *ospf;
4263 int type, ret;
4264 struct in_addr adv_router;
4266 ospf = ospf_lookup ();
4267 if (ospf == NULL)
4269 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4270 return CMD_SUCCESS;
4273 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
4274 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
4276 if (argc != 2)
4277 return CMD_WARNING;
4279 /* Set database type to show. */
4280 if (strncmp (argv[0], "r", 1) == 0)
4281 type = OSPF_ROUTER_LSA;
4282 else if (strncmp (argv[0], "ne", 2) == 0)
4283 type = OSPF_NETWORK_LSA;
4284 else if (strncmp (argv[0], "ns", 2) == 0)
4285 type = OSPF_AS_NSSA_LSA;
4286 else if (strncmp (argv[0], "s", 1) == 0)
4287 type = OSPF_SUMMARY_LSA;
4288 else if (strncmp (argv[0], "a", 1) == 0)
4289 type = OSPF_ASBR_SUMMARY_LSA;
4290 else if (strncmp (argv[0], "e", 1) == 0)
4291 type = OSPF_AS_EXTERNAL_LSA;
4292 #ifdef HAVE_OPAQUE_LSA
4293 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4294 type = OSPF_OPAQUE_LINK_LSA;
4295 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4296 type = OSPF_OPAQUE_AREA_LSA;
4297 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4298 type = OSPF_OPAQUE_AS_LSA;
4299 #endif /* HAVE_OPAQUE_LSA */
4300 else
4301 return CMD_WARNING;
4303 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
4304 if (strncmp (argv[1], "s", 1) == 0)
4305 adv_router = ospf->router_id;
4306 else
4308 ret = inet_aton (argv[1], &adv_router);
4309 if (!ret)
4310 return CMD_WARNING;
4313 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
4315 return CMD_SUCCESS;
4318 ALIAS (show_ip_ospf_database_type_adv_router,
4319 show_ip_ospf_database_type_self_cmd,
4320 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
4321 SHOW_STR
4322 IP_STR
4323 "OSPF information\n"
4324 "Database summary\n"
4325 OSPF_LSA_TYPES_DESC
4326 "Self-originated link states\n")
4329 DEFUN (ip_ospf_authentication_args,
4330 ip_ospf_authentication_args_addr_cmd,
4331 "ip ospf authentication (null|message-digest) A.B.C.D",
4332 "IP Information\n"
4333 "OSPF interface commands\n"
4334 "Enable authentication on this interface\n"
4335 "Use null authentication\n"
4336 "Use message-digest authentication\n"
4337 "Address of interface")
4339 struct interface *ifp;
4340 struct in_addr addr;
4341 int ret;
4342 struct ospf_if_params *params;
4344 ifp = vty->index;
4345 params = IF_DEF_PARAMS (ifp);
4347 if (argc == 2)
4349 ret = inet_aton(argv[1], &addr);
4350 if (!ret)
4352 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4353 VTY_NEWLINE);
4354 return CMD_WARNING;
4357 params = ospf_get_if_params (ifp, addr);
4358 ospf_if_update_params (ifp, addr);
4361 /* Handle null authentication */
4362 if ( argv[0][0] == 'n' )
4364 SET_IF_PARAM (params, auth_type);
4365 params->auth_type = OSPF_AUTH_NULL;
4366 return CMD_SUCCESS;
4369 /* Handle message-digest authentication */
4370 if ( argv[0][0] == 'm' )
4372 SET_IF_PARAM (params, auth_type);
4373 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
4374 return CMD_SUCCESS;
4377 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4378 return CMD_WARNING;
4381 ALIAS (ip_ospf_authentication_args,
4382 ip_ospf_authentication_args_cmd,
4383 "ip ospf authentication (null|message-digest)",
4384 "IP Information\n"
4385 "OSPF interface commands\n"
4386 "Enable authentication on this interface\n"
4387 "Use null authentication\n"
4388 "Use message-digest authentication\n")
4390 DEFUN (ip_ospf_authentication,
4391 ip_ospf_authentication_addr_cmd,
4392 "ip ospf authentication A.B.C.D",
4393 "IP Information\n"
4394 "OSPF interface commands\n"
4395 "Enable authentication on this interface\n"
4396 "Address of interface")
4398 struct interface *ifp;
4399 struct in_addr addr;
4400 int ret;
4401 struct ospf_if_params *params;
4403 ifp = vty->index;
4404 params = IF_DEF_PARAMS (ifp);
4406 if (argc == 1)
4408 ret = inet_aton(argv[0], &addr);
4409 if (!ret)
4411 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4412 VTY_NEWLINE);
4413 return CMD_WARNING;
4416 params = ospf_get_if_params (ifp, addr);
4417 ospf_if_update_params (ifp, addr);
4420 SET_IF_PARAM (params, auth_type);
4421 params->auth_type = OSPF_AUTH_SIMPLE;
4423 return CMD_SUCCESS;
4426 ALIAS (ip_ospf_authentication,
4427 ip_ospf_authentication_cmd,
4428 "ip ospf authentication",
4429 "IP Information\n"
4430 "OSPF interface commands\n"
4431 "Enable authentication on this interface\n")
4433 DEFUN (no_ip_ospf_authentication,
4434 no_ip_ospf_authentication_addr_cmd,
4435 "no ip ospf authentication A.B.C.D",
4436 NO_STR
4437 "IP Information\n"
4438 "OSPF interface commands\n"
4439 "Enable authentication on this interface\n"
4440 "Address of interface")
4442 struct interface *ifp;
4443 struct in_addr addr;
4444 int ret;
4445 struct ospf_if_params *params;
4447 ifp = vty->index;
4448 params = IF_DEF_PARAMS (ifp);
4450 if (argc == 1)
4452 ret = inet_aton(argv[0], &addr);
4453 if (!ret)
4455 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4456 VTY_NEWLINE);
4457 return CMD_WARNING;
4460 params = ospf_lookup_if_params (ifp, addr);
4461 if (params == NULL)
4462 return CMD_SUCCESS;
4465 params->auth_type = OSPF_AUTH_NOTSET;
4466 UNSET_IF_PARAM (params, auth_type);
4468 if (params != IF_DEF_PARAMS (ifp))
4470 ospf_free_if_params (ifp, addr);
4471 ospf_if_update_params (ifp, addr);
4474 return CMD_SUCCESS;
4477 ALIAS (no_ip_ospf_authentication,
4478 no_ip_ospf_authentication_cmd,
4479 "no ip ospf authentication",
4480 NO_STR
4481 "IP Information\n"
4482 "OSPF interface commands\n"
4483 "Enable authentication on this interface\n")
4485 DEFUN (ip_ospf_authentication_key,
4486 ip_ospf_authentication_key_addr_cmd,
4487 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4488 "IP Information\n"
4489 "OSPF interface commands\n"
4490 "Authentication password (key)\n"
4491 "The OSPF password (key)\n"
4492 "Address of interface")
4494 struct interface *ifp;
4495 struct in_addr addr;
4496 int ret;
4497 struct ospf_if_params *params;
4499 ifp = vty->index;
4500 params = IF_DEF_PARAMS (ifp);
4502 if (argc == 2)
4504 ret = inet_aton(argv[1], &addr);
4505 if (!ret)
4507 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4508 VTY_NEWLINE);
4509 return CMD_WARNING;
4512 params = ospf_get_if_params (ifp, addr);
4513 ospf_if_update_params (ifp, addr);
4517 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
4518 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
4519 SET_IF_PARAM (params, auth_simple);
4521 return CMD_SUCCESS;
4524 ALIAS (ip_ospf_authentication_key,
4525 ip_ospf_authentication_key_cmd,
4526 "ip ospf authentication-key AUTH_KEY",
4527 "IP Information\n"
4528 "OSPF interface commands\n"
4529 "Authentication password (key)\n"
4530 "The OSPF password (key)")
4532 ALIAS (ip_ospf_authentication_key,
4533 ospf_authentication_key_cmd,
4534 "ospf authentication-key AUTH_KEY",
4535 "OSPF interface commands\n"
4536 "Authentication password (key)\n"
4537 "The OSPF password (key)")
4539 DEFUN (no_ip_ospf_authentication_key,
4540 no_ip_ospf_authentication_key_addr_cmd,
4541 "no ip ospf authentication-key A.B.C.D",
4542 NO_STR
4543 "IP Information\n"
4544 "OSPF interface commands\n"
4545 "Authentication password (key)\n"
4546 "Address of interface")
4548 struct interface *ifp;
4549 struct in_addr addr;
4550 int ret;
4551 struct ospf_if_params *params;
4553 ifp = vty->index;
4554 params = IF_DEF_PARAMS (ifp);
4556 if (argc == 1)
4558 ret = inet_aton(argv[0], &addr);
4559 if (!ret)
4561 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4562 VTY_NEWLINE);
4563 return CMD_WARNING;
4566 params = ospf_lookup_if_params (ifp, addr);
4567 if (params == NULL)
4568 return CMD_SUCCESS;
4571 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4572 UNSET_IF_PARAM (params, auth_simple);
4574 if (params != IF_DEF_PARAMS (ifp))
4576 ospf_free_if_params (ifp, addr);
4577 ospf_if_update_params (ifp, addr);
4580 return CMD_SUCCESS;
4583 ALIAS (no_ip_ospf_authentication_key,
4584 no_ip_ospf_authentication_key_cmd,
4585 "no ip ospf authentication-key",
4586 NO_STR
4587 "IP Information\n"
4588 "OSPF interface commands\n"
4589 "Authentication password (key)\n")
4591 ALIAS (no_ip_ospf_authentication_key,
4592 no_ospf_authentication_key_cmd,
4593 "no ospf authentication-key",
4594 NO_STR
4595 "OSPF interface commands\n"
4596 "Authentication password (key)\n")
4598 DEFUN (ip_ospf_message_digest_key,
4599 ip_ospf_message_digest_key_addr_cmd,
4600 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4601 "IP Information\n"
4602 "OSPF interface commands\n"
4603 "Message digest authentication password (key)\n"
4604 "Key ID\n"
4605 "Use MD5 algorithm\n"
4606 "The OSPF password (key)"
4607 "Address of interface")
4609 struct interface *ifp;
4610 struct crypt_key *ck;
4611 u_char key_id;
4612 struct in_addr addr;
4613 int ret;
4614 struct ospf_if_params *params;
4616 ifp = vty->index;
4617 params = IF_DEF_PARAMS (ifp);
4619 if (argc == 3)
4621 ret = inet_aton(argv[2], &addr);
4622 if (!ret)
4624 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4625 VTY_NEWLINE);
4626 return CMD_WARNING;
4629 params = ospf_get_if_params (ifp, addr);
4630 ospf_if_update_params (ifp, addr);
4633 key_id = strtol (argv[0], NULL, 10);
4634 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4636 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4637 return CMD_WARNING;
4640 ck = ospf_crypt_key_new ();
4641 ck->key_id = (u_char) key_id;
4642 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
4643 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
4645 ospf_crypt_key_add (params->auth_crypt, ck);
4646 SET_IF_PARAM (params, auth_crypt);
4648 return CMD_SUCCESS;
4651 ALIAS (ip_ospf_message_digest_key,
4652 ip_ospf_message_digest_key_cmd,
4653 "ip ospf message-digest-key <1-255> md5 KEY",
4654 "IP Information\n"
4655 "OSPF interface commands\n"
4656 "Message digest authentication password (key)\n"
4657 "Key ID\n"
4658 "Use MD5 algorithm\n"
4659 "The OSPF password (key)")
4661 ALIAS (ip_ospf_message_digest_key,
4662 ospf_message_digest_key_cmd,
4663 "ospf message-digest-key <1-255> md5 KEY",
4664 "OSPF interface commands\n"
4665 "Message digest authentication password (key)\n"
4666 "Key ID\n"
4667 "Use MD5 algorithm\n"
4668 "The OSPF password (key)")
4670 DEFUN (no_ip_ospf_message_digest_key,
4671 no_ip_ospf_message_digest_key_addr_cmd,
4672 "no ip ospf message-digest-key <1-255> A.B.C.D",
4673 NO_STR
4674 "IP Information\n"
4675 "OSPF interface commands\n"
4676 "Message digest authentication password (key)\n"
4677 "Key ID\n"
4678 "Address of interface")
4680 struct interface *ifp;
4681 struct crypt_key *ck;
4682 int key_id;
4683 struct in_addr addr;
4684 int ret;
4685 struct ospf_if_params *params;
4687 ifp = vty->index;
4688 params = IF_DEF_PARAMS (ifp);
4690 if (argc == 2)
4692 ret = inet_aton(argv[1], &addr);
4693 if (!ret)
4695 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4696 VTY_NEWLINE);
4697 return CMD_WARNING;
4700 params = ospf_lookup_if_params (ifp, addr);
4701 if (params == NULL)
4702 return CMD_SUCCESS;
4705 key_id = strtol (argv[0], NULL, 10);
4706 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4707 if (ck == NULL)
4709 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4710 return CMD_WARNING;
4713 ospf_crypt_key_delete (params->auth_crypt, key_id);
4715 if (params != IF_DEF_PARAMS (ifp))
4717 ospf_free_if_params (ifp, addr);
4718 ospf_if_update_params (ifp, addr);
4721 return CMD_SUCCESS;
4724 ALIAS (no_ip_ospf_message_digest_key,
4725 no_ip_ospf_message_digest_key_cmd,
4726 "no ip ospf message-digest-key <1-255>",
4727 NO_STR
4728 "IP Information\n"
4729 "OSPF interface commands\n"
4730 "Message digest authentication password (key)\n"
4731 "Key ID\n")
4733 ALIAS (no_ip_ospf_message_digest_key,
4734 no_ospf_message_digest_key_cmd,
4735 "no ospf message-digest-key <1-255>",
4736 NO_STR
4737 "OSPF interface commands\n"
4738 "Message digest authentication password (key)\n"
4739 "Key ID\n")
4741 DEFUN (ip_ospf_cost,
4742 ip_ospf_cost_u32_inet4_cmd,
4743 "ip ospf cost <1-65535> A.B.C.D",
4744 "IP Information\n"
4745 "OSPF interface commands\n"
4746 "Interface cost\n"
4747 "Cost\n"
4748 "Address of interface")
4750 struct interface *ifp = vty->index;
4751 u_int32_t cost;
4752 struct in_addr addr;
4753 int ret;
4754 struct ospf_if_params *params;
4756 params = IF_DEF_PARAMS (ifp);
4758 cost = strtol (argv[0], NULL, 10);
4760 /* cost range is <1-65535>. */
4761 if (cost < 1 || cost > 65535)
4763 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4764 return CMD_WARNING;
4767 if (argc == 2)
4769 ret = inet_aton(argv[1], &addr);
4770 if (!ret)
4772 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4773 VTY_NEWLINE);
4774 return CMD_WARNING;
4777 params = ospf_get_if_params (ifp, addr);
4778 ospf_if_update_params (ifp, addr);
4781 SET_IF_PARAM (params, output_cost_cmd);
4782 params->output_cost_cmd = cost;
4784 ospf_if_recalculate_output_cost (ifp);
4786 return CMD_SUCCESS;
4789 ALIAS (ip_ospf_cost,
4790 ip_ospf_cost_u32_cmd,
4791 "ip ospf cost <1-65535>",
4792 "IP Information\n"
4793 "OSPF interface commands\n"
4794 "Interface cost\n"
4795 "Cost")
4797 ALIAS (ip_ospf_cost,
4798 ospf_cost_u32_cmd,
4799 "ospf cost <1-65535>",
4800 "OSPF interface commands\n"
4801 "Interface cost\n"
4802 "Cost")
4804 ALIAS (ip_ospf_cost,
4805 ospf_cost_u32_inet4_cmd,
4806 "ospf cost <1-65535> A.B.C.D",
4807 "OSPF interface commands\n"
4808 "Interface cost\n"
4809 "Cost\n"
4810 "Address of interface")
4812 DEFUN (no_ip_ospf_cost,
4813 no_ip_ospf_cost_inet4_cmd,
4814 "no ip ospf cost A.B.C.D",
4815 NO_STR
4816 "IP Information\n"
4817 "OSPF interface commands\n"
4818 "Interface cost\n"
4819 "Address of interface")
4821 struct interface *ifp = vty->index;
4822 struct in_addr addr;
4823 int ret;
4824 struct ospf_if_params *params;
4826 ifp = vty->index;
4827 params = IF_DEF_PARAMS (ifp);
4829 if (argc == 1)
4831 ret = inet_aton(argv[0], &addr);
4832 if (!ret)
4834 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4835 VTY_NEWLINE);
4836 return CMD_WARNING;
4839 params = ospf_lookup_if_params (ifp, addr);
4840 if (params == NULL)
4841 return CMD_SUCCESS;
4844 UNSET_IF_PARAM (params, output_cost_cmd);
4846 if (params != IF_DEF_PARAMS (ifp))
4848 ospf_free_if_params (ifp, addr);
4849 ospf_if_update_params (ifp, addr);
4852 ospf_if_recalculate_output_cost (ifp);
4854 return CMD_SUCCESS;
4857 ALIAS (no_ip_ospf_cost,
4858 no_ip_ospf_cost_cmd,
4859 "no ip ospf cost",
4860 NO_STR
4861 "IP Information\n"
4862 "OSPF interface commands\n"
4863 "Interface cost\n")
4865 ALIAS (no_ip_ospf_cost,
4866 no_ospf_cost_cmd,
4867 "no ospf cost",
4868 NO_STR
4869 "OSPF interface commands\n"
4870 "Interface cost\n")
4872 ALIAS (no_ip_ospf_cost,
4873 no_ospf_cost_inet4_cmd,
4874 "no ospf cost A.B.C.D",
4875 NO_STR
4876 "OSPF interface commands\n"
4877 "Interface cost\n"
4878 "Address of interface")
4881 static void
4882 ospf_nbr_timer_update (struct ospf_interface *oi)
4884 struct route_node *rn;
4885 struct ospf_neighbor *nbr;
4887 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4888 if ((nbr = rn->info))
4890 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4891 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4892 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4893 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4897 static int
4898 ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str,
4899 const char *nbr_str,
4900 const char *fast_hello_str)
4902 struct interface *ifp = vty->index;
4903 u_int32_t seconds;
4904 u_char hellomult;
4905 struct in_addr addr;
4906 int ret;
4907 struct ospf_if_params *params;
4908 struct ospf_interface *oi;
4909 struct route_node *rn;
4911 params = IF_DEF_PARAMS (ifp);
4913 if (nbr_str)
4915 ret = inet_aton(nbr_str, &addr);
4916 if (!ret)
4918 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4919 VTY_NEWLINE);
4920 return CMD_WARNING;
4923 params = ospf_get_if_params (ifp, addr);
4924 ospf_if_update_params (ifp, addr);
4927 if (interval_str)
4929 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str,
4930 1, 65535);
4932 /* reset fast_hello too, just to be sure */
4933 UNSET_IF_PARAM (params, fast_hello);
4934 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
4936 else if (fast_hello_str)
4938 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str,
4939 1, 10);
4940 /* 1s dead-interval with sub-second hellos desired */
4941 seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL;
4942 SET_IF_PARAM (params, fast_hello);
4943 params->fast_hello = hellomult;
4945 else
4947 vty_out (vty, "Please specify dead-interval or hello-multiplier%s",
4948 VTY_NEWLINE);
4949 return CMD_WARNING;
4952 SET_IF_PARAM (params, v_wait);
4953 params->v_wait = seconds;
4955 /* Update timer values in neighbor structure. */
4956 if (nbr_str)
4958 struct ospf *ospf;
4959 if ((ospf = ospf_lookup()))
4961 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4962 if (oi)
4963 ospf_nbr_timer_update (oi);
4966 else
4968 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4969 if ((oi = rn->info))
4970 ospf_nbr_timer_update (oi);
4973 return CMD_SUCCESS;
4977 DEFUN (ip_ospf_dead_interval,
4978 ip_ospf_dead_interval_addr_cmd,
4979 "ip ospf dead-interval <1-65535> A.B.C.D",
4980 "IP Information\n"
4981 "OSPF interface commands\n"
4982 "Interval after which a neighbor is declared dead\n"
4983 "Seconds\n"
4984 "Address of interface\n")
4986 if (argc == 2)
4987 return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL);
4988 else
4989 return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL);
4992 ALIAS (ip_ospf_dead_interval,
4993 ip_ospf_dead_interval_cmd,
4994 "ip ospf dead-interval <1-65535>",
4995 "IP Information\n"
4996 "OSPF interface commands\n"
4997 "Interval after which a neighbor is declared dead\n"
4998 "Seconds\n")
5000 ALIAS (ip_ospf_dead_interval,
5001 ospf_dead_interval_cmd,
5002 "ospf dead-interval <1-65535>",
5003 "OSPF interface commands\n"
5004 "Interval after which a neighbor is declared dead\n"
5005 "Seconds\n")
5007 DEFUN (ip_ospf_dead_interval_minimal,
5008 ip_ospf_dead_interval_minimal_addr_cmd,
5009 "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
5010 "IP Information\n"
5011 "OSPF interface commands\n"
5012 "Interval after which a neighbor is declared dead\n"
5013 "Minimal 1s dead-interval with fast sub-second hellos\n"
5014 "Hello multiplier factor\n"
5015 "Number of Hellos to send each second\n"
5016 "Address of interface\n")
5018 if (argc == 2)
5019 return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]);
5020 else
5021 return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]);
5024 ALIAS (ip_ospf_dead_interval_minimal,
5025 ip_ospf_dead_interval_minimal_cmd,
5026 "ip ospf dead-interval minimal hello-multiplier <1-10>",
5027 "IP Information\n"
5028 "OSPF interface commands\n"
5029 "Interval after which a neighbor is declared dead\n"
5030 "Minimal 1s dead-interval with fast sub-second hellos\n"
5031 "Hello multiplier factor\n"
5032 "Number of Hellos to send each second\n")
5034 DEFUN (no_ip_ospf_dead_interval,
5035 no_ip_ospf_dead_interval_addr_cmd,
5036 "no ip ospf dead-interval A.B.C.D",
5037 NO_STR
5038 "IP Information\n"
5039 "OSPF interface commands\n"
5040 "Interval after which a neighbor is declared dead\n"
5041 "Address of interface")
5043 struct interface *ifp = vty->index;
5044 struct in_addr addr;
5045 int ret;
5046 struct ospf_if_params *params;
5047 struct ospf_interface *oi;
5048 struct route_node *rn;
5050 ifp = vty->index;
5051 params = IF_DEF_PARAMS (ifp);
5053 if (argc == 1)
5055 ret = inet_aton(argv[0], &addr);
5056 if (!ret)
5058 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5059 VTY_NEWLINE);
5060 return CMD_WARNING;
5063 params = ospf_lookup_if_params (ifp, addr);
5064 if (params == NULL)
5065 return CMD_SUCCESS;
5068 UNSET_IF_PARAM (params, v_wait);
5069 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
5071 UNSET_IF_PARAM (params, fast_hello);
5072 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
5074 if (params != IF_DEF_PARAMS (ifp))
5076 ospf_free_if_params (ifp, addr);
5077 ospf_if_update_params (ifp, addr);
5080 /* Update timer values in neighbor structure. */
5081 if (argc == 1)
5083 struct ospf *ospf;
5085 if ((ospf = ospf_lookup()))
5087 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
5088 if (oi)
5089 ospf_nbr_timer_update (oi);
5092 else
5094 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5095 if ((oi = rn->info))
5096 ospf_nbr_timer_update (oi);
5099 return CMD_SUCCESS;
5102 ALIAS (no_ip_ospf_dead_interval,
5103 no_ip_ospf_dead_interval_cmd,
5104 "no ip ospf dead-interval",
5105 NO_STR
5106 "IP Information\n"
5107 "OSPF interface commands\n"
5108 "Interval after which a neighbor is declared dead\n")
5110 ALIAS (no_ip_ospf_dead_interval,
5111 no_ospf_dead_interval_cmd,
5112 "no ospf dead-interval",
5113 NO_STR
5114 "OSPF interface commands\n"
5115 "Interval after which a neighbor is declared dead\n")
5117 DEFUN (ip_ospf_hello_interval,
5118 ip_ospf_hello_interval_addr_cmd,
5119 "ip ospf hello-interval <1-65535> A.B.C.D",
5120 "IP Information\n"
5121 "OSPF interface commands\n"
5122 "Time between HELLO packets\n"
5123 "Seconds\n"
5124 "Address of interface")
5126 struct interface *ifp = vty->index;
5127 u_int32_t seconds;
5128 struct in_addr addr;
5129 int ret;
5130 struct ospf_if_params *params;
5132 params = IF_DEF_PARAMS (ifp);
5134 seconds = strtol (argv[0], NULL, 10);
5136 /* HelloInterval range is <1-65535>. */
5137 if (seconds < 1 || seconds > 65535)
5139 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
5140 return CMD_WARNING;
5143 if (argc == 2)
5145 ret = inet_aton(argv[1], &addr);
5146 if (!ret)
5148 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5149 VTY_NEWLINE);
5150 return CMD_WARNING;
5153 params = ospf_get_if_params (ifp, addr);
5154 ospf_if_update_params (ifp, addr);
5157 SET_IF_PARAM (params, v_hello);
5158 params->v_hello = seconds;
5160 return CMD_SUCCESS;
5163 ALIAS (ip_ospf_hello_interval,
5164 ip_ospf_hello_interval_cmd,
5165 "ip ospf hello-interval <1-65535>",
5166 "IP Information\n"
5167 "OSPF interface commands\n"
5168 "Time between HELLO packets\n"
5169 "Seconds\n")
5171 ALIAS (ip_ospf_hello_interval,
5172 ospf_hello_interval_cmd,
5173 "ospf hello-interval <1-65535>",
5174 "OSPF interface commands\n"
5175 "Time between HELLO packets\n"
5176 "Seconds\n")
5178 DEFUN (no_ip_ospf_hello_interval,
5179 no_ip_ospf_hello_interval_addr_cmd,
5180 "no ip ospf hello-interval A.B.C.D",
5181 NO_STR
5182 "IP Information\n"
5183 "OSPF interface commands\n"
5184 "Time between HELLO packets\n"
5185 "Address of interface")
5187 struct interface *ifp = vty->index;
5188 struct in_addr addr;
5189 int ret;
5190 struct ospf_if_params *params;
5192 ifp = vty->index;
5193 params = IF_DEF_PARAMS (ifp);
5195 if (argc == 1)
5197 ret = inet_aton(argv[0], &addr);
5198 if (!ret)
5200 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5201 VTY_NEWLINE);
5202 return CMD_WARNING;
5205 params = ospf_lookup_if_params (ifp, addr);
5206 if (params == NULL)
5207 return CMD_SUCCESS;
5210 UNSET_IF_PARAM (params, v_hello);
5211 params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT;
5213 if (params != IF_DEF_PARAMS (ifp))
5215 ospf_free_if_params (ifp, addr);
5216 ospf_if_update_params (ifp, addr);
5219 return CMD_SUCCESS;
5222 ALIAS (no_ip_ospf_hello_interval,
5223 no_ip_ospf_hello_interval_cmd,
5224 "no ip ospf hello-interval",
5225 NO_STR
5226 "IP Information\n"
5227 "OSPF interface commands\n"
5228 "Time between HELLO packets\n")
5230 ALIAS (no_ip_ospf_hello_interval,
5231 no_ospf_hello_interval_cmd,
5232 "no ospf hello-interval",
5233 NO_STR
5234 "OSPF interface commands\n"
5235 "Time between HELLO packets\n")
5237 DEFUN (ip_ospf_network,
5238 ip_ospf_network_cmd,
5239 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5240 "IP Information\n"
5241 "OSPF interface commands\n"
5242 "Network type\n"
5243 "Specify OSPF broadcast multi-access network\n"
5244 "Specify OSPF NBMA network\n"
5245 "Specify OSPF point-to-multipoint network\n"
5246 "Specify OSPF point-to-point network\n")
5248 struct interface *ifp = vty->index;
5249 int old_type = IF_DEF_PARAMS (ifp)->type;
5250 struct route_node *rn;
5252 if (strncmp (argv[0], "b", 1) == 0)
5253 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
5254 else if (strncmp (argv[0], "n", 1) == 0)
5255 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
5256 else if (strncmp (argv[0], "point-to-m", 10) == 0)
5257 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
5258 else if (strncmp (argv[0], "point-to-p", 10) == 0)
5259 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
5261 if (IF_DEF_PARAMS (ifp)->type == old_type)
5262 return CMD_SUCCESS;
5264 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
5266 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5268 struct ospf_interface *oi = rn->info;
5270 if (!oi)
5271 continue;
5273 oi->type = IF_DEF_PARAMS (ifp)->type;
5275 if (oi->state > ISM_Down)
5277 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5278 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5282 return CMD_SUCCESS;
5285 ALIAS (ip_ospf_network,
5286 ospf_network_cmd,
5287 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5288 "OSPF interface commands\n"
5289 "Network type\n"
5290 "Specify OSPF broadcast multi-access network\n"
5291 "Specify OSPF NBMA network\n"
5292 "Specify OSPF point-to-multipoint network\n"
5293 "Specify OSPF point-to-point network\n")
5295 DEFUN (no_ip_ospf_network,
5296 no_ip_ospf_network_cmd,
5297 "no ip ospf network",
5298 NO_STR
5299 "IP Information\n"
5300 "OSPF interface commands\n"
5301 "Network type\n")
5303 struct interface *ifp = vty->index;
5304 int old_type = IF_DEF_PARAMS (ifp)->type;
5305 struct route_node *rn;
5307 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
5309 if (IF_DEF_PARAMS (ifp)->type == old_type)
5310 return CMD_SUCCESS;
5312 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5314 struct ospf_interface *oi = rn->info;
5316 if (!oi)
5317 continue;
5319 oi->type = IF_DEF_PARAMS (ifp)->type;
5321 if (oi->state > ISM_Down)
5323 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5324 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5328 return CMD_SUCCESS;
5331 ALIAS (no_ip_ospf_network,
5332 no_ospf_network_cmd,
5333 "no ospf network",
5334 NO_STR
5335 "OSPF interface commands\n"
5336 "Network type\n")
5338 DEFUN (ip_ospf_priority,
5339 ip_ospf_priority_addr_cmd,
5340 "ip ospf priority <0-255> A.B.C.D",
5341 "IP Information\n"
5342 "OSPF interface commands\n"
5343 "Router priority\n"
5344 "Priority\n"
5345 "Address of interface")
5347 struct interface *ifp = vty->index;
5348 u_int32_t priority;
5349 struct route_node *rn;
5350 struct in_addr addr;
5351 int ret;
5352 struct ospf_if_params *params;
5354 params = IF_DEF_PARAMS (ifp);
5356 priority = strtol (argv[0], NULL, 10);
5358 /* Router Priority range is <0-255>. */
5359 if (priority < 0 || priority > 255)
5361 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
5362 return CMD_WARNING;
5365 if (argc == 2)
5367 ret = inet_aton(argv[1], &addr);
5368 if (!ret)
5370 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5371 VTY_NEWLINE);
5372 return CMD_WARNING;
5375 params = ospf_get_if_params (ifp, addr);
5376 ospf_if_update_params (ifp, addr);
5379 SET_IF_PARAM (params, priority);
5380 params->priority = priority;
5382 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5384 struct ospf_interface *oi = rn->info;
5386 if (!oi)
5387 continue;
5390 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5392 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5393 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5397 return CMD_SUCCESS;
5400 ALIAS (ip_ospf_priority,
5401 ip_ospf_priority_cmd,
5402 "ip ospf priority <0-255>",
5403 "IP Information\n"
5404 "OSPF interface commands\n"
5405 "Router priority\n"
5406 "Priority\n")
5408 ALIAS (ip_ospf_priority,
5409 ospf_priority_cmd,
5410 "ospf priority <0-255>",
5411 "OSPF interface commands\n"
5412 "Router priority\n"
5413 "Priority\n")
5415 DEFUN (no_ip_ospf_priority,
5416 no_ip_ospf_priority_addr_cmd,
5417 "no ip ospf priority A.B.C.D",
5418 NO_STR
5419 "IP Information\n"
5420 "OSPF interface commands\n"
5421 "Router priority\n"
5422 "Address of interface")
5424 struct interface *ifp = vty->index;
5425 struct route_node *rn;
5426 struct in_addr addr;
5427 int ret;
5428 struct ospf_if_params *params;
5430 ifp = vty->index;
5431 params = IF_DEF_PARAMS (ifp);
5433 if (argc == 1)
5435 ret = inet_aton(argv[0], &addr);
5436 if (!ret)
5438 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5439 VTY_NEWLINE);
5440 return CMD_WARNING;
5443 params = ospf_lookup_if_params (ifp, addr);
5444 if (params == NULL)
5445 return CMD_SUCCESS;
5448 UNSET_IF_PARAM (params, priority);
5449 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
5451 if (params != IF_DEF_PARAMS (ifp))
5453 ospf_free_if_params (ifp, addr);
5454 ospf_if_update_params (ifp, addr);
5457 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5459 struct ospf_interface *oi = rn->info;
5461 if (!oi)
5462 continue;
5465 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5467 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5468 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5472 return CMD_SUCCESS;
5475 ALIAS (no_ip_ospf_priority,
5476 no_ip_ospf_priority_cmd,
5477 "no ip ospf priority",
5478 NO_STR
5479 "IP Information\n"
5480 "OSPF interface commands\n"
5481 "Router priority\n")
5483 ALIAS (no_ip_ospf_priority,
5484 no_ospf_priority_cmd,
5485 "no ospf priority",
5486 NO_STR
5487 "OSPF interface commands\n"
5488 "Router priority\n")
5490 DEFUN (ip_ospf_retransmit_interval,
5491 ip_ospf_retransmit_interval_addr_cmd,
5492 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5493 "IP Information\n"
5494 "OSPF interface commands\n"
5495 "Time between retransmitting lost link state advertisements\n"
5496 "Seconds\n"
5497 "Address of interface")
5499 struct interface *ifp = vty->index;
5500 u_int32_t seconds;
5501 struct in_addr addr;
5502 int ret;
5503 struct ospf_if_params *params;
5505 params = IF_DEF_PARAMS (ifp);
5506 seconds = strtol (argv[0], NULL, 10);
5508 /* Retransmit Interval range is <3-65535>. */
5509 if (seconds < 3 || seconds > 65535)
5511 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5512 return CMD_WARNING;
5516 if (argc == 2)
5518 ret = inet_aton(argv[1], &addr);
5519 if (!ret)
5521 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5522 VTY_NEWLINE);
5523 return CMD_WARNING;
5526 params = ospf_get_if_params (ifp, addr);
5527 ospf_if_update_params (ifp, addr);
5530 SET_IF_PARAM (params, retransmit_interval);
5531 params->retransmit_interval = seconds;
5533 return CMD_SUCCESS;
5536 ALIAS (ip_ospf_retransmit_interval,
5537 ip_ospf_retransmit_interval_cmd,
5538 "ip ospf retransmit-interval <3-65535>",
5539 "IP Information\n"
5540 "OSPF interface commands\n"
5541 "Time between retransmitting lost link state advertisements\n"
5542 "Seconds\n")
5544 ALIAS (ip_ospf_retransmit_interval,
5545 ospf_retransmit_interval_cmd,
5546 "ospf retransmit-interval <3-65535>",
5547 "OSPF interface commands\n"
5548 "Time between retransmitting lost link state advertisements\n"
5549 "Seconds\n")
5551 DEFUN (no_ip_ospf_retransmit_interval,
5552 no_ip_ospf_retransmit_interval_addr_cmd,
5553 "no ip ospf retransmit-interval A.B.C.D",
5554 NO_STR
5555 "IP Information\n"
5556 "OSPF interface commands\n"
5557 "Time between retransmitting lost link state advertisements\n"
5558 "Address of interface")
5560 struct interface *ifp = vty->index;
5561 struct in_addr addr;
5562 int ret;
5563 struct ospf_if_params *params;
5565 ifp = vty->index;
5566 params = IF_DEF_PARAMS (ifp);
5568 if (argc == 1)
5570 ret = inet_aton(argv[0], &addr);
5571 if (!ret)
5573 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5574 VTY_NEWLINE);
5575 return CMD_WARNING;
5578 params = ospf_lookup_if_params (ifp, addr);
5579 if (params == NULL)
5580 return CMD_SUCCESS;
5583 UNSET_IF_PARAM (params, retransmit_interval);
5584 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5586 if (params != IF_DEF_PARAMS (ifp))
5588 ospf_free_if_params (ifp, addr);
5589 ospf_if_update_params (ifp, addr);
5592 return CMD_SUCCESS;
5595 ALIAS (no_ip_ospf_retransmit_interval,
5596 no_ip_ospf_retransmit_interval_cmd,
5597 "no ip ospf retransmit-interval",
5598 NO_STR
5599 "IP Information\n"
5600 "OSPF interface commands\n"
5601 "Time between retransmitting lost link state advertisements\n")
5603 ALIAS (no_ip_ospf_retransmit_interval,
5604 no_ospf_retransmit_interval_cmd,
5605 "no ospf retransmit-interval",
5606 NO_STR
5607 "OSPF interface commands\n"
5608 "Time between retransmitting lost link state advertisements\n")
5610 DEFUN (ip_ospf_transmit_delay,
5611 ip_ospf_transmit_delay_addr_cmd,
5612 "ip ospf transmit-delay <1-65535> A.B.C.D",
5613 "IP Information\n"
5614 "OSPF interface commands\n"
5615 "Link state transmit delay\n"
5616 "Seconds\n"
5617 "Address of interface")
5619 struct interface *ifp = vty->index;
5620 u_int32_t seconds;
5621 struct in_addr addr;
5622 int ret;
5623 struct ospf_if_params *params;
5625 params = IF_DEF_PARAMS (ifp);
5626 seconds = strtol (argv[0], NULL, 10);
5628 /* Transmit Delay range is <1-65535>. */
5629 if (seconds < 1 || seconds > 65535)
5631 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5632 return CMD_WARNING;
5635 if (argc == 2)
5637 ret = inet_aton(argv[1], &addr);
5638 if (!ret)
5640 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5641 VTY_NEWLINE);
5642 return CMD_WARNING;
5645 params = ospf_get_if_params (ifp, addr);
5646 ospf_if_update_params (ifp, addr);
5649 SET_IF_PARAM (params, transmit_delay);
5650 params->transmit_delay = seconds;
5652 return CMD_SUCCESS;
5655 ALIAS (ip_ospf_transmit_delay,
5656 ip_ospf_transmit_delay_cmd,
5657 "ip ospf transmit-delay <1-65535>",
5658 "IP Information\n"
5659 "OSPF interface commands\n"
5660 "Link state transmit delay\n"
5661 "Seconds\n")
5663 ALIAS (ip_ospf_transmit_delay,
5664 ospf_transmit_delay_cmd,
5665 "ospf transmit-delay <1-65535>",
5666 "OSPF interface commands\n"
5667 "Link state transmit delay\n"
5668 "Seconds\n")
5670 DEFUN (no_ip_ospf_transmit_delay,
5671 no_ip_ospf_transmit_delay_addr_cmd,
5672 "no ip ospf transmit-delay A.B.C.D",
5673 NO_STR
5674 "IP Information\n"
5675 "OSPF interface commands\n"
5676 "Link state transmit delay\n"
5677 "Address of interface")
5679 struct interface *ifp = vty->index;
5680 struct in_addr addr;
5681 int ret;
5682 struct ospf_if_params *params;
5684 ifp = vty->index;
5685 params = IF_DEF_PARAMS (ifp);
5687 if (argc == 1)
5689 ret = inet_aton(argv[0], &addr);
5690 if (!ret)
5692 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5693 VTY_NEWLINE);
5694 return CMD_WARNING;
5697 params = ospf_lookup_if_params (ifp, addr);
5698 if (params == NULL)
5699 return CMD_SUCCESS;
5702 UNSET_IF_PARAM (params, transmit_delay);
5703 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5705 if (params != IF_DEF_PARAMS (ifp))
5707 ospf_free_if_params (ifp, addr);
5708 ospf_if_update_params (ifp, addr);
5711 return CMD_SUCCESS;
5714 ALIAS (no_ip_ospf_transmit_delay,
5715 no_ip_ospf_transmit_delay_cmd,
5716 "no ip ospf transmit-delay",
5717 NO_STR
5718 "IP Information\n"
5719 "OSPF interface commands\n"
5720 "Link state transmit delay\n")
5722 ALIAS (no_ip_ospf_transmit_delay,
5723 no_ospf_transmit_delay_cmd,
5724 "no ospf transmit-delay",
5725 NO_STR
5726 "OSPF interface commands\n"
5727 "Link state transmit delay\n")
5730 DEFUN (ospf_redistribute_source_metric_type,
5731 ospf_redistribute_source_metric_type_routemap_cmd,
5732 "redistribute " QUAGGA_REDIST_STR_OSPFD
5733 " metric <0-16777214> metric-type (1|2) route-map WORD",
5734 REDIST_STR
5735 QUAGGA_REDIST_HELP_STR_OSPFD
5736 "Metric for redistributed routes\n"
5737 "OSPF default metric\n"
5738 "OSPF exterior metric type for redistributed routes\n"
5739 "Set OSPF External Type 1 metrics\n"
5740 "Set OSPF External Type 2 metrics\n"
5741 "Route map reference\n"
5742 "Pointer to route-map entries\n")
5744 struct ospf *ospf = vty->index;
5745 int source;
5746 int type = -1;
5747 int metric = -1;
5749 /* Get distribute source. */
5750 if (!str2distribute_source (argv[0], &source))
5751 return CMD_WARNING;
5753 /* Get metric value. */
5754 if (argc >= 2)
5755 if (!str2metric (argv[1], &metric))
5756 return CMD_WARNING;
5758 /* Get metric type. */
5759 if (argc >= 3)
5760 if (!str2metric_type (argv[2], &type))
5761 return CMD_WARNING;
5763 if (argc == 4)
5764 ospf_routemap_set (ospf, source, argv[3]);
5765 else
5766 ospf_routemap_unset (ospf, source);
5768 return ospf_redistribute_set (ospf, source, type, metric);
5771 ALIAS (ospf_redistribute_source_metric_type,
5772 ospf_redistribute_source_metric_type_cmd,
5773 "redistribute " QUAGGA_REDIST_STR_OSPFD
5774 " metric <0-16777214> metric-type (1|2)",
5775 REDIST_STR
5776 QUAGGA_REDIST_HELP_STR_OSPFD
5777 "Metric for redistributed routes\n"
5778 "OSPF default metric\n"
5779 "OSPF exterior metric type for redistributed routes\n"
5780 "Set OSPF External Type 1 metrics\n"
5781 "Set OSPF External Type 2 metrics\n")
5783 ALIAS (ospf_redistribute_source_metric_type,
5784 ospf_redistribute_source_metric_cmd,
5785 "redistribute " QUAGGA_REDIST_STR_OSPFD " metric <0-16777214>",
5786 REDIST_STR
5787 QUAGGA_REDIST_HELP_STR_OSPFD
5788 "Metric for redistributed routes\n"
5789 "OSPF default metric\n")
5791 DEFUN (ospf_redistribute_source_type_metric,
5792 ospf_redistribute_source_type_metric_routemap_cmd,
5793 "redistribute " QUAGGA_REDIST_STR_OSPFD
5794 " metric-type (1|2) metric <0-16777214> route-map WORD",
5795 REDIST_STR
5796 QUAGGA_REDIST_HELP_STR_OSPFD
5797 "OSPF exterior metric type for redistributed routes\n"
5798 "Set OSPF External Type 1 metrics\n"
5799 "Set OSPF External Type 2 metrics\n"
5800 "Metric for redistributed routes\n"
5801 "OSPF default metric\n"
5802 "Route map reference\n"
5803 "Pointer to route-map entries\n")
5805 struct ospf *ospf = vty->index;
5806 int source;
5807 int type = -1;
5808 int metric = -1;
5810 /* Get distribute source. */
5811 if (!str2distribute_source (argv[0], &source))
5812 return CMD_WARNING;
5814 /* Get metric value. */
5815 if (argc >= 2)
5816 if (!str2metric_type (argv[1], &type))
5817 return CMD_WARNING;
5819 /* Get metric type. */
5820 if (argc >= 3)
5821 if (!str2metric (argv[2], &metric))
5822 return CMD_WARNING;
5824 if (argc == 4)
5825 ospf_routemap_set (ospf, source, argv[3]);
5826 else
5827 ospf_routemap_unset (ospf, source);
5829 return ospf_redistribute_set (ospf, source, type, metric);
5832 ALIAS (ospf_redistribute_source_type_metric,
5833 ospf_redistribute_source_type_metric_cmd,
5834 "redistribute " QUAGGA_REDIST_STR_OSPFD
5835 " metric-type (1|2) metric <0-16777214>",
5836 REDIST_STR
5837 QUAGGA_REDIST_HELP_STR_OSPFD
5838 "OSPF exterior metric type for redistributed routes\n"
5839 "Set OSPF External Type 1 metrics\n"
5840 "Set OSPF External Type 2 metrics\n"
5841 "Metric for redistributed routes\n"
5842 "OSPF default metric\n")
5844 ALIAS (ospf_redistribute_source_type_metric,
5845 ospf_redistribute_source_type_cmd,
5846 "redistribute " QUAGGA_REDIST_STR_OSPFD " metric-type (1|2)",
5847 REDIST_STR
5848 QUAGGA_REDIST_HELP_STR_OSPFD
5849 "OSPF exterior metric type for redistributed routes\n"
5850 "Set OSPF External Type 1 metrics\n"
5851 "Set OSPF External Type 2 metrics\n")
5853 ALIAS (ospf_redistribute_source_type_metric,
5854 ospf_redistribute_source_cmd,
5855 "redistribute " QUAGGA_REDIST_STR_OSPFD,
5856 REDIST_STR
5857 QUAGGA_REDIST_HELP_STR_OSPFD)
5859 DEFUN (ospf_redistribute_source_metric_routemap,
5860 ospf_redistribute_source_metric_routemap_cmd,
5861 "redistribute " QUAGGA_REDIST_STR_OSPFD
5862 " metric <0-16777214> route-map WORD",
5863 REDIST_STR
5864 QUAGGA_REDIST_HELP_STR_OSPFD
5865 "Metric for redistributed routes\n"
5866 "OSPF default metric\n"
5867 "Route map reference\n"
5868 "Pointer to route-map entries\n")
5870 struct ospf *ospf = vty->index;
5871 int source;
5872 int metric = -1;
5874 /* Get distribute source. */
5875 if (!str2distribute_source (argv[0], &source))
5876 return CMD_WARNING;
5878 /* Get metric value. */
5879 if (argc >= 2)
5880 if (!str2metric (argv[1], &metric))
5881 return CMD_WARNING;
5883 if (argc == 3)
5884 ospf_routemap_set (ospf, source, argv[2]);
5885 else
5886 ospf_routemap_unset (ospf, source);
5888 return ospf_redistribute_set (ospf, source, -1, metric);
5891 DEFUN (ospf_redistribute_source_type_routemap,
5892 ospf_redistribute_source_type_routemap_cmd,
5893 "redistribute " QUAGGA_REDIST_STR_OSPFD
5894 " metric-type (1|2) route-map WORD",
5895 REDIST_STR
5896 QUAGGA_REDIST_HELP_STR_OSPFD
5897 "OSPF exterior metric type for redistributed routes\n"
5898 "Set OSPF External Type 1 metrics\n"
5899 "Set OSPF External Type 2 metrics\n"
5900 "Route map reference\n"
5901 "Pointer to route-map entries\n")
5903 struct ospf *ospf = vty->index;
5904 int source;
5905 int type = -1;
5907 /* Get distribute source. */
5908 if (!str2distribute_source (argv[0], &source))
5909 return CMD_WARNING;
5911 /* Get metric value. */
5912 if (argc >= 2)
5913 if (!str2metric_type (argv[1], &type))
5914 return CMD_WARNING;
5916 if (argc == 3)
5917 ospf_routemap_set (ospf, source, argv[2]);
5918 else
5919 ospf_routemap_unset (ospf, source);
5921 return ospf_redistribute_set (ospf, source, type, -1);
5924 DEFUN (ospf_redistribute_source_routemap,
5925 ospf_redistribute_source_routemap_cmd,
5926 "redistribute " QUAGGA_REDIST_STR_OSPFD " route-map WORD",
5927 REDIST_STR
5928 QUAGGA_REDIST_HELP_STR_OSPFD
5929 "Route map reference\n"
5930 "Pointer to route-map entries\n")
5932 struct ospf *ospf = vty->index;
5933 int source;
5935 /* Get distribute source. */
5936 if (!str2distribute_source (argv[0], &source))
5937 return CMD_WARNING;
5939 if (argc == 2)
5940 ospf_routemap_set (ospf, source, argv[1]);
5941 else
5942 ospf_routemap_unset (ospf, source);
5944 return ospf_redistribute_set (ospf, source, -1, -1);
5947 DEFUN (no_ospf_redistribute_source,
5948 no_ospf_redistribute_source_cmd,
5949 "no redistribute " QUAGGA_REDIST_STR_OSPFD,
5950 NO_STR
5951 REDIST_STR
5952 QUAGGA_REDIST_HELP_STR_OSPFD)
5954 struct ospf *ospf = vty->index;
5955 int source;
5957 if (!str2distribute_source (argv[0], &source))
5958 return CMD_WARNING;
5960 ospf_routemap_unset (ospf, source);
5961 return ospf_redistribute_unset (ospf, source);
5964 DEFUN (ospf_distribute_list_out,
5965 ospf_distribute_list_out_cmd,
5966 "distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
5967 "Filter networks in routing updates\n"
5968 "Access-list name\n"
5969 OUT_STR
5970 QUAGGA_REDIST_HELP_STR_OSPFD)
5972 struct ospf *ospf = vty->index;
5973 int source;
5975 /* Get distribute source. */
5976 if (!str2distribute_source (argv[1], &source))
5977 return CMD_WARNING;
5979 return ospf_distribute_list_out_set (ospf, source, argv[0]);
5982 DEFUN (no_ospf_distribute_list_out,
5983 no_ospf_distribute_list_out_cmd,
5984 "no distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
5985 NO_STR
5986 "Filter networks in routing updates\n"
5987 "Access-list name\n"
5988 OUT_STR
5989 QUAGGA_REDIST_HELP_STR_OSPFD)
5991 struct ospf *ospf = vty->index;
5992 int source;
5994 if (!str2distribute_source (argv[1], &source))
5995 return CMD_WARNING;
5997 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
6000 /* Default information originate. */
6001 DEFUN (ospf_default_information_originate_metric_type_routemap,
6002 ospf_default_information_originate_metric_type_routemap_cmd,
6003 "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD",
6004 "Control distribution of default information\n"
6005 "Distribute a default route\n"
6006 "OSPF default metric\n"
6007 "OSPF metric\n"
6008 "OSPF metric type for default routes\n"
6009 "Set OSPF External Type 1 metrics\n"
6010 "Set OSPF External Type 2 metrics\n"
6011 "Route map reference\n"
6012 "Pointer to route-map entries\n")
6014 struct ospf *ospf = vty->index;
6015 int type = -1;
6016 int metric = -1;
6018 /* Get metric value. */
6019 if (argc >= 1)
6020 if (!str2metric (argv[0], &metric))
6021 return CMD_WARNING;
6023 /* Get metric type. */
6024 if (argc >= 2)
6025 if (!str2metric_type (argv[1], &type))
6026 return CMD_WARNING;
6028 if (argc == 3)
6029 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
6030 else
6031 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6033 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6034 type, metric);
6037 ALIAS (ospf_default_information_originate_metric_type_routemap,
6038 ospf_default_information_originate_metric_type_cmd,
6039 "default-information originate metric <0-16777214> metric-type (1|2)",
6040 "Control distribution of default information\n"
6041 "Distribute a default route\n"
6042 "OSPF default metric\n"
6043 "OSPF metric\n"
6044 "OSPF metric type for default routes\n"
6045 "Set OSPF External Type 1 metrics\n"
6046 "Set OSPF External Type 2 metrics\n")
6048 ALIAS (ospf_default_information_originate_metric_type_routemap,
6049 ospf_default_information_originate_metric_cmd,
6050 "default-information originate metric <0-16777214>",
6051 "Control distribution of default information\n"
6052 "Distribute a default route\n"
6053 "OSPF default metric\n"
6054 "OSPF metric\n")
6056 ALIAS (ospf_default_information_originate_metric_type_routemap,
6057 ospf_default_information_originate_cmd,
6058 "default-information originate",
6059 "Control distribution of default information\n"
6060 "Distribute a default route\n")
6062 /* Default information originate. */
6063 DEFUN (ospf_default_information_originate_metric_routemap,
6064 ospf_default_information_originate_metric_routemap_cmd,
6065 "default-information originate metric <0-16777214> route-map WORD",
6066 "Control distribution of default information\n"
6067 "Distribute a default route\n"
6068 "OSPF default metric\n"
6069 "OSPF metric\n"
6070 "Route map reference\n"
6071 "Pointer to route-map entries\n")
6073 struct ospf *ospf = vty->index;
6074 int metric = -1;
6076 /* Get metric value. */
6077 if (argc >= 1)
6078 if (!str2metric (argv[0], &metric))
6079 return CMD_WARNING;
6081 if (argc == 2)
6082 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
6083 else
6084 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6086 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6087 -1, metric);
6090 /* Default information originate. */
6091 DEFUN (ospf_default_information_originate_routemap,
6092 ospf_default_information_originate_routemap_cmd,
6093 "default-information originate route-map WORD",
6094 "Control distribution of default information\n"
6095 "Distribute a default route\n"
6096 "Route map reference\n"
6097 "Pointer to route-map entries\n")
6099 struct ospf *ospf = vty->index;
6101 if (argc == 1)
6102 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
6103 else
6104 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6106 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1);
6109 DEFUN (ospf_default_information_originate_type_metric_routemap,
6110 ospf_default_information_originate_type_metric_routemap_cmd,
6111 "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD",
6112 "Control distribution of default information\n"
6113 "Distribute a default route\n"
6114 "OSPF metric type for default routes\n"
6115 "Set OSPF External Type 1 metrics\n"
6116 "Set OSPF External Type 2 metrics\n"
6117 "OSPF default metric\n"
6118 "OSPF metric\n"
6119 "Route map reference\n"
6120 "Pointer to route-map entries\n")
6122 struct ospf *ospf = vty->index;
6123 int type = -1;
6124 int metric = -1;
6126 /* Get metric type. */
6127 if (argc >= 1)
6128 if (!str2metric_type (argv[0], &type))
6129 return CMD_WARNING;
6131 /* Get metric value. */
6132 if (argc >= 2)
6133 if (!str2metric (argv[1], &metric))
6134 return CMD_WARNING;
6136 if (argc == 3)
6137 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
6138 else
6139 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6141 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6142 type, metric);
6145 ALIAS (ospf_default_information_originate_type_metric_routemap,
6146 ospf_default_information_originate_type_metric_cmd,
6147 "default-information originate metric-type (1|2) metric <0-16777214>",
6148 "Control distribution of default information\n"
6149 "Distribute a default route\n"
6150 "OSPF metric type for default routes\n"
6151 "Set OSPF External Type 1 metrics\n"
6152 "Set OSPF External Type 2 metrics\n"
6153 "OSPF default metric\n"
6154 "OSPF metric\n")
6156 ALIAS (ospf_default_information_originate_type_metric_routemap,
6157 ospf_default_information_originate_type_cmd,
6158 "default-information originate metric-type (1|2)",
6159 "Control distribution of default information\n"
6160 "Distribute a default route\n"
6161 "OSPF metric type for default routes\n"
6162 "Set OSPF External Type 1 metrics\n"
6163 "Set OSPF External Type 2 metrics\n")
6165 DEFUN (ospf_default_information_originate_type_routemap,
6166 ospf_default_information_originate_type_routemap_cmd,
6167 "default-information originate metric-type (1|2) route-map WORD",
6168 "Control distribution of default information\n"
6169 "Distribute a default route\n"
6170 "OSPF metric type for default routes\n"
6171 "Set OSPF External Type 1 metrics\n"
6172 "Set OSPF External Type 2 metrics\n"
6173 "Route map reference\n"
6174 "Pointer to route-map entries\n")
6176 struct ospf *ospf = vty->index;
6177 int type = -1;
6179 /* Get metric type. */
6180 if (argc >= 1)
6181 if (!str2metric_type (argv[0], &type))
6182 return CMD_WARNING;
6184 if (argc == 2)
6185 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
6186 else
6187 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6189 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6190 type, -1);
6193 DEFUN (ospf_default_information_originate_always_metric_type_routemap,
6194 ospf_default_information_originate_always_metric_type_routemap_cmd,
6195 "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD",
6196 "Control distribution of default information\n"
6197 "Distribute a default route\n"
6198 "Always advertise default route\n"
6199 "OSPF default metric\n"
6200 "OSPF metric\n"
6201 "OSPF metric type for default routes\n"
6202 "Set OSPF External Type 1 metrics\n"
6203 "Set OSPF External Type 2 metrics\n"
6204 "Route map reference\n"
6205 "Pointer to route-map entries\n")
6207 struct ospf *ospf = vty->index;
6208 int type = -1;
6209 int metric = -1;
6211 /* Get metric value. */
6212 if (argc >= 1)
6213 if (!str2metric (argv[0], &metric))
6214 return CMD_WARNING;
6216 /* Get metric type. */
6217 if (argc >= 2)
6218 if (!str2metric_type (argv[1], &type))
6219 return CMD_WARNING;
6221 if (argc == 3)
6222 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
6223 else
6224 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6226 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
6227 type, metric);
6230 ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6231 ospf_default_information_originate_always_metric_type_cmd,
6232 "default-information originate always metric <0-16777214> metric-type (1|2)",
6233 "Control distribution of default information\n"
6234 "Distribute a default route\n"
6235 "Always advertise default route\n"
6236 "OSPF default metric\n"
6237 "OSPF metric\n"
6238 "OSPF metric type for default routes\n"
6239 "Set OSPF External Type 1 metrics\n"
6240 "Set OSPF External Type 2 metrics\n")
6242 ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6243 ospf_default_information_originate_always_metric_cmd,
6244 "default-information originate always metric <0-16777214>",
6245 "Control distribution of default information\n"
6246 "Distribute a default route\n"
6247 "Always advertise default route\n"
6248 "OSPF default metric\n"
6249 "OSPF metric\n"
6250 "OSPF metric type for default routes\n")
6252 ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6253 ospf_default_information_originate_always_cmd,
6254 "default-information originate always",
6255 "Control distribution of default information\n"
6256 "Distribute a default route\n"
6257 "Always advertise default route\n")
6259 DEFUN (ospf_default_information_originate_always_metric_routemap,
6260 ospf_default_information_originate_always_metric_routemap_cmd,
6261 "default-information originate always metric <0-16777214> route-map WORD",
6262 "Control distribution of default information\n"
6263 "Distribute a default route\n"
6264 "Always advertise default route\n"
6265 "OSPF default metric\n"
6266 "OSPF metric\n"
6267 "Route map reference\n"
6268 "Pointer to route-map entries\n")
6270 struct ospf *ospf = vty->index;
6271 int metric = -1;
6273 /* Get metric value. */
6274 if (argc >= 1)
6275 if (!str2metric (argv[0], &metric))
6276 return CMD_WARNING;
6278 if (argc == 2)
6279 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
6280 else
6281 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6283 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
6284 -1, metric);
6287 DEFUN (ospf_default_information_originate_always_routemap,
6288 ospf_default_information_originate_always_routemap_cmd,
6289 "default-information originate always route-map WORD",
6290 "Control distribution of default information\n"
6291 "Distribute a default route\n"
6292 "Always advertise default route\n"
6293 "Route map reference\n"
6294 "Pointer to route-map entries\n")
6296 struct ospf *ospf = vty->index;
6298 if (argc == 1)
6299 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
6300 else
6301 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6303 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1);
6306 DEFUN (ospf_default_information_originate_always_type_metric_routemap,
6307 ospf_default_information_originate_always_type_metric_routemap_cmd,
6308 "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD",
6309 "Control distribution of default information\n"
6310 "Distribute a default route\n"
6311 "Always advertise default route\n"
6312 "OSPF metric type for default routes\n"
6313 "Set OSPF External Type 1 metrics\n"
6314 "Set OSPF External Type 2 metrics\n"
6315 "OSPF default metric\n"
6316 "OSPF metric\n"
6317 "Route map reference\n"
6318 "Pointer to route-map entries\n")
6320 struct ospf *ospf = vty->index;
6321 int type = -1;
6322 int metric = -1;
6324 /* Get metric type. */
6325 if (argc >= 1)
6326 if (!str2metric_type (argv[0], &type))
6327 return CMD_WARNING;
6329 /* Get metric value. */
6330 if (argc >= 2)
6331 if (!str2metric (argv[1], &metric))
6332 return CMD_WARNING;
6334 if (argc == 3)
6335 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
6336 else
6337 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6339 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
6340 type, metric);
6343 ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6344 ospf_default_information_originate_always_type_metric_cmd,
6345 "default-information originate always metric-type (1|2) metric <0-16777214>",
6346 "Control distribution of default information\n"
6347 "Distribute a default route\n"
6348 "Always advertise default route\n"
6349 "OSPF metric type for default routes\n"
6350 "Set OSPF External Type 1 metrics\n"
6351 "Set OSPF External Type 2 metrics\n"
6352 "OSPF default metric\n"
6353 "OSPF metric\n")
6355 ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6356 ospf_default_information_originate_always_type_cmd,
6357 "default-information originate always metric-type (1|2)",
6358 "Control distribution of default information\n"
6359 "Distribute a default route\n"
6360 "Always advertise default route\n"
6361 "OSPF metric type for default routes\n"
6362 "Set OSPF External Type 1 metrics\n"
6363 "Set OSPF External Type 2 metrics\n")
6365 DEFUN (ospf_default_information_originate_always_type_routemap,
6366 ospf_default_information_originate_always_type_routemap_cmd,
6367 "default-information originate always metric-type (1|2) route-map WORD",
6368 "Control distribution of default information\n"
6369 "Distribute a default route\n"
6370 "Always advertise default route\n"
6371 "OSPF metric type for default routes\n"
6372 "Set OSPF External Type 1 metrics\n"
6373 "Set OSPF External Type 2 metrics\n"
6374 "Route map reference\n"
6375 "Pointer to route-map entries\n")
6377 struct ospf *ospf = vty->index;
6378 int type = -1;
6380 /* Get metric type. */
6381 if (argc >= 1)
6382 if (!str2metric_type (argv[0], &type))
6383 return CMD_WARNING;
6385 if (argc == 2)
6386 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
6387 else
6388 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6390 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
6391 type, -1);
6394 DEFUN (no_ospf_default_information_originate,
6395 no_ospf_default_information_originate_cmd,
6396 "no default-information originate",
6397 NO_STR
6398 "Control distribution of default information\n"
6399 "Distribute a default route\n")
6401 struct ospf *ospf = vty->index;
6402 struct prefix_ipv4 p;
6404 p.family = AF_INET;
6405 p.prefix.s_addr = 0;
6406 p.prefixlen = 0;
6408 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0);
6410 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6411 ospf_external_info_delete (DEFAULT_ROUTE, p);
6412 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6413 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6416 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6417 return ospf_redistribute_default_unset (ospf);
6420 DEFUN (ospf_default_metric,
6421 ospf_default_metric_cmd,
6422 "default-metric <0-16777214>",
6423 "Set metric of redistributed routes\n"
6424 "Default metric\n")
6426 struct ospf *ospf = vty->index;
6427 int metric = -1;
6429 if (!str2metric (argv[0], &metric))
6430 return CMD_WARNING;
6432 ospf->default_metric = metric;
6434 return CMD_SUCCESS;
6437 DEFUN (no_ospf_default_metric,
6438 no_ospf_default_metric_cmd,
6439 "no default-metric",
6440 NO_STR
6441 "Set metric of redistributed routes\n")
6443 struct ospf *ospf = vty->index;
6445 ospf->default_metric = -1;
6447 return CMD_SUCCESS;
6450 ALIAS (no_ospf_default_metric,
6451 no_ospf_default_metric_val_cmd,
6452 "no default-metric <0-16777214>",
6453 NO_STR
6454 "Set metric of redistributed routes\n"
6455 "Default metric\n")
6457 DEFUN (ospf_distance,
6458 ospf_distance_cmd,
6459 "distance <1-255>",
6460 "Define an administrative distance\n"
6461 "OSPF Administrative distance\n")
6463 struct ospf *ospf = vty->index;
6465 ospf->distance_all = atoi (argv[0]);
6467 return CMD_SUCCESS;
6470 DEFUN (no_ospf_distance,
6471 no_ospf_distance_cmd,
6472 "no distance <1-255>",
6473 NO_STR
6474 "Define an administrative distance\n"
6475 "OSPF Administrative distance\n")
6477 struct ospf *ospf = vty->index;
6479 ospf->distance_all = 0;
6481 return CMD_SUCCESS;
6484 DEFUN (no_ospf_distance_ospf,
6485 no_ospf_distance_ospf_cmd,
6486 "no distance ospf",
6487 NO_STR
6488 "Define an administrative distance\n"
6489 "OSPF Administrative distance\n"
6490 "OSPF Distance\n")
6492 struct ospf *ospf = vty->index;
6494 ospf->distance_intra = 0;
6495 ospf->distance_inter = 0;
6496 ospf->distance_external = 0;
6498 return CMD_SUCCESS;
6501 DEFUN (ospf_distance_ospf_intra,
6502 ospf_distance_ospf_intra_cmd,
6503 "distance ospf intra-area <1-255>",
6504 "Define an administrative distance\n"
6505 "OSPF Administrative distance\n"
6506 "Intra-area routes\n"
6507 "Distance for intra-area routes\n")
6509 struct ospf *ospf = vty->index;
6511 ospf->distance_intra = atoi (argv[0]);
6513 return CMD_SUCCESS;
6516 DEFUN (ospf_distance_ospf_intra_inter,
6517 ospf_distance_ospf_intra_inter_cmd,
6518 "distance ospf intra-area <1-255> inter-area <1-255>",
6519 "Define an administrative distance\n"
6520 "OSPF Administrative distance\n"
6521 "Intra-area routes\n"
6522 "Distance for intra-area routes\n"
6523 "Inter-area routes\n"
6524 "Distance for inter-area routes\n")
6526 struct ospf *ospf = vty->index;
6528 ospf->distance_intra = atoi (argv[0]);
6529 ospf->distance_inter = atoi (argv[1]);
6531 return CMD_SUCCESS;
6534 DEFUN (ospf_distance_ospf_intra_external,
6535 ospf_distance_ospf_intra_external_cmd,
6536 "distance ospf intra-area <1-255> external <1-255>",
6537 "Define an administrative distance\n"
6538 "OSPF Administrative distance\n"
6539 "Intra-area routes\n"
6540 "Distance for intra-area routes\n"
6541 "External routes\n"
6542 "Distance for external routes\n")
6544 struct ospf *ospf = vty->index;
6546 ospf->distance_intra = atoi (argv[0]);
6547 ospf->distance_external = atoi (argv[1]);
6549 return CMD_SUCCESS;
6552 DEFUN (ospf_distance_ospf_intra_inter_external,
6553 ospf_distance_ospf_intra_inter_external_cmd,
6554 "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>",
6555 "Define an administrative distance\n"
6556 "OSPF Administrative distance\n"
6557 "Intra-area routes\n"
6558 "Distance for intra-area routes\n"
6559 "Inter-area routes\n"
6560 "Distance for inter-area routes\n"
6561 "External routes\n"
6562 "Distance for external routes\n")
6564 struct ospf *ospf = vty->index;
6566 ospf->distance_intra = atoi (argv[0]);
6567 ospf->distance_inter = atoi (argv[1]);
6568 ospf->distance_external = atoi (argv[2]);
6570 return CMD_SUCCESS;
6573 DEFUN (ospf_distance_ospf_intra_external_inter,
6574 ospf_distance_ospf_intra_external_inter_cmd,
6575 "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>",
6576 "Define an administrative distance\n"
6577 "OSPF Administrative distance\n"
6578 "Intra-area routes\n"
6579 "Distance for intra-area routes\n"
6580 "External routes\n"
6581 "Distance for external routes\n"
6582 "Inter-area routes\n"
6583 "Distance for inter-area routes\n")
6585 struct ospf *ospf = vty->index;
6587 ospf->distance_intra = atoi (argv[0]);
6588 ospf->distance_external = atoi (argv[1]);
6589 ospf->distance_inter = atoi (argv[2]);
6591 return CMD_SUCCESS;
6594 DEFUN (ospf_distance_ospf_inter,
6595 ospf_distance_ospf_inter_cmd,
6596 "distance ospf inter-area <1-255>",
6597 "Define an administrative distance\n"
6598 "OSPF Administrative distance\n"
6599 "Inter-area routes\n"
6600 "Distance for inter-area routes\n")
6602 struct ospf *ospf = vty->index;
6604 ospf->distance_inter = atoi (argv[0]);
6606 return CMD_SUCCESS;
6609 DEFUN (ospf_distance_ospf_inter_intra,
6610 ospf_distance_ospf_inter_intra_cmd,
6611 "distance ospf inter-area <1-255> intra-area <1-255>",
6612 "Define an administrative distance\n"
6613 "OSPF Administrative distance\n"
6614 "Inter-area routes\n"
6615 "Distance for inter-area routes\n"
6616 "Intra-area routes\n"
6617 "Distance for intra-area routes\n")
6619 struct ospf *ospf = vty->index;
6621 ospf->distance_inter = atoi (argv[0]);
6622 ospf->distance_intra = atoi (argv[1]);
6624 return CMD_SUCCESS;
6627 DEFUN (ospf_distance_ospf_inter_external,
6628 ospf_distance_ospf_inter_external_cmd,
6629 "distance ospf inter-area <1-255> external <1-255>",
6630 "Define an administrative distance\n"
6631 "OSPF Administrative distance\n"
6632 "Inter-area routes\n"
6633 "Distance for inter-area routes\n"
6634 "External routes\n"
6635 "Distance for external routes\n")
6637 struct ospf *ospf = vty->index;
6639 ospf->distance_inter = atoi (argv[0]);
6640 ospf->distance_external = atoi (argv[1]);
6642 return CMD_SUCCESS;
6645 DEFUN (ospf_distance_ospf_inter_intra_external,
6646 ospf_distance_ospf_inter_intra_external_cmd,
6647 "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>",
6648 "Define an administrative distance\n"
6649 "OSPF Administrative distance\n"
6650 "Inter-area routes\n"
6651 "Distance for inter-area routes\n"
6652 "Intra-area routes\n"
6653 "Distance for intra-area routes\n"
6654 "External routes\n"
6655 "Distance for external routes\n")
6657 struct ospf *ospf = vty->index;
6659 ospf->distance_inter = atoi (argv[0]);
6660 ospf->distance_intra = atoi (argv[1]);
6661 ospf->distance_external = atoi (argv[2]);
6663 return CMD_SUCCESS;
6666 DEFUN (ospf_distance_ospf_inter_external_intra,
6667 ospf_distance_ospf_inter_external_intra_cmd,
6668 "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>",
6669 "Define an administrative distance\n"
6670 "OSPF Administrative distance\n"
6671 "Inter-area routes\n"
6672 "Distance for inter-area routes\n"
6673 "External routes\n"
6674 "Distance for external routes\n"
6675 "Intra-area routes\n"
6676 "Distance for intra-area routes\n")
6678 struct ospf *ospf = vty->index;
6680 ospf->distance_inter = atoi (argv[0]);
6681 ospf->distance_external = atoi (argv[1]);
6682 ospf->distance_intra = atoi (argv[2]);
6684 return CMD_SUCCESS;
6687 DEFUN (ospf_distance_ospf_external,
6688 ospf_distance_ospf_external_cmd,
6689 "distance ospf external <1-255>",
6690 "Define an administrative distance\n"
6691 "OSPF Administrative distance\n"
6692 "External routes\n"
6693 "Distance for external routes\n")
6695 struct ospf *ospf = vty->index;
6697 ospf->distance_external = atoi (argv[0]);
6699 return CMD_SUCCESS;
6702 DEFUN (ospf_distance_ospf_external_intra,
6703 ospf_distance_ospf_external_intra_cmd,
6704 "distance ospf external <1-255> intra-area <1-255>",
6705 "Define an administrative distance\n"
6706 "OSPF Administrative distance\n"
6707 "External routes\n"
6708 "Distance for external routes\n"
6709 "Intra-area routes\n"
6710 "Distance for intra-area routes\n")
6712 struct ospf *ospf = vty->index;
6714 ospf->distance_external = atoi (argv[0]);
6715 ospf->distance_intra = atoi (argv[1]);
6717 return CMD_SUCCESS;
6720 DEFUN (ospf_distance_ospf_external_inter,
6721 ospf_distance_ospf_external_inter_cmd,
6722 "distance ospf external <1-255> inter-area <1-255>",
6723 "Define an administrative distance\n"
6724 "OSPF Administrative distance\n"
6725 "External routes\n"
6726 "Distance for external routes\n"
6727 "Inter-area routes\n"
6728 "Distance for inter-area routes\n")
6730 struct ospf *ospf = vty->index;
6732 ospf->distance_external = atoi (argv[0]);
6733 ospf->distance_inter = atoi (argv[1]);
6735 return CMD_SUCCESS;
6738 DEFUN (ospf_distance_ospf_external_intra_inter,
6739 ospf_distance_ospf_external_intra_inter_cmd,
6740 "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>",
6741 "Define an administrative distance\n"
6742 "OSPF Administrative distance\n"
6743 "External routes\n"
6744 "Distance for external routes\n"
6745 "Intra-area routes\n"
6746 "Distance for intra-area routes\n"
6747 "Inter-area routes\n"
6748 "Distance for inter-area routes\n")
6750 struct ospf *ospf = vty->index;
6752 ospf->distance_external = atoi (argv[0]);
6753 ospf->distance_intra = atoi (argv[1]);
6754 ospf->distance_inter = atoi (argv[2]);
6756 return CMD_SUCCESS;
6759 DEFUN (ospf_distance_ospf_external_inter_intra,
6760 ospf_distance_ospf_external_inter_intra_cmd,
6761 "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>",
6762 "Define an administrative distance\n"
6763 "OSPF Administrative distance\n"
6764 "External routes\n"
6765 "Distance for external routes\n"
6766 "Inter-area routes\n"
6767 "Distance for inter-area routes\n"
6768 "Intra-area routes\n"
6769 "Distance for intra-area routes\n")
6771 struct ospf *ospf = vty->index;
6773 ospf->distance_external = atoi (argv[0]);
6774 ospf->distance_inter = atoi (argv[1]);
6775 ospf->distance_intra = atoi (argv[2]);
6777 return CMD_SUCCESS;
6780 DEFUN (ospf_distance_source,
6781 ospf_distance_source_cmd,
6782 "distance <1-255> A.B.C.D/M",
6783 "Administrative distance\n"
6784 "Distance value\n"
6785 "IP source prefix\n")
6787 struct ospf *ospf = vty->index;
6789 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
6791 return CMD_SUCCESS;
6794 DEFUN (no_ospf_distance_source,
6795 no_ospf_distance_source_cmd,
6796 "no distance <1-255> A.B.C.D/M",
6797 NO_STR
6798 "Administrative distance\n"
6799 "Distance value\n"
6800 "IP source prefix\n")
6802 struct ospf *ospf = vty->index;
6804 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6806 return CMD_SUCCESS;
6809 DEFUN (ospf_distance_source_access_list,
6810 ospf_distance_source_access_list_cmd,
6811 "distance <1-255> A.B.C.D/M WORD",
6812 "Administrative distance\n"
6813 "Distance value\n"
6814 "IP source prefix\n"
6815 "Access list name\n")
6817 struct ospf *ospf = vty->index;
6819 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6821 return CMD_SUCCESS;
6824 DEFUN (no_ospf_distance_source_access_list,
6825 no_ospf_distance_source_access_list_cmd,
6826 "no distance <1-255> A.B.C.D/M WORD",
6827 NO_STR
6828 "Administrative distance\n"
6829 "Distance value\n"
6830 "IP source prefix\n"
6831 "Access list name\n")
6833 struct ospf *ospf = vty->index;
6835 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6837 return CMD_SUCCESS;
6840 DEFUN (ip_ospf_mtu_ignore,
6841 ip_ospf_mtu_ignore_addr_cmd,
6842 "ip ospf mtu-ignore A.B.C.D",
6843 "IP Information\n"
6844 "OSPF interface commands\n"
6845 "Disable mtu mismatch detection\n"
6846 "Address of interface")
6848 struct interface *ifp = vty->index;
6849 struct in_addr addr;
6850 int ret;
6852 struct ospf_if_params *params;
6853 params = IF_DEF_PARAMS (ifp);
6855 if (argc == 1)
6857 ret = inet_aton(argv[0], &addr);
6858 if (!ret)
6860 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6861 VTY_NEWLINE);
6862 return CMD_WARNING;
6864 params = ospf_get_if_params (ifp, addr);
6865 ospf_if_update_params (ifp, addr);
6867 params->mtu_ignore = 1;
6868 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6869 SET_IF_PARAM (params, mtu_ignore);
6870 else
6872 UNSET_IF_PARAM (params, mtu_ignore);
6873 if (params != IF_DEF_PARAMS (ifp))
6875 ospf_free_if_params (ifp, addr);
6876 ospf_if_update_params (ifp, addr);
6879 return CMD_SUCCESS;
6882 ALIAS (ip_ospf_mtu_ignore,
6883 ip_ospf_mtu_ignore_cmd,
6884 "ip ospf mtu-ignore",
6885 "IP Information\n"
6886 "OSPF interface commands\n"
6887 "Disable mtu mismatch detection\n")
6890 DEFUN (no_ip_ospf_mtu_ignore,
6891 no_ip_ospf_mtu_ignore_addr_cmd,
6892 "no ip ospf mtu-ignore A.B.C.D",
6893 "IP Information\n"
6894 "OSPF interface commands\n"
6895 "Disable mtu mismatch detection\n"
6896 "Address of interface")
6898 struct interface *ifp = vty->index;
6899 struct in_addr addr;
6900 int ret;
6902 struct ospf_if_params *params;
6903 params = IF_DEF_PARAMS (ifp);
6905 if (argc == 1)
6907 ret = inet_aton(argv[0], &addr);
6908 if (!ret)
6910 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6911 VTY_NEWLINE);
6912 return CMD_WARNING;
6914 params = ospf_get_if_params (ifp, addr);
6915 ospf_if_update_params (ifp, addr);
6917 params->mtu_ignore = 0;
6918 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6919 SET_IF_PARAM (params, mtu_ignore);
6920 else
6922 UNSET_IF_PARAM (params, mtu_ignore);
6923 if (params != IF_DEF_PARAMS (ifp))
6925 ospf_free_if_params (ifp, addr);
6926 ospf_if_update_params (ifp, addr);
6929 return CMD_SUCCESS;
6932 ALIAS (no_ip_ospf_mtu_ignore,
6933 no_ip_ospf_mtu_ignore_cmd,
6934 "no ip ospf mtu-ignore",
6935 "IP Information\n"
6936 "OSPF interface commands\n"
6937 "Disable mtu mismatch detection\n")
6939 DEFUN (ospf_max_metric_router_lsa_admin,
6940 ospf_max_metric_router_lsa_admin_cmd,
6941 "max-metric router-lsa administrative",
6942 "OSPF maximum / infinite-distance metric\n"
6943 "Advertise own Router-LSA with infinite distance (stub router)\n"
6944 "Administratively applied, for an indefinite period\n")
6946 struct listnode *ln;
6947 struct ospf_area *area;
6948 struct ospf *ospf = vty->index;
6950 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6952 SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
6954 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
6955 ospf_router_lsa_timer_add (area);
6957 return CMD_SUCCESS;
6960 DEFUN (no_ospf_max_metric_router_lsa_admin,
6961 no_ospf_max_metric_router_lsa_admin_cmd,
6962 "no max-metric router-lsa administrative",
6963 NO_STR
6964 "OSPF maximum / infinite-distance metric\n"
6965 "Advertise own Router-LSA with infinite distance (stub router)\n"
6966 "Administratively applied, for an indefinite period\n")
6968 struct listnode *ln;
6969 struct ospf_area *area;
6970 struct ospf *ospf = vty->index;
6972 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6974 UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
6976 /* Don't trample on the start-up stub timer */
6977 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)
6978 && !area->t_stub_router)
6980 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
6981 ospf_router_lsa_timer_add (area);
6984 return CMD_SUCCESS;
6987 DEFUN (ospf_max_metric_router_lsa_startup,
6988 ospf_max_metric_router_lsa_startup_cmd,
6989 "max-metric router-lsa on-startup <5-86400>",
6990 "OSPF maximum / infinite-distance metric\n"
6991 "Advertise own Router-LSA with infinite distance (stub router)\n"
6992 "Automatically advertise stub Router-LSA on startup of OSPF\n"
6993 "Time (seconds) to advertise self as stub-router\n")
6995 unsigned int seconds;
6996 struct ospf *ospf = vty->index;
6998 if (argc != 1)
7000 vty_out (vty, "%% Must supply stub-router period");
7001 return CMD_WARNING;
7004 VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]);
7006 ospf->stub_router_startup_time = seconds;
7008 return CMD_SUCCESS;
7011 DEFUN (no_ospf_max_metric_router_lsa_startup,
7012 no_ospf_max_metric_router_lsa_startup_cmd,
7013 "no max-metric router-lsa on-startup",
7014 NO_STR
7015 "OSPF maximum / infinite-distance metric\n"
7016 "Advertise own Router-LSA with infinite distance (stub router)\n"
7017 "Automatically advertise stub Router-LSA on startup of OSPF\n")
7019 struct listnode *ln;
7020 struct ospf_area *area;
7021 struct ospf *ospf = vty->index;
7023 ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED;
7025 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7027 SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED);
7028 OSPF_TIMER_OFF (area->t_stub_router);
7030 /* Don't trample on admin stub routed */
7031 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
7033 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
7034 ospf_router_lsa_timer_add (area);
7037 return CMD_SUCCESS;
7040 DEFUN (ospf_max_metric_router_lsa_shutdown,
7041 ospf_max_metric_router_lsa_shutdown_cmd,
7042 "max-metric router-lsa on-shutdown <5-86400>",
7043 "OSPF maximum / infinite-distance metric\n"
7044 "Advertise own Router-LSA with infinite distance (stub router)\n"
7045 "Advertise stub-router prior to full shutdown of OSPF\n"
7046 "Time (seconds) to wait till full shutdown\n")
7048 unsigned int seconds;
7049 struct ospf *ospf = vty->index;
7051 if (argc != 1)
7053 vty_out (vty, "%% Must supply stub-router shutdown period");
7054 return CMD_WARNING;
7057 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]);
7059 ospf->stub_router_shutdown_time = seconds;
7061 return CMD_SUCCESS;
7064 DEFUN (no_ospf_max_metric_router_lsa_shutdown,
7065 no_ospf_max_metric_router_lsa_shutdown_cmd,
7066 "no max-metric router-lsa on-shutdown",
7067 NO_STR
7068 "OSPF maximum / infinite-distance metric\n"
7069 "Advertise own Router-LSA with infinite distance (stub router)\n"
7070 "Advertise stub-router prior to full shutdown of OSPF\n")
7072 struct ospf *ospf = vty->index;
7074 ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;
7076 return CMD_SUCCESS;
7079 static void
7080 config_write_stub_router (struct vty *vty, struct ospf *ospf)
7082 struct listnode *ln;
7083 struct ospf_area *area;
7085 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
7086 vty_out (vty, " max-metric router-lsa on-startup %u%s",
7087 ospf->stub_router_startup_time, VTY_NEWLINE);
7088 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
7089 vty_out (vty, " max-metric router-lsa on-shutdown %u%s",
7090 ospf->stub_router_shutdown_time, VTY_NEWLINE);
7091 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7093 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
7095 vty_out (vty, " max-metric router-lsa administrative%s",
7096 VTY_NEWLINE);
7097 break;
7100 return;
7103 static void
7104 show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
7106 struct route_node *rn;
7107 struct ospf_route *or;
7108 struct listnode *pnode, *pnnode;
7109 struct ospf_path *path;
7111 vty_out (vty, "============ OSPF network routing table ============%s",
7112 VTY_NEWLINE);
7114 for (rn = route_top (rt); rn; rn = route_next (rn))
7115 if ((or = rn->info) != NULL)
7117 char buf1[19];
7118 snprintf (buf1, 19, "%s/%d",
7119 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
7121 switch (or->path_type)
7123 case OSPF_PATH_INTER_AREA:
7124 if (or->type == OSPF_DESTINATION_NETWORK)
7125 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
7126 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
7127 else if (or->type == OSPF_DESTINATION_DISCARD)
7128 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
7129 break;
7130 case OSPF_PATH_INTRA_AREA:
7131 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
7132 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
7133 break;
7134 default:
7135 break;
7138 if (or->type == OSPF_DESTINATION_NETWORK)
7139 for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
7141 if (if_lookup_by_index(path->ifindex))
7143 if (path->nexthop.s_addr == 0)
7144 vty_out (vty, "%24s directly attached to %s%s",
7145 "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
7146 else
7147 vty_out (vty, "%24s via %s, %s%s", "",
7148 inet_ntoa (path->nexthop),
7149 ifindex2ifname (path->ifindex), VTY_NEWLINE);
7153 vty_out (vty, "%s", VTY_NEWLINE);
7156 static void
7157 show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
7159 struct route_node *rn;
7160 struct ospf_route *or;
7161 struct listnode *pnode;
7162 struct listnode *node;
7163 struct ospf_path *path;
7165 vty_out (vty, "============ OSPF router routing table =============%s",
7166 VTY_NEWLINE);
7167 for (rn = route_top (rtrs); rn; rn = route_next (rn))
7168 if (rn->info)
7170 int flag = 0;
7172 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
7174 for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or))
7176 if (flag++)
7177 vty_out (vty, "%24s", "");
7179 /* Show path. */
7180 vty_out (vty, "%s [%d] area: %s",
7181 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
7182 or->cost, inet_ntoa (or->u.std.area_id));
7183 /* Show flags. */
7184 vty_out (vty, "%s%s%s",
7185 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
7186 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
7187 VTY_NEWLINE);
7189 for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
7191 if (if_lookup_by_index(path->ifindex))
7193 if (path->nexthop.s_addr == 0)
7194 vty_out (vty, "%24s directly attached to %s%s",
7195 "", ifindex2ifname (path->ifindex),
7196 VTY_NEWLINE);
7197 else
7198 vty_out (vty, "%24s via %s, %s%s", "",
7199 inet_ntoa (path->nexthop),
7200 ifindex2ifname (path->ifindex),
7201 VTY_NEWLINE);
7206 vty_out (vty, "%s", VTY_NEWLINE);
7209 static void
7210 show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
7212 struct route_node *rn;
7213 struct ospf_route *er;
7214 struct listnode *pnode, *pnnode;
7215 struct ospf_path *path;
7217 vty_out (vty, "============ OSPF external routing table ===========%s",
7218 VTY_NEWLINE);
7219 for (rn = route_top (rt); rn; rn = route_next (rn))
7220 if ((er = rn->info) != NULL)
7222 char buf1[19];
7223 snprintf (buf1, 19, "%s/%d",
7224 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
7226 switch (er->path_type)
7228 case OSPF_PATH_TYPE1_EXTERNAL:
7229 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
7230 er->cost, er->u.ext.tag, VTY_NEWLINE);
7231 break;
7232 case OSPF_PATH_TYPE2_EXTERNAL:
7233 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
7234 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
7235 break;
7238 for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
7240 if (if_lookup_by_index(path->ifindex))
7242 if (path->nexthop.s_addr == 0)
7243 vty_out (vty, "%24s directly attached to %s%s",
7244 "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
7245 else
7246 vty_out (vty, "%24s via %s, %s%s", "",
7247 inet_ntoa (path->nexthop),
7248 ifindex2ifname (path->ifindex),
7249 VTY_NEWLINE);
7253 vty_out (vty, "%s", VTY_NEWLINE);
7256 DEFUN (show_ip_ospf_border_routers,
7257 show_ip_ospf_border_routers_cmd,
7258 "show ip ospf border-routers",
7259 SHOW_STR
7260 IP_STR
7261 "show all the ABR's and ASBR's\n"
7262 "for this area\n")
7264 struct ospf *ospf;
7266 if ((ospf = ospf_lookup ()) == NULL)
7268 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
7269 return CMD_SUCCESS;
7272 if (ospf->new_table == NULL)
7274 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7275 return CMD_SUCCESS;
7278 /* Show Network routes.
7279 show_ip_ospf_route_network (vty, ospf->new_table); */
7281 /* Show Router routes. */
7282 show_ip_ospf_route_router (vty, ospf->new_rtrs);
7284 return CMD_SUCCESS;
7287 DEFUN (show_ip_ospf_route,
7288 show_ip_ospf_route_cmd,
7289 "show ip ospf route",
7290 SHOW_STR
7291 IP_STR
7292 "OSPF information\n"
7293 "OSPF routing table\n")
7295 struct ospf *ospf;
7297 if ((ospf = ospf_lookup ()) == NULL)
7299 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
7300 return CMD_SUCCESS;
7303 if (ospf->new_table == NULL)
7305 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7306 return CMD_SUCCESS;
7309 /* Show Network routes. */
7310 show_ip_ospf_route_network (vty, ospf->new_table);
7312 /* Show Router routes. */
7313 show_ip_ospf_route_router (vty, ospf->new_rtrs);
7315 /* Show AS External routes. */
7316 show_ip_ospf_route_external (vty, ospf->old_external_route);
7318 return CMD_SUCCESS;
7322 const char *ospf_abr_type_str[] =
7324 "unknown",
7325 "standard",
7326 "ibm",
7327 "cisco",
7328 "shortcut"
7331 const char *ospf_shortcut_mode_str[] =
7333 "default",
7334 "enable",
7335 "disable"
7339 static void
7340 area_id2str (char *buf, int length, struct ospf_area *area)
7342 memset (buf, 0, length);
7344 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
7345 strncpy (buf, inet_ntoa (area->area_id), length);
7346 else
7347 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
7351 const char *ospf_int_type_str[] =
7353 "unknown", /* should never be used. */
7354 "point-to-point",
7355 "broadcast",
7356 "non-broadcast",
7357 "point-to-multipoint",
7358 "virtual-link", /* should never be used. */
7359 "loopback"
7362 /* Configuration write function for ospfd. */
7363 static int
7364 config_write_interface (struct vty *vty)
7366 struct listnode *n1, *n2;
7367 struct interface *ifp;
7368 struct crypt_key *ck;
7369 int write = 0;
7370 struct route_node *rn = NULL;
7371 struct ospf_if_params *params;
7373 for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp))
7375 if (memcmp (ifp->name, "VLINK", 5) == 0)
7376 continue;
7378 vty_out (vty, "!%s", VTY_NEWLINE);
7379 vty_out (vty, "interface %s%s", ifp->name,
7380 VTY_NEWLINE);
7381 if (ifp->desc)
7382 vty_out (vty, " description %s%s", ifp->desc,
7383 VTY_NEWLINE);
7385 write++;
7387 params = IF_DEF_PARAMS (ifp);
7389 do {
7390 /* Interface Network print. */
7391 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
7392 params->type != OSPF_IFTYPE_LOOPBACK)
7394 if (params->type != ospf_default_iftype(ifp))
7396 vty_out (vty, " ip ospf network %s",
7397 ospf_int_type_str[params->type]);
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);
7404 /* OSPF interface authentication print */
7405 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
7406 params->auth_type != OSPF_AUTH_NOTSET)
7408 const char *auth_str;
7410 /* Translation tables are not that much help here due to syntax
7411 of the simple option */
7412 switch (params->auth_type)
7415 case OSPF_AUTH_NULL:
7416 auth_str = " null";
7417 break;
7419 case OSPF_AUTH_SIMPLE:
7420 auth_str = "";
7421 break;
7423 case OSPF_AUTH_CRYPTOGRAPHIC:
7424 auth_str = " message-digest";
7425 break;
7427 default:
7428 auth_str = "";
7429 break;
7432 vty_out (vty, " ip ospf authentication%s", auth_str);
7433 if (params != IF_DEF_PARAMS (ifp))
7434 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7435 vty_out (vty, "%s", VTY_NEWLINE);
7438 /* Simple Authentication Password print. */
7439 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
7440 params->auth_simple[0] != '\0')
7442 vty_out (vty, " ip ospf authentication-key %s",
7443 params->auth_simple);
7444 if (params != IF_DEF_PARAMS (ifp))
7445 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7446 vty_out (vty, "%s", VTY_NEWLINE);
7449 /* Cryptographic Authentication Key print. */
7450 for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck))
7452 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
7453 ck->key_id, ck->auth_key);
7454 if (params != IF_DEF_PARAMS (ifp))
7455 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7456 vty_out (vty, "%s", VTY_NEWLINE);
7459 /* Interface Output Cost print. */
7460 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
7462 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
7463 if (params != IF_DEF_PARAMS (ifp))
7464 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7465 vty_out (vty, "%s", VTY_NEWLINE);
7468 /* Hello Interval print. */
7469 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
7470 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
7472 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
7473 if (params != IF_DEF_PARAMS (ifp))
7474 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7475 vty_out (vty, "%s", VTY_NEWLINE);
7479 /* Router Dead Interval print. */
7480 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
7481 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
7483 vty_out (vty, " ip ospf dead-interval ");
7485 /* fast hello ? */
7486 if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello))
7487 vty_out (vty, "minimal hello-multiplier %d",
7488 params->fast_hello);
7489 else
7490 vty_out (vty, "%u", params->v_wait);
7492 if (params != IF_DEF_PARAMS (ifp))
7493 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7494 vty_out (vty, "%s", VTY_NEWLINE);
7497 /* Router Priority print. */
7498 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
7499 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
7501 vty_out (vty, " ip ospf priority %u", params->priority);
7502 if (params != IF_DEF_PARAMS (ifp))
7503 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7504 vty_out (vty, "%s", VTY_NEWLINE);
7507 /* Retransmit Interval print. */
7508 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
7509 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
7511 vty_out (vty, " ip ospf retransmit-interval %u",
7512 params->retransmit_interval);
7513 if (params != IF_DEF_PARAMS (ifp))
7514 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7515 vty_out (vty, "%s", VTY_NEWLINE);
7518 /* Transmit Delay print. */
7519 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
7520 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
7522 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
7523 if (params != IF_DEF_PARAMS (ifp))
7524 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7525 vty_out (vty, "%s", VTY_NEWLINE);
7528 /* MTU ignore print. */
7529 if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) &&
7530 params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
7532 if (params->mtu_ignore == 0)
7533 vty_out (vty, " no ip ospf mtu-ignore");
7534 else
7535 vty_out (vty, " ip ospf mtu-ignore");
7536 if (params != IF_DEF_PARAMS (ifp))
7537 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7538 vty_out (vty, "%s", VTY_NEWLINE);
7542 while (1)
7544 if (rn == NULL)
7545 rn = route_top (IF_OIFS_PARAMS (ifp));
7546 else
7547 rn = route_next (rn);
7549 if (rn == NULL)
7550 break;
7551 params = rn->info;
7552 if (params != NULL)
7553 break;
7555 } while (rn);
7557 #ifdef HAVE_OPAQUE_LSA
7558 ospf_opaque_config_write_if (vty, ifp);
7559 #endif /* HAVE_OPAQUE_LSA */
7562 return write;
7565 static int
7566 config_write_network_area (struct vty *vty, struct ospf *ospf)
7568 struct route_node *rn;
7569 u_char buf[INET_ADDRSTRLEN];
7571 /* `network area' print. */
7572 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
7573 if (rn->info)
7575 struct ospf_network *n = rn->info;
7577 memset (buf, 0, INET_ADDRSTRLEN);
7579 /* Create Area ID string by specified Area ID format. */
7580 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
7581 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
7582 else
7583 sprintf ((char *) buf, "%lu",
7584 (unsigned long int) ntohl (n->area_id.s_addr));
7586 /* Network print. */
7587 vty_out (vty, " network %s/%d area %s%s",
7588 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7589 buf, VTY_NEWLINE);
7592 return 0;
7595 static int
7596 config_write_ospf_area (struct vty *vty, struct ospf *ospf)
7598 struct listnode *node;
7599 struct ospf_area *area;
7600 u_char buf[INET_ADDRSTRLEN];
7602 /* Area configuration print. */
7603 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
7605 struct route_node *rn1;
7607 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
7609 if (area->auth_type != OSPF_AUTH_NULL)
7611 if (area->auth_type == OSPF_AUTH_SIMPLE)
7612 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
7613 else
7614 vty_out (vty, " area %s authentication message-digest%s",
7615 buf, VTY_NEWLINE);
7618 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
7619 vty_out (vty, " area %s shortcut %s%s", buf,
7620 ospf_shortcut_mode_str[area->shortcut_configured],
7621 VTY_NEWLINE);
7623 if ((area->external_routing == OSPF_AREA_STUB)
7624 || (area->external_routing == OSPF_AREA_NSSA)
7627 if (area->external_routing == OSPF_AREA_STUB)
7628 vty_out (vty, " area %s stub", buf);
7629 else if (area->external_routing == OSPF_AREA_NSSA)
7631 vty_out (vty, " area %s nssa", buf);
7632 switch (area->NSSATranslatorRole)
7634 case OSPF_NSSA_ROLE_NEVER:
7635 vty_out (vty, " translate-never");
7636 break;
7637 case OSPF_NSSA_ROLE_ALWAYS:
7638 vty_out (vty, " translate-always");
7639 break;
7640 case OSPF_NSSA_ROLE_CANDIDATE:
7641 default:
7642 vty_out (vty, " translate-candidate");
7646 if (area->no_summary)
7647 vty_out (vty, " no-summary");
7649 vty_out (vty, "%s", VTY_NEWLINE);
7651 if (area->default_cost != 1)
7652 vty_out (vty, " area %s default-cost %d%s", buf,
7653 area->default_cost, VTY_NEWLINE);
7656 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
7657 if (rn1->info)
7659 struct ospf_area_range *range = rn1->info;
7661 vty_out (vty, " area %s range %s/%d", buf,
7662 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
7664 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
7665 vty_out (vty, " cost %d", range->cost_config);
7667 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
7668 vty_out (vty, " not-advertise");
7670 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
7671 vty_out (vty, " substitute %s/%d",
7672 inet_ntoa (range->subst_addr), range->subst_masklen);
7674 vty_out (vty, "%s", VTY_NEWLINE);
7677 if (EXPORT_NAME (area))
7678 vty_out (vty, " area %s export-list %s%s", buf,
7679 EXPORT_NAME (area), VTY_NEWLINE);
7681 if (IMPORT_NAME (area))
7682 vty_out (vty, " area %s import-list %s%s", buf,
7683 IMPORT_NAME (area), VTY_NEWLINE);
7685 if (PREFIX_NAME_IN (area))
7686 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
7687 PREFIX_NAME_IN (area), VTY_NEWLINE);
7689 if (PREFIX_NAME_OUT (area))
7690 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7691 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7694 return 0;
7697 static int
7698 config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
7700 struct ospf_nbr_nbma *nbr_nbma;
7701 struct route_node *rn;
7703 /* Static Neighbor configuration print. */
7704 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
7705 if ((nbr_nbma = rn->info))
7707 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7709 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7710 vty_out (vty, " priority %d", nbr_nbma->priority);
7712 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7713 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7715 vty_out (vty, "%s", VTY_NEWLINE);
7718 return 0;
7721 static int
7722 config_write_virtual_link (struct vty *vty, struct ospf *ospf)
7724 struct listnode *node;
7725 struct ospf_vl_data *vl_data;
7726 u_char buf[INET_ADDRSTRLEN];
7728 /* Virtual-Link print */
7729 for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
7731 struct listnode *n2;
7732 struct crypt_key *ck;
7733 struct ospf_interface *oi;
7735 if (vl_data != NULL)
7737 memset (buf, 0, INET_ADDRSTRLEN);
7739 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
7740 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
7741 else
7742 sprintf ((char *) buf, "%lu",
7743 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7744 oi = vl_data->vl_oi;
7746 /* timers */
7747 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7748 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7749 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7750 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7751 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7752 buf,
7753 inet_ntoa (vl_data->vl_peer),
7754 OSPF_IF_PARAM (oi, v_hello),
7755 OSPF_IF_PARAM (oi, retransmit_interval),
7756 OSPF_IF_PARAM (oi, transmit_delay),
7757 OSPF_IF_PARAM (oi, v_wait),
7758 VTY_NEWLINE);
7759 else
7760 vty_out (vty, " area %s virtual-link %s%s", buf,
7761 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7762 /* Auth key */
7763 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7764 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7765 buf,
7766 inet_ntoa (vl_data->vl_peer),
7767 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7768 VTY_NEWLINE);
7769 /* md5 keys */
7770 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt,
7771 n2, ck))
7772 vty_out (vty, " area %s virtual-link %s"
7773 " message-digest-key %d md5 %s%s",
7774 buf,
7775 inet_ntoa (vl_data->vl_peer),
7776 ck->key_id, ck->auth_key, VTY_NEWLINE);
7781 return 0;
7785 static int
7786 config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
7788 int type;
7790 /* redistribute print. */
7791 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7792 if (type != zclient->redist_default && zclient->redist[type])
7794 vty_out (vty, " redistribute %s", zebra_route_string(type));
7795 if (ospf->dmetric[type].value >= 0)
7796 vty_out (vty, " metric %d", ospf->dmetric[type].value);
7798 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
7799 vty_out (vty, " metric-type 1");
7801 if (ROUTEMAP_NAME (ospf, type))
7802 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
7804 vty_out (vty, "%s", VTY_NEWLINE);
7807 return 0;
7810 static int
7811 config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
7813 if (ospf->default_metric != -1)
7814 vty_out (vty, " default-metric %d%s", ospf->default_metric,
7815 VTY_NEWLINE);
7816 return 0;
7819 static int
7820 config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
7822 int type;
7824 if (ospf)
7826 /* distribute-list print. */
7827 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7828 if (ospf->dlist[type].name)
7829 vty_out (vty, " distribute-list %s out %s%s",
7830 ospf->dlist[type].name,
7831 zebra_route_string(type), VTY_NEWLINE);
7833 /* default-information print. */
7834 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
7836 vty_out (vty, " default-information originate");
7837 if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS)
7838 vty_out (vty, " always");
7840 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
7841 vty_out (vty, " metric %d",
7842 ospf->dmetric[DEFAULT_ROUTE].value);
7843 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
7844 vty_out (vty, " metric-type 1");
7846 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7847 vty_out (vty, " route-map %s",
7848 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
7850 vty_out (vty, "%s", VTY_NEWLINE);
7855 return 0;
7858 static int
7859 config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
7861 struct route_node *rn;
7862 struct ospf_distance *odistance;
7864 if (ospf->distance_all)
7865 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
7867 if (ospf->distance_intra
7868 || ospf->distance_inter
7869 || ospf->distance_external)
7871 vty_out (vty, " distance ospf");
7873 if (ospf->distance_intra)
7874 vty_out (vty, " intra-area %d", ospf->distance_intra);
7875 if (ospf->distance_inter)
7876 vty_out (vty, " inter-area %d", ospf->distance_inter);
7877 if (ospf->distance_external)
7878 vty_out (vty, " external %d", ospf->distance_external);
7880 vty_out (vty, "%s", VTY_NEWLINE);
7883 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
7884 if ((odistance = rn->info) != NULL)
7886 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7887 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7888 odistance->access_list ? odistance->access_list : "",
7889 VTY_NEWLINE);
7891 return 0;
7894 /* OSPF configuration write function. */
7895 static int
7896 ospf_config_write (struct vty *vty)
7898 struct ospf *ospf;
7899 struct interface *ifp;
7900 struct ospf_interface *oi;
7901 struct listnode *node;
7902 int write = 0;
7904 ospf = ospf_lookup ();
7905 if (ospf != NULL)
7907 /* `router ospf' print. */
7908 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7910 write++;
7912 if (!ospf->networks)
7913 return write;
7915 /* Router ID print. */
7916 if (ospf->router_id_static.s_addr != 0)
7917 vty_out (vty, " ospf router-id %s%s",
7918 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
7920 /* ABR type print. */
7921 if (ospf->abr_type != OSPF_ABR_DEFAULT)
7922 vty_out (vty, " ospf abr-type %s%s",
7923 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
7925 /* log-adjacency-changes flag print. */
7926 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
7928 vty_out(vty, " log-adjacency-changes");
7929 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
7930 vty_out(vty, " detail");
7931 vty_out(vty, "%s", VTY_NEWLINE);
7934 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
7935 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
7936 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
7938 /* auto-cost reference-bandwidth configuration. */
7939 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
7941 vty_out (vty, "! Important: ensure reference bandwidth "
7942 "is consistent across all routers%s", VTY_NEWLINE);
7943 vty_out (vty, " auto-cost reference-bandwidth %d%s",
7944 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
7947 /* SPF timers print. */
7948 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
7949 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT ||
7950 ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT)
7951 vty_out (vty, " timers throttle spf %d %d %d%s",
7952 ospf->spf_delay, ospf->spf_holdtime,
7953 ospf->spf_max_holdtime, VTY_NEWLINE);
7955 /* Max-metric router-lsa print */
7956 config_write_stub_router (vty, ospf);
7958 /* SPF refresh parameters print. */
7959 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
7960 vty_out (vty, " refresh timer %d%s",
7961 ospf->lsa_refresh_interval, VTY_NEWLINE);
7963 /* Redistribute information print. */
7964 config_write_ospf_redistribute (vty, ospf);
7966 /* passive-interface print. */
7967 if (ospf->passive_interface_default == OSPF_IF_PASSIVE)
7968 vty_out (vty, " passive-interface default%s", VTY_NEWLINE);
7970 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
7971 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)
7972 && IF_DEF_PARAMS (ifp)->passive_interface !=
7973 ospf->passive_interface_default)
7975 vty_out (vty, " %spassive-interface %s%s",
7976 IF_DEF_PARAMS (ifp)->passive_interface ? "" : "no ",
7977 ifp->name, VTY_NEWLINE);
7979 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
7981 if (!OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface))
7982 continue;
7983 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi->ifp),
7984 passive_interface))
7986 if (oi->params->passive_interface == IF_DEF_PARAMS (oi->ifp)->passive_interface)
7987 continue;
7989 else if (oi->params->passive_interface == ospf->passive_interface_default)
7990 continue;
7992 vty_out (vty, " %spassive-interface %s %s%s",
7993 oi->params->passive_interface ? "" : "no ",
7994 oi->ifp->name,
7995 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
7998 /* Network area print. */
7999 config_write_network_area (vty, ospf);
8001 /* Area config print. */
8002 config_write_ospf_area (vty, ospf);
8004 /* static neighbor print. */
8005 config_write_ospf_nbr_nbma (vty, ospf);
8007 /* Virtual-Link print. */
8008 config_write_virtual_link (vty, ospf);
8010 /* Default metric configuration. */
8011 config_write_ospf_default_metric (vty, ospf);
8013 /* Distribute-list and default-information print. */
8014 config_write_ospf_distribute (vty, ospf);
8016 /* Distance configuration. */
8017 config_write_ospf_distance (vty, ospf);
8019 #ifdef HAVE_OPAQUE_LSA
8020 ospf_opaque_config_write_router (vty, ospf);
8021 #endif /* HAVE_OPAQUE_LSA */
8024 return write;
8027 void
8028 ospf_vty_show_init (void)
8030 /* "show ip ospf" commands. */
8031 install_element (VIEW_NODE, &show_ip_ospf_cmd);
8032 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
8034 /* "show ip ospf database" commands. */
8035 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
8036 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
8037 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
8038 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
8039 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
8040 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
8041 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
8042 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
8043 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
8044 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
8045 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
8046 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
8047 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
8048 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
8050 /* "show ip ospf interface" commands. */
8051 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
8052 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
8054 /* "show ip ospf neighbor" commands. */
8055 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
8056 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
8057 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
8058 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
8059 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
8060 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
8061 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
8062 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
8063 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
8064 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
8065 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
8066 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
8067 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
8068 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
8070 /* "show ip ospf route" commands. */
8071 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
8072 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
8073 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
8074 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
8078 /* ospfd's interface node. */
8079 static struct cmd_node interface_node =
8081 INTERFACE_NODE,
8082 "%s(config-if)# ",
8086 /* Initialization of OSPF interface. */
8087 static void
8088 ospf_vty_if_init (void)
8090 /* Install interface node. */
8091 install_node (&interface_node, config_write_interface);
8093 install_element (CONFIG_NODE, &interface_cmd);
8094 install_element (CONFIG_NODE, &no_interface_cmd);
8095 install_default (INTERFACE_NODE);
8097 /* "description" commands. */
8098 install_element (INTERFACE_NODE, &interface_desc_cmd);
8099 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
8101 /* "ip ospf authentication" commands. */
8102 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
8103 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
8104 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
8105 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
8106 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
8107 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
8108 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
8109 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
8110 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
8111 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
8113 /* "ip ospf message-digest-key" commands. */
8114 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
8115 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
8116 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
8117 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
8119 /* "ip ospf cost" commands. */
8120 install_element (INTERFACE_NODE, &ip_ospf_cost_u32_inet4_cmd);
8121 install_element (INTERFACE_NODE, &ip_ospf_cost_u32_cmd);
8122 install_element (INTERFACE_NODE, &no_ip_ospf_cost_inet4_cmd);
8123 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
8125 /* "ip ospf mtu-ignore" commands. */
8126 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd);
8127 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd);
8128 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd);
8129 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd);
8131 /* "ip ospf dead-interval" commands. */
8132 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
8133 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
8134 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd);
8135 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd);
8136 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
8137 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
8139 /* "ip ospf hello-interval" commands. */
8140 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
8141 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
8142 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
8143 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
8145 /* "ip ospf network" commands. */
8146 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
8147 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
8149 /* "ip ospf priority" commands. */
8150 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
8151 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
8152 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
8153 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
8155 /* "ip ospf retransmit-interval" commands. */
8156 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
8157 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
8158 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
8159 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
8161 /* "ip ospf transmit-delay" commands. */
8162 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
8163 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
8164 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
8165 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
8167 /* These commands are compatibitliy for previous version. */
8168 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
8169 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
8170 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
8171 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
8172 install_element (INTERFACE_NODE, &ospf_cost_u32_cmd);
8173 install_element (INTERFACE_NODE, &ospf_cost_u32_inet4_cmd);
8174 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
8175 install_element (INTERFACE_NODE, &no_ospf_cost_inet4_cmd);
8176 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
8177 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
8178 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
8179 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
8180 install_element (INTERFACE_NODE, &ospf_network_cmd);
8181 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
8182 install_element (INTERFACE_NODE, &ospf_priority_cmd);
8183 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
8184 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
8185 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
8186 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
8187 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
8190 static void
8191 ospf_vty_zebra_init (void)
8193 install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd);
8194 install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd);
8195 install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd);
8196 install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd);
8197 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
8198 install_element (OSPF_NODE,
8199 &ospf_redistribute_source_metric_type_routemap_cmd);
8200 install_element (OSPF_NODE,
8201 &ospf_redistribute_source_type_metric_routemap_cmd);
8202 install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd);
8203 install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd);
8204 install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd);
8206 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
8208 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
8209 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
8211 install_element (OSPF_NODE,
8212 &ospf_default_information_originate_metric_type_cmd);
8213 install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd);
8214 install_element (OSPF_NODE,
8215 &ospf_default_information_originate_type_metric_cmd);
8216 install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd);
8217 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
8218 install_element (OSPF_NODE,
8219 &ospf_default_information_originate_always_metric_type_cmd);
8220 install_element (OSPF_NODE,
8221 &ospf_default_information_originate_always_metric_cmd);
8222 install_element (OSPF_NODE,
8223 &ospf_default_information_originate_always_cmd);
8224 install_element (OSPF_NODE,
8225 &ospf_default_information_originate_always_type_metric_cmd);
8226 install_element (OSPF_NODE,
8227 &ospf_default_information_originate_always_type_cmd);
8229 install_element (OSPF_NODE,
8230 &ospf_default_information_originate_metric_type_routemap_cmd);
8231 install_element (OSPF_NODE,
8232 &ospf_default_information_originate_metric_routemap_cmd);
8233 install_element (OSPF_NODE,
8234 &ospf_default_information_originate_routemap_cmd);
8235 install_element (OSPF_NODE,
8236 &ospf_default_information_originate_type_metric_routemap_cmd);
8237 install_element (OSPF_NODE,
8238 &ospf_default_information_originate_type_routemap_cmd);
8239 install_element (OSPF_NODE,
8240 &ospf_default_information_originate_always_metric_type_routemap_cmd);
8241 install_element (OSPF_NODE,
8242 &ospf_default_information_originate_always_metric_routemap_cmd);
8243 install_element (OSPF_NODE,
8244 &ospf_default_information_originate_always_routemap_cmd);
8245 install_element (OSPF_NODE,
8246 &ospf_default_information_originate_always_type_metric_routemap_cmd);
8247 install_element (OSPF_NODE,
8248 &ospf_default_information_originate_always_type_routemap_cmd);
8250 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
8252 install_element (OSPF_NODE, &ospf_default_metric_cmd);
8253 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
8254 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
8256 install_element (OSPF_NODE, &ospf_distance_cmd);
8257 install_element (OSPF_NODE, &no_ospf_distance_cmd);
8258 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
8259 install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd);
8260 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd);
8261 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd);
8262 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd);
8263 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd);
8264 install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd);
8265 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd);
8266 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd);
8267 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd);
8268 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd);
8269 install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd);
8270 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd);
8271 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd);
8272 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd);
8273 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd);
8274 #if 0
8275 install_element (OSPF_NODE, &ospf_distance_source_cmd);
8276 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
8277 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
8278 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
8279 #endif /* 0 */
8282 static struct cmd_node ospf_node =
8284 OSPF_NODE,
8285 "%s(config-router)# ",
8290 /* Install OSPF related vty commands. */
8291 void
8292 ospf_vty_init (void)
8294 /* Install ospf top node. */
8295 install_node (&ospf_node, ospf_config_write);
8297 /* "router ospf" commands. */
8298 install_element (CONFIG_NODE, &router_ospf_cmd);
8299 install_element (CONFIG_NODE, &no_router_ospf_cmd);
8301 install_default (OSPF_NODE);
8303 /* "ospf router-id" commands. */
8304 install_element (OSPF_NODE, &ospf_router_id_cmd);
8305 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
8306 install_element (OSPF_NODE, &router_ospf_id_cmd);
8307 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
8309 /* "passive-interface" commands. */
8310 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
8311 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
8312 install_element (OSPF_NODE, &ospf_passive_interface_default_cmd);
8313 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
8314 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
8315 install_element (OSPF_NODE, &no_ospf_passive_interface_default_cmd);
8317 /* "ospf abr-type" commands. */
8318 install_element (OSPF_NODE, &ospf_abr_type_cmd);
8319 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
8321 /* "ospf log-adjacency-changes" commands. */
8322 install_element (OSPF_NODE, &ospf_log_adjacency_changes_cmd);
8323 install_element (OSPF_NODE, &ospf_log_adjacency_changes_detail_cmd);
8324 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_cmd);
8325 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd);
8327 /* "ospf rfc1583-compatible" commands. */
8328 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
8329 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
8330 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
8331 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
8333 /* "network area" commands. */
8334 install_element (OSPF_NODE, &ospf_network_area_cmd);
8335 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
8337 /* "area authentication" commands. */
8338 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
8339 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
8340 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
8342 /* "area range" commands. */
8343 install_element (OSPF_NODE, &ospf_area_range_cmd);
8344 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
8345 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
8346 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
8347 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
8348 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
8349 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
8350 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
8351 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
8352 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
8353 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
8355 /* "area virtual-link" commands. */
8356 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
8357 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
8359 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
8360 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
8362 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
8363 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
8365 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
8366 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
8368 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
8369 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
8371 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
8372 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
8373 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
8375 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
8376 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
8378 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
8379 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
8381 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
8382 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
8383 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
8385 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
8386 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
8387 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
8389 /* "area stub" commands. */
8390 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
8391 install_element (OSPF_NODE, &ospf_area_stub_cmd);
8392 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
8393 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
8395 /* "area nssa" commands. */
8396 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
8397 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
8398 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
8399 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
8400 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
8401 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
8403 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
8404 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
8406 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
8407 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
8409 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
8410 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
8412 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
8413 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
8415 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
8416 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
8418 /* SPF timer commands */
8419 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
8420 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
8421 install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd);
8422 install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd);
8424 /* refresh timer commands */
8425 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
8426 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
8427 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
8429 /* max-metric commands */
8430 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd);
8431 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd);
8432 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd);
8433 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd);
8434 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd);
8435 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd);
8437 /* reference bandwidth commands */
8438 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
8439 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
8441 /* "neighbor" commands. */
8442 install_element (OSPF_NODE, &ospf_neighbor_cmd);
8443 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
8444 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
8445 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
8446 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
8447 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
8448 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
8449 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
8451 /* Init interface related vty commands. */
8452 ospf_vty_if_init ();
8454 /* Init zebra related vty commands. */
8455 ospf_vty_zebra_init ();