[ospfd] Additional NSM neighbour state change stats/information
[jleu-quagga.git] / ospfd / ospf_vty.c
blob912f1d09c847547a9a7e71616c2bf203bef1e212
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 const static 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 DEFUN (ospf_passive_interface,
253 ospf_passive_interface_addr_cmd,
254 "passive-interface IFNAME A.B.C.D",
255 "Suppress routing updates on an interface\n"
256 "Interface's name\n")
258 struct interface *ifp;
259 struct in_addr addr;
260 int ret;
261 struct ospf_if_params *params;
262 struct route_node *rn;
264 ifp = if_get_by_name (argv[0]);
266 params = IF_DEF_PARAMS (ifp);
268 if (argc == 2)
270 ret = inet_aton(argv[1], &addr);
271 if (!ret)
273 vty_out (vty, "Please specify interface address by A.B.C.D%s",
274 VTY_NEWLINE);
275 return CMD_WARNING;
278 params = ospf_get_if_params (ifp, addr);
279 ospf_if_update_params (ifp, addr);
282 SET_IF_PARAM (params, passive_interface);
283 params->passive_interface = OSPF_IF_PASSIVE;
285 /* XXX We should call ospf_if_set_multicast on exactly those
286 * interfaces for which the passive property changed. It is too much
287 * work to determine this set, so we do this for every interface.
288 * This is safe and reasonable because ospf_if_set_multicast uses a
289 * record of joined groups to avoid systems calls if the desired
290 * memberships match the current memership.
292 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
294 struct ospf_interface *oi = rn->info;
296 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE))
297 ospf_if_set_multicast(oi);
300 * XXX It is not clear what state transitions the interface needs to
301 * undergo when going from active to passive. Fixing this will
302 * require precise identification of interfaces having such a
303 * transition.
306 return CMD_SUCCESS;
309 ALIAS (ospf_passive_interface,
310 ospf_passive_interface_cmd,
311 "passive-interface IFNAME",
312 "Suppress routing updates on an interface\n"
313 "Interface's name\n")
315 DEFUN (no_ospf_passive_interface,
316 no_ospf_passive_interface_addr_cmd,
317 "no passive-interface IFNAME A.B.C.D",
318 NO_STR
319 "Allow routing updates on an interface\n"
320 "Interface's name\n")
322 struct interface *ifp;
323 struct in_addr addr;
324 struct ospf_if_params *params;
325 int ret;
326 struct route_node *rn;
328 ifp = if_get_by_name (argv[0]);
330 params = IF_DEF_PARAMS (ifp);
332 if (argc == 2)
334 ret = inet_aton(argv[1], &addr);
335 if (!ret)
337 vty_out (vty, "Please specify interface address by A.B.C.D%s",
338 VTY_NEWLINE);
339 return CMD_WARNING;
342 params = ospf_lookup_if_params (ifp, addr);
343 if (params == NULL)
344 return CMD_SUCCESS;
347 UNSET_IF_PARAM (params, passive_interface);
348 params->passive_interface = OSPF_IF_ACTIVE;
350 if (params != IF_DEF_PARAMS (ifp))
352 ospf_free_if_params (ifp, addr);
353 ospf_if_update_params (ifp, addr);
356 /* XXX We should call ospf_if_set_multicast on exactly those
357 * interfaces for which the passive property changed. It is too much
358 * work to determine this set, so we do this for every interface.
359 * This is safe and reasonable because ospf_if_set_multicast uses a
360 * record of joined groups to avoid systems calls if the desired
361 * memberships match the current memership.
363 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
365 struct ospf_interface *oi = rn->info;
367 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE))
368 ospf_if_set_multicast(oi);
371 return CMD_SUCCESS;
374 ALIAS (no_ospf_passive_interface,
375 no_ospf_passive_interface_cmd,
376 "no passive-interface IFNAME",
377 NO_STR
378 "Allow routing updates on an interface\n"
379 "Interface's name\n")
381 DEFUN (ospf_network_area,
382 ospf_network_area_cmd,
383 "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
384 "Enable routing on an IP network\n"
385 "OSPF network prefix\n"
386 "Set the OSPF area ID\n"
387 "OSPF area ID in IP address format\n"
388 "OSPF area ID as a decimal value\n")
390 struct ospf *ospf= vty->index;
391 struct prefix_ipv4 p;
392 struct in_addr area_id;
393 int ret, format;
395 /* Get network prefix and Area ID. */
396 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
397 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
399 ret = ospf_network_set (ospf, &p, area_id);
400 if (ret == 0)
402 vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE);
403 return CMD_WARNING;
406 return CMD_SUCCESS;
409 DEFUN (no_ospf_network_area,
410 no_ospf_network_area_cmd,
411 "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
412 NO_STR
413 "Enable routing on an IP network\n"
414 "OSPF network prefix\n"
415 "Set the OSPF area ID\n"
416 "OSPF area ID in IP address format\n"
417 "OSPF area ID as a decimal value\n")
419 struct ospf *ospf = (struct ospf *) vty->index;
420 struct prefix_ipv4 p;
421 struct in_addr area_id;
422 int ret, format;
424 /* Get network prefix and Area ID. */
425 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
426 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
428 ret = ospf_network_unset (ospf, &p, area_id);
429 if (ret == 0)
431 vty_out (vty, "Can't find specified network area configuration.%s",
432 VTY_NEWLINE);
433 return CMD_WARNING;
436 return CMD_SUCCESS;
440 DEFUN (ospf_area_range,
441 ospf_area_range_cmd,
442 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
443 "OSPF area parameters\n"
444 "OSPF area ID in IP address format\n"
445 "OSPF area ID as a decimal value\n"
446 "Summarize routes matching address/mask (border routers only)\n"
447 "Area range prefix\n")
449 struct ospf *ospf = vty->index;
450 struct prefix_ipv4 p;
451 struct in_addr area_id;
452 int format;
453 u_int32_t cost;
455 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
456 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
458 ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE);
459 if (argc > 2)
461 VTY_GET_INTEGER ("range cost", cost, argv[2]);
462 ospf_area_range_cost_set (ospf, area_id, &p, cost);
465 return CMD_SUCCESS;
468 ALIAS (ospf_area_range,
469 ospf_area_range_advertise_cmd,
470 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise",
471 "OSPF area parameters\n"
472 "OSPF area ID in IP address format\n"
473 "OSPF area ID as a decimal value\n"
474 "OSPF area range for route advertise (default)\n"
475 "Area range prefix\n"
476 "Advertise this range (default)\n")
478 ALIAS (ospf_area_range,
479 ospf_area_range_cost_cmd,
480 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
481 "OSPF area parameters\n"
482 "OSPF area ID in IP address format\n"
483 "OSPF area ID as a decimal value\n"
484 "Summarize routes matching address/mask (border routers only)\n"
485 "Area range prefix\n"
486 "User specified metric for this range\n"
487 "Advertised metric for this range\n")
489 ALIAS (ospf_area_range,
490 ospf_area_range_advertise_cost_cmd,
491 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
492 "OSPF area parameters\n"
493 "OSPF area ID in IP address format\n"
494 "OSPF area ID as a decimal value\n"
495 "Summarize routes matching address/mask (border routers only)\n"
496 "Area range prefix\n"
497 "Advertise this range (default)\n"
498 "User specified metric for this range\n"
499 "Advertised metric for this range\n")
501 DEFUN (ospf_area_range_not_advertise,
502 ospf_area_range_not_advertise_cmd,
503 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise",
504 "OSPF area parameters\n"
505 "OSPF area ID in IP address format\n"
506 "OSPF area ID as a decimal value\n"
507 "Summarize routes matching address/mask (border routers only)\n"
508 "Area range prefix\n"
509 "DoNotAdvertise this range\n")
511 struct ospf *ospf = vty->index;
512 struct prefix_ipv4 p;
513 struct in_addr area_id;
514 int format;
516 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
517 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
519 ospf_area_range_set (ospf, area_id, &p, 0);
521 return CMD_SUCCESS;
524 DEFUN (no_ospf_area_range,
525 no_ospf_area_range_cmd,
526 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
527 NO_STR
528 "OSPF area parameters\n"
529 "OSPF area ID in IP address format\n"
530 "OSPF area ID as a decimal value\n"
531 "Summarize routes matching address/mask (border routers only)\n"
532 "Area range prefix\n")
534 struct ospf *ospf = vty->index;
535 struct prefix_ipv4 p;
536 struct in_addr area_id;
537 int format;
539 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
540 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
542 ospf_area_range_unset (ospf, area_id, &p);
544 return CMD_SUCCESS;
547 ALIAS (no_ospf_area_range,
548 no_ospf_area_range_advertise_cmd,
549 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)",
550 NO_STR
551 "OSPF area parameters\n"
552 "OSPF area ID in IP address format\n"
553 "OSPF area ID as a decimal value\n"
554 "Summarize routes matching address/mask (border routers only)\n"
555 "Area range prefix\n"
556 "Advertise this range (default)\n"
557 "DoNotAdvertise this range\n")
559 ALIAS (no_ospf_area_range,
560 no_ospf_area_range_cost_cmd,
561 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
562 NO_STR
563 "OSPF area parameters\n"
564 "OSPF area ID in IP address format\n"
565 "OSPF area ID as a decimal value\n"
566 "Summarize routes matching address/mask (border routers only)\n"
567 "Area range prefix\n"
568 "User specified metric for this range\n"
569 "Advertised metric for this range\n")
571 ALIAS (no_ospf_area_range,
572 no_ospf_area_range_advertise_cost_cmd,
573 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
574 NO_STR
575 "OSPF area parameters\n"
576 "OSPF area ID in IP address format\n"
577 "OSPF area ID as a decimal value\n"
578 "Summarize routes matching address/mask (border routers only)\n"
579 "Area range prefix\n"
580 "Advertise this range (default)\n"
581 "User specified metric for this range\n"
582 "Advertised metric for this range\n")
584 DEFUN (ospf_area_range_substitute,
585 ospf_area_range_substitute_cmd,
586 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
587 "OSPF area parameters\n"
588 "OSPF area ID in IP address format\n"
589 "OSPF area ID as a decimal value\n"
590 "Summarize routes matching address/mask (border routers only)\n"
591 "Area range prefix\n"
592 "Announce area range as another prefix\n"
593 "Network prefix to be announced instead of range\n")
595 struct ospf *ospf = vty->index;
596 struct prefix_ipv4 p, s;
597 struct in_addr area_id;
598 int format;
600 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
601 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
602 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
604 ospf_area_range_substitute_set (ospf, area_id, &p, &s);
606 return CMD_SUCCESS;
609 DEFUN (no_ospf_area_range_substitute,
610 no_ospf_area_range_substitute_cmd,
611 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
612 NO_STR
613 "OSPF area parameters\n"
614 "OSPF area ID in IP address format\n"
615 "OSPF area ID as a decimal value\n"
616 "Summarize routes matching address/mask (border routers only)\n"
617 "Area range prefix\n"
618 "Announce area range as another prefix\n"
619 "Network prefix to be announced instead of range\n")
621 struct ospf *ospf = vty->index;
622 struct prefix_ipv4 p, s;
623 struct in_addr area_id;
624 int format;
626 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
627 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
628 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
630 ospf_area_range_substitute_unset (ospf, area_id, &p);
632 return CMD_SUCCESS;
636 /* Command Handler Logic in VLink stuff is delicate!!
638 ALTER AT YOUR OWN RISK!!!!
640 Various dummy values are used to represent 'NoChange' state for
641 VLink configuration NOT being changed by a VLink command, and
642 special syntax is used within the command strings so that the
643 typed in command verbs can be seen in the configuration command
644 bacckend handler. This is to drastically reduce the verbeage
645 required to coe up with a reasonably compatible Cisco VLink command
647 - Matthew Grant <grantma@anathoth.gen.nz>
648 Wed, 21 Feb 2001 15:13:52 +1300
652 /* Configuration data for virtual links
654 struct ospf_vl_config_data {
655 struct vty *vty; /* vty stuff */
656 struct in_addr area_id; /* area ID from command line */
657 int format; /* command line area ID format */
658 struct in_addr vl_peer; /* command line vl_peer */
659 int auth_type; /* Authehntication type, if given */
660 char *auth_key; /* simple password if present */
661 int crypto_key_id; /* Cryptographic key ID */
662 char *md5_key; /* MD5 authentication key */
663 int hello_interval; /* Obvious what these are... */
664 int retransmit_interval;
665 int transmit_delay;
666 int dead_interval;
669 static void
670 ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config,
671 struct vty *vty)
673 memset (vl_config, 0, sizeof (struct ospf_vl_config_data));
674 vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN;
675 vl_config->vty = vty;
678 static struct ospf_vl_data *
679 ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
681 struct ospf_area *area;
682 struct ospf_vl_data *vl_data;
683 struct vty *vty;
684 struct in_addr area_id;
686 vty = vl_config->vty;
687 area_id = vl_config->area_id;
689 if (area_id.s_addr == OSPF_AREA_BACKBONE)
691 vty_out (vty,
692 "Configuring VLs over the backbone is not allowed%s",
693 VTY_NEWLINE);
694 return NULL;
696 area = ospf_area_get (ospf, area_id, vl_config->format);
698 if (area->external_routing != OSPF_AREA_DEFAULT)
700 if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS)
701 vty_out (vty, "Area %s is %s%s",
702 inet_ntoa (area_id),
703 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
704 VTY_NEWLINE);
705 else
706 vty_out (vty, "Area %ld is %s%s",
707 (u_long)ntohl (area_id.s_addr),
708 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
709 VTY_NEWLINE);
710 return NULL;
713 if ((vl_data = ospf_vl_lookup (ospf, area, vl_config->vl_peer)) == NULL)
715 vl_data = ospf_vl_data_new (area, vl_config->vl_peer);
716 if (vl_data->vl_oi == NULL)
718 vl_data->vl_oi = ospf_vl_new (ospf, vl_data);
719 ospf_vl_add (ospf, vl_data);
720 ospf_spf_calculate_schedule (ospf);
723 return vl_data;
727 static int
728 ospf_vl_set_security (struct ospf_vl_data *vl_data,
729 struct ospf_vl_config_data *vl_config)
731 struct crypt_key *ck;
732 struct vty *vty;
733 struct interface *ifp = vl_data->vl_oi->ifp;
735 vty = vl_config->vty;
737 if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN)
739 SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type);
740 IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type;
743 if (vl_config->auth_key)
745 memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1);
746 strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key,
747 OSPF_AUTH_SIMPLE_SIZE);
749 else if (vl_config->md5_key)
751 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id)
752 != NULL)
754 vty_out (vty, "OSPF: Key %d already exists%s",
755 vl_config->crypto_key_id, VTY_NEWLINE);
756 return CMD_WARNING;
758 ck = ospf_crypt_key_new ();
759 ck->key_id = vl_config->crypto_key_id;
760 memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
761 strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE);
763 ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck);
765 else if (vl_config->crypto_key_id != 0)
767 /* Delete a key */
769 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt,
770 vl_config->crypto_key_id) == NULL)
772 vty_out (vty, "OSPF: Key %d does not exist%s",
773 vl_config->crypto_key_id, VTY_NEWLINE);
774 return CMD_WARNING;
777 ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id);
781 return CMD_SUCCESS;
784 static int
785 ospf_vl_set_timers (struct ospf_vl_data *vl_data,
786 struct ospf_vl_config_data *vl_config)
788 struct interface *ifp = ifp = vl_data->vl_oi->ifp;
789 /* Virtual Link data initialised to defaults, so only set
790 if a value given */
791 if (vl_config->hello_interval)
793 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello);
794 IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval;
797 if (vl_config->dead_interval)
799 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait);
800 IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval;
803 if (vl_config->retransmit_interval)
805 SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval);
806 IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval;
809 if (vl_config->transmit_delay)
811 SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay);
812 IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay;
815 return CMD_SUCCESS;
820 /* The business end of all of the above */
821 static int
822 ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
824 struct ospf_vl_data *vl_data;
825 int ret;
827 vl_data = ospf_find_vl_data (ospf, vl_config);
828 if (!vl_data)
829 return CMD_WARNING;
831 /* Process this one first as it can have a fatal result, which can
832 only logically occur if the virtual link exists already
833 Thus a command error does not result in a change to the
834 running configuration such as unexpectedly altered timer
835 values etc.*/
836 ret = ospf_vl_set_security (vl_data, vl_config);
837 if (ret != CMD_SUCCESS)
838 return ret;
840 /* Set any time based parameters, these area already range checked */
842 ret = ospf_vl_set_timers (vl_data, vl_config);
843 if (ret != CMD_SUCCESS)
844 return ret;
846 return CMD_SUCCESS;
850 /* This stuff exists to make specifying all the alias commands A LOT simpler
852 #define VLINK_HELPSTR_IPADDR \
853 "OSPF area parameters\n" \
854 "OSPF area ID in IP address format\n" \
855 "OSPF area ID as a decimal value\n" \
856 "Configure a virtual link\n" \
857 "Router ID of the remote ABR\n"
859 #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
860 "Enable authentication on this virtual link\n" \
861 "dummy string \n"
863 #define VLINK_HELPSTR_AUTHTYPE_ALL \
864 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
865 "Use null authentication\n" \
866 "Use message-digest authentication\n"
868 #define VLINK_HELPSTR_TIME_PARAM_NOSECS \
869 "Time between HELLO packets\n" \
870 "Time between retransmitting lost link state advertisements\n" \
871 "Link state transmit delay\n" \
872 "Interval after which a neighbor is declared dead\n"
874 #define VLINK_HELPSTR_TIME_PARAM \
875 VLINK_HELPSTR_TIME_PARAM_NOSECS \
876 "Seconds\n"
878 #define VLINK_HELPSTR_AUTH_SIMPLE \
879 "Authentication password (key)\n" \
880 "The OSPF password (key)"
882 #define VLINK_HELPSTR_AUTH_MD5 \
883 "Message digest authentication password (key)\n" \
884 "dummy string \n" \
885 "Key ID\n" \
886 "Use MD5 algorithm\n" \
887 "The OSPF password (key)"
889 DEFUN (ospf_area_vlink,
890 ospf_area_vlink_cmd,
891 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
892 VLINK_HELPSTR_IPADDR)
894 struct ospf *ospf = vty->index;
895 struct ospf_vl_config_data vl_config;
896 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
897 char md5_key[OSPF_AUTH_MD5_SIZE+1];
898 int i;
899 int ret;
901 ospf_vl_config_data_init(&vl_config, vty);
903 /* Read off first 2 parameters and check them */
904 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format);
905 if (ret < 0)
907 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
908 return CMD_WARNING;
911 ret = inet_aton (argv[1], &vl_config.vl_peer);
912 if (! ret)
914 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
915 VTY_NEWLINE);
916 return CMD_WARNING;
919 if (argc <=2)
921 /* Thats all folks! - BUGS B. strikes again!!!*/
923 return ospf_vl_set (ospf, &vl_config);
926 /* Deal with other parameters */
927 for (i=2; i < argc; i++)
930 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
932 switch (argv[i][0])
935 case 'a':
936 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
938 /* authentication-key - this option can occur anywhere on
939 command line. At start of command line
940 must check for authentication option. */
941 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
942 strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE);
943 vl_config.auth_key = auth_key;
944 i++;
946 else if (strncmp (argv[i], "authentication", 14) == 0)
948 /* authentication - this option can only occur at start
949 of command line */
950 vl_config.auth_type = OSPF_AUTH_SIMPLE;
951 if ((i+1) < argc)
953 if (strncmp (argv[i+1], "n", 1) == 0)
955 /* "authentication null" */
956 vl_config.auth_type = OSPF_AUTH_NULL;
957 i++;
959 else if (strncmp (argv[i+1], "m", 1) == 0
960 && strcmp (argv[i+1], "message-digest-") != 0)
962 /* "authentication message-digest" */
963 vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
964 i++;
968 break;
970 case 'm':
971 /* message-digest-key */
972 i++;
973 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
974 if (vl_config.crypto_key_id < 0)
975 return CMD_WARNING;
976 i++;
977 memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1);
978 strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE);
979 vl_config.md5_key = md5_key;
980 break;
982 case 'h':
983 /* Hello interval */
984 i++;
985 vl_config.hello_interval = strtol (argv[i], NULL, 10);
986 if (vl_config.hello_interval < 0)
987 return CMD_WARNING;
988 break;
990 case 'r':
991 /* Retransmit Interval */
992 i++;
993 vl_config.retransmit_interval = strtol (argv[i], NULL, 10);
994 if (vl_config.retransmit_interval < 0)
995 return CMD_WARNING;
996 break;
998 case 't':
999 /* Transmit Delay */
1000 i++;
1001 vl_config.transmit_delay = strtol (argv[i], NULL, 10);
1002 if (vl_config.transmit_delay < 0)
1003 return CMD_WARNING;
1004 break;
1006 case 'd':
1007 /* Dead Interval */
1008 i++;
1009 vl_config.dead_interval = strtol (argv[i], NULL, 10);
1010 if (vl_config.dead_interval < 0)
1011 return CMD_WARNING;
1012 break;
1017 /* Action configuration */
1019 return ospf_vl_set (ospf, &vl_config);
1023 DEFUN (no_ospf_area_vlink,
1024 no_ospf_area_vlink_cmd,
1025 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
1026 NO_STR
1027 VLINK_HELPSTR_IPADDR)
1029 struct ospf *ospf = vty->index;
1030 struct ospf_area *area;
1031 struct ospf_vl_config_data vl_config;
1032 struct ospf_vl_data *vl_data = NULL;
1033 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
1034 int i;
1035 int ret, format;
1037 ospf_vl_config_data_init(&vl_config, vty);
1039 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format);
1040 if (ret < 0)
1042 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
1043 return CMD_WARNING;
1046 area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id);
1047 if (!area)
1049 vty_out (vty, "Area does not exist%s", VTY_NEWLINE);
1050 return CMD_WARNING;
1053 ret = inet_aton (argv[1], &vl_config.vl_peer);
1054 if (! ret)
1056 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
1057 VTY_NEWLINE);
1058 return CMD_WARNING;
1061 if (argc <=2)
1063 /* Basic VLink no command */
1064 /* Thats all folks! - BUGS B. strikes again!!!*/
1065 if ((vl_data = ospf_vl_lookup (ospf, area, vl_config.vl_peer)))
1066 ospf_vl_delete (ospf, vl_data);
1068 ospf_area_check_free (ospf, vl_config.area_id);
1070 return CMD_SUCCESS;
1073 /* If we are down here, we are reseting parameters */
1075 /* Deal with other parameters */
1076 for (i=2; i < argc; i++)
1078 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1080 switch (argv[i][0])
1083 case 'a':
1084 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
1086 /* authentication-key - this option can occur anywhere on
1087 command line. At start of command line
1088 must check for authentication option. */
1089 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
1090 vl_config.auth_key = auth_key;
1092 else if (strncmp (argv[i], "authentication", 14) == 0)
1094 /* authentication - this option can only occur at start
1095 of command line */
1096 vl_config.auth_type = OSPF_AUTH_NOTSET;
1098 break;
1100 case 'm':
1101 /* message-digest-key */
1102 /* Delete one key */
1103 i++;
1104 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
1105 if (vl_config.crypto_key_id < 0)
1106 return CMD_WARNING;
1107 vl_config.md5_key = NULL;
1108 break;
1110 case 'h':
1111 /* Hello interval */
1112 vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
1113 break;
1115 case 'r':
1116 /* Retransmit Interval */
1117 vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
1118 break;
1120 case 't':
1121 /* Transmit Delay */
1122 vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
1123 break;
1125 case 'd':
1126 /* Dead Interval */
1127 i++;
1128 vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
1129 break;
1134 /* Action configuration */
1136 return ospf_vl_set (ospf, &vl_config);
1139 ALIAS (ospf_area_vlink,
1140 ospf_area_vlink_param1_cmd,
1141 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1142 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1143 VLINK_HELPSTR_IPADDR
1144 VLINK_HELPSTR_TIME_PARAM)
1146 ALIAS (no_ospf_area_vlink,
1147 no_ospf_area_vlink_param1_cmd,
1148 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1149 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1150 NO_STR
1151 VLINK_HELPSTR_IPADDR
1152 VLINK_HELPSTR_TIME_PARAM)
1154 ALIAS (ospf_area_vlink,
1155 ospf_area_vlink_param2_cmd,
1156 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1157 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1158 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1159 VLINK_HELPSTR_IPADDR
1160 VLINK_HELPSTR_TIME_PARAM
1161 VLINK_HELPSTR_TIME_PARAM)
1163 ALIAS (no_ospf_area_vlink,
1164 no_ospf_area_vlink_param2_cmd,
1165 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1166 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1167 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1168 NO_STR
1169 VLINK_HELPSTR_IPADDR
1170 VLINK_HELPSTR_TIME_PARAM
1171 VLINK_HELPSTR_TIME_PARAM)
1173 ALIAS (ospf_area_vlink,
1174 ospf_area_vlink_param3_cmd,
1175 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1176 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1177 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1178 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1179 VLINK_HELPSTR_IPADDR
1180 VLINK_HELPSTR_TIME_PARAM
1181 VLINK_HELPSTR_TIME_PARAM
1182 VLINK_HELPSTR_TIME_PARAM)
1184 ALIAS (no_ospf_area_vlink,
1185 no_ospf_area_vlink_param3_cmd,
1186 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1187 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1188 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1189 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1190 NO_STR
1191 VLINK_HELPSTR_IPADDR
1192 VLINK_HELPSTR_TIME_PARAM
1193 VLINK_HELPSTR_TIME_PARAM
1194 VLINK_HELPSTR_TIME_PARAM)
1196 ALIAS (ospf_area_vlink,
1197 ospf_area_vlink_param4_cmd,
1198 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1199 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1200 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1201 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1202 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1203 VLINK_HELPSTR_IPADDR
1204 VLINK_HELPSTR_TIME_PARAM
1205 VLINK_HELPSTR_TIME_PARAM
1206 VLINK_HELPSTR_TIME_PARAM
1207 VLINK_HELPSTR_TIME_PARAM)
1209 ALIAS (no_ospf_area_vlink,
1210 no_ospf_area_vlink_param4_cmd,
1211 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1212 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1213 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1214 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1215 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1216 NO_STR
1217 VLINK_HELPSTR_IPADDR
1218 VLINK_HELPSTR_TIME_PARAM
1219 VLINK_HELPSTR_TIME_PARAM
1220 VLINK_HELPSTR_TIME_PARAM
1221 VLINK_HELPSTR_TIME_PARAM)
1223 ALIAS (ospf_area_vlink,
1224 ospf_area_vlink_authtype_args_cmd,
1225 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1226 "(authentication|) (message-digest|null)",
1227 VLINK_HELPSTR_IPADDR
1228 VLINK_HELPSTR_AUTHTYPE_ALL)
1230 ALIAS (ospf_area_vlink,
1231 ospf_area_vlink_authtype_cmd,
1232 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1233 "(authentication|)",
1234 VLINK_HELPSTR_IPADDR
1235 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1237 ALIAS (no_ospf_area_vlink,
1238 no_ospf_area_vlink_authtype_cmd,
1239 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1240 "(authentication|)",
1241 NO_STR
1242 VLINK_HELPSTR_IPADDR
1243 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1245 ALIAS (ospf_area_vlink,
1246 ospf_area_vlink_md5_cmd,
1247 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1248 "(message-digest-key|) <1-255> md5 KEY",
1249 VLINK_HELPSTR_IPADDR
1250 VLINK_HELPSTR_AUTH_MD5)
1252 ALIAS (no_ospf_area_vlink,
1253 no_ospf_area_vlink_md5_cmd,
1254 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1255 "(message-digest-key|) <1-255>",
1256 NO_STR
1257 VLINK_HELPSTR_IPADDR
1258 VLINK_HELPSTR_AUTH_MD5)
1260 ALIAS (ospf_area_vlink,
1261 ospf_area_vlink_authkey_cmd,
1262 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1263 "(authentication-key|) AUTH_KEY",
1264 VLINK_HELPSTR_IPADDR
1265 VLINK_HELPSTR_AUTH_SIMPLE)
1267 ALIAS (no_ospf_area_vlink,
1268 no_ospf_area_vlink_authkey_cmd,
1269 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1270 "(authentication-key|)",
1271 NO_STR
1272 VLINK_HELPSTR_IPADDR
1273 VLINK_HELPSTR_AUTH_SIMPLE)
1275 ALIAS (ospf_area_vlink,
1276 ospf_area_vlink_authtype_args_authkey_cmd,
1277 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1278 "(authentication|) (message-digest|null) "
1279 "(authentication-key|) AUTH_KEY",
1280 VLINK_HELPSTR_IPADDR
1281 VLINK_HELPSTR_AUTHTYPE_ALL
1282 VLINK_HELPSTR_AUTH_SIMPLE)
1284 ALIAS (ospf_area_vlink,
1285 ospf_area_vlink_authtype_authkey_cmd,
1286 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1287 "(authentication|) "
1288 "(authentication-key|) AUTH_KEY",
1289 VLINK_HELPSTR_IPADDR
1290 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1291 VLINK_HELPSTR_AUTH_SIMPLE)
1293 ALIAS (no_ospf_area_vlink,
1294 no_ospf_area_vlink_authtype_authkey_cmd,
1295 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1296 "(authentication|) "
1297 "(authentication-key|)",
1298 NO_STR
1299 VLINK_HELPSTR_IPADDR
1300 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1301 VLINK_HELPSTR_AUTH_SIMPLE)
1303 ALIAS (ospf_area_vlink,
1304 ospf_area_vlink_authtype_args_md5_cmd,
1305 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1306 "(authentication|) (message-digest|null) "
1307 "(message-digest-key|) <1-255> md5 KEY",
1308 VLINK_HELPSTR_IPADDR
1309 VLINK_HELPSTR_AUTHTYPE_ALL
1310 VLINK_HELPSTR_AUTH_MD5)
1312 ALIAS (ospf_area_vlink,
1313 ospf_area_vlink_authtype_md5_cmd,
1314 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1315 "(authentication|) "
1316 "(message-digest-key|) <1-255> md5 KEY",
1317 VLINK_HELPSTR_IPADDR
1318 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1319 VLINK_HELPSTR_AUTH_MD5)
1321 ALIAS (no_ospf_area_vlink,
1322 no_ospf_area_vlink_authtype_md5_cmd,
1323 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1324 "(authentication|) "
1325 "(message-digest-key|)",
1326 NO_STR
1327 VLINK_HELPSTR_IPADDR
1328 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1329 VLINK_HELPSTR_AUTH_MD5)
1332 DEFUN (ospf_area_shortcut,
1333 ospf_area_shortcut_cmd,
1334 "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)",
1335 "OSPF area parameters\n"
1336 "OSPF area ID in IP address format\n"
1337 "OSPF area ID as a decimal value\n"
1338 "Configure the area's shortcutting mode\n"
1339 "Set default shortcutting behavior\n"
1340 "Enable shortcutting through the area\n"
1341 "Disable shortcutting through the area\n")
1343 struct ospf *ospf = vty->index;
1344 struct ospf_area *area;
1345 struct in_addr area_id;
1346 int mode;
1347 int format;
1349 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1351 area = ospf_area_get (ospf, area_id, format);
1353 if (strncmp (argv[1], "de", 2) == 0)
1354 mode = OSPF_SHORTCUT_DEFAULT;
1355 else if (strncmp (argv[1], "di", 2) == 0)
1356 mode = OSPF_SHORTCUT_DISABLE;
1357 else if (strncmp (argv[1], "e", 1) == 0)
1358 mode = OSPF_SHORTCUT_ENABLE;
1359 else
1360 return CMD_WARNING;
1362 ospf_area_shortcut_set (ospf, area, mode);
1364 if (ospf->abr_type != OSPF_ABR_SHORTCUT)
1365 vty_out (vty, "Shortcut area setting will take effect "
1366 "only when the router is configured as Shortcut ABR%s",
1367 VTY_NEWLINE);
1369 return CMD_SUCCESS;
1372 DEFUN (no_ospf_area_shortcut,
1373 no_ospf_area_shortcut_cmd,
1374 "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)",
1375 NO_STR
1376 "OSPF area parameters\n"
1377 "OSPF area ID in IP address format\n"
1378 "OSPF area ID as a decimal value\n"
1379 "Deconfigure the area's shortcutting mode\n"
1380 "Deconfigure enabled shortcutting through the area\n"
1381 "Deconfigure disabled shortcutting through the area\n")
1383 struct ospf *ospf = vty->index;
1384 struct ospf_area *area;
1385 struct in_addr area_id;
1386 int format;
1388 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1390 area = ospf_area_lookup_by_area_id (ospf, area_id);
1391 if (!area)
1392 return CMD_SUCCESS;
1394 ospf_area_shortcut_unset (ospf, area);
1396 return CMD_SUCCESS;
1400 DEFUN (ospf_area_stub,
1401 ospf_area_stub_cmd,
1402 "area (A.B.C.D|<0-4294967295>) stub",
1403 "OSPF area parameters\n"
1404 "OSPF area ID in IP address format\n"
1405 "OSPF area ID as a decimal value\n"
1406 "Configure OSPF area as stub\n")
1408 struct ospf *ospf = vty->index;
1409 struct in_addr area_id;
1410 int ret, format;
1412 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1414 ret = ospf_area_stub_set (ospf, area_id);
1415 if (ret == 0)
1417 vty_out (vty, "First deconfigure all virtual link through this area%s",
1418 VTY_NEWLINE);
1419 return CMD_WARNING;
1422 ospf_area_no_summary_unset (ospf, area_id);
1424 return CMD_SUCCESS;
1427 DEFUN (ospf_area_stub_no_summary,
1428 ospf_area_stub_no_summary_cmd,
1429 "area (A.B.C.D|<0-4294967295>) stub no-summary",
1430 "OSPF stub parameters\n"
1431 "OSPF area ID in IP address format\n"
1432 "OSPF area ID as a decimal value\n"
1433 "Configure OSPF area as stub\n"
1434 "Do not inject inter-area routes into stub\n")
1436 struct ospf *ospf = vty->index;
1437 struct in_addr area_id;
1438 int ret, format;
1440 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1442 ret = ospf_area_stub_set (ospf, area_id);
1443 if (ret == 0)
1445 vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s",
1446 VTY_NEWLINE);
1447 return CMD_WARNING;
1450 ospf_area_no_summary_set (ospf, area_id);
1452 return CMD_SUCCESS;
1455 DEFUN (no_ospf_area_stub,
1456 no_ospf_area_stub_cmd,
1457 "no area (A.B.C.D|<0-4294967295>) stub",
1458 NO_STR
1459 "OSPF area parameters\n"
1460 "OSPF area ID in IP address format\n"
1461 "OSPF area ID as a decimal value\n"
1462 "Configure OSPF area as stub\n")
1464 struct ospf *ospf = vty->index;
1465 struct in_addr area_id;
1466 int format;
1468 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1470 ospf_area_stub_unset (ospf, area_id);
1471 ospf_area_no_summary_unset (ospf, area_id);
1473 return CMD_SUCCESS;
1476 DEFUN (no_ospf_area_stub_no_summary,
1477 no_ospf_area_stub_no_summary_cmd,
1478 "no area (A.B.C.D|<0-4294967295>) stub no-summary",
1479 NO_STR
1480 "OSPF area parameters\n"
1481 "OSPF area ID in IP address format\n"
1482 "OSPF area ID as a decimal value\n"
1483 "Configure OSPF area as stub\n"
1484 "Do not inject inter-area routes into area\n")
1486 struct ospf *ospf = vty->index;
1487 struct in_addr area_id;
1488 int format;
1490 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1491 ospf_area_no_summary_unset (ospf, area_id);
1493 return CMD_SUCCESS;
1496 static int
1497 ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[],
1498 int nosum)
1500 struct ospf *ospf = vty->index;
1501 struct in_addr area_id;
1502 int ret, format;
1504 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1506 ret = ospf_area_nssa_set (ospf, area_id);
1507 if (ret == 0)
1509 vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s",
1510 VTY_NEWLINE);
1511 return CMD_WARNING;
1514 if (argc > 1)
1516 if (strncmp (argv[1], "translate-c", 11) == 0)
1517 ospf_area_nssa_translator_role_set (ospf, area_id,
1518 OSPF_NSSA_ROLE_CANDIDATE);
1519 else if (strncmp (argv[1], "translate-n", 11) == 0)
1520 ospf_area_nssa_translator_role_set (ospf, area_id,
1521 OSPF_NSSA_ROLE_NEVER);
1522 else if (strncmp (argv[1], "translate-a", 11) == 0)
1523 ospf_area_nssa_translator_role_set (ospf, area_id,
1524 OSPF_NSSA_ROLE_ALWAYS);
1526 else
1528 ospf_area_nssa_translator_role_set (ospf, area_id,
1529 OSPF_NSSA_ROLE_CANDIDATE);
1532 if (nosum)
1533 ospf_area_no_summary_set (ospf, area_id);
1534 else
1535 ospf_area_no_summary_unset (ospf, area_id);
1537 ospf_schedule_abr_task (ospf);
1539 return CMD_SUCCESS;
1542 DEFUN (ospf_area_nssa_translate_no_summary,
1543 ospf_area_nssa_translate_no_summary_cmd,
1544 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary",
1545 "OSPF area parameters\n"
1546 "OSPF area ID in IP address format\n"
1547 "OSPF area ID as a decimal value\n"
1548 "Configure OSPF area as nssa\n"
1549 "Configure NSSA-ABR for translate election (default)\n"
1550 "Configure NSSA-ABR to never translate\n"
1551 "Configure NSSA-ABR to always translate\n"
1552 "Do not inject inter-area routes into nssa\n")
1554 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
1557 DEFUN (ospf_area_nssa_translate,
1558 ospf_area_nssa_translate_cmd,
1559 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)",
1560 "OSPF area parameters\n"
1561 "OSPF area ID in IP address format\n"
1562 "OSPF area ID as a decimal value\n"
1563 "Configure OSPF area as nssa\n"
1564 "Configure NSSA-ABR for translate election (default)\n"
1565 "Configure NSSA-ABR to never translate\n"
1566 "Configure NSSA-ABR to always translate\n")
1568 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1571 DEFUN (ospf_area_nssa,
1572 ospf_area_nssa_cmd,
1573 "area (A.B.C.D|<0-4294967295>) nssa",
1574 "OSPF area parameters\n"
1575 "OSPF area ID in IP address format\n"
1576 "OSPF area ID as a decimal value\n"
1577 "Configure OSPF area as nssa\n")
1579 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1582 DEFUN (ospf_area_nssa_no_summary,
1583 ospf_area_nssa_no_summary_cmd,
1584 "area (A.B.C.D|<0-4294967295>) nssa no-summary",
1585 "OSPF area parameters\n"
1586 "OSPF area ID in IP address format\n"
1587 "OSPF area ID as a decimal value\n"
1588 "Configure OSPF area as nssa\n"
1589 "Do not inject inter-area routes into nssa\n")
1591 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
1594 DEFUN (no_ospf_area_nssa,
1595 no_ospf_area_nssa_cmd,
1596 "no area (A.B.C.D|<0-4294967295>) nssa",
1597 NO_STR
1598 "OSPF area parameters\n"
1599 "OSPF area ID in IP address format\n"
1600 "OSPF area ID as a decimal value\n"
1601 "Configure OSPF area as nssa\n")
1603 struct ospf *ospf = vty->index;
1604 struct in_addr area_id;
1605 int format;
1607 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1609 ospf_area_nssa_unset (ospf, area_id);
1610 ospf_area_no_summary_unset (ospf, area_id);
1612 ospf_schedule_abr_task (ospf);
1614 return CMD_SUCCESS;
1617 DEFUN (no_ospf_area_nssa_no_summary,
1618 no_ospf_area_nssa_no_summary_cmd,
1619 "no area (A.B.C.D|<0-4294967295>) nssa no-summary",
1620 NO_STR
1621 "OSPF area parameters\n"
1622 "OSPF area ID in IP address format\n"
1623 "OSPF area ID as a decimal value\n"
1624 "Configure OSPF area as nssa\n"
1625 "Do not inject inter-area routes into nssa\n")
1627 struct ospf *ospf = vty->index;
1628 struct in_addr area_id;
1629 int format;
1631 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1632 ospf_area_no_summary_unset (ospf, area_id);
1634 return CMD_SUCCESS;
1637 DEFUN (ospf_area_default_cost,
1638 ospf_area_default_cost_cmd,
1639 "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1640 "OSPF area parameters\n"
1641 "OSPF area ID in IP address format\n"
1642 "OSPF area ID as a decimal value\n"
1643 "Set the summary-default cost of a NSSA or stub area\n"
1644 "Stub's advertised default summary cost\n")
1646 struct ospf *ospf = vty->index;
1647 struct ospf_area *area;
1648 struct in_addr area_id;
1649 u_int32_t cost;
1650 int format;
1651 struct prefix_ipv4 p;
1653 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1654 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1656 area = ospf_area_get (ospf, area_id, format);
1658 if (area->external_routing == OSPF_AREA_DEFAULT)
1660 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1661 return CMD_WARNING;
1664 area->default_cost = cost;
1666 p.family = AF_INET;
1667 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1668 p.prefixlen = 0;
1669 if (IS_DEBUG_OSPF_EVENT)
1670 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1671 "announcing 0.0.0.0/0 to area %s",
1672 inet_ntoa (area->area_id));
1673 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1675 return CMD_SUCCESS;
1678 DEFUN (no_ospf_area_default_cost,
1679 no_ospf_area_default_cost_cmd,
1680 "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1681 NO_STR
1682 "OSPF area parameters\n"
1683 "OSPF area ID in IP address format\n"
1684 "OSPF area ID as a decimal value\n"
1685 "Set the summary-default cost of a NSSA or stub area\n"
1686 "Stub's advertised default summary cost\n")
1688 struct ospf *ospf = vty->index;
1689 struct ospf_area *area;
1690 struct in_addr area_id;
1691 u_int32_t cost;
1692 int format;
1693 struct prefix_ipv4 p;
1695 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1696 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1698 area = ospf_area_lookup_by_area_id (ospf, area_id);
1699 if (area == NULL)
1700 return CMD_SUCCESS;
1702 if (area->external_routing == OSPF_AREA_DEFAULT)
1704 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1705 return CMD_WARNING;
1708 area->default_cost = 1;
1710 p.family = AF_INET;
1711 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1712 p.prefixlen = 0;
1713 if (IS_DEBUG_OSPF_EVENT)
1714 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1715 "announcing 0.0.0.0/0 to area %s",
1716 inet_ntoa (area->area_id));
1717 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1720 ospf_area_check_free (ospf, area_id);
1722 return CMD_SUCCESS;
1725 DEFUN (ospf_area_export_list,
1726 ospf_area_export_list_cmd,
1727 "area (A.B.C.D|<0-4294967295>) export-list NAME",
1728 "OSPF area parameters\n"
1729 "OSPF area ID in IP address format\n"
1730 "OSPF area ID as a decimal value\n"
1731 "Set the filter for networks announced to other areas\n"
1732 "Name of the access-list\n")
1734 struct ospf *ospf = vty->index;
1735 struct ospf_area *area;
1736 struct in_addr area_id;
1737 int format;
1739 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1741 area = ospf_area_get (ospf, area_id, format);
1742 ospf_area_export_list_set (ospf, area, argv[1]);
1744 return CMD_SUCCESS;
1747 DEFUN (no_ospf_area_export_list,
1748 no_ospf_area_export_list_cmd,
1749 "no area (A.B.C.D|<0-4294967295>) export-list NAME",
1750 NO_STR
1751 "OSPF area parameters\n"
1752 "OSPF area ID in IP address format\n"
1753 "OSPF area ID as a decimal value\n"
1754 "Unset the filter for networks announced to other areas\n"
1755 "Name of the access-list\n")
1757 struct ospf *ospf = vty->index;
1758 struct ospf_area *area;
1759 struct in_addr area_id;
1760 int format;
1762 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1764 area = ospf_area_lookup_by_area_id (ospf, area_id);
1765 if (area == NULL)
1766 return CMD_SUCCESS;
1768 ospf_area_export_list_unset (ospf, area);
1770 return CMD_SUCCESS;
1774 DEFUN (ospf_area_import_list,
1775 ospf_area_import_list_cmd,
1776 "area (A.B.C.D|<0-4294967295>) import-list NAME",
1777 "OSPF area parameters\n"
1778 "OSPF area ID in IP address format\n"
1779 "OSPF area ID as a decimal value\n"
1780 "Set the filter for networks from other areas announced to the specified one\n"
1781 "Name of the access-list\n")
1783 struct ospf *ospf = vty->index;
1784 struct ospf_area *area;
1785 struct in_addr area_id;
1786 int format;
1788 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1790 area = ospf_area_get (ospf, area_id, format);
1791 ospf_area_import_list_set (ospf, area, argv[1]);
1793 return CMD_SUCCESS;
1796 DEFUN (no_ospf_area_import_list,
1797 no_ospf_area_import_list_cmd,
1798 "no area (A.B.C.D|<0-4294967295>) import-list NAME",
1799 NO_STR
1800 "OSPF area parameters\n"
1801 "OSPF area ID in IP address format\n"
1802 "OSPF area ID as a decimal value\n"
1803 "Unset the filter for networks announced to other areas\n"
1804 "Name of the access-list\n")
1806 struct ospf *ospf = vty->index;
1807 struct ospf_area *area;
1808 struct in_addr area_id;
1809 int format;
1811 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1813 area = ospf_area_lookup_by_area_id (ospf, area_id);
1814 if (area == NULL)
1815 return CMD_SUCCESS;
1817 ospf_area_import_list_unset (ospf, area);
1819 return CMD_SUCCESS;
1822 DEFUN (ospf_area_filter_list,
1823 ospf_area_filter_list_cmd,
1824 "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1825 "OSPF area parameters\n"
1826 "OSPF area ID in IP address format\n"
1827 "OSPF area ID as a decimal value\n"
1828 "Filter networks between OSPF areas\n"
1829 "Filter prefixes between OSPF areas\n"
1830 "Name of an IP prefix-list\n"
1831 "Filter networks sent to this area\n"
1832 "Filter networks sent from this area\n")
1834 struct ospf *ospf = vty->index;
1835 struct ospf_area *area;
1836 struct in_addr area_id;
1837 struct prefix_list *plist;
1838 int format;
1840 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1842 area = ospf_area_get (ospf, area_id, format);
1843 plist = prefix_list_lookup (AFI_IP, argv[1]);
1844 if (strncmp (argv[2], "in", 2) == 0)
1846 PREFIX_LIST_IN (area) = plist;
1847 if (PREFIX_NAME_IN (area))
1848 free (PREFIX_NAME_IN (area));
1850 PREFIX_NAME_IN (area) = strdup (argv[1]);
1851 ospf_schedule_abr_task (ospf);
1853 else
1855 PREFIX_LIST_OUT (area) = plist;
1856 if (PREFIX_NAME_OUT (area))
1857 free (PREFIX_NAME_OUT (area));
1859 PREFIX_NAME_OUT (area) = strdup (argv[1]);
1860 ospf_schedule_abr_task (ospf);
1863 return CMD_SUCCESS;
1866 DEFUN (no_ospf_area_filter_list,
1867 no_ospf_area_filter_list_cmd,
1868 "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1869 NO_STR
1870 "OSPF area parameters\n"
1871 "OSPF area ID in IP address format\n"
1872 "OSPF area ID as a decimal value\n"
1873 "Filter networks between OSPF areas\n"
1874 "Filter prefixes between OSPF areas\n"
1875 "Name of an IP prefix-list\n"
1876 "Filter networks sent to this area\n"
1877 "Filter networks sent from this area\n")
1879 struct ospf *ospf = vty->index;
1880 struct ospf_area *area;
1881 struct in_addr area_id;
1882 struct prefix_list *plist;
1883 int format;
1885 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1887 if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL)
1888 return CMD_SUCCESS;
1890 plist = prefix_list_lookup (AFI_IP, argv[1]);
1891 if (strncmp (argv[2], "in", 2) == 0)
1893 if (PREFIX_NAME_IN (area))
1894 if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0)
1895 return CMD_SUCCESS;
1897 PREFIX_LIST_IN (area) = NULL;
1898 if (PREFIX_NAME_IN (area))
1899 free (PREFIX_NAME_IN (area));
1901 PREFIX_NAME_IN (area) = NULL;
1903 ospf_schedule_abr_task (ospf);
1905 else
1907 if (PREFIX_NAME_OUT (area))
1908 if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0)
1909 return CMD_SUCCESS;
1911 PREFIX_LIST_OUT (area) = NULL;
1912 if (PREFIX_NAME_OUT (area))
1913 free (PREFIX_NAME_OUT (area));
1915 PREFIX_NAME_OUT (area) = NULL;
1917 ospf_schedule_abr_task (ospf);
1920 return CMD_SUCCESS;
1924 DEFUN (ospf_area_authentication_message_digest,
1925 ospf_area_authentication_message_digest_cmd,
1926 "area (A.B.C.D|<0-4294967295>) authentication message-digest",
1927 "OSPF area parameters\n"
1928 "Enable authentication\n"
1929 "Use message-digest authentication\n")
1931 struct ospf *ospf = vty->index;
1932 struct ospf_area *area;
1933 struct in_addr area_id;
1934 int format;
1936 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1938 area = ospf_area_get (ospf, area_id, format);
1939 area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
1941 return CMD_SUCCESS;
1944 DEFUN (ospf_area_authentication,
1945 ospf_area_authentication_cmd,
1946 "area (A.B.C.D|<0-4294967295>) authentication",
1947 "OSPF area parameters\n"
1948 "OSPF area ID in IP address format\n"
1949 "OSPF area ID as a decimal value\n"
1950 "Enable authentication\n")
1952 struct ospf *ospf = vty->index;
1953 struct ospf_area *area;
1954 struct in_addr area_id;
1955 int format;
1957 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1959 area = ospf_area_get (ospf, area_id, format);
1960 area->auth_type = OSPF_AUTH_SIMPLE;
1962 return CMD_SUCCESS;
1965 DEFUN (no_ospf_area_authentication,
1966 no_ospf_area_authentication_cmd,
1967 "no area (A.B.C.D|<0-4294967295>) authentication",
1968 NO_STR
1969 "OSPF area parameters\n"
1970 "OSPF area ID in IP address format\n"
1971 "OSPF area ID as a decimal value\n"
1972 "Enable authentication\n")
1974 struct ospf *ospf = vty->index;
1975 struct ospf_area *area;
1976 struct in_addr area_id;
1977 int format;
1979 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1981 area = ospf_area_lookup_by_area_id (ospf, area_id);
1982 if (area == NULL)
1983 return CMD_SUCCESS;
1985 area->auth_type = OSPF_AUTH_NULL;
1987 ospf_area_check_free (ospf, area_id);
1989 return CMD_SUCCESS;
1993 DEFUN (ospf_abr_type,
1994 ospf_abr_type_cmd,
1995 "ospf abr-type (cisco|ibm|shortcut|standard)",
1996 "OSPF specific commands\n"
1997 "Set OSPF ABR type\n"
1998 "Alternative ABR, cisco implementation\n"
1999 "Alternative ABR, IBM implementation\n"
2000 "Shortcut ABR\n"
2001 "Standard behavior (RFC2328)\n")
2003 struct ospf *ospf = vty->index;
2004 u_char abr_type = OSPF_ABR_UNKNOWN;
2006 if (strncmp (argv[0], "c", 1) == 0)
2007 abr_type = OSPF_ABR_CISCO;
2008 else if (strncmp (argv[0], "i", 1) == 0)
2009 abr_type = OSPF_ABR_IBM;
2010 else if (strncmp (argv[0], "sh", 2) == 0)
2011 abr_type = OSPF_ABR_SHORTCUT;
2012 else if (strncmp (argv[0], "st", 2) == 0)
2013 abr_type = OSPF_ABR_STAND;
2014 else
2015 return CMD_WARNING;
2017 /* If ABR type value is changed, schedule ABR task. */
2018 if (ospf->abr_type != abr_type)
2020 ospf->abr_type = abr_type;
2021 ospf_schedule_abr_task (ospf);
2024 return CMD_SUCCESS;
2027 DEFUN (no_ospf_abr_type,
2028 no_ospf_abr_type_cmd,
2029 "no ospf abr-type (cisco|ibm|shortcut|standard)",
2030 NO_STR
2031 "OSPF specific commands\n"
2032 "Set OSPF ABR type\n"
2033 "Alternative ABR, cisco implementation\n"
2034 "Alternative ABR, IBM implementation\n"
2035 "Shortcut ABR\n")
2037 struct ospf *ospf = vty->index;
2038 u_char abr_type = OSPF_ABR_UNKNOWN;
2040 if (strncmp (argv[0], "c", 1) == 0)
2041 abr_type = OSPF_ABR_CISCO;
2042 else if (strncmp (argv[0], "i", 1) == 0)
2043 abr_type = OSPF_ABR_IBM;
2044 else if (strncmp (argv[0], "s", 1) == 0)
2045 abr_type = OSPF_ABR_SHORTCUT;
2046 else
2047 return CMD_WARNING;
2049 /* If ABR type value is changed, schedule ABR task. */
2050 if (ospf->abr_type == abr_type)
2052 ospf->abr_type = OSPF_ABR_DEFAULT;
2053 ospf_schedule_abr_task (ospf);
2056 return CMD_SUCCESS;
2059 DEFUN (ospf_log_adjacency_changes,
2060 ospf_log_adjacency_changes_cmd,
2061 "log-adjacency-changes",
2062 "Log changes in adjacency state\n")
2064 struct ospf *ospf = vty->index;
2066 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2067 return CMD_SUCCESS;
2070 DEFUN (ospf_log_adjacency_changes_detail,
2071 ospf_log_adjacency_changes_detail_cmd,
2072 "log-adjacency-changes detail",
2073 "Log changes in adjacency state\n"
2074 "Log all state changes\n")
2076 struct ospf *ospf = vty->index;
2078 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2079 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2080 return CMD_SUCCESS;
2083 DEFUN (no_ospf_log_adjacency_changes,
2084 no_ospf_log_adjacency_changes_cmd,
2085 "no log-adjacency-changes",
2086 NO_STR
2087 "Log changes in adjacency state\n")
2089 struct ospf *ospf = vty->index;
2091 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2092 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2093 return CMD_SUCCESS;
2096 DEFUN (no_ospf_log_adjacency_changes_detail,
2097 no_ospf_log_adjacency_changes_detail_cmd,
2098 "no log-adjacency-changes detail",
2099 NO_STR
2100 "Log changes in adjacency state\n"
2101 "Log all state changes\n")
2103 struct ospf *ospf = vty->index;
2105 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2106 return CMD_SUCCESS;
2109 DEFUN (ospf_compatible_rfc1583,
2110 ospf_compatible_rfc1583_cmd,
2111 "compatible rfc1583",
2112 "OSPF compatibility list\n"
2113 "compatible with RFC 1583\n")
2115 struct ospf *ospf = vty->index;
2117 if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2119 SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
2120 ospf_spf_calculate_schedule (ospf);
2122 return CMD_SUCCESS;
2125 DEFUN (no_ospf_compatible_rfc1583,
2126 no_ospf_compatible_rfc1583_cmd,
2127 "no compatible rfc1583",
2128 NO_STR
2129 "OSPF compatibility list\n"
2130 "compatible with RFC 1583\n")
2132 struct ospf *ospf = vty->index;
2134 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2136 UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
2137 ospf_spf_calculate_schedule (ospf);
2139 return CMD_SUCCESS;
2142 ALIAS (ospf_compatible_rfc1583,
2143 ospf_rfc1583_flag_cmd,
2144 "ospf rfc1583compatibility",
2145 "OSPF specific commands\n"
2146 "Enable the RFC1583Compatibility flag\n")
2148 ALIAS (no_ospf_compatible_rfc1583,
2149 no_ospf_rfc1583_flag_cmd,
2150 "no ospf rfc1583compatibility",
2151 NO_STR
2152 "OSPF specific commands\n"
2153 "Disable the RFC1583Compatibility flag\n")
2155 static int
2156 ospf_timers_spf_set (struct vty *vty, unsigned int delay,
2157 unsigned int hold,
2158 unsigned int max)
2160 struct ospf *ospf = vty->index;
2162 ospf->spf_delay = delay;
2163 ospf->spf_holdtime = hold;
2164 ospf->spf_max_holdtime = max;
2166 return CMD_SUCCESS;
2169 DEFUN (ospf_timers_throttle_spf,
2170 ospf_timers_throttle_spf_cmd,
2171 "timers throttle spf <0-600000> <0-600000> <0-600000>",
2172 "Adjust routing timers\n"
2173 "Throttling adaptive timer\n"
2174 "OSPF SPF timers\n"
2175 "Delay (msec) from first change received till SPF calculation\n"
2176 "Initial hold time (msec) between consecutive SPF calculations\n"
2177 "Maximum hold time (msec)\n")
2179 unsigned int delay, hold, max;
2181 if (argc != 3)
2183 vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
2184 return CMD_WARNING;
2187 VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000);
2188 VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000);
2189 VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000);
2191 return ospf_timers_spf_set (vty, delay, hold, max);
2194 DEFUN_DEPRECATED (ospf_timers_spf,
2195 ospf_timers_spf_cmd,
2196 "timers spf <0-4294967295> <0-4294967295>",
2197 "Adjust routing timers\n"
2198 "OSPF SPF timers\n"
2199 "Delay (s) between receiving a change to SPF calculation\n"
2200 "Hold time (s) between consecutive SPF calculations\n")
2202 unsigned int delay, hold;
2204 if (argc != 2)
2206 vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE);
2207 return CMD_WARNING;
2210 VTY_GET_INTEGER ("SPF delay timer", delay, argv[0]);
2211 VTY_GET_INTEGER ("SPF hold timer", hold, argv[1]);
2213 /* truncate down the second values if they're greater than 600000ms */
2214 if (delay > (600000 / 1000))
2215 delay = 600000;
2216 else if (delay == 0)
2217 /* 0s delay was probably specified because of lack of ms resolution */
2218 delay = OSPF_SPF_DELAY_DEFAULT;
2219 if (hold > (600000 / 1000))
2220 hold = 600000;
2222 return ospf_timers_spf_set (vty, delay * 1000, hold * 1000, hold * 1000);
2225 DEFUN (no_ospf_timers_throttle_spf,
2226 no_ospf_timers_throttle_spf_cmd,
2227 "no timers throttle spf",
2228 NO_STR
2229 "Adjust routing timers\n"
2230 "Throttling adaptive timer\n"
2231 "OSPF SPF timers\n")
2233 return ospf_timers_spf_set (vty,
2234 OSPF_SPF_DELAY_DEFAULT,
2235 OSPF_SPF_HOLDTIME_DEFAULT,
2236 OSPF_SPF_MAX_HOLDTIME_DEFAULT);
2239 ALIAS_DEPRECATED (no_ospf_timers_throttle_spf,
2240 no_ospf_timers_spf_cmd,
2241 "no timers spf",
2242 NO_STR
2243 "Adjust routing timers\n"
2244 "OSPF SPF timers\n")
2246 DEFUN (ospf_neighbor,
2247 ospf_neighbor_cmd,
2248 "neighbor A.B.C.D",
2249 NEIGHBOR_STR
2250 "Neighbor IP address\n")
2252 struct ospf *ospf = vty->index;
2253 struct in_addr nbr_addr;
2254 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2255 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
2257 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2259 if (argc > 1)
2260 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255);
2262 if (argc > 2)
2263 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535);
2265 ospf_nbr_nbma_set (ospf, nbr_addr);
2266 if (argc > 1)
2267 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2268 if (argc > 2)
2269 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, priority);
2271 return CMD_SUCCESS;
2274 ALIAS (ospf_neighbor,
2275 ospf_neighbor_priority_poll_interval_cmd,
2276 "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2277 NEIGHBOR_STR
2278 "Neighbor IP address\n"
2279 "Neighbor Priority\n"
2280 "Priority\n"
2281 "Dead Neighbor Polling interval\n"
2282 "Seconds\n")
2284 ALIAS (ospf_neighbor,
2285 ospf_neighbor_priority_cmd,
2286 "neighbor A.B.C.D priority <0-255>",
2287 NEIGHBOR_STR
2288 "Neighbor IP address\n"
2289 "Neighbor Priority\n"
2290 "Seconds\n")
2292 DEFUN (ospf_neighbor_poll_interval,
2293 ospf_neighbor_poll_interval_cmd,
2294 "neighbor A.B.C.D poll-interval <1-65535>",
2295 NEIGHBOR_STR
2296 "Neighbor IP address\n"
2297 "Dead Neighbor Polling interval\n"
2298 "Seconds\n")
2300 struct ospf *ospf = vty->index;
2301 struct in_addr nbr_addr;
2302 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2303 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
2305 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2307 if (argc > 1)
2308 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535);
2310 if (argc > 2)
2311 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255);
2313 ospf_nbr_nbma_set (ospf, nbr_addr);
2314 if (argc > 1)
2315 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
2316 if (argc > 2)
2317 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2319 return CMD_SUCCESS;
2322 ALIAS (ospf_neighbor_poll_interval,
2323 ospf_neighbor_poll_interval_priority_cmd,
2324 "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2325 NEIGHBOR_STR
2326 "Neighbor address\n"
2327 "OSPF dead-router polling interval\n"
2328 "Seconds\n"
2329 "OSPF priority of non-broadcast neighbor\n"
2330 "Priority\n")
2332 DEFUN (no_ospf_neighbor,
2333 no_ospf_neighbor_cmd,
2334 "no neighbor A.B.C.D",
2335 NO_STR
2336 NEIGHBOR_STR
2337 "Neighbor IP address\n")
2339 struct ospf *ospf = vty->index;
2340 struct in_addr nbr_addr;
2341 int ret;
2343 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2345 ret = ospf_nbr_nbma_unset (ospf, nbr_addr);
2347 return CMD_SUCCESS;
2350 ALIAS (no_ospf_neighbor,
2351 no_ospf_neighbor_priority_cmd,
2352 "no neighbor A.B.C.D priority <0-255>",
2353 NO_STR
2354 NEIGHBOR_STR
2355 "Neighbor IP address\n"
2356 "Neighbor Priority\n"
2357 "Priority\n")
2359 ALIAS (no_ospf_neighbor,
2360 no_ospf_neighbor_poll_interval_cmd,
2361 "no neighbor A.B.C.D poll-interval <1-65535>",
2362 NO_STR
2363 NEIGHBOR_STR
2364 "Neighbor IP address\n"
2365 "Dead Neighbor Polling interval\n"
2366 "Seconds\n")
2368 ALIAS (no_ospf_neighbor,
2369 no_ospf_neighbor_priority_pollinterval_cmd,
2370 "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2371 NO_STR
2372 NEIGHBOR_STR
2373 "Neighbor IP address\n"
2374 "Neighbor Priority\n"
2375 "Priority\n"
2376 "Dead Neighbor Polling interval\n"
2377 "Seconds\n")
2380 DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd,
2381 "refresh timer <10-1800>",
2382 "Adjust refresh parameters\n"
2383 "Set refresh timer\n"
2384 "Timer value in seconds\n")
2386 struct ospf *ospf = vty->index;
2387 unsigned int interval;
2389 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2390 interval = (interval / 10) * 10;
2392 ospf_timers_refresh_set (ospf, interval);
2394 return CMD_SUCCESS;
2397 DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd,
2398 "no refresh timer <10-1800>",
2399 "Adjust refresh parameters\n"
2400 "Unset refresh timer\n"
2401 "Timer value in seconds\n")
2403 struct ospf *ospf = vty->index;
2404 unsigned int interval;
2406 if (argc == 1)
2408 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2410 if (ospf->lsa_refresh_interval != interval ||
2411 interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
2412 return CMD_SUCCESS;
2415 ospf_timers_refresh_unset (ospf);
2417 return CMD_SUCCESS;
2420 ALIAS (no_ospf_refresh_timer,
2421 no_ospf_refresh_timer_cmd,
2422 "no refresh timer",
2423 "Adjust refresh parameters\n"
2424 "Unset refresh timer\n")
2426 DEFUN (ospf_auto_cost_reference_bandwidth,
2427 ospf_auto_cost_reference_bandwidth_cmd,
2428 "auto-cost reference-bandwidth <1-4294967>",
2429 "Calculate OSPF interface cost according to bandwidth\n"
2430 "Use reference bandwidth method to assign OSPF cost\n"
2431 "The reference bandwidth in terms of Mbits per second\n")
2433 struct ospf *ospf = vty->index;
2434 u_int32_t refbw;
2435 struct listnode *node;
2436 struct interface *ifp;
2438 refbw = strtol (argv[0], NULL, 10);
2439 if (refbw < 1 || refbw > 4294967)
2441 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
2442 return CMD_WARNING;
2445 /* If reference bandwidth is changed. */
2446 if ((refbw * 1000) == ospf->ref_bandwidth)
2447 return CMD_SUCCESS;
2449 ospf->ref_bandwidth = refbw * 1000;
2450 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
2451 ospf_if_recalculate_output_cost (ifp);
2453 return CMD_SUCCESS;
2456 DEFUN (no_ospf_auto_cost_reference_bandwidth,
2457 no_ospf_auto_cost_reference_bandwidth_cmd,
2458 "no auto-cost reference-bandwidth",
2459 NO_STR
2460 "Calculate OSPF interface cost according to bandwidth\n"
2461 "Use reference bandwidth method to assign OSPF cost\n")
2463 struct ospf *ospf = vty->index;
2464 struct listnode *node, *nnode;
2465 struct interface *ifp;
2467 if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
2468 return CMD_SUCCESS;
2470 ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
2471 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2472 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2474 for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp))
2475 ospf_if_recalculate_output_cost (ifp);
2477 return CMD_SUCCESS;
2480 const char *ospf_abr_type_descr_str[] =
2482 "Unknown",
2483 "Standard (RFC2328)",
2484 "Alternative IBM",
2485 "Alternative Cisco",
2486 "Alternative Shortcut"
2489 const char *ospf_shortcut_mode_descr_str[] =
2491 "Default",
2492 "Enabled",
2493 "Disabled"
2498 static void
2499 show_ip_ospf_area (struct vty *vty, struct ospf_area *area)
2501 /* Show Area ID. */
2502 vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id));
2504 /* Show Area type/mode. */
2505 if (OSPF_IS_AREA_BACKBONE (area))
2506 vty_out (vty, " (Backbone)%s", VTY_NEWLINE);
2507 else
2509 if (area->external_routing == OSPF_AREA_STUB)
2510 vty_out (vty, " (Stub%s%s)",
2511 area->no_summary ? ", no summary" : "",
2512 area->shortcut_configured ? "; " : "");
2514 else if (area->external_routing == OSPF_AREA_NSSA)
2515 vty_out (vty, " (NSSA%s%s)",
2516 area->no_summary ? ", no summary" : "",
2517 area->shortcut_configured ? "; " : "");
2519 vty_out (vty, "%s", VTY_NEWLINE);
2520 vty_out (vty, " Shortcutting mode: %s",
2521 ospf_shortcut_mode_descr_str[area->shortcut_configured]);
2522 vty_out (vty, ", S-bit consensus: %s%s",
2523 area->shortcut_capability ? "ok" : "no", VTY_NEWLINE);
2526 /* Show number of interfaces. */
2527 vty_out (vty, " Number of interfaces in this area: Total: %d, "
2528 "Active: %d%s", listcount (area->oiflist),
2529 area->act_ints, VTY_NEWLINE);
2531 if (area->external_routing == OSPF_AREA_NSSA)
2533 vty_out (vty, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE, VTY_NEWLINE);
2534 if (! IS_OSPF_ABR (area->ospf))
2535 vty_out (vty, " It is not ABR, therefore not Translator. %s",
2536 VTY_NEWLINE);
2537 else if (area->NSSATranslatorState)
2539 vty_out (vty, " We are an ABR and ");
2540 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2541 vty_out (vty, "the NSSA Elected Translator. %s",
2542 VTY_NEWLINE);
2543 else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS)
2544 vty_out (vty, "always an NSSA Translator. %s",
2545 VTY_NEWLINE);
2547 else
2549 vty_out (vty, " We are an ABR, but ");
2550 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2551 vty_out (vty, "not the NSSA Elected Translator. %s",
2552 VTY_NEWLINE);
2553 else
2554 vty_out (vty, "never an NSSA Translator. %s",
2555 VTY_NEWLINE);
2558 /* Stub-router state for this area */
2559 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
2561 char timebuf[OSPF_TIME_DUMP_SIZE];
2562 vty_out (vty, " Originating stub / maximum-distance Router-LSA%s",
2563 VTY_NEWLINE);
2564 if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
2565 vty_out (vty, " Administratively activated (indefinitely)%s",
2566 VTY_NEWLINE);
2567 if (area->t_stub_router)
2568 vty_out (vty, " Active from startup, %s remaining%s",
2569 ospf_timer_dump (area->t_stub_router, timebuf,
2570 sizeof(timebuf)), VTY_NEWLINE);
2573 /* Show number of fully adjacent neighbors. */
2574 vty_out (vty, " Number of fully adjacent neighbors in this area:"
2575 " %d%s", area->full_nbrs, VTY_NEWLINE);
2577 /* Show authentication type. */
2578 vty_out (vty, " Area has ");
2579 if (area->auth_type == OSPF_AUTH_NULL)
2580 vty_out (vty, "no authentication%s", VTY_NEWLINE);
2581 else if (area->auth_type == OSPF_AUTH_SIMPLE)
2582 vty_out (vty, "simple password authentication%s", VTY_NEWLINE);
2583 else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC)
2584 vty_out (vty, "message digest authentication%s", VTY_NEWLINE);
2586 if (!OSPF_IS_AREA_BACKBONE (area))
2587 vty_out (vty, " Number of full virtual adjacencies going through"
2588 " this area: %d%s", area->full_vls, VTY_NEWLINE);
2590 /* Show SPF calculation times. */
2591 vty_out (vty, " SPF algorithm executed %d times%s",
2592 area->spf_calculation, VTY_NEWLINE);
2594 /* Show number of LSA. */
2595 vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE);
2596 vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
2597 ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA),
2598 ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE);
2599 vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
2600 ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA),
2601 ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE);
2602 vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
2603 ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA),
2604 ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE);
2605 vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
2606 ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA),
2607 ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE);
2608 vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
2609 ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA),
2610 ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE);
2611 #ifdef HAVE_OPAQUE_LSA
2612 vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
2613 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA),
2614 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE);
2615 vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
2616 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA),
2617 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE);
2618 #endif /* HAVE_OPAQUE_LSA */
2619 vty_out (vty, "%s", VTY_NEWLINE);
2622 DEFUN (show_ip_ospf,
2623 show_ip_ospf_cmd,
2624 "show ip ospf",
2625 SHOW_STR
2626 IP_STR
2627 "OSPF information\n")
2629 struct listnode *node, *nnode;
2630 struct ospf_area * area;
2631 struct ospf *ospf;
2632 struct timeval result;
2633 char timebuf[OSPF_TIME_DUMP_SIZE];
2635 /* Check OSPF is enable. */
2636 ospf = ospf_lookup ();
2637 if (ospf == NULL)
2639 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2640 return CMD_SUCCESS;
2643 /* Show Router ID. */
2644 vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
2645 inet_ntoa (ospf->router_id),
2646 VTY_NEWLINE);
2648 /* Graceful shutdown */
2649 if (ospf->t_deferred_shutdown)
2650 vty_out (vty, " Deferred shutdown in progress, %s remaining%s",
2651 ospf_timer_dump (ospf->t_deferred_shutdown,
2652 timebuf, sizeof (timebuf)), VTY_NEWLINE);
2653 /* Show capability. */
2654 vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
2655 vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
2656 vty_out (vty, " RFC1583Compatibility flag is %s%s",
2657 CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ?
2658 "enabled" : "disabled", VTY_NEWLINE);
2659 #ifdef HAVE_OPAQUE_LSA
2660 vty_out (vty, " OpaqueCapability flag is %s%s%s",
2661 CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ?
2662 "enabled" : "disabled",
2663 IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ?
2664 " (origination blocked)" : "",
2665 VTY_NEWLINE);
2666 #endif /* HAVE_OPAQUE_LSA */
2668 /* Show stub-router configuration */
2669 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED
2670 || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2672 vty_out (vty, " Stub router advertisement is configured%s",
2673 VTY_NEWLINE);
2674 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2675 vty_out (vty, " Enabled for %us after start-up%s",
2676 ospf->stub_router_startup_time, VTY_NEWLINE);
2677 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2678 vty_out (vty, " Enabled for %us prior to full shutdown%s",
2679 ospf->stub_router_shutdown_time, VTY_NEWLINE);
2682 /* Show SPF timers. */
2683 vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s"
2684 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
2685 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
2686 " Hold time multiplier is currently %d%s",
2687 ospf->spf_delay, VTY_NEWLINE,
2688 ospf->spf_holdtime, VTY_NEWLINE,
2689 ospf->spf_max_holdtime, VTY_NEWLINE,
2690 ospf->spf_hold_multiplier, VTY_NEWLINE);
2691 vty_out (vty, " SPF algorithm ");
2692 if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec)
2694 result = tv_sub (recent_time, ospf->ts_spf);
2695 vty_out (vty, "last executed %s ago%s",
2696 ospf_timeval_dump (&result, timebuf, sizeof (timebuf)),
2697 VTY_NEWLINE);
2699 else
2700 vty_out (vty, "has not been run%s", VTY_NEWLINE);
2701 vty_out (vty, " SPF timer %s%s%s",
2702 (ospf->t_spf_calc ? "due in " : "is "),
2703 ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)),
2704 VTY_NEWLINE);
2706 /* Show refresh parameters. */
2707 vty_out (vty, " Refresh timer %d secs%s",
2708 ospf->lsa_refresh_interval, VTY_NEWLINE);
2710 /* Show ABR/ASBR flags. */
2711 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
2712 vty_out (vty, " This router is an ABR, ABR type is: %s%s",
2713 ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE);
2715 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
2716 vty_out (vty, " This router is an ASBR "
2717 "(injecting external routing information)%s", VTY_NEWLINE);
2719 /* Show Number of AS-external-LSAs. */
2720 vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
2721 ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA),
2722 ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE);
2723 #ifdef HAVE_OPAQUE_LSA
2724 vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
2725 ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA),
2726 ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE);
2727 #endif /* HAVE_OPAQUE_LSA */
2728 /* Show number of areas attached. */
2729 vty_out (vty, " Number of areas attached to this router: %d%s",
2730 listcount (ospf->areas), VTY_NEWLINE);
2732 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
2734 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
2735 vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE);
2736 else
2737 vty_out(vty, " Adjacency changes are logged%s",VTY_NEWLINE);
2740 vty_out (vty, "%s",VTY_NEWLINE);
2742 /* Show each area status. */
2743 for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
2744 show_ip_ospf_area (vty, area);
2746 return CMD_SUCCESS;
2750 static void
2751 show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
2752 struct interface *ifp)
2754 int is_up;
2755 struct ospf_neighbor *nbr;
2756 struct route_node *rn;
2758 /* Is interface up? */
2759 vty_out (vty, "%s is %s%s", ifp->name,
2760 ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE);
2761 vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s",
2762 ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags),
2763 VTY_NEWLINE);
2765 /* Is interface OSPF enabled? */
2766 if (ospf_oi_count(ifp) == 0)
2768 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2769 return;
2771 else if (!is_up)
2773 vty_out (vty, " OSPF is enabled, but not running on this interface%s",
2774 VTY_NEWLINE);
2775 return;
2778 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
2780 struct ospf_interface *oi = rn->info;
2782 if (oi == NULL)
2783 continue;
2785 /* Show OSPF interface information. */
2786 vty_out (vty, " Internet Address %s/%d,",
2787 inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
2789 if (oi->connected->destination || oi->type == OSPF_IFTYPE_VIRTUALLINK)
2791 struct in_addr *dest;
2792 const char *dstr;
2794 if ((ifp->flags & IFF_POINTOPOINT)
2795 || oi->type == OSPF_IFTYPE_VIRTUALLINK)
2796 dstr = "Peer";
2797 else
2798 dstr = "Broadcast";
2800 /* For Vlinks, showing the peer address is probably more
2801 * informative than the local interface that is being used
2803 if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
2804 dest = &oi->vl_data->peer_addr;
2805 else
2806 dest = &oi->connected->destination->u.prefix4;
2808 vty_out (vty, " %s %s,", dstr, inet_ntoa (*dest));
2811 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
2812 VTY_NEWLINE);
2814 vty_out (vty, " MTU mismatch detection:%s%s",
2815 OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE);
2817 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
2818 inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
2819 oi->output_cost, VTY_NEWLINE);
2821 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
2822 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
2823 PRIORITY (oi), VTY_NEWLINE);
2825 /* Show DR information. */
2826 if (DR (oi).s_addr == 0)
2827 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2828 else
2830 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
2831 if (nbr == NULL)
2832 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2833 else
2835 vty_out (vty, " Designated Router (ID) %s,",
2836 inet_ntoa (nbr->router_id));
2837 vty_out (vty, " Interface Address %s%s",
2838 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2842 /* Show BDR information. */
2843 if (BDR (oi).s_addr == 0)
2844 vty_out (vty, " No backup designated router on this network%s",
2845 VTY_NEWLINE);
2846 else
2848 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
2849 if (nbr == NULL)
2850 vty_out (vty, " No backup designated router on this network%s",
2851 VTY_NEWLINE);
2852 else
2854 vty_out (vty, " Backup Designated Router (ID) %s,",
2855 inet_ntoa (nbr->router_id));
2856 vty_out (vty, " Interface Address %s%s",
2857 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2861 vty_out (vty, " Multicast group memberships:");
2862 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)
2863 || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
2865 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS))
2866 vty_out (vty, " OSPFAllRouters");
2867 if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
2868 vty_out (vty, " OSPFDesignatedRouters");
2870 else
2871 vty_out (vty, " <None>");
2872 vty_out (vty, "%s", VTY_NEWLINE);
2874 vty_out (vty, " Timer intervals configured,");
2875 vty_out (vty, " Hello ");
2876 if (OSPF_IF_PARAM (oi, fast_hello) == 0)
2877 vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello));
2878 else
2879 vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello));
2880 vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s",
2881 OSPF_IF_PARAM (oi, v_wait),
2882 OSPF_IF_PARAM (oi, v_wait),
2883 OSPF_IF_PARAM (oi, retransmit_interval),
2884 VTY_NEWLINE);
2886 if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_ACTIVE)
2888 char timebuf[OSPF_TIME_DUMP_SIZE];
2889 vty_out (vty, " Hello due in %s%s",
2890 ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)),
2891 VTY_NEWLINE);
2893 else /* OSPF_IF_PASSIVE is set */
2894 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
2896 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
2897 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
2898 VTY_NEWLINE);
2902 DEFUN (show_ip_ospf_interface,
2903 show_ip_ospf_interface_cmd,
2904 "show ip ospf interface [INTERFACE]",
2905 SHOW_STR
2906 IP_STR
2907 "OSPF information\n"
2908 "Interface information\n"
2909 "Interface name\n")
2911 struct interface *ifp;
2912 struct ospf *ospf;
2913 struct listnode *node;
2915 ospf = ospf_lookup ();
2916 if (ospf == NULL)
2918 vty_out (vty, "OSPF Routing Process not enabled%s", VTY_NEWLINE);
2919 return CMD_SUCCESS;
2922 /* Show All Interfaces. */
2923 if (argc == 0)
2924 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
2925 show_ip_ospf_interface_sub (vty, ospf, ifp);
2926 /* Interface name is specified. */
2927 else
2929 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
2930 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
2931 else
2932 show_ip_ospf_interface_sub (vty, ospf, ifp);
2935 return CMD_SUCCESS;
2938 static void
2939 show_ip_ospf_neighbour_header (struct vty *vty)
2941 vty_out (vty, "%s%15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
2942 VTY_NEWLINE,
2943 "Neighbor ID", "Pri", "State", "Dead Time",
2944 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
2945 VTY_NEWLINE);
2948 static void
2949 show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
2951 struct route_node *rn;
2952 struct ospf_neighbor *nbr;
2953 char msgbuf[16];
2954 char timebuf[OSPF_TIME_DUMP_SIZE];
2956 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
2957 if ((nbr = rn->info))
2958 /* Do not show myself. */
2959 if (nbr != oi->nbr_self)
2960 /* Down state is not shown. */
2961 if (nbr->state != NSM_Down)
2963 ospf_nbr_state_message (nbr, msgbuf, 16);
2965 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
2966 vty_out (vty, "%-15s %3d %-15s ",
2967 "-", nbr->priority,
2968 msgbuf);
2969 else
2970 vty_out (vty, "%-15s %3d %-15s ",
2971 inet_ntoa (nbr->router_id), nbr->priority,
2972 msgbuf);
2974 vty_out (vty, "%9s ",
2975 ospf_timer_dump (nbr->t_inactivity, timebuf,
2976 sizeof(timebuf)));
2978 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
2979 vty_out (vty, "%-20s %5ld %5ld %5d%s",
2980 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
2981 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
2982 VTY_NEWLINE);
2986 DEFUN (show_ip_ospf_neighbor,
2987 show_ip_ospf_neighbor_cmd,
2988 "show ip ospf neighbor",
2989 SHOW_STR
2990 IP_STR
2991 "OSPF information\n"
2992 "Neighbor list\n")
2994 struct ospf *ospf;
2995 struct ospf_interface *oi;
2996 struct listnode *node;
2998 ospf = ospf_lookup ();
2999 if (ospf == NULL)
3001 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3002 return CMD_SUCCESS;
3005 show_ip_ospf_neighbour_header (vty);
3007 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3008 show_ip_ospf_neighbor_sub (vty, oi);
3010 return CMD_SUCCESS;
3013 DEFUN (show_ip_ospf_neighbor_all,
3014 show_ip_ospf_neighbor_all_cmd,
3015 "show ip ospf neighbor all",
3016 SHOW_STR
3017 IP_STR
3018 "OSPF information\n"
3019 "Neighbor list\n"
3020 "include down status neighbor\n")
3022 struct ospf *ospf = vty->index;
3023 struct listnode *node;
3024 struct ospf_interface *oi;
3026 if (ospf == NULL)
3028 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3029 return CMD_SUCCESS;
3032 show_ip_ospf_neighbour_header (vty);
3034 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3036 struct listnode *nbr_node;
3037 struct ospf_nbr_nbma *nbr_nbma;
3039 show_ip_ospf_neighbor_sub (vty, oi);
3041 /* print Down neighbor status */
3042 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma))
3044 if (nbr_nbma->nbr == NULL
3045 || nbr_nbma->nbr->state == NSM_Down)
3047 vty_out (vty, "%-15s %3d %-15s %9s ",
3048 "-", nbr_nbma->priority, "Down", "-");
3049 vty_out (vty, "%-15s %-20s %5d %5d %5d%s",
3050 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
3051 0, 0, 0, VTY_NEWLINE);
3056 return CMD_SUCCESS;
3059 DEFUN (show_ip_ospf_neighbor_int,
3060 show_ip_ospf_neighbor_int_cmd,
3061 "show ip ospf neighbor IFNAME",
3062 SHOW_STR
3063 IP_STR
3064 "OSPF information\n"
3065 "Neighbor list\n"
3066 "Interface name\n")
3068 struct ospf *ospf;
3069 struct interface *ifp;
3070 struct route_node *rn;
3072 ifp = if_lookup_by_name (argv[0]);
3073 if (!ifp)
3075 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
3076 return CMD_WARNING;
3079 ospf = ospf_lookup ();
3080 if (ospf == NULL)
3082 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3083 return CMD_SUCCESS;
3086 show_ip_ospf_neighbour_header (vty);
3088 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
3090 struct ospf_interface *oi = rn->info;
3092 if (oi == NULL)
3093 continue;
3095 show_ip_ospf_neighbor_sub (vty, oi);
3098 return CMD_SUCCESS;
3101 static void
3102 show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
3103 struct ospf_nbr_nbma *nbr_nbma)
3105 char timebuf[OSPF_TIME_DUMP_SIZE];
3107 /* Show neighbor ID. */
3108 vty_out (vty, " Neighbor %s,", "-");
3110 /* Show interface address. */
3111 vty_out (vty, " interface address %s%s",
3112 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
3113 /* Show Area ID. */
3114 vty_out (vty, " In the area %s via interface %s%s",
3115 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
3116 /* Show neighbor priority and state. */
3117 vty_out (vty, " Neighbor priority is %d, State is %s,",
3118 nbr_nbma->priority, "Down");
3119 /* Show state changes. */
3120 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
3122 /* Show PollInterval */
3123 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
3125 /* Show poll-interval timer. */
3126 vty_out (vty, " Poll timer due in %s%s",
3127 ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)),
3128 VTY_NEWLINE);
3130 /* Show poll-interval timer thread. */
3131 vty_out (vty, " Thread Poll Timer %s%s",
3132 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
3135 static void
3136 show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
3137 struct ospf_neighbor *nbr)
3139 char timebuf[OSPF_TIME_DUMP_SIZE];
3141 /* Show neighbor ID. */
3142 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
3143 vty_out (vty, " Neighbor %s,", "-");
3144 else
3145 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
3147 /* Show interface address. */
3148 vty_out (vty, " interface address %s%s",
3149 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
3150 /* Show Area ID. */
3151 vty_out (vty, " In the area %s via interface %s%s",
3152 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
3153 /* Show neighbor priority and state. */
3154 vty_out (vty, " Neighbor priority is %d, State is %s,",
3155 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
3156 /* Show state changes. */
3157 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
3158 if (nbr->ts_last_progress.tv_sec || nbr->ts_last_progress.tv_usec)
3160 struct timeval res = tv_sub (recent_time, nbr->ts_last_progress);
3161 vty_out (vty, " Most recent state change statistics:%s",
3162 VTY_NEWLINE);
3163 vty_out (vty, " Progressive change %s ago%s",
3164 ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
3165 VTY_NEWLINE);
3167 if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec)
3169 struct timeval res = tv_sub (recent_time, nbr->ts_last_regress);
3170 vty_out (vty, " Regressive change %s ago, due to %s%s",
3171 ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
3172 (nbr->last_regress_str ? nbr->last_regress_str : "??"),
3173 VTY_NEWLINE);
3175 /* Show Designated Rotuer ID. */
3176 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
3177 /* Show Backup Designated Rotuer ID. */
3178 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
3179 /* Show options. */
3180 vty_out (vty, " Options %d %s%s", nbr->options,
3181 ospf_options_dump (nbr->options), VTY_NEWLINE);
3182 /* Show Router Dead interval timer. */
3183 vty_out (vty, " Dead timer due in %s%s",
3184 ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)),
3185 VTY_NEWLINE);
3186 /* Show Database Summary list. */
3187 vty_out (vty, " Database Summary List %d%s",
3188 ospf_db_summary_count (nbr), VTY_NEWLINE);
3189 /* Show Link State Request list. */
3190 vty_out (vty, " Link State Request List %ld%s",
3191 ospf_ls_request_count (nbr), VTY_NEWLINE);
3192 /* Show Link State Retransmission list. */
3193 vty_out (vty, " Link State Retransmission List %ld%s",
3194 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
3195 /* Show inactivity timer thread. */
3196 vty_out (vty, " Thread Inactivity Timer %s%s",
3197 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
3198 /* Show Database Description retransmission thread. */
3199 vty_out (vty, " Thread Database Description Retransmision %s%s",
3200 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
3201 /* Show Link State Request Retransmission thread. */
3202 vty_out (vty, " Thread Link State Request Retransmission %s%s",
3203 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
3204 /* Show Link State Update Retransmission thread. */
3205 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
3206 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
3209 DEFUN (show_ip_ospf_neighbor_id,
3210 show_ip_ospf_neighbor_id_cmd,
3211 "show ip ospf neighbor A.B.C.D",
3212 SHOW_STR
3213 IP_STR
3214 "OSPF information\n"
3215 "Neighbor list\n"
3216 "Neighbor ID\n")
3218 struct ospf *ospf;
3219 struct listnode *node;
3220 struct ospf_neighbor *nbr;
3221 struct ospf_interface *oi;
3222 struct in_addr router_id;
3223 int ret;
3225 ret = inet_aton (argv[0], &router_id);
3226 if (!ret)
3228 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
3229 return CMD_WARNING;
3232 ospf = ospf_lookup ();
3233 if (ospf == NULL)
3235 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3236 return CMD_SUCCESS;
3239 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3240 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
3241 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3243 return CMD_SUCCESS;
3246 DEFUN (show_ip_ospf_neighbor_detail,
3247 show_ip_ospf_neighbor_detail_cmd,
3248 "show ip ospf neighbor detail",
3249 SHOW_STR
3250 IP_STR
3251 "OSPF information\n"
3252 "Neighbor list\n"
3253 "detail of all neighbors\n")
3255 struct ospf *ospf;
3256 struct ospf_interface *oi;
3257 struct listnode *node;
3259 ospf = ospf_lookup ();
3260 if (ospf == NULL)
3262 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3263 return CMD_SUCCESS;
3266 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3268 struct route_node *rn;
3269 struct ospf_neighbor *nbr;
3271 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3272 if ((nbr = rn->info))
3273 if (nbr != oi->nbr_self)
3274 if (nbr->state != NSM_Down)
3275 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3278 return CMD_SUCCESS;
3281 DEFUN (show_ip_ospf_neighbor_detail_all,
3282 show_ip_ospf_neighbor_detail_all_cmd,
3283 "show ip ospf neighbor detail all",
3284 SHOW_STR
3285 IP_STR
3286 "OSPF information\n"
3287 "Neighbor list\n"
3288 "detail of all neighbors\n"
3289 "include down status neighbor\n")
3291 struct ospf *ospf;
3292 struct listnode *node;
3293 struct ospf_interface *oi;
3295 ospf = ospf_lookup ();
3296 if (ospf == NULL)
3298 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3299 return CMD_SUCCESS;
3302 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3304 struct route_node *rn;
3305 struct ospf_neighbor *nbr;
3306 struct ospf_nbr_nbma *nbr_nbma;
3308 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3309 if ((nbr = rn->info))
3310 if (nbr != oi->nbr_self)
3311 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3312 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3314 if (oi->type == OSPF_IFTYPE_NBMA)
3316 struct listnode *nd;
3318 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma))
3319 if (nbr_nbma->nbr == NULL
3320 || nbr_nbma->nbr->state == NSM_Down)
3321 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
3325 return CMD_SUCCESS;
3328 DEFUN (show_ip_ospf_neighbor_int_detail,
3329 show_ip_ospf_neighbor_int_detail_cmd,
3330 "show ip ospf neighbor IFNAME detail",
3331 SHOW_STR
3332 IP_STR
3333 "OSPF information\n"
3334 "Neighbor list\n"
3335 "Interface name\n"
3336 "detail of all neighbors")
3338 struct ospf *ospf;
3339 struct ospf_interface *oi;
3340 struct interface *ifp;
3341 struct route_node *rn, *nrn;
3342 struct ospf_neighbor *nbr;
3344 ifp = if_lookup_by_name (argv[0]);
3345 if (!ifp)
3347 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
3348 return CMD_WARNING;
3351 ospf = ospf_lookup ();
3352 if (ospf == NULL)
3354 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3355 return CMD_SUCCESS;
3359 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
3360 if ((oi = rn->info))
3361 for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn))
3362 if ((nbr = nrn->info))
3363 if (nbr != oi->nbr_self)
3364 if (nbr->state != NSM_Down)
3365 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3367 return CMD_SUCCESS;
3371 /* Show functions */
3372 static int
3373 show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
3375 struct router_lsa *rl;
3376 struct summary_lsa *sl;
3377 struct as_external_lsa *asel;
3378 struct prefix_ipv4 p;
3380 if (lsa != NULL)
3381 /* If self option is set, check LSA self flag. */
3382 if (self == 0 || IS_LSA_SELF (lsa))
3384 /* LSA common part show. */
3385 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3386 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3387 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3388 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3389 /* LSA specific part show. */
3390 switch (lsa->data->type)
3392 case OSPF_ROUTER_LSA:
3393 rl = (struct router_lsa *) lsa->data;
3394 vty_out (vty, " %-d", ntohs (rl->links));
3395 break;
3396 case OSPF_SUMMARY_LSA:
3397 sl = (struct summary_lsa *) lsa->data;
3399 p.family = AF_INET;
3400 p.prefix = sl->header.id;
3401 p.prefixlen = ip_masklen (sl->mask);
3402 apply_mask_ipv4 (&p);
3404 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3405 break;
3406 case OSPF_AS_EXTERNAL_LSA:
3407 case OSPF_AS_NSSA_LSA:
3408 asel = (struct as_external_lsa *) lsa->data;
3410 p.family = AF_INET;
3411 p.prefix = asel->header.id;
3412 p.prefixlen = ip_masklen (asel->mask);
3413 apply_mask_ipv4 (&p);
3415 vty_out (vty, " %s %s/%d [0x%lx]",
3416 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3417 inet_ntoa (p.prefix), p.prefixlen,
3418 (u_long)ntohl (asel->e[0].route_tag));
3419 break;
3420 case OSPF_NETWORK_LSA:
3421 case OSPF_ASBR_SUMMARY_LSA:
3422 #ifdef HAVE_OPAQUE_LSA
3423 case OSPF_OPAQUE_LINK_LSA:
3424 case OSPF_OPAQUE_AREA_LSA:
3425 case OSPF_OPAQUE_AS_LSA:
3426 #endif /* HAVE_OPAQUE_LSA */
3427 default:
3428 break;
3430 vty_out (vty, VTY_NEWLINE);
3433 return 0;
3436 const char *show_database_desc[] =
3438 "unknown",
3439 "Router Link States",
3440 "Net Link States",
3441 "Summary Link States",
3442 "ASBR-Summary Link States",
3443 "AS External Link States",
3444 "Group Membership LSA",
3445 "NSSA-external Link States",
3446 #ifdef HAVE_OPAQUE_LSA
3447 "Type-8 LSA",
3448 "Link-Local Opaque-LSA",
3449 "Area-Local Opaque-LSA",
3450 "AS-external Opaque-LSA",
3451 #endif /* HAVE_OPAQUE_LSA */
3454 #define SHOW_OSPF_COMMON_HEADER \
3455 "Link ID ADV Router Age Seq# CkSum"
3457 const char *show_database_header[] =
3460 "Link ID ADV Router Age Seq# CkSum Link count",
3461 "Link ID ADV Router Age Seq# CkSum",
3462 "Link ID ADV Router Age Seq# CkSum Route",
3463 "Link ID ADV Router Age Seq# CkSum",
3464 "Link ID ADV Router Age Seq# CkSum Route",
3465 " --- header for Group Member ----",
3466 "Link ID ADV Router Age Seq# CkSum Route",
3467 #ifdef HAVE_OPAQUE_LSA
3468 " --- type-8 ---",
3469 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3470 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3471 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3472 #endif /* HAVE_OPAQUE_LSA */
3475 const char *show_lsa_flags[] =
3477 "Self-originated",
3478 "Checked",
3479 "Received",
3480 "Approved",
3481 "Discard",
3482 "Translated",
3485 static void
3486 show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3488 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
3490 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
3491 vty_out (vty, " Options: 0x%-2x : %s%s",
3492 lsa->data->options,
3493 ospf_options_dump(lsa->data->options),
3494 VTY_NEWLINE);
3495 vty_out (vty, " LS Flags: 0x%-2x %s%s",
3496 lsa->flags,
3497 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
3498 VTY_NEWLINE);
3500 if (lsa->data->type == OSPF_ROUTER_LSA)
3502 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3504 if (rlsa->flags)
3505 vty_out (vty, " :%s%s%s%s",
3506 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3507 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3508 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3509 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3511 vty_out (vty, "%s", VTY_NEWLINE);
3513 vty_out (vty, " LS Type: %s%s",
3514 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3515 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3516 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3517 vty_out (vty, " Advertising Router: %s%s",
3518 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3519 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3520 VTY_NEWLINE);
3521 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3522 VTY_NEWLINE);
3523 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3526 const char *link_type_desc[] =
3528 "(null)",
3529 "another Router (point-to-point)",
3530 "a Transit Network",
3531 "Stub Network",
3532 "a Virtual Link",
3535 const char *link_id_desc[] =
3537 "(null)",
3538 "Neighboring Router ID",
3539 "Designated Router address",
3540 "Net",
3541 "Neighboring Router ID",
3544 const char *link_data_desc[] =
3546 "(null)",
3547 "Router Interface address",
3548 "Router Interface address",
3549 "Network Mask",
3550 "Router Interface address",
3553 /* Show router-LSA each Link information. */
3554 static void
3555 show_ip_ospf_database_router_links (struct vty *vty,
3556 struct router_lsa *rl)
3558 int len, i, type;
3560 len = ntohs (rl->header.length) - 4;
3561 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3563 type = rl->link[i].type;
3565 vty_out (vty, " Link connected to: %s%s",
3566 link_type_desc[type], VTY_NEWLINE);
3567 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3568 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3569 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3570 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3571 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3572 vty_out (vty, " TOS 0 Metric: %d%s",
3573 ntohs (rl->link[i].metric), VTY_NEWLINE);
3574 vty_out (vty, "%s", VTY_NEWLINE);
3578 /* Show router-LSA detail information. */
3579 static int
3580 show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3582 if (lsa != NULL)
3584 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3586 show_ip_ospf_database_header (vty, lsa);
3588 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3589 VTY_NEWLINE, VTY_NEWLINE);
3591 show_ip_ospf_database_router_links (vty, rl);
3592 vty_out (vty, "%s", VTY_NEWLINE);
3595 return 0;
3598 /* Show network-LSA detail information. */
3599 static int
3600 show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3602 int length, i;
3604 if (lsa != NULL)
3606 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3608 show_ip_ospf_database_header (vty, lsa);
3610 vty_out (vty, " Network Mask: /%d%s",
3611 ip_masklen (nl->mask), VTY_NEWLINE);
3613 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3615 for (i = 0; length > 0; i++, length -= 4)
3616 vty_out (vty, " Attached Router: %s%s",
3617 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3619 vty_out (vty, "%s", VTY_NEWLINE);
3622 return 0;
3625 /* Show summary-LSA detail information. */
3626 static int
3627 show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3629 if (lsa != NULL)
3631 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3633 show_ip_ospf_database_header (vty, lsa);
3635 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3636 VTY_NEWLINE);
3637 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3638 VTY_NEWLINE);
3639 vty_out (vty, "%s", VTY_NEWLINE);
3642 return 0;
3645 /* Show summary-ASBR-LSA detail information. */
3646 static int
3647 show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3649 if (lsa != NULL)
3651 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3653 show_ip_ospf_database_header (vty, lsa);
3655 vty_out (vty, " Network Mask: /%d%s",
3656 ip_masklen (sl->mask), VTY_NEWLINE);
3657 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3658 VTY_NEWLINE);
3659 vty_out (vty, "%s", VTY_NEWLINE);
3662 return 0;
3665 /* Show AS-external-LSA detail information. */
3666 static int
3667 show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3669 if (lsa != NULL)
3671 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3673 show_ip_ospf_database_header (vty, lsa);
3675 vty_out (vty, " Network Mask: /%d%s",
3676 ip_masklen (al->mask), VTY_NEWLINE);
3677 vty_out (vty, " Metric Type: %s%s",
3678 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3679 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3680 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3681 vty_out (vty, " Metric: %d%s",
3682 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3683 vty_out (vty, " Forward Address: %s%s",
3684 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3686 vty_out (vty, " External Route Tag: %lu%s%s",
3687 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3690 return 0;
3693 /* N.B. This function currently seems to be unused. */
3694 static int
3695 show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3697 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3699 /* show_ip_ospf_database_header (vty, lsa); */
3701 zlog_debug( " Network Mask: /%d%s",
3702 ip_masklen (al->mask), "\n");
3703 zlog_debug( " Metric Type: %s%s",
3704 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3705 "2 (Larger than any link state path)" : "1", "\n");
3706 zlog_debug( " TOS: 0%s", "\n");
3707 zlog_debug( " Metric: %d%s",
3708 GET_METRIC (al->e[0].metric), "\n");
3709 zlog_debug( " Forward Address: %s%s",
3710 inet_ntoa (al->e[0].fwd_addr), "\n");
3712 zlog_debug( " External Route Tag: %u%s%s",
3713 ntohl (al->e[0].route_tag), "\n", "\n");
3715 return 0;
3718 /* Show AS-NSSA-LSA detail information. */
3719 static int
3720 show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3722 if (lsa != NULL)
3724 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3726 show_ip_ospf_database_header (vty, lsa);
3728 vty_out (vty, " Network Mask: /%d%s",
3729 ip_masklen (al->mask), VTY_NEWLINE);
3730 vty_out (vty, " Metric Type: %s%s",
3731 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3732 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3733 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3734 vty_out (vty, " Metric: %d%s",
3735 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3736 vty_out (vty, " NSSA: Forward Address: %s%s",
3737 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3739 vty_out (vty, " External Route Tag: %u%s%s",
3740 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3743 return 0;
3746 static int
3747 show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3749 return 0;
3752 #ifdef HAVE_OPAQUE_LSA
3753 static int
3754 show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3756 if (lsa != NULL)
3758 show_ip_ospf_database_header (vty, lsa);
3759 show_opaque_info_detail (vty, lsa);
3761 vty_out (vty, "%s", VTY_NEWLINE);
3763 return 0;
3765 #endif /* HAVE_OPAQUE_LSA */
3767 int (*show_function[])(struct vty *, struct ospf_lsa *) =
3769 NULL,
3770 show_router_lsa_detail,
3771 show_network_lsa_detail,
3772 show_summary_lsa_detail,
3773 show_summary_asbr_lsa_detail,
3774 show_as_external_lsa_detail,
3775 show_func_dummy,
3776 show_as_nssa_lsa_detail, /* almost same as external */
3777 #ifdef HAVE_OPAQUE_LSA
3778 NULL, /* type-8 */
3779 show_opaque_lsa_detail,
3780 show_opaque_lsa_detail,
3781 show_opaque_lsa_detail,
3782 #endif /* HAVE_OPAQUE_LSA */
3785 static void
3786 show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3787 struct in_addr *adv_router)
3789 memset (lp, 0, sizeof (struct prefix_ls));
3790 lp->family = 0;
3791 if (id == NULL)
3792 lp->prefixlen = 0;
3793 else if (adv_router == NULL)
3795 lp->prefixlen = 32;
3796 lp->id = *id;
3798 else
3800 lp->prefixlen = 64;
3801 lp->id = *id;
3802 lp->adv_router = *adv_router;
3806 static void
3807 show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3808 struct in_addr *id, struct in_addr *adv_router)
3810 struct prefix_ls lp;
3811 struct route_node *rn, *start;
3812 struct ospf_lsa *lsa;
3814 show_lsa_prefix_set (vty, &lp, id, adv_router);
3815 start = route_node_get (rt, (struct prefix *) &lp);
3816 if (start)
3818 route_lock_node (start);
3819 for (rn = start; rn; rn = route_next_until (rn, start))
3820 if ((lsa = rn->info))
3822 if (show_function[lsa->data->type] != NULL)
3823 show_function[lsa->data->type] (vty, lsa);
3825 route_unlock_node (start);
3829 /* Show detail LSA information
3830 -- if id is NULL then show all LSAs. */
3831 static void
3832 show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
3833 struct in_addr *id, struct in_addr *adv_router)
3835 struct listnode *node;
3836 struct ospf_area *area;
3838 switch (type)
3840 case OSPF_AS_EXTERNAL_LSA:
3841 #ifdef HAVE_OPAQUE_LSA
3842 case OSPF_OPAQUE_AS_LSA:
3843 #endif /* HAVE_OPAQUE_LSA */
3844 vty_out (vty, " %s %s%s",
3845 show_database_desc[type],
3846 VTY_NEWLINE, VTY_NEWLINE);
3847 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
3848 break;
3849 default:
3850 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
3852 vty_out (vty, "%s %s (Area %s)%s%s",
3853 VTY_NEWLINE, show_database_desc[type],
3854 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3855 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3857 break;
3861 static void
3862 show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3863 struct in_addr *adv_router)
3865 struct route_node *rn;
3866 struct ospf_lsa *lsa;
3868 for (rn = route_top (rt); rn; rn = route_next (rn))
3869 if ((lsa = rn->info))
3870 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3872 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3873 continue;
3874 if (show_function[lsa->data->type] != NULL)
3875 show_function[lsa->data->type] (vty, lsa);
3879 /* Show detail LSA information. */
3880 static void
3881 show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
3882 struct in_addr *adv_router)
3884 struct listnode *node;
3885 struct ospf_area *area;
3887 switch (type)
3889 case OSPF_AS_EXTERNAL_LSA:
3890 #ifdef HAVE_OPAQUE_LSA
3891 case OSPF_OPAQUE_AS_LSA:
3892 #endif /* HAVE_OPAQUE_LSA */
3893 vty_out (vty, " %s %s%s",
3894 show_database_desc[type],
3895 VTY_NEWLINE, VTY_NEWLINE);
3896 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
3897 adv_router);
3898 break;
3899 default:
3900 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
3902 vty_out (vty, "%s %s (Area %s)%s%s",
3903 VTY_NEWLINE, show_database_desc[type],
3904 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3905 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3906 adv_router);
3908 break;
3912 static void
3913 show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
3915 struct ospf_lsa *lsa;
3916 struct route_node *rn;
3917 struct ospf_area *area;
3918 struct listnode *node;
3919 int type;
3921 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
3923 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3925 switch (type)
3927 case OSPF_AS_EXTERNAL_LSA:
3928 #ifdef HAVE_OPAQUE_LSA
3929 case OSPF_OPAQUE_AS_LSA:
3930 #endif /* HAVE_OPAQUE_LSA */
3931 continue;
3932 default:
3933 break;
3935 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
3936 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
3938 vty_out (vty, " %s (Area %s)%s%s",
3939 show_database_desc[type],
3940 ospf_area_desc_string (area),
3941 VTY_NEWLINE, VTY_NEWLINE);
3942 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
3944 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
3945 show_lsa_summary (vty, lsa, self);
3947 vty_out (vty, "%s", VTY_NEWLINE);
3952 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3954 switch (type)
3956 case OSPF_AS_EXTERNAL_LSA:
3957 #ifdef HAVE_OPAQUE_LSA
3958 case OSPF_OPAQUE_AS_LSA:
3959 #endif /* HAVE_OPAQUE_LSA */
3960 break;
3961 default:
3962 continue;
3964 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
3965 (!self && ospf_lsdb_count (ospf->lsdb, type)))
3967 vty_out (vty, " %s%s%s",
3968 show_database_desc[type],
3969 VTY_NEWLINE, VTY_NEWLINE);
3970 vty_out (vty, "%s%s", show_database_header[type],
3971 VTY_NEWLINE);
3973 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
3974 show_lsa_summary (vty, lsa, self);
3976 vty_out (vty, "%s", VTY_NEWLINE);
3980 vty_out (vty, "%s", VTY_NEWLINE);
3983 static void
3984 show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
3986 struct listnode *node;
3987 struct ospf_lsa *lsa;
3989 vty_out (vty, "%s MaxAge Link States:%s%s",
3990 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
3992 for (ALL_LIST_ELEMENTS_RO (ospf->maxage_lsa, node, lsa))
3994 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
3995 vty_out (vty, "Link State ID: %s%s",
3996 inet_ntoa (lsa->data->id), VTY_NEWLINE);
3997 vty_out (vty, "Advertising Router: %s%s",
3998 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3999 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
4000 vty_out (vty, "%s", VTY_NEWLINE);
4004 #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
4005 #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
4007 #ifdef HAVE_OPAQUE_LSA
4008 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
4009 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
4010 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
4011 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
4012 #else /* HAVE_OPAQUE_LSA */
4013 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
4014 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
4015 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
4016 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
4017 #endif /* HAVE_OPAQUE_LSA */
4019 #define OSPF_LSA_TYPES_CMD_STR \
4020 "asbr-summary|external|network|router|summary" \
4021 OSPF_LSA_TYPE_NSSA_CMD_STR \
4022 OSPF_LSA_TYPE_OPAQUE_CMD_STR
4024 #define OSPF_LSA_TYPES_DESC \
4025 "ASBR summary link states\n" \
4026 "External link states\n" \
4027 "Network link states\n" \
4028 "Router link states\n" \
4029 "Network summary link states\n" \
4030 OSPF_LSA_TYPE_NSSA_DESC \
4031 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
4032 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
4033 OSPF_LSA_TYPE_OPAQUE_AS_DESC
4035 DEFUN (show_ip_ospf_database,
4036 show_ip_ospf_database_cmd,
4037 "show ip ospf database",
4038 SHOW_STR
4039 IP_STR
4040 "OSPF information\n"
4041 "Database summary\n")
4043 struct ospf *ospf;
4044 int type, ret;
4045 struct in_addr id, adv_router;
4047 ospf = ospf_lookup ();
4048 if (ospf == NULL)
4050 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4051 return CMD_SUCCESS;
4054 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
4055 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
4057 /* Show all LSA. */
4058 if (argc == 0)
4060 show_ip_ospf_database_summary (vty, ospf, 0);
4061 return CMD_SUCCESS;
4064 /* Set database type to show. */
4065 if (strncmp (argv[0], "r", 1) == 0)
4066 type = OSPF_ROUTER_LSA;
4067 else if (strncmp (argv[0], "ne", 2) == 0)
4068 type = OSPF_NETWORK_LSA;
4069 else if (strncmp (argv[0], "ns", 2) == 0)
4070 type = OSPF_AS_NSSA_LSA;
4071 else if (strncmp (argv[0], "su", 2) == 0)
4072 type = OSPF_SUMMARY_LSA;
4073 else if (strncmp (argv[0], "a", 1) == 0)
4074 type = OSPF_ASBR_SUMMARY_LSA;
4075 else if (strncmp (argv[0], "e", 1) == 0)
4076 type = OSPF_AS_EXTERNAL_LSA;
4077 else if (strncmp (argv[0], "se", 2) == 0)
4079 show_ip_ospf_database_summary (vty, ospf, 1);
4080 return CMD_SUCCESS;
4082 else if (strncmp (argv[0], "m", 1) == 0)
4084 show_ip_ospf_database_maxage (vty, ospf);
4085 return CMD_SUCCESS;
4087 #ifdef HAVE_OPAQUE_LSA
4088 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4089 type = OSPF_OPAQUE_LINK_LSA;
4090 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4091 type = OSPF_OPAQUE_AREA_LSA;
4092 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4093 type = OSPF_OPAQUE_AS_LSA;
4094 #endif /* HAVE_OPAQUE_LSA */
4095 else
4096 return CMD_WARNING;
4098 /* `show ip ospf database LSA'. */
4099 if (argc == 1)
4100 show_lsa_detail (vty, ospf, type, NULL, NULL);
4101 else if (argc >= 2)
4103 ret = inet_aton (argv[1], &id);
4104 if (!ret)
4105 return CMD_WARNING;
4107 /* `show ip ospf database LSA ID'. */
4108 if (argc == 2)
4109 show_lsa_detail (vty, ospf, type, &id, NULL);
4110 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
4111 else if (argc == 3)
4113 if (strncmp (argv[2], "s", 1) == 0)
4114 adv_router = ospf->router_id;
4115 else
4117 ret = inet_aton (argv[2], &adv_router);
4118 if (!ret)
4119 return CMD_WARNING;
4121 show_lsa_detail (vty, ospf, type, &id, &adv_router);
4125 return CMD_SUCCESS;
4128 ALIAS (show_ip_ospf_database,
4129 show_ip_ospf_database_type_cmd,
4130 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
4131 SHOW_STR
4132 IP_STR
4133 "OSPF information\n"
4134 "Database summary\n"
4135 OSPF_LSA_TYPES_DESC
4136 "LSAs in MaxAge list\n"
4137 "Self-originated link states\n")
4139 ALIAS (show_ip_ospf_database,
4140 show_ip_ospf_database_type_id_cmd,
4141 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
4142 SHOW_STR
4143 IP_STR
4144 "OSPF information\n"
4145 "Database summary\n"
4146 OSPF_LSA_TYPES_DESC
4147 "Link State ID (as an IP address)\n")
4149 ALIAS (show_ip_ospf_database,
4150 show_ip_ospf_database_type_id_adv_router_cmd,
4151 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
4152 SHOW_STR
4153 IP_STR
4154 "OSPF information\n"
4155 "Database summary\n"
4156 OSPF_LSA_TYPES_DESC
4157 "Link State ID (as an IP address)\n"
4158 "Advertising Router link states\n"
4159 "Advertising Router (as an IP address)\n")
4161 ALIAS (show_ip_ospf_database,
4162 show_ip_ospf_database_type_id_self_cmd,
4163 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
4164 SHOW_STR
4165 IP_STR
4166 "OSPF information\n"
4167 "Database summary\n"
4168 OSPF_LSA_TYPES_DESC
4169 "Link State ID (as an IP address)\n"
4170 "Self-originated link states\n"
4171 "\n")
4173 DEFUN (show_ip_ospf_database_type_adv_router,
4174 show_ip_ospf_database_type_adv_router_cmd,
4175 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
4176 SHOW_STR
4177 IP_STR
4178 "OSPF information\n"
4179 "Database summary\n"
4180 OSPF_LSA_TYPES_DESC
4181 "Advertising Router link states\n"
4182 "Advertising Router (as an IP address)\n")
4184 struct ospf *ospf;
4185 int type, ret;
4186 struct in_addr adv_router;
4188 ospf = ospf_lookup ();
4189 if (ospf == NULL)
4191 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4192 return CMD_SUCCESS;
4195 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
4196 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
4198 if (argc != 2)
4199 return CMD_WARNING;
4201 /* Set database type to show. */
4202 if (strncmp (argv[0], "r", 1) == 0)
4203 type = OSPF_ROUTER_LSA;
4204 else if (strncmp (argv[0], "ne", 2) == 0)
4205 type = OSPF_NETWORK_LSA;
4206 else if (strncmp (argv[0], "ns", 2) == 0)
4207 type = OSPF_AS_NSSA_LSA;
4208 else if (strncmp (argv[0], "s", 1) == 0)
4209 type = OSPF_SUMMARY_LSA;
4210 else if (strncmp (argv[0], "a", 1) == 0)
4211 type = OSPF_ASBR_SUMMARY_LSA;
4212 else if (strncmp (argv[0], "e", 1) == 0)
4213 type = OSPF_AS_EXTERNAL_LSA;
4214 #ifdef HAVE_OPAQUE_LSA
4215 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4216 type = OSPF_OPAQUE_LINK_LSA;
4217 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4218 type = OSPF_OPAQUE_AREA_LSA;
4219 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4220 type = OSPF_OPAQUE_AS_LSA;
4221 #endif /* HAVE_OPAQUE_LSA */
4222 else
4223 return CMD_WARNING;
4225 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
4226 if (strncmp (argv[1], "s", 1) == 0)
4227 adv_router = ospf->router_id;
4228 else
4230 ret = inet_aton (argv[1], &adv_router);
4231 if (!ret)
4232 return CMD_WARNING;
4235 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
4237 return CMD_SUCCESS;
4240 ALIAS (show_ip_ospf_database_type_adv_router,
4241 show_ip_ospf_database_type_self_cmd,
4242 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
4243 SHOW_STR
4244 IP_STR
4245 "OSPF information\n"
4246 "Database summary\n"
4247 OSPF_LSA_TYPES_DESC
4248 "Self-originated link states\n")
4251 DEFUN (ip_ospf_authentication_args,
4252 ip_ospf_authentication_args_addr_cmd,
4253 "ip ospf authentication (null|message-digest) A.B.C.D",
4254 "IP Information\n"
4255 "OSPF interface commands\n"
4256 "Enable authentication on this interface\n"
4257 "Use null authentication\n"
4258 "Use message-digest authentication\n"
4259 "Address of interface")
4261 struct interface *ifp;
4262 struct in_addr addr;
4263 int ret;
4264 struct ospf_if_params *params;
4266 ifp = vty->index;
4267 params = IF_DEF_PARAMS (ifp);
4269 if (argc == 2)
4271 ret = inet_aton(argv[1], &addr);
4272 if (!ret)
4274 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4275 VTY_NEWLINE);
4276 return CMD_WARNING;
4279 params = ospf_get_if_params (ifp, addr);
4280 ospf_if_update_params (ifp, addr);
4283 /* Handle null authentication */
4284 if ( argv[0][0] == 'n' )
4286 SET_IF_PARAM (params, auth_type);
4287 params->auth_type = OSPF_AUTH_NULL;
4288 return CMD_SUCCESS;
4291 /* Handle message-digest authentication */
4292 if ( argv[0][0] == 'm' )
4294 SET_IF_PARAM (params, auth_type);
4295 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
4296 return CMD_SUCCESS;
4299 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4300 return CMD_WARNING;
4303 ALIAS (ip_ospf_authentication_args,
4304 ip_ospf_authentication_args_cmd,
4305 "ip ospf authentication (null|message-digest)",
4306 "IP Information\n"
4307 "OSPF interface commands\n"
4308 "Enable authentication on this interface\n"
4309 "Use null authentication\n"
4310 "Use message-digest authentication\n")
4312 DEFUN (ip_ospf_authentication,
4313 ip_ospf_authentication_addr_cmd,
4314 "ip ospf authentication A.B.C.D",
4315 "IP Information\n"
4316 "OSPF interface commands\n"
4317 "Enable authentication on this interface\n"
4318 "Address of interface")
4320 struct interface *ifp;
4321 struct in_addr addr;
4322 int ret;
4323 struct ospf_if_params *params;
4325 ifp = vty->index;
4326 params = IF_DEF_PARAMS (ifp);
4328 if (argc == 1)
4330 ret = inet_aton(argv[1], &addr);
4331 if (!ret)
4333 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4334 VTY_NEWLINE);
4335 return CMD_WARNING;
4338 params = ospf_get_if_params (ifp, addr);
4339 ospf_if_update_params (ifp, addr);
4342 SET_IF_PARAM (params, auth_type);
4343 params->auth_type = OSPF_AUTH_SIMPLE;
4345 return CMD_SUCCESS;
4348 ALIAS (ip_ospf_authentication,
4349 ip_ospf_authentication_cmd,
4350 "ip ospf authentication",
4351 "IP Information\n"
4352 "OSPF interface commands\n"
4353 "Enable authentication on this interface\n")
4355 DEFUN (no_ip_ospf_authentication,
4356 no_ip_ospf_authentication_addr_cmd,
4357 "no ip ospf authentication A.B.C.D",
4358 NO_STR
4359 "IP Information\n"
4360 "OSPF interface commands\n"
4361 "Enable authentication on this interface\n"
4362 "Address of interface")
4364 struct interface *ifp;
4365 struct in_addr addr;
4366 int ret;
4367 struct ospf_if_params *params;
4369 ifp = vty->index;
4370 params = IF_DEF_PARAMS (ifp);
4372 if (argc == 1)
4374 ret = inet_aton(argv[1], &addr);
4375 if (!ret)
4377 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4378 VTY_NEWLINE);
4379 return CMD_WARNING;
4382 params = ospf_lookup_if_params (ifp, addr);
4383 if (params == NULL)
4384 return CMD_SUCCESS;
4387 params->auth_type = OSPF_AUTH_NOTSET;
4388 UNSET_IF_PARAM (params, auth_type);
4390 if (params != IF_DEF_PARAMS (ifp))
4392 ospf_free_if_params (ifp, addr);
4393 ospf_if_update_params (ifp, addr);
4396 return CMD_SUCCESS;
4399 ALIAS (no_ip_ospf_authentication,
4400 no_ip_ospf_authentication_cmd,
4401 "no ip ospf authentication",
4402 NO_STR
4403 "IP Information\n"
4404 "OSPF interface commands\n"
4405 "Enable authentication on this interface\n")
4407 DEFUN (ip_ospf_authentication_key,
4408 ip_ospf_authentication_key_addr_cmd,
4409 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4410 "IP Information\n"
4411 "OSPF interface commands\n"
4412 "Authentication password (key)\n"
4413 "The OSPF password (key)\n"
4414 "Address of interface")
4416 struct interface *ifp;
4417 struct in_addr addr;
4418 int ret;
4419 struct ospf_if_params *params;
4421 ifp = vty->index;
4422 params = IF_DEF_PARAMS (ifp);
4424 if (argc == 2)
4426 ret = inet_aton(argv[1], &addr);
4427 if (!ret)
4429 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4430 VTY_NEWLINE);
4431 return CMD_WARNING;
4434 params = ospf_get_if_params (ifp, addr);
4435 ospf_if_update_params (ifp, addr);
4439 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
4440 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
4441 SET_IF_PARAM (params, auth_simple);
4443 return CMD_SUCCESS;
4446 ALIAS (ip_ospf_authentication_key,
4447 ip_ospf_authentication_key_cmd,
4448 "ip ospf authentication-key AUTH_KEY",
4449 "IP Information\n"
4450 "OSPF interface commands\n"
4451 "Authentication password (key)\n"
4452 "The OSPF password (key)")
4454 ALIAS (ip_ospf_authentication_key,
4455 ospf_authentication_key_cmd,
4456 "ospf authentication-key AUTH_KEY",
4457 "OSPF interface commands\n"
4458 "Authentication password (key)\n"
4459 "The OSPF password (key)")
4461 DEFUN (no_ip_ospf_authentication_key,
4462 no_ip_ospf_authentication_key_addr_cmd,
4463 "no ip ospf authentication-key A.B.C.D",
4464 NO_STR
4465 "IP Information\n"
4466 "OSPF interface commands\n"
4467 "Authentication password (key)\n"
4468 "Address of interface")
4470 struct interface *ifp;
4471 struct in_addr addr;
4472 int ret;
4473 struct ospf_if_params *params;
4475 ifp = vty->index;
4476 params = IF_DEF_PARAMS (ifp);
4478 if (argc == 2)
4480 ret = inet_aton(argv[1], &addr);
4481 if (!ret)
4483 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4484 VTY_NEWLINE);
4485 return CMD_WARNING;
4488 params = ospf_lookup_if_params (ifp, addr);
4489 if (params == NULL)
4490 return CMD_SUCCESS;
4493 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4494 UNSET_IF_PARAM (params, auth_simple);
4496 if (params != IF_DEF_PARAMS (ifp))
4498 ospf_free_if_params (ifp, addr);
4499 ospf_if_update_params (ifp, addr);
4502 return CMD_SUCCESS;
4505 ALIAS (no_ip_ospf_authentication_key,
4506 no_ip_ospf_authentication_key_cmd,
4507 "no ip ospf authentication-key",
4508 NO_STR
4509 "IP Information\n"
4510 "OSPF interface commands\n"
4511 "Authentication password (key)\n")
4513 ALIAS (no_ip_ospf_authentication_key,
4514 no_ospf_authentication_key_cmd,
4515 "no ospf authentication-key",
4516 NO_STR
4517 "OSPF interface commands\n"
4518 "Authentication password (key)\n")
4520 DEFUN (ip_ospf_message_digest_key,
4521 ip_ospf_message_digest_key_addr_cmd,
4522 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4523 "IP Information\n"
4524 "OSPF interface commands\n"
4525 "Message digest authentication password (key)\n"
4526 "Key ID\n"
4527 "Use MD5 algorithm\n"
4528 "The OSPF password (key)"
4529 "Address of interface")
4531 struct interface *ifp;
4532 struct crypt_key *ck;
4533 u_char key_id;
4534 struct in_addr addr;
4535 int ret;
4536 struct ospf_if_params *params;
4538 ifp = vty->index;
4539 params = IF_DEF_PARAMS (ifp);
4541 if (argc == 3)
4543 ret = inet_aton(argv[2], &addr);
4544 if (!ret)
4546 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4547 VTY_NEWLINE);
4548 return CMD_WARNING;
4551 params = ospf_get_if_params (ifp, addr);
4552 ospf_if_update_params (ifp, addr);
4555 key_id = strtol (argv[0], NULL, 10);
4556 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4558 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4559 return CMD_WARNING;
4562 ck = ospf_crypt_key_new ();
4563 ck->key_id = (u_char) key_id;
4564 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
4565 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
4567 ospf_crypt_key_add (params->auth_crypt, ck);
4568 SET_IF_PARAM (params, auth_crypt);
4570 return CMD_SUCCESS;
4573 ALIAS (ip_ospf_message_digest_key,
4574 ip_ospf_message_digest_key_cmd,
4575 "ip ospf message-digest-key <1-255> md5 KEY",
4576 "IP Information\n"
4577 "OSPF interface commands\n"
4578 "Message digest authentication password (key)\n"
4579 "Key ID\n"
4580 "Use MD5 algorithm\n"
4581 "The OSPF password (key)")
4583 ALIAS (ip_ospf_message_digest_key,
4584 ospf_message_digest_key_cmd,
4585 "ospf message-digest-key <1-255> md5 KEY",
4586 "OSPF interface commands\n"
4587 "Message digest authentication password (key)\n"
4588 "Key ID\n"
4589 "Use MD5 algorithm\n"
4590 "The OSPF password (key)")
4592 DEFUN (no_ip_ospf_message_digest_key,
4593 no_ip_ospf_message_digest_key_addr_cmd,
4594 "no ip ospf message-digest-key <1-255> A.B.C.D",
4595 NO_STR
4596 "IP Information\n"
4597 "OSPF interface commands\n"
4598 "Message digest authentication password (key)\n"
4599 "Key ID\n"
4600 "Address of interface")
4602 struct interface *ifp;
4603 struct crypt_key *ck;
4604 int key_id;
4605 struct in_addr addr;
4606 int ret;
4607 struct ospf_if_params *params;
4609 ifp = vty->index;
4610 params = IF_DEF_PARAMS (ifp);
4612 if (argc == 2)
4614 ret = inet_aton(argv[1], &addr);
4615 if (!ret)
4617 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4618 VTY_NEWLINE);
4619 return CMD_WARNING;
4622 params = ospf_lookup_if_params (ifp, addr);
4623 if (params == NULL)
4624 return CMD_SUCCESS;
4627 key_id = strtol (argv[0], NULL, 10);
4628 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4629 if (ck == NULL)
4631 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4632 return CMD_WARNING;
4635 ospf_crypt_key_delete (params->auth_crypt, key_id);
4637 if (params != IF_DEF_PARAMS (ifp))
4639 ospf_free_if_params (ifp, addr);
4640 ospf_if_update_params (ifp, addr);
4643 return CMD_SUCCESS;
4646 ALIAS (no_ip_ospf_message_digest_key,
4647 no_ip_ospf_message_digest_key_cmd,
4648 "no ip ospf message-digest-key <1-255>",
4649 NO_STR
4650 "IP Information\n"
4651 "OSPF interface commands\n"
4652 "Message digest authentication password (key)\n"
4653 "Key ID\n")
4655 ALIAS (no_ip_ospf_message_digest_key,
4656 no_ospf_message_digest_key_cmd,
4657 "no ospf message-digest-key <1-255>",
4658 NO_STR
4659 "OSPF interface commands\n"
4660 "Message digest authentication password (key)\n"
4661 "Key ID\n")
4663 DEFUN (ip_ospf_cost,
4664 ip_ospf_cost_addr_cmd,
4665 "ip ospf cost <1-65535> A.B.C.D",
4666 "IP Information\n"
4667 "OSPF interface commands\n"
4668 "Interface cost\n"
4669 "Cost\n"
4670 "Address of interface")
4672 struct interface *ifp = vty->index;
4673 u_int32_t cost;
4674 struct in_addr addr;
4675 int ret;
4676 struct ospf_if_params *params;
4678 params = IF_DEF_PARAMS (ifp);
4680 cost = strtol (argv[0], NULL, 10);
4682 /* cost range is <1-65535>. */
4683 if (cost < 1 || cost > 65535)
4685 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4686 return CMD_WARNING;
4689 if (argc == 2)
4691 ret = inet_aton(argv[1], &addr);
4692 if (!ret)
4694 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4695 VTY_NEWLINE);
4696 return CMD_WARNING;
4699 params = ospf_get_if_params (ifp, addr);
4700 ospf_if_update_params (ifp, addr);
4703 SET_IF_PARAM (params, output_cost_cmd);
4704 params->output_cost_cmd = cost;
4706 ospf_if_recalculate_output_cost (ifp);
4708 return CMD_SUCCESS;
4711 ALIAS (ip_ospf_cost,
4712 ip_ospf_cost_cmd,
4713 "ip ospf cost <1-65535>",
4714 "IP Information\n"
4715 "OSPF interface commands\n"
4716 "Interface cost\n"
4717 "Cost")
4719 ALIAS (ip_ospf_cost,
4720 ospf_cost_cmd,
4721 "ospf cost <1-65535>",
4722 "OSPF interface commands\n"
4723 "Interface cost\n"
4724 "Cost")
4726 DEFUN (no_ip_ospf_cost,
4727 no_ip_ospf_cost_addr_cmd,
4728 "no ip ospf cost A.B.C.D",
4729 NO_STR
4730 "IP Information\n"
4731 "OSPF interface commands\n"
4732 "Interface cost\n"
4733 "Address of interface")
4735 struct interface *ifp = vty->index;
4736 struct in_addr addr;
4737 int ret;
4738 struct ospf_if_params *params;
4740 ifp = vty->index;
4741 params = IF_DEF_PARAMS (ifp);
4743 if (argc == 1)
4745 ret = inet_aton(argv[0], &addr);
4746 if (!ret)
4748 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4749 VTY_NEWLINE);
4750 return CMD_WARNING;
4753 params = ospf_lookup_if_params (ifp, addr);
4754 if (params == NULL)
4755 return CMD_SUCCESS;
4758 UNSET_IF_PARAM (params, output_cost_cmd);
4760 if (params != IF_DEF_PARAMS (ifp))
4762 ospf_free_if_params (ifp, addr);
4763 ospf_if_update_params (ifp, addr);
4766 ospf_if_recalculate_output_cost (ifp);
4768 return CMD_SUCCESS;
4771 ALIAS (no_ip_ospf_cost,
4772 no_ip_ospf_cost_cmd,
4773 "no ip ospf cost",
4774 NO_STR
4775 "IP Information\n"
4776 "OSPF interface commands\n"
4777 "Interface cost\n")
4779 ALIAS (no_ip_ospf_cost,
4780 no_ospf_cost_cmd,
4781 "no ospf cost",
4782 NO_STR
4783 "OSPF interface commands\n"
4784 "Interface cost\n")
4786 static void
4787 ospf_nbr_timer_update (struct ospf_interface *oi)
4789 struct route_node *rn;
4790 struct ospf_neighbor *nbr;
4792 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4793 if ((nbr = rn->info))
4795 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4796 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4797 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4798 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4802 static int
4803 ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str,
4804 const char *nbr_str,
4805 const char *fast_hello_str)
4807 struct interface *ifp = vty->index;
4808 u_int32_t seconds;
4809 u_char hellomult;
4810 struct in_addr addr;
4811 int ret;
4812 struct ospf_if_params *params;
4813 struct ospf_interface *oi;
4814 struct route_node *rn;
4816 params = IF_DEF_PARAMS (ifp);
4818 if (nbr_str)
4820 ret = inet_aton(nbr_str, &addr);
4821 if (!ret)
4823 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4824 VTY_NEWLINE);
4825 return CMD_WARNING;
4828 params = ospf_get_if_params (ifp, addr);
4829 ospf_if_update_params (ifp, addr);
4832 if (interval_str)
4834 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str,
4835 1, 65535);
4837 /* reset fast_hello too, just to be sure */
4838 UNSET_IF_PARAM (params, fast_hello);
4839 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
4841 else if (fast_hello_str)
4843 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str,
4844 1, 10);
4845 /* 1s dead-interval with sub-second hellos desired */
4846 seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL;
4847 SET_IF_PARAM (params, fast_hello);
4848 params->fast_hello = hellomult;
4850 else
4852 vty_out (vty, "Please specify dead-interval or hello-multiplier%s",
4853 VTY_NEWLINE);
4854 return CMD_WARNING;
4857 SET_IF_PARAM (params, v_wait);
4858 params->v_wait = seconds;
4860 /* Update timer values in neighbor structure. */
4861 if (nbr_str)
4863 struct ospf *ospf;
4864 if ((ospf = ospf_lookup()))
4866 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4867 if (oi)
4868 ospf_nbr_timer_update (oi);
4871 else
4873 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4874 if ((oi = rn->info))
4875 ospf_nbr_timer_update (oi);
4878 return CMD_SUCCESS;
4882 DEFUN (ip_ospf_dead_interval,
4883 ip_ospf_dead_interval_addr_cmd,
4884 "ip ospf dead-interval <1-65535> A.B.C.D",
4885 "IP Information\n"
4886 "OSPF interface commands\n"
4887 "Interval after which a neighbor is declared dead\n"
4888 "Seconds\n"
4889 "Address of interface\n")
4891 if (argc == 2)
4892 return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL);
4893 else
4894 return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL);
4897 ALIAS (ip_ospf_dead_interval,
4898 ip_ospf_dead_interval_cmd,
4899 "ip ospf dead-interval <1-65535>",
4900 "IP Information\n"
4901 "OSPF interface commands\n"
4902 "Interval after which a neighbor is declared dead\n"
4903 "Seconds\n")
4905 ALIAS (ip_ospf_dead_interval,
4906 ospf_dead_interval_cmd,
4907 "ospf dead-interval <1-65535>",
4908 "OSPF interface commands\n"
4909 "Interval after which a neighbor is declared dead\n"
4910 "Seconds\n")
4912 DEFUN (ip_ospf_dead_interval_minimal,
4913 ip_ospf_dead_interval_minimal_addr_cmd,
4914 "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
4915 "IP Information\n"
4916 "OSPF interface commands\n"
4917 "Interval after which a neighbor is declared dead\n"
4918 "Minimal 1s dead-interval with fast sub-second hellos\n"
4919 "Hello multiplier factor\n"
4920 "Number of Hellos to send each second\n"
4921 "Address of interface\n")
4923 if (argc == 2)
4924 return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]);
4925 else
4926 return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]);
4929 ALIAS (ip_ospf_dead_interval_minimal,
4930 ip_ospf_dead_interval_minimal_cmd,
4931 "ip ospf dead-interval minimal hello-multiplier <1-10>",
4932 "IP Information\n"
4933 "OSPF interface commands\n"
4934 "Interval after which a neighbor is declared dead\n"
4935 "Minimal 1s dead-interval with fast sub-second hellos\n"
4936 "Hello multiplier factor\n"
4937 "Number of Hellos to send each second\n")
4939 DEFUN (no_ip_ospf_dead_interval,
4940 no_ip_ospf_dead_interval_addr_cmd,
4941 "no ip ospf dead-interval A.B.C.D",
4942 NO_STR
4943 "IP Information\n"
4944 "OSPF interface commands\n"
4945 "Interval after which a neighbor is declared dead\n"
4946 "Address of interface")
4948 struct interface *ifp = vty->index;
4949 struct in_addr addr;
4950 int ret;
4951 struct ospf_if_params *params;
4952 struct ospf_interface *oi;
4953 struct route_node *rn;
4955 ifp = vty->index;
4956 params = IF_DEF_PARAMS (ifp);
4958 if (argc == 1)
4960 ret = inet_aton(argv[0], &addr);
4961 if (!ret)
4963 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4964 VTY_NEWLINE);
4965 return CMD_WARNING;
4968 params = ospf_lookup_if_params (ifp, addr);
4969 if (params == NULL)
4970 return CMD_SUCCESS;
4973 UNSET_IF_PARAM (params, v_wait);
4974 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
4976 UNSET_IF_PARAM (params, fast_hello);
4977 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
4979 if (params != IF_DEF_PARAMS (ifp))
4981 ospf_free_if_params (ifp, addr);
4982 ospf_if_update_params (ifp, addr);
4985 /* Update timer values in neighbor structure. */
4986 if (argc == 1)
4988 struct ospf *ospf;
4990 if ((ospf = ospf_lookup()))
4992 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4993 if (oi)
4994 ospf_nbr_timer_update (oi);
4997 else
4999 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5000 if ((oi = rn->info))
5001 ospf_nbr_timer_update (oi);
5004 return CMD_SUCCESS;
5007 ALIAS (no_ip_ospf_dead_interval,
5008 no_ip_ospf_dead_interval_cmd,
5009 "no ip ospf dead-interval",
5010 NO_STR
5011 "IP Information\n"
5012 "OSPF interface commands\n"
5013 "Interval after which a neighbor is declared dead\n")
5015 ALIAS (no_ip_ospf_dead_interval,
5016 no_ospf_dead_interval_cmd,
5017 "no ospf dead-interval",
5018 NO_STR
5019 "OSPF interface commands\n"
5020 "Interval after which a neighbor is declared dead\n")
5022 DEFUN (ip_ospf_hello_interval,
5023 ip_ospf_hello_interval_addr_cmd,
5024 "ip ospf hello-interval <1-65535> A.B.C.D",
5025 "IP Information\n"
5026 "OSPF interface commands\n"
5027 "Time between HELLO packets\n"
5028 "Seconds\n"
5029 "Address of interface")
5031 struct interface *ifp = vty->index;
5032 u_int32_t seconds;
5033 struct in_addr addr;
5034 int ret;
5035 struct ospf_if_params *params;
5037 params = IF_DEF_PARAMS (ifp);
5039 seconds = strtol (argv[0], NULL, 10);
5041 /* HelloInterval range is <1-65535>. */
5042 if (seconds < 1 || seconds > 65535)
5044 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
5045 return CMD_WARNING;
5048 if (argc == 2)
5050 ret = inet_aton(argv[1], &addr);
5051 if (!ret)
5053 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5054 VTY_NEWLINE);
5055 return CMD_WARNING;
5058 params = ospf_get_if_params (ifp, addr);
5059 ospf_if_update_params (ifp, addr);
5062 SET_IF_PARAM (params, v_hello);
5063 params->v_hello = seconds;
5065 return CMD_SUCCESS;
5068 ALIAS (ip_ospf_hello_interval,
5069 ip_ospf_hello_interval_cmd,
5070 "ip ospf hello-interval <1-65535>",
5071 "IP Information\n"
5072 "OSPF interface commands\n"
5073 "Time between HELLO packets\n"
5074 "Seconds\n")
5076 ALIAS (ip_ospf_hello_interval,
5077 ospf_hello_interval_cmd,
5078 "ospf hello-interval <1-65535>",
5079 "OSPF interface commands\n"
5080 "Time between HELLO packets\n"
5081 "Seconds\n")
5083 DEFUN (no_ip_ospf_hello_interval,
5084 no_ip_ospf_hello_interval_addr_cmd,
5085 "no ip ospf hello-interval A.B.C.D",
5086 NO_STR
5087 "IP Information\n"
5088 "OSPF interface commands\n"
5089 "Time between HELLO packets\n"
5090 "Address of interface")
5092 struct interface *ifp = vty->index;
5093 struct in_addr addr;
5094 int ret;
5095 struct ospf_if_params *params;
5097 ifp = vty->index;
5098 params = IF_DEF_PARAMS (ifp);
5100 if (argc == 1)
5102 ret = inet_aton(argv[0], &addr);
5103 if (!ret)
5105 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5106 VTY_NEWLINE);
5107 return CMD_WARNING;
5110 params = ospf_lookup_if_params (ifp, addr);
5111 if (params == NULL)
5112 return CMD_SUCCESS;
5115 UNSET_IF_PARAM (params, v_hello);
5116 params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT;
5118 if (params != IF_DEF_PARAMS (ifp))
5120 ospf_free_if_params (ifp, addr);
5121 ospf_if_update_params (ifp, addr);
5124 return CMD_SUCCESS;
5127 ALIAS (no_ip_ospf_hello_interval,
5128 no_ip_ospf_hello_interval_cmd,
5129 "no ip ospf hello-interval",
5130 NO_STR
5131 "IP Information\n"
5132 "OSPF interface commands\n"
5133 "Time between HELLO packets\n")
5135 ALIAS (no_ip_ospf_hello_interval,
5136 no_ospf_hello_interval_cmd,
5137 "no ospf hello-interval",
5138 NO_STR
5139 "OSPF interface commands\n"
5140 "Time between HELLO packets\n")
5142 DEFUN (ip_ospf_network,
5143 ip_ospf_network_cmd,
5144 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5145 "IP Information\n"
5146 "OSPF interface commands\n"
5147 "Network type\n"
5148 "Specify OSPF broadcast multi-access network\n"
5149 "Specify OSPF NBMA network\n"
5150 "Specify OSPF point-to-multipoint network\n"
5151 "Specify OSPF point-to-point network\n")
5153 struct interface *ifp = vty->index;
5154 int old_type = IF_DEF_PARAMS (ifp)->type;
5155 struct route_node *rn;
5157 if (strncmp (argv[0], "b", 1) == 0)
5158 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
5159 else if (strncmp (argv[0], "n", 1) == 0)
5160 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
5161 else if (strncmp (argv[0], "point-to-m", 10) == 0)
5162 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
5163 else if (strncmp (argv[0], "point-to-p", 10) == 0)
5164 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
5166 if (IF_DEF_PARAMS (ifp)->type == old_type)
5167 return CMD_SUCCESS;
5169 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
5171 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5173 struct ospf_interface *oi = rn->info;
5175 if (!oi)
5176 continue;
5178 oi->type = IF_DEF_PARAMS (ifp)->type;
5180 if (oi->state > ISM_Down)
5182 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5183 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5187 return CMD_SUCCESS;
5190 ALIAS (ip_ospf_network,
5191 ospf_network_cmd,
5192 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5193 "OSPF interface commands\n"
5194 "Network type\n"
5195 "Specify OSPF broadcast multi-access network\n"
5196 "Specify OSPF NBMA network\n"
5197 "Specify OSPF point-to-multipoint network\n"
5198 "Specify OSPF point-to-point network\n")
5200 DEFUN (no_ip_ospf_network,
5201 no_ip_ospf_network_cmd,
5202 "no ip ospf network",
5203 NO_STR
5204 "IP Information\n"
5205 "OSPF interface commands\n"
5206 "Network type\n")
5208 struct interface *ifp = vty->index;
5209 int old_type = IF_DEF_PARAMS (ifp)->type;
5210 struct route_node *rn;
5212 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
5214 if (IF_DEF_PARAMS (ifp)->type == old_type)
5215 return CMD_SUCCESS;
5217 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5219 struct ospf_interface *oi = rn->info;
5221 if (!oi)
5222 continue;
5224 oi->type = IF_DEF_PARAMS (ifp)->type;
5226 if (oi->state > ISM_Down)
5228 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5229 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5233 return CMD_SUCCESS;
5236 ALIAS (no_ip_ospf_network,
5237 no_ospf_network_cmd,
5238 "no ospf network",
5239 NO_STR
5240 "OSPF interface commands\n"
5241 "Network type\n")
5243 DEFUN (ip_ospf_priority,
5244 ip_ospf_priority_addr_cmd,
5245 "ip ospf priority <0-255> A.B.C.D",
5246 "IP Information\n"
5247 "OSPF interface commands\n"
5248 "Router priority\n"
5249 "Priority\n"
5250 "Address of interface")
5252 struct interface *ifp = vty->index;
5253 u_int32_t priority;
5254 struct route_node *rn;
5255 struct in_addr addr;
5256 int ret;
5257 struct ospf_if_params *params;
5259 params = IF_DEF_PARAMS (ifp);
5261 priority = strtol (argv[0], NULL, 10);
5263 /* Router Priority range is <0-255>. */
5264 if (priority < 0 || priority > 255)
5266 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
5267 return CMD_WARNING;
5270 if (argc == 2)
5272 ret = inet_aton(argv[1], &addr);
5273 if (!ret)
5275 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5276 VTY_NEWLINE);
5277 return CMD_WARNING;
5280 params = ospf_get_if_params (ifp, addr);
5281 ospf_if_update_params (ifp, addr);
5284 SET_IF_PARAM (params, priority);
5285 params->priority = priority;
5287 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5289 struct ospf_interface *oi = rn->info;
5291 if (!oi)
5292 continue;
5295 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5297 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5298 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5302 return CMD_SUCCESS;
5305 ALIAS (ip_ospf_priority,
5306 ip_ospf_priority_cmd,
5307 "ip ospf priority <0-255>",
5308 "IP Information\n"
5309 "OSPF interface commands\n"
5310 "Router priority\n"
5311 "Priority\n")
5313 ALIAS (ip_ospf_priority,
5314 ospf_priority_cmd,
5315 "ospf priority <0-255>",
5316 "OSPF interface commands\n"
5317 "Router priority\n"
5318 "Priority\n")
5320 DEFUN (no_ip_ospf_priority,
5321 no_ip_ospf_priority_addr_cmd,
5322 "no ip ospf priority A.B.C.D",
5323 NO_STR
5324 "IP Information\n"
5325 "OSPF interface commands\n"
5326 "Router priority\n"
5327 "Address of interface")
5329 struct interface *ifp = vty->index;
5330 struct route_node *rn;
5331 struct in_addr addr;
5332 int ret;
5333 struct ospf_if_params *params;
5335 ifp = vty->index;
5336 params = IF_DEF_PARAMS (ifp);
5338 if (argc == 1)
5340 ret = inet_aton(argv[0], &addr);
5341 if (!ret)
5343 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5344 VTY_NEWLINE);
5345 return CMD_WARNING;
5348 params = ospf_lookup_if_params (ifp, addr);
5349 if (params == NULL)
5350 return CMD_SUCCESS;
5353 UNSET_IF_PARAM (params, priority);
5354 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
5356 if (params != IF_DEF_PARAMS (ifp))
5358 ospf_free_if_params (ifp, addr);
5359 ospf_if_update_params (ifp, addr);
5362 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5364 struct ospf_interface *oi = rn->info;
5366 if (!oi)
5367 continue;
5370 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5372 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5373 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5377 return CMD_SUCCESS;
5380 ALIAS (no_ip_ospf_priority,
5381 no_ip_ospf_priority_cmd,
5382 "no ip ospf priority",
5383 NO_STR
5384 "IP Information\n"
5385 "OSPF interface commands\n"
5386 "Router priority\n")
5388 ALIAS (no_ip_ospf_priority,
5389 no_ospf_priority_cmd,
5390 "no ospf priority",
5391 NO_STR
5392 "OSPF interface commands\n"
5393 "Router priority\n")
5395 DEFUN (ip_ospf_retransmit_interval,
5396 ip_ospf_retransmit_interval_addr_cmd,
5397 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5398 "IP Information\n"
5399 "OSPF interface commands\n"
5400 "Time between retransmitting lost link state advertisements\n"
5401 "Seconds\n"
5402 "Address of interface")
5404 struct interface *ifp = vty->index;
5405 u_int32_t seconds;
5406 struct in_addr addr;
5407 int ret;
5408 struct ospf_if_params *params;
5410 params = IF_DEF_PARAMS (ifp);
5411 seconds = strtol (argv[0], NULL, 10);
5413 /* Retransmit Interval range is <3-65535>. */
5414 if (seconds < 3 || seconds > 65535)
5416 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5417 return CMD_WARNING;
5421 if (argc == 2)
5423 ret = inet_aton(argv[1], &addr);
5424 if (!ret)
5426 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5427 VTY_NEWLINE);
5428 return CMD_WARNING;
5431 params = ospf_get_if_params (ifp, addr);
5432 ospf_if_update_params (ifp, addr);
5435 SET_IF_PARAM (params, retransmit_interval);
5436 params->retransmit_interval = seconds;
5438 return CMD_SUCCESS;
5441 ALIAS (ip_ospf_retransmit_interval,
5442 ip_ospf_retransmit_interval_cmd,
5443 "ip ospf retransmit-interval <3-65535>",
5444 "IP Information\n"
5445 "OSPF interface commands\n"
5446 "Time between retransmitting lost link state advertisements\n"
5447 "Seconds\n")
5449 ALIAS (ip_ospf_retransmit_interval,
5450 ospf_retransmit_interval_cmd,
5451 "ospf retransmit-interval <3-65535>",
5452 "OSPF interface commands\n"
5453 "Time between retransmitting lost link state advertisements\n"
5454 "Seconds\n")
5456 DEFUN (no_ip_ospf_retransmit_interval,
5457 no_ip_ospf_retransmit_interval_addr_cmd,
5458 "no ip ospf retransmit-interval A.B.C.D",
5459 NO_STR
5460 "IP Information\n"
5461 "OSPF interface commands\n"
5462 "Time between retransmitting lost link state advertisements\n"
5463 "Address of interface")
5465 struct interface *ifp = vty->index;
5466 struct in_addr addr;
5467 int ret;
5468 struct ospf_if_params *params;
5470 ifp = vty->index;
5471 params = IF_DEF_PARAMS (ifp);
5473 if (argc == 1)
5475 ret = inet_aton(argv[0], &addr);
5476 if (!ret)
5478 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5479 VTY_NEWLINE);
5480 return CMD_WARNING;
5483 params = ospf_lookup_if_params (ifp, addr);
5484 if (params == NULL)
5485 return CMD_SUCCESS;
5488 UNSET_IF_PARAM (params, retransmit_interval);
5489 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5491 if (params != IF_DEF_PARAMS (ifp))
5493 ospf_free_if_params (ifp, addr);
5494 ospf_if_update_params (ifp, addr);
5497 return CMD_SUCCESS;
5500 ALIAS (no_ip_ospf_retransmit_interval,
5501 no_ip_ospf_retransmit_interval_cmd,
5502 "no ip ospf retransmit-interval",
5503 NO_STR
5504 "IP Information\n"
5505 "OSPF interface commands\n"
5506 "Time between retransmitting lost link state advertisements\n")
5508 ALIAS (no_ip_ospf_retransmit_interval,
5509 no_ospf_retransmit_interval_cmd,
5510 "no ospf retransmit-interval",
5511 NO_STR
5512 "OSPF interface commands\n"
5513 "Time between retransmitting lost link state advertisements\n")
5515 DEFUN (ip_ospf_transmit_delay,
5516 ip_ospf_transmit_delay_addr_cmd,
5517 "ip ospf transmit-delay <1-65535> A.B.C.D",
5518 "IP Information\n"
5519 "OSPF interface commands\n"
5520 "Link state transmit delay\n"
5521 "Seconds\n"
5522 "Address of interface")
5524 struct interface *ifp = vty->index;
5525 u_int32_t seconds;
5526 struct in_addr addr;
5527 int ret;
5528 struct ospf_if_params *params;
5530 params = IF_DEF_PARAMS (ifp);
5531 seconds = strtol (argv[0], NULL, 10);
5533 /* Transmit Delay range is <1-65535>. */
5534 if (seconds < 1 || seconds > 65535)
5536 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5537 return CMD_WARNING;
5540 if (argc == 2)
5542 ret = inet_aton(argv[1], &addr);
5543 if (!ret)
5545 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5546 VTY_NEWLINE);
5547 return CMD_WARNING;
5550 params = ospf_get_if_params (ifp, addr);
5551 ospf_if_update_params (ifp, addr);
5554 SET_IF_PARAM (params, transmit_delay);
5555 params->transmit_delay = seconds;
5557 return CMD_SUCCESS;
5560 ALIAS (ip_ospf_transmit_delay,
5561 ip_ospf_transmit_delay_cmd,
5562 "ip ospf transmit-delay <1-65535>",
5563 "IP Information\n"
5564 "OSPF interface commands\n"
5565 "Link state transmit delay\n"
5566 "Seconds\n")
5568 ALIAS (ip_ospf_transmit_delay,
5569 ospf_transmit_delay_cmd,
5570 "ospf transmit-delay <1-65535>",
5571 "OSPF interface commands\n"
5572 "Link state transmit delay\n"
5573 "Seconds\n")
5575 DEFUN (no_ip_ospf_transmit_delay,
5576 no_ip_ospf_transmit_delay_addr_cmd,
5577 "no ip ospf transmit-delay A.B.C.D",
5578 NO_STR
5579 "IP Information\n"
5580 "OSPF interface commands\n"
5581 "Link state transmit delay\n"
5582 "Address of interface")
5584 struct interface *ifp = vty->index;
5585 struct in_addr addr;
5586 int ret;
5587 struct ospf_if_params *params;
5589 ifp = vty->index;
5590 params = IF_DEF_PARAMS (ifp);
5592 if (argc == 1)
5594 ret = inet_aton(argv[0], &addr);
5595 if (!ret)
5597 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5598 VTY_NEWLINE);
5599 return CMD_WARNING;
5602 params = ospf_lookup_if_params (ifp, addr);
5603 if (params == NULL)
5604 return CMD_SUCCESS;
5607 UNSET_IF_PARAM (params, transmit_delay);
5608 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5610 if (params != IF_DEF_PARAMS (ifp))
5612 ospf_free_if_params (ifp, addr);
5613 ospf_if_update_params (ifp, addr);
5616 return CMD_SUCCESS;
5619 ALIAS (no_ip_ospf_transmit_delay,
5620 no_ip_ospf_transmit_delay_cmd,
5621 "no ip ospf transmit-delay",
5622 NO_STR
5623 "IP Information\n"
5624 "OSPF interface commands\n"
5625 "Link state transmit delay\n")
5627 ALIAS (no_ip_ospf_transmit_delay,
5628 no_ospf_transmit_delay_cmd,
5629 "no ospf transmit-delay",
5630 NO_STR
5631 "OSPF interface commands\n"
5632 "Link state transmit delay\n")
5635 DEFUN (ospf_redistribute_source_metric_type,
5636 ospf_redistribute_source_metric_type_routemap_cmd,
5637 "redistribute " QUAGGA_REDIST_STR_OSPFD
5638 " metric <0-16777214> metric-type (1|2) route-map WORD",
5639 REDIST_STR
5640 QUAGGA_REDIST_HELP_STR_OSPFD
5641 "Metric for redistributed routes\n"
5642 "OSPF default metric\n"
5643 "OSPF exterior metric type for redistributed routes\n"
5644 "Set OSPF External Type 1 metrics\n"
5645 "Set OSPF External Type 2 metrics\n"
5646 "Route map reference\n"
5647 "Pointer to route-map entries\n")
5649 struct ospf *ospf = vty->index;
5650 int source;
5651 int type = -1;
5652 int metric = -1;
5654 /* Get distribute source. */
5655 if (!str2distribute_source (argv[0], &source))
5656 return CMD_WARNING;
5658 /* Get metric value. */
5659 if (argc >= 2)
5660 if (!str2metric (argv[1], &metric))
5661 return CMD_WARNING;
5663 /* Get metric type. */
5664 if (argc >= 3)
5665 if (!str2metric_type (argv[2], &type))
5666 return CMD_WARNING;
5668 if (argc == 4)
5669 ospf_routemap_set (ospf, source, argv[3]);
5670 else
5671 ospf_routemap_unset (ospf, source);
5673 return ospf_redistribute_set (ospf, source, type, metric);
5676 ALIAS (ospf_redistribute_source_metric_type,
5677 ospf_redistribute_source_metric_type_cmd,
5678 "redistribute " QUAGGA_REDIST_STR_OSPFD
5679 " metric <0-16777214> metric-type (1|2)",
5680 REDIST_STR
5681 QUAGGA_REDIST_HELP_STR_OSPFD
5682 "Metric for redistributed routes\n"
5683 "OSPF default metric\n"
5684 "OSPF exterior metric type for redistributed routes\n"
5685 "Set OSPF External Type 1 metrics\n"
5686 "Set OSPF External Type 2 metrics\n")
5688 ALIAS (ospf_redistribute_source_metric_type,
5689 ospf_redistribute_source_metric_cmd,
5690 "redistribute " QUAGGA_REDIST_STR_OSPFD " metric <0-16777214>",
5691 REDIST_STR
5692 QUAGGA_REDIST_HELP_STR_OSPFD
5693 "Metric for redistributed routes\n"
5694 "OSPF default metric\n")
5696 DEFUN (ospf_redistribute_source_type_metric,
5697 ospf_redistribute_source_type_metric_routemap_cmd,
5698 "redistribute " QUAGGA_REDIST_STR_OSPFD
5699 " metric-type (1|2) metric <0-16777214> route-map WORD",
5700 REDIST_STR
5701 QUAGGA_REDIST_HELP_STR_OSPFD
5702 "OSPF exterior metric type for redistributed routes\n"
5703 "Set OSPF External Type 1 metrics\n"
5704 "Set OSPF External Type 2 metrics\n"
5705 "Metric for redistributed routes\n"
5706 "OSPF default metric\n"
5707 "Route map reference\n"
5708 "Pointer to route-map entries\n")
5710 struct ospf *ospf = vty->index;
5711 int source;
5712 int type = -1;
5713 int metric = -1;
5715 /* Get distribute source. */
5716 if (!str2distribute_source (argv[0], &source))
5717 return CMD_WARNING;
5719 /* Get metric value. */
5720 if (argc >= 2)
5721 if (!str2metric_type (argv[1], &type))
5722 return CMD_WARNING;
5724 /* Get metric type. */
5725 if (argc >= 3)
5726 if (!str2metric (argv[2], &metric))
5727 return CMD_WARNING;
5729 if (argc == 4)
5730 ospf_routemap_set (ospf, source, argv[3]);
5731 else
5732 ospf_routemap_unset (ospf, source);
5734 return ospf_redistribute_set (ospf, source, type, metric);
5737 ALIAS (ospf_redistribute_source_type_metric,
5738 ospf_redistribute_source_type_metric_cmd,
5739 "redistribute " QUAGGA_REDIST_STR_OSPFD
5740 " metric-type (1|2) metric <0-16777214>",
5741 REDIST_STR
5742 QUAGGA_REDIST_HELP_STR_OSPFD
5743 "OSPF exterior metric type for redistributed routes\n"
5744 "Set OSPF External Type 1 metrics\n"
5745 "Set OSPF External Type 2 metrics\n"
5746 "Metric for redistributed routes\n"
5747 "OSPF default metric\n")
5749 ALIAS (ospf_redistribute_source_type_metric,
5750 ospf_redistribute_source_type_cmd,
5751 "redistribute " QUAGGA_REDIST_STR_OSPFD " metric-type (1|2)",
5752 REDIST_STR
5753 QUAGGA_REDIST_HELP_STR_OSPFD
5754 "OSPF exterior metric type for redistributed routes\n"
5755 "Set OSPF External Type 1 metrics\n"
5756 "Set OSPF External Type 2 metrics\n")
5758 ALIAS (ospf_redistribute_source_type_metric,
5759 ospf_redistribute_source_cmd,
5760 "redistribute " QUAGGA_REDIST_STR_OSPFD,
5761 REDIST_STR
5762 QUAGGA_REDIST_HELP_STR_OSPFD)
5764 DEFUN (ospf_redistribute_source_metric_routemap,
5765 ospf_redistribute_source_metric_routemap_cmd,
5766 "redistribute " QUAGGA_REDIST_STR_OSPFD
5767 " metric <0-16777214> route-map WORD",
5768 REDIST_STR
5769 QUAGGA_REDIST_HELP_STR_OSPFD
5770 "Metric for redistributed routes\n"
5771 "OSPF default metric\n"
5772 "Route map reference\n"
5773 "Pointer to route-map entries\n")
5775 struct ospf *ospf = vty->index;
5776 int source;
5777 int metric = -1;
5779 /* Get distribute source. */
5780 if (!str2distribute_source (argv[0], &source))
5781 return CMD_WARNING;
5783 /* Get metric value. */
5784 if (argc >= 2)
5785 if (!str2metric (argv[1], &metric))
5786 return CMD_WARNING;
5788 if (argc == 3)
5789 ospf_routemap_set (ospf, source, argv[2]);
5790 else
5791 ospf_routemap_unset (ospf, source);
5793 return ospf_redistribute_set (ospf, source, -1, metric);
5796 DEFUN (ospf_redistribute_source_type_routemap,
5797 ospf_redistribute_source_type_routemap_cmd,
5798 "redistribute " QUAGGA_REDIST_STR_OSPFD
5799 " metric-type (1|2) route-map WORD",
5800 REDIST_STR
5801 QUAGGA_REDIST_HELP_STR_OSPFD
5802 "OSPF exterior metric type for redistributed routes\n"
5803 "Set OSPF External Type 1 metrics\n"
5804 "Set OSPF External Type 2 metrics\n"
5805 "Route map reference\n"
5806 "Pointer to route-map entries\n")
5808 struct ospf *ospf = vty->index;
5809 int source;
5810 int type = -1;
5812 /* Get distribute source. */
5813 if (!str2distribute_source (argv[0], &source))
5814 return CMD_WARNING;
5816 /* Get metric value. */
5817 if (argc >= 2)
5818 if (!str2metric_type (argv[1], &type))
5819 return CMD_WARNING;
5821 if (argc == 3)
5822 ospf_routemap_set (ospf, source, argv[2]);
5823 else
5824 ospf_routemap_unset (ospf, source);
5826 return ospf_redistribute_set (ospf, source, type, -1);
5829 DEFUN (ospf_redistribute_source_routemap,
5830 ospf_redistribute_source_routemap_cmd,
5831 "redistribute " QUAGGA_REDIST_STR_OSPFD " route-map WORD",
5832 REDIST_STR
5833 QUAGGA_REDIST_HELP_STR_OSPFD
5834 "Route map reference\n"
5835 "Pointer to route-map entries\n")
5837 struct ospf *ospf = vty->index;
5838 int source;
5840 /* Get distribute source. */
5841 if (!str2distribute_source (argv[0], &source))
5842 return CMD_WARNING;
5844 if (argc == 2)
5845 ospf_routemap_set (ospf, source, argv[1]);
5846 else
5847 ospf_routemap_unset (ospf, source);
5849 return ospf_redistribute_set (ospf, source, -1, -1);
5852 DEFUN (no_ospf_redistribute_source,
5853 no_ospf_redistribute_source_cmd,
5854 "no redistribute " QUAGGA_REDIST_STR_OSPFD,
5855 NO_STR
5856 REDIST_STR
5857 QUAGGA_REDIST_HELP_STR_OSPFD)
5859 struct ospf *ospf = vty->index;
5860 int source;
5862 if (!str2distribute_source (argv[0], &source))
5863 return CMD_WARNING;
5865 ospf_routemap_unset (ospf, source);
5866 return ospf_redistribute_unset (ospf, source);
5869 DEFUN (ospf_distribute_list_out,
5870 ospf_distribute_list_out_cmd,
5871 "distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
5872 "Filter networks in routing updates\n"
5873 "Access-list name\n"
5874 OUT_STR
5875 QUAGGA_REDIST_HELP_STR_OSPFD)
5877 struct ospf *ospf = vty->index;
5878 int source;
5880 /* Get distribute source. */
5881 if (!str2distribute_source (argv[1], &source))
5882 return CMD_WARNING;
5884 return ospf_distribute_list_out_set (ospf, source, argv[0]);
5887 DEFUN (no_ospf_distribute_list_out,
5888 no_ospf_distribute_list_out_cmd,
5889 "no distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
5890 NO_STR
5891 "Filter networks in routing updates\n"
5892 "Access-list name\n"
5893 OUT_STR
5894 QUAGGA_REDIST_HELP_STR_OSPFD)
5896 struct ospf *ospf = vty->index;
5897 int source;
5899 if (!str2distribute_source (argv[1], &source))
5900 return CMD_WARNING;
5902 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
5905 /* Default information originate. */
5906 DEFUN (ospf_default_information_originate_metric_type_routemap,
5907 ospf_default_information_originate_metric_type_routemap_cmd,
5908 "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD",
5909 "Control distribution of default information\n"
5910 "Distribute a default route\n"
5911 "OSPF default metric\n"
5912 "OSPF metric\n"
5913 "OSPF metric type for default routes\n"
5914 "Set OSPF External Type 1 metrics\n"
5915 "Set OSPF External Type 2 metrics\n"
5916 "Route map reference\n"
5917 "Pointer to route-map entries\n")
5919 struct ospf *ospf = vty->index;
5920 int type = -1;
5921 int metric = -1;
5923 /* Get metric value. */
5924 if (argc >= 1)
5925 if (!str2metric (argv[0], &metric))
5926 return CMD_WARNING;
5928 /* Get metric type. */
5929 if (argc >= 2)
5930 if (!str2metric_type (argv[1], &type))
5931 return CMD_WARNING;
5933 if (argc == 3)
5934 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
5935 else
5936 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5938 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5939 type, metric);
5942 ALIAS (ospf_default_information_originate_metric_type_routemap,
5943 ospf_default_information_originate_metric_type_cmd,
5944 "default-information originate metric <0-16777214> metric-type (1|2)",
5945 "Control distribution of default information\n"
5946 "Distribute a default route\n"
5947 "OSPF default metric\n"
5948 "OSPF metric\n"
5949 "OSPF metric type for default routes\n"
5950 "Set OSPF External Type 1 metrics\n"
5951 "Set OSPF External Type 2 metrics\n")
5953 ALIAS (ospf_default_information_originate_metric_type_routemap,
5954 ospf_default_information_originate_metric_cmd,
5955 "default-information originate metric <0-16777214>",
5956 "Control distribution of default information\n"
5957 "Distribute a default route\n"
5958 "OSPF default metric\n"
5959 "OSPF metric\n")
5961 ALIAS (ospf_default_information_originate_metric_type_routemap,
5962 ospf_default_information_originate_cmd,
5963 "default-information originate",
5964 "Control distribution of default information\n"
5965 "Distribute a default route\n")
5967 /* Default information originate. */
5968 DEFUN (ospf_default_information_originate_metric_routemap,
5969 ospf_default_information_originate_metric_routemap_cmd,
5970 "default-information originate metric <0-16777214> route-map WORD",
5971 "Control distribution of default information\n"
5972 "Distribute a default route\n"
5973 "OSPF default metric\n"
5974 "OSPF metric\n"
5975 "Route map reference\n"
5976 "Pointer to route-map entries\n")
5978 struct ospf *ospf = vty->index;
5979 int metric = -1;
5981 /* Get metric value. */
5982 if (argc >= 1)
5983 if (!str2metric (argv[0], &metric))
5984 return CMD_WARNING;
5986 if (argc == 2)
5987 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
5988 else
5989 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5991 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5992 -1, metric);
5995 /* Default information originate. */
5996 DEFUN (ospf_default_information_originate_routemap,
5997 ospf_default_information_originate_routemap_cmd,
5998 "default-information originate route-map WORD",
5999 "Control distribution of default information\n"
6000 "Distribute a default route\n"
6001 "Route map reference\n"
6002 "Pointer to route-map entries\n")
6004 struct ospf *ospf = vty->index;
6006 if (argc == 1)
6007 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
6008 else
6009 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6011 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1);
6014 DEFUN (ospf_default_information_originate_type_metric_routemap,
6015 ospf_default_information_originate_type_metric_routemap_cmd,
6016 "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD",
6017 "Control distribution of default information\n"
6018 "Distribute a default route\n"
6019 "OSPF metric type for default routes\n"
6020 "Set OSPF External Type 1 metrics\n"
6021 "Set OSPF External Type 2 metrics\n"
6022 "OSPF default metric\n"
6023 "OSPF metric\n"
6024 "Route map reference\n"
6025 "Pointer to route-map entries\n")
6027 struct ospf *ospf = vty->index;
6028 int type = -1;
6029 int metric = -1;
6031 /* Get metric type. */
6032 if (argc >= 1)
6033 if (!str2metric_type (argv[0], &type))
6034 return CMD_WARNING;
6036 /* Get metric value. */
6037 if (argc >= 2)
6038 if (!str2metric (argv[1], &metric))
6039 return CMD_WARNING;
6041 if (argc == 3)
6042 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
6043 else
6044 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6046 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6047 type, metric);
6050 ALIAS (ospf_default_information_originate_type_metric_routemap,
6051 ospf_default_information_originate_type_metric_cmd,
6052 "default-information originate metric-type (1|2) metric <0-16777214>",
6053 "Control distribution of default information\n"
6054 "Distribute a default route\n"
6055 "OSPF metric type for default routes\n"
6056 "Set OSPF External Type 1 metrics\n"
6057 "Set OSPF External Type 2 metrics\n"
6058 "OSPF default metric\n"
6059 "OSPF metric\n")
6061 ALIAS (ospf_default_information_originate_type_metric_routemap,
6062 ospf_default_information_originate_type_cmd,
6063 "default-information originate metric-type (1|2)",
6064 "Control distribution of default information\n"
6065 "Distribute a default route\n"
6066 "OSPF metric type for default routes\n"
6067 "Set OSPF External Type 1 metrics\n"
6068 "Set OSPF External Type 2 metrics\n")
6070 DEFUN (ospf_default_information_originate_type_routemap,
6071 ospf_default_information_originate_type_routemap_cmd,
6072 "default-information originate metric-type (1|2) route-map WORD",
6073 "Control distribution of default information\n"
6074 "Distribute a default route\n"
6075 "OSPF metric type for default routes\n"
6076 "Set OSPF External Type 1 metrics\n"
6077 "Set OSPF External Type 2 metrics\n"
6078 "Route map reference\n"
6079 "Pointer to route-map entries\n")
6081 struct ospf *ospf = vty->index;
6082 int type = -1;
6084 /* Get metric type. */
6085 if (argc >= 1)
6086 if (!str2metric_type (argv[0], &type))
6087 return CMD_WARNING;
6089 if (argc == 2)
6090 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
6091 else
6092 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6094 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6095 type, -1);
6098 DEFUN (ospf_default_information_originate_always_metric_type_routemap,
6099 ospf_default_information_originate_always_metric_type_routemap_cmd,
6100 "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD",
6101 "Control distribution of default information\n"
6102 "Distribute a default route\n"
6103 "Always advertise default route\n"
6104 "OSPF default metric\n"
6105 "OSPF metric\n"
6106 "OSPF metric type for default routes\n"
6107 "Set OSPF External Type 1 metrics\n"
6108 "Set OSPF External Type 2 metrics\n"
6109 "Route map reference\n"
6110 "Pointer to route-map entries\n")
6112 struct ospf *ospf = vty->index;
6113 int type = -1;
6114 int metric = -1;
6116 /* Get metric value. */
6117 if (argc >= 1)
6118 if (!str2metric (argv[0], &metric))
6119 return CMD_WARNING;
6121 /* Get metric type. */
6122 if (argc >= 2)
6123 if (!str2metric_type (argv[1], &type))
6124 return CMD_WARNING;
6126 if (argc == 3)
6127 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
6128 else
6129 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6131 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
6132 type, metric);
6135 ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6136 ospf_default_information_originate_always_metric_type_cmd,
6137 "default-information originate always metric <0-16777214> metric-type (1|2)",
6138 "Control distribution of default information\n"
6139 "Distribute a default route\n"
6140 "Always advertise default route\n"
6141 "OSPF default metric\n"
6142 "OSPF metric\n"
6143 "OSPF metric type for default routes\n"
6144 "Set OSPF External Type 1 metrics\n"
6145 "Set OSPF External Type 2 metrics\n")
6147 ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6148 ospf_default_information_originate_always_metric_cmd,
6149 "default-information originate always metric <0-16777214>",
6150 "Control distribution of default information\n"
6151 "Distribute a default route\n"
6152 "Always advertise default route\n"
6153 "OSPF default metric\n"
6154 "OSPF metric\n"
6155 "OSPF metric type for default routes\n")
6157 ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6158 ospf_default_information_originate_always_cmd,
6159 "default-information originate always",
6160 "Control distribution of default information\n"
6161 "Distribute a default route\n"
6162 "Always advertise default route\n")
6164 DEFUN (ospf_default_information_originate_always_metric_routemap,
6165 ospf_default_information_originate_always_metric_routemap_cmd,
6166 "default-information originate always metric <0-16777214> route-map WORD",
6167 "Control distribution of default information\n"
6168 "Distribute a default route\n"
6169 "Always advertise default route\n"
6170 "OSPF default metric\n"
6171 "OSPF metric\n"
6172 "Route map reference\n"
6173 "Pointer to route-map entries\n")
6175 struct ospf *ospf = vty->index;
6176 int metric = -1;
6178 /* Get metric value. */
6179 if (argc >= 1)
6180 if (!str2metric (argv[0], &metric))
6181 return CMD_WARNING;
6183 if (argc == 2)
6184 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
6185 else
6186 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6188 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
6189 -1, metric);
6192 DEFUN (ospf_default_information_originate_always_routemap,
6193 ospf_default_information_originate_always_routemap_cmd,
6194 "default-information originate always route-map WORD",
6195 "Control distribution of default information\n"
6196 "Distribute a default route\n"
6197 "Always advertise default route\n"
6198 "Route map reference\n"
6199 "Pointer to route-map entries\n")
6201 struct ospf *ospf = vty->index;
6203 if (argc == 1)
6204 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
6205 else
6206 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6208 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1);
6211 DEFUN (ospf_default_information_originate_always_type_metric_routemap,
6212 ospf_default_information_originate_always_type_metric_routemap_cmd,
6213 "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD",
6214 "Control distribution of default information\n"
6215 "Distribute a default route\n"
6216 "Always advertise default route\n"
6217 "OSPF metric type for default routes\n"
6218 "Set OSPF External Type 1 metrics\n"
6219 "Set OSPF External Type 2 metrics\n"
6220 "OSPF default metric\n"
6221 "OSPF metric\n"
6222 "Route map reference\n"
6223 "Pointer to route-map entries\n")
6225 struct ospf *ospf = vty->index;
6226 int type = -1;
6227 int metric = -1;
6229 /* Get metric type. */
6230 if (argc >= 1)
6231 if (!str2metric_type (argv[0], &type))
6232 return CMD_WARNING;
6234 /* Get metric value. */
6235 if (argc >= 2)
6236 if (!str2metric (argv[1], &metric))
6237 return CMD_WARNING;
6239 if (argc == 3)
6240 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
6241 else
6242 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6244 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
6245 type, metric);
6248 ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6249 ospf_default_information_originate_always_type_metric_cmd,
6250 "default-information originate always metric-type (1|2) metric <0-16777214>",
6251 "Control distribution of default information\n"
6252 "Distribute a default route\n"
6253 "Always advertise default route\n"
6254 "OSPF metric type for default routes\n"
6255 "Set OSPF External Type 1 metrics\n"
6256 "Set OSPF External Type 2 metrics\n"
6257 "OSPF default metric\n"
6258 "OSPF metric\n")
6260 ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6261 ospf_default_information_originate_always_type_cmd,
6262 "default-information originate always metric-type (1|2)",
6263 "Control distribution of default information\n"
6264 "Distribute a default route\n"
6265 "Always advertise default route\n"
6266 "OSPF metric type for default routes\n"
6267 "Set OSPF External Type 1 metrics\n"
6268 "Set OSPF External Type 2 metrics\n")
6270 DEFUN (ospf_default_information_originate_always_type_routemap,
6271 ospf_default_information_originate_always_type_routemap_cmd,
6272 "default-information originate always metric-type (1|2) route-map WORD",
6273 "Control distribution of default information\n"
6274 "Distribute a default route\n"
6275 "Always advertise default route\n"
6276 "OSPF metric type for default routes\n"
6277 "Set OSPF External Type 1 metrics\n"
6278 "Set OSPF External Type 2 metrics\n"
6279 "Route map reference\n"
6280 "Pointer to route-map entries\n")
6282 struct ospf *ospf = vty->index;
6283 int type = -1;
6285 /* Get metric type. */
6286 if (argc >= 1)
6287 if (!str2metric_type (argv[0], &type))
6288 return CMD_WARNING;
6290 if (argc == 2)
6291 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
6292 else
6293 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6295 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
6296 type, -1);
6299 DEFUN (no_ospf_default_information_originate,
6300 no_ospf_default_information_originate_cmd,
6301 "no default-information originate",
6302 NO_STR
6303 "Control distribution of default information\n"
6304 "Distribute a default route\n")
6306 struct ospf *ospf = vty->index;
6307 struct prefix_ipv4 p;
6309 p.family = AF_INET;
6310 p.prefix.s_addr = 0;
6311 p.prefixlen = 0;
6313 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0);
6315 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6316 ospf_external_info_delete (DEFAULT_ROUTE, p);
6317 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6318 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6321 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6322 return ospf_redistribute_default_unset (ospf);
6325 DEFUN (ospf_default_metric,
6326 ospf_default_metric_cmd,
6327 "default-metric <0-16777214>",
6328 "Set metric of redistributed routes\n"
6329 "Default metric\n")
6331 struct ospf *ospf = vty->index;
6332 int metric = -1;
6334 if (!str2metric (argv[0], &metric))
6335 return CMD_WARNING;
6337 ospf->default_metric = metric;
6339 return CMD_SUCCESS;
6342 DEFUN (no_ospf_default_metric,
6343 no_ospf_default_metric_cmd,
6344 "no default-metric",
6345 NO_STR
6346 "Set metric of redistributed routes\n")
6348 struct ospf *ospf = vty->index;
6350 ospf->default_metric = -1;
6352 return CMD_SUCCESS;
6355 ALIAS (no_ospf_default_metric,
6356 no_ospf_default_metric_val_cmd,
6357 "no default-metric <0-16777214>",
6358 NO_STR
6359 "Set metric of redistributed routes\n"
6360 "Default metric\n")
6362 DEFUN (ospf_distance,
6363 ospf_distance_cmd,
6364 "distance <1-255>",
6365 "Define an administrative distance\n"
6366 "OSPF Administrative distance\n")
6368 struct ospf *ospf = vty->index;
6370 ospf->distance_all = atoi (argv[0]);
6372 return CMD_SUCCESS;
6375 DEFUN (no_ospf_distance,
6376 no_ospf_distance_cmd,
6377 "no distance <1-255>",
6378 NO_STR
6379 "Define an administrative distance\n"
6380 "OSPF Administrative distance\n")
6382 struct ospf *ospf = vty->index;
6384 ospf->distance_all = 0;
6386 return CMD_SUCCESS;
6389 DEFUN (no_ospf_distance_ospf,
6390 no_ospf_distance_ospf_cmd,
6391 "no distance ospf",
6392 NO_STR
6393 "Define an administrative distance\n"
6394 "OSPF Administrative distance\n"
6395 "OSPF Distance\n")
6397 struct ospf *ospf = vty->index;
6399 ospf->distance_intra = 0;
6400 ospf->distance_inter = 0;
6401 ospf->distance_external = 0;
6403 return CMD_SUCCESS;
6406 DEFUN (ospf_distance_ospf_intra,
6407 ospf_distance_ospf_intra_cmd,
6408 "distance ospf intra-area <1-255>",
6409 "Define an administrative distance\n"
6410 "OSPF Administrative distance\n"
6411 "Intra-area routes\n"
6412 "Distance for intra-area routes\n")
6414 struct ospf *ospf = vty->index;
6416 ospf->distance_intra = atoi (argv[0]);
6418 return CMD_SUCCESS;
6421 DEFUN (ospf_distance_ospf_intra_inter,
6422 ospf_distance_ospf_intra_inter_cmd,
6423 "distance ospf intra-area <1-255> inter-area <1-255>",
6424 "Define an administrative distance\n"
6425 "OSPF Administrative distance\n"
6426 "Intra-area routes\n"
6427 "Distance for intra-area routes\n"
6428 "Inter-area routes\n"
6429 "Distance for inter-area routes\n")
6431 struct ospf *ospf = vty->index;
6433 ospf->distance_intra = atoi (argv[0]);
6434 ospf->distance_inter = atoi (argv[1]);
6436 return CMD_SUCCESS;
6439 DEFUN (ospf_distance_ospf_intra_external,
6440 ospf_distance_ospf_intra_external_cmd,
6441 "distance ospf intra-area <1-255> external <1-255>",
6442 "Define an administrative distance\n"
6443 "OSPF Administrative distance\n"
6444 "Intra-area routes\n"
6445 "Distance for intra-area routes\n"
6446 "External routes\n"
6447 "Distance for external routes\n")
6449 struct ospf *ospf = vty->index;
6451 ospf->distance_intra = atoi (argv[0]);
6452 ospf->distance_external = atoi (argv[1]);
6454 return CMD_SUCCESS;
6457 DEFUN (ospf_distance_ospf_intra_inter_external,
6458 ospf_distance_ospf_intra_inter_external_cmd,
6459 "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>",
6460 "Define an administrative distance\n"
6461 "OSPF Administrative distance\n"
6462 "Intra-area routes\n"
6463 "Distance for intra-area routes\n"
6464 "Inter-area routes\n"
6465 "Distance for inter-area routes\n"
6466 "External routes\n"
6467 "Distance for external routes\n")
6469 struct ospf *ospf = vty->index;
6471 ospf->distance_intra = atoi (argv[0]);
6472 ospf->distance_inter = atoi (argv[1]);
6473 ospf->distance_external = atoi (argv[2]);
6475 return CMD_SUCCESS;
6478 DEFUN (ospf_distance_ospf_intra_external_inter,
6479 ospf_distance_ospf_intra_external_inter_cmd,
6480 "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>",
6481 "Define an administrative distance\n"
6482 "OSPF Administrative distance\n"
6483 "Intra-area routes\n"
6484 "Distance for intra-area routes\n"
6485 "External routes\n"
6486 "Distance for external routes\n"
6487 "Inter-area routes\n"
6488 "Distance for inter-area routes\n")
6490 struct ospf *ospf = vty->index;
6492 ospf->distance_intra = atoi (argv[0]);
6493 ospf->distance_external = atoi (argv[1]);
6494 ospf->distance_inter = atoi (argv[2]);
6496 return CMD_SUCCESS;
6499 DEFUN (ospf_distance_ospf_inter,
6500 ospf_distance_ospf_inter_cmd,
6501 "distance ospf inter-area <1-255>",
6502 "Define an administrative distance\n"
6503 "OSPF Administrative distance\n"
6504 "Inter-area routes\n"
6505 "Distance for inter-area routes\n")
6507 struct ospf *ospf = vty->index;
6509 ospf->distance_inter = atoi (argv[0]);
6511 return CMD_SUCCESS;
6514 DEFUN (ospf_distance_ospf_inter_intra,
6515 ospf_distance_ospf_inter_intra_cmd,
6516 "distance ospf inter-area <1-255> intra-area <1-255>",
6517 "Define an administrative distance\n"
6518 "OSPF Administrative distance\n"
6519 "Inter-area routes\n"
6520 "Distance for inter-area routes\n"
6521 "Intra-area routes\n"
6522 "Distance for intra-area routes\n")
6524 struct ospf *ospf = vty->index;
6526 ospf->distance_inter = atoi (argv[0]);
6527 ospf->distance_intra = atoi (argv[1]);
6529 return CMD_SUCCESS;
6532 DEFUN (ospf_distance_ospf_inter_external,
6533 ospf_distance_ospf_inter_external_cmd,
6534 "distance ospf inter-area <1-255> external <1-255>",
6535 "Define an administrative distance\n"
6536 "OSPF Administrative distance\n"
6537 "Inter-area routes\n"
6538 "Distance for inter-area routes\n"
6539 "External routes\n"
6540 "Distance for external routes\n")
6542 struct ospf *ospf = vty->index;
6544 ospf->distance_inter = atoi (argv[0]);
6545 ospf->distance_external = atoi (argv[1]);
6547 return CMD_SUCCESS;
6550 DEFUN (ospf_distance_ospf_inter_intra_external,
6551 ospf_distance_ospf_inter_intra_external_cmd,
6552 "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>",
6553 "Define an administrative distance\n"
6554 "OSPF Administrative distance\n"
6555 "Inter-area routes\n"
6556 "Distance for inter-area routes\n"
6557 "Intra-area routes\n"
6558 "Distance for intra-area routes\n"
6559 "External routes\n"
6560 "Distance for external routes\n")
6562 struct ospf *ospf = vty->index;
6564 ospf->distance_inter = atoi (argv[0]);
6565 ospf->distance_intra = atoi (argv[1]);
6566 ospf->distance_external = atoi (argv[2]);
6568 return CMD_SUCCESS;
6571 DEFUN (ospf_distance_ospf_inter_external_intra,
6572 ospf_distance_ospf_inter_external_intra_cmd,
6573 "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>",
6574 "Define an administrative distance\n"
6575 "OSPF Administrative distance\n"
6576 "Inter-area routes\n"
6577 "Distance for inter-area routes\n"
6578 "External routes\n"
6579 "Distance for external routes\n"
6580 "Intra-area routes\n"
6581 "Distance for intra-area routes\n")
6583 struct ospf *ospf = vty->index;
6585 ospf->distance_inter = atoi (argv[0]);
6586 ospf->distance_external = atoi (argv[1]);
6587 ospf->distance_intra = atoi (argv[2]);
6589 return CMD_SUCCESS;
6592 DEFUN (ospf_distance_ospf_external,
6593 ospf_distance_ospf_external_cmd,
6594 "distance ospf external <1-255>",
6595 "Define an administrative distance\n"
6596 "OSPF Administrative distance\n"
6597 "External routes\n"
6598 "Distance for external routes\n")
6600 struct ospf *ospf = vty->index;
6602 ospf->distance_external = atoi (argv[0]);
6604 return CMD_SUCCESS;
6607 DEFUN (ospf_distance_ospf_external_intra,
6608 ospf_distance_ospf_external_intra_cmd,
6609 "distance ospf external <1-255> intra-area <1-255>",
6610 "Define an administrative distance\n"
6611 "OSPF Administrative distance\n"
6612 "External routes\n"
6613 "Distance for external routes\n"
6614 "Intra-area routes\n"
6615 "Distance for intra-area routes\n")
6617 struct ospf *ospf = vty->index;
6619 ospf->distance_external = atoi (argv[0]);
6620 ospf->distance_intra = atoi (argv[1]);
6622 return CMD_SUCCESS;
6625 DEFUN (ospf_distance_ospf_external_inter,
6626 ospf_distance_ospf_external_inter_cmd,
6627 "distance ospf external <1-255> inter-area <1-255>",
6628 "Define an administrative distance\n"
6629 "OSPF Administrative distance\n"
6630 "External routes\n"
6631 "Distance for external routes\n"
6632 "Inter-area routes\n"
6633 "Distance for inter-area routes\n")
6635 struct ospf *ospf = vty->index;
6637 ospf->distance_external = atoi (argv[0]);
6638 ospf->distance_inter = atoi (argv[1]);
6640 return CMD_SUCCESS;
6643 DEFUN (ospf_distance_ospf_external_intra_inter,
6644 ospf_distance_ospf_external_intra_inter_cmd,
6645 "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>",
6646 "Define an administrative distance\n"
6647 "OSPF Administrative distance\n"
6648 "External routes\n"
6649 "Distance for external routes\n"
6650 "Intra-area routes\n"
6651 "Distance for intra-area routes\n"
6652 "Inter-area routes\n"
6653 "Distance for inter-area routes\n")
6655 struct ospf *ospf = vty->index;
6657 ospf->distance_external = atoi (argv[0]);
6658 ospf->distance_intra = atoi (argv[1]);
6659 ospf->distance_inter = atoi (argv[2]);
6661 return CMD_SUCCESS;
6664 DEFUN (ospf_distance_ospf_external_inter_intra,
6665 ospf_distance_ospf_external_inter_intra_cmd,
6666 "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>",
6667 "Define an administrative distance\n"
6668 "OSPF Administrative distance\n"
6669 "External routes\n"
6670 "Distance for external routes\n"
6671 "Inter-area routes\n"
6672 "Distance for inter-area routes\n"
6673 "Intra-area routes\n"
6674 "Distance for intra-area routes\n")
6676 struct ospf *ospf = vty->index;
6678 ospf->distance_external = atoi (argv[0]);
6679 ospf->distance_inter = atoi (argv[1]);
6680 ospf->distance_intra = atoi (argv[2]);
6682 return CMD_SUCCESS;
6685 DEFUN (ospf_distance_source,
6686 ospf_distance_source_cmd,
6687 "distance <1-255> A.B.C.D/M",
6688 "Administrative distance\n"
6689 "Distance value\n"
6690 "IP source prefix\n")
6692 struct ospf *ospf = vty->index;
6694 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
6696 return CMD_SUCCESS;
6699 DEFUN (no_ospf_distance_source,
6700 no_ospf_distance_source_cmd,
6701 "no distance <1-255> A.B.C.D/M",
6702 NO_STR
6703 "Administrative distance\n"
6704 "Distance value\n"
6705 "IP source prefix\n")
6707 struct ospf *ospf = vty->index;
6709 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6711 return CMD_SUCCESS;
6714 DEFUN (ospf_distance_source_access_list,
6715 ospf_distance_source_access_list_cmd,
6716 "distance <1-255> A.B.C.D/M WORD",
6717 "Administrative distance\n"
6718 "Distance value\n"
6719 "IP source prefix\n"
6720 "Access list name\n")
6722 struct ospf *ospf = vty->index;
6724 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6726 return CMD_SUCCESS;
6729 DEFUN (no_ospf_distance_source_access_list,
6730 no_ospf_distance_source_access_list_cmd,
6731 "no distance <1-255> A.B.C.D/M WORD",
6732 NO_STR
6733 "Administrative distance\n"
6734 "Distance value\n"
6735 "IP source prefix\n"
6736 "Access list name\n")
6738 struct ospf *ospf = vty->index;
6740 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6742 return CMD_SUCCESS;
6745 DEFUN (ip_ospf_mtu_ignore,
6746 ip_ospf_mtu_ignore_addr_cmd,
6747 "ip ospf mtu-ignore A.B.C.D",
6748 "IP Information\n"
6749 "OSPF interface commands\n"
6750 "Disable mtu mismatch detection\n"
6751 "Address of interface")
6753 struct interface *ifp = vty->index;
6754 struct in_addr addr;
6755 int ret;
6757 struct ospf_if_params *params;
6758 params = IF_DEF_PARAMS (ifp);
6760 if (argc == 1)
6762 ret = inet_aton(argv[0], &addr);
6763 if (!ret)
6765 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6766 VTY_NEWLINE);
6767 return CMD_WARNING;
6769 params = ospf_get_if_params (ifp, addr);
6770 ospf_if_update_params (ifp, addr);
6772 params->mtu_ignore = 1;
6773 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6774 SET_IF_PARAM (params, mtu_ignore);
6775 else
6777 UNSET_IF_PARAM (params, mtu_ignore);
6778 if (params != IF_DEF_PARAMS (ifp))
6780 ospf_free_if_params (ifp, addr);
6781 ospf_if_update_params (ifp, addr);
6784 return CMD_SUCCESS;
6787 ALIAS (ip_ospf_mtu_ignore,
6788 ip_ospf_mtu_ignore_cmd,
6789 "ip ospf mtu-ignore",
6790 "IP Information\n"
6791 "OSPF interface commands\n"
6792 "Disable mtu mismatch detection\n")
6795 DEFUN (no_ip_ospf_mtu_ignore,
6796 no_ip_ospf_mtu_ignore_addr_cmd,
6797 "no ip ospf mtu-ignore A.B.C.D",
6798 "IP Information\n"
6799 "OSPF interface commands\n"
6800 "Disable mtu mismatch detection\n"
6801 "Address of interface")
6803 struct interface *ifp = vty->index;
6804 struct in_addr addr;
6805 int ret;
6807 struct ospf_if_params *params;
6808 params = IF_DEF_PARAMS (ifp);
6810 if (argc == 1)
6812 ret = inet_aton(argv[0], &addr);
6813 if (!ret)
6815 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6816 VTY_NEWLINE);
6817 return CMD_WARNING;
6819 params = ospf_get_if_params (ifp, addr);
6820 ospf_if_update_params (ifp, addr);
6822 params->mtu_ignore = 0;
6823 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6824 SET_IF_PARAM (params, mtu_ignore);
6825 else
6827 UNSET_IF_PARAM (params, mtu_ignore);
6828 if (params != IF_DEF_PARAMS (ifp))
6830 ospf_free_if_params (ifp, addr);
6831 ospf_if_update_params (ifp, addr);
6834 return CMD_SUCCESS;
6837 ALIAS (no_ip_ospf_mtu_ignore,
6838 no_ip_ospf_mtu_ignore_cmd,
6839 "no ip ospf mtu-ignore",
6840 "IP Information\n"
6841 "OSPF interface commands\n"
6842 "Disable mtu mismatch detection\n")
6844 DEFUN (ospf_max_metric_router_lsa_admin,
6845 ospf_max_metric_router_lsa_admin_cmd,
6846 "max-metric router-lsa administrative",
6847 "OSPF maximum / infinite-distance metric\n"
6848 "Advertise own Router-LSA with infinite distance (stub router)\n"
6849 "Administratively applied, for an indefinite period\n")
6851 struct listnode *ln;
6852 struct ospf_area *area;
6853 struct ospf *ospf = vty->index;
6855 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6857 SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
6859 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
6860 ospf_router_lsa_timer_add (area);
6862 return CMD_SUCCESS;
6865 DEFUN (no_ospf_max_metric_router_lsa_admin,
6866 no_ospf_max_metric_router_lsa_admin_cmd,
6867 "no max-metric router-lsa administrative",
6868 NO_STR
6869 "OSPF maximum / infinite-distance metric\n"
6870 "Advertise own Router-LSA with infinite distance (stub router)\n"
6871 "Administratively applied, for an indefinite period\n")
6873 struct listnode *ln;
6874 struct ospf_area *area;
6875 struct ospf *ospf = vty->index;
6877 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6879 UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
6881 /* Don't trample on the start-up stub timer */
6882 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)
6883 && !area->t_stub_router)
6885 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
6886 ospf_router_lsa_timer_add (area);
6889 return CMD_SUCCESS;
6892 DEFUN (ospf_max_metric_router_lsa_startup,
6893 ospf_max_metric_router_lsa_startup_cmd,
6894 "max-metric router-lsa on-startup <5-86400>",
6895 "OSPF maximum / infinite-distance metric\n"
6896 "Advertise own Router-LSA with infinite distance (stub router)\n"
6897 "Automatically advertise stub Router-LSA on startup of OSPF\n"
6898 "Time (seconds) to advertise self as stub-router\n")
6900 unsigned int seconds;
6901 struct ospf *ospf = vty->index;
6903 if (argc != 1)
6905 vty_out (vty, "%% Must supply stub-router period");
6906 return CMD_WARNING;
6909 VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]);
6911 ospf->stub_router_startup_time = seconds;
6913 return CMD_SUCCESS;
6916 DEFUN (no_ospf_max_metric_router_lsa_startup,
6917 no_ospf_max_metric_router_lsa_startup_cmd,
6918 "no max-metric router-lsa on-startup",
6919 NO_STR
6920 "OSPF maximum / infinite-distance metric\n"
6921 "Advertise own Router-LSA with infinite distance (stub router)\n"
6922 "Automatically advertise stub Router-LSA on startup of OSPF\n")
6924 struct listnode *ln;
6925 struct ospf_area *area;
6926 struct ospf *ospf = vty->index;
6928 ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED;
6930 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6932 SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED);
6933 OSPF_TIMER_OFF (area->t_stub_router);
6935 /* Don't trample on admin stub routed */
6936 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
6938 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
6939 ospf_router_lsa_timer_add (area);
6942 return CMD_SUCCESS;
6945 DEFUN (ospf_max_metric_router_lsa_shutdown,
6946 ospf_max_metric_router_lsa_shutdown_cmd,
6947 "max-metric router-lsa on-shutdown <5-86400>",
6948 "OSPF maximum / infinite-distance metric\n"
6949 "Advertise own Router-LSA with infinite distance (stub router)\n"
6950 "Advertise stub-router prior to full shutdown of OSPF\n"
6951 "Time (seconds) to wait till full shutdown\n")
6953 unsigned int seconds;
6954 struct ospf *ospf = vty->index;
6956 if (argc != 1)
6958 vty_out (vty, "%% Must supply stub-router shutdown period");
6959 return CMD_WARNING;
6962 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]);
6964 ospf->stub_router_shutdown_time = seconds;
6966 return CMD_SUCCESS;
6969 DEFUN (no_ospf_max_metric_router_lsa_shutdown,
6970 no_ospf_max_metric_router_lsa_shutdown_cmd,
6971 "no max-metric router-lsa on-shutdown",
6972 NO_STR
6973 "OSPF maximum / infinite-distance metric\n"
6974 "Advertise own Router-LSA with infinite distance (stub router)\n"
6975 "Advertise stub-router prior to full shutdown of OSPF\n")
6977 struct ospf *ospf = vty->index;
6979 ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;
6981 return CMD_SUCCESS;
6984 static void
6985 config_write_stub_router (struct vty *vty, struct ospf *ospf)
6987 struct listnode *ln;
6988 struct ospf_area *area;
6990 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
6991 vty_out (vty, " max-metric router-lsa on-startup %u%s",
6992 ospf->stub_router_startup_time, VTY_NEWLINE);
6993 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
6994 vty_out (vty, " max-metric router-lsa on-shutdown %u%s",
6995 ospf->stub_router_shutdown_time, VTY_NEWLINE);
6996 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6998 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
7000 vty_out (vty, " max-metric router-lsa administrative%s",
7001 VTY_NEWLINE);
7002 break;
7005 return;
7008 static void
7009 show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
7011 struct route_node *rn;
7012 struct ospf_route *or;
7013 struct listnode *pnode, *pnnode;
7014 struct ospf_path *path;
7016 vty_out (vty, "============ OSPF network routing table ============%s",
7017 VTY_NEWLINE);
7019 for (rn = route_top (rt); rn; rn = route_next (rn))
7020 if ((or = rn->info) != NULL)
7022 char buf1[19];
7023 snprintf (buf1, 19, "%s/%d",
7024 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
7026 switch (or->path_type)
7028 case OSPF_PATH_INTER_AREA:
7029 if (or->type == OSPF_DESTINATION_NETWORK)
7030 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
7031 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
7032 else if (or->type == OSPF_DESTINATION_DISCARD)
7033 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
7034 break;
7035 case OSPF_PATH_INTRA_AREA:
7036 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
7037 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
7038 break;
7039 default:
7040 break;
7043 if (or->type == OSPF_DESTINATION_NETWORK)
7044 for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
7046 if (path->oi != NULL && ospf_if_exists(path->oi))
7048 if (path->nexthop.s_addr == 0)
7049 vty_out (vty, "%24s directly attached to %s%s",
7050 "", path->oi->ifp->name, VTY_NEWLINE);
7051 else
7052 vty_out (vty, "%24s via %s, %s%s", "",
7053 inet_ntoa (path->nexthop), path->oi->ifp->name,
7054 VTY_NEWLINE);
7058 vty_out (vty, "%s", VTY_NEWLINE);
7061 static void
7062 show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
7064 struct route_node *rn;
7065 struct ospf_route *or;
7066 struct listnode *pnode;
7067 struct listnode *node;
7068 struct ospf_path *path;
7070 vty_out (vty, "============ OSPF router routing table =============%s",
7071 VTY_NEWLINE);
7072 for (rn = route_top (rtrs); rn; rn = route_next (rn))
7073 if (rn->info)
7075 int flag = 0;
7077 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
7079 for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or))
7081 if (flag++)
7082 vty_out (vty, "%24s", "");
7084 /* Show path. */
7085 vty_out (vty, "%s [%d] area: %s",
7086 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
7087 or->cost, inet_ntoa (or->u.std.area_id));
7088 /* Show flags. */
7089 vty_out (vty, "%s%s%s",
7090 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
7091 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
7092 VTY_NEWLINE);
7094 for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
7096 if (path->oi != NULL && ospf_if_exists(path->oi))
7098 if (path->nexthop.s_addr == 0)
7099 vty_out (vty, "%24s directly attached to %s%s",
7100 "", path->oi->ifp->name, VTY_NEWLINE);
7101 else
7102 vty_out (vty, "%24s via %s, %s%s", "",
7103 inet_ntoa (path->nexthop),
7104 path->oi->ifp->name, VTY_NEWLINE);
7109 vty_out (vty, "%s", VTY_NEWLINE);
7112 static void
7113 show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
7115 struct route_node *rn;
7116 struct ospf_route *er;
7117 struct listnode *pnode, *pnnode;
7118 struct ospf_path *path;
7120 vty_out (vty, "============ OSPF external routing table ===========%s",
7121 VTY_NEWLINE);
7122 for (rn = route_top (rt); rn; rn = route_next (rn))
7123 if ((er = rn->info) != NULL)
7125 char buf1[19];
7126 snprintf (buf1, 19, "%s/%d",
7127 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
7129 switch (er->path_type)
7131 case OSPF_PATH_TYPE1_EXTERNAL:
7132 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
7133 er->cost, er->u.ext.tag, VTY_NEWLINE);
7134 break;
7135 case OSPF_PATH_TYPE2_EXTERNAL:
7136 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
7137 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
7138 break;
7141 for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
7143 if (path->oi != NULL && ospf_if_exists(path->oi))
7145 if (path->nexthop.s_addr == 0)
7146 vty_out (vty, "%24s directly attached to %s%s",
7147 "", path->oi->ifp->name, VTY_NEWLINE);
7148 else
7149 vty_out (vty, "%24s via %s, %s%s", "",
7150 inet_ntoa (path->nexthop), path->oi->ifp->name,
7151 VTY_NEWLINE);
7155 vty_out (vty, "%s", VTY_NEWLINE);
7158 DEFUN (show_ip_ospf_border_routers,
7159 show_ip_ospf_border_routers_cmd,
7160 "show ip ospf border-routers",
7161 SHOW_STR
7162 IP_STR
7163 "show all the ABR's and ASBR's\n"
7164 "for this area\n")
7166 struct ospf *ospf;
7168 if ((ospf = ospf_lookup ()) == NULL)
7170 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
7171 return CMD_SUCCESS;
7174 if (ospf->new_table == NULL)
7176 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7177 return CMD_SUCCESS;
7180 /* Show Network routes.
7181 show_ip_ospf_route_network (vty, ospf->new_table); */
7183 /* Show Router routes. */
7184 show_ip_ospf_route_router (vty, ospf->new_rtrs);
7186 return CMD_SUCCESS;
7189 DEFUN (show_ip_ospf_route,
7190 show_ip_ospf_route_cmd,
7191 "show ip ospf route",
7192 SHOW_STR
7193 IP_STR
7194 "OSPF information\n"
7195 "OSPF routing table\n")
7197 struct ospf *ospf;
7199 if ((ospf = ospf_lookup ()) == NULL)
7201 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
7202 return CMD_SUCCESS;
7205 if (ospf->new_table == NULL)
7207 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7208 return CMD_SUCCESS;
7211 /* Show Network routes. */
7212 show_ip_ospf_route_network (vty, ospf->new_table);
7214 /* Show Router routes. */
7215 show_ip_ospf_route_router (vty, ospf->new_rtrs);
7217 /* Show AS External routes. */
7218 show_ip_ospf_route_external (vty, ospf->old_external_route);
7220 return CMD_SUCCESS;
7224 const char *ospf_abr_type_str[] =
7226 "unknown",
7227 "standard",
7228 "ibm",
7229 "cisco",
7230 "shortcut"
7233 const char *ospf_shortcut_mode_str[] =
7235 "default",
7236 "enable",
7237 "disable"
7241 static void
7242 area_id2str (char *buf, int length, struct ospf_area *area)
7244 memset (buf, 0, length);
7246 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
7247 strncpy (buf, inet_ntoa (area->area_id), length);
7248 else
7249 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
7253 const char *ospf_int_type_str[] =
7255 "unknown", /* should never be used. */
7256 "point-to-point",
7257 "broadcast",
7258 "non-broadcast",
7259 "point-to-multipoint",
7260 "virtual-link", /* should never be used. */
7261 "loopback"
7264 /* Configuration write function for ospfd. */
7265 static int
7266 config_write_interface (struct vty *vty)
7268 struct listnode *n1, *n2;
7269 struct interface *ifp;
7270 struct crypt_key *ck;
7271 int write = 0;
7272 struct route_node *rn = NULL;
7273 struct ospf_if_params *params;
7275 for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp))
7277 if (memcmp (ifp->name, "VLINK", 5) == 0)
7278 continue;
7280 vty_out (vty, "!%s", VTY_NEWLINE);
7281 vty_out (vty, "interface %s%s", ifp->name,
7282 VTY_NEWLINE);
7283 if (ifp->desc)
7284 vty_out (vty, " description %s%s", ifp->desc,
7285 VTY_NEWLINE);
7287 write++;
7289 params = IF_DEF_PARAMS (ifp);
7291 do {
7292 /* Interface Network print. */
7293 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
7294 params->type != OSPF_IFTYPE_LOOPBACK)
7296 if (params->type != ospf_default_iftype(ifp))
7298 vty_out (vty, " ip ospf network %s",
7299 ospf_int_type_str[params->type]);
7300 if (params != IF_DEF_PARAMS (ifp))
7301 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7302 vty_out (vty, "%s", VTY_NEWLINE);
7306 /* OSPF interface authentication print */
7307 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
7308 params->auth_type != OSPF_AUTH_NOTSET)
7310 const char *auth_str;
7312 /* Translation tables are not that much help here due to syntax
7313 of the simple option */
7314 switch (params->auth_type)
7317 case OSPF_AUTH_NULL:
7318 auth_str = " null";
7319 break;
7321 case OSPF_AUTH_SIMPLE:
7322 auth_str = "";
7323 break;
7325 case OSPF_AUTH_CRYPTOGRAPHIC:
7326 auth_str = " message-digest";
7327 break;
7329 default:
7330 auth_str = "";
7331 break;
7334 vty_out (vty, " ip ospf authentication%s", auth_str);
7335 if (params != IF_DEF_PARAMS (ifp))
7336 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7337 vty_out (vty, "%s", VTY_NEWLINE);
7340 /* Simple Authentication Password print. */
7341 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
7342 params->auth_simple[0] != '\0')
7344 vty_out (vty, " ip ospf authentication-key %s",
7345 params->auth_simple);
7346 if (params != IF_DEF_PARAMS (ifp))
7347 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7348 vty_out (vty, "%s", VTY_NEWLINE);
7351 /* Cryptographic Authentication Key print. */
7352 for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck))
7354 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
7355 ck->key_id, ck->auth_key);
7356 if (params != IF_DEF_PARAMS (ifp))
7357 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7358 vty_out (vty, "%s", VTY_NEWLINE);
7361 /* Interface Output Cost print. */
7362 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
7364 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
7365 if (params != IF_DEF_PARAMS (ifp))
7366 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7367 vty_out (vty, "%s", VTY_NEWLINE);
7370 /* Hello Interval print. */
7371 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
7372 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
7374 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
7375 if (params != IF_DEF_PARAMS (ifp))
7376 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7377 vty_out (vty, "%s", VTY_NEWLINE);
7381 /* Router Dead Interval print. */
7382 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
7383 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
7385 vty_out (vty, " ip ospf dead-interval ");
7387 /* fast hello ? */
7388 if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello))
7389 vty_out (vty, "minimal hello-multiplier %d",
7390 params->fast_hello);
7391 else
7392 vty_out (vty, "%u", params->v_wait);
7394 if (params != IF_DEF_PARAMS (ifp))
7395 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7396 vty_out (vty, "%s", VTY_NEWLINE);
7399 /* Router Priority print. */
7400 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
7401 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
7403 vty_out (vty, " ip ospf priority %u", params->priority);
7404 if (params != IF_DEF_PARAMS (ifp))
7405 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7406 vty_out (vty, "%s", VTY_NEWLINE);
7409 /* Retransmit Interval print. */
7410 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
7411 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
7413 vty_out (vty, " ip ospf retransmit-interval %u",
7414 params->retransmit_interval);
7415 if (params != IF_DEF_PARAMS (ifp))
7416 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7417 vty_out (vty, "%s", VTY_NEWLINE);
7420 /* Transmit Delay print. */
7421 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
7422 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
7424 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
7425 if (params != IF_DEF_PARAMS (ifp))
7426 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7427 vty_out (vty, "%s", VTY_NEWLINE);
7430 /* MTU ignore print. */
7431 if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) &&
7432 params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
7434 if (params->mtu_ignore == 0)
7435 vty_out (vty, " no ip ospf mtu-ignore");
7436 else
7437 vty_out (vty, " ip ospf mtu-ignore");
7438 if (params != IF_DEF_PARAMS (ifp))
7439 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7440 vty_out (vty, "%s", VTY_NEWLINE);
7444 while (1)
7446 if (rn == NULL)
7447 rn = route_top (IF_OIFS_PARAMS (ifp));
7448 else
7449 rn = route_next (rn);
7451 if (rn == NULL)
7452 break;
7453 params = rn->info;
7454 if (params != NULL)
7455 break;
7457 } while (rn);
7459 #ifdef HAVE_OPAQUE_LSA
7460 ospf_opaque_config_write_if (vty, ifp);
7461 #endif /* HAVE_OPAQUE_LSA */
7464 return write;
7467 static int
7468 config_write_network_area (struct vty *vty, struct ospf *ospf)
7470 struct route_node *rn;
7471 u_char buf[INET_ADDRSTRLEN];
7473 /* `network area' print. */
7474 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
7475 if (rn->info)
7477 struct ospf_network *n = rn->info;
7479 memset (buf, 0, INET_ADDRSTRLEN);
7481 /* Create Area ID string by specified Area ID format. */
7482 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
7483 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
7484 else
7485 sprintf ((char *) buf, "%lu",
7486 (unsigned long int) ntohl (n->area_id.s_addr));
7488 /* Network print. */
7489 vty_out (vty, " network %s/%d area %s%s",
7490 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7491 buf, VTY_NEWLINE);
7494 return 0;
7497 static int
7498 config_write_ospf_area (struct vty *vty, struct ospf *ospf)
7500 struct listnode *node;
7501 struct ospf_area *area;
7502 u_char buf[INET_ADDRSTRLEN];
7504 /* Area configuration print. */
7505 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
7507 struct route_node *rn1;
7509 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
7511 if (area->auth_type != OSPF_AUTH_NULL)
7513 if (area->auth_type == OSPF_AUTH_SIMPLE)
7514 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
7515 else
7516 vty_out (vty, " area %s authentication message-digest%s",
7517 buf, VTY_NEWLINE);
7520 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
7521 vty_out (vty, " area %s shortcut %s%s", buf,
7522 ospf_shortcut_mode_str[area->shortcut_configured],
7523 VTY_NEWLINE);
7525 if ((area->external_routing == OSPF_AREA_STUB)
7526 || (area->external_routing == OSPF_AREA_NSSA)
7529 if (area->external_routing == OSPF_AREA_STUB)
7530 vty_out (vty, " area %s stub", buf);
7531 else if (area->external_routing == OSPF_AREA_NSSA)
7533 vty_out (vty, " area %s nssa", buf);
7534 switch (area->NSSATranslatorRole)
7536 case OSPF_NSSA_ROLE_NEVER:
7537 vty_out (vty, " translate-never");
7538 break;
7539 case OSPF_NSSA_ROLE_ALWAYS:
7540 vty_out (vty, " translate-always");
7541 break;
7542 case OSPF_NSSA_ROLE_CANDIDATE:
7543 default:
7544 vty_out (vty, " translate-candidate");
7548 if (area->no_summary)
7549 vty_out (vty, " no-summary");
7551 vty_out (vty, "%s", VTY_NEWLINE);
7553 if (area->default_cost != 1)
7554 vty_out (vty, " area %s default-cost %d%s", buf,
7555 area->default_cost, VTY_NEWLINE);
7558 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
7559 if (rn1->info)
7561 struct ospf_area_range *range = rn1->info;
7563 vty_out (vty, " area %s range %s/%d", buf,
7564 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
7566 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
7567 vty_out (vty, " cost %d", range->cost_config);
7569 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
7570 vty_out (vty, " not-advertise");
7572 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
7573 vty_out (vty, " substitute %s/%d",
7574 inet_ntoa (range->subst_addr), range->subst_masklen);
7576 vty_out (vty, "%s", VTY_NEWLINE);
7579 if (EXPORT_NAME (area))
7580 vty_out (vty, " area %s export-list %s%s", buf,
7581 EXPORT_NAME (area), VTY_NEWLINE);
7583 if (IMPORT_NAME (area))
7584 vty_out (vty, " area %s import-list %s%s", buf,
7585 IMPORT_NAME (area), VTY_NEWLINE);
7587 if (PREFIX_NAME_IN (area))
7588 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
7589 PREFIX_NAME_IN (area), VTY_NEWLINE);
7591 if (PREFIX_NAME_OUT (area))
7592 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7593 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7596 return 0;
7599 static int
7600 config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
7602 struct ospf_nbr_nbma *nbr_nbma;
7603 struct route_node *rn;
7605 /* Static Neighbor configuration print. */
7606 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
7607 if ((nbr_nbma = rn->info))
7609 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7611 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7612 vty_out (vty, " priority %d", nbr_nbma->priority);
7614 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7615 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7617 vty_out (vty, "%s", VTY_NEWLINE);
7620 return 0;
7623 static int
7624 config_write_virtual_link (struct vty *vty, struct ospf *ospf)
7626 struct listnode *node;
7627 struct ospf_vl_data *vl_data;
7628 u_char buf[INET_ADDRSTRLEN];
7630 /* Virtual-Link print */
7631 for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
7633 struct listnode *n2;
7634 struct crypt_key *ck;
7635 struct ospf_interface *oi;
7637 if (vl_data != NULL)
7639 memset (buf, 0, INET_ADDRSTRLEN);
7641 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
7642 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
7643 else
7644 sprintf ((char *) buf, "%lu",
7645 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7646 oi = vl_data->vl_oi;
7648 /* timers */
7649 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7650 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7651 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7652 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7653 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7654 buf,
7655 inet_ntoa (vl_data->vl_peer),
7656 OSPF_IF_PARAM (oi, v_hello),
7657 OSPF_IF_PARAM (oi, retransmit_interval),
7658 OSPF_IF_PARAM (oi, transmit_delay),
7659 OSPF_IF_PARAM (oi, v_wait),
7660 VTY_NEWLINE);
7661 else
7662 vty_out (vty, " area %s virtual-link %s%s", buf,
7663 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7664 /* Auth key */
7665 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7666 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7667 buf,
7668 inet_ntoa (vl_data->vl_peer),
7669 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7670 VTY_NEWLINE);
7671 /* md5 keys */
7672 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt,
7673 n2, ck))
7674 vty_out (vty, " area %s virtual-link %s"
7675 " message-digest-key %d md5 %s%s",
7676 buf,
7677 inet_ntoa (vl_data->vl_peer),
7678 ck->key_id, ck->auth_key, VTY_NEWLINE);
7683 return 0;
7687 static int
7688 config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
7690 int type;
7692 /* redistribute print. */
7693 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7694 if (type != zclient->redist_default && zclient->redist[type])
7696 vty_out (vty, " redistribute %s", zebra_route_string(type));
7697 if (ospf->dmetric[type].value >= 0)
7698 vty_out (vty, " metric %d", ospf->dmetric[type].value);
7700 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
7701 vty_out (vty, " metric-type 1");
7703 if (ROUTEMAP_NAME (ospf, type))
7704 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
7706 vty_out (vty, "%s", VTY_NEWLINE);
7709 return 0;
7712 static int
7713 config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
7715 if (ospf->default_metric != -1)
7716 vty_out (vty, " default-metric %d%s", ospf->default_metric,
7717 VTY_NEWLINE);
7718 return 0;
7721 static int
7722 config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
7724 int type;
7726 if (ospf)
7728 /* distribute-list print. */
7729 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7730 if (ospf->dlist[type].name)
7731 vty_out (vty, " distribute-list %s out %s%s",
7732 ospf->dlist[type].name,
7733 zebra_route_string(type), VTY_NEWLINE);
7735 /* default-information print. */
7736 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
7738 vty_out (vty, " default-information originate");
7739 if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS)
7740 vty_out (vty, " always");
7742 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
7743 vty_out (vty, " metric %d",
7744 ospf->dmetric[DEFAULT_ROUTE].value);
7745 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
7746 vty_out (vty, " metric-type 1");
7748 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7749 vty_out (vty, " route-map %s",
7750 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
7752 vty_out (vty, "%s", VTY_NEWLINE);
7757 return 0;
7760 static int
7761 config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
7763 struct route_node *rn;
7764 struct ospf_distance *odistance;
7766 if (ospf->distance_all)
7767 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
7769 if (ospf->distance_intra
7770 || ospf->distance_inter
7771 || ospf->distance_external)
7773 vty_out (vty, " distance ospf");
7775 if (ospf->distance_intra)
7776 vty_out (vty, " intra-area %d", ospf->distance_intra);
7777 if (ospf->distance_inter)
7778 vty_out (vty, " inter-area %d", ospf->distance_inter);
7779 if (ospf->distance_external)
7780 vty_out (vty, " external %d", ospf->distance_external);
7782 vty_out (vty, "%s", VTY_NEWLINE);
7785 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
7786 if ((odistance = rn->info) != NULL)
7788 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7789 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7790 odistance->access_list ? odistance->access_list : "",
7791 VTY_NEWLINE);
7793 return 0;
7796 /* OSPF configuration write function. */
7797 static int
7798 ospf_config_write (struct vty *vty)
7800 struct ospf *ospf;
7801 struct interface *ifp;
7802 struct ospf_interface *oi;
7803 struct listnode *node;
7804 int write = 0;
7806 ospf = ospf_lookup ();
7807 if (ospf != NULL)
7809 /* `router ospf' print. */
7810 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7812 write++;
7814 if (!ospf->networks)
7815 return write;
7817 /* Router ID print. */
7818 if (ospf->router_id_static.s_addr != 0)
7819 vty_out (vty, " ospf router-id %s%s",
7820 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
7822 /* ABR type print. */
7823 if (ospf->abr_type != OSPF_ABR_DEFAULT)
7824 vty_out (vty, " ospf abr-type %s%s",
7825 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
7827 /* log-adjacency-changes flag print. */
7828 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
7830 vty_out(vty, " log-adjacency-changes");
7831 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
7832 vty_out(vty, " detail");
7833 vty_out(vty, "%s", VTY_NEWLINE);
7836 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
7837 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
7838 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
7840 /* auto-cost reference-bandwidth configuration. */
7841 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
7843 vty_out (vty, "! Important: ensure reference bandwidth "
7844 "is consistent across all routers%s", VTY_NEWLINE);
7845 vty_out (vty, " auto-cost reference-bandwidth %d%s",
7846 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
7849 /* SPF timers print. */
7850 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
7851 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT ||
7852 ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT)
7853 vty_out (vty, " timers throttle spf %d %d %d%s",
7854 ospf->spf_delay, ospf->spf_holdtime,
7855 ospf->spf_max_holdtime, VTY_NEWLINE);
7857 /* Max-metric router-lsa print */
7858 config_write_stub_router (vty, ospf);
7860 /* SPF refresh parameters print. */
7861 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
7862 vty_out (vty, " refresh timer %d%s",
7863 ospf->lsa_refresh_interval, VTY_NEWLINE);
7865 /* Redistribute information print. */
7866 config_write_ospf_redistribute (vty, ospf);
7868 /* passive-interface print. */
7869 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
7870 if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE)
7871 vty_out (vty, " passive-interface %s%s",
7872 ifp->name, VTY_NEWLINE);
7874 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
7875 if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) &&
7876 oi->params->passive_interface == OSPF_IF_PASSIVE)
7877 vty_out (vty, " passive-interface %s %s%s",
7878 oi->ifp->name,
7879 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
7881 /* Network area print. */
7882 config_write_network_area (vty, ospf);
7884 /* Area config print. */
7885 config_write_ospf_area (vty, ospf);
7887 /* static neighbor print. */
7888 config_write_ospf_nbr_nbma (vty, ospf);
7890 /* Virtual-Link print. */
7891 config_write_virtual_link (vty, ospf);
7893 /* Default metric configuration. */
7894 config_write_ospf_default_metric (vty, ospf);
7896 /* Distribute-list and default-information print. */
7897 config_write_ospf_distribute (vty, ospf);
7899 /* Distance configuration. */
7900 config_write_ospf_distance (vty, ospf);
7902 #ifdef HAVE_OPAQUE_LSA
7903 ospf_opaque_config_write_router (vty, ospf);
7904 #endif /* HAVE_OPAQUE_LSA */
7907 return write;
7910 void
7911 ospf_vty_show_init (void)
7913 /* "show ip ospf" commands. */
7914 install_element (VIEW_NODE, &show_ip_ospf_cmd);
7915 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
7917 /* "show ip ospf database" commands. */
7918 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
7919 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
7920 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7921 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7922 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
7923 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
7924 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
7925 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
7926 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
7927 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7928 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7929 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
7930 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
7931 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
7933 /* "show ip ospf interface" commands. */
7934 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
7935 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
7937 /* "show ip ospf neighbor" commands. */
7938 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7939 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
7940 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
7941 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7942 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
7943 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
7944 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
7945 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7946 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
7947 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
7948 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7949 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
7950 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
7951 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
7953 /* "show ip ospf route" commands. */
7954 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
7955 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
7956 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
7957 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
7961 /* ospfd's interface node. */
7962 struct cmd_node interface_node =
7964 INTERFACE_NODE,
7965 "%s(config-if)# ",
7969 /* Initialization of OSPF interface. */
7970 static void
7971 ospf_vty_if_init (void)
7973 /* Install interface node. */
7974 install_node (&interface_node, config_write_interface);
7976 install_element (CONFIG_NODE, &interface_cmd);
7977 install_element (CONFIG_NODE, &no_interface_cmd);
7978 install_default (INTERFACE_NODE);
7980 /* "description" commands. */
7981 install_element (INTERFACE_NODE, &interface_desc_cmd);
7982 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
7984 /* "ip ospf authentication" commands. */
7985 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
7986 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
7987 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
7988 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
7989 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
7990 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
7991 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
7992 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
7993 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
7994 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
7996 /* "ip ospf message-digest-key" commands. */
7997 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
7998 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
7999 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
8000 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
8002 /* "ip ospf cost" commands. */
8003 install_element (INTERFACE_NODE, &ip_ospf_cost_addr_cmd);
8004 install_element (INTERFACE_NODE, &ip_ospf_cost_cmd);
8005 install_element (INTERFACE_NODE, &no_ip_ospf_cost_addr_cmd);
8006 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
8008 /* "ip ospf mtu-ignore" commands. */
8009 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd);
8010 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd);
8011 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd);
8012 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd);
8014 /* "ip ospf dead-interval" commands. */
8015 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
8016 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
8017 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd);
8018 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd);
8019 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
8020 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
8022 /* "ip ospf hello-interval" commands. */
8023 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
8024 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
8025 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
8026 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
8028 /* "ip ospf network" commands. */
8029 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
8030 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
8032 /* "ip ospf priority" commands. */
8033 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
8034 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
8035 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
8036 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
8038 /* "ip ospf retransmit-interval" commands. */
8039 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
8040 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
8041 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
8042 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
8044 /* "ip ospf transmit-delay" commands. */
8045 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
8046 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
8047 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
8048 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
8050 /* These commands are compatibitliy for previous version. */
8051 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
8052 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
8053 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
8054 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
8055 install_element (INTERFACE_NODE, &ospf_cost_cmd);
8056 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
8057 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
8058 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
8059 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
8060 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
8061 install_element (INTERFACE_NODE, &ospf_network_cmd);
8062 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
8063 install_element (INTERFACE_NODE, &ospf_priority_cmd);
8064 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
8065 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
8066 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
8067 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
8068 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
8071 /* Zebra node structure. */
8072 struct cmd_node zebra_node =
8074 ZEBRA_NODE,
8075 "%s(config-router)#",
8078 static void
8079 ospf_vty_zebra_init (void)
8081 install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd);
8082 install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd);
8083 install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd);
8084 install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd);
8085 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
8086 install_element (OSPF_NODE,
8087 &ospf_redistribute_source_metric_type_routemap_cmd);
8088 install_element (OSPF_NODE,
8089 &ospf_redistribute_source_type_metric_routemap_cmd);
8090 install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd);
8091 install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd);
8092 install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd);
8094 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
8096 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
8097 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
8099 install_element (OSPF_NODE,
8100 &ospf_default_information_originate_metric_type_cmd);
8101 install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd);
8102 install_element (OSPF_NODE,
8103 &ospf_default_information_originate_type_metric_cmd);
8104 install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd);
8105 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
8106 install_element (OSPF_NODE,
8107 &ospf_default_information_originate_always_metric_type_cmd);
8108 install_element (OSPF_NODE,
8109 &ospf_default_information_originate_always_metric_cmd);
8110 install_element (OSPF_NODE,
8111 &ospf_default_information_originate_always_cmd);
8112 install_element (OSPF_NODE,
8113 &ospf_default_information_originate_always_type_metric_cmd);
8114 install_element (OSPF_NODE,
8115 &ospf_default_information_originate_always_type_cmd);
8117 install_element (OSPF_NODE,
8118 &ospf_default_information_originate_metric_type_routemap_cmd);
8119 install_element (OSPF_NODE,
8120 &ospf_default_information_originate_metric_routemap_cmd);
8121 install_element (OSPF_NODE,
8122 &ospf_default_information_originate_routemap_cmd);
8123 install_element (OSPF_NODE,
8124 &ospf_default_information_originate_type_metric_routemap_cmd);
8125 install_element (OSPF_NODE,
8126 &ospf_default_information_originate_type_routemap_cmd);
8127 install_element (OSPF_NODE,
8128 &ospf_default_information_originate_always_metric_type_routemap_cmd);
8129 install_element (OSPF_NODE,
8130 &ospf_default_information_originate_always_metric_routemap_cmd);
8131 install_element (OSPF_NODE,
8132 &ospf_default_information_originate_always_routemap_cmd);
8133 install_element (OSPF_NODE,
8134 &ospf_default_information_originate_always_type_metric_routemap_cmd);
8135 install_element (OSPF_NODE,
8136 &ospf_default_information_originate_always_type_routemap_cmd);
8138 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
8140 install_element (OSPF_NODE, &ospf_default_metric_cmd);
8141 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
8142 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
8144 install_element (OSPF_NODE, &ospf_distance_cmd);
8145 install_element (OSPF_NODE, &no_ospf_distance_cmd);
8146 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
8147 install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd);
8148 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd);
8149 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd);
8150 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd);
8151 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd);
8152 install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd);
8153 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd);
8154 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd);
8155 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd);
8156 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd);
8157 install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd);
8158 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd);
8159 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd);
8160 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd);
8161 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd);
8162 #if 0
8163 install_element (OSPF_NODE, &ospf_distance_source_cmd);
8164 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
8165 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
8166 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
8167 #endif /* 0 */
8170 struct cmd_node ospf_node =
8172 OSPF_NODE,
8173 "%s(config-router)# ",
8178 /* Install OSPF related vty commands. */
8179 void
8180 ospf_vty_init (void)
8182 /* Install ospf top node. */
8183 install_node (&ospf_node, ospf_config_write);
8185 /* "router ospf" commands. */
8186 install_element (CONFIG_NODE, &router_ospf_cmd);
8187 install_element (CONFIG_NODE, &no_router_ospf_cmd);
8189 install_default (OSPF_NODE);
8191 /* "ospf router-id" commands. */
8192 install_element (OSPF_NODE, &ospf_router_id_cmd);
8193 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
8194 install_element (OSPF_NODE, &router_ospf_id_cmd);
8195 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
8197 /* "passive-interface" commands. */
8198 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
8199 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
8200 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
8201 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
8203 /* "ospf abr-type" commands. */
8204 install_element (OSPF_NODE, &ospf_abr_type_cmd);
8205 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
8207 /* "ospf log-adjacency-changes" commands. */
8208 install_element (OSPF_NODE, &ospf_log_adjacency_changes_cmd);
8209 install_element (OSPF_NODE, &ospf_log_adjacency_changes_detail_cmd);
8210 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_cmd);
8211 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd);
8213 /* "ospf rfc1583-compatible" commands. */
8214 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
8215 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
8216 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
8217 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
8219 /* "network area" commands. */
8220 install_element (OSPF_NODE, &ospf_network_area_cmd);
8221 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
8223 /* "area authentication" commands. */
8224 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
8225 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
8226 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
8228 /* "area range" commands. */
8229 install_element (OSPF_NODE, &ospf_area_range_cmd);
8230 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
8231 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
8232 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
8233 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
8234 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
8235 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
8236 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
8237 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
8238 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
8239 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
8241 /* "area virtual-link" commands. */
8242 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
8243 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
8245 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
8246 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
8248 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
8249 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
8251 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
8252 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
8254 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
8255 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
8257 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
8258 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
8259 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
8261 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
8262 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
8264 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
8265 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
8267 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
8268 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
8269 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
8271 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
8272 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
8273 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
8275 /* "area stub" commands. */
8276 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
8277 install_element (OSPF_NODE, &ospf_area_stub_cmd);
8278 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
8279 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
8281 /* "area nssa" commands. */
8282 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
8283 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
8284 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
8285 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
8286 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
8287 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
8289 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
8290 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
8292 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
8293 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
8295 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
8296 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
8298 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
8299 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
8301 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
8302 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
8304 /* SPF timer commands */
8305 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
8306 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
8307 install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd);
8308 install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd);
8310 /* refresh timer commands */
8311 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
8312 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
8313 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
8315 /* max-metric commands */
8316 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd);
8317 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd);
8318 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd);
8319 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd);
8320 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd);
8321 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd);
8323 /* reference bandwidth commands */
8324 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
8325 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
8327 /* "neighbor" commands. */
8328 install_element (OSPF_NODE, &ospf_neighbor_cmd);
8329 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
8330 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
8331 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
8332 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
8333 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
8334 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
8335 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
8337 /* Init interface related vty commands. */
8338 ospf_vty_if_init ();
8340 /* Init zebra related vty commands. */
8341 ospf_vty_zebra_init ();