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
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
37 #include "ospfd/ospfd.h"
38 #include "ospfd/ospf_asbr.h"
39 #include "ospfd/ospf_lsa.h"
40 #include "ospfd/ospf_lsdb.h"
41 #include "ospfd/ospf_ism.h"
42 #include "ospfd/ospf_interface.h"
43 #include "ospfd/ospf_nsm.h"
44 #include "ospfd/ospf_neighbor.h"
45 #include "ospfd/ospf_flood.h"
46 #include "ospfd/ospf_abr.h"
47 #include "ospfd/ospf_spf.h"
48 #include "ospfd/ospf_route.h"
49 #include "ospfd/ospf_zebra.h"
50 /*#include "ospfd/ospf_routemap.h" */
51 #include "ospfd/ospf_vty.h"
52 #include "ospfd/ospf_dump.h"
53 #include "ospfd/ospf_bfd.h"
55 static const char *ospf_network_type_str
[] =
66 /* Utility functions. */
68 ospf_str2area_id (const char *str
, struct in_addr
*area_id
, int *format
)
73 /* match "A.B.C.D". */
74 if (strchr (str
, '.') != NULL
)
76 ret
= inet_aton (str
, area_id
);
79 *format
= OSPF_AREA_ID_FORMAT_ADDRESS
;
81 /* match "<0-4294967295>". */
87 ret
= strtoul (str
, &endptr
, 10);
88 if (*endptr
!= '\0' || errno
|| ret
> UINT32_MAX
)
91 area_id
->s_addr
= htonl (ret
);
92 *format
= OSPF_AREA_ID_FORMAT_DECIMAL
;
100 str2metric (const char *str
, int *metric
)
106 *metric
= strtol (str
, NULL
, 10);
107 if (*metric
< 0 && *metric
> 16777214)
109 /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */
117 str2metric_type (const char *str
, int *metric_type
)
123 if (strncmp (str
, "1", 1) == 0)
124 *metric_type
= EXTERNAL_METRIC_TYPE_1
;
125 else if (strncmp (str
, "2", 1) == 0)
126 *metric_type
= EXTERNAL_METRIC_TYPE_2
;
134 ospf_oi_count (struct interface
*ifp
)
136 struct route_node
*rn
;
139 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
150 "Enable a routing process\n"
151 "Start OSPF configuration\n")
154 u_short instance
= 0;
156 ospf
= ospf_lookup();
159 vty_out (vty
, "There isn't active ospf instance %s", VTY_NEWLINE
);
163 vty
->node
= OSPF_NODE
;
166 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
168 /* The following logic to set the vty->index is in place to be able
169 to ignore the commands which dont belong to this instance. */
170 if (ospf
->instance
!= instance
)
174 if (IS_DEBUG_OSPF_EVENT
)
175 zlog_debug ("Config command 'router ospf %d' received", instance
);
176 ospf
->oi_running
= 1;
178 ospf_router_id_update (ospf
);
185 router_ospf_instance_cmd
,
186 "router ospf <1-65535>",
187 "Enable a routing process\n"
188 "Start OSPF configuration\n"
191 DEFUN (no_router_ospf
,
195 "Enable a routing process\n"
196 "Start OSPF configuration\n")
199 u_short instance
= 0;
202 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
204 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
212 ALIAS (no_router_ospf
,
213 no_router_ospf_instance_cmd
,
214 "no router ospf <1-65535>",
216 "Enable a routing process\n"
217 "Start OSPF configuration\n"
220 DEFUN (ospf_router_id
,
222 "ospf router-id A.B.C.D",
223 "OSPF specific commands\n"
224 "router-id for the OSPF process\n"
225 "OSPF router-id in IP address format\n")
227 struct ospf
*ospf
= vty
->index
;
228 struct listnode
*node
;
229 struct ospf_area
*area
;
230 struct in_addr router_id
;
236 ret
= inet_aton (argv
[0], &router_id
);
239 vty_out (vty
, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE
);
243 ospf
->router_id_static
= router_id
;
245 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
248 vty_out (vty
, "For this router-id change to take effect,"
249 " save config and restart ospfd%s", VTY_NEWLINE
);
253 ospf_router_id_update (ospf
);
258 ALIAS_HIDDEN (ospf_router_id
,
259 ospf_router_id_old_cmd
,
261 "router-id for the OSPF process\n"
262 "OSPF router-id in IP address format\n")
264 DEFUN (no_ospf_router_id
,
265 no_ospf_router_id_cmd
,
268 "OSPF specific commands\n"
269 "router-id for the OSPF process\n")
271 struct ospf
*ospf
= vty
->index
;
272 struct listnode
*node
;
273 struct ospf_area
*area
;
278 ospf
->router_id_static
.s_addr
= 0;
280 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
283 vty_out (vty
, "For this router-id change to take effect,"
284 " save config and restart ospfd%s", VTY_NEWLINE
);
288 ospf_router_id_update (ospf
);
293 ALIAS (no_ospf_router_id
,
294 no_ospf_router_id_val_cmd
,
295 "no ospf router-id A.B.C.D",
297 "OSPF specific commands\n"
298 "router-id for the OSPF process\n"
299 "OSPF router-id in IP address format\n")
302 ospf_passive_interface_default (struct ospf
*ospf
, u_char newval
)
305 struct interface
*ifp
;
306 struct ospf_interface
*oi
;
308 ospf
->passive_interface_default
= newval
;
310 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, ln
, ifp
))
313 OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
))
314 UNSET_IF_PARAM (IF_DEF_PARAMS (ifp
), passive_interface
);
316 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, ln
, oi
))
318 if (OSPF_IF_PARAM_CONFIGURED (oi
->params
, passive_interface
))
319 UNSET_IF_PARAM (oi
->params
, passive_interface
);
320 /* update multicast memberships */
321 ospf_if_set_multicast(oi
);
326 ospf_passive_interface_update (struct ospf
*ospf
, struct interface
*ifp
,
328 struct ospf_if_params
*params
, u_char value
)
332 params
->passive_interface
= value
;
333 if (params
!= IF_DEF_PARAMS (ifp
))
335 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
))
336 dflt
= IF_DEF_PARAMS (ifp
)->passive_interface
;
338 dflt
= ospf
->passive_interface_default
;
341 SET_IF_PARAM (params
, passive_interface
);
343 UNSET_IF_PARAM (params
, passive_interface
);
345 ospf_free_if_params (ifp
, addr
);
346 ospf_if_update_params (ifp
, addr
);
350 if (value
!= ospf
->passive_interface_default
)
351 SET_IF_PARAM (params
, passive_interface
);
353 UNSET_IF_PARAM (params
, passive_interface
);
357 DEFUN (ospf_passive_interface
,
358 ospf_passive_interface_addr_cmd
,
359 "passive-interface IFNAME A.B.C.D",
360 "Suppress routing updates on an interface\n"
361 "Interface's name\n")
363 struct interface
*ifp
;
366 struct ospf_if_params
*params
;
367 struct route_node
*rn
;
368 struct ospf
*ospf
= vty
->index
;
375 ospf_passive_interface_default (ospf
, OSPF_IF_PASSIVE
);
379 ifp
= if_get_by_name (argv
[0]);
381 params
= IF_DEF_PARAMS (ifp
);
385 ret
= inet_aton(argv
[1], &addr
);
388 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
393 params
= ospf_get_if_params (ifp
, addr
);
394 ospf_if_update_params (ifp
, addr
);
396 ospf_passive_interface_update (ospf
, ifp
, addr
, params
, OSPF_IF_PASSIVE
);
398 /* XXX We should call ospf_if_set_multicast on exactly those
399 * interfaces for which the passive property changed. It is too much
400 * work to determine this set, so we do this for every interface.
401 * This is safe and reasonable because ospf_if_set_multicast uses a
402 * record of joined groups to avoid systems calls if the desired
403 * memberships match the current memership.
406 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next (rn
))
408 struct ospf_interface
*oi
= rn
->info
;
410 if (oi
&& (OSPF_IF_PARAM(oi
, passive_interface
) == OSPF_IF_PASSIVE
))
411 ospf_if_set_multicast(oi
);
414 * XXX It is not clear what state transitions the interface needs to
415 * undergo when going from active to passive. Fixing this will
416 * require precise identification of interfaces having such a
423 ALIAS (ospf_passive_interface
,
424 ospf_passive_interface_cmd
,
425 "passive-interface IFNAME",
426 "Suppress routing updates on an interface\n"
427 "Interface's name\n")
429 ALIAS (ospf_passive_interface
,
430 ospf_passive_interface_default_cmd
,
431 "passive-interface default",
432 "Suppress routing updates on an interface\n"
433 "Suppress routing updates on interfaces by default\n")
435 DEFUN (no_ospf_passive_interface
,
436 no_ospf_passive_interface_addr_cmd
,
437 "no passive-interface IFNAME A.B.C.D",
439 "Allow routing updates on an interface\n"
440 "Interface's name\n")
442 struct interface
*ifp
;
444 struct ospf_if_params
*params
;
446 struct route_node
*rn
;
447 struct ospf
*ospf
= vty
->index
;
454 ospf_passive_interface_default (ospf
, OSPF_IF_ACTIVE
);
458 ifp
= if_get_by_name (argv
[0]);
460 params
= IF_DEF_PARAMS (ifp
);
464 ret
= inet_aton(argv
[1], &addr
);
467 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
472 params
= ospf_lookup_if_params (ifp
, addr
);
476 ospf_passive_interface_update (ospf
, ifp
, addr
, params
, OSPF_IF_ACTIVE
);
478 /* XXX We should call ospf_if_set_multicast on exactly those
479 * interfaces for which the passive property changed. It is too much
480 * work to determine this set, so we do this for every interface.
481 * This is safe and reasonable because ospf_if_set_multicast uses a
482 * record of joined groups to avoid systems calls if the desired
483 * memberships match the current memership.
485 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next (rn
))
487 struct ospf_interface
*oi
= rn
->info
;
489 if (oi
&& (OSPF_IF_PARAM(oi
, passive_interface
) == OSPF_IF_ACTIVE
))
490 ospf_if_set_multicast(oi
);
496 ALIAS (no_ospf_passive_interface
,
497 no_ospf_passive_interface_cmd
,
498 "no passive-interface IFNAME",
500 "Allow routing updates on an interface\n"
501 "Interface's name\n")
503 ALIAS (no_ospf_passive_interface
,
504 no_ospf_passive_interface_default_cmd
,
505 "no passive-interface default",
507 "Allow routing updates on an interface\n"
508 "Allow routing updates on interfaces by default\n")
510 DEFUN (ospf_network_area
,
511 ospf_network_area_cmd
,
512 "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
513 "Enable routing on an IP network\n"
514 "OSPF network prefix\n"
515 "Set the OSPF area ID\n"
516 "OSPF area ID in IP address format\n"
517 "OSPF area ID as a decimal value\n")
519 struct ospf
*ospf
= vty
->index
;
520 struct prefix_ipv4 p
;
521 struct in_addr area_id
;
529 vty_out (vty
, "The network command is not supported in multi-instance ospf%s",
534 if (ospf
->if_ospf_cli_count
> 0)
536 vty_out (vty
, "Please remove all ip ospf area x.x.x.x commands first.%s",
541 /* Get network prefix and Area ID. */
542 VTY_GET_IPV4_PREFIX ("network prefix", p
, argv
[0]);
543 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[1]);
545 ret
= ospf_network_set (ospf
, &p
, area_id
);
548 vty_out (vty
, "There is already same network statement.%s", VTY_NEWLINE
);
555 DEFUN (no_ospf_network_area
,
556 no_ospf_network_area_cmd
,
557 "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
559 "Enable routing on an IP network\n"
560 "OSPF network prefix\n"
561 "Set the OSPF area ID\n"
562 "OSPF area ID in IP address format\n"
563 "OSPF area ID as a decimal value\n")
565 struct ospf
*ospf
= (struct ospf
*) vty
->index
;
566 struct prefix_ipv4 p
;
567 struct in_addr area_id
;
575 vty_out (vty
, "The network command is not supported in multi-instance ospf%s",
580 /* Get network prefix and Area ID. */
581 VTY_GET_IPV4_PREFIX ("network prefix", p
, argv
[0]);
582 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[1]);
584 ret
= ospf_network_unset (ospf
, &p
, area_id
);
587 vty_out (vty
, "Can't find specified network area configuration.%s",
596 DEFUN (ospf_area_range
,
598 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
599 "OSPF area parameters\n"
600 "OSPF area ID in IP address format\n"
601 "OSPF area ID as a decimal value\n"
602 "Summarize routes matching address/mask (border routers only)\n"
603 "Area range prefix\n")
605 struct ospf
*ospf
= vty
->index
;
606 struct prefix_ipv4 p
;
607 struct in_addr area_id
;
614 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
615 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[1]);
617 ospf_area_range_set (ospf
, area_id
, &p
, OSPF_AREA_RANGE_ADVERTISE
);
620 VTY_GET_INTEGER ("range cost", cost
, argv
[2]);
621 ospf_area_range_cost_set (ospf
, area_id
, &p
, cost
);
627 ALIAS (ospf_area_range
,
628 ospf_area_range_advertise_cmd
,
629 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise",
630 "OSPF area parameters\n"
631 "OSPF area ID in IP address format\n"
632 "OSPF area ID as a decimal value\n"
633 "OSPF area range for route advertise (default)\n"
634 "Area range prefix\n"
635 "Advertise this range (default)\n")
637 ALIAS (ospf_area_range
,
638 ospf_area_range_cost_cmd
,
639 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
640 "OSPF area parameters\n"
641 "OSPF area ID in IP address format\n"
642 "OSPF area ID as a decimal value\n"
643 "Summarize routes matching address/mask (border routers only)\n"
644 "Area range prefix\n"
645 "User specified metric for this range\n"
646 "Advertised metric for this range\n")
648 ALIAS (ospf_area_range
,
649 ospf_area_range_advertise_cost_cmd
,
650 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
651 "OSPF area parameters\n"
652 "OSPF area ID in IP address format\n"
653 "OSPF area ID as a decimal value\n"
654 "Summarize routes matching address/mask (border routers only)\n"
655 "Area range prefix\n"
656 "Advertise this range (default)\n"
657 "User specified metric for this range\n"
658 "Advertised metric for this range\n")
660 DEFUN (ospf_area_range_not_advertise
,
661 ospf_area_range_not_advertise_cmd
,
662 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise",
663 "OSPF area parameters\n"
664 "OSPF area ID in IP address format\n"
665 "OSPF area ID as a decimal value\n"
666 "Summarize routes matching address/mask (border routers only)\n"
667 "Area range prefix\n"
668 "DoNotAdvertise this range\n")
670 struct ospf
*ospf
= vty
->index
;
671 struct prefix_ipv4 p
;
672 struct in_addr area_id
;
678 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
679 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[1]);
681 ospf_area_range_set (ospf
, area_id
, &p
, 0);
686 DEFUN (no_ospf_area_range
,
687 no_ospf_area_range_cmd
,
688 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
690 "OSPF area parameters\n"
691 "OSPF area ID in IP address format\n"
692 "OSPF area ID as a decimal value\n"
693 "Summarize routes matching address/mask (border routers only)\n"
694 "Area range prefix\n")
696 struct ospf
*ospf
= vty
->index
;
697 struct prefix_ipv4 p
;
698 struct in_addr area_id
;
704 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
705 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[1]);
707 ospf_area_range_unset (ospf
, area_id
, &p
);
712 ALIAS (no_ospf_area_range
,
713 no_ospf_area_range_advertise_cmd
,
714 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)",
716 "OSPF area parameters\n"
717 "OSPF area ID in IP address format\n"
718 "OSPF area ID as a decimal value\n"
719 "Summarize routes matching address/mask (border routers only)\n"
720 "Area range prefix\n"
721 "Advertise this range (default)\n"
722 "DoNotAdvertise this range\n")
724 ALIAS (no_ospf_area_range
,
725 no_ospf_area_range_cost_cmd
,
726 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
728 "OSPF area parameters\n"
729 "OSPF area ID in IP address format\n"
730 "OSPF area ID as a decimal value\n"
731 "Summarize routes matching address/mask (border routers only)\n"
732 "Area range prefix\n"
733 "User specified metric for this range\n"
734 "Advertised metric for this range\n")
736 ALIAS (no_ospf_area_range
,
737 no_ospf_area_range_advertise_cost_cmd
,
738 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
740 "OSPF area parameters\n"
741 "OSPF area ID in IP address format\n"
742 "OSPF area ID as a decimal value\n"
743 "Summarize routes matching address/mask (border routers only)\n"
744 "Area range prefix\n"
745 "Advertise this range (default)\n"
746 "User specified metric for this range\n"
747 "Advertised metric for this range\n")
749 DEFUN (ospf_area_range_substitute
,
750 ospf_area_range_substitute_cmd
,
751 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
752 "OSPF area parameters\n"
753 "OSPF area ID in IP address format\n"
754 "OSPF area ID as a decimal value\n"
755 "Summarize routes matching address/mask (border routers only)\n"
756 "Area range prefix\n"
757 "Announce area range as another prefix\n"
758 "Network prefix to be announced instead of range\n")
760 struct ospf
*ospf
= vty
->index
;
761 struct prefix_ipv4 p
, s
;
762 struct in_addr area_id
;
768 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
769 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[1]);
770 VTY_GET_IPV4_PREFIX ("substituted network prefix", s
, argv
[2]);
772 ospf_area_range_substitute_set (ospf
, area_id
, &p
, &s
);
777 DEFUN (no_ospf_area_range_substitute
,
778 no_ospf_area_range_substitute_cmd
,
779 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
781 "OSPF area parameters\n"
782 "OSPF area ID in IP address format\n"
783 "OSPF area ID as a decimal value\n"
784 "Summarize routes matching address/mask (border routers only)\n"
785 "Area range prefix\n"
786 "Announce area range as another prefix\n"
787 "Network prefix to be announced instead of range\n")
789 struct ospf
*ospf
= vty
->index
;
790 struct prefix_ipv4 p
, s
;
791 struct in_addr area_id
;
797 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
798 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[1]);
799 VTY_GET_IPV4_PREFIX ("substituted network prefix", s
, argv
[2]);
801 ospf_area_range_substitute_unset (ospf
, area_id
, &p
);
807 /* Command Handler Logic in VLink stuff is delicate!!
809 ALTER AT YOUR OWN RISK!!!!
811 Various dummy values are used to represent 'NoChange' state for
812 VLink configuration NOT being changed by a VLink command, and
813 special syntax is used within the command strings so that the
814 typed in command verbs can be seen in the configuration command
815 bacckend handler. This is to drastically reduce the verbeage
816 required to coe up with a reasonably compatible Cisco VLink command
818 - Matthew Grant <grantma@anathoth.gen.nz>
819 Wed, 21 Feb 2001 15:13:52 +1300
823 /* Configuration data for virtual links
825 struct ospf_vl_config_data
{
826 struct vty
*vty
; /* vty stuff */
827 struct in_addr area_id
; /* area ID from command line */
828 int format
; /* command line area ID format */
829 struct in_addr vl_peer
; /* command line vl_peer */
830 int auth_type
; /* Authehntication type, if given */
831 char *auth_key
; /* simple password if present */
832 int crypto_key_id
; /* Cryptographic key ID */
833 char *md5_key
; /* MD5 authentication key */
834 int hello_interval
; /* Obvious what these are... */
835 int retransmit_interval
;
841 ospf_vl_config_data_init (struct ospf_vl_config_data
*vl_config
,
844 memset (vl_config
, 0, sizeof (struct ospf_vl_config_data
));
845 vl_config
->auth_type
= OSPF_AUTH_CMD_NOTSEEN
;
846 vl_config
->vty
= vty
;
849 static struct ospf_vl_data
*
850 ospf_find_vl_data (struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
852 struct ospf_area
*area
;
853 struct ospf_vl_data
*vl_data
;
855 struct in_addr area_id
;
857 vty
= vl_config
->vty
;
858 area_id
= vl_config
->area_id
;
860 if (area_id
.s_addr
== OSPF_AREA_BACKBONE
)
863 "Configuring VLs over the backbone is not allowed%s",
867 area
= ospf_area_get (ospf
, area_id
, vl_config
->format
);
869 if (area
->external_routing
!= OSPF_AREA_DEFAULT
)
871 if (vl_config
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
872 vty_out (vty
, "Area %s is %s%s",
874 area
->external_routing
== OSPF_AREA_NSSA
?"nssa":"stub",
877 vty_out (vty
, "Area %ld is %s%s",
878 (u_long
)ntohl (area_id
.s_addr
),
879 area
->external_routing
== OSPF_AREA_NSSA
?"nssa":"stub",
884 if ((vl_data
= ospf_vl_lookup (ospf
, area
, vl_config
->vl_peer
)) == NULL
)
886 vl_data
= ospf_vl_data_new (area
, vl_config
->vl_peer
);
887 if (vl_data
->vl_oi
== NULL
)
889 vl_data
->vl_oi
= ospf_vl_new (ospf
, vl_data
);
890 ospf_vl_add (ospf
, vl_data
);
891 ospf_spf_calculate_schedule (ospf
);
899 ospf_vl_set_security (struct ospf_vl_data
*vl_data
,
900 struct ospf_vl_config_data
*vl_config
)
902 struct crypt_key
*ck
;
904 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
906 vty
= vl_config
->vty
;
908 if (vl_config
->auth_type
!= OSPF_AUTH_CMD_NOTSEEN
)
910 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), auth_type
);
911 IF_DEF_PARAMS (ifp
)->auth_type
= vl_config
->auth_type
;
914 if (vl_config
->auth_key
)
916 memset(IF_DEF_PARAMS (ifp
)->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+1);
917 strncpy ((char *) IF_DEF_PARAMS (ifp
)->auth_simple
, vl_config
->auth_key
,
918 OSPF_AUTH_SIMPLE_SIZE
);
920 else if (vl_config
->md5_key
)
922 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp
)->auth_crypt
, vl_config
->crypto_key_id
)
925 vty_out (vty
, "OSPF: Key %d already exists%s",
926 vl_config
->crypto_key_id
, VTY_NEWLINE
);
929 ck
= ospf_crypt_key_new ();
930 ck
->key_id
= vl_config
->crypto_key_id
;
931 memset(ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
932 strncpy ((char *) ck
->auth_key
, vl_config
->md5_key
, OSPF_AUTH_MD5_SIZE
);
934 ospf_crypt_key_add (IF_DEF_PARAMS (ifp
)->auth_crypt
, ck
);
936 else if (vl_config
->crypto_key_id
!= 0)
940 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp
)->auth_crypt
,
941 vl_config
->crypto_key_id
) == NULL
)
943 vty_out (vty
, "OSPF: Key %d does not exist%s",
944 vl_config
->crypto_key_id
, VTY_NEWLINE
);
948 ospf_crypt_key_delete (IF_DEF_PARAMS (ifp
)->auth_crypt
, vl_config
->crypto_key_id
);
956 ospf_vl_set_timers (struct ospf_vl_data
*vl_data
,
957 struct ospf_vl_config_data
*vl_config
)
959 struct interface
*ifp
= ifp
= vl_data
->vl_oi
->ifp
;
960 /* Virtual Link data initialised to defaults, so only set
962 if (vl_config
->hello_interval
)
964 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), v_hello
);
965 IF_DEF_PARAMS (ifp
)->v_hello
= vl_config
->hello_interval
;
968 if (vl_config
->dead_interval
)
970 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), v_wait
);
971 IF_DEF_PARAMS (ifp
)->v_wait
= vl_config
->dead_interval
;
974 if (vl_config
->retransmit_interval
)
976 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), retransmit_interval
);
977 IF_DEF_PARAMS (ifp
)->retransmit_interval
= vl_config
->retransmit_interval
;
980 if (vl_config
->transmit_delay
)
982 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), transmit_delay
);
983 IF_DEF_PARAMS (ifp
)->transmit_delay
= vl_config
->transmit_delay
;
991 /* The business end of all of the above */
993 ospf_vl_set (struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
995 struct ospf_vl_data
*vl_data
;
998 vl_data
= ospf_find_vl_data (ospf
, vl_config
);
1002 /* Process this one first as it can have a fatal result, which can
1003 only logically occur if the virtual link exists already
1004 Thus a command error does not result in a change to the
1005 running configuration such as unexpectedly altered timer
1007 ret
= ospf_vl_set_security (vl_data
, vl_config
);
1008 if (ret
!= CMD_SUCCESS
)
1011 /* Set any time based parameters, these area already range checked */
1013 ret
= ospf_vl_set_timers (vl_data
, vl_config
);
1014 if (ret
!= CMD_SUCCESS
)
1021 /* This stuff exists to make specifying all the alias commands A LOT simpler
1023 #define VLINK_HELPSTR_IPADDR \
1024 "OSPF area parameters\n" \
1025 "OSPF area ID in IP address format\n" \
1026 "OSPF area ID as a decimal value\n" \
1027 "Configure a virtual link\n" \
1028 "Router ID of the remote ABR\n"
1030 #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
1031 "Enable authentication on this virtual link\n" \
1034 #define VLINK_HELPSTR_AUTHTYPE_ALL \
1035 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
1036 "Use null authentication\n" \
1037 "Use message-digest authentication\n"
1039 #define VLINK_HELPSTR_TIME_PARAM_NOSECS \
1040 "Time between HELLO packets\n" \
1041 "Time between retransmitting lost link state advertisements\n" \
1042 "Link state transmit delay\n" \
1043 "Interval after which a neighbor is declared dead\n"
1045 #define VLINK_HELPSTR_TIME_PARAM \
1046 VLINK_HELPSTR_TIME_PARAM_NOSECS \
1049 #define VLINK_HELPSTR_AUTH_SIMPLE \
1050 "Authentication password (key)\n" \
1051 "The OSPF password (key)"
1053 #define VLINK_HELPSTR_AUTH_MD5 \
1054 "Message digest authentication password (key)\n" \
1057 "Use MD5 algorithm\n" \
1058 "The OSPF password (key)"
1060 DEFUN (ospf_area_vlink
,
1061 ospf_area_vlink_cmd
,
1062 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
1063 VLINK_HELPSTR_IPADDR
)
1065 struct ospf
*ospf
= vty
->index
;
1066 struct ospf_vl_config_data vl_config
;
1067 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+1];
1068 char md5_key
[OSPF_AUTH_MD5_SIZE
+1];
1075 ospf_vl_config_data_init(&vl_config
, vty
);
1077 /* Read off first 2 parameters and check them */
1078 ret
= ospf_str2area_id (argv
[0], &vl_config
.area_id
, &vl_config
.format
);
1081 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1085 ret
= inet_aton (argv
[1], &vl_config
.vl_peer
);
1088 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s",
1095 /* Thats all folks! - BUGS B. strikes again!!!*/
1097 return ospf_vl_set (ospf
, &vl_config
);
1100 /* Deal with other parameters */
1101 for (i
=2; i
< argc
; i
++)
1104 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1110 if (i
> 2 || strncmp (argv
[i
], "authentication-", 15) == 0)
1112 /* authentication-key - this option can occur anywhere on
1113 command line. At start of command line
1114 must check for authentication option. */
1115 memset (auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1116 strncpy (auth_key
, argv
[i
+1], OSPF_AUTH_SIMPLE_SIZE
);
1117 vl_config
.auth_key
= auth_key
;
1120 else if (strncmp (argv
[i
], "authentication", 14) == 0)
1122 /* authentication - this option can only occur at start
1124 vl_config
.auth_type
= OSPF_AUTH_SIMPLE
;
1127 if (strncmp (argv
[i
+1], "n", 1) == 0)
1129 /* "authentication null" */
1130 vl_config
.auth_type
= OSPF_AUTH_NULL
;
1133 else if (strncmp (argv
[i
+1], "m", 1) == 0
1134 && strcmp (argv
[i
+1], "message-digest-") != 0)
1136 /* "authentication message-digest" */
1137 vl_config
.auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
1145 /* message-digest-key */
1147 vl_config
.crypto_key_id
= strtol (argv
[i
], NULL
, 10);
1148 if (vl_config
.crypto_key_id
< 0)
1151 memset(md5_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
1152 strncpy (md5_key
, argv
[i
], OSPF_AUTH_MD5_SIZE
);
1153 vl_config
.md5_key
= md5_key
;
1157 /* Hello interval */
1159 vl_config
.hello_interval
= strtol (argv
[i
], NULL
, 10);
1160 if (vl_config
.hello_interval
< 0)
1165 /* Retransmit Interval */
1167 vl_config
.retransmit_interval
= strtol (argv
[i
], NULL
, 10);
1168 if (vl_config
.retransmit_interval
< 0)
1173 /* Transmit Delay */
1175 vl_config
.transmit_delay
= strtol (argv
[i
], NULL
, 10);
1176 if (vl_config
.transmit_delay
< 0)
1183 vl_config
.dead_interval
= strtol (argv
[i
], NULL
, 10);
1184 if (vl_config
.dead_interval
< 0)
1191 /* Action configuration */
1193 return ospf_vl_set (ospf
, &vl_config
);
1197 DEFUN (no_ospf_area_vlink
,
1198 no_ospf_area_vlink_cmd
,
1199 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
1201 VLINK_HELPSTR_IPADDR
)
1203 struct ospf
*ospf
= vty
->index
;
1204 struct ospf_area
*area
;
1205 struct ospf_vl_config_data vl_config
;
1206 struct ospf_vl_data
*vl_data
= NULL
;
1207 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+1];
1214 ospf_vl_config_data_init(&vl_config
, vty
);
1216 ret
= ospf_str2area_id (argv
[0], &vl_config
.area_id
, &format
);
1219 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1223 area
= ospf_area_lookup_by_area_id (ospf
, vl_config
.area_id
);
1226 vty_out (vty
, "Area does not exist%s", VTY_NEWLINE
);
1230 ret
= inet_aton (argv
[1], &vl_config
.vl_peer
);
1233 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s",
1240 /* Basic VLink no command */
1241 /* Thats all folks! - BUGS B. strikes again!!!*/
1242 if ((vl_data
= ospf_vl_lookup (ospf
, area
, vl_config
.vl_peer
)))
1243 ospf_vl_delete (ospf
, vl_data
);
1245 ospf_area_check_free (ospf
, vl_config
.area_id
);
1250 /* If we are down here, we are reseting parameters */
1252 /* Deal with other parameters */
1253 for (i
=2; i
< argc
; i
++)
1255 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1261 if (i
> 2 || strncmp (argv
[i
], "authentication-", 15) == 0)
1263 /* authentication-key - this option can occur anywhere on
1264 command line. At start of command line
1265 must check for authentication option. */
1266 memset (auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1267 vl_config
.auth_key
= auth_key
;
1269 else if (strncmp (argv
[i
], "authentication", 14) == 0)
1271 /* authentication - this option can only occur at start
1273 vl_config
.auth_type
= OSPF_AUTH_NOTSET
;
1278 /* message-digest-key */
1279 /* Delete one key */
1281 vl_config
.crypto_key_id
= strtol (argv
[i
], NULL
, 10);
1282 if (vl_config
.crypto_key_id
< 0)
1284 vl_config
.md5_key
= NULL
;
1288 /* Hello interval */
1289 vl_config
.hello_interval
= OSPF_HELLO_INTERVAL_DEFAULT
;
1293 /* Retransmit Interval */
1294 vl_config
.retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
1298 /* Transmit Delay */
1299 vl_config
.transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
1305 vl_config
.dead_interval
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
1311 /* Action configuration */
1313 return ospf_vl_set (ospf
, &vl_config
);
1316 ALIAS (ospf_area_vlink
,
1317 ospf_area_vlink_param1_cmd
,
1318 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1319 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1320 VLINK_HELPSTR_IPADDR
1321 VLINK_HELPSTR_TIME_PARAM
)
1323 ALIAS (no_ospf_area_vlink
,
1324 no_ospf_area_vlink_param1_cmd
,
1325 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1326 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1328 VLINK_HELPSTR_IPADDR
1329 VLINK_HELPSTR_TIME_PARAM
)
1331 ALIAS (ospf_area_vlink
,
1332 ospf_area_vlink_param2_cmd
,
1333 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1334 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1335 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1336 VLINK_HELPSTR_IPADDR
1337 VLINK_HELPSTR_TIME_PARAM
1338 VLINK_HELPSTR_TIME_PARAM
)
1340 ALIAS (no_ospf_area_vlink
,
1341 no_ospf_area_vlink_param2_cmd
,
1342 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1343 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1344 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1346 VLINK_HELPSTR_IPADDR
1347 VLINK_HELPSTR_TIME_PARAM
1348 VLINK_HELPSTR_TIME_PARAM
)
1350 ALIAS (ospf_area_vlink
,
1351 ospf_area_vlink_param3_cmd
,
1352 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1353 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1354 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1355 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1356 VLINK_HELPSTR_IPADDR
1357 VLINK_HELPSTR_TIME_PARAM
1358 VLINK_HELPSTR_TIME_PARAM
1359 VLINK_HELPSTR_TIME_PARAM
)
1361 ALIAS (no_ospf_area_vlink
,
1362 no_ospf_area_vlink_param3_cmd
,
1363 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1364 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1365 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1366 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1368 VLINK_HELPSTR_IPADDR
1369 VLINK_HELPSTR_TIME_PARAM
1370 VLINK_HELPSTR_TIME_PARAM
1371 VLINK_HELPSTR_TIME_PARAM
)
1373 ALIAS (ospf_area_vlink
,
1374 ospf_area_vlink_param4_cmd
,
1375 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1376 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1377 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1378 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1379 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1380 VLINK_HELPSTR_IPADDR
1381 VLINK_HELPSTR_TIME_PARAM
1382 VLINK_HELPSTR_TIME_PARAM
1383 VLINK_HELPSTR_TIME_PARAM
1384 VLINK_HELPSTR_TIME_PARAM
)
1386 ALIAS (no_ospf_area_vlink
,
1387 no_ospf_area_vlink_param4_cmd
,
1388 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1389 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1390 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1391 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1392 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1394 VLINK_HELPSTR_IPADDR
1395 VLINK_HELPSTR_TIME_PARAM
1396 VLINK_HELPSTR_TIME_PARAM
1397 VLINK_HELPSTR_TIME_PARAM
1398 VLINK_HELPSTR_TIME_PARAM
)
1400 ALIAS (ospf_area_vlink
,
1401 ospf_area_vlink_authtype_args_cmd
,
1402 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1403 "(authentication|) (message-digest|null)",
1404 VLINK_HELPSTR_IPADDR
1405 VLINK_HELPSTR_AUTHTYPE_ALL
)
1407 ALIAS (no_ospf_area_vlink
,
1408 no_ospf_area_vlink_authtype_args_cmd
,
1409 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1410 "(authentication|) (message-digest|null)",
1412 VLINK_HELPSTR_IPADDR
1413 VLINK_HELPSTR_AUTHTYPE_ALL
)
1415 ALIAS (ospf_area_vlink
,
1416 ospf_area_vlink_authtype_cmd
,
1417 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1418 "(authentication|)",
1419 VLINK_HELPSTR_IPADDR
1420 VLINK_HELPSTR_AUTHTYPE_SIMPLE
)
1422 ALIAS (no_ospf_area_vlink
,
1423 no_ospf_area_vlink_authtype_cmd
,
1424 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1425 "(authentication|)",
1427 VLINK_HELPSTR_IPADDR
1428 VLINK_HELPSTR_AUTHTYPE_SIMPLE
)
1430 ALIAS (ospf_area_vlink
,
1431 ospf_area_vlink_md5_cmd
,
1432 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1433 "(message-digest-key|) <1-255> md5 KEY",
1434 VLINK_HELPSTR_IPADDR
1435 VLINK_HELPSTR_AUTH_MD5
)
1437 ALIAS (no_ospf_area_vlink
,
1438 no_ospf_area_vlink_md5_cmd
,
1439 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1440 "(message-digest-key|) <1-255> md5 KEY",
1442 VLINK_HELPSTR_IPADDR
1443 VLINK_HELPSTR_AUTH_MD5
)
1445 ALIAS (ospf_area_vlink
,
1446 ospf_area_vlink_authkey_cmd
,
1447 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1448 "(authentication-key|) AUTH_KEY",
1449 VLINK_HELPSTR_IPADDR
1450 VLINK_HELPSTR_AUTH_SIMPLE
)
1452 ALIAS (no_ospf_area_vlink
,
1453 no_ospf_area_vlink_authkey_cmd
,
1454 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1455 "(authentication-key|) AUTH_KEY",
1457 VLINK_HELPSTR_IPADDR
1458 VLINK_HELPSTR_AUTH_SIMPLE
)
1460 ALIAS (ospf_area_vlink
,
1461 ospf_area_vlink_authtype_args_authkey_cmd
,
1462 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1463 "(authentication|) (message-digest|null) "
1464 "(authentication-key|) AUTH_KEY",
1465 VLINK_HELPSTR_IPADDR
1466 VLINK_HELPSTR_AUTHTYPE_ALL
1467 VLINK_HELPSTR_AUTH_SIMPLE
)
1469 ALIAS (no_ospf_area_vlink
,
1470 no_ospf_area_vlink_authtype_args_authkey_cmd
,
1471 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1472 "(authentication|) (message-digest|null) "
1473 "(authentication-key|) AUTH_KEY",
1475 VLINK_HELPSTR_IPADDR
1476 VLINK_HELPSTR_AUTHTYPE_ALL
1477 VLINK_HELPSTR_AUTH_SIMPLE
)
1479 ALIAS (ospf_area_vlink
,
1480 ospf_area_vlink_authtype_authkey_cmd
,
1481 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1482 "(authentication|) "
1483 "(authentication-key|) AUTH_KEY",
1484 VLINK_HELPSTR_IPADDR
1485 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1486 VLINK_HELPSTR_AUTH_SIMPLE
)
1488 ALIAS (no_ospf_area_vlink
,
1489 no_ospf_area_vlink_authtype_authkey_cmd
,
1490 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1491 "(authentication|) "
1492 "(authentication-key|) AUTH_KEY",
1494 VLINK_HELPSTR_IPADDR
1495 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1496 VLINK_HELPSTR_AUTH_SIMPLE
)
1498 ALIAS (ospf_area_vlink
,
1499 ospf_area_vlink_authtype_args_md5_cmd
,
1500 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1501 "(authentication|) (message-digest|null) "
1502 "(message-digest-key|) <1-255> md5 KEY",
1503 VLINK_HELPSTR_IPADDR
1504 VLINK_HELPSTR_AUTHTYPE_ALL
1505 VLINK_HELPSTR_AUTH_MD5
)
1507 ALIAS (no_ospf_area_vlink
,
1508 no_ospf_area_vlink_authtype_args_md5_cmd
,
1509 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1510 "(authentication|) (message-digest|null) "
1511 "(message-digest-key|) <1-255> md5 KEY",
1513 VLINK_HELPSTR_IPADDR
1514 VLINK_HELPSTR_AUTHTYPE_ALL
1515 VLINK_HELPSTR_AUTH_MD5
)
1517 ALIAS (ospf_area_vlink
,
1518 ospf_area_vlink_authtype_md5_cmd
,
1519 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1520 "(authentication|) "
1521 "(message-digest-key|) <1-255> md5 KEY",
1522 VLINK_HELPSTR_IPADDR
1523 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1524 VLINK_HELPSTR_AUTH_MD5
)
1526 ALIAS (no_ospf_area_vlink
,
1527 no_ospf_area_vlink_authtype_md5_cmd
,
1528 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1529 "(authentication|) "
1530 "(message-digest-key|) <1-255> md5 KEY",
1532 VLINK_HELPSTR_IPADDR
1533 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1534 VLINK_HELPSTR_AUTH_MD5
)
1537 DEFUN (ospf_area_shortcut
,
1538 ospf_area_shortcut_cmd
,
1539 "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)",
1540 "OSPF area parameters\n"
1541 "OSPF area ID in IP address format\n"
1542 "OSPF area ID as a decimal value\n"
1543 "Configure the area's shortcutting mode\n"
1544 "Set default shortcutting behavior\n"
1545 "Enable shortcutting through the area\n"
1546 "Disable shortcutting through the area\n")
1548 struct ospf
*ospf
= vty
->index
;
1549 struct ospf_area
*area
;
1550 struct in_addr area_id
;
1557 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id
, format
, argv
[0]);
1559 area
= ospf_area_get (ospf
, area_id
, format
);
1561 if (strncmp (argv
[1], "de", 2) == 0)
1562 mode
= OSPF_SHORTCUT_DEFAULT
;
1563 else if (strncmp (argv
[1], "di", 2) == 0)
1564 mode
= OSPF_SHORTCUT_DISABLE
;
1565 else if (strncmp (argv
[1], "e", 1) == 0)
1566 mode
= OSPF_SHORTCUT_ENABLE
;
1570 ospf_area_shortcut_set (ospf
, area
, mode
);
1572 if (ospf
->abr_type
!= OSPF_ABR_SHORTCUT
)
1573 vty_out (vty
, "Shortcut area setting will take effect "
1574 "only when the router is configured as Shortcut ABR%s",
1580 DEFUN (no_ospf_area_shortcut
,
1581 no_ospf_area_shortcut_cmd
,
1582 "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)",
1584 "OSPF area parameters\n"
1585 "OSPF area ID in IP address format\n"
1586 "OSPF area ID as a decimal value\n"
1587 "Deconfigure the area's shortcutting mode\n"
1588 "Deconfigure enabled shortcutting through the area\n"
1589 "Deconfigure disabled shortcutting through the area\n")
1591 struct ospf
*ospf
= vty
->index
;
1592 struct ospf_area
*area
;
1593 struct in_addr area_id
;
1599 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id
, format
, argv
[0]);
1601 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1605 ospf_area_shortcut_unset (ospf
, area
);
1611 DEFUN (ospf_area_stub
,
1613 "area (A.B.C.D|<0-4294967295>) stub",
1614 "OSPF area parameters\n"
1615 "OSPF area ID in IP address format\n"
1616 "OSPF area ID as a decimal value\n"
1617 "Configure OSPF area as stub\n")
1619 struct ospf
*ospf
= vty
->index
;
1620 struct in_addr area_id
;
1626 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[0]);
1628 ret
= ospf_area_stub_set (ospf
, area_id
);
1631 vty_out (vty
, "First deconfigure all virtual link through this area%s",
1636 ospf_area_no_summary_unset (ospf
, area_id
);
1641 DEFUN (ospf_area_stub_no_summary
,
1642 ospf_area_stub_no_summary_cmd
,
1643 "area (A.B.C.D|<0-4294967295>) stub no-summary",
1644 "OSPF stub parameters\n"
1645 "OSPF area ID in IP address format\n"
1646 "OSPF area ID as a decimal value\n"
1647 "Configure OSPF area as stub\n"
1648 "Do not inject inter-area routes into stub\n")
1650 struct ospf
*ospf
= vty
->index
;
1651 struct in_addr area_id
;
1657 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[0]);
1659 ret
= ospf_area_stub_set (ospf
, area_id
);
1662 vty_out (vty
, "%% Area cannot be stub as it contains a virtual link%s",
1667 ospf_area_no_summary_set (ospf
, area_id
);
1672 DEFUN (no_ospf_area_stub
,
1673 no_ospf_area_stub_cmd
,
1674 "no area (A.B.C.D|<0-4294967295>) stub",
1676 "OSPF area parameters\n"
1677 "OSPF area ID in IP address format\n"
1678 "OSPF area ID as a decimal value\n"
1679 "Configure OSPF area as stub\n")
1681 struct ospf
*ospf
= vty
->index
;
1682 struct in_addr area_id
;
1688 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[0]);
1690 ospf_area_stub_unset (ospf
, area_id
);
1691 ospf_area_no_summary_unset (ospf
, area_id
);
1696 DEFUN (no_ospf_area_stub_no_summary
,
1697 no_ospf_area_stub_no_summary_cmd
,
1698 "no area (A.B.C.D|<0-4294967295>) stub no-summary",
1700 "OSPF area parameters\n"
1701 "OSPF area ID in IP address format\n"
1702 "OSPF area ID as a decimal value\n"
1703 "Configure OSPF area as stub\n"
1704 "Do not inject inter-area routes into area\n")
1706 struct ospf
*ospf
= vty
->index
;
1707 struct in_addr area_id
;
1713 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[0]);
1714 ospf_area_no_summary_unset (ospf
, area_id
);
1720 ospf_area_nssa_cmd_handler (struct vty
*vty
, int argc
, const char *argv
[],
1723 struct ospf
*ospf
= vty
->index
;
1724 struct in_addr area_id
;
1730 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id
, format
, argv
[0]);
1732 ret
= ospf_area_nssa_set (ospf
, area_id
);
1735 vty_out (vty
, "%% Area cannot be nssa as it contains a virtual link%s",
1742 if (strncmp (argv
[1], "translate-c", 11) == 0)
1743 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1744 OSPF_NSSA_ROLE_CANDIDATE
);
1745 else if (strncmp (argv
[1], "translate-n", 11) == 0)
1746 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1747 OSPF_NSSA_ROLE_NEVER
);
1748 else if (strncmp (argv
[1], "translate-a", 11) == 0)
1749 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1750 OSPF_NSSA_ROLE_ALWAYS
);
1754 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1755 OSPF_NSSA_ROLE_CANDIDATE
);
1759 ospf_area_no_summary_set (ospf
, area_id
);
1761 ospf_area_no_summary_unset (ospf
, area_id
);
1763 ospf_schedule_abr_task (ospf
);
1768 DEFUN (ospf_area_nssa_translate_no_summary
,
1769 ospf_area_nssa_translate_no_summary_cmd
,
1770 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary",
1771 "OSPF area parameters\n"
1772 "OSPF area ID in IP address format\n"
1773 "OSPF area ID as a decimal value\n"
1774 "Configure OSPF area as nssa\n"
1775 "Configure NSSA-ABR for translate election (default)\n"
1776 "Configure NSSA-ABR to never translate\n"
1777 "Configure NSSA-ABR to always translate\n"
1778 "Do not inject inter-area routes into nssa\n")
1780 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 1);
1783 DEFUN (ospf_area_nssa_translate
,
1784 ospf_area_nssa_translate_cmd
,
1785 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)",
1786 "OSPF area parameters\n"
1787 "OSPF area ID in IP address format\n"
1788 "OSPF area ID as a decimal value\n"
1789 "Configure OSPF area as nssa\n"
1790 "Configure NSSA-ABR for translate election (default)\n"
1791 "Configure NSSA-ABR to never translate\n"
1792 "Configure NSSA-ABR to always translate\n")
1794 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 0);
1797 DEFUN (ospf_area_nssa
,
1799 "area (A.B.C.D|<0-4294967295>) nssa",
1800 "OSPF area parameters\n"
1801 "OSPF area ID in IP address format\n"
1802 "OSPF area ID as a decimal value\n"
1803 "Configure OSPF area as nssa\n")
1805 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 0);
1808 DEFUN (ospf_area_nssa_no_summary
,
1809 ospf_area_nssa_no_summary_cmd
,
1810 "area (A.B.C.D|<0-4294967295>) nssa no-summary",
1811 "OSPF area parameters\n"
1812 "OSPF area ID in IP address format\n"
1813 "OSPF area ID as a decimal value\n"
1814 "Configure OSPF area as nssa\n"
1815 "Do not inject inter-area routes into nssa\n")
1817 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 1);
1820 DEFUN (no_ospf_area_nssa
,
1821 no_ospf_area_nssa_cmd
,
1822 "no area (A.B.C.D|<0-4294967295>) nssa",
1824 "OSPF area parameters\n"
1825 "OSPF area ID in IP address format\n"
1826 "OSPF area ID as a decimal value\n"
1827 "Configure OSPF area as nssa\n")
1829 struct ospf
*ospf
= vty
->index
;
1830 struct in_addr area_id
;
1836 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id
, format
, argv
[0]);
1838 ospf_area_nssa_unset (ospf
, area_id
);
1839 ospf_area_no_summary_unset (ospf
, area_id
);
1841 ospf_schedule_abr_task (ospf
);
1846 ALIAS (no_ospf_area_nssa
,
1847 no_ospf_area_nssa_no_summary_cmd
,
1848 "no area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always|) {no-summary}",
1850 "OSPF area parameters\n"
1851 "OSPF area ID in IP address format\n"
1852 "OSPF area ID as a decimal value\n"
1853 "Configure OSPF area as nssa\n"
1854 "Configure NSSA-ABR for translate election (default)\n"
1855 "Configure NSSA-ABR to never translate\n"
1856 "Configure NSSA-ABR to always translate\n"
1857 "Do not inject inter-area routes into nssa\n")
1859 DEFUN (ospf_area_default_cost
,
1860 ospf_area_default_cost_cmd
,
1861 "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1862 "OSPF area parameters\n"
1863 "OSPF area ID in IP address format\n"
1864 "OSPF area ID as a decimal value\n"
1865 "Set the summary-default cost of a NSSA or stub area\n"
1866 "Stub's advertised default summary cost\n")
1868 struct ospf
*ospf
= vty
->index
;
1869 struct ospf_area
*area
;
1870 struct in_addr area_id
;
1873 struct prefix_ipv4 p
;
1878 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id
, format
, argv
[0]);
1879 VTY_GET_INTEGER_RANGE ("stub default cost", cost
, argv
[1], 0, 16777215);
1881 area
= ospf_area_get (ospf
, area_id
, format
);
1883 if (area
->external_routing
== OSPF_AREA_DEFAULT
)
1885 vty_out (vty
, "The area is neither stub, nor NSSA%s", VTY_NEWLINE
);
1889 area
->default_cost
= cost
;
1892 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1894 if (IS_DEBUG_OSPF_EVENT
)
1895 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1896 "announcing 0.0.0.0/0 to area %s",
1897 inet_ntoa (area
->area_id
));
1898 ospf_abr_announce_network_to_area (&p
, area
->default_cost
, area
);
1903 DEFUN (no_ospf_area_default_cost
,
1904 no_ospf_area_default_cost_cmd
,
1905 "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1907 "OSPF area parameters\n"
1908 "OSPF area ID in IP address format\n"
1909 "OSPF area ID as a decimal value\n"
1910 "Set the summary-default cost of a NSSA or stub area\n"
1911 "Stub's advertised default summary cost\n")
1913 struct ospf
*ospf
= vty
->index
;
1914 struct ospf_area
*area
;
1915 struct in_addr area_id
;
1917 struct prefix_ipv4 p
;
1922 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id
, format
, argv
[0]);
1923 VTY_CHECK_INTEGER_RANGE ("stub default cost", argv
[1], 0, OSPF_LS_INFINITY
);
1925 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1929 if (area
->external_routing
== OSPF_AREA_DEFAULT
)
1931 vty_out (vty
, "The area is neither stub, nor NSSA%s", VTY_NEWLINE
);
1935 area
->default_cost
= 1;
1938 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1940 if (IS_DEBUG_OSPF_EVENT
)
1941 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1942 "announcing 0.0.0.0/0 to area %s",
1943 inet_ntoa (area
->area_id
));
1944 ospf_abr_announce_network_to_area (&p
, area
->default_cost
, area
);
1947 ospf_area_check_free (ospf
, area_id
);
1952 DEFUN (ospf_area_export_list
,
1953 ospf_area_export_list_cmd
,
1954 "area (A.B.C.D|<0-4294967295>) export-list NAME",
1955 "OSPF area parameters\n"
1956 "OSPF area ID in IP address format\n"
1957 "OSPF area ID as a decimal value\n"
1958 "Set the filter for networks announced to other areas\n"
1959 "Name of the access-list\n")
1961 struct ospf
*ospf
= vty
->index
;
1962 struct ospf_area
*area
;
1963 struct in_addr area_id
;
1969 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
1971 area
= ospf_area_get (ospf
, area_id
, format
);
1972 ospf_area_export_list_set (ospf
, area
, argv
[1]);
1977 DEFUN (no_ospf_area_export_list
,
1978 no_ospf_area_export_list_cmd
,
1979 "no area (A.B.C.D|<0-4294967295>) export-list NAME",
1981 "OSPF area parameters\n"
1982 "OSPF area ID in IP address format\n"
1983 "OSPF area ID as a decimal value\n"
1984 "Unset the filter for networks announced to other areas\n"
1985 "Name of the access-list\n")
1987 struct ospf
*ospf
= vty
->index
;
1988 struct ospf_area
*area
;
1989 struct in_addr area_id
;
1995 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
1997 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
2001 ospf_area_export_list_unset (ospf
, area
);
2007 DEFUN (ospf_area_import_list
,
2008 ospf_area_import_list_cmd
,
2009 "area (A.B.C.D|<0-4294967295>) import-list NAME",
2010 "OSPF area parameters\n"
2011 "OSPF area ID in IP address format\n"
2012 "OSPF area ID as a decimal value\n"
2013 "Set the filter for networks from other areas announced to the specified one\n"
2014 "Name of the access-list\n")
2016 struct ospf
*ospf
= vty
->index
;
2017 struct ospf_area
*area
;
2018 struct in_addr area_id
;
2024 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
2026 area
= ospf_area_get (ospf
, area_id
, format
);
2027 ospf_area_import_list_set (ospf
, area
, argv
[1]);
2032 DEFUN (no_ospf_area_import_list
,
2033 no_ospf_area_import_list_cmd
,
2034 "no area (A.B.C.D|<0-4294967295>) import-list NAME",
2036 "OSPF area parameters\n"
2037 "OSPF area ID in IP address format\n"
2038 "OSPF area ID as a decimal value\n"
2039 "Unset the filter for networks announced to other areas\n"
2040 "Name of the access-list\n")
2042 struct ospf
*ospf
= vty
->index
;
2043 struct ospf_area
*area
;
2044 struct in_addr area_id
;
2050 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
2052 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
2056 ospf_area_import_list_unset (ospf
, area
);
2061 DEFUN (ospf_area_filter_list
,
2062 ospf_area_filter_list_cmd
,
2063 "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
2064 "OSPF area parameters\n"
2065 "OSPF area ID in IP address format\n"
2066 "OSPF area ID as a decimal value\n"
2067 "Filter networks between OSPF areas\n"
2068 "Filter prefixes between OSPF areas\n"
2069 "Name of an IP prefix-list\n"
2070 "Filter networks sent to this area\n"
2071 "Filter networks sent from this area\n")
2073 struct ospf
*ospf
= vty
->index
;
2074 struct ospf_area
*area
;
2075 struct in_addr area_id
;
2076 struct prefix_list
*plist
;
2082 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
2084 area
= ospf_area_get (ospf
, area_id
, format
);
2085 plist
= prefix_list_lookup (AFI_IP
, argv
[1]);
2086 if (strncmp (argv
[2], "in", 2) == 0)
2088 PREFIX_LIST_IN (area
) = plist
;
2089 if (PREFIX_NAME_IN (area
))
2090 free (PREFIX_NAME_IN (area
));
2092 PREFIX_NAME_IN (area
) = strdup (argv
[1]);
2093 ospf_schedule_abr_task (ospf
);
2097 PREFIX_LIST_OUT (area
) = plist
;
2098 if (PREFIX_NAME_OUT (area
))
2099 free (PREFIX_NAME_OUT (area
));
2101 PREFIX_NAME_OUT (area
) = strdup (argv
[1]);
2102 ospf_schedule_abr_task (ospf
);
2108 DEFUN (no_ospf_area_filter_list
,
2109 no_ospf_area_filter_list_cmd
,
2110 "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
2112 "OSPF area parameters\n"
2113 "OSPF area ID in IP address format\n"
2114 "OSPF area ID as a decimal value\n"
2115 "Filter networks between OSPF areas\n"
2116 "Filter prefixes between OSPF areas\n"
2117 "Name of an IP prefix-list\n"
2118 "Filter networks sent to this area\n"
2119 "Filter networks sent from this area\n")
2121 struct ospf
*ospf
= vty
->index
;
2122 struct ospf_area
*area
;
2123 struct in_addr area_id
;
2129 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
2131 if ((area
= ospf_area_lookup_by_area_id (ospf
, area_id
)) == NULL
)
2134 if (strncmp (argv
[2], "in", 2) == 0)
2136 if (PREFIX_NAME_IN (area
))
2137 if (strcmp (PREFIX_NAME_IN (area
), argv
[1]) != 0)
2140 PREFIX_LIST_IN (area
) = NULL
;
2141 if (PREFIX_NAME_IN (area
))
2142 free (PREFIX_NAME_IN (area
));
2144 PREFIX_NAME_IN (area
) = NULL
;
2146 ospf_schedule_abr_task (ospf
);
2150 if (PREFIX_NAME_OUT (area
))
2151 if (strcmp (PREFIX_NAME_OUT (area
), argv
[1]) != 0)
2154 PREFIX_LIST_OUT (area
) = NULL
;
2155 if (PREFIX_NAME_OUT (area
))
2156 free (PREFIX_NAME_OUT (area
));
2158 PREFIX_NAME_OUT (area
) = NULL
;
2160 ospf_schedule_abr_task (ospf
);
2167 DEFUN (ospf_area_authentication_message_digest
,
2168 ospf_area_authentication_message_digest_cmd
,
2169 "area (A.B.C.D|<0-4294967295>) authentication message-digest",
2170 "OSPF area parameters\n"
2171 "OSPF area ID in IP address format\n"
2172 "OSPF area ID as a decimal value\n"
2173 "Enable authentication\n"
2174 "Use message-digest authentication\n")
2176 struct ospf
*ospf
= vty
->index
;
2177 struct ospf_area
*area
;
2178 struct in_addr area_id
;
2184 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
2186 area
= ospf_area_get (ospf
, area_id
, format
);
2187 area
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
2192 DEFUN (ospf_area_authentication
,
2193 ospf_area_authentication_cmd
,
2194 "area (A.B.C.D|<0-4294967295>) authentication",
2195 "OSPF area parameters\n"
2196 "OSPF area ID in IP address format\n"
2197 "OSPF area ID as a decimal value\n"
2198 "Enable authentication\n")
2200 struct ospf
*ospf
= vty
->index
;
2201 struct ospf_area
*area
;
2202 struct in_addr area_id
;
2208 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
2210 area
= ospf_area_get (ospf
, area_id
, format
);
2211 area
->auth_type
= OSPF_AUTH_SIMPLE
;
2216 DEFUN (no_ospf_area_authentication
,
2217 no_ospf_area_authentication_cmd
,
2218 "no area (A.B.C.D|<0-4294967295>) authentication",
2220 "OSPF area parameters\n"
2221 "OSPF area ID in IP address format\n"
2222 "OSPF area ID as a decimal value\n"
2223 "Enable authentication\n")
2225 struct ospf
*ospf
= vty
->index
;
2226 struct ospf_area
*area
;
2227 struct in_addr area_id
;
2233 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
2235 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
2239 area
->auth_type
= OSPF_AUTH_NULL
;
2241 ospf_area_check_free (ospf
, area_id
);
2247 DEFUN (ospf_abr_type
,
2249 "ospf abr-type (cisco|ibm|shortcut|standard)",
2250 "OSPF specific commands\n"
2251 "Set OSPF ABR type\n"
2252 "Alternative ABR, cisco implementation\n"
2253 "Alternative ABR, IBM implementation\n"
2255 "Standard behavior (RFC2328)\n")
2257 struct ospf
*ospf
= vty
->index
;
2258 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2263 if (strncmp (argv
[0], "c", 1) == 0)
2264 abr_type
= OSPF_ABR_CISCO
;
2265 else if (strncmp (argv
[0], "i", 1) == 0)
2266 abr_type
= OSPF_ABR_IBM
;
2267 else if (strncmp (argv
[0], "sh", 2) == 0)
2268 abr_type
= OSPF_ABR_SHORTCUT
;
2269 else if (strncmp (argv
[0], "st", 2) == 0)
2270 abr_type
= OSPF_ABR_STAND
;
2274 /* If ABR type value is changed, schedule ABR task. */
2275 if (ospf
->abr_type
!= abr_type
)
2277 ospf
->abr_type
= abr_type
;
2278 ospf_schedule_abr_task (ospf
);
2284 DEFUN (no_ospf_abr_type
,
2285 no_ospf_abr_type_cmd
,
2286 "no ospf abr-type (cisco|ibm|shortcut|standard)",
2288 "OSPF specific commands\n"
2289 "Set OSPF ABR type\n"
2290 "Alternative ABR, cisco implementation\n"
2291 "Alternative ABR, IBM implementation\n"
2294 struct ospf
*ospf
= vty
->index
;
2295 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2300 if (strncmp (argv
[0], "c", 1) == 0)
2301 abr_type
= OSPF_ABR_CISCO
;
2302 else if (strncmp (argv
[0], "i", 1) == 0)
2303 abr_type
= OSPF_ABR_IBM
;
2304 else if (strncmp (argv
[0], "sh", 2) == 0)
2305 abr_type
= OSPF_ABR_SHORTCUT
;
2306 else if (strncmp (argv
[0], "st", 2) == 0)
2307 abr_type
= OSPF_ABR_STAND
;
2311 /* If ABR type value is changed, schedule ABR task. */
2312 if (ospf
->abr_type
== abr_type
)
2314 ospf
->abr_type
= OSPF_ABR_DEFAULT
;
2315 ospf_schedule_abr_task (ospf
);
2321 DEFUN (ospf_log_adjacency_changes
,
2322 ospf_log_adjacency_changes_cmd
,
2323 "log-adjacency-changes",
2324 "Log changes in adjacency state\n")
2326 struct ospf
*ospf
= vty
->index
;
2331 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2332 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2336 DEFUN (ospf_log_adjacency_changes_detail
,
2337 ospf_log_adjacency_changes_detail_cmd
,
2338 "log-adjacency-changes detail",
2339 "Log changes in adjacency state\n"
2340 "Log all state changes\n")
2342 struct ospf
*ospf
= vty
->index
;
2347 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2348 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2352 DEFUN (no_ospf_log_adjacency_changes
,
2353 no_ospf_log_adjacency_changes_cmd
,
2354 "no log-adjacency-changes",
2356 "Log changes in adjacency state\n")
2358 struct ospf
*ospf
= vty
->index
;
2363 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2364 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2368 DEFUN (no_ospf_log_adjacency_changes_detail
,
2369 no_ospf_log_adjacency_changes_detail_cmd
,
2370 "no log-adjacency-changes detail",
2372 "Log changes in adjacency state\n"
2373 "Log all state changes\n")
2375 struct ospf
*ospf
= vty
->index
;
2380 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2381 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2385 DEFUN (ospf_compatible_rfc1583
,
2386 ospf_compatible_rfc1583_cmd
,
2387 "compatible rfc1583",
2388 "OSPF compatibility list\n"
2389 "compatible with RFC 1583\n")
2391 struct ospf
*ospf
= vty
->index
;
2396 if (!CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
2398 SET_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2399 ospf_spf_calculate_schedule (ospf
);
2404 DEFUN (no_ospf_compatible_rfc1583
,
2405 no_ospf_compatible_rfc1583_cmd
,
2406 "no compatible rfc1583",
2408 "OSPF compatibility list\n"
2409 "compatible with RFC 1583\n")
2411 struct ospf
*ospf
= vty
->index
;
2416 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
2418 UNSET_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2419 ospf_spf_calculate_schedule (ospf
);
2424 ALIAS (ospf_compatible_rfc1583
,
2425 ospf_rfc1583_flag_cmd
,
2426 "ospf rfc1583compatibility",
2427 "OSPF specific commands\n"
2428 "Enable the RFC1583Compatibility flag\n")
2430 ALIAS (no_ospf_compatible_rfc1583
,
2431 no_ospf_rfc1583_flag_cmd
,
2432 "no ospf rfc1583compatibility",
2434 "OSPF specific commands\n"
2435 "Disable the RFC1583Compatibility flag\n")
2438 ospf_timers_spf_set (struct vty
*vty
, unsigned int delay
,
2442 struct ospf
*ospf
= vty
->index
;
2447 ospf
->spf_delay
= delay
;
2448 ospf
->spf_holdtime
= hold
;
2449 ospf
->spf_max_holdtime
= max
;
2454 DEFUN (ospf_timers_min_ls_interval
,
2455 ospf_timers_min_ls_interval_cmd
,
2456 "timers throttle lsa all <0-5000>",
2457 "Adjust routing timers\n"
2458 "Throttling adaptive timer\n"
2459 "LSA delay between transmissions\n"
2461 "Delay (msec) between sending LSAs\n")
2463 struct ospf
*ospf
= vty
->index
;
2464 unsigned int interval
;
2468 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2472 VTY_GET_INTEGER ("LSA interval", interval
, argv
[0]);
2474 ospf
->min_ls_interval
= interval
;
2479 DEFUN (no_ospf_timers_min_ls_interval
,
2480 no_ospf_timers_min_ls_interval_cmd
,
2481 "no timers throttle lsa all",
2483 "Adjust routing timers\n"
2484 "Throttling adaptive timer\n"
2485 "LSA delay between transmissions\n"
2488 struct ospf
*ospf
= vty
->index
;
2489 ospf
->min_ls_interval
= OSPF_MIN_LS_INTERVAL
;
2494 ALIAS (no_ospf_timers_min_ls_interval
,
2495 no_ospf_timers_min_ls_interval_val_cmd
,
2496 "no timers throttle lsa all <0-5000>",
2498 "Adjust routing timers\n"
2499 "Throttling adaptive timer\n"
2500 "LSA delay between transmissions\n"
2502 "Delay (msec) between sending LSAs\n")
2504 DEFUN (ospf_timers_min_ls_arrival
,
2505 ospf_timers_min_ls_arrival_cmd
,
2506 "timers lsa arrival <0-1000>",
2507 "Adjust routing timers\n"
2508 "Throttling link state advertisement delays\n"
2509 "OSPF minimum arrival interval delay\n"
2510 "Delay (msec) between accepted LSAs\n")
2512 struct ospf
*ospf
= vty
->index
;
2513 unsigned int arrival
;
2517 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2521 VTY_GET_INTEGER_RANGE ("minimum LSA inter-arrival time", arrival
, argv
[0], 0, 1000);
2523 ospf
->min_ls_arrival
= arrival
;
2528 DEFUN (no_ospf_timers_min_ls_arrival
,
2529 no_ospf_timers_min_ls_arrival_cmd
,
2530 "no timers lsa arrival",
2532 "Adjust routing timers\n"
2533 "Throttling link state advertisement delays\n"
2534 "OSPF minimum arrival interval delay\n")
2536 struct ospf
*ospf
= vty
->index
;
2537 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2542 ALIAS (no_ospf_timers_min_ls_arrival
,
2543 no_ospf_timers_min_ls_arrival_val_cmd
,
2544 "no timers lsa arrival <0-1000>",
2546 "Adjust routing timers\n"
2547 "Throttling link state advertisement delays\n"
2548 "OSPF minimum arrival interval delay\n"
2549 "Delay (msec) between accepted LSAs\n")
2551 DEFUN (ospf_timers_throttle_spf
,
2552 ospf_timers_throttle_spf_cmd
,
2553 "timers throttle spf <0-600000> <0-600000> <0-600000>",
2554 "Adjust routing timers\n"
2555 "Throttling adaptive timer\n"
2557 "Delay (msec) from first change received till SPF calculation\n"
2558 "Initial hold time (msec) between consecutive SPF calculations\n"
2559 "Maximum hold time (msec)\n")
2561 unsigned int delay
, hold
, max
;
2565 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2569 VTY_GET_INTEGER_RANGE ("SPF delay timer", delay
, argv
[0], 0, 600000);
2570 VTY_GET_INTEGER_RANGE ("SPF hold timer", hold
, argv
[1], 0, 600000);
2571 VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max
, argv
[2], 0, 600000);
2573 return ospf_timers_spf_set (vty
, delay
, hold
, max
);
2576 DEFUN (no_ospf_timers_throttle_spf
,
2577 no_ospf_timers_throttle_spf_cmd
,
2578 "no timers throttle spf",
2580 "Adjust routing timers\n"
2581 "Throttling adaptive timer\n"
2582 "OSPF SPF timers\n")
2584 return ospf_timers_spf_set (vty
,
2585 OSPF_SPF_DELAY_DEFAULT
,
2586 OSPF_SPF_HOLDTIME_DEFAULT
,
2587 OSPF_SPF_MAX_HOLDTIME_DEFAULT
);
2590 ALIAS (no_ospf_timers_throttle_spf
,
2591 no_ospf_timers_throttle_spf_val_cmd
,
2592 "no timers throttle spf <0-600000> <0-600000> <0-600000>",
2594 "Adjust routing timers\n"
2595 "Throttling adaptive timer\n"
2597 "Delay (msec) from first change received till SPF calculation\n"
2598 "Initial hold time (msec) between consecutive SPF calculations\n"
2599 "Maximum hold time (msec)\n")
2601 DEFUN (ospf_timers_lsa
,
2602 ospf_timers_lsa_cmd
,
2603 "timers lsa min-arrival <0-600000>",
2604 "Adjust routing timers\n"
2606 "Minimum delay in receiving new version of a LSA\n"
2607 "Delay in milliseconds\n")
2609 unsigned int minarrival
;
2610 struct ospf
*ospf
= vty
->index
;
2617 vty_out (vty
, "Insufficient number of arguments%s", VTY_NEWLINE
);
2621 VTY_GET_INTEGER ("LSA min-arrival", minarrival
, argv
[0]);
2623 ospf
->min_ls_arrival
= minarrival
;
2628 DEFUN (no_ospf_timers_lsa
,
2629 no_ospf_timers_lsa_cmd
,
2630 "no timers lsa min-arrival",
2632 "Adjust routing timers\n"
2634 "Minimum delay in receiving new version of a LSA\n")
2636 unsigned int minarrival
;
2637 struct ospf
*ospf
= vty
->index
;
2644 VTY_GET_INTEGER ("LSA min-arrival", minarrival
, argv
[0]);
2646 if (ospf
->min_ls_arrival
!= minarrival
||
2647 minarrival
== OSPF_MIN_LS_ARRIVAL
)
2651 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2656 ALIAS (no_ospf_timers_lsa
,
2657 no_ospf_timers_lsa_val_cmd
,
2658 "no timers lsa min-arrival <0-600000>",
2660 "Adjust routing timers\n"
2662 "Minimum delay in receiving new version of a LSA\n"
2663 "Delay in milliseconds\n")
2666 DEFUN (ospf_neighbor
,
2670 "Neighbor IP address\n")
2672 struct ospf
*ospf
= vty
->index
;
2673 struct in_addr nbr_addr
;
2674 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2675 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2680 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[0]);
2683 VTY_GET_INTEGER_RANGE ("neighbor priority", priority
, argv
[1], 0, 255);
2686 VTY_GET_INTEGER_RANGE ("poll interval", interval
, argv
[2], 1, 65535);
2688 ospf_nbr_nbma_set (ospf
, nbr_addr
);
2690 ospf_nbr_nbma_priority_set (ospf
, nbr_addr
, priority
);
2692 ospf_nbr_nbma_poll_interval_set (ospf
, nbr_addr
, interval
);
2697 ALIAS (ospf_neighbor
,
2698 ospf_neighbor_priority_poll_interval_cmd
,
2699 "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2701 "Neighbor IP address\n"
2702 "Neighbor Priority\n"
2704 "Dead Neighbor Polling interval\n"
2707 ALIAS (ospf_neighbor
,
2708 ospf_neighbor_priority_cmd
,
2709 "neighbor A.B.C.D priority <0-255>",
2711 "Neighbor IP address\n"
2712 "Neighbor Priority\n"
2715 DEFUN (ospf_neighbor_poll_interval
,
2716 ospf_neighbor_poll_interval_cmd
,
2717 "neighbor A.B.C.D poll-interval <1-65535>",
2719 "Neighbor IP address\n"
2720 "Dead Neighbor Polling interval\n"
2723 struct ospf
*ospf
= vty
->index
;
2724 struct in_addr nbr_addr
;
2725 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2726 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2731 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[0]);
2734 VTY_GET_INTEGER_RANGE ("poll interval", interval
, argv
[1], 1, 65535);
2737 VTY_GET_INTEGER_RANGE ("neighbor priority", priority
, argv
[2], 0, 255);
2739 ospf_nbr_nbma_set (ospf
, nbr_addr
);
2741 ospf_nbr_nbma_poll_interval_set (ospf
, nbr_addr
, interval
);
2743 ospf_nbr_nbma_priority_set (ospf
, nbr_addr
, priority
);
2748 ALIAS (ospf_neighbor_poll_interval
,
2749 ospf_neighbor_poll_interval_priority_cmd
,
2750 "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2752 "Neighbor address\n"
2753 "OSPF dead-router polling interval\n"
2755 "OSPF priority of non-broadcast neighbor\n"
2758 DEFUN (no_ospf_neighbor
,
2759 no_ospf_neighbor_cmd
,
2760 "no neighbor A.B.C.D",
2763 "Neighbor IP address\n")
2765 struct ospf
*ospf
= vty
->index
;
2766 struct in_addr nbr_addr
;
2771 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[0]);
2773 (void)ospf_nbr_nbma_unset (ospf
, nbr_addr
);
2778 ALIAS (no_ospf_neighbor
,
2779 no_ospf_neighbor_priority_cmd
,
2780 "no neighbor A.B.C.D priority <0-255>",
2783 "Neighbor IP address\n"
2784 "Neighbor Priority\n"
2787 ALIAS (no_ospf_neighbor
,
2788 no_ospf_neighbor_poll_interval_cmd
,
2789 "no neighbor A.B.C.D poll-interval <1-65535>",
2792 "Neighbor IP address\n"
2793 "Dead Neighbor Polling interval\n"
2796 ALIAS (no_ospf_neighbor
,
2797 no_ospf_neighbor_poll_interval_priority_cmd
,
2798 "no neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2801 "Neighbor IP address\n"
2802 "Dead Neighbor Polling interval\n"
2804 "OSPF priority of non-broadcast neighbor\n"
2807 ALIAS (no_ospf_neighbor
,
2808 no_ospf_neighbor_priority_pollinterval_cmd
,
2809 "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2812 "Neighbor IP address\n"
2813 "Neighbor Priority\n"
2815 "Dead Neighbor Polling interval\n"
2818 DEFUN (ospf_refresh_timer
, ospf_refresh_timer_cmd
,
2819 "refresh timer <10-1800>",
2820 "Adjust refresh parameters\n"
2821 "Set refresh timer\n"
2822 "Timer value in seconds\n")
2824 struct ospf
*ospf
= vty
->index
;
2825 unsigned int interval
;
2830 VTY_GET_INTEGER_RANGE ("refresh timer", interval
, argv
[0], 10, 1800);
2831 interval
= (interval
/ 10) * 10;
2833 ospf_timers_refresh_set (ospf
, interval
);
2838 DEFUN (no_ospf_refresh_timer
, no_ospf_refresh_timer_val_cmd
,
2839 "no refresh timer <10-1800>",
2840 "Adjust refresh parameters\n"
2841 "Unset refresh timer\n"
2842 "Timer value in seconds\n")
2844 struct ospf
*ospf
= vty
->index
;
2845 unsigned int interval
;
2852 VTY_GET_INTEGER_RANGE ("refresh timer", interval
, argv
[0], 10, 1800);
2854 if (ospf
->lsa_refresh_interval
!= interval
||
2855 interval
== OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
2859 ospf_timers_refresh_unset (ospf
);
2864 ALIAS (no_ospf_refresh_timer
,
2865 no_ospf_refresh_timer_cmd
,
2867 "Adjust refresh parameters\n"
2868 "Unset refresh timer\n")
2870 DEFUN (ospf_auto_cost_reference_bandwidth
,
2871 ospf_auto_cost_reference_bandwidth_cmd
,
2872 "auto-cost reference-bandwidth <1-4294967>",
2873 "Calculate OSPF interface cost according to bandwidth\n"
2874 "Use reference bandwidth method to assign OSPF cost\n"
2875 "The reference bandwidth in terms of Mbits per second\n")
2877 struct ospf
*ospf
= vty
->index
;
2879 struct listnode
*node
;
2880 struct interface
*ifp
;
2885 refbw
= strtol (argv
[0], NULL
, 10);
2886 if (refbw
< 1 || refbw
> 4294967)
2888 vty_out (vty
, "reference-bandwidth value is invalid%s", VTY_NEWLINE
);
2892 /* If reference bandwidth is changed. */
2893 if ((refbw
* 1000) == ospf
->ref_bandwidth
)
2896 ospf
->ref_bandwidth
= refbw
* 1000;
2897 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, node
, ifp
))
2898 ospf_if_recalculate_output_cost (ifp
);
2903 DEFUN (no_ospf_auto_cost_reference_bandwidth
,
2904 no_ospf_auto_cost_reference_bandwidth_cmd
,
2905 "no auto-cost reference-bandwidth",
2907 "Calculate OSPF interface cost according to bandwidth\n"
2908 "Use reference bandwidth method to assign OSPF cost\n")
2910 struct ospf
*ospf
= vty
->index
;
2911 struct listnode
*node
, *nnode
;
2912 struct interface
*ifp
;
2917 if (ospf
->ref_bandwidth
== OSPF_DEFAULT_REF_BANDWIDTH
)
2920 ospf
->ref_bandwidth
= OSPF_DEFAULT_REF_BANDWIDTH
;
2921 vty_out (vty
, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE
);
2922 vty_out (vty
, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE
);
2924 for (ALL_LIST_ELEMENTS (om
->iflist
, node
, nnode
, ifp
))
2925 ospf_if_recalculate_output_cost (ifp
);
2930 ALIAS (no_ospf_auto_cost_reference_bandwidth
,
2931 no_ospf_auto_cost_reference_bandwidth_val_cmd
,
2932 "no auto-cost reference-bandwidth <1-4294967>",
2934 "Calculate OSPF interface cost according to bandwidth\n"
2935 "Use reference bandwidth method to assign OSPF cost\n"
2936 "The reference bandwidth in terms of Mbits per second\n")
2938 DEFUN (ospf_write_multiplier
,
2939 ospf_write_multiplier_cmd
,
2940 "ospf write-multiplier <1-100>",
2941 "OSPF specific commands\n"
2942 "Write multiplier\n"
2943 "Maximum number of interface serviced per write\n")
2945 struct ospf
*ospf
= vty
->index
;
2946 u_int32_t write_oi_count
;
2951 write_oi_count
= strtol (argv
[0], NULL
, 10);
2952 if (write_oi_count
< 1 || write_oi_count
> 100)
2954 vty_out (vty
, "write-multiplier value is invalid%s", VTY_NEWLINE
);
2958 ospf
->write_oi_count
= write_oi_count
;
2962 ALIAS (ospf_write_multiplier
,
2963 write_multiplier_cmd
,
2964 "write-multiplier <1-100>",
2965 "Write multiplier\n"
2966 "Maximum number of interface serviced per write\n")
2968 DEFUN (no_ospf_write_multiplier
,
2969 no_ospf_write_multiplier_cmd
,
2970 "no ospf write-multiplier <1-100>",
2972 "OSPF specific commands\n"
2973 "Write multiplier\n"
2974 "Maximum number of interface serviced per write\n")
2976 struct ospf
*ospf
= vty
->index
;
2981 ospf
->write_oi_count
= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
;
2985 ALIAS (no_ospf_write_multiplier
,
2986 no_write_multiplier_cmd
,
2987 "no write-multiplier",
2989 "Write multiplier\n")
2991 ALIAS (no_ospf_write_multiplier
,
2992 no_write_multiplier_val_cmd
,
2993 "no write-multiplier <1-100>",
2995 "Write multiplier\n"
2996 "Maximum number of interface serviced per write\n")
2998 const char *ospf_abr_type_descr_str
[] =
3001 "Standard (RFC2328)",
3003 "Alternative Cisco",
3004 "Alternative Shortcut"
3007 const char *ospf_shortcut_mode_descr_str
[] =
3015 show_ip_ospf_area (struct vty
*vty
, struct ospf_area
*area
, json_object
*json_areas
, u_char use_json
)
3017 json_object
*json_area
= NULL
;
3020 json_area
= json_object_new_object();
3024 vty_out (vty
, " Area ID: %s", inet_ntoa (area
->area_id
));
3026 /* Show Area type/mode. */
3027 if (OSPF_IS_AREA_BACKBONE (area
))
3030 json_object_boolean_true_add(json_area
, "backbone");
3032 vty_out (vty
, " (Backbone)%s", VTY_NEWLINE
);
3038 if (area
->external_routing
== OSPF_AREA_STUB
)
3040 if (area
->no_summary
)
3041 json_object_boolean_true_add(json_area
, "stubNoSummary");
3042 if (area
->shortcut_configured
)
3043 json_object_boolean_true_add(json_area
, "stubShortcut");
3045 else if (area
->external_routing
== OSPF_AREA_NSSA
)
3047 if (area
->no_summary
)
3048 json_object_boolean_true_add(json_area
, "nssaNoSummary");
3049 if (area
->shortcut_configured
)
3050 json_object_boolean_true_add(json_area
, "nssaShortcut");
3053 json_object_string_add(json_area
,"shortcuttingMode",
3054 ospf_shortcut_mode_descr_str
[area
->shortcut_configured
]);
3055 if (area
->shortcut_capability
)
3056 json_object_boolean_true_add(json_area
,"sBitConcensus");
3060 if (area
->external_routing
== OSPF_AREA_STUB
)
3061 vty_out (vty
, " (Stub%s%s)",
3062 area
->no_summary
? ", no summary" : "",
3063 area
->shortcut_configured
? "; " : "");
3064 else if (area
->external_routing
== OSPF_AREA_NSSA
)
3065 vty_out (vty
, " (NSSA%s%s)",
3066 area
->no_summary
? ", no summary" : "",
3067 area
->shortcut_configured
? "; " : "");
3069 vty_out (vty
, "%s", VTY_NEWLINE
);
3070 vty_out (vty
, " Shortcutting mode: %s",
3071 ospf_shortcut_mode_descr_str
[area
->shortcut_configured
]);
3072 vty_out (vty
, ", S-bit consensus: %s%s",
3073 area
->shortcut_capability
? "ok" : "no", VTY_NEWLINE
);
3077 /* Show number of interfaces */
3080 json_object_int_add(json_area
, "areaIfTotalCounter", listcount (area
->oiflist
));
3081 json_object_int_add(json_area
, "areaIfActiveCounter", area
->act_ints
);
3084 vty_out (vty
, " Number of interfaces in this area: Total: %d, "
3085 "Active: %d%s", listcount (area
->oiflist
),
3086 area
->act_ints
, VTY_NEWLINE
);
3088 if (area
->external_routing
== OSPF_AREA_NSSA
)
3092 json_object_boolean_true_add(json_area
, "nssa");
3093 if (! IS_OSPF_ABR (area
->ospf
))
3094 json_object_boolean_false_add(json_area
, "abr");
3095 else if (area
->NSSATranslatorState
)
3097 json_object_boolean_true_add(json_area
, "abr");
3098 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
3099 json_object_boolean_true_add(json_area
, "nssaTranslatorElected");
3100 else if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_ALWAYS
)
3101 json_object_boolean_true_add(json_area
, "nssaTranslatorAlways");
3105 json_object_boolean_true_add(json_area
, "abr");
3106 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
3107 json_object_boolean_false_add(json_area
, "nssaTranslatorElected");
3109 json_object_boolean_true_add(json_area
, "nssaTranslatorNever");
3114 vty_out (vty
, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE
, VTY_NEWLINE
);
3115 if (! IS_OSPF_ABR (area
->ospf
))
3116 vty_out (vty
, " It is not ABR, therefore not Translator. %s",
3118 else if (area
->NSSATranslatorState
)
3120 vty_out (vty
, " We are an ABR and ");
3121 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
3122 vty_out (vty
, "the NSSA Elected Translator. %s",
3124 else if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_ALWAYS
)
3125 vty_out (vty
, "always an NSSA Translator. %s",
3130 vty_out (vty
, " We are an ABR, but ");
3131 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
3132 vty_out (vty
, "not the NSSA Elected Translator. %s",
3135 vty_out (vty
, "never an NSSA Translator. %s",
3141 /* Stub-router state for this area */
3142 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
))
3144 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3148 json_object_boolean_true_add(json_area
, "originStubMaxDistRouterLsa");
3149 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
3150 json_object_boolean_true_add(json_area
, "indefiniteActiveAdmin");
3151 if (area
->t_stub_router
)
3153 struct timeval result
;
3154 unsigned long time_store
= 0;
3155 result
= tv_sub (area
->t_stub_router
->u
.sands
, recent_relative_time());
3156 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3157 json_object_int_add(json_area
, "activeStartupRemainderMsecs", time_store
);
3162 vty_out (vty
, " Originating stub / maximum-distance Router-LSA%s",
3164 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
3165 vty_out (vty
, " Administratively activated (indefinitely)%s",
3167 if (area
->t_stub_router
)
3168 vty_out (vty
, " Active from startup, %s remaining%s",
3169 ospf_timer_dump (area
->t_stub_router
, timebuf
,
3170 sizeof(timebuf
)), VTY_NEWLINE
);
3176 /* Show number of fully adjacent neighbors. */
3177 json_object_int_add(json_area
, "nbrFullAdjacentCounter", area
->full_nbrs
);
3179 /* Show authentication type. */
3180 if (area
->auth_type
== OSPF_AUTH_NULL
)
3181 json_object_string_add(json_area
, "authentication", "authenticationNone");
3182 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
3183 json_object_string_add(json_area
, "authentication", "authenticationSimplePassword");
3184 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
3185 json_object_string_add(json_area
, "authentication", "authenticationMessageDigest");
3187 if (!OSPF_IS_AREA_BACKBONE (area
))
3188 json_object_int_add(json_area
, "virtualAdjacenciesPassingCounter", area
->full_vls
);
3190 /* Show SPF calculation times. */
3191 json_object_int_add(json_area
, "spfExecutedCounter", area
->spf_calculation
);
3192 json_object_int_add(json_area
, "lsaNumber", area
->lsdb
->total
);
3193 json_object_int_add(json_area
, "lsaRouterNumber", ospf_lsdb_count (area
->lsdb
, OSPF_ROUTER_LSA
));
3194 json_object_int_add(json_area
, "lsaRouterChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_ROUTER_LSA
));
3195 json_object_int_add(json_area
, "lsaNetworkNumber", ospf_lsdb_count (area
->lsdb
, OSPF_NETWORK_LSA
));
3196 json_object_int_add(json_area
, "lsaNetworkChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_NETWORK_LSA
));
3197 json_object_int_add(json_area
, "lsaSummaryNumber", ospf_lsdb_count (area
->lsdb
, OSPF_SUMMARY_LSA
));
3198 json_object_int_add(json_area
, "lsaSummaryChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_SUMMARY_LSA
));
3199 json_object_int_add(json_area
, "lsaAsbrNumber", ospf_lsdb_count (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
3200 json_object_int_add(json_area
, "lsaAsbrChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
3201 json_object_int_add(json_area
, "lsaNssaNumber", ospf_lsdb_count (area
->lsdb
, OSPF_AS_NSSA_LSA
));
3202 json_object_int_add(json_area
, "lsaNssaChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_AS_NSSA_LSA
));
3206 /* Show number of fully adjacent neighbors. */
3207 vty_out (vty
, " Number of fully adjacent neighbors in this area:"
3208 " %d%s", area
->full_nbrs
, VTY_NEWLINE
);
3210 /* Show authentication type. */
3211 vty_out (vty
, " Area has ");
3212 if (area
->auth_type
== OSPF_AUTH_NULL
)
3213 vty_out (vty
, "no authentication%s", VTY_NEWLINE
);
3214 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
3215 vty_out (vty
, "simple password authentication%s", VTY_NEWLINE
);
3216 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
3217 vty_out (vty
, "message digest authentication%s", VTY_NEWLINE
);
3219 if (!OSPF_IS_AREA_BACKBONE (area
))
3220 vty_out (vty
, " Number of full virtual adjacencies going through"
3221 " this area: %d%s", area
->full_vls
, VTY_NEWLINE
);
3223 /* Show SPF calculation times. */
3224 vty_out (vty
, " SPF algorithm executed %d times%s",
3225 area
->spf_calculation
, VTY_NEWLINE
);
3227 /* Show number of LSA. */
3228 vty_out (vty
, " Number of LSA %ld%s", area
->lsdb
->total
, VTY_NEWLINE
);
3229 vty_out (vty
, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
3230 ospf_lsdb_count (area
->lsdb
, OSPF_ROUTER_LSA
),
3231 ospf_lsdb_checksum (area
->lsdb
, OSPF_ROUTER_LSA
), VTY_NEWLINE
);
3232 vty_out (vty
, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
3233 ospf_lsdb_count (area
->lsdb
, OSPF_NETWORK_LSA
),
3234 ospf_lsdb_checksum (area
->lsdb
, OSPF_NETWORK_LSA
), VTY_NEWLINE
);
3235 vty_out (vty
, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
3236 ospf_lsdb_count (area
->lsdb
, OSPF_SUMMARY_LSA
),
3237 ospf_lsdb_checksum (area
->lsdb
, OSPF_SUMMARY_LSA
), VTY_NEWLINE
);
3238 vty_out (vty
, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
3239 ospf_lsdb_count (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
),
3240 ospf_lsdb_checksum (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
), VTY_NEWLINE
);
3241 vty_out (vty
, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
3242 ospf_lsdb_count (area
->lsdb
, OSPF_AS_NSSA_LSA
),
3243 ospf_lsdb_checksum (area
->lsdb
, OSPF_AS_NSSA_LSA
), VTY_NEWLINE
);
3246 #ifdef HAVE_OPAQUE_LSA
3249 json_object_int_add(json_area
, "lsaOpaqueLinkNumber", ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
3250 json_object_int_add(json_area
, "lsaOpaqueLinkChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
3251 json_object_int_add(json_area
, "lsaOpaqueAreaNumber", ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
3252 json_object_int_add(json_area
, "lsaOpaqueAreaChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
3256 vty_out (vty
, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
3257 ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
),
3258 ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
), VTY_NEWLINE
);
3259 vty_out (vty
, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
3260 ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
),
3261 ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
), VTY_NEWLINE
);
3263 #endif /* HAVE_OPAQUE_LSA */
3266 json_object_object_add(json_areas
, inet_ntoa (area
->area_id
), json_area
);
3268 vty_out (vty
, "%s", VTY_NEWLINE
);
3272 show_ip_ospf_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
3274 struct listnode
*node
, *nnode
;
3275 struct ospf_area
* area
;
3276 struct timeval result
;
3277 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3278 json_object
*json
= NULL
;
3279 json_object
*json_areas
= NULL
;
3282 json
= json_object_new_object();
3283 json_areas
= json_object_new_object();
3289 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3293 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3294 VTY_NEWLINE
, VTY_NEWLINE
);
3298 /* Show Router ID. */
3301 json_object_string_add(json
, "routerId", inet_ntoa (ospf
->router_id
));
3305 vty_out (vty
, " OSPF Routing Process, Router ID: %s%s",
3306 inet_ntoa (ospf
->router_id
),
3310 /* Graceful shutdown */
3311 if (ospf
->t_deferred_shutdown
)
3315 unsigned long time_store
= 0;
3316 result
= tv_sub (ospf
->t_deferred_shutdown
->u
.sands
, recent_relative_time());
3317 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3318 json_object_int_add(json
, "deferredShutdownMsecs", time_store
);
3322 vty_out (vty
, " Deferred shutdown in progress, %s remaining%s",
3323 ospf_timer_dump (ospf
->t_deferred_shutdown
,
3324 timebuf
, sizeof (timebuf
)), VTY_NEWLINE
);
3328 /* Show capability. */
3331 json_object_boolean_true_add(json
, "tosRoutesOnly");
3332 json_object_boolean_true_add(json
, "rfc2328Conform");
3333 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
3335 json_object_boolean_true_add(json
, "rfc1583Compatibility");
3340 vty_out (vty
, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE
);
3341 vty_out (vty
, " This implementation conforms to RFC2328%s", VTY_NEWLINE
);
3342 vty_out (vty
, " RFC1583Compatibility flag is %s%s",
3343 CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
) ?
3344 "enabled" : "disabled", VTY_NEWLINE
);
3347 #ifdef HAVE_OPAQUE_LSA
3350 if (CHECK_FLAG (ospf
->config
, OSPF_OPAQUE_CAPABLE
))
3352 json_object_boolean_true_add(json
, "opaqueCapable");
3354 if (IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf
->opaque
))
3356 json_object_boolean_true_add(json
, "lsaOpaqueOriginationBlocked");
3361 vty_out (vty
, " OpaqueCapability flag is %s%s%s",
3362 CHECK_FLAG (ospf
->config
, OSPF_OPAQUE_CAPABLE
) ? "enabled" : "disabled",
3363 IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf
->opaque
) ? " (origination blocked)" : "",
3366 #endif /* HAVE_OPAQUE_LSA */
3368 /* Show stub-router configuration */
3369 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
3370 || ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3374 json_object_boolean_true_add(json
, "stubAdvertisement");
3375 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3376 json_object_int_add(json
,"postStartEnabledMsecs", ospf
->stub_router_startup_time
/ 1000);
3377 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3378 json_object_int_add(json
,"preShutdownEnabledMsecs", ospf
->stub_router_shutdown_time
/ 1000);
3382 vty_out (vty
, " Stub router advertisement is configured%s",
3384 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3385 vty_out (vty
, " Enabled for %us after start-up%s",
3386 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
3387 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3388 vty_out (vty
, " Enabled for %us prior to full shutdown%s",
3389 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
3393 /* Show SPF timers. */
3396 json_object_int_add(json
, "spfScheduleDelayMsecs", ospf
->spf_delay
);
3397 json_object_int_add(json
, "holdtimeMinMsecs", ospf
->spf_holdtime
);
3398 json_object_int_add(json
, "holdtimeMaxMsecs", ospf
->spf_max_holdtime
);
3399 json_object_int_add(json
, "holdtimeMultplier", ospf
->spf_hold_multiplier
);
3403 vty_out (vty
, " Initial SPF scheduling delay %d millisec(s)%s"
3404 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
3405 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
3406 " Hold time multiplier is currently %d%s",
3407 ospf
->spf_delay
, VTY_NEWLINE
,
3408 ospf
->spf_holdtime
, VTY_NEWLINE
,
3409 ospf
->spf_max_holdtime
, VTY_NEWLINE
,
3410 ospf
->spf_hold_multiplier
, VTY_NEWLINE
);
3415 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
)
3417 unsigned long time_store
= 0;
3419 result
= tv_sub (recent_relative_time(), ospf
->ts_spf
);
3420 result
= tv_sub (result
, recent_relative_time());
3421 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3422 json_object_int_add(json
, "spfLastExecutedMsecs", time_store
);
3424 time_store
= (1000 * ospf
->ts_spf_duration
.tv_sec
) + (ospf
->ts_spf_duration
.tv_usec
/ 1000);
3425 json_object_int_add(json
, "spfLastDurationMsecs", time_store
);
3428 json_object_boolean_true_add(json
, "spfHasNotRun");
3432 vty_out (vty
, " SPF algorithm ");
3433 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
)
3435 result
= tv_sub (recent_relative_time(), ospf
->ts_spf
);
3436 vty_out (vty
, "last executed %s ago%s",
3437 ospf_timeval_dump (&result
, timebuf
, sizeof (timebuf
)),
3439 vty_out (vty
, " Last SPF duration %s%s",
3440 ospf_timeval_dump (&ospf
->ts_spf_duration
, timebuf
, sizeof (timebuf
)),
3444 vty_out (vty
, "has not been run%s", VTY_NEWLINE
);
3449 struct timeval temp_time
;
3450 unsigned long time_store
= 0;
3452 if (ospf
->t_spf_calc
)
3454 temp_time
= tv_sub (ospf
->t_spf_calc
->u
.sands
, recent_relative_time());
3455 time_store
= (1000 * temp_time
.tv_sec
) + (temp_time
.tv_usec
/ 1000);
3456 json_object_int_add(json
, "spfTimerDueInMsecs", time_store
);
3459 json_object_int_add(json
, "lsaMinIntervalMsecs", ospf
->min_ls_interval
);
3460 json_object_int_add(json
, "lsaMinArrivalMsecs", ospf
->min_ls_arrival
);
3461 /* Show write multiplier values */
3462 json_object_int_add(json
, "writeMultiplier", ospf
->write_oi_count
);
3463 /* Show refresh parameters. */
3464 json_object_int_add(json
, "refreshTimerMsecs", ospf
->lsa_refresh_interval
/ 1000);
3468 vty_out (vty
, " SPF timer %s%s%s",
3469 (ospf
->t_spf_calc
? "due in " : "is "),
3470 ospf_timer_dump (ospf
->t_spf_calc
, timebuf
, sizeof (timebuf
)),
3473 vty_out (vty
, " LSA minimum interval %d msecs%s",
3474 ospf
->min_ls_interval
, VTY_NEWLINE
);
3475 vty_out (vty
, " LSA minimum arrival %d msecs%s",
3476 ospf
->min_ls_arrival
, VTY_NEWLINE
);
3478 /* Show write multiplier values */
3479 vty_out (vty
, " Write Multiplier set to %d %s",
3480 ospf
->write_oi_count
, VTY_NEWLINE
);
3482 /* Show refresh parameters. */
3483 vty_out (vty
, " Refresh timer %d secs%s",
3484 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
3487 /* Show ABR/ASBR flags. */
3488 if (CHECK_FLAG (ospf
->flags
, OSPF_FLAG_ABR
))
3491 json_object_string_add(json
, "abrType", ospf_abr_type_descr_str
[ospf
->abr_type
]);
3493 vty_out (vty
, " This router is an ABR, ABR type is: %s%s",
3494 ospf_abr_type_descr_str
[ospf
->abr_type
], VTY_NEWLINE
);
3496 if (CHECK_FLAG (ospf
->flags
, OSPF_FLAG_ASBR
))
3499 json_object_string_add(json
, "asbrRouter", "injectingExternalRoutingInformation");
3501 vty_out (vty
, " This router is an ASBR "
3502 "(injecting external routing information)%s", VTY_NEWLINE
);
3505 /* Show Number of AS-external-LSAs. */
3508 json_object_int_add(json
, "lsaExternalCounter",
3509 ospf_lsdb_count (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3510 json_object_int_add(json
, "lsaExternalChecksum",
3511 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3515 vty_out (vty
, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
3516 ospf_lsdb_count (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
),
3517 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
), VTY_NEWLINE
);
3520 #ifdef HAVE_OPAQUE_LSA
3523 json_object_int_add(json
, "lsaAsopaqueCounter",
3524 ospf_lsdb_count (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3525 json_object_int_add(json
, "lsaAsOpaqueChecksum",
3526 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3530 vty_out (vty
, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
3531 ospf_lsdb_count (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
),
3532 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
), VTY_NEWLINE
);
3534 #endif /* HAVE_OPAQUE_LSA */
3536 /* Show number of areas attached. */
3538 json_object_int_add(json
, "attachedAreaCounter", listcount (ospf
->areas
));
3540 vty_out (vty
, " Number of areas attached to this router: %d%s",
3541 listcount (ospf
->areas
), VTY_NEWLINE
);
3543 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
))
3545 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
3548 json_object_boolean_true_add(json
, "adjacencyChangesLoggedAll");
3550 vty_out(vty
, " All adjacency changes are logged%s",VTY_NEWLINE
);
3555 json_object_boolean_true_add(json
, "adjacencyChangesLogged");
3557 vty_out(vty
, " Adjacency changes are logged%s",VTY_NEWLINE
);
3560 /* Show each area status. */
3561 for (ALL_LIST_ELEMENTS (ospf
->areas
, node
, nnode
, area
))
3562 show_ip_ospf_area (vty
, area
, json_areas
, use_json
);
3566 json_object_object_add(json
, "areas", json_areas
);
3567 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
3568 json_object_free(json
);
3571 vty_out (vty
, "%s",VTY_NEWLINE
);
3576 DEFUN (show_ip_ospf
,
3578 "show ip ospf {json}",
3581 "OSPF information\n"
3582 "JavaScript Object Notation\n")
3585 u_char uj
= use_json(argc
, argv
);
3587 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3590 return (show_ip_ospf_common(vty
, ospf
, uj
));
3593 DEFUN (show_ip_ospf_instance
,
3594 show_ip_ospf_instance_cmd
,
3595 "show ip ospf <1-65535> {json}",
3598 "OSPF information\n"
3600 "JavaScript Object Notation\n")
3603 u_short instance
= 0;
3604 u_char uj
= use_json(argc
, argv
);
3606 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
3607 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
3610 return (show_ip_ospf_common(vty
, ospf
, uj
));
3614 show_ip_ospf_interface_sub (struct vty
*vty
, struct ospf
*ospf
, struct interface
*ifp
,
3615 json_object
*json_interface_sub
, u_char use_json
)
3618 struct ospf_neighbor
*nbr
;
3619 struct route_node
*rn
;
3621 /* Is interface up? */
3624 is_up
= if_is_operative(ifp
);
3626 json_object_boolean_true_add(json_interface_sub
, "ifUp");
3628 json_object_boolean_false_add(json_interface_sub
, "ifDown");
3630 json_object_int_add(json_interface_sub
, "ifIndex", ifp
->ifindex
);
3631 json_object_int_add(json_interface_sub
, "mtuBytes", ifp
->mtu
);
3632 json_object_int_add(json_interface_sub
, "bandwidthKbit", ifp
->bandwidth
);
3633 json_object_string_add(json_interface_sub
, "ifFlags", if_flag_dump(ifp
->flags
));
3637 vty_out (vty
, "%s is %s%s", ifp
->name
,
3638 ((is_up
= if_is_operative(ifp
)) ? "up" : "down"), VTY_NEWLINE
);
3639 vty_out (vty
, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s",
3640 ifp
->ifindex
, ifp
->mtu
, ifp
->bandwidth
, if_flag_dump(ifp
->flags
),
3644 /* Is interface OSPF enabled? */
3647 if (ospf_oi_count(ifp
) == 0)
3649 json_object_boolean_false_add(json_interface_sub
, "ospfEnabled");
3654 json_object_boolean_false_add(json_interface_sub
, "ospfRunning");
3658 json_object_boolean_true_add(json_interface_sub
, "ospfEnabled");
3662 if (ospf_oi_count(ifp
) == 0)
3664 vty_out (vty
, " OSPF not enabled on this interface%s", VTY_NEWLINE
);
3669 vty_out (vty
, " OSPF is enabled, but not running on this interface%s",
3675 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
3677 struct ospf_interface
*oi
= rn
->info
;
3682 if (CHECK_FLAG(oi
->connected
->flags
, ZEBRA_IFA_UNNUMBERED
))
3685 json_object_boolean_true_add(json_interface_sub
, "ifUnnumbered");
3687 vty_out (vty
, " This interface is UNNUMBERED,");
3691 /* Show OSPF interface information. */
3694 json_object_string_add(json_interface_sub
, "ipAddress", inet_ntoa (oi
->address
->u
.prefix4
));
3695 json_object_int_add(json_interface_sub
, "ipAddressPrefixlen", oi
->address
->prefixlen
);
3698 vty_out (vty
, " Internet Address %s/%d,",
3699 inet_ntoa (oi
->address
->u
.prefix4
), oi
->address
->prefixlen
);
3701 if (oi
->connected
->destination
|| oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3703 struct in_addr
*dest
;
3706 if (CONNECTED_PEER(oi
->connected
)
3707 || oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3712 /* For Vlinks, showing the peer address is probably more
3713 * * * * * informative than the local interface that is being used
3715 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3716 dest
= &oi
->vl_data
->peer_addr
;
3718 dest
= &oi
->connected
->destination
->u
.prefix4
;
3722 json_object_string_add(json_interface_sub
, "ospfIfType", dstr
);
3723 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3724 json_object_string_add(json_interface_sub
, "vlinkPeer", inet_ntoa (*dest
));
3726 json_object_string_add(json_interface_sub
, "localIfUsed", inet_ntoa (*dest
));
3729 vty_out (vty
, " %s %s,", dstr
, inet_ntoa (*dest
));
3734 json_object_string_add(json_interface_sub
, "area", ospf_area_desc_string (oi
->area
));
3735 if (OSPF_IF_PARAM(oi
, mtu_ignore
))
3736 json_object_boolean_true_add(json_interface_sub
, "mtuMismatchDetect");
3737 json_object_string_add(json_interface_sub
, "routerId", inet_ntoa (ospf
->router_id
));
3738 json_object_string_add(json_interface_sub
, "networkType", ospf_network_type_str
[oi
->type
]);
3739 json_object_int_add(json_interface_sub
, "cost", oi
->output_cost
);
3740 json_object_int_add(json_interface_sub
, "transmitDelayMsecs", 1000 / OSPF_IF_PARAM (oi
,transmit_delay
));
3741 json_object_string_add(json_interface_sub
, "state", LOOKUP (ospf_ism_state_msg
, oi
->state
));
3742 json_object_int_add(json_interface_sub
, "priority", PRIORITY (oi
));
3746 vty_out (vty
, " Area %s%s", ospf_area_desc_string (oi
->area
),
3749 vty_out (vty
, " MTU mismatch detection:%s%s",
3750 OSPF_IF_PARAM(oi
, mtu_ignore
) ? "disabled" : "enabled", VTY_NEWLINE
);
3752 vty_out (vty
, " Router ID %s, Network Type %s, Cost: %d%s",
3753 inet_ntoa (ospf
->router_id
), ospf_network_type_str
[oi
->type
],
3754 oi
->output_cost
, VTY_NEWLINE
);
3756 vty_out (vty
, " Transmit Delay is %d sec, State %s, Priority %d%s",
3757 OSPF_IF_PARAM (oi
,transmit_delay
), LOOKUP (ospf_ism_state_msg
, oi
->state
),
3758 PRIORITY (oi
), VTY_NEWLINE
);
3761 /* Show DR information. */
3762 if (DR (oi
).s_addr
== 0)
3765 vty_out (vty
, " No backup designated router on this network%s",
3770 nbr
= ospf_nbr_lookup_by_addr (oi
->nbrs
, &BDR (oi
));
3774 vty_out (vty
, " No backup designated router on this network%s",
3781 json_object_string_add(json_interface_sub
, "bdrId", inet_ntoa (nbr
->router_id
));
3782 json_object_string_add(json_interface_sub
, "bdrAddress", inet_ntoa (nbr
->address
.u
.prefix4
));
3786 vty_out (vty
, " Backup Designated Router (ID) %s,",
3787 inet_ntoa (nbr
->router_id
));
3788 vty_out (vty
, " Interface Address %s%s",
3789 inet_ntoa (nbr
->address
.u
.prefix4
), VTY_NEWLINE
);
3794 /* Next network-LSA sequence number we'll use, if we're elected DR */
3795 if (oi
->params
&& ntohl (oi
->params
->network_lsa_seqnum
) != OSPF_INITIAL_SEQUENCE_NUMBER
)
3798 json_object_int_add(json_interface_sub
, "networkLsaSequence", ntohl (oi
->params
->network_lsa_seqnum
));
3800 vty_out (vty
, " Saved Network-LSA sequence number 0x%x%s",
3801 ntohl (oi
->params
->network_lsa_seqnum
), VTY_NEWLINE
);
3806 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3807 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3809 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3810 json_object_boolean_true_add(json_interface_sub
, "mcastMemberOspfAllRouters");
3811 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3812 json_object_boolean_true_add(json_interface_sub
, "mcastMemberOspfDesignatedRouters");
3817 vty_out (vty
, " Multicast group memberships:");
3818 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3819 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3821 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3822 vty_out (vty
, " OSPFAllRouters");
3823 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3824 vty_out (vty
, " OSPFDesignatedRouters");
3827 vty_out (vty
, " <None>");
3828 vty_out (vty
, "%s", VTY_NEWLINE
);
3833 if (OSPF_IF_PARAM (oi
, fast_hello
) == 0)
3834 json_object_int_add(json_interface_sub
, "timerMsecs", 1000 /OSPF_IF_PARAM (oi
, v_hello
));
3836 json_object_int_add(json_interface_sub
, "timerMsecs", 1000 / OSPF_IF_PARAM (oi
, fast_hello
));
3837 json_object_int_add(json_interface_sub
, "timerDeadMsecs", 1000 / OSPF_IF_PARAM (oi
, v_wait
));
3838 json_object_int_add(json_interface_sub
, "timerWaitMsecs", 1000 / OSPF_IF_PARAM (oi
, v_wait
));
3839 json_object_int_add(json_interface_sub
, "timerRetransmit", 1000 / OSPF_IF_PARAM (oi
, retransmit_interval
));
3843 vty_out (vty
, " Timer intervals configured,");
3844 vty_out (vty
, " Hello ");
3845 if (OSPF_IF_PARAM (oi
, fast_hello
) == 0)
3846 vty_out (vty
, "%ds,", OSPF_IF_PARAM (oi
, v_hello
));
3848 vty_out (vty
, "%dms,", 1000 / OSPF_IF_PARAM (oi
, fast_hello
));
3849 vty_out (vty
, " Dead %ds, Wait %ds, Retransmit %d%s",
3850 OSPF_IF_PARAM (oi
, v_wait
),
3851 OSPF_IF_PARAM (oi
, v_wait
),
3852 OSPF_IF_PARAM (oi
, retransmit_interval
),
3856 if (OSPF_IF_PASSIVE_STATUS (oi
) == OSPF_IF_ACTIVE
)
3858 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3861 struct timeval result
;
3862 unsigned long time_store
= 0;
3863 result
= tv_sub (oi
->t_hello
->u
.sands
, recent_relative_time());
3864 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3865 json_object_int_add(json_interface_sub
, "timerHelloInMsecs", time_store
);
3868 vty_out (vty
, " Hello due in %s%s",
3869 ospf_timer_dump (oi
->t_hello
, timebuf
, sizeof(timebuf
)),
3872 else /* passive-interface is set */
3875 json_object_boolean_true_add(json_interface_sub
, "timerPassiveIface");
3877 vty_out (vty
, " No Hellos (Passive interface)%s", VTY_NEWLINE
);
3882 json_object_int_add(json_interface_sub
, "nbrCount", ospf_nbr_count (oi
, 0));
3883 json_object_int_add(json_interface_sub
, "nbrAdjacentCount", ospf_nbr_count (oi
, NSM_Full
));
3886 vty_out (vty
, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
3887 ospf_nbr_count (oi
, 0), ospf_nbr_count (oi
, NSM_Full
),
3889 ospf_bfd_interface_show(vty
, ifp
, json_interface_sub
, use_json
);
3894 show_ip_ospf_interface_common (struct vty
*vty
, struct ospf
*ospf
, int argc
,
3895 const char **argv
, int iface_argv
, u_char use_json
)
3897 struct interface
*ifp
;
3898 struct listnode
*node
;
3899 json_object
*json
= NULL
;
3900 json_object
*json_interface_sub
= NULL
;
3904 json
= json_object_new_object();
3905 json_interface_sub
= json_object_new_object();
3911 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3913 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3914 VTY_NEWLINE
, VTY_NEWLINE
);
3917 if (argc
== (iface_argv
+ 1))
3919 /* Show All Interfaces.*/
3920 for (ALL_LIST_ELEMENTS_RO (iflist
, node
, ifp
))
3922 if (ospf_oi_count(ifp
))
3924 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3928 else if (argv
[iface_argv
] && strcmp(argv
[iface_argv
], "json") == 0)
3930 /* Show All Interfaces. */
3931 for (ALL_LIST_ELEMENTS_RO (iflist
, node
, ifp
))
3933 if (ospf_oi_count(ifp
))
3935 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3936 json_object_object_add(json
, ifp
->name
, json_interface_sub
);
3942 /* Interface name is specified. */
3943 if ((ifp
= if_lookup_by_name (argv
[iface_argv
])) == NULL
)
3946 json_object_boolean_true_add(json
, "noSuchIface");
3948 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
3952 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3954 json_object_object_add(json
, ifp
->name
, json_interface_sub
);
3960 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
3961 json_object_free(json
);
3964 vty_out (vty
, "%s", VTY_NEWLINE
);
3969 DEFUN (show_ip_ospf_interface
,
3970 show_ip_ospf_interface_cmd
,
3971 "show ip ospf interface [INTERFACE] {json}",
3974 "OSPF information\n"
3975 "Interface information\n"
3977 "JavaScript Object Notation\n")
3980 u_char uj
= use_json(argc
, argv
);
3982 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3985 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 0, uj
);
3988 DEFUN (show_ip_ospf_instance_interface
,
3989 show_ip_ospf_instance_interface_cmd
,
3990 "show ip ospf <1-65535> interface [INTERFACE] {json}",
3993 "OSPF information\n"
3995 "Interface information\n"
3997 "JavaScript Object Notation\n")
4000 u_short instance
= 0;
4001 u_char uj
= use_json(argc
, argv
);
4003 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
4004 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
4007 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 1, uj
);
4011 show_ip_ospf_neighbour_header (struct vty
*vty
)
4013 vty_out (vty
, "%s%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
4015 "Neighbor ID", "Pri", "State", "Dead Time",
4016 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
4021 show_ip_ospf_neighbor_sub (struct vty
*vty
, struct ospf_interface
*oi
, json_object
*json
, u_char use_json
)
4023 struct route_node
*rn
;
4024 struct ospf_neighbor
*nbr
;
4026 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4027 json_object
*json_neighbor
= NULL
;
4029 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4031 if ((nbr
= rn
->info
))
4033 /* Do not show myself. */
4034 if (nbr
!= oi
->nbr_self
)
4036 /* Down state is not shown. */
4037 if (nbr
->state
!= NSM_Down
)
4041 json_neighbor
= json_object_new_object();
4042 ospf_nbr_state_message (nbr
, msgbuf
, 16);
4044 struct timeval result
;
4045 unsigned long time_store
= 0;
4047 result
= tv_sub (nbr
->t_inactivity
->u
.sands
, recent_relative_time());
4048 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
4050 json_object_int_add (json_neighbor
, "priority", nbr
->priority
);
4051 json_object_string_add (json_neighbor
, "state", msgbuf
);
4052 json_object_int_add (json_neighbor
, "deadTimeMsecs", time_store
);
4053 json_object_string_add (json_neighbor
, "address", inet_ntoa (nbr
->src
));
4054 json_object_string_add (json_neighbor
, "ifaceName", IF_NAME (oi
));
4055 json_object_int_add (json_neighbor
, "retransmitCounter", ospf_ls_retransmit_count (nbr
));
4056 json_object_int_add (json_neighbor
, "requestCounter", ospf_ls_request_count (nbr
));
4057 json_object_int_add (json_neighbor
, "dbSummaryCounter", ospf_db_summary_count (nbr
));
4058 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4059 json_object_object_add(json
, "neighbor", json_neighbor
);
4061 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_neighbor
);
4065 ospf_nbr_state_message (nbr
, msgbuf
, 16);
4067 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4068 vty_out (vty
, "%-15s %3d %-15s ",
4072 vty_out (vty
, "%-15s %3d %-15s ",
4073 inet_ntoa (nbr
->router_id
), nbr
->priority
,
4076 vty_out (vty
, "%9s ",
4077 ospf_timer_dump (nbr
->t_inactivity
, timebuf
,
4079 vty_out (vty
, "%-15s ", inet_ntoa (nbr
->src
));
4080 vty_out (vty
, "%-20s %5ld %5ld %5d%s",
4081 IF_NAME (oi
), ospf_ls_retransmit_count (nbr
),
4082 ospf_ls_request_count (nbr
), ospf_db_summary_count (nbr
),
4092 show_ip_ospf_neighbor_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4094 struct ospf_interface
*oi
;
4095 struct listnode
*node
;
4096 json_object
*json
= NULL
;
4099 json
= json_object_new_object();
4101 show_ip_ospf_neighbour_header (vty
);
4106 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4108 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4109 VTY_NEWLINE
, VTY_NEWLINE
);
4112 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4113 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
4117 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
4118 json_object_free(json
);
4121 vty_out (vty
, "%s", VTY_NEWLINE
);
4126 DEFUN (show_ip_ospf_neighbor
,
4127 show_ip_ospf_neighbor_cmd
,
4128 "show ip ospf neighbor {json}",
4131 "OSPF information\n"
4133 "JavaScript Object Notation\n")
4136 u_char uj
= use_json(argc
, argv
);
4138 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4141 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
4145 DEFUN (show_ip_ospf_instance_neighbor
,
4146 show_ip_ospf_instance_neighbor_cmd
,
4147 "show ip ospf <1-65535> neighbor {json}",
4150 "OSPF information\n"
4153 "JavaScript Object Notation\n")
4156 u_short instance
= 0;
4157 u_char uj
= use_json(argc
, argv
);
4159 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
4160 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4163 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
4167 show_ip_ospf_neighbor_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4169 struct listnode
*node
;
4170 struct ospf_interface
*oi
;
4171 json_object
*json
= NULL
;
4172 json_object
*json_neighbor_sub
= NULL
;
4176 json
= json_object_new_object();
4177 json_neighbor_sub
= json_object_new_object();
4180 show_ip_ospf_neighbour_header (vty
);
4185 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4187 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4188 VTY_NEWLINE
, VTY_NEWLINE
);
4191 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4193 struct listnode
*nbr_node
;
4194 struct ospf_nbr_nbma
*nbr_nbma
;
4196 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
4198 /* print Down neighbor status */
4199 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nbr_node
, nbr_nbma
))
4201 if (nbr_nbma
->nbr
== NULL
4202 || nbr_nbma
->nbr
->state
== NSM_Down
)
4206 json_object_int_add (json_neighbor_sub
, "nbrNbmaPriority", nbr_nbma
->priority
);
4207 json_object_boolean_true_add (json_neighbor_sub
, "nbrNbmaDown");
4208 json_object_string_add (json_neighbor_sub
, "nbrNbmaIfaceName", IF_NAME (oi
));
4209 json_object_int_add (json_neighbor_sub
, "nbrNbmaRetransmitCounter", 0);
4210 json_object_int_add (json_neighbor_sub
, "nbrNbmaRequestCounter", 0);
4211 json_object_int_add (json_neighbor_sub
, "nbrNbmaDbSummaryCounter", 0);
4212 json_object_object_add(json
, inet_ntoa (nbr_nbma
->addr
), json_neighbor_sub
);
4216 vty_out (vty
, "%-15s %3d %-15s %9s ",
4217 "-", nbr_nbma
->priority
, "Down", "-");
4218 vty_out (vty
, "%-15s %-20s %5d %5d %5d%s",
4219 inet_ntoa (nbr_nbma
->addr
), IF_NAME (oi
),
4220 0, 0, 0, VTY_NEWLINE
);
4228 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
4229 json_object_free(json
);
4232 vty_out (vty
, "%s", VTY_NEWLINE
);
4237 DEFUN (show_ip_ospf_neighbor_all
,
4238 show_ip_ospf_neighbor_all_cmd
,
4239 "show ip ospf neighbor all {json}",
4242 "OSPF information\n"
4244 "include down status neighbor\n"
4245 "JavaScript Object Notation\n")
4248 u_char uj
= use_json(argc
, argv
);
4250 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4253 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
4256 DEFUN (show_ip_ospf_instance_neighbor_all
,
4257 show_ip_ospf_instance_neighbor_all_cmd
,
4258 "show ip ospf <1-65535> neighbor all {json}",
4261 "OSPF information\n"
4264 "include down status neighbor\n"
4265 "JavaScript Object Notation\n")
4268 u_short instance
= 0;
4269 u_char uj
= use_json(argc
, argv
);
4271 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
4272 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4275 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
4279 show_ip_ospf_neighbor_int_common (struct vty
*vty
, struct ospf
*ospf
, int arg_base
,
4280 const char **argv
, u_char use_json
)
4282 struct interface
*ifp
;
4283 struct route_node
*rn
;
4284 json_object
*json
= NULL
;
4287 json
= json_object_new_object();
4289 show_ip_ospf_neighbour_header (vty
);
4294 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4296 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4297 VTY_NEWLINE
, VTY_NEWLINE
);
4300 ifp
= if_lookup_by_name (argv
[arg_base
]);
4304 json_object_boolean_true_add(json
, "noSuchIface");
4306 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
4310 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
4312 struct ospf_interface
*oi
= rn
->info
;
4317 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
4322 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
4323 json_object_free(json
);
4326 vty_out (vty
, "%s", VTY_NEWLINE
);
4331 DEFUN (show_ip_ospf_neighbor_int
,
4332 show_ip_ospf_neighbor_int_cmd
,
4333 "show ip ospf neighbor IFNAME {json}",
4336 "OSPF information\n"
4339 "JavaScript Object Notation\n")
4342 u_char uj
= use_json(argc
, argv
);
4344 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4347 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 0, argv
, uj
);
4350 DEFUN (show_ip_ospf_instance_neighbor_int
,
4351 show_ip_ospf_instance_neighbor_int_cmd
,
4352 "show ip ospf <1-65535> neighbor IFNAME {json}",
4355 "OSPF information\n"
4359 "JavaScript Object Notation\n")
4362 u_short instance
= 0;
4363 u_char uj
= use_json(argc
, argv
);
4365 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
4366 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4369 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 1, argv
, uj
);
4373 show_ip_ospf_nbr_nbma_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
, struct ospf_nbr_nbma
*nbr_nbma
,
4374 u_char use_json
, json_object
*json
)
4376 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4377 json_object
*json_sub
= NULL
;
4380 json_sub
= json_object_new_object();
4381 else /* Show neighbor ID. */
4382 vty_out (vty
, " Neighbor %s,", "-");
4384 /* Show interface address. */
4386 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr_nbma
->addr
));
4388 vty_out (vty
, " interface address %s%s",
4389 inet_ntoa (nbr_nbma
->addr
), VTY_NEWLINE
);
4394 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4395 json_object_string_add(json_sub
, "iface", IF_NAME (oi
));
4398 vty_out (vty
, " In the area %s via interface %s%s",
4399 ospf_area_desc_string (oi
->area
), IF_NAME (oi
), VTY_NEWLINE
);
4401 /* Show neighbor priority and state. */
4404 json_object_int_add(json_sub
, "nbrPriority", nbr_nbma
->priority
);
4405 json_object_string_add(json_sub
, "nbrState", "down");
4408 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4409 nbr_nbma
->priority
, "Down");
4411 /* Show state changes. */
4413 json_object_int_add(json_sub
, "stateChangeCounter", nbr_nbma
->state_change
);
4415 vty_out (vty
, " %d state changes%s", nbr_nbma
->state_change
, VTY_NEWLINE
);
4417 /* Show PollInterval */
4419 json_object_int_add(json_sub
, "pollInterval", nbr_nbma
->v_poll
);
4421 vty_out (vty
, " Poll interval %d%s", nbr_nbma
->v_poll
, VTY_NEWLINE
);
4423 /* Show poll-interval timer. */
4426 struct timeval res
= tv_sub (nbr_nbma
->t_poll
->u
.sands
, recent_relative_time ());
4427 unsigned long time_store
= 0;
4428 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4429 json_object_int_add(json_sub
, "pollIntervalTimerDueMsec", time_store
);
4432 vty_out (vty
, " Poll timer due in %s%s",
4433 ospf_timer_dump (nbr_nbma
->t_poll
, timebuf
, sizeof(timebuf
)),
4436 /* Show poll-interval timer thread. */
4439 if (nbr_nbma
->t_poll
!= NULL
)
4440 json_object_string_add(json_sub
, "pollIntervalTimerThread", "on");
4443 vty_out (vty
, " Thread Poll Timer %s%s",
4444 nbr_nbma
->t_poll
!= NULL
? "on" : "off", VTY_NEWLINE
);
4447 json_object_object_add(json
, "noNbrId", json_sub
);
4451 show_ip_ospf_neighbor_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
,
4452 struct ospf_neighbor
*nbr
, u_char use_json
, json_object
*json
)
4454 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4455 json_object
*json_sub
= NULL
;
4458 json_sub
= json_object_new_object();
4461 /* Show neighbor ID. */
4462 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4463 vty_out (vty
, " Neighbor %s,", "-");
4465 vty_out (vty
, " Neighbor %s,", inet_ntoa (nbr
->router_id
));
4468 /* Show interface address. */
4470 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr
->address
.u
.prefix4
));
4472 vty_out (vty
, " interface address %s%s",
4473 inet_ntoa (nbr
->address
.u
.prefix4
), VTY_NEWLINE
);
4478 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4479 json_object_string_add(json_sub
, "ifaceName", oi
->ifp
->name
);
4482 vty_out (vty
, " In the area %s via interface %s%s",
4483 ospf_area_desc_string (oi
->area
), oi
->ifp
->name
, VTY_NEWLINE
);
4485 /* Show neighbor priority and state. */
4488 json_object_int_add(json_sub
, "nbrPriority", nbr
->priority
);
4489 json_object_string_add(json_sub
, "nbrState", LOOKUP (ospf_nsm_state_msg
, nbr
->state
));
4492 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4493 nbr
->priority
, LOOKUP (ospf_nsm_state_msg
, nbr
->state
));
4495 /* Show state changes. */
4497 json_object_int_add(json_sub
, "stateChangeCounter", nbr
->state_change
);
4499 vty_out (vty
, " %d state changes%s", nbr
->state_change
, VTY_NEWLINE
);
4501 if (nbr
->ts_last_progress
.tv_sec
|| nbr
->ts_last_progress
.tv_usec
)
4503 struct timeval res
= tv_sub (recent_relative_time (), nbr
->ts_last_progress
);
4506 unsigned long time_store
= 0;
4507 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4508 json_object_int_add(json_sub
, "lastPrgrsvChangeMsec", time_store
);
4512 vty_out (vty
, " Most recent state change statistics:%s",
4514 vty_out (vty
, " Progressive change %s ago%s",
4515 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4520 if (nbr
->ts_last_regress
.tv_sec
|| nbr
->ts_last_regress
.tv_usec
)
4522 struct timeval res
= tv_sub (recent_relative_time (), nbr
->ts_last_regress
);
4525 unsigned long time_store
= 0;
4526 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4527 json_object_int_add(json_sub
, "lastRegressiveChangeMsec", time_store
);
4528 if (nbr
->last_regress_str
)
4529 json_object_string_add(json_sub
, "lastRegressiveChangeReason", nbr
->last_regress_str
);
4533 vty_out (vty
, " Regressive change %s ago, due to %s%s",
4534 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4535 (nbr
->last_regress_str
? nbr
->last_regress_str
: "??"),
4540 /* Show Designated Rotuer ID. */
4542 json_object_string_add(json_sub
, "routerDesignatedId", inet_ntoa (nbr
->d_router
));
4544 vty_out (vty
, " DR is %s,", inet_ntoa (nbr
->d_router
));
4546 /* Show Backup Designated Rotuer ID. */
4548 json_object_string_add(json_sub
, "routerDesignatedBackupId", inet_ntoa (nbr
->bd_router
));
4550 vty_out (vty
, " BDR is %s%s", inet_ntoa (nbr
->bd_router
), VTY_NEWLINE
);
4555 json_object_int_add(json_sub
, "optionsCounter", nbr
->options
);
4556 json_object_string_add(json_sub
, "optionsList", ospf_options_dump (nbr
->options
));
4559 vty_out (vty
, " Options %d %s%s", nbr
->options
,
4560 ospf_options_dump (nbr
->options
), VTY_NEWLINE
);
4562 /* Show Router Dead interval timer. */
4565 struct timeval res
= tv_sub (nbr
->t_inactivity
->u
.sands
, recent_relative_time ());
4566 unsigned long time_store
= 0;
4567 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4568 json_object_int_add(json_sub
, "routerDeadIntervalTimerDueMsec", time_store
);
4571 vty_out (vty
, " Dead timer due in %s%s",
4572 ospf_timer_dump (nbr
->t_inactivity
, timebuf
, sizeof (timebuf
)),
4575 /* Show Database Summary list. */
4577 json_object_int_add(json_sub
, "databaseSummaryListCounter", ospf_db_summary_count (nbr
));
4579 vty_out (vty
, " Database Summary List %d%s",
4580 ospf_db_summary_count (nbr
), VTY_NEWLINE
);
4582 /* Show Link State Request list. */
4584 json_object_int_add(json_sub
, "linkStateRequestListCounter", ospf_ls_request_count (nbr
));
4586 vty_out (vty
, " Link State Request List %ld%s",
4587 ospf_ls_request_count (nbr
), VTY_NEWLINE
);
4589 /* Show Link State Retransmission list. */
4591 json_object_int_add(json_sub
, "linkStateRetransmissionListCounter", ospf_ls_retransmit_count (nbr
));
4593 vty_out (vty
, " Link State Retransmission List %ld%s",
4594 ospf_ls_retransmit_count (nbr
), VTY_NEWLINE
);
4596 /* Show inactivity timer thread. */
4599 if (nbr
->t_inactivity
!= NULL
)
4600 json_object_string_add(json_sub
, "threadInactivityTimer", "on");
4603 vty_out (vty
, " Thread Inactivity Timer %s%s",
4604 nbr
->t_inactivity
!= NULL
? "on" : "off", VTY_NEWLINE
);
4606 /* Show Database Description retransmission thread. */
4609 if (nbr
->t_db_desc
!= NULL
)
4610 json_object_string_add(json_sub
, "threadDatabaseDescriptionRetransmission", "on");
4613 vty_out (vty
, " Thread Database Description Retransmision %s%s",
4614 nbr
->t_db_desc
!= NULL
? "on" : "off", VTY_NEWLINE
);
4616 /* Show Link State Request Retransmission thread. */
4619 if (nbr
->t_ls_req
!= NULL
)
4620 json_object_string_add(json_sub
, "threadLinkStateRequestRetransmission", "on");
4623 vty_out (vty
, " Thread Link State Request Retransmission %s%s",
4624 nbr
->t_ls_req
!= NULL
? "on" : "off", VTY_NEWLINE
);
4626 /* Show Link State Update Retransmission thread. */
4629 if (nbr
->t_ls_upd
!= NULL
)
4630 json_object_string_add(json_sub
, "threadLinkStateUpdateRetransmission", "on");
4633 vty_out (vty
, " Thread Link State Update Retransmission %s%s%s",
4634 nbr
->t_ls_upd
!= NULL
? "on" : "off", VTY_NEWLINE
, VTY_NEWLINE
);
4638 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4639 json_object_object_add(json
, "noNbrId", json_sub
);
4641 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_sub
);
4644 ospf_bfd_show_info(vty
, nbr
->bfd_info
, json
, use_json
, 0);
4648 show_ip_ospf_neighbor_id_common (struct vty
*vty
, struct ospf
*ospf
,
4649 int arg_base
, const char **argv
, u_char use_json
)
4651 struct listnode
*node
;
4652 struct ospf_neighbor
*nbr
;
4653 struct ospf_interface
*oi
;
4654 struct in_addr router_id
;
4656 json_object
*json
= NULL
;
4659 json
= json_object_new_object();
4664 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4666 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4667 VTY_NEWLINE
, VTY_NEWLINE
);
4670 ret
= inet_aton (argv
[arg_base
], &router_id
);
4674 vty_out (vty
, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE
);
4678 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4680 if ((nbr
= ospf_nbr_lookup_by_routerid (oi
->nbrs
, &router_id
)))
4682 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4688 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
4689 json_object_free(json
);
4692 vty_out (vty
, "%s", VTY_NEWLINE
);
4697 DEFUN (show_ip_ospf_neighbor_id
,
4698 show_ip_ospf_neighbor_id_cmd
,
4699 "show ip ospf neighbor A.B.C.D {json}",
4702 "OSPF information\n"
4705 "JavaScript Object Notation\n")
4708 u_char uj
= use_json(argc
, argv
);
4710 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4713 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 0, argv
, uj
);
4716 DEFUN (show_ip_ospf_instance_neighbor_id
,
4717 show_ip_ospf_instance_neighbor_id_cmd
,
4718 "show ip ospf <1-65535> neighbor A.B.C.D {json}",
4721 "OSPF information\n"
4725 "JavaScript Object Notation\n")
4728 u_short instance
= 0;
4729 u_char uj
= use_json(argc
, argv
);
4731 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
4732 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4735 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 1, argv
, uj
);
4739 show_ip_ospf_neighbor_detail_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4741 struct ospf_interface
*oi
;
4742 struct listnode
*node
;
4743 json_object
*json
= NULL
;
4746 json
= json_object_new_object();
4751 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4753 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4754 VTY_NEWLINE
, VTY_NEWLINE
);
4757 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4759 struct route_node
*rn
;
4760 struct ospf_neighbor
*nbr
;
4762 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4764 if ((nbr
= rn
->info
))
4766 if (nbr
!= oi
->nbr_self
)
4768 if (nbr
->state
!= NSM_Down
)
4770 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4779 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
4780 json_object_free(json
);
4783 vty_out (vty
, "%s", VTY_NEWLINE
);
4788 DEFUN (show_ip_ospf_neighbor_detail
,
4789 show_ip_ospf_neighbor_detail_cmd
,
4790 "show ip ospf neighbor detail {json}",
4793 "OSPF information\n"
4795 "detail of all neighbors\n"
4796 "JavaScript Object Notation\n")
4799 u_char uj
= use_json(argc
, argv
);
4801 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4804 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4807 DEFUN (show_ip_ospf_instance_neighbor_detail
,
4808 show_ip_ospf_instance_neighbor_detail_cmd
,
4809 "show ip ospf <1-65535> neighbor detail {json}",
4812 "OSPF information\n"
4815 "detail of all neighbors\n"
4816 "JavaScript Object Notation\n")
4819 u_short instance
= 0;
4820 u_char uj
= use_json(argc
, argv
);
4822 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
4823 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
4826 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4830 show_ip_ospf_neighbor_detail_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4832 struct listnode
*node
;
4833 struct ospf_interface
*oi
;
4834 json_object
*json
= NULL
;
4837 json
= json_object_new_object();
4842 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4844 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4845 VTY_NEWLINE
, VTY_NEWLINE
);
4848 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4850 struct route_node
*rn
;
4851 struct ospf_neighbor
*nbr
;
4852 struct ospf_nbr_nbma
*nbr_nbma
;
4854 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4855 if ((nbr
= rn
->info
))
4856 if (nbr
!= oi
->nbr_self
)
4857 if (oi
->type
== OSPF_IFTYPE_NBMA
&& nbr
->state
!= NSM_Down
)
4858 show_ip_ospf_neighbor_detail_sub (vty
, oi
, rn
->info
, use_json
, json
);
4860 if (oi
->type
== OSPF_IFTYPE_NBMA
)
4862 struct listnode
*nd
;
4864 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nd
, nbr_nbma
))
4866 if (nbr_nbma
->nbr
== NULL
|| nbr_nbma
->nbr
->state
== NSM_Down
)
4867 show_ip_ospf_nbr_nbma_detail_sub (vty
, oi
, nbr_nbma
, use_json
, json
);
4874 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
4875 json_object_free(json
);
4879 vty_out (vty
, "%s", VTY_NEWLINE
);
4885 DEFUN (show_ip_ospf_neighbor_detail_all
,
4886 show_ip_ospf_neighbor_detail_all_cmd
,
4887 "show ip ospf neighbor detail all {json}",
4890 "OSPF information\n"
4892 "detail of all neighbors\n"
4893 "include down status neighbor\n"
4894 "JavaScript Object Notation\n")
4897 u_char uj
= use_json(argc
, argv
);
4899 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4902 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4905 DEFUN (show_ip_ospf_instance_neighbor_detail_all
,
4906 show_ip_ospf_instance_neighbor_detail_all_cmd
,
4907 "show ip ospf <1-65535> neighbor detail all {json}",
4910 "OSPF information\n"
4913 "detail of all neighbors\n"
4914 "include down status neighbor\n"
4915 "JavaScript Object Notation\n")
4918 u_short instance
= 0;
4919 u_char uj
= use_json(argc
, argv
);
4921 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
4922 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4925 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4929 show_ip_ospf_neighbor_int_detail_common (struct vty
*vty
, struct ospf
*ospf
,
4930 int arg_base
, const char **argv
, u_char use_json
)
4932 struct ospf_interface
*oi
;
4933 struct interface
*ifp
;
4934 struct route_node
*rn
, *nrn
;
4935 struct ospf_neighbor
*nbr
;
4936 json_object
*json
= NULL
;
4939 json
= json_object_new_object();
4944 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4946 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4947 VTY_NEWLINE
, VTY_NEWLINE
);
4950 ifp
= if_lookup_by_name (argv
[arg_base
]);
4954 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
4958 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
4960 if ((oi
= rn
->info
))
4962 for (nrn
= route_top (oi
->nbrs
); nrn
; nrn
= route_next (nrn
))
4964 if ((nbr
= nrn
->info
))
4966 if (nbr
!= oi
->nbr_self
)
4968 if (nbr
->state
!= NSM_Down
)
4969 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4978 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
4979 json_object_free(json
);
4982 vty_out (vty
, "%s", VTY_NEWLINE
);
4987 DEFUN (show_ip_ospf_neighbor_int_detail
,
4988 show_ip_ospf_neighbor_int_detail_cmd
,
4989 "show ip ospf neighbor IFNAME detail {json}",
4992 "OSPF information\n"
4995 "detail of all neighbors\n"
4996 "JavaScript Object Notation\n")
4999 u_char uj
= use_json(argc
, argv
);
5001 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5004 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 0, argv
, uj
);
5007 DEFUN (show_ip_ospf_instance_neighbor_int_detail
,
5008 show_ip_ospf_instance_neighbor_int_detail_cmd
,
5009 "show ip ospf <1-65535> neighbor IFNAME detail {json}",
5012 "OSPF information\n"
5016 "detail of all neighbors\n"
5017 "JavaScript Object Notation\n")
5020 u_short instance
= 0;
5021 u_char uj
= use_json(argc
, argv
);
5023 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
5024 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
5027 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 1, argv
, uj
);
5030 /* Show functions */
5032 show_lsa_summary (struct vty
*vty
, struct ospf_lsa
*lsa
, int self
)
5034 struct router_lsa
*rl
;
5035 struct summary_lsa
*sl
;
5036 struct as_external_lsa
*asel
;
5037 struct prefix_ipv4 p
;
5040 /* If self option is set, check LSA self flag. */
5041 if (self
== 0 || IS_LSA_SELF (lsa
))
5043 /* LSA common part show. */
5044 vty_out (vty
, "%-15s ", inet_ntoa (lsa
->data
->id
));
5045 vty_out (vty
, "%-15s %4d 0x%08lx 0x%04x",
5046 inet_ntoa (lsa
->data
->adv_router
), LS_AGE (lsa
),
5047 (u_long
)ntohl (lsa
->data
->ls_seqnum
), ntohs (lsa
->data
->checksum
));
5048 /* LSA specific part show. */
5049 switch (lsa
->data
->type
)
5051 case OSPF_ROUTER_LSA
:
5052 rl
= (struct router_lsa
*) lsa
->data
;
5053 vty_out (vty
, " %-d", ntohs (rl
->links
));
5055 case OSPF_SUMMARY_LSA
:
5056 sl
= (struct summary_lsa
*) lsa
->data
;
5059 p
.prefix
= sl
->header
.id
;
5060 p
.prefixlen
= ip_masklen (sl
->mask
);
5061 apply_mask_ipv4 (&p
);
5063 vty_out (vty
, " %s/%d", inet_ntoa (p
.prefix
), p
.prefixlen
);
5065 case OSPF_AS_EXTERNAL_LSA
:
5066 case OSPF_AS_NSSA_LSA
:
5067 asel
= (struct as_external_lsa
*) lsa
->data
;
5070 p
.prefix
= asel
->header
.id
;
5071 p
.prefixlen
= ip_masklen (asel
->mask
);
5072 apply_mask_ipv4 (&p
);
5074 vty_out (vty
, " %s %s/%d [0x%lx]",
5075 IS_EXTERNAL_METRIC (asel
->e
[0].tos
) ? "E2" : "E1",
5076 inet_ntoa (p
.prefix
), p
.prefixlen
,
5077 (u_long
)ntohl (asel
->e
[0].route_tag
));
5079 case OSPF_NETWORK_LSA
:
5080 case OSPF_ASBR_SUMMARY_LSA
:
5081 #ifdef HAVE_OPAQUE_LSA
5082 case OSPF_OPAQUE_LINK_LSA
:
5083 case OSPF_OPAQUE_AREA_LSA
:
5084 case OSPF_OPAQUE_AS_LSA
:
5085 #endif /* HAVE_OPAQUE_LSA */
5089 vty_out (vty
, VTY_NEWLINE
);
5095 static const char *show_database_desc
[] =
5098 "Router Link States",
5100 "Summary Link States",
5101 "ASBR-Summary Link States",
5102 "AS External Link States",
5103 "Group Membership LSA",
5104 "NSSA-external Link States",
5105 #ifdef HAVE_OPAQUE_LSA
5107 "Link-Local Opaque-LSA",
5108 "Area-Local Opaque-LSA",
5109 "AS-external Opaque-LSA",
5110 #endif /* HAVE_OPAQUE_LSA */
5113 static const char *show_database_header
[] =
5116 "Link ID ADV Router Age Seq# CkSum Link count",
5117 "Link ID ADV Router Age Seq# CkSum",
5118 "Link ID ADV Router Age Seq# CkSum Route",
5119 "Link ID ADV Router Age Seq# CkSum",
5120 "Link ID ADV Router Age Seq# CkSum Route",
5121 " --- header for Group Member ----",
5122 "Link ID ADV Router Age Seq# CkSum Route",
5123 #ifdef HAVE_OPAQUE_LSA
5125 "Opaque-Type/Id ADV Router Age Seq# CkSum",
5126 "Opaque-Type/Id ADV Router Age Seq# CkSum",
5127 "Opaque-Type/Id ADV Router Age Seq# CkSum",
5128 #endif /* HAVE_OPAQUE_LSA */
5132 show_ip_ospf_database_header (struct vty
*vty
, struct ospf_lsa
*lsa
)
5134 struct router_lsa
*rlsa
= (struct router_lsa
*) lsa
->data
;
5136 vty_out (vty
, " LS age: %d%s", LS_AGE (lsa
), VTY_NEWLINE
);
5137 vty_out (vty
, " Options: 0x%-2x : %s%s",
5139 ospf_options_dump(lsa
->data
->options
),
5141 vty_out (vty
, " LS Flags: 0x%-2x %s%s",
5143 ((lsa
->flags
& OSPF_LSA_LOCAL_XLT
) ? "(Translated from Type-7)" : ""),
5146 if (lsa
->data
->type
== OSPF_ROUTER_LSA
)
5148 vty_out (vty
, " Flags: 0x%x" , rlsa
->flags
);
5151 vty_out (vty
, " :%s%s%s%s",
5152 IS_ROUTER_LSA_BORDER (rlsa
) ? " ABR" : "",
5153 IS_ROUTER_LSA_EXTERNAL (rlsa
) ? " ASBR" : "",
5154 IS_ROUTER_LSA_VIRTUAL (rlsa
) ? " VL-endpoint" : "",
5155 IS_ROUTER_LSA_SHORTCUT (rlsa
) ? " Shortcut" : "");
5157 vty_out (vty
, "%s", VTY_NEWLINE
);
5159 vty_out (vty
, " LS Type: %s%s",
5160 LOOKUP (ospf_lsa_type_msg
, lsa
->data
->type
), VTY_NEWLINE
);
5161 vty_out (vty
, " Link State ID: %s %s%s", inet_ntoa (lsa
->data
->id
),
5162 LOOKUP (ospf_link_state_id_type_msg
, lsa
->data
->type
), VTY_NEWLINE
);
5163 vty_out (vty
, " Advertising Router: %s%s",
5164 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
5165 vty_out (vty
, " LS Seq Number: %08lx%s", (u_long
)ntohl (lsa
->data
->ls_seqnum
),
5167 vty_out (vty
, " Checksum: 0x%04x%s", ntohs (lsa
->data
->checksum
),
5169 vty_out (vty
, " Length: %d%s", ntohs (lsa
->data
->length
), VTY_NEWLINE
);
5172 const char *link_type_desc
[] =
5175 "another Router (point-to-point)",
5176 "a Transit Network",
5181 const char *link_id_desc
[] =
5184 "Neighboring Router ID",
5185 "Designated Router address",
5187 "Neighboring Router ID",
5190 const char *link_data_desc
[] =
5193 "Router Interface address",
5194 "Router Interface address",
5196 "Router Interface address",
5199 /* Show router-LSA each Link information. */
5201 show_ip_ospf_database_router_links (struct vty
*vty
,
5202 struct router_lsa
*rl
)
5207 len
= ntohs (rl
->header
.length
) - 4;
5208 for (i
= 0; i
< ntohs (rl
->links
) && len
> 0; len
-= 12, i
++)
5210 type
= rl
->link
[i
].type
;
5212 vty_out (vty
, " Link connected to: %s%s",
5213 link_type_desc
[type
], VTY_NEWLINE
);
5214 vty_out (vty
, " (Link ID) %s: %s%s", link_id_desc
[type
],
5215 inet_ntoa (rl
->link
[i
].link_id
), VTY_NEWLINE
);
5216 vty_out (vty
, " (Link Data) %s: %s%s", link_data_desc
[type
],
5217 inet_ntoa (rl
->link
[i
].link_data
), VTY_NEWLINE
);
5218 vty_out (vty
, " Number of TOS metrics: 0%s", VTY_NEWLINE
);
5219 vty_out (vty
, " TOS 0 Metric: %d%s",
5220 ntohs (rl
->link
[i
].metric
), VTY_NEWLINE
);
5221 vty_out (vty
, "%s", VTY_NEWLINE
);
5225 /* Show router-LSA detail information. */
5227 show_router_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5231 struct router_lsa
*rl
= (struct router_lsa
*) lsa
->data
;
5233 show_ip_ospf_database_header (vty
, lsa
);
5235 vty_out (vty
, " Number of Links: %d%s%s", ntohs (rl
->links
),
5236 VTY_NEWLINE
, VTY_NEWLINE
);
5238 show_ip_ospf_database_router_links (vty
, rl
);
5239 vty_out (vty
, "%s", VTY_NEWLINE
);
5245 /* Show network-LSA detail information. */
5247 show_network_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5253 struct network_lsa
*nl
= (struct network_lsa
*) lsa
->data
;
5255 show_ip_ospf_database_header (vty
, lsa
);
5257 vty_out (vty
, " Network Mask: /%d%s",
5258 ip_masklen (nl
->mask
), VTY_NEWLINE
);
5260 length
= ntohs (lsa
->data
->length
) - OSPF_LSA_HEADER_SIZE
- 4;
5262 for (i
= 0; length
> 0; i
++, length
-= 4)
5263 vty_out (vty
, " Attached Router: %s%s",
5264 inet_ntoa (nl
->routers
[i
]), VTY_NEWLINE
);
5266 vty_out (vty
, "%s", VTY_NEWLINE
);
5272 /* Show summary-LSA detail information. */
5274 show_summary_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5278 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
5280 show_ip_ospf_database_header (vty
, lsa
);
5282 vty_out (vty
, " Network Mask: /%d%s", ip_masklen (sl
->mask
),
5284 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
5286 vty_out (vty
, "%s", VTY_NEWLINE
);
5292 /* Show summary-ASBR-LSA detail information. */
5294 show_summary_asbr_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5298 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
5300 show_ip_ospf_database_header (vty
, lsa
);
5302 vty_out (vty
, " Network Mask: /%d%s",
5303 ip_masklen (sl
->mask
), VTY_NEWLINE
);
5304 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
5306 vty_out (vty
, "%s", VTY_NEWLINE
);
5312 /* Show AS-external-LSA detail information. */
5314 show_as_external_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5318 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5320 show_ip_ospf_database_header (vty
, lsa
);
5322 vty_out (vty
, " Network Mask: /%d%s",
5323 ip_masklen (al
->mask
), VTY_NEWLINE
);
5324 vty_out (vty
, " Metric Type: %s%s",
5325 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5326 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
5327 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
5328 vty_out (vty
, " Metric: %d%s",
5329 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
5330 vty_out (vty
, " Forward Address: %s%s",
5331 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
5333 vty_out (vty
, " External Route Tag: %lu%s%s",
5334 (u_long
)ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
5342 show_as_external_lsa_stdvty (struct ospf_lsa
*lsa
)
5344 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5346 /* show_ip_ospf_database_header (vty, lsa); */
5348 zlog_debug( " Network Mask: /%d%s",
5349 ip_masklen (al
->mask
), "\n");
5350 zlog_debug( " Metric Type: %s%s",
5351 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5352 "2 (Larger than any link state path)" : "1", "\n");
5353 zlog_debug( " TOS: 0%s", "\n");
5354 zlog_debug( " Metric: %d%s",
5355 GET_METRIC (al
->e
[0].metric
), "\n");
5356 zlog_debug( " Forward Address: %s%s",
5357 inet_ntoa (al
->e
[0].fwd_addr
), "\n");
5359 zlog_debug( " External Route Tag: %u%s%s",
5360 ntohl (al
->e
[0].route_tag
), "\n", "\n");
5366 /* Show AS-NSSA-LSA detail information. */
5368 show_as_nssa_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5372 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5374 show_ip_ospf_database_header (vty
, lsa
);
5376 vty_out (vty
, " Network Mask: /%d%s",
5377 ip_masklen (al
->mask
), VTY_NEWLINE
);
5378 vty_out (vty
, " Metric Type: %s%s",
5379 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5380 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
5381 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
5382 vty_out (vty
, " Metric: %d%s",
5383 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
5384 vty_out (vty
, " NSSA: Forward Address: %s%s",
5385 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
5387 vty_out (vty
, " External Route Tag: %u%s%s",
5388 ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
5395 show_func_dummy (struct vty
*vty
, struct ospf_lsa
*lsa
)
5400 #ifdef HAVE_OPAQUE_LSA
5402 show_opaque_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5406 show_ip_ospf_database_header (vty
, lsa
);
5407 show_opaque_info_detail (vty
, lsa
);
5409 vty_out (vty
, "%s", VTY_NEWLINE
);
5413 #endif /* HAVE_OPAQUE_LSA */
5415 int (*show_function
[])(struct vty
*, struct ospf_lsa
*) =
5418 show_router_lsa_detail
,
5419 show_network_lsa_detail
,
5420 show_summary_lsa_detail
,
5421 show_summary_asbr_lsa_detail
,
5422 show_as_external_lsa_detail
,
5424 show_as_nssa_lsa_detail
, /* almost same as external */
5425 #ifdef HAVE_OPAQUE_LSA
5427 show_opaque_lsa_detail
,
5428 show_opaque_lsa_detail
,
5429 show_opaque_lsa_detail
,
5430 #endif /* HAVE_OPAQUE_LSA */
5434 show_lsa_prefix_set (struct vty
*vty
, struct prefix_ls
*lp
, struct in_addr
*id
,
5435 struct in_addr
*adv_router
)
5437 memset (lp
, 0, sizeof (struct prefix_ls
));
5441 else if (adv_router
== NULL
)
5450 lp
->adv_router
= *adv_router
;
5455 show_lsa_detail_proc (struct vty
*vty
, struct route_table
*rt
,
5456 struct in_addr
*id
, struct in_addr
*adv_router
)
5458 struct prefix_ls lp
;
5459 struct route_node
*rn
, *start
;
5460 struct ospf_lsa
*lsa
;
5462 show_lsa_prefix_set (vty
, &lp
, id
, adv_router
);
5463 start
= route_node_get (rt
, (struct prefix
*) &lp
);
5466 route_lock_node (start
);
5467 for (rn
= start
; rn
; rn
= route_next_until (rn
, start
))
5468 if ((lsa
= rn
->info
))
5470 if (show_function
[lsa
->data
->type
] != NULL
)
5471 show_function
[lsa
->data
->type
] (vty
, lsa
);
5473 route_unlock_node (start
);
5477 /* Show detail LSA information
5478 -- if id is NULL then show all LSAs. */
5480 show_lsa_detail (struct vty
*vty
, struct ospf
*ospf
, int type
,
5481 struct in_addr
*id
, struct in_addr
*adv_router
)
5483 struct listnode
*node
;
5484 struct ospf_area
*area
;
5488 case OSPF_AS_EXTERNAL_LSA
:
5489 #ifdef HAVE_OPAQUE_LSA
5490 case OSPF_OPAQUE_AS_LSA
:
5491 #endif /* HAVE_OPAQUE_LSA */
5492 vty_out (vty
, " %s %s%s",
5493 show_database_desc
[type
],
5494 VTY_NEWLINE
, VTY_NEWLINE
);
5495 show_lsa_detail_proc (vty
, AS_LSDB (ospf
, type
), id
, adv_router
);
5498 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5500 vty_out (vty
, "%s %s (Area %s)%s%s",
5501 VTY_NEWLINE
, show_database_desc
[type
],
5502 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5503 show_lsa_detail_proc (vty
, AREA_LSDB (area
, type
), id
, adv_router
);
5510 show_lsa_detail_adv_router_proc (struct vty
*vty
, struct route_table
*rt
,
5511 struct in_addr
*adv_router
)
5513 struct route_node
*rn
;
5514 struct ospf_lsa
*lsa
;
5516 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
5517 if ((lsa
= rn
->info
))
5518 if (IPV4_ADDR_SAME (adv_router
, &lsa
->data
->adv_router
))
5520 if (CHECK_FLAG (lsa
->flags
, OSPF_LSA_LOCAL_XLT
))
5522 if (show_function
[lsa
->data
->type
] != NULL
)
5523 show_function
[lsa
->data
->type
] (vty
, lsa
);
5527 /* Show detail LSA information. */
5529 show_lsa_detail_adv_router (struct vty
*vty
, struct ospf
*ospf
, int type
,
5530 struct in_addr
*adv_router
)
5532 struct listnode
*node
;
5533 struct ospf_area
*area
;
5537 case OSPF_AS_EXTERNAL_LSA
:
5538 #ifdef HAVE_OPAQUE_LSA
5539 case OSPF_OPAQUE_AS_LSA
:
5540 #endif /* HAVE_OPAQUE_LSA */
5541 vty_out (vty
, " %s %s%s",
5542 show_database_desc
[type
],
5543 VTY_NEWLINE
, VTY_NEWLINE
);
5544 show_lsa_detail_adv_router_proc (vty
, AS_LSDB (ospf
, type
),
5548 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5550 vty_out (vty
, "%s %s (Area %s)%s%s",
5551 VTY_NEWLINE
, show_database_desc
[type
],
5552 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5553 show_lsa_detail_adv_router_proc (vty
, AREA_LSDB (area
, type
),
5561 show_ip_ospf_database_summary (struct vty
*vty
, struct ospf
*ospf
, int self
)
5563 struct ospf_lsa
*lsa
;
5564 struct route_node
*rn
;
5565 struct ospf_area
*area
;
5566 struct listnode
*node
;
5569 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5571 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5575 case OSPF_AS_EXTERNAL_LSA
:
5576 #ifdef HAVE_OPAQUE_LSA
5577 case OSPF_OPAQUE_AS_LSA
:
5578 #endif /* HAVE_OPAQUE_LSA */
5583 if (ospf_lsdb_count_self (area
->lsdb
, type
) > 0 ||
5584 (!self
&& ospf_lsdb_count (area
->lsdb
, type
) > 0))
5586 vty_out (vty
, " %s (Area %s)%s%s",
5587 show_database_desc
[type
],
5588 ospf_area_desc_string (area
),
5589 VTY_NEWLINE
, VTY_NEWLINE
);
5590 vty_out (vty
, "%s%s", show_database_header
[type
], VTY_NEWLINE
);
5592 LSDB_LOOP (AREA_LSDB (area
, type
), rn
, lsa
)
5593 show_lsa_summary (vty
, lsa
, self
);
5595 vty_out (vty
, "%s", VTY_NEWLINE
);
5600 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5604 case OSPF_AS_EXTERNAL_LSA
:
5605 #ifdef HAVE_OPAQUE_LSA
5606 case OSPF_OPAQUE_AS_LSA
:
5607 #endif /* HAVE_OPAQUE_LSA */
5612 if (ospf_lsdb_count_self (ospf
->lsdb
, type
) ||
5613 (!self
&& ospf_lsdb_count (ospf
->lsdb
, type
)))
5615 vty_out (vty
, " %s%s%s",
5616 show_database_desc
[type
],
5617 VTY_NEWLINE
, VTY_NEWLINE
);
5618 vty_out (vty
, "%s%s", show_database_header
[type
],
5621 LSDB_LOOP (AS_LSDB (ospf
, type
), rn
, lsa
)
5622 show_lsa_summary (vty
, lsa
, self
);
5624 vty_out (vty
, "%s", VTY_NEWLINE
);
5628 vty_out (vty
, "%s", VTY_NEWLINE
);
5632 show_ip_ospf_database_maxage (struct vty
*vty
, struct ospf
*ospf
)
5634 struct route_node
*rn
;
5636 vty_out (vty
, "%s MaxAge Link States:%s%s",
5637 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
5639 for (rn
= route_top (ospf
->maxage_lsa
); rn
; rn
= route_next (rn
))
5641 struct ospf_lsa
*lsa
;
5643 if ((lsa
= rn
->info
) != NULL
)
5645 vty_out (vty
, "Link type: %d%s", lsa
->data
->type
, VTY_NEWLINE
);
5646 vty_out (vty
, "Link State ID: %s%s",
5647 inet_ntoa (lsa
->data
->id
), VTY_NEWLINE
);
5648 vty_out (vty
, "Advertising Router: %s%s",
5649 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
5650 vty_out (vty
, "LSA lock count: %d%s", lsa
->lock
, VTY_NEWLINE
);
5651 vty_out (vty
, "%s", VTY_NEWLINE
);
5656 #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
5657 #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
5659 #ifdef HAVE_OPAQUE_LSA
5660 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
5661 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
5662 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
5663 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
5664 #else /* HAVE_OPAQUE_LSA */
5665 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
5666 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
5667 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
5668 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
5669 #endif /* HAVE_OPAQUE_LSA */
5671 #define OSPF_LSA_TYPES_CMD_STR \
5672 "asbr-summary|external|network|router|summary" \
5673 OSPF_LSA_TYPE_NSSA_CMD_STR \
5674 OSPF_LSA_TYPE_OPAQUE_CMD_STR
5676 #define OSPF_LSA_TYPES_DESC \
5677 "ASBR summary link states\n" \
5678 "External link states\n" \
5679 "Network link states\n" \
5680 "Router link states\n" \
5681 "Network summary link states\n" \
5682 OSPF_LSA_TYPE_NSSA_DESC \
5683 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
5684 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
5685 OSPF_LSA_TYPE_OPAQUE_AS_DESC
5688 show_ip_ospf_database_common (struct vty
*vty
, struct ospf
*ospf
,
5689 int arg_base
, int argc
, const char **argv
)
5692 struct in_addr id
, adv_router
;
5695 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5698 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5699 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5702 if (argc
== arg_base
+ 0)
5704 show_ip_ospf_database_summary (vty
, ospf
, 0);
5708 /* Set database type to show. */
5709 if (strncmp (argv
[arg_base
+ 0], "r", 1) == 0)
5710 type
= OSPF_ROUTER_LSA
;
5711 else if (strncmp (argv
[arg_base
+ 0], "ne", 2) == 0)
5712 type
= OSPF_NETWORK_LSA
;
5713 else if (strncmp (argv
[arg_base
+ 0], "ns", 2) == 0)
5714 type
= OSPF_AS_NSSA_LSA
;
5715 else if (strncmp (argv
[arg_base
+ 0], "su", 2) == 0)
5716 type
= OSPF_SUMMARY_LSA
;
5717 else if (strncmp (argv
[arg_base
+ 0], "a", 1) == 0)
5718 type
= OSPF_ASBR_SUMMARY_LSA
;
5719 else if (strncmp (argv
[arg_base
+ 0], "e", 1) == 0)
5720 type
= OSPF_AS_EXTERNAL_LSA
;
5721 else if (strncmp (argv
[arg_base
+ 0], "se", 2) == 0)
5723 show_ip_ospf_database_summary (vty
, ospf
, 1);
5726 else if (strncmp (argv
[arg_base
+ 0], "m", 1) == 0)
5728 show_ip_ospf_database_maxage (vty
, ospf
);
5731 #ifdef HAVE_OPAQUE_LSA
5732 else if (strncmp (argv
[arg_base
+ 0], "opaque-l", 8) == 0)
5733 type
= OSPF_OPAQUE_LINK_LSA
;
5734 else if (strncmp (argv
[arg_base
+ 0], "opaque-ar", 9) == 0)
5735 type
= OSPF_OPAQUE_AREA_LSA
;
5736 else if (strncmp (argv
[arg_base
+ 0], "opaque-as", 9) == 0)
5737 type
= OSPF_OPAQUE_AS_LSA
;
5738 #endif /* HAVE_OPAQUE_LSA */
5742 /* `show ip ospf database LSA'. */
5743 if (argc
== arg_base
+ 1)
5744 show_lsa_detail (vty
, ospf
, type
, NULL
, NULL
);
5745 else if (argc
>= arg_base
+ 2)
5747 ret
= inet_aton (argv
[arg_base
+ 1], &id
);
5751 /* `show ip ospf database LSA ID'. */
5752 if (argc
== arg_base
+ 2)
5753 show_lsa_detail (vty
, ospf
, type
, &id
, NULL
);
5754 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
5755 else if (argc
== arg_base
+ 3)
5757 if (strncmp (argv
[arg_base
+ 2], "s", 1) == 0)
5758 adv_router
= ospf
->router_id
;
5761 ret
= inet_aton (argv
[arg_base
+ 2], &adv_router
);
5765 show_lsa_detail (vty
, ospf
, type
, &id
, &adv_router
);
5772 DEFUN (show_ip_ospf_database
,
5773 show_ip_ospf_database_cmd
,
5774 "show ip ospf database",
5777 "OSPF information\n"
5778 "Database summary\n")
5782 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5785 return (show_ip_ospf_database_common(vty
, ospf
, 0, argc
, argv
));
5788 ALIAS (show_ip_ospf_database
,
5789 show_ip_ospf_database_type_cmd
,
5790 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR
"|max-age|self-originate)",
5793 "OSPF information\n"
5794 "Database summary\n"
5796 "LSAs in MaxAge list\n"
5797 "Self-originated link states\n")
5799 ALIAS (show_ip_ospf_database
,
5800 show_ip_ospf_database_type_id_cmd
,
5801 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR
") A.B.C.D",
5804 "OSPF information\n"
5805 "Database summary\n"
5807 "Link State ID (as an IP address)\n")
5809 ALIAS (show_ip_ospf_database
,
5810 show_ip_ospf_database_type_id_adv_router_cmd
,
5811 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR
") A.B.C.D adv-router A.B.C.D",
5814 "OSPF information\n"
5815 "Database summary\n"
5817 "Link State ID (as an IP address)\n"
5818 "Advertising Router link states\n"
5819 "Advertising Router (as an IP address)\n")
5821 ALIAS (show_ip_ospf_database
,
5822 show_ip_ospf_database_type_id_self_cmd
,
5823 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR
") A.B.C.D (self-originate|)",
5826 "OSPF information\n"
5827 "Database summary\n"
5829 "Link State ID (as an IP address)\n"
5830 "Self-originated link states\n"
5833 DEFUN (show_ip_ospf_instance_database
,
5834 show_ip_ospf_instance_database_cmd
,
5835 "show ip ospf <1-65535> database",
5838 "OSPF information\n"
5840 "Database summary\n")
5843 u_short instance
= 0;
5845 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
5847 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5850 return (show_ip_ospf_database_common(vty
, ospf
, 1, argc
, argv
));
5853 ALIAS (show_ip_ospf_instance_database
,
5854 show_ip_ospf_instance_database_type_cmd
,
5855 "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR
"|max-age|self-originate)",
5858 "OSPF information\n"
5860 "Database summary\n"
5862 "LSAs in MaxAge list\n"
5863 "Self-originated link states\n")
5865 ALIAS (show_ip_ospf_instance_database
,
5866 show_ip_ospf_instance_database_type_id_cmd
,
5867 "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR
") A.B.C.D",
5870 "OSPF information\n"
5872 "Database summary\n"
5874 "Link State ID (as an IP address)\n")
5876 ALIAS (show_ip_ospf_instance_database
,
5877 show_ip_ospf_instance_database_type_id_adv_router_cmd
,
5878 "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR
") A.B.C.D adv-router A.B.C.D",
5881 "OSPF information\n"
5883 "Database summary\n"
5885 "Link State ID (as an IP address)\n"
5886 "Advertising Router link states\n"
5887 "Advertising Router (as an IP address)\n")
5889 ALIAS (show_ip_ospf_instance_database
,
5890 show_ip_ospf_instance_database_type_id_self_cmd
,
5891 "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR
") A.B.C.D (self-originate|)",
5894 "OSPF information\n"
5896 "Database summary\n"
5898 "Link State ID (as an IP address)\n"
5899 "Self-originated link states\n"
5904 show_ip_ospf_database_type_adv_router_common (struct vty
*vty
, struct ospf
*ospf
,
5905 int arg_base
, int argc
, const char **argv
)
5908 struct in_addr adv_router
;
5911 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5914 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5915 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5917 if (argc
!= arg_base
+ 2)
5920 /* Set database type to show. */
5921 if (strncmp (argv
[arg_base
+ 0], "r", 1) == 0)
5922 type
= OSPF_ROUTER_LSA
;
5923 else if (strncmp (argv
[arg_base
+ 0], "ne", 2) == 0)
5924 type
= OSPF_NETWORK_LSA
;
5925 else if (strncmp (argv
[arg_base
+ 0], "ns", 2) == 0)
5926 type
= OSPF_AS_NSSA_LSA
;
5927 else if (strncmp (argv
[arg_base
+ 0], "s", 1) == 0)
5928 type
= OSPF_SUMMARY_LSA
;
5929 else if (strncmp (argv
[arg_base
+ 0], "a", 1) == 0)
5930 type
= OSPF_ASBR_SUMMARY_LSA
;
5931 else if (strncmp (argv
[arg_base
+ 0], "e", 1) == 0)
5932 type
= OSPF_AS_EXTERNAL_LSA
;
5933 #ifdef HAVE_OPAQUE_LSA
5934 else if (strncmp (argv
[arg_base
+ 0], "opaque-l", 8) == 0)
5935 type
= OSPF_OPAQUE_LINK_LSA
;
5936 else if (strncmp (argv
[arg_base
+ 0], "opaque-ar", 9) == 0)
5937 type
= OSPF_OPAQUE_AREA_LSA
;
5938 else if (strncmp (argv
[arg_base
+ 0], "opaque-as", 9) == 0)
5939 type
= OSPF_OPAQUE_AS_LSA
;
5940 #endif /* HAVE_OPAQUE_LSA */
5944 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
5945 if (strncmp (argv
[arg_base
+ 1], "s", 1) == 0)
5946 adv_router
= ospf
->router_id
;
5949 ret
= inet_aton (argv
[arg_base
+ 1], &adv_router
);
5954 show_lsa_detail_adv_router (vty
, ospf
, type
, &adv_router
);
5959 DEFUN (show_ip_ospf_database_type_adv_router
,
5960 show_ip_ospf_database_type_adv_router_cmd
,
5961 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR
") adv-router A.B.C.D",
5964 "OSPF information\n"
5965 "Database summary\n"
5967 "Advertising Router link states\n"
5968 "Advertising Router (as an IP address)\n")
5972 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5975 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 0, argc
, argv
));
5978 ALIAS (show_ip_ospf_database_type_adv_router
,
5979 show_ip_ospf_database_type_self_cmd
,
5980 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR
") (self-originate|)",
5983 "OSPF information\n"
5984 "Database summary\n"
5986 "Self-originated link states\n")
5988 DEFUN (show_ip_ospf_instance_database_type_adv_router
,
5989 show_ip_ospf_instance_database_type_adv_router_cmd
,
5990 "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR
") adv-router A.B.C.D",
5993 "OSPF information\n"
5995 "Database summary\n"
5997 "Advertising Router link states\n"
5998 "Advertising Router (as an IP address)\n")
6001 u_short instance
= 0;
6003 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
6005 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
6008 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 1, argc
, argv
));
6011 ALIAS (show_ip_ospf_instance_database_type_adv_router
,
6012 show_ip_ospf_instance_database_type_self_cmd
,
6013 "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR
") (self-originate|)",
6016 "OSPF information\n"
6018 "Database summary\n"
6020 "Self-originated link states\n")
6022 DEFUN (ip_ospf_authentication_args
,
6023 ip_ospf_authentication_args_addr_cmd
,
6024 "ip ospf authentication (null|message-digest) A.B.C.D",
6026 "OSPF interface commands\n"
6027 "Enable authentication on this interface\n"
6028 "Use null authentication\n"
6029 "Use message-digest authentication\n"
6030 "Address of interface")
6032 struct interface
*ifp
;
6033 struct in_addr addr
;
6035 struct ospf_if_params
*params
;
6038 params
= IF_DEF_PARAMS (ifp
);
6042 ret
= inet_aton(argv
[1], &addr
);
6045 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6050 params
= ospf_get_if_params (ifp
, addr
);
6051 ospf_if_update_params (ifp
, addr
);
6054 /* Handle null authentication */
6055 if ( argv
[0][0] == 'n' )
6057 SET_IF_PARAM (params
, auth_type
);
6058 params
->auth_type
= OSPF_AUTH_NULL
;
6062 /* Handle message-digest authentication */
6063 if ( argv
[0][0] == 'm' )
6065 SET_IF_PARAM (params
, auth_type
);
6066 params
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
6070 vty_out (vty
, "You shouldn't get here!%s", VTY_NEWLINE
);
6074 ALIAS (ip_ospf_authentication_args
,
6075 ip_ospf_authentication_args_cmd
,
6076 "ip ospf authentication (null|message-digest)",
6078 "OSPF interface commands\n"
6079 "Enable authentication on this interface\n"
6080 "Use null authentication\n"
6081 "Use message-digest authentication\n")
6083 DEFUN (ip_ospf_authentication
,
6084 ip_ospf_authentication_addr_cmd
,
6085 "ip ospf authentication A.B.C.D",
6087 "OSPF interface commands\n"
6088 "Enable authentication on this interface\n"
6089 "Address of interface")
6091 struct interface
*ifp
;
6092 struct in_addr addr
;
6094 struct ospf_if_params
*params
;
6097 params
= IF_DEF_PARAMS (ifp
);
6101 ret
= inet_aton(argv
[0], &addr
);
6104 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6109 params
= ospf_get_if_params (ifp
, addr
);
6110 ospf_if_update_params (ifp
, addr
);
6113 SET_IF_PARAM (params
, auth_type
);
6114 params
->auth_type
= OSPF_AUTH_SIMPLE
;
6119 ALIAS (ip_ospf_authentication
,
6120 ip_ospf_authentication_cmd
,
6121 "ip ospf authentication",
6123 "OSPF interface commands\n"
6124 "Enable authentication on this interface\n")
6126 DEFUN (no_ip_ospf_authentication_args
,
6127 no_ip_ospf_authentication_args_addr_cmd
,
6128 "no ip ospf authentication (null|message-digest) A.B.C.D",
6131 "OSPF interface commands\n"
6132 "Enable authentication on this interface\n"
6133 "Use null authentication\n"
6134 "Use message-digest authentication\n"
6135 "Address of interface")
6137 struct interface
*ifp
;
6138 struct in_addr addr
;
6140 struct ospf_if_params
*params
;
6141 struct route_node
*rn
;
6145 params
= IF_DEF_PARAMS (ifp
);
6149 ret
= inet_aton(argv
[1], &addr
);
6152 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6157 params
= ospf_lookup_if_params (ifp
, addr
);
6160 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
6163 params
->auth_type
= OSPF_AUTH_NOTSET
;
6164 UNSET_IF_PARAM (params
, auth_type
);
6165 if (params
!= IF_DEF_PARAMS (ifp
))
6167 ospf_free_if_params (ifp
, addr
);
6168 ospf_if_update_params (ifp
, addr
);
6173 if ( argv
[0][0] == 'n' )
6175 auth_type
= OSPF_AUTH_NULL
;
6177 else if ( argv
[0][0] == 'm' )
6179 auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
6183 vty_out (vty
, "Unexpected input encountered%s", VTY_NEWLINE
);
6187 * Here we have a case where the user has entered
6188 * 'no ip ospf authentication (null | message_digest )'
6189 * we need to find if we have any ip addresses underneath it that
6190 * correspond to the associated type.
6192 if (params
->auth_type
== auth_type
)
6194 params
->auth_type
= OSPF_AUTH_NOTSET
;
6195 UNSET_IF_PARAM (params
, auth_type
);
6198 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
6200 if ((params
= rn
->info
))
6202 if (params
->auth_type
== auth_type
)
6204 params
->auth_type
= OSPF_AUTH_NOTSET
;
6205 UNSET_IF_PARAM (params
, auth_type
);
6206 if (params
!= IF_DEF_PARAMS (ifp
))
6208 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
6209 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
6219 ALIAS (no_ip_ospf_authentication_args
,
6220 no_ip_ospf_authentication_args_cmd
,
6221 "no ip ospf authentication (null|message-digest)",
6224 "OSPF interface commands\n"
6225 "Enable authentication on this interface\n"
6226 "Use null authentication\n"
6227 "Use message-digest authentication\n")
6229 DEFUN (no_ip_ospf_authentication
,
6230 no_ip_ospf_authentication_addr_cmd
,
6231 "no ip ospf authentication A.B.C.D",
6234 "OSPF interface commands\n"
6235 "Enable authentication on this interface\n"
6236 "Address of interface")
6238 struct interface
*ifp
;
6239 struct in_addr addr
;
6241 struct ospf_if_params
*params
;
6242 struct route_node
*rn
;
6245 params
= IF_DEF_PARAMS (ifp
);
6249 ret
= inet_aton(argv
[0], &addr
);
6252 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6257 params
= ospf_lookup_if_params (ifp
, addr
);
6260 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
6264 params
->auth_type
= OSPF_AUTH_NOTSET
;
6265 UNSET_IF_PARAM (params
, auth_type
);
6266 if (params
!= IF_DEF_PARAMS (ifp
))
6268 ospf_free_if_params (ifp
, addr
);
6269 ospf_if_update_params (ifp
, addr
);
6275 * When a user enters 'no ip ospf authentication'
6276 * We should remove all authentication types from
6279 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
6280 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
6281 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
6283 params
->auth_type
= OSPF_AUTH_NOTSET
;
6284 UNSET_IF_PARAM (params
, auth_type
);
6287 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
6289 if ((params
= rn
->info
))
6292 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
6293 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
6294 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
6296 params
->auth_type
= OSPF_AUTH_NOTSET
;
6297 UNSET_IF_PARAM (params
, auth_type
);
6298 if (params
!= IF_DEF_PARAMS (ifp
))
6300 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
6301 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
6311 ALIAS (no_ip_ospf_authentication
,
6312 no_ip_ospf_authentication_cmd
,
6313 "no ip ospf authentication",
6316 "OSPF interface commands\n"
6317 "Enable authentication on this interface\n")
6319 DEFUN (ip_ospf_authentication_key
,
6320 ip_ospf_authentication_key_addr_cmd
,
6321 "ip ospf authentication-key AUTH_KEY A.B.C.D",
6323 "OSPF interface commands\n"
6324 "Authentication password (key)\n"
6325 "The OSPF password (key)\n"
6326 "Address of interface")
6328 struct interface
*ifp
;
6329 struct in_addr addr
;
6331 struct ospf_if_params
*params
;
6334 params
= IF_DEF_PARAMS (ifp
);
6338 ret
= inet_aton(argv
[1], &addr
);
6341 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6346 params
= ospf_get_if_params (ifp
, addr
);
6347 ospf_if_update_params (ifp
, addr
);
6350 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
6351 strncpy ((char *) params
->auth_simple
, argv
[0], OSPF_AUTH_SIMPLE_SIZE
);
6352 SET_IF_PARAM (params
, auth_simple
);
6357 ALIAS (ip_ospf_authentication_key
,
6358 ip_ospf_authentication_key_cmd
,
6359 "ip ospf authentication-key AUTH_KEY",
6361 "OSPF interface commands\n"
6362 "Authentication password (key)\n"
6363 "The OSPF password (key)")
6365 ALIAS_HIDDEN (ip_ospf_authentication_key
,
6366 ospf_authentication_key_cmd
,
6367 "ospf authentication-key AUTH_KEY",
6368 "OSPF interface commands\n"
6369 "Authentication password (key)\n"
6370 "The OSPF password (key)")
6372 DEFUN (no_ip_ospf_authentication_key
,
6373 no_ip_ospf_authentication_key_authkey_addr_cmd
,
6374 "no ip ospf authentication-key AUTH_KEY A.B.C.D",
6377 "OSPF interface commands\n"
6378 "Authentication password (key)\n"
6379 "The OSPF password (key)")
6381 struct interface
*ifp
;
6382 struct in_addr addr
;
6383 struct ospf_if_params
*params
;
6387 params
= IF_DEF_PARAMS (ifp
);
6391 ret
= inet_aton(argv
[1], &addr
);
6394 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6399 params
= ospf_lookup_if_params (ifp
, addr
);
6404 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
);
6405 UNSET_IF_PARAM (params
, auth_simple
);
6407 if (params
!= IF_DEF_PARAMS (ifp
))
6409 ospf_free_if_params (ifp
, addr
);
6410 ospf_if_update_params (ifp
, addr
);
6416 ALIAS (no_ip_ospf_authentication_key
,
6417 no_ip_ospf_authentication_key_authkey_cmd
,
6418 "no ip ospf authentication-key AUTH_KEY",
6421 "OSPF interface commands\n"
6422 "Authentication password (key)\n")
6424 ALIAS (no_ip_ospf_authentication_key
,
6425 no_ip_ospf_authentication_key_cmd
,
6426 "no ip ospf authentication-key",
6429 "OSPF interface commands\n"
6430 "Authentication password (key)\n")
6432 ALIAS (no_ip_ospf_authentication_key
,
6433 no_ospf_authentication_key_cmd
,
6434 "no ospf authentication-key",
6436 "OSPF interface commands\n"
6437 "Authentication password (key)\n")
6439 ALIAS (no_ip_ospf_authentication_key
,
6440 no_ospf_authentication_key_authkey_cmd
,
6441 "no ospf authentication-key AUTH_KEY",
6443 "OSPF interface commands\n"
6444 "Authentication password (key)\n"
6445 "The OSPF password (key)\n")
6447 ALIAS (no_ip_ospf_authentication_key
,
6448 no_ospf_authentication_key_authkey_ip_cmd
,
6449 "no ospf authentication-key AUTH_KEY A.B.C.D",
6451 "OSPF interface commands\n"
6452 "Authentication password (key)\n"
6453 "The OSPF password (key)\n"
6454 "Address of interface")
6456 DEFUN (ip_ospf_message_digest_key
,
6457 ip_ospf_message_digest_key_addr_cmd
,
6458 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
6460 "OSPF interface commands\n"
6461 "Message digest authentication password (key)\n"
6463 "Use MD5 algorithm\n"
6464 "The OSPF password (key)"
6465 "Address of interface")
6467 struct interface
*ifp
;
6468 struct crypt_key
*ck
;
6470 struct in_addr addr
;
6472 struct ospf_if_params
*params
;
6475 params
= IF_DEF_PARAMS (ifp
);
6479 ret
= inet_aton(argv
[2], &addr
);
6482 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6487 params
= ospf_get_if_params (ifp
, addr
);
6488 ospf_if_update_params (ifp
, addr
);
6491 key_id
= strtol (argv
[0], NULL
, 10);
6492 if (ospf_crypt_key_lookup (params
->auth_crypt
, key_id
) != NULL
)
6494 vty_out (vty
, "OSPF: Key %d already exists%s", key_id
, VTY_NEWLINE
);
6498 ck
= ospf_crypt_key_new ();
6499 ck
->key_id
= (u_char
) key_id
;
6500 memset (ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
6501 strncpy ((char *) ck
->auth_key
, argv
[1], OSPF_AUTH_MD5_SIZE
);
6503 ospf_crypt_key_add (params
->auth_crypt
, ck
);
6504 SET_IF_PARAM (params
, auth_crypt
);
6509 ALIAS (ip_ospf_message_digest_key
,
6510 ip_ospf_message_digest_key_cmd
,
6511 "ip ospf message-digest-key <1-255> md5 KEY",
6513 "OSPF interface commands\n"
6514 "Message digest authentication password (key)\n"
6516 "Use MD5 algorithm\n"
6517 "The OSPF password (key)")
6519 ALIAS_HIDDEN (ip_ospf_message_digest_key
,
6520 ospf_message_digest_key_cmd
,
6521 "ospf message-digest-key <1-255> md5 KEY",
6522 "OSPF interface commands\n"
6523 "Message digest authentication password (key)\n"
6525 "Use MD5 algorithm\n"
6526 "The OSPF password (key)")
6528 DEFUN (no_ip_ospf_message_digest_key_md5
,
6529 no_ip_ospf_message_digest_key_md5_addr_cmd
,
6530 "no ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
6533 "OSPF interface commands\n"
6534 "Message digest authentication password (key)\n"
6536 "Use MD5 algorithm\n"
6537 "The OSPF password (key)"
6538 "Address of interface")
6540 struct interface
*ifp
;
6541 struct crypt_key
*ck
;
6543 struct in_addr addr
;
6545 struct ospf_if_params
*params
;
6548 params
= IF_DEF_PARAMS (ifp
);
6552 ret
= inet_aton(argv
[2], &addr
);
6555 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6560 params
= ospf_lookup_if_params (ifp
, addr
);
6565 key_id
= strtol (argv
[0], NULL
, 10);
6566 ck
= ospf_crypt_key_lookup (params
->auth_crypt
, key_id
);
6569 vty_out (vty
, "OSPF: Key %d does not exist%s", key_id
, VTY_NEWLINE
);
6573 ospf_crypt_key_delete (params
->auth_crypt
, key_id
);
6575 if (params
!= IF_DEF_PARAMS (ifp
))
6577 ospf_free_if_params (ifp
, addr
);
6578 ospf_if_update_params (ifp
, addr
);
6584 ALIAS (no_ip_ospf_message_digest_key_md5
,
6585 no_ip_ospf_message_digest_key_md5_cmd
,
6586 "no ip ospf message-digest-key <1-255> md5 KEY",
6589 "OSPF interface commands\n"
6590 "Message digest authentication password (key)\n"
6592 "Use MD5 algorithm\n"
6593 "The OSPF password (key)")
6595 DEFUN (no_ip_ospf_message_digest_key
,
6596 no_ip_ospf_message_digest_key_addr_cmd
,
6597 "no ip ospf message-digest-key <1-255> A.B.C.D",
6600 "OSPF interface commands\n"
6601 "Message digest authentication password (key)\n"
6603 "Address of interface")
6605 struct interface
*ifp
;
6606 struct crypt_key
*ck
;
6608 struct in_addr addr
;
6610 struct ospf_if_params
*params
;
6613 params
= IF_DEF_PARAMS (ifp
);
6617 ret
= inet_aton(argv
[1], &addr
);
6620 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6625 params
= ospf_lookup_if_params (ifp
, addr
);
6630 key_id
= strtol (argv
[0], NULL
, 10);
6631 ck
= ospf_crypt_key_lookup (params
->auth_crypt
, key_id
);
6634 vty_out (vty
, "OSPF: Key %d does not exist%s", key_id
, VTY_NEWLINE
);
6638 ospf_crypt_key_delete (params
->auth_crypt
, key_id
);
6640 if (params
!= IF_DEF_PARAMS (ifp
))
6642 ospf_free_if_params (ifp
, addr
);
6643 ospf_if_update_params (ifp
, addr
);
6649 ALIAS (no_ip_ospf_message_digest_key
,
6650 no_ip_ospf_message_digest_key_cmd
,
6651 "no ip ospf message-digest-key <1-255>",
6654 "OSPF interface commands\n"
6655 "Message digest authentication password (key)\n"
6658 ALIAS (no_ip_ospf_message_digest_key
,
6659 no_ospf_message_digest_key_cmd
,
6660 "no ospf message-digest-key <1-255>",
6662 "OSPF interface commands\n"
6663 "Message digest authentication password (key)\n"
6666 DEFUN (ip_ospf_cost
,
6667 ip_ospf_cost_u32_inet4_cmd
,
6668 "ip ospf cost <1-65535> A.B.C.D",
6670 "OSPF interface commands\n"
6673 "Address of interface")
6675 struct interface
*ifp
= vty
->index
;
6677 struct in_addr addr
;
6679 struct ospf_if_params
*params
;
6681 params
= IF_DEF_PARAMS (ifp
);
6683 cost
= strtol (argv
[0], NULL
, 10);
6685 /* cost range is <1-65535>. */
6686 if (cost
< 1 || cost
> 65535)
6688 vty_out (vty
, "Interface output cost is invalid%s", VTY_NEWLINE
);
6694 ret
= inet_aton(argv
[1], &addr
);
6697 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6702 params
= ospf_get_if_params (ifp
, addr
);
6703 ospf_if_update_params (ifp
, addr
);
6706 SET_IF_PARAM (params
, output_cost_cmd
);
6707 params
->output_cost_cmd
= cost
;
6709 ospf_if_recalculate_output_cost (ifp
);
6714 ALIAS (ip_ospf_cost
,
6715 ip_ospf_cost_u32_cmd
,
6716 "ip ospf cost <1-65535>",
6718 "OSPF interface commands\n"
6722 ALIAS_HIDDEN (ip_ospf_cost
,
6724 "ospf cost <1-65535>",
6725 "OSPF interface commands\n"
6729 ALIAS_HIDDEN (ip_ospf_cost
,
6730 ospf_cost_u32_inet4_cmd
,
6731 "ospf cost <1-65535> A.B.C.D",
6732 "OSPF interface commands\n"
6735 "Address of interface")
6737 DEFUN (no_ip_ospf_cost
,
6738 no_ip_ospf_cost_inet4_cmd
,
6739 "no ip ospf cost A.B.C.D",
6742 "OSPF interface commands\n"
6744 "Address of interface")
6746 struct interface
*ifp
= vty
->index
;
6747 struct in_addr addr
;
6749 struct ospf_if_params
*params
;
6752 params
= IF_DEF_PARAMS (ifp
);
6756 ret
= inet_aton(argv
[0], &addr
);
6759 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6764 params
= ospf_lookup_if_params (ifp
, addr
);
6769 UNSET_IF_PARAM (params
, output_cost_cmd
);
6771 if (params
!= IF_DEF_PARAMS (ifp
))
6773 ospf_free_if_params (ifp
, addr
);
6774 ospf_if_update_params (ifp
, addr
);
6777 ospf_if_recalculate_output_cost (ifp
);
6782 ALIAS (no_ip_ospf_cost
,
6783 no_ip_ospf_cost_cmd
,
6787 "OSPF interface commands\n"
6790 ALIAS (no_ip_ospf_cost
,
6794 "OSPF interface commands\n"
6797 ALIAS (no_ip_ospf_cost
,
6798 no_ospf_cost_inet4_cmd
,
6799 "no ospf cost A.B.C.D",
6801 "OSPF interface commands\n"
6803 "Address of interface")
6805 DEFUN (no_ip_ospf_cost2
,
6806 no_ip_ospf_cost_u32_cmd
,
6807 "no ip ospf cost <1-65535>",
6810 "OSPF interface commands\n"
6814 struct interface
*ifp
= vty
->index
;
6815 struct in_addr addr
;
6818 struct ospf_if_params
*params
;
6821 params
= IF_DEF_PARAMS (ifp
);
6823 /* According to the semantics we are mimicking "no ip ospf cost N" is
6824 * always treated as "no ip ospf cost" regardless of the actual value
6825 * of N already configured for the interface. Thus the first argument
6826 * is always checked to be a number, but is ignored after that.
6828 cost
= strtol (argv
[0], NULL
, 10);
6829 if (cost
< 1 || cost
> 65535)
6831 vty_out (vty
, "Interface output cost is invalid%s", VTY_NEWLINE
);
6837 ret
= inet_aton(argv
[1], &addr
);
6840 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6845 params
= ospf_lookup_if_params (ifp
, addr
);
6850 UNSET_IF_PARAM (params
, output_cost_cmd
);
6852 if (params
!= IF_DEF_PARAMS (ifp
))
6854 ospf_free_if_params (ifp
, addr
);
6855 ospf_if_update_params (ifp
, addr
);
6858 ospf_if_recalculate_output_cost (ifp
);
6863 ALIAS (no_ip_ospf_cost2
,
6864 no_ospf_cost_u32_cmd
,
6865 "no ospf cost <1-65535>",
6867 "OSPF interface commands\n"
6871 ALIAS (no_ip_ospf_cost2
,
6872 no_ip_ospf_cost_u32_inet4_cmd
,
6873 "no ip ospf cost <1-65535> A.B.C.D",
6876 "OSPF interface commands\n"
6879 "Address of interface")
6881 ALIAS (no_ip_ospf_cost2
,
6882 no_ospf_cost_u32_inet4_cmd
,
6883 "no ospf cost <1-65535> A.B.C.D",
6885 "OSPF interface commands\n"
6888 "Address of interface")
6891 ospf_nbr_timer_update (struct ospf_interface
*oi
)
6893 struct route_node
*rn
;
6894 struct ospf_neighbor
*nbr
;
6896 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
6897 if ((nbr
= rn
->info
))
6899 nbr
->v_inactivity
= OSPF_IF_PARAM (oi
, v_wait
);
6900 nbr
->v_db_desc
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6901 nbr
->v_ls_req
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6902 nbr
->v_ls_upd
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6907 ospf_vty_dead_interval_set (struct vty
*vty
, const char *interval_str
,
6908 const char *nbr_str
,
6909 const char *fast_hello_str
)
6911 struct interface
*ifp
= vty
->index
;
6914 struct in_addr addr
;
6916 struct ospf_if_params
*params
;
6917 struct ospf_interface
*oi
;
6918 struct route_node
*rn
;
6920 params
= IF_DEF_PARAMS (ifp
);
6924 ret
= inet_aton(nbr_str
, &addr
);
6927 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6932 params
= ospf_get_if_params (ifp
, addr
);
6933 ospf_if_update_params (ifp
, addr
);
6938 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds
, interval_str
,
6941 /* reset fast_hello too, just to be sure */
6942 UNSET_IF_PARAM (params
, fast_hello
);
6943 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6945 else if (fast_hello_str
)
6947 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult
, fast_hello_str
,
6949 /* 1s dead-interval with sub-second hellos desired */
6950 seconds
= OSPF_ROUTER_DEAD_INTERVAL_MINIMAL
;
6951 SET_IF_PARAM (params
, fast_hello
);
6952 params
->fast_hello
= hellomult
;
6956 vty_out (vty
, "Please specify dead-interval or hello-multiplier%s",
6961 SET_IF_PARAM (params
, v_wait
);
6962 params
->v_wait
= seconds
;
6964 /* Update timer values in neighbor structure. */
6968 if ((ospf
= ospf_lookup()))
6970 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
6972 ospf_nbr_timer_update (oi
);
6977 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6978 if ((oi
= rn
->info
))
6979 ospf_nbr_timer_update (oi
);
6986 DEFUN (ip_ospf_dead_interval
,
6987 ip_ospf_dead_interval_addr_cmd
,
6988 "ip ospf dead-interval <1-65535> A.B.C.D",
6990 "OSPF interface commands\n"
6991 "Interval after which a neighbor is declared dead\n"
6993 "Address of interface\n")
6996 return ospf_vty_dead_interval_set (vty
, argv
[0], argv
[1], NULL
);
6998 return ospf_vty_dead_interval_set (vty
, argv
[0], NULL
, NULL
);
7001 ALIAS (ip_ospf_dead_interval
,
7002 ip_ospf_dead_interval_cmd
,
7003 "ip ospf dead-interval <1-65535>",
7005 "OSPF interface commands\n"
7006 "Interval after which a neighbor is declared dead\n"
7009 ALIAS_HIDDEN (ip_ospf_dead_interval
,
7010 ospf_dead_interval_cmd
,
7011 "ospf dead-interval <1-65535>",
7012 "OSPF interface commands\n"
7013 "Interval after which a neighbor is declared dead\n"
7016 DEFUN (ip_ospf_dead_interval_minimal
,
7017 ip_ospf_dead_interval_minimal_addr_cmd
,
7018 "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
7020 "OSPF interface commands\n"
7021 "Interval after which a neighbor is declared dead\n"
7022 "Minimal 1s dead-interval with fast sub-second hellos\n"
7023 "Hello multiplier factor\n"
7024 "Number of Hellos to send each second\n"
7025 "Address of interface\n")
7028 return ospf_vty_dead_interval_set (vty
, NULL
, argv
[1], argv
[0]);
7030 return ospf_vty_dead_interval_set (vty
, NULL
, NULL
, argv
[0]);
7033 ALIAS (ip_ospf_dead_interval_minimal
,
7034 ip_ospf_dead_interval_minimal_cmd
,
7035 "ip ospf dead-interval minimal hello-multiplier <1-10>",
7037 "OSPF interface commands\n"
7038 "Interval after which a neighbor is declared dead\n"
7039 "Minimal 1s dead-interval with fast sub-second hellos\n"
7040 "Hello multiplier factor\n"
7041 "Number of Hellos to send each second\n")
7043 DEFUN (no_ip_ospf_dead_interval
,
7044 no_ip_ospf_dead_interval_addr_cmd
,
7045 "no ip ospf dead-interval <1-65535> A.B.C.D",
7048 "OSPF interface commands\n"
7049 "Interval after which a neighbor is declared dead\n"
7051 "Address of interface")
7053 struct interface
*ifp
= vty
->index
;
7054 struct in_addr addr
;
7056 struct ospf_if_params
*params
;
7057 struct ospf_interface
*oi
;
7058 struct route_node
*rn
;
7061 params
= IF_DEF_PARAMS (ifp
);
7065 ret
= inet_aton(argv
[1], &addr
);
7068 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7073 params
= ospf_lookup_if_params (ifp
, addr
);
7078 UNSET_IF_PARAM (params
, v_wait
);
7079 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
7081 UNSET_IF_PARAM (params
, fast_hello
);
7082 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
7084 if (params
!= IF_DEF_PARAMS (ifp
))
7086 ospf_free_if_params (ifp
, addr
);
7087 ospf_if_update_params (ifp
, addr
);
7090 /* Update timer values in neighbor structure. */
7095 if ((ospf
= ospf_lookup()))
7097 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
7099 ospf_nbr_timer_update (oi
);
7104 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7105 if ((oi
= rn
->info
))
7106 ospf_nbr_timer_update (oi
);
7112 ALIAS (no_ip_ospf_dead_interval
,
7113 no_ip_ospf_dead_interval_seconds_cmd
,
7114 "no ip ospf dead-interval <1-65535>",
7117 "OSPF interface commands\n"
7118 "Interval after which a neighbor is declared dead\n"
7121 ALIAS (no_ip_ospf_dead_interval
,
7122 no_ip_ospf_dead_interval_cmd
,
7123 "no ip ospf dead-interval",
7126 "OSPF interface commands\n"
7127 "Interval after which a neighbor is declared dead\n")
7129 ALIAS (no_ip_ospf_dead_interval
,
7130 no_ospf_dead_interval_cmd
,
7131 "no ospf dead-interval",
7133 "OSPF interface commands\n"
7134 "Interval after which a neighbor is declared dead\n")
7136 ALIAS (no_ip_ospf_dead_interval
,
7137 no_ip_ospf_dead_interval_minimal_addr_cmd
,
7138 "no ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
7141 "OSPF interface commands\n"
7142 "Interval after which a neighbor is declared dead\n"
7143 "Minimal 1s dead-interval with fast sub-second hellos\n"
7144 "Hello multiplier factor\n"
7145 "Number of Hellos to send each second\n"
7146 "Address of interface\n")
7148 ALIAS (no_ip_ospf_dead_interval
,
7149 no_ip_ospf_dead_interval_minimal_cmd
,
7150 "no ip ospf dead-interval minimal hello-multiplier <1-10>",
7153 "OSPF interface commands\n"
7154 "Interval after which a neighbor is declared dead\n"
7155 "Minimal 1s dead-interval with fast sub-second hellos\n"
7156 "Hello multiplier factor\n"
7157 "Number of Hellos to send each second\n")
7159 DEFUN (ip_ospf_hello_interval
,
7160 ip_ospf_hello_interval_addr_cmd
,
7161 "ip ospf hello-interval <1-65535> A.B.C.D",
7163 "OSPF interface commands\n"
7164 "Time between HELLO packets\n"
7166 "Address of interface")
7168 struct interface
*ifp
= vty
->index
;
7170 struct in_addr addr
;
7172 struct ospf_if_params
*params
;
7174 params
= IF_DEF_PARAMS (ifp
);
7176 seconds
= strtol (argv
[0], NULL
, 10);
7178 /* HelloInterval range is <1-65535>. */
7179 if (seconds
< 1 || seconds
> 65535)
7181 vty_out (vty
, "Hello Interval is invalid%s", VTY_NEWLINE
);
7187 ret
= inet_aton(argv
[1], &addr
);
7190 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7195 params
= ospf_get_if_params (ifp
, addr
);
7196 ospf_if_update_params (ifp
, addr
);
7199 SET_IF_PARAM (params
, v_hello
);
7200 params
->v_hello
= seconds
;
7205 ALIAS (ip_ospf_hello_interval
,
7206 ip_ospf_hello_interval_cmd
,
7207 "ip ospf hello-interval <1-65535>",
7209 "OSPF interface commands\n"
7210 "Time between HELLO packets\n"
7213 ALIAS_HIDDEN (ip_ospf_hello_interval
,
7214 ospf_hello_interval_cmd
,
7215 "ospf hello-interval <1-65535>",
7216 "OSPF interface commands\n"
7217 "Time between HELLO packets\n"
7220 DEFUN (no_ip_ospf_hello_interval
,
7221 no_ip_ospf_hello_interval_addr_cmd
,
7222 "no ip ospf hello-interval <1-65535> A.B.C.D",
7225 "OSPF interface commands\n"
7226 "Time between HELLO packets\n"
7228 "Address of interface")
7230 struct interface
*ifp
= vty
->index
;
7231 struct in_addr addr
;
7233 struct ospf_if_params
*params
;
7236 params
= IF_DEF_PARAMS (ifp
);
7240 ret
= inet_aton(argv
[1], &addr
);
7243 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7248 params
= ospf_lookup_if_params (ifp
, addr
);
7253 UNSET_IF_PARAM (params
, v_hello
);
7254 params
->v_hello
= OSPF_HELLO_INTERVAL_DEFAULT
;
7256 if (params
!= IF_DEF_PARAMS (ifp
))
7258 ospf_free_if_params (ifp
, addr
);
7259 ospf_if_update_params (ifp
, addr
);
7265 ALIAS (no_ip_ospf_hello_interval
,
7266 no_ip_ospf_hello_interval_seconds_cmd
,
7267 "no ip ospf hello-interval <1-65535>",
7270 "OSPF interface commands\n"
7271 "Time between HELLO packets\n"
7274 ALIAS (no_ip_ospf_hello_interval
,
7275 no_ip_ospf_hello_interval_cmd
,
7276 "no ip ospf hello-interval",
7279 "OSPF interface commands\n"
7280 "Time between HELLO packets\n")
7282 ALIAS (no_ip_ospf_hello_interval
,
7283 no_ospf_hello_interval_cmd
,
7284 "no ospf hello-interval <1-65535>",
7286 "OSPF interface commands\n"
7287 "Time between HELLO packets\n"
7290 DEFUN (ip_ospf_network
,
7291 ip_ospf_network_cmd
,
7292 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
7294 "OSPF interface commands\n"
7296 "Specify OSPF broadcast multi-access network\n"
7297 "Specify OSPF NBMA network\n"
7298 "Specify OSPF point-to-multipoint network\n"
7299 "Specify OSPF point-to-point network\n")
7301 struct interface
*ifp
= vty
->index
;
7302 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
7303 struct route_node
*rn
;
7305 if (old_type
== OSPF_IFTYPE_LOOPBACK
)
7307 vty_out (vty
, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE
);
7311 if (strncmp (argv
[0], "b", 1) == 0)
7312 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_BROADCAST
;
7313 else if (strncmp (argv
[0], "n", 1) == 0)
7314 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_NBMA
;
7315 else if (strncmp (argv
[0], "point-to-m", 10) == 0)
7316 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOMULTIPOINT
;
7317 else if (strncmp (argv
[0], "point-to-p", 10) == 0)
7318 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOPOINT
;
7320 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
7323 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), type
);
7325 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7327 struct ospf_interface
*oi
= rn
->info
;
7332 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
7334 if (oi
->state
> ISM_Down
)
7336 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
7337 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
7344 ALIAS_HIDDEN (ip_ospf_network
,
7346 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
7347 "OSPF interface commands\n"
7349 "Specify OSPF broadcast multi-access network\n"
7350 "Specify OSPF NBMA network\n"
7351 "Specify OSPF point-to-multipoint network\n"
7352 "Specify OSPF point-to-point network\n")
7354 DEFUN (no_ip_ospf_network
,
7355 no_ip_ospf_network_cmd
,
7356 "no ip ospf network",
7359 "OSPF interface commands\n"
7362 struct interface
*ifp
= vty
->index
;
7363 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
7364 struct route_node
*rn
;
7366 IF_DEF_PARAMS (ifp
)->type
= ospf_default_iftype(ifp
);
7368 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
7371 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7373 struct ospf_interface
*oi
= rn
->info
;
7378 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
7380 if (oi
->state
> ISM_Down
)
7382 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
7383 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
7390 ALIAS (no_ip_ospf_network
,
7391 no_ip_ospf_network_val_cmd
,
7392 "no ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
7395 "OSPF interface commands\n"
7397 "Specify OSPF broadcast multi-access network\n"
7398 "Specify OSPF NBMA network\n"
7399 "Specify OSPF point-to-multipoint network\n"
7400 "Specify OSPF point-to-point network\n")
7402 ALIAS (no_ip_ospf_network
,
7403 no_ospf_network_cmd
,
7406 "OSPF interface commands\n"
7409 ALIAS (no_ip_ospf_network
,
7410 no_ospf_network_val_cmd
,
7411 "no ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
7413 "OSPF interface commands\n"
7415 "Specify OSPF broadcast multi-access network\n"
7416 "Specify OSPF NBMA network\n"
7417 "Specify OSPF point-to-multipoint network\n"
7418 "Specify OSPF point-to-point network\n")
7420 DEFUN (ip_ospf_priority
,
7421 ip_ospf_priority_addr_cmd
,
7422 "ip ospf priority <0-255> A.B.C.D",
7424 "OSPF interface commands\n"
7427 "Address of interface")
7429 struct interface
*ifp
= vty
->index
;
7431 struct route_node
*rn
;
7432 struct in_addr addr
;
7434 struct ospf_if_params
*params
;
7436 params
= IF_DEF_PARAMS (ifp
);
7438 priority
= strtol (argv
[0], NULL
, 10);
7440 /* Router Priority range is <0-255>. */
7441 if (priority
< 0 || priority
> 255)
7443 vty_out (vty
, "Router Priority is invalid%s", VTY_NEWLINE
);
7449 ret
= inet_aton(argv
[1], &addr
);
7452 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7457 params
= ospf_get_if_params (ifp
, addr
);
7458 ospf_if_update_params (ifp
, addr
);
7461 SET_IF_PARAM (params
, priority
);
7462 params
->priority
= priority
;
7464 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7466 struct ospf_interface
*oi
= rn
->info
;
7472 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
7474 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
7475 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
7482 ALIAS (ip_ospf_priority
,
7483 ip_ospf_priority_cmd
,
7484 "ip ospf priority <0-255>",
7486 "OSPF interface commands\n"
7490 ALIAS_HIDDEN (ip_ospf_priority
,
7492 "ospf priority <0-255>",
7493 "OSPF interface commands\n"
7497 DEFUN (no_ip_ospf_priority
,
7498 no_ip_ospf_priority_addr_cmd
,
7499 "no ip ospf priority <0-255> A.B.C.D",
7502 "OSPF interface commands\n"
7505 "Address of interface")
7507 struct interface
*ifp
= vty
->index
;
7508 struct route_node
*rn
;
7509 struct in_addr addr
;
7511 struct ospf_if_params
*params
;
7514 params
= IF_DEF_PARAMS (ifp
);
7518 ret
= inet_aton(argv
[1], &addr
);
7521 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7526 params
= ospf_lookup_if_params (ifp
, addr
);
7531 UNSET_IF_PARAM (params
, priority
);
7532 params
->priority
= OSPF_ROUTER_PRIORITY_DEFAULT
;
7534 if (params
!= IF_DEF_PARAMS (ifp
))
7536 ospf_free_if_params (ifp
, addr
);
7537 ospf_if_update_params (ifp
, addr
);
7540 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7542 struct ospf_interface
*oi
= rn
->info
;
7548 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
7550 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
7551 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
7558 ALIAS (no_ip_ospf_priority
,
7559 no_ip_ospf_priority_no_param_cmd
,
7560 "no ip ospf priority",
7563 "OSPF interface commands\n"
7564 "Router priority\n");
7566 ALIAS (no_ip_ospf_priority
,
7567 no_ip_ospf_priority_cmd
,
7568 "no ip ospf priority <0-255>",
7571 "OSPF interface commands\n"
7575 ALIAS (no_ip_ospf_priority
,
7576 no_ospf_priority_cmd
,
7577 "no ospf priority <0-255>",
7579 "OSPF interface commands\n"
7584 DEFUN (ip_ospf_retransmit_interval
,
7585 ip_ospf_retransmit_interval_addr_cmd
,
7586 "ip ospf retransmit-interval <3-65535> A.B.C.D",
7588 "OSPF interface commands\n"
7589 "Time between retransmitting lost link state advertisements\n"
7591 "Address of interface")
7593 struct interface
*ifp
= vty
->index
;
7595 struct in_addr addr
;
7597 struct ospf_if_params
*params
;
7599 params
= IF_DEF_PARAMS (ifp
);
7600 seconds
= strtol (argv
[0], NULL
, 10);
7602 /* Retransmit Interval range is <3-65535>. */
7603 if (seconds
< 3 || seconds
> 65535)
7605 vty_out (vty
, "Retransmit Interval is invalid%s", VTY_NEWLINE
);
7612 ret
= inet_aton(argv
[1], &addr
);
7615 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7620 params
= ospf_get_if_params (ifp
, addr
);
7621 ospf_if_update_params (ifp
, addr
);
7624 SET_IF_PARAM (params
, retransmit_interval
);
7625 params
->retransmit_interval
= seconds
;
7630 ALIAS (ip_ospf_retransmit_interval
,
7631 ip_ospf_retransmit_interval_cmd
,
7632 "ip ospf retransmit-interval <3-65535>",
7634 "OSPF interface commands\n"
7635 "Time between retransmitting lost link state advertisements\n"
7638 ALIAS_HIDDEN (ip_ospf_retransmit_interval
,
7639 ospf_retransmit_interval_cmd
,
7640 "ospf retransmit-interval <3-65535>",
7641 "OSPF interface commands\n"
7642 "Time between retransmitting lost link state advertisements\n"
7645 DEFUN (no_ip_ospf_retransmit_interval
,
7646 no_ip_ospf_retransmit_interval_addr_cmd
,
7647 "no ip ospf retransmit-interval A.B.C.D",
7650 "OSPF interface commands\n"
7651 "Time between retransmitting lost link state advertisements\n"
7652 "Address of interface")
7654 struct interface
*ifp
= vty
->index
;
7655 struct in_addr addr
;
7657 struct ospf_if_params
*params
;
7661 params
= IF_DEF_PARAMS (ifp
);
7670 ret
= inet_aton(argv
[addr_index
], &addr
);
7673 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7678 params
= ospf_lookup_if_params (ifp
, addr
);
7683 UNSET_IF_PARAM (params
, retransmit_interval
);
7684 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
7686 if (params
!= IF_DEF_PARAMS (ifp
))
7688 ospf_free_if_params (ifp
, addr
);
7689 ospf_if_update_params (ifp
, addr
);
7695 ALIAS (no_ip_ospf_retransmit_interval
,
7696 no_ip_ospf_retransmit_interval_sec_addr_cmd
,
7697 "no ip ospf retransmit-interval <3-65535> A.B.C.D",
7700 "OSPF interface commands\n"
7701 "Time between retransmitting lost link state advertisements\n"
7703 "Address of interface")
7705 ALIAS (no_ip_ospf_retransmit_interval
,
7706 no_ip_ospf_retransmit_interval_cmd
,
7707 "no ip ospf retransmit-interval",
7710 "OSPF interface commands\n"
7711 "Time between retransmitting lost link state advertisements\n")
7713 ALIAS (no_ip_ospf_retransmit_interval
,
7714 no_ospf_retransmit_interval_cmd
,
7715 "no ospf retransmit-interval",
7717 "OSPF interface commands\n"
7718 "Time between retransmitting lost link state advertisements\n")
7720 DEFUN (no_ip_ospf_retransmit_interval_sec
,
7721 no_ip_ospf_retransmit_interval_sec_cmd
,
7722 "no ip ospf retransmit-interval <3-65535>",
7725 "OSPF interface commands\n"
7726 "Time between retransmitting lost link state advertisements\n"
7729 struct interface
*ifp
= vty
->index
;
7730 struct ospf_if_params
*params
;
7733 params
= IF_DEF_PARAMS (ifp
);
7735 UNSET_IF_PARAM (params
, retransmit_interval
);
7736 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
7742 DEFUN (ip_ospf_transmit_delay
,
7743 ip_ospf_transmit_delay_addr_cmd
,
7744 "ip ospf transmit-delay <1-65535> A.B.C.D",
7746 "OSPF interface commands\n"
7747 "Link state transmit delay\n"
7749 "Address of interface")
7751 struct interface
*ifp
= vty
->index
;
7753 struct in_addr addr
;
7755 struct ospf_if_params
*params
;
7757 params
= IF_DEF_PARAMS (ifp
);
7758 seconds
= strtol (argv
[0], NULL
, 10);
7760 /* Transmit Delay range is <1-65535>. */
7761 if (seconds
< 1 || seconds
> 65535)
7763 vty_out (vty
, "Transmit Delay is invalid%s", VTY_NEWLINE
);
7769 ret
= inet_aton(argv
[1], &addr
);
7772 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7777 params
= ospf_get_if_params (ifp
, addr
);
7778 ospf_if_update_params (ifp
, addr
);
7781 SET_IF_PARAM (params
, transmit_delay
);
7782 params
->transmit_delay
= seconds
;
7787 ALIAS (ip_ospf_transmit_delay
,
7788 ip_ospf_transmit_delay_cmd
,
7789 "ip ospf transmit-delay <1-65535>",
7791 "OSPF interface commands\n"
7792 "Link state transmit delay\n"
7795 ALIAS_HIDDEN (ip_ospf_transmit_delay
,
7796 ospf_transmit_delay_cmd
,
7797 "ospf transmit-delay <1-65535>",
7798 "OSPF interface commands\n"
7799 "Link state transmit delay\n"
7802 DEFUN (no_ip_ospf_transmit_delay
,
7803 no_ip_ospf_transmit_delay_addr_cmd
,
7804 "no ip ospf transmit-delay A.B.C.D",
7807 "OSPF interface commands\n"
7808 "Link state transmit delay\n"
7809 "Address of interface")
7811 struct interface
*ifp
= vty
->index
;
7812 struct in_addr addr
;
7814 struct ospf_if_params
*params
;
7818 params
= IF_DEF_PARAMS (ifp
);
7827 ret
= inet_aton(argv
[addr_index
], &addr
);
7830 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7835 params
= ospf_lookup_if_params (ifp
, addr
);
7840 UNSET_IF_PARAM (params
, transmit_delay
);
7841 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
7843 if (params
!= IF_DEF_PARAMS (ifp
))
7845 ospf_free_if_params (ifp
, addr
);
7846 ospf_if_update_params (ifp
, addr
);
7852 ALIAS (no_ip_ospf_transmit_delay
,
7853 no_ip_ospf_transmit_delay_sec_addr_cmd
,
7854 "no ip ospf transmit-delay <1-65535> A.B.C.D",
7857 "OSPF interface commands\n"
7858 "Link state transmit delay\n"
7860 "Address of interface")
7862 ALIAS (no_ip_ospf_transmit_delay
,
7863 no_ip_ospf_transmit_delay_cmd
,
7864 "no ip ospf transmit-delay",
7867 "OSPF interface commands\n"
7868 "Link state transmit delay\n")
7870 ALIAS (no_ip_ospf_transmit_delay
,
7871 no_ospf_transmit_delay_cmd
,
7872 "no ospf transmit-delay",
7874 "OSPF interface commands\n"
7875 "Link state transmit delay\n")
7877 DEFUN (no_ip_ospf_transmit_delay_sec
,
7878 no_ip_ospf_transmit_delay_sec_cmd
,
7879 "no ip ospf transmit-delay <1-65535>",
7882 "OSPF interface commands\n"
7883 "Link state transmit delay\n"
7885 "Address of interface")
7887 struct interface
*ifp
= vty
->index
;
7888 struct ospf_if_params
*params
;
7891 params
= IF_DEF_PARAMS (ifp
);
7893 UNSET_IF_PARAM (params
, transmit_delay
);
7894 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
7899 DEFUN (ip_ospf_area
,
7901 "ip ospf area (A.B.C.D|<0-4294967295>)",
7903 "OSPF interface commands\n"
7904 "Enable OSPF on this interface\n"
7905 "OSPF area ID in IP address format\n"
7906 "OSPF area ID as a decimal value\n")
7908 struct interface
*ifp
= vty
->index
;
7910 struct in_addr area_id
;
7912 struct ospf_if_params
*params
;
7913 struct route_node
*rn
;
7914 u_short instance
= 0;
7917 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
7919 ospf
= ospf_lookup_instance (instance
);
7922 params
= IF_DEF_PARAMS (ifp
);
7923 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7925 ospf_interface_unset (ifp
);
7926 ospf
= ospf_lookup();
7927 ospf
->if_ospf_cli_count
--;
7932 ret
= ospf_str2area_id (argv
[instance
? 1 : 0], &area_id
, &format
);
7935 vty_out (vty
, "Please specify area by A.B.C.D|<0-4294967295>%s",
7939 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
7941 vty_out (vty
, "Cannot enable OSPF on a virtual link.%s", VTY_NEWLINE
);
7945 params
= IF_DEF_PARAMS (ifp
);
7946 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7949 "Must remove previous area config before changing ospf area %s",
7954 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
7956 if (rn
->info
!= NULL
)
7958 vty_out (vty
, "Please remove all network commands first.%s", VTY_NEWLINE
);
7963 /* enable ospf on this interface with area_id */
7964 ospf_interface_set (ifp
, area_id
);
7965 ospf
->if_ospf_cli_count
++;
7970 ALIAS (ip_ospf_area
,
7971 ip_ospf_instance_area_cmd
,
7972 "ip ospf <1-65535> area (A.B.C.D|<0-4294967295>)",
7974 "OSPF interface commands\n"
7976 "Enable OSPF on this interface\n"
7977 "OSPF area ID in IP address format\n"
7978 "OSPF area ID as a decimal value\n")
7980 DEFUN (no_ip_ospf_area
,
7981 no_ip_ospf_area_cmd
,
7985 "OSPF interface commands\n"
7986 "Disable OSPF on this interface\n")
7988 struct interface
*ifp
= vty
->index
;
7990 struct ospf_if_params
*params
;
7991 u_short instance
= 0;
7993 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
7996 params
= IF_DEF_PARAMS (ifp
);
7997 if (!OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7999 vty_out (vty
, "Can't find specified inteface area configuration.%s", VTY_NEWLINE
);
8003 ospf_interface_unset (ifp
);
8004 ospf
->if_ospf_cli_count
--;
8008 ALIAS (no_ip_ospf_area
,
8009 no_ip_ospf_area_val_cmd
,
8010 "no ip ospf area (A.B.C.D|<0-4294967295>)",
8013 "OSPF interface commands\n"
8014 "Disable OSPF on this interface\n"
8015 "OSPF area ID in IP address format\n"
8016 "OSPF area ID as a decimal value\n")
8018 DEFUN (no_ip_ospf_instance_area
,
8019 no_ip_ospf_instance_area_cmd
,
8020 "no ip ospf <1-65535> area",
8023 "OSPF interface commands\n"
8025 "Disable OSPF on this interface\n")
8027 struct interface
*ifp
= vty
->index
;
8029 struct ospf_if_params
*params
;
8030 u_short instance
= 0;
8032 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
8034 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
8037 params
= IF_DEF_PARAMS (ifp
);
8038 if (!OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
8040 vty_out (vty
, "Can't find specified inteface area configuration.%s", VTY_NEWLINE
);
8044 ospf_interface_unset (ifp
);
8045 ospf
->if_ospf_cli_count
--;
8049 ALIAS (no_ip_ospf_instance_area
,
8050 no_ip_ospf_instance_area_val_cmd
,
8051 "no ip ospf <1-65535> area (A.B.C.D|<0-4294967295>)",
8054 "OSPF interface commands\n"
8056 "Disable OSPF on this interface\n"
8057 "OSPF area ID in IP address format\n"
8058 "OSPF area ID as a decimal value\n")
8060 DEFUN (ospf_redistribute_source
,
8061 ospf_redistribute_source_cmd
,
8062 "redistribute " QUAGGA_REDIST_STR_OSPFD
8063 " {metric <0-16777214>|metric-type (1|2)|route-map WORD}",
8065 QUAGGA_REDIST_HELP_STR_OSPFD
8066 "Metric for redistributed routes\n"
8067 "OSPF default metric\n"
8068 "OSPF exterior metric type for redistributed routes\n"
8069 "Set OSPF External Type 1 metrics\n"
8070 "Set OSPF External Type 2 metrics\n"
8071 "Route map reference\n"
8072 "Pointer to route-map entries\n")
8074 struct ospf
*ospf
= vty
->index
;
8078 struct ospf_redist
*red
;
8081 return CMD_WARNING
; /* should not happen */
8086 /* Get distribute source. */
8087 source
= proto_redistnum(AFI_IP
, argv
[0]);
8088 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
8091 /* Get metric value. */
8092 if (argv
[1] != NULL
)
8093 if (!str2metric (argv
[1], &metric
))
8096 /* Get metric type. */
8097 if (argv
[2] != NULL
)
8098 if (!str2metric_type (argv
[2], &type
))
8101 red
= ospf_redist_add(ospf
, source
, 0);
8103 if (argv
[3] != NULL
)
8104 ospf_routemap_set (red
, argv
[3]);
8106 ospf_routemap_unset (red
);
8108 return ospf_redistribute_set (ospf
, source
, 0, type
, metric
);
8111 DEFUN (no_ospf_redistribute_source
,
8112 no_ospf_redistribute_source_cmd
,
8113 "no redistribute " QUAGGA_REDIST_STR_OSPFD
8114 " {metric <0-16777214>|metric-type (1|2)|route-map WORD}",
8117 QUAGGA_REDIST_HELP_STR_OSPFD
8118 "Metric for redistributed routes\n"
8119 "OSPF default metric\n"
8120 "OSPF exterior metric type for redistributed routes\n"
8121 "Set OSPF External Type 1 metrics\n"
8122 "Set OSPF External Type 2 metrics\n"
8123 "Route map reference\n"
8124 "Pointer to route-map entries\n")
8126 struct ospf
*ospf
= vty
->index
;
8128 struct ospf_redist
*red
;
8132 source
= proto_redistnum(AFI_IP
, argv
[0]);
8133 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
8136 red
= ospf_redist_lookup(ospf
, source
, 0);
8140 ospf_routemap_unset (red
);
8141 return ospf_redistribute_unset (ospf
, source
, 0);
8144 DEFUN (ospf_redistribute_instance_source
,
8145 ospf_redistribute_instance_source_cmd
,
8146 "redistribute (ospf|table) <1-65535>"
8147 " {metric <0-16777214>|metric-type (1|2)|route-map WORD}",
8149 "Open Shortest Path First\n"
8150 "Non-main Kernel Routing Table\n"
8151 "Instance ID/Table ID\n"
8152 "Metric for redistributed routes\n"
8153 "OSPF default metric\n"
8154 "OSPF exterior metric type for redistributed routes\n"
8155 "Set OSPF External Type 1 metrics\n"
8156 "Set OSPF External Type 2 metrics\n"
8157 "Route map reference\n"
8158 "Pointer to route-map entries\n")
8160 struct ospf
*ospf
= vty
->index
;
8165 struct ospf_redist
*red
;
8167 if (strncmp(argv
[0], "o", 1) == 0)
8168 source
= ZEBRA_ROUTE_OSPF
;
8170 source
= ZEBRA_ROUTE_TABLE
;
8172 VTY_GET_INTEGER ("Instance ID", instance
, argv
[1]);
8177 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
8179 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
8184 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
8186 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
8191 /* Get metric value. */
8192 if (argv
[2] != NULL
)
8193 if (!str2metric (argv
[2], &metric
))
8196 /* Get metric type. */
8197 if (argv
[3] != NULL
)
8198 if (!str2metric_type (argv
[3], &type
))
8201 red
= ospf_redist_add(ospf
, source
, instance
);
8202 if (argv
[4] != NULL
)
8203 ospf_routemap_set (red
, argv
[4]);
8205 ospf_routemap_unset (red
);
8207 return ospf_redistribute_set (ospf
, source
, instance
, type
, metric
);
8210 DEFUN (no_ospf_redistribute_instance_source
,
8211 no_ospf_redistribute_instance_source_cmd
,
8212 "no redistribute (ospf|table) <1-65535>"
8213 " {metric <0-16777214>|metric-type (1|2)|route-map WORD}",
8216 "Open Shortest Path First\n"
8217 "Non-main Kernel Routing Table\n"
8218 "Instance ID/Table Id\n"
8219 "Metric for redistributed routes\n"
8220 "OSPF default metric\n"
8221 "OSPF exterior metric type for redistributed routes\n"
8222 "Set OSPF External Type 1 metrics\n"
8223 "Set OSPF External Type 2 metrics\n"
8224 "Route map reference\n"
8225 "Pointer to route-map entries\n")
8227 struct ospf
*ospf
= vty
->index
;
8229 struct ospf_redist
*red
;
8235 if (strncmp(argv
[0], "o", 1) == 0)
8236 source
= ZEBRA_ROUTE_OSPF
;
8238 source
= ZEBRA_ROUTE_TABLE
;
8240 VTY_GET_INTEGER ("Instance ID", instance
, argv
[1]);
8242 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
8244 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
8249 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
8251 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
8256 red
= ospf_redist_lookup(ospf
, source
, instance
);
8260 ospf_routemap_unset (red
);
8261 return ospf_redistribute_unset (ospf
, source
, instance
);
8264 DEFUN (ospf_distribute_list_out
,
8265 ospf_distribute_list_out_cmd
,
8266 "distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD
,
8267 "Filter networks in routing updates\n"
8268 "Access-list name\n"
8270 QUAGGA_REDIST_HELP_STR_OSPFD
)
8272 struct ospf
*ospf
= vty
->index
;
8278 /* Get distribute source. */
8279 source
= proto_redistnum(AFI_IP
, argv
[1]);
8280 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
8283 return ospf_distribute_list_out_set (ospf
, source
, argv
[0]);
8286 DEFUN (no_ospf_distribute_list_out
,
8287 no_ospf_distribute_list_out_cmd
,
8288 "no distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD
,
8290 "Filter networks in routing updates\n"
8291 "Access-list name\n"
8293 QUAGGA_REDIST_HELP_STR_OSPFD
)
8295 struct ospf
*ospf
= vty
->index
;
8301 source
= proto_redistnum(AFI_IP
, argv
[1]);
8302 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
8305 return ospf_distribute_list_out_unset (ospf
, source
, argv
[0]);
8308 /* Default information originate. */
8309 DEFUN (ospf_default_information_originate
,
8310 ospf_default_information_originate_cmd
,
8311 "default-information originate "
8312 "{always|metric <0-16777214>|metric-type (1|2)|route-map WORD}",
8313 "Control distribution of default information\n"
8314 "Distribute a default route\n"
8315 "Always advertise default route\n"
8316 "OSPF default metric\n"
8318 "OSPF metric type for default routes\n"
8319 "Set OSPF External Type 1 metrics\n"
8320 "Set OSPF External Type 2 metrics\n"
8321 "Route map reference\n"
8322 "Pointer to route-map entries\n")
8324 struct ospf
*ospf
= vty
->index
;
8325 int default_originate
= DEFAULT_ORIGINATE_ZEBRA
;
8328 struct ospf_redist
*red
;
8334 return CMD_WARNING
; /* this should not happen */
8336 /* Check whether "always" was specified */
8337 if (argv
[0] != NULL
)
8338 default_originate
= DEFAULT_ORIGINATE_ALWAYS
;
8340 red
= ospf_redist_add(ospf
, DEFAULT_ROUTE
, 0);
8342 /* Get metric value. */
8343 if (argv
[1] != NULL
)
8344 if (!str2metric (argv
[1], &metric
))
8347 /* Get metric type. */
8348 if (argv
[2] != NULL
)
8349 if (!str2metric_type (argv
[2], &type
))
8352 if (argv
[3] != NULL
)
8353 ospf_routemap_set (red
, argv
[3]);
8355 ospf_routemap_unset (red
);
8357 return ospf_redistribute_default_set (ospf
, default_originate
,
8361 DEFUN (no_ospf_default_information_originate
,
8362 no_ospf_default_information_originate_cmd
,
8363 "no default-information originate"
8364 "{always|metric <0-16777214>|metric-type (1|2)|route-map WORD}",
8366 "Control distribution of default information\n"
8367 "Distribute a default route\n"
8368 "Always advertise default route\n"
8369 "OSPF default metric\n"
8371 "OSPF metric type for default routes\n"
8372 "Set OSPF External Type 1 metrics\n"
8373 "Set OSPF External Type 2 metrics\n"
8374 "Route map reference\n"
8375 "Pointer to route-map entries\n")
8377 struct ospf
*ospf
= vty
->index
;
8378 struct prefix_ipv4 p
;
8379 struct ospf_external
*ext
;
8380 struct ospf_redist
*red
;
8386 p
.prefix
.s_addr
= 0;
8389 ospf_external_lsa_flush (ospf
, DEFAULT_ROUTE
, &p
, 0);
8391 if ((ext
= ospf_external_lookup(DEFAULT_ROUTE
, 0)) &&
8392 EXTERNAL_INFO (ext
)) {
8393 ospf_external_info_delete (DEFAULT_ROUTE
, 0, p
);
8394 ospf_external_del (DEFAULT_ROUTE
, 0);
8397 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
8401 ospf_routemap_unset (red
);
8402 return ospf_redistribute_default_unset (ospf
);
8405 DEFUN (ospf_default_metric
,
8406 ospf_default_metric_cmd
,
8407 "default-metric <0-16777214>",
8408 "Set metric of redistributed routes\n"
8411 struct ospf
*ospf
= vty
->index
;
8417 if (!str2metric (argv
[0], &metric
))
8420 ospf
->default_metric
= metric
;
8425 DEFUN (no_ospf_default_metric
,
8426 no_ospf_default_metric_cmd
,
8427 "no default-metric",
8429 "Set metric of redistributed routes\n")
8431 struct ospf
*ospf
= vty
->index
;
8436 ospf
->default_metric
= -1;
8441 ALIAS (no_ospf_default_metric
,
8442 no_ospf_default_metric_val_cmd
,
8443 "no default-metric <0-16777214>",
8445 "Set metric of redistributed routes\n"
8448 DEFUN (ospf_distance
,
8451 "Define an administrative distance\n"
8452 "OSPF Administrative distance\n")
8454 struct ospf
*ospf
= vty
->index
;
8459 ospf
->distance_all
= atoi (argv
[0]);
8464 DEFUN (no_ospf_distance
,
8465 no_ospf_distance_cmd
,
8466 "no distance <1-255>",
8468 "Define an administrative distance\n"
8469 "OSPF Administrative distance\n")
8471 struct ospf
*ospf
= vty
->index
;
8476 ospf
->distance_all
= 0;
8481 DEFUN (no_ospf_distance_ospf
,
8482 no_ospf_distance_ospf_cmd
,
8483 "no distance ospf {intra-area <1-255>|inter-area <1-255>|external <1-255>}",
8485 "Define an administrative distance\n"
8486 "OSPF Administrative distance\n"
8487 "Intra-area routes\n"
8488 "Distance for intra-area routes\n"
8489 "Inter-area routes\n"
8490 "Distance for inter-area routes\n"
8492 "Distance for external routes\n")
8494 struct ospf
*ospf
= vty
->index
;
8502 if (argv
[0] != NULL
)
8503 ospf
->distance_intra
= 0;
8505 if (argv
[1] != NULL
)
8506 ospf
->distance_inter
= 0;
8508 if (argv
[2] != NULL
)
8509 ospf
->distance_external
= 0;
8511 if (argv
[0] || argv
[1] || argv
[2])
8514 /* If no arguments are given, clear all distance information */
8515 ospf
->distance_intra
= 0;
8516 ospf
->distance_inter
= 0;
8517 ospf
->distance_external
= 0;
8522 DEFUN (ospf_distance_ospf
,
8523 ospf_distance_ospf_cmd
,
8525 "{intra-area <1-255>|inter-area <1-255>|external <1-255>}",
8526 "Define an administrative distance\n"
8527 "OSPF Administrative distance\n"
8528 "Intra-area routes\n"
8529 "Distance for intra-area routes\n"
8530 "Inter-area routes\n"
8531 "Distance for inter-area routes\n"
8533 "Distance for external routes\n")
8535 struct ospf
*ospf
= vty
->index
;
8537 if (argc
< 3) /* should not happen */
8540 if (!argv
[0] && !argv
[1] && !argv
[2])
8542 vty_out(vty
, "%% Command incomplete. (Arguments required)%s",
8547 if (argv
[0] != NULL
)
8548 ospf
->distance_intra
= atoi(argv
[0]);
8550 if (argv
[1] != NULL
)
8551 ospf
->distance_inter
= atoi(argv
[1]);
8553 if (argv
[2] != NULL
)
8554 ospf
->distance_external
= atoi(argv
[2]);
8559 DEFUN (ospf_distance_source
,
8560 ospf_distance_source_cmd
,
8561 "distance <1-255> A.B.C.D/M",
8562 "Administrative distance\n"
8564 "IP source prefix\n")
8566 struct ospf
*ospf
= vty
->index
;
8571 ospf_distance_set (vty
, ospf
, argv
[0], argv
[1], NULL
);
8576 DEFUN (no_ospf_distance_source
,
8577 no_ospf_distance_source_cmd
,
8578 "no distance <1-255> A.B.C.D/M",
8580 "Administrative distance\n"
8582 "IP source prefix\n")
8584 struct ospf
*ospf
= vty
->index
;
8589 ospf_distance_unset (vty
, ospf
, argv
[0], argv
[1], NULL
);
8594 DEFUN (ospf_distance_source_access_list
,
8595 ospf_distance_source_access_list_cmd
,
8596 "distance <1-255> A.B.C.D/M WORD",
8597 "Administrative distance\n"
8599 "IP source prefix\n"
8600 "Access list name\n")
8602 struct ospf
*ospf
= vty
->index
;
8607 ospf_distance_set (vty
, ospf
, argv
[0], argv
[1], argv
[2]);
8612 DEFUN (no_ospf_distance_source_access_list
,
8613 no_ospf_distance_source_access_list_cmd
,
8614 "no distance <1-255> A.B.C.D/M WORD",
8616 "Administrative distance\n"
8618 "IP source prefix\n"
8619 "Access list name\n")
8621 struct ospf
*ospf
= vty
->index
;
8626 ospf_distance_unset (vty
, ospf
, argv
[0], argv
[1], argv
[2]);
8631 DEFUN (ip_ospf_mtu_ignore
,
8632 ip_ospf_mtu_ignore_addr_cmd
,
8633 "ip ospf mtu-ignore A.B.C.D",
8635 "OSPF interface commands\n"
8636 "Disable mtu mismatch detection\n"
8637 "Address of interface")
8639 struct interface
*ifp
= vty
->index
;
8640 struct in_addr addr
;
8643 struct ospf_if_params
*params
;
8644 params
= IF_DEF_PARAMS (ifp
);
8648 ret
= inet_aton(argv
[0], &addr
);
8651 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
8655 params
= ospf_get_if_params (ifp
, addr
);
8656 ospf_if_update_params (ifp
, addr
);
8658 params
->mtu_ignore
= 1;
8659 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
8660 SET_IF_PARAM (params
, mtu_ignore
);
8663 UNSET_IF_PARAM (params
, mtu_ignore
);
8664 if (params
!= IF_DEF_PARAMS (ifp
))
8666 ospf_free_if_params (ifp
, addr
);
8667 ospf_if_update_params (ifp
, addr
);
8673 ALIAS (ip_ospf_mtu_ignore
,
8674 ip_ospf_mtu_ignore_cmd
,
8675 "ip ospf mtu-ignore",
8677 "OSPF interface commands\n"
8678 "Disable mtu mismatch detection\n")
8681 DEFUN (no_ip_ospf_mtu_ignore
,
8682 no_ip_ospf_mtu_ignore_addr_cmd
,
8683 "no ip ospf mtu-ignore A.B.C.D",
8685 "OSPF interface commands\n"
8686 "Disable mtu mismatch detection\n"
8687 "Address of interface")
8689 struct interface
*ifp
= vty
->index
;
8690 struct in_addr addr
;
8693 struct ospf_if_params
*params
;
8694 params
= IF_DEF_PARAMS (ifp
);
8698 ret
= inet_aton(argv
[0], &addr
);
8701 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
8705 params
= ospf_get_if_params (ifp
, addr
);
8706 ospf_if_update_params (ifp
, addr
);
8708 params
->mtu_ignore
= 0;
8709 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
8710 SET_IF_PARAM (params
, mtu_ignore
);
8713 UNSET_IF_PARAM (params
, mtu_ignore
);
8714 if (params
!= IF_DEF_PARAMS (ifp
))
8716 ospf_free_if_params (ifp
, addr
);
8717 ospf_if_update_params (ifp
, addr
);
8723 ALIAS (no_ip_ospf_mtu_ignore
,
8724 no_ip_ospf_mtu_ignore_cmd
,
8725 "no ip ospf mtu-ignore",
8727 "OSPF interface commands\n"
8728 "Disable mtu mismatch detection\n")
8730 DEFUN (ospf_max_metric_router_lsa_admin
,
8731 ospf_max_metric_router_lsa_admin_cmd
,
8732 "max-metric router-lsa administrative",
8733 "OSPF maximum / infinite-distance metric\n"
8734 "Advertise own Router-LSA with infinite distance (stub router)\n"
8735 "Administratively applied, for an indefinite period\n")
8737 struct listnode
*ln
;
8738 struct ospf_area
*area
;
8739 struct ospf
*ospf
= vty
->index
;
8744 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
8746 SET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
8748 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
))
8749 ospf_router_lsa_update_area (area
);
8752 /* Allows for areas configured later to get the property */
8753 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_SET
;
8758 DEFUN (no_ospf_max_metric_router_lsa_admin
,
8759 no_ospf_max_metric_router_lsa_admin_cmd
,
8760 "no max-metric router-lsa administrative",
8762 "OSPF maximum / infinite-distance metric\n"
8763 "Advertise own Router-LSA with infinite distance (stub router)\n"
8764 "Administratively applied, for an indefinite period\n")
8766 struct listnode
*ln
;
8767 struct ospf_area
*area
;
8768 struct ospf
*ospf
= vty
->index
;
8773 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
8775 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
8777 /* Don't trample on the start-up stub timer */
8778 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
)
8779 && !area
->t_stub_router
)
8781 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
8782 ospf_router_lsa_update_area (area
);
8785 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET
;
8789 DEFUN (ospf_max_metric_router_lsa_startup
,
8790 ospf_max_metric_router_lsa_startup_cmd
,
8791 "max-metric router-lsa on-startup <5-86400>",
8792 "OSPF maximum / infinite-distance metric\n"
8793 "Advertise own Router-LSA with infinite distance (stub router)\n"
8794 "Automatically advertise stub Router-LSA on startup of OSPF\n"
8795 "Time (seconds) to advertise self as stub-router\n")
8797 unsigned int seconds
;
8798 struct ospf
*ospf
= vty
->index
;
8805 vty_out (vty
, "%% Must supply stub-router period");
8809 VTY_GET_INTEGER ("stub-router startup period", seconds
, argv
[0]);
8811 ospf
->stub_router_startup_time
= seconds
;
8816 DEFUN (no_ospf_max_metric_router_lsa_startup
,
8817 no_ospf_max_metric_router_lsa_startup_cmd
,
8818 "no max-metric router-lsa on-startup <5-86400>",
8820 "OSPF maximum / infinite-distance metric\n"
8821 "Advertise own Router-LSA with infinite distance (stub router)\n"
8822 "Automatically advertise stub Router-LSA on startup of OSPF\n"
8823 "Time (seconds) to advertise self as stub-router\n")
8825 struct listnode
*ln
;
8826 struct ospf_area
*area
;
8827 struct ospf
*ospf
= vty
->index
;
8832 ospf
->stub_router_startup_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
8834 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
8836 SET_FLAG (area
->stub_router_state
, OSPF_AREA_WAS_START_STUB_ROUTED
);
8837 OSPF_TIMER_OFF (area
->t_stub_router
);
8839 /* Don't trample on admin stub routed */
8840 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
8842 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
8843 ospf_router_lsa_update_area (area
);
8849 ALIAS (no_ospf_max_metric_router_lsa_startup
,
8850 no_ospf_max_metric_router_lsa_startup_no_param_cmd
,
8851 "no max-metric router-lsa on-startup",
8853 "OSPF maximum / infinite-distance metric\n"
8854 "Advertise own Router-LSA with infinite distance (stub router)\n"
8855 "Automatically advertise stub Router-LSA on startup of OSPF\n");
8857 DEFUN (ospf_max_metric_router_lsa_shutdown
,
8858 ospf_max_metric_router_lsa_shutdown_cmd
,
8859 "max-metric router-lsa on-shutdown <5-100>",
8860 "OSPF maximum / infinite-distance metric\n"
8861 "Advertise own Router-LSA with infinite distance (stub router)\n"
8862 "Advertise stub-router prior to full shutdown of OSPF\n"
8863 "Time (seconds) to wait till full shutdown\n")
8865 unsigned int seconds
;
8866 struct ospf
*ospf
= vty
->index
;
8873 vty_out (vty
, "%% Must supply stub-router shutdown period");
8877 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds
, argv
[0]);
8879 ospf
->stub_router_shutdown_time
= seconds
;
8884 DEFUN (no_ospf_max_metric_router_lsa_shutdown
,
8885 no_ospf_max_metric_router_lsa_shutdown_cmd
,
8886 "no max-metric router-lsa on-shutdown <5-100>",
8888 "OSPF maximum / infinite-distance metric\n"
8889 "Advertise own Router-LSA with infinite distance (stub router)\n"
8890 "Advertise stub-router prior to full shutdown of OSPF\n"
8891 "Time (seconds) to wait till full shutdown\n")
8893 struct ospf
*ospf
= vty
->index
;
8898 ospf
->stub_router_shutdown_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
8903 ALIAS (no_ospf_max_metric_router_lsa_shutdown
,
8904 no_ospf_max_metric_router_lsa_shutdown_no_param_cmd
,
8905 "no max-metric router-lsa on-shutdown",
8907 "OSPF maximum / infinite-distance metric\n"
8908 "Advertise own Router-LSA with infinite distance (stub router)\n"
8909 "Advertise stub-router prior to full shutdown of OSPF\n");
8912 config_write_stub_router (struct vty
*vty
, struct ospf
*ospf
)
8914 struct listnode
*ln
;
8915 struct ospf_area
*area
;
8917 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
8918 vty_out (vty
, " max-metric router-lsa on-startup %u%s",
8919 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
8920 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
8921 vty_out (vty
, " max-metric router-lsa on-shutdown %u%s",
8922 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
8923 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
8925 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
8927 vty_out (vty
, " max-metric router-lsa administrative%s",
8936 show_ip_ospf_route_network (struct vty
*vty
, struct route_table
*rt
)
8938 struct route_node
*rn
;
8939 struct ospf_route
*or;
8940 struct listnode
*pnode
, *pnnode
;
8941 struct ospf_path
*path
;
8943 vty_out (vty
, "============ OSPF network routing table ============%s",
8946 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
8947 if ((or = rn
->info
) != NULL
)
8950 snprintf (buf1
, 19, "%s/%d",
8951 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
8953 switch (or->path_type
)
8955 case OSPF_PATH_INTER_AREA
:
8956 if (or->type
== OSPF_DESTINATION_NETWORK
)
8957 vty_out (vty
, "N IA %-18s [%d] area: %s%s", buf1
, or->cost
,
8958 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
8959 else if (or->type
== OSPF_DESTINATION_DISCARD
)
8960 vty_out (vty
, "D IA %-18s Discard entry%s", buf1
, VTY_NEWLINE
);
8962 case OSPF_PATH_INTRA_AREA
:
8963 vty_out (vty
, "N %-18s [%d] area: %s%s", buf1
, or->cost
,
8964 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
8970 if (or->type
== OSPF_DESTINATION_NETWORK
)
8971 for (ALL_LIST_ELEMENTS (or->paths
, pnode
, pnnode
, path
))
8973 if (if_lookup_by_index(path
->ifindex
))
8975 if (path
->nexthop
.s_addr
== 0)
8976 vty_out (vty
, "%24s directly attached to %s%s",
8977 "", ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
8979 vty_out (vty
, "%24s via %s, %s%s", "",
8980 inet_ntoa (path
->nexthop
),
8981 ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
8985 vty_out (vty
, "%s", VTY_NEWLINE
);
8989 show_ip_ospf_route_router (struct vty
*vty
, struct route_table
*rtrs
)
8991 struct route_node
*rn
;
8992 struct ospf_route
*or;
8993 struct listnode
*pnode
;
8994 struct listnode
*node
;
8995 struct ospf_path
*path
;
8997 vty_out (vty
, "============ OSPF router routing table =============%s",
8999 for (rn
= route_top (rtrs
); rn
; rn
= route_next (rn
))
9004 vty_out (vty
, "R %-15s ", inet_ntoa (rn
->p
.u
.prefix4
));
9006 for (ALL_LIST_ELEMENTS_RO ((struct list
*)rn
->info
, node
, or))
9009 vty_out (vty
, "%24s", "");
9012 vty_out (vty
, "%s [%d] area: %s",
9013 (or->path_type
== OSPF_PATH_INTER_AREA
? "IA" : " "),
9014 or->cost
, inet_ntoa (or->u
.std
.area_id
));
9016 vty_out (vty
, "%s%s%s",
9017 (or->u
.std
.flags
& ROUTER_LSA_BORDER
? ", ABR" : ""),
9018 (or->u
.std
.flags
& ROUTER_LSA_EXTERNAL
? ", ASBR" : ""),
9021 for (ALL_LIST_ELEMENTS_RO (or->paths
, pnode
, path
))
9023 if (if_lookup_by_index(path
->ifindex
))
9025 if (path
->nexthop
.s_addr
== 0)
9026 vty_out (vty
, "%24s directly attached to %s%s",
9027 "", ifindex2ifname (path
->ifindex
),
9030 vty_out (vty
, "%24s via %s, %s%s", "",
9031 inet_ntoa (path
->nexthop
),
9032 ifindex2ifname (path
->ifindex
),
9038 vty_out (vty
, "%s", VTY_NEWLINE
);
9042 show_ip_ospf_route_external (struct vty
*vty
, struct route_table
*rt
)
9044 struct route_node
*rn
;
9045 struct ospf_route
*er
;
9046 struct listnode
*pnode
, *pnnode
;
9047 struct ospf_path
*path
;
9049 vty_out (vty
, "============ OSPF external routing table ===========%s",
9051 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
9052 if ((er
= rn
->info
) != NULL
)
9055 snprintf (buf1
, 19, "%s/%d",
9056 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
9058 switch (er
->path_type
)
9060 case OSPF_PATH_TYPE1_EXTERNAL
:
9061 vty_out (vty
, "N E1 %-18s [%d] tag: %u%s", buf1
,
9062 er
->cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
9064 case OSPF_PATH_TYPE2_EXTERNAL
:
9065 vty_out (vty
, "N E2 %-18s [%d/%d] tag: %u%s", buf1
, er
->cost
,
9066 er
->u
.ext
.type2_cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
9070 for (ALL_LIST_ELEMENTS (er
->paths
, pnode
, pnnode
, path
))
9072 if (if_lookup_by_index(path
->ifindex
))
9074 if (path
->nexthop
.s_addr
== 0)
9075 vty_out (vty
, "%24s directly attached to %s%s",
9076 "", ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
9078 vty_out (vty
, "%24s via %s, %s%s", "",
9079 inet_ntoa (path
->nexthop
),
9080 ifindex2ifname (path
->ifindex
),
9085 vty_out (vty
, "%s", VTY_NEWLINE
);
9089 show_ip_ospf_border_routers_common (struct vty
*vty
, struct ospf
*ospf
)
9092 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
9093 VTY_NEWLINE
, VTY_NEWLINE
);
9095 if (ospf
->new_table
== NULL
)
9097 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
9101 /* Show Network routes.
9102 show_ip_ospf_route_network (vty, ospf->new_table); */
9104 /* Show Router routes. */
9105 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
9107 vty_out (vty
, "%s", VTY_NEWLINE
);
9112 DEFUN (show_ip_ospf_border_routers
,
9113 show_ip_ospf_border_routers_cmd
,
9114 "show ip ospf border-routers",
9117 "OSPF information\n"
9118 "Show all the ABR's and ASBR's\n")
9122 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
9125 return show_ip_ospf_border_routers_common(vty
, ospf
);
9128 DEFUN (show_ip_ospf_instance_border_routers
,
9129 show_ip_ospf_instance_border_routers_cmd
,
9130 "show ip ospf <1-65535> border-routers",
9133 "OSPF information\n"
9135 "Show all the ABR's and ASBR's\n")
9138 u_short instance
= 0;
9140 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
9141 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
9144 return show_ip_ospf_border_routers_common(vty
, ospf
);
9148 show_ip_ospf_route_common (struct vty
*vty
, struct ospf
*ospf
)
9151 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
9152 VTY_NEWLINE
, VTY_NEWLINE
);
9154 if (ospf
->new_table
== NULL
)
9156 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
9160 /* Show Network routes. */
9161 show_ip_ospf_route_network (vty
, ospf
->new_table
);
9163 /* Show Router routes. */
9164 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
9166 /* Show AS External routes. */
9167 show_ip_ospf_route_external (vty
, ospf
->old_external_route
);
9169 vty_out (vty
, "%s", VTY_NEWLINE
);
9174 DEFUN (show_ip_ospf_route
,
9175 show_ip_ospf_route_cmd
,
9176 "show ip ospf route",
9179 "OSPF information\n"
9180 "OSPF routing table\n")
9184 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
9187 return show_ip_ospf_route_common(vty
, ospf
);
9190 DEFUN (show_ip_ospf_instance_route
,
9191 show_ip_ospf_instance_route_cmd
,
9192 "show ip ospf <1-65535> route",
9195 "OSPF information\n"
9197 "OSPF routing table\n")
9200 u_short instance
= 0;
9202 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
9203 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
9206 return show_ip_ospf_route_common(vty
, ospf
);
9209 const char *ospf_abr_type_str
[] =
9218 const char *ospf_shortcut_mode_str
[] =
9227 area_id2str (char *buf
, int length
, struct ospf_area
*area
)
9229 memset (buf
, 0, length
);
9231 if (area
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
9232 strncpy (buf
, inet_ntoa (area
->area_id
), length
);
9234 sprintf (buf
, "%lu", (unsigned long) ntohl (area
->area_id
.s_addr
));
9238 const char *ospf_int_type_str
[] =
9240 "unknown", /* should never be used. */
9244 "point-to-multipoint",
9245 "virtual-link", /* should never be used. */
9249 /* Configuration write function for ospfd. */
9251 config_write_interface (struct vty
*vty
)
9253 struct listnode
*n1
, *n2
;
9254 struct interface
*ifp
;
9255 struct crypt_key
*ck
;
9257 struct route_node
*rn
= NULL
;
9258 struct ospf_if_params
*params
;
9259 struct ospf
*ospf
= ospf_lookup();
9261 for (ALL_LIST_ELEMENTS_RO (iflist
, n1
, ifp
))
9263 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
9266 vty_out (vty
, "!%s", VTY_NEWLINE
);
9267 vty_out (vty
, "interface %s%s", ifp
->name
,
9270 vty_out (vty
, " description %s%s", ifp
->desc
,
9275 params
= IF_DEF_PARAMS (ifp
);
9278 /* Interface Network print. */
9279 if (OSPF_IF_PARAM_CONFIGURED (params
, type
) &&
9280 params
->type
!= OSPF_IFTYPE_LOOPBACK
)
9282 if (params
->type
!= ospf_default_iftype(ifp
))
9284 vty_out (vty
, " ip ospf network %s",
9285 ospf_int_type_str
[params
->type
]);
9286 if (params
!= IF_DEF_PARAMS (ifp
))
9287 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9288 vty_out (vty
, "%s", VTY_NEWLINE
);
9292 /* OSPF interface authentication print */
9293 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_type
) &&
9294 params
->auth_type
!= OSPF_AUTH_NOTSET
)
9296 const char *auth_str
;
9298 /* Translation tables are not that much help here due to syntax
9299 of the simple option */
9300 switch (params
->auth_type
)
9303 case OSPF_AUTH_NULL
:
9307 case OSPF_AUTH_SIMPLE
:
9311 case OSPF_AUTH_CRYPTOGRAPHIC
:
9312 auth_str
= " message-digest";
9320 vty_out (vty
, " ip ospf authentication%s", auth_str
);
9321 if (params
!= IF_DEF_PARAMS (ifp
))
9322 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9323 vty_out (vty
, "%s", VTY_NEWLINE
);
9326 /* Simple Authentication Password print. */
9327 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_simple
) &&
9328 params
->auth_simple
[0] != '\0')
9330 vty_out (vty
, " ip ospf authentication-key %s",
9331 params
->auth_simple
);
9332 if (params
!= IF_DEF_PARAMS (ifp
))
9333 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9334 vty_out (vty
, "%s", VTY_NEWLINE
);
9337 /* Cryptographic Authentication Key print. */
9338 for (ALL_LIST_ELEMENTS_RO (params
->auth_crypt
, n2
, ck
))
9340 vty_out (vty
, " ip ospf message-digest-key %d md5 %s",
9341 ck
->key_id
, ck
->auth_key
);
9342 if (params
!= IF_DEF_PARAMS (ifp
))
9343 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9344 vty_out (vty
, "%s", VTY_NEWLINE
);
9347 /* Interface Output Cost print. */
9348 if (OSPF_IF_PARAM_CONFIGURED (params
, output_cost_cmd
))
9350 vty_out (vty
, " ip ospf cost %u", params
->output_cost_cmd
);
9351 if (params
!= IF_DEF_PARAMS (ifp
))
9352 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9353 vty_out (vty
, "%s", VTY_NEWLINE
);
9356 /* Hello Interval print. */
9357 if (OSPF_IF_PARAM_CONFIGURED (params
, v_hello
) &&
9358 params
->v_hello
!= OSPF_HELLO_INTERVAL_DEFAULT
)
9360 vty_out (vty
, " ip ospf hello-interval %u", params
->v_hello
);
9361 if (params
!= IF_DEF_PARAMS (ifp
))
9362 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9363 vty_out (vty
, "%s", VTY_NEWLINE
);
9367 /* Router Dead Interval print. */
9368 if (OSPF_IF_PARAM_CONFIGURED (params
, v_wait
) &&
9369 params
->v_wait
!= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
)
9371 vty_out (vty
, " ip ospf dead-interval ");
9374 if (OSPF_IF_PARAM_CONFIGURED (params
, fast_hello
))
9375 vty_out (vty
, "minimal hello-multiplier %d",
9376 params
->fast_hello
);
9378 vty_out (vty
, "%u", params
->v_wait
);
9380 if (params
!= IF_DEF_PARAMS (ifp
))
9381 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9382 vty_out (vty
, "%s", VTY_NEWLINE
);
9385 /* Router Priority print. */
9386 if (OSPF_IF_PARAM_CONFIGURED (params
, priority
) &&
9387 params
->priority
!= OSPF_ROUTER_PRIORITY_DEFAULT
)
9389 vty_out (vty
, " ip ospf priority %u", params
->priority
);
9390 if (params
!= IF_DEF_PARAMS (ifp
))
9391 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9392 vty_out (vty
, "%s", VTY_NEWLINE
);
9395 /* Retransmit Interval print. */
9396 if (OSPF_IF_PARAM_CONFIGURED (params
, retransmit_interval
) &&
9397 params
->retransmit_interval
!= OSPF_RETRANSMIT_INTERVAL_DEFAULT
)
9399 vty_out (vty
, " ip ospf retransmit-interval %u",
9400 params
->retransmit_interval
);
9401 if (params
!= IF_DEF_PARAMS (ifp
))
9402 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9403 vty_out (vty
, "%s", VTY_NEWLINE
);
9406 /* Transmit Delay print. */
9407 if (OSPF_IF_PARAM_CONFIGURED (params
, transmit_delay
) &&
9408 params
->transmit_delay
!= OSPF_TRANSMIT_DELAY_DEFAULT
)
9410 vty_out (vty
, " ip ospf transmit-delay %u", params
->transmit_delay
);
9411 if (params
!= IF_DEF_PARAMS (ifp
))
9412 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9413 vty_out (vty
, "%s", VTY_NEWLINE
);
9417 if (OSPF_IF_PARAM_CONFIGURED (params
, if_area
))
9420 vty_out (vty
, " ip ospf %d area %s%s", ospf
->instance
,
9421 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
9423 vty_out (vty
, " ip ospf area %s%s",
9424 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
9429 ospf_bfd_write_config(vty
, params
);
9431 /* MTU ignore print. */
9432 if (OSPF_IF_PARAM_CONFIGURED (params
, mtu_ignore
) &&
9433 params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
9435 if (params
->mtu_ignore
== 0)
9436 vty_out (vty
, " no ip ospf mtu-ignore");
9438 vty_out (vty
, " ip ospf mtu-ignore");
9439 if (params
!= IF_DEF_PARAMS (ifp
))
9440 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9441 vty_out (vty
, "%s", VTY_NEWLINE
);
9448 rn
= route_top (IF_OIFS_PARAMS (ifp
));
9450 rn
= route_next (rn
);
9460 #ifdef HAVE_OPAQUE_LSA
9461 ospf_opaque_config_write_if (vty
, ifp
);
9462 #endif /* HAVE_OPAQUE_LSA */
9469 config_write_network_area (struct vty
*vty
, struct ospf
*ospf
)
9471 struct route_node
*rn
;
9472 u_char buf
[INET_ADDRSTRLEN
];
9474 /* `network area' print. */
9475 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
9478 struct ospf_network
*n
= rn
->info
;
9480 memset (buf
, 0, INET_ADDRSTRLEN
);
9482 /* Create Area ID string by specified Area ID format. */
9483 if (n
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
9484 strncpy ((char *) buf
, inet_ntoa (n
->area_id
), INET_ADDRSTRLEN
);
9486 sprintf ((char *) buf
, "%lu",
9487 (unsigned long int) ntohl (n
->area_id
.s_addr
));
9489 /* Network print. */
9490 vty_out (vty
, " network %s/%d area %s%s",
9491 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
9499 config_write_ospf_area (struct vty
*vty
, struct ospf
*ospf
)
9501 struct listnode
*node
;
9502 struct ospf_area
*area
;
9503 u_char buf
[INET_ADDRSTRLEN
];
9505 /* Area configuration print. */
9506 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
9508 struct route_node
*rn1
;
9510 area_id2str ((char *) buf
, INET_ADDRSTRLEN
, area
);
9512 if (area
->auth_type
!= OSPF_AUTH_NULL
)
9514 if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
9515 vty_out (vty
, " area %s authentication%s", buf
, VTY_NEWLINE
);
9517 vty_out (vty
, " area %s authentication message-digest%s",
9521 if (area
->shortcut_configured
!= OSPF_SHORTCUT_DEFAULT
)
9522 vty_out (vty
, " area %s shortcut %s%s", buf
,
9523 ospf_shortcut_mode_str
[area
->shortcut_configured
],
9526 if ((area
->external_routing
== OSPF_AREA_STUB
)
9527 || (area
->external_routing
== OSPF_AREA_NSSA
)
9530 if (area
->external_routing
== OSPF_AREA_STUB
)
9531 vty_out (vty
, " area %s stub", buf
);
9532 else if (area
->external_routing
== OSPF_AREA_NSSA
)
9534 vty_out (vty
, " area %s nssa", buf
);
9535 switch (area
->NSSATranslatorRole
)
9537 case OSPF_NSSA_ROLE_NEVER
:
9538 vty_out (vty
, " translate-never");
9540 case OSPF_NSSA_ROLE_ALWAYS
:
9541 vty_out (vty
, " translate-always");
9543 case OSPF_NSSA_ROLE_CANDIDATE
:
9545 vty_out (vty
, " translate-candidate");
9549 if (area
->no_summary
)
9550 vty_out (vty
, " no-summary");
9552 vty_out (vty
, "%s", VTY_NEWLINE
);
9554 if (area
->default_cost
!= 1)
9555 vty_out (vty
, " area %s default-cost %d%s", buf
,
9556 area
->default_cost
, VTY_NEWLINE
);
9559 for (rn1
= route_top (area
->ranges
); rn1
; rn1
= route_next (rn1
))
9562 struct ospf_area_range
*range
= rn1
->info
;
9564 vty_out (vty
, " area %s range %s/%d", buf
,
9565 inet_ntoa (rn1
->p
.u
.prefix4
), rn1
->p
.prefixlen
);
9567 if (range
->cost_config
!= OSPF_AREA_RANGE_COST_UNSPEC
)
9568 vty_out (vty
, " cost %d", range
->cost_config
);
9570 if (!CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_ADVERTISE
))
9571 vty_out (vty
, " not-advertise");
9573 if (CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_SUBSTITUTE
))
9574 vty_out (vty
, " substitute %s/%d",
9575 inet_ntoa (range
->subst_addr
), range
->subst_masklen
);
9577 vty_out (vty
, "%s", VTY_NEWLINE
);
9580 if (EXPORT_NAME (area
))
9581 vty_out (vty
, " area %s export-list %s%s", buf
,
9582 EXPORT_NAME (area
), VTY_NEWLINE
);
9584 if (IMPORT_NAME (area
))
9585 vty_out (vty
, " area %s import-list %s%s", buf
,
9586 IMPORT_NAME (area
), VTY_NEWLINE
);
9588 if (PREFIX_NAME_IN (area
))
9589 vty_out (vty
, " area %s filter-list prefix %s in%s", buf
,
9590 PREFIX_NAME_IN (area
), VTY_NEWLINE
);
9592 if (PREFIX_NAME_OUT (area
))
9593 vty_out (vty
, " area %s filter-list prefix %s out%s", buf
,
9594 PREFIX_NAME_OUT (area
), VTY_NEWLINE
);
9601 config_write_ospf_nbr_nbma (struct vty
*vty
, struct ospf
*ospf
)
9603 struct ospf_nbr_nbma
*nbr_nbma
;
9604 struct route_node
*rn
;
9606 /* Static Neighbor configuration print. */
9607 for (rn
= route_top (ospf
->nbr_nbma
); rn
; rn
= route_next (rn
))
9608 if ((nbr_nbma
= rn
->info
))
9610 vty_out (vty
, " neighbor %s", inet_ntoa (nbr_nbma
->addr
));
9612 if (nbr_nbma
->priority
!= OSPF_NEIGHBOR_PRIORITY_DEFAULT
)
9613 vty_out (vty
, " priority %d", nbr_nbma
->priority
);
9615 if (nbr_nbma
->v_poll
!= OSPF_POLL_INTERVAL_DEFAULT
)
9616 vty_out (vty
, " poll-interval %d", nbr_nbma
->v_poll
);
9618 vty_out (vty
, "%s", VTY_NEWLINE
);
9625 config_write_virtual_link (struct vty
*vty
, struct ospf
*ospf
)
9627 struct listnode
*node
;
9628 struct ospf_vl_data
*vl_data
;
9629 u_char buf
[INET_ADDRSTRLEN
];
9631 /* Virtual-Link print */
9632 for (ALL_LIST_ELEMENTS_RO (ospf
->vlinks
, node
, vl_data
))
9634 struct listnode
*n2
;
9635 struct crypt_key
*ck
;
9636 struct ospf_interface
*oi
;
9638 if (vl_data
!= NULL
)
9640 memset (buf
, 0, INET_ADDRSTRLEN
);
9642 if (vl_data
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
9643 strncpy ((char *) buf
, inet_ntoa (vl_data
->vl_area_id
), INET_ADDRSTRLEN
);
9645 sprintf ((char *) buf
, "%lu",
9646 (unsigned long int) ntohl (vl_data
->vl_area_id
.s_addr
));
9647 oi
= vl_data
->vl_oi
;
9650 if (OSPF_IF_PARAM (oi
, v_hello
) != OSPF_HELLO_INTERVAL_DEFAULT
||
9651 OSPF_IF_PARAM (oi
, v_wait
) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
||
9652 OSPF_IF_PARAM (oi
, retransmit_interval
) != OSPF_RETRANSMIT_INTERVAL_DEFAULT
||
9653 OSPF_IF_PARAM (oi
, transmit_delay
) != OSPF_TRANSMIT_DELAY_DEFAULT
)
9654 vty_out (vty
, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
9656 inet_ntoa (vl_data
->vl_peer
),
9657 OSPF_IF_PARAM (oi
, v_hello
),
9658 OSPF_IF_PARAM (oi
, retransmit_interval
),
9659 OSPF_IF_PARAM (oi
, transmit_delay
),
9660 OSPF_IF_PARAM (oi
, v_wait
),
9663 vty_out (vty
, " area %s virtual-link %s%s", buf
,
9664 inet_ntoa (vl_data
->vl_peer
), VTY_NEWLINE
);
9666 if (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
[0] != '\0')
9667 vty_out (vty
, " area %s virtual-link %s authentication-key %s%s",
9669 inet_ntoa (vl_data
->vl_peer
),
9670 IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
,
9673 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_crypt
,
9675 vty_out (vty
, " area %s virtual-link %s"
9676 " message-digest-key %d md5 %s%s",
9678 inet_ntoa (vl_data
->vl_peer
),
9679 ck
->key_id
, ck
->auth_key
, VTY_NEWLINE
);
9689 config_write_ospf_redistribute (struct vty
*vty
, struct ospf
*ospf
)
9693 /* redistribute print. */
9694 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
9696 struct list
*red_list
;
9697 struct listnode
*node
;
9698 struct ospf_redist
*red
;
9700 red_list
= ospf
->redist
[type
];
9704 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
))
9706 vty_out (vty
, " redistribute %s", zebra_route_string(type
));
9708 vty_out (vty
, " %d", red
->instance
);
9710 if (red
->dmetric
.value
>= 0)
9711 vty_out (vty
, " metric %d", red
->dmetric
.value
);
9713 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
9714 vty_out (vty
, " metric-type 1");
9716 if (ROUTEMAP_NAME (red
))
9717 vty_out (vty
, " route-map %s", ROUTEMAP_NAME (red
));
9719 vty_out (vty
, "%s", VTY_NEWLINE
);
9727 config_write_ospf_default_metric (struct vty
*vty
, struct ospf
*ospf
)
9729 if (ospf
->default_metric
!= -1)
9730 vty_out (vty
, " default-metric %d%s", ospf
->default_metric
,
9736 config_write_ospf_distribute (struct vty
*vty
, struct ospf
*ospf
)
9739 struct ospf_redist
*red
;
9743 /* distribute-list print. */
9744 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
9745 if (DISTRIBUTE_NAME (ospf
, type
))
9746 vty_out (vty
, " distribute-list %s out %s%s",
9747 DISTRIBUTE_NAME (ospf
, type
),
9748 zebra_route_string(type
), VTY_NEWLINE
);
9750 /* default-information print. */
9751 if (ospf
->default_originate
!= DEFAULT_ORIGINATE_NONE
)
9753 vty_out (vty
, " default-information originate");
9754 if (ospf
->default_originate
== DEFAULT_ORIGINATE_ALWAYS
)
9755 vty_out (vty
, " always");
9757 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
9760 if (red
->dmetric
.value
>= 0)
9761 vty_out (vty
, " metric %d",
9762 red
->dmetric
.value
);
9763 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
9764 vty_out (vty
, " metric-type 1");
9766 if (ROUTEMAP_NAME (red
))
9767 vty_out (vty
, " route-map %s",
9768 ROUTEMAP_NAME (red
));
9771 vty_out (vty
, "%s", VTY_NEWLINE
);
9780 config_write_ospf_distance (struct vty
*vty
, struct ospf
*ospf
)
9782 struct route_node
*rn
;
9783 struct ospf_distance
*odistance
;
9785 if (ospf
->distance_all
)
9786 vty_out (vty
, " distance %d%s", ospf
->distance_all
, VTY_NEWLINE
);
9788 if (ospf
->distance_intra
9789 || ospf
->distance_inter
9790 || ospf
->distance_external
)
9792 vty_out (vty
, " distance ospf");
9794 if (ospf
->distance_intra
)
9795 vty_out (vty
, " intra-area %d", ospf
->distance_intra
);
9796 if (ospf
->distance_inter
)
9797 vty_out (vty
, " inter-area %d", ospf
->distance_inter
);
9798 if (ospf
->distance_external
)
9799 vty_out (vty
, " external %d", ospf
->distance_external
);
9801 vty_out (vty
, "%s", VTY_NEWLINE
);
9804 for (rn
= route_top (ospf
->distance_table
); rn
; rn
= route_next (rn
))
9805 if ((odistance
= rn
->info
) != NULL
)
9807 vty_out (vty
, " distance %d %s/%d %s%s", odistance
->distance
,
9808 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
9809 odistance
->access_list
? odistance
->access_list
: "",
9815 /* OSPF configuration write function. */
9817 ospf_config_write (struct vty
*vty
)
9820 struct interface
*ifp
;
9821 struct ospf_interface
*oi
;
9822 struct listnode
*node
;
9825 ospf
= ospf_lookup ();
9826 if (ospf
!= NULL
&& ospf
->oi_running
)
9828 /* `router ospf' print. */
9830 vty_out (vty
, "router ospf %d%s", ospf
->instance
, VTY_NEWLINE
);
9832 vty_out (vty
, "router ospf%s", VTY_NEWLINE
);
9836 if (!ospf
->networks
)
9839 /* Router ID print. */
9840 if (ospf
->router_id_static
.s_addr
!= 0)
9841 vty_out (vty
, " ospf router-id %s%s",
9842 inet_ntoa (ospf
->router_id_static
), VTY_NEWLINE
);
9844 /* ABR type print. */
9845 if (ospf
->abr_type
!= OSPF_ABR_DEFAULT
)
9846 vty_out (vty
, " ospf abr-type %s%s",
9847 ospf_abr_type_str
[ospf
->abr_type
], VTY_NEWLINE
);
9849 /* log-adjacency-changes flag print. */
9850 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
))
9852 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
9853 vty_out(vty
, " log-adjacency-changes detail%s", VTY_NEWLINE
);
9857 vty_out(vty
, " no log-adjacency-changes%s", VTY_NEWLINE
);
9860 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
9861 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
9862 vty_out (vty
, " compatible rfc1583%s", VTY_NEWLINE
);
9864 /* auto-cost reference-bandwidth configuration. */
9865 if (ospf
->ref_bandwidth
!= OSPF_DEFAULT_REF_BANDWIDTH
)
9867 vty_out (vty
, "! Important: ensure reference bandwidth "
9868 "is consistent across all routers%s", VTY_NEWLINE
);
9869 vty_out (vty
, " auto-cost reference-bandwidth %d%s",
9870 ospf
->ref_bandwidth
/ 1000, VTY_NEWLINE
);
9873 /* SPF timers print. */
9874 if (ospf
->spf_delay
!= OSPF_SPF_DELAY_DEFAULT
||
9875 ospf
->spf_holdtime
!= OSPF_SPF_HOLDTIME_DEFAULT
||
9876 ospf
->spf_max_holdtime
!= OSPF_SPF_MAX_HOLDTIME_DEFAULT
)
9877 vty_out (vty
, " timers throttle spf %d %d %d%s",
9878 ospf
->spf_delay
, ospf
->spf_holdtime
,
9879 ospf
->spf_max_holdtime
, VTY_NEWLINE
);
9881 /* LSA timers print. */
9882 if (ospf
->min_ls_interval
!= OSPF_MIN_LS_INTERVAL
)
9883 vty_out (vty
, " timers throttle lsa all %d%s",
9884 ospf
->min_ls_interval
, VTY_NEWLINE
);
9885 if (ospf
->min_ls_arrival
!= OSPF_MIN_LS_ARRIVAL
)
9886 vty_out (vty
, " timers lsa min-arrival %d%s",
9887 ospf
->min_ls_arrival
, VTY_NEWLINE
);
9889 /* Write multiplier print. */
9890 if (ospf
->write_oi_count
!= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
)
9891 vty_out (vty
, " ospf write-multiplier %d%s",
9892 ospf
->write_oi_count
, VTY_NEWLINE
);
9894 /* Max-metric router-lsa print */
9895 config_write_stub_router (vty
, ospf
);
9897 /* SPF refresh parameters print. */
9898 if (ospf
->lsa_refresh_interval
!= OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
9899 vty_out (vty
, " refresh timer %d%s",
9900 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
9902 /* Redistribute information print. */
9903 config_write_ospf_redistribute (vty
, ospf
);
9905 /* passive-interface print. */
9906 if (ospf
->passive_interface_default
== OSPF_IF_PASSIVE
)
9907 vty_out (vty
, " passive-interface default%s", VTY_NEWLINE
);
9909 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, node
, ifp
))
9910 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
)
9911 && IF_DEF_PARAMS (ifp
)->passive_interface
!=
9912 ospf
->passive_interface_default
)
9914 vty_out (vty
, " %spassive-interface %s%s",
9915 IF_DEF_PARAMS (ifp
)->passive_interface
? "" : "no ",
9916 ifp
->name
, VTY_NEWLINE
);
9918 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
9920 if (!OSPF_IF_PARAM_CONFIGURED (oi
->params
, passive_interface
))
9922 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi
->ifp
),
9925 if (oi
->params
->passive_interface
== IF_DEF_PARAMS (oi
->ifp
)->passive_interface
)
9928 else if (oi
->params
->passive_interface
== ospf
->passive_interface_default
)
9931 vty_out (vty
, " %spassive-interface %s %s%s",
9932 oi
->params
->passive_interface
? "" : "no ",
9934 inet_ntoa (oi
->address
->u
.prefix4
), VTY_NEWLINE
);
9937 /* Network area print. */
9938 config_write_network_area (vty
, ospf
);
9940 /* Area config print. */
9941 config_write_ospf_area (vty
, ospf
);
9943 /* static neighbor print. */
9944 config_write_ospf_nbr_nbma (vty
, ospf
);
9946 /* Virtual-Link print. */
9947 config_write_virtual_link (vty
, ospf
);
9949 /* Default metric configuration. */
9950 config_write_ospf_default_metric (vty
, ospf
);
9952 /* Distribute-list and default-information print. */
9953 config_write_ospf_distribute (vty
, ospf
);
9955 /* Distance configuration. */
9956 config_write_ospf_distance (vty
, ospf
);
9958 #ifdef HAVE_OPAQUE_LSA
9959 ospf_opaque_config_write_router (vty
, ospf
);
9960 #endif /* HAVE_OPAQUE_LSA */
9967 ospf_vty_show_init (void)
9969 /* "show ip ospf" commands. */
9970 install_element (VIEW_NODE
, &show_ip_ospf_cmd
);
9971 install_element (ENABLE_NODE
, &show_ip_ospf_cmd
);
9973 install_element (VIEW_NODE
, &show_ip_ospf_instance_cmd
);
9974 install_element (ENABLE_NODE
, &show_ip_ospf_instance_cmd
);
9976 /* "show ip ospf database" commands. */
9977 install_element (VIEW_NODE
, &show_ip_ospf_database_type_cmd
);
9978 install_element (VIEW_NODE
, &show_ip_ospf_database_type_id_cmd
);
9979 install_element (VIEW_NODE
, &show_ip_ospf_database_type_id_adv_router_cmd
);
9980 install_element (VIEW_NODE
, &show_ip_ospf_database_type_adv_router_cmd
);
9981 install_element (VIEW_NODE
, &show_ip_ospf_database_type_id_self_cmd
);
9982 install_element (VIEW_NODE
, &show_ip_ospf_database_type_self_cmd
);
9983 install_element (VIEW_NODE
, &show_ip_ospf_database_cmd
);
9984 install_element (ENABLE_NODE
, &show_ip_ospf_database_type_cmd
);
9985 install_element (ENABLE_NODE
, &show_ip_ospf_database_type_id_cmd
);
9986 install_element (ENABLE_NODE
, &show_ip_ospf_database_type_id_adv_router_cmd
);
9987 install_element (ENABLE_NODE
, &show_ip_ospf_database_type_adv_router_cmd
);
9988 install_element (ENABLE_NODE
, &show_ip_ospf_database_type_id_self_cmd
);
9989 install_element (ENABLE_NODE
, &show_ip_ospf_database_type_self_cmd
);
9990 install_element (ENABLE_NODE
, &show_ip_ospf_database_cmd
);
9992 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_cmd
);
9993 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_id_cmd
);
9994 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_id_adv_router_cmd
);
9995 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_adv_router_cmd
);
9996 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_id_self_cmd
);
9997 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_self_cmd
);
9998 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_cmd
);
9999 install_element (ENABLE_NODE
, &show_ip_ospf_instance_database_type_cmd
);
10000 install_element (ENABLE_NODE
, &show_ip_ospf_instance_database_type_id_cmd
);
10001 install_element (ENABLE_NODE
, &show_ip_ospf_instance_database_type_id_adv_router_cmd
);
10002 install_element (ENABLE_NODE
, &show_ip_ospf_instance_database_type_adv_router_cmd
);
10003 install_element (ENABLE_NODE
, &show_ip_ospf_instance_database_type_id_self_cmd
);
10004 install_element (ENABLE_NODE
, &show_ip_ospf_instance_database_type_self_cmd
);
10005 install_element (ENABLE_NODE
, &show_ip_ospf_instance_database_cmd
);
10007 /* "show ip ospf interface" commands. */
10008 install_element (VIEW_NODE
, &show_ip_ospf_interface_cmd
);
10009 install_element (ENABLE_NODE
, &show_ip_ospf_interface_cmd
);
10011 install_element (VIEW_NODE
, &show_ip_ospf_instance_interface_cmd
);
10012 install_element (ENABLE_NODE
, &show_ip_ospf_instance_interface_cmd
);
10014 /* "show ip ospf neighbor" commands. */
10015 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_detail_cmd
);
10016 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_cmd
);
10017 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_id_cmd
);
10018 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_all_cmd
);
10019 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_cmd
);
10020 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_cmd
);
10021 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_all_cmd
);
10022 install_element (ENABLE_NODE
, &show_ip_ospf_neighbor_int_detail_cmd
);
10023 install_element (ENABLE_NODE
, &show_ip_ospf_neighbor_int_cmd
);
10024 install_element (ENABLE_NODE
, &show_ip_ospf_neighbor_id_cmd
);
10025 install_element (ENABLE_NODE
, &show_ip_ospf_neighbor_detail_all_cmd
);
10026 install_element (ENABLE_NODE
, &show_ip_ospf_neighbor_detail_cmd
);
10027 install_element (ENABLE_NODE
, &show_ip_ospf_neighbor_cmd
);
10028 install_element (ENABLE_NODE
, &show_ip_ospf_neighbor_all_cmd
);
10030 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_detail_cmd
);
10031 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_cmd
);
10032 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_id_cmd
);
10033 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_all_cmd
);
10034 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_cmd
);
10035 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_cmd
);
10036 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_all_cmd
);
10037 install_element (ENABLE_NODE
, &show_ip_ospf_instance_neighbor_int_detail_cmd
);
10038 install_element (ENABLE_NODE
, &show_ip_ospf_instance_neighbor_int_cmd
);
10039 install_element (ENABLE_NODE
, &show_ip_ospf_instance_neighbor_id_cmd
);
10040 install_element (ENABLE_NODE
, &show_ip_ospf_instance_neighbor_detail_all_cmd
);
10041 install_element (ENABLE_NODE
, &show_ip_ospf_instance_neighbor_detail_cmd
);
10042 install_element (ENABLE_NODE
, &show_ip_ospf_instance_neighbor_cmd
);
10043 install_element (ENABLE_NODE
, &show_ip_ospf_instance_neighbor_all_cmd
);
10045 /* "show ip ospf route" commands. */
10046 install_element (VIEW_NODE
, &show_ip_ospf_route_cmd
);
10047 install_element (ENABLE_NODE
, &show_ip_ospf_route_cmd
);
10048 install_element (VIEW_NODE
, &show_ip_ospf_border_routers_cmd
);
10049 install_element (ENABLE_NODE
, &show_ip_ospf_border_routers_cmd
);
10051 install_element (VIEW_NODE
, &show_ip_ospf_instance_route_cmd
);
10052 install_element (ENABLE_NODE
, &show_ip_ospf_instance_route_cmd
);
10053 install_element (VIEW_NODE
, &show_ip_ospf_instance_border_routers_cmd
);
10054 install_element (ENABLE_NODE
, &show_ip_ospf_instance_border_routers_cmd
);
10058 /* ospfd's interface node. */
10059 static struct cmd_node interface_node
=
10066 /* Initialization of OSPF interface. */
10068 ospf_vty_if_init (void)
10070 /* Install interface node. */
10071 install_node (&interface_node
, config_write_interface
);
10073 install_element (CONFIG_NODE
, &interface_cmd
);
10074 install_element (CONFIG_NODE
, &no_interface_cmd
);
10075 install_default (INTERFACE_NODE
);
10077 /* "description" commands. */
10078 install_element (INTERFACE_NODE
, &interface_desc_cmd
);
10079 install_element (INTERFACE_NODE
, &no_interface_desc_cmd
);
10081 /* "ip ospf authentication" commands. */
10082 install_element (INTERFACE_NODE
, &ip_ospf_authentication_args_addr_cmd
);
10083 install_element (INTERFACE_NODE
, &ip_ospf_authentication_args_cmd
);
10084 install_element (INTERFACE_NODE
, &ip_ospf_authentication_addr_cmd
);
10085 install_element (INTERFACE_NODE
, &ip_ospf_authentication_cmd
);
10086 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_args_addr_cmd
);
10087 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_args_cmd
);
10088 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_addr_cmd
);
10089 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_cmd
);
10090 install_element (INTERFACE_NODE
, &ip_ospf_authentication_key_addr_cmd
);
10091 install_element (INTERFACE_NODE
, &ip_ospf_authentication_key_cmd
);
10092 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_key_authkey_addr_cmd
);
10093 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_key_authkey_cmd
);
10094 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_key_cmd
);
10096 /* "ip ospf message-digest-key" commands. */
10097 install_element (INTERFACE_NODE
, &ip_ospf_message_digest_key_addr_cmd
);
10098 install_element (INTERFACE_NODE
, &ip_ospf_message_digest_key_cmd
);
10099 install_element (INTERFACE_NODE
, &no_ip_ospf_message_digest_key_addr_cmd
);
10100 install_element (INTERFACE_NODE
, &no_ip_ospf_message_digest_key_cmd
);
10101 install_element (INTERFACE_NODE
, &no_ip_ospf_message_digest_key_md5_addr_cmd
);
10102 install_element (INTERFACE_NODE
, &no_ip_ospf_message_digest_key_md5_cmd
);
10104 /* "ip ospf cost" commands. */
10105 install_element (INTERFACE_NODE
, &ip_ospf_cost_u32_inet4_cmd
);
10106 install_element (INTERFACE_NODE
, &ip_ospf_cost_u32_cmd
);
10107 install_element (INTERFACE_NODE
, &no_ip_ospf_cost_u32_cmd
);
10108 install_element (INTERFACE_NODE
, &no_ip_ospf_cost_u32_inet4_cmd
);
10109 install_element (INTERFACE_NODE
, &no_ip_ospf_cost_inet4_cmd
);
10110 install_element (INTERFACE_NODE
, &no_ip_ospf_cost_cmd
);
10112 /* "ip ospf mtu-ignore" commands. */
10113 install_element (INTERFACE_NODE
, &ip_ospf_mtu_ignore_addr_cmd
);
10114 install_element (INTERFACE_NODE
, &ip_ospf_mtu_ignore_cmd
);
10115 install_element (INTERFACE_NODE
, &no_ip_ospf_mtu_ignore_addr_cmd
);
10116 install_element (INTERFACE_NODE
, &no_ip_ospf_mtu_ignore_cmd
);
10118 /* "ip ospf dead-interval" commands. */
10119 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_addr_cmd
);
10120 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_cmd
);
10121 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_minimal_addr_cmd
);
10122 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_minimal_cmd
);
10123 install_element (INTERFACE_NODE
, &no_ip_ospf_dead_interval_addr_cmd
);
10124 install_element (INTERFACE_NODE
, &no_ip_ospf_dead_interval_cmd
);
10125 install_element (INTERFACE_NODE
, &no_ip_ospf_dead_interval_seconds_cmd
);
10127 /* "ip ospf hello-interval" commands. */
10128 install_element (INTERFACE_NODE
, &ip_ospf_hello_interval_addr_cmd
);
10129 install_element (INTERFACE_NODE
, &ip_ospf_hello_interval_cmd
);
10130 install_element (INTERFACE_NODE
, &no_ip_ospf_hello_interval_addr_cmd
);
10131 install_element (INTERFACE_NODE
, &no_ip_ospf_hello_interval_cmd
);
10132 install_element (INTERFACE_NODE
, &no_ip_ospf_hello_interval_seconds_cmd
);
10134 /* "ip ospf network" commands. */
10135 install_element (INTERFACE_NODE
, &ip_ospf_network_cmd
);
10136 install_element (INTERFACE_NODE
, &no_ip_ospf_network_cmd
);
10137 install_element (INTERFACE_NODE
, &no_ip_ospf_network_val_cmd
);
10139 /* "ip ospf priority" commands. */
10140 install_element (INTERFACE_NODE
, &ip_ospf_priority_addr_cmd
);
10141 install_element (INTERFACE_NODE
, &ip_ospf_priority_cmd
);
10142 install_element (INTERFACE_NODE
, &no_ip_ospf_priority_cmd
);
10143 install_element (INTERFACE_NODE
, &no_ip_ospf_priority_no_param_cmd
);
10144 install_element (INTERFACE_NODE
, &no_ip_ospf_priority_addr_cmd
);
10146 /* "ip ospf retransmit-interval" commands. */
10147 install_element (INTERFACE_NODE
, &ip_ospf_retransmit_interval_addr_cmd
);
10148 install_element (INTERFACE_NODE
, &ip_ospf_retransmit_interval_cmd
);
10149 install_element (INTERFACE_NODE
, &no_ip_ospf_retransmit_interval_addr_cmd
);
10150 install_element (INTERFACE_NODE
, &no_ip_ospf_retransmit_interval_cmd
);
10151 install_element (INTERFACE_NODE
, &no_ip_ospf_retransmit_interval_sec_addr_cmd
);
10152 install_element (INTERFACE_NODE
, &no_ip_ospf_retransmit_interval_sec_cmd
);
10154 /* "ip ospf transmit-delay" commands. */
10155 install_element (INTERFACE_NODE
, &ip_ospf_transmit_delay_addr_cmd
);
10156 install_element (INTERFACE_NODE
, &ip_ospf_transmit_delay_cmd
);
10157 install_element (INTERFACE_NODE
, &no_ip_ospf_transmit_delay_addr_cmd
);
10158 install_element (INTERFACE_NODE
, &no_ip_ospf_transmit_delay_cmd
);
10159 install_element (INTERFACE_NODE
, &no_ip_ospf_transmit_delay_sec_addr_cmd
);
10160 install_element (INTERFACE_NODE
, &no_ip_ospf_transmit_delay_sec_cmd
);
10162 /* "ip ospf area" commands. */
10163 install_element (INTERFACE_NODE
, &ip_ospf_area_cmd
);
10164 install_element (INTERFACE_NODE
, &no_ip_ospf_area_cmd
);
10165 install_element (INTERFACE_NODE
, &no_ip_ospf_area_val_cmd
);
10166 install_element (INTERFACE_NODE
, &ip_ospf_instance_area_cmd
);
10167 install_element (INTERFACE_NODE
, &no_ip_ospf_instance_area_cmd
);
10168 install_element (INTERFACE_NODE
, &no_ip_ospf_instance_area_val_cmd
);
10170 /* These commands are compatibitliy for previous version. */
10171 install_element (INTERFACE_NODE
, &ospf_authentication_key_cmd
);
10172 install_element (INTERFACE_NODE
, &no_ospf_authentication_key_cmd
);
10173 install_element (INTERFACE_NODE
, &no_ospf_authentication_key_authkey_cmd
);
10174 install_element (INTERFACE_NODE
, &no_ospf_authentication_key_authkey_ip_cmd
);
10175 install_element (INTERFACE_NODE
, &ospf_message_digest_key_cmd
);
10176 install_element (INTERFACE_NODE
, &no_ospf_message_digest_key_cmd
);
10177 install_element (INTERFACE_NODE
, &ospf_cost_u32_cmd
);
10178 install_element (INTERFACE_NODE
, &ospf_cost_u32_inet4_cmd
);
10179 install_element (INTERFACE_NODE
, &no_ospf_cost_cmd
);
10180 install_element (INTERFACE_NODE
, &no_ospf_cost_u32_cmd
);
10181 install_element (INTERFACE_NODE
, &no_ospf_cost_u32_inet4_cmd
);
10182 install_element (INTERFACE_NODE
, &no_ospf_cost_inet4_cmd
);
10183 install_element (INTERFACE_NODE
, &ospf_dead_interval_cmd
);
10184 install_element (INTERFACE_NODE
, &no_ospf_dead_interval_cmd
);
10185 install_element (INTERFACE_NODE
, &no_ip_ospf_dead_interval_minimal_addr_cmd
);
10186 install_element (INTERFACE_NODE
, &no_ip_ospf_dead_interval_minimal_cmd
);
10187 install_element (INTERFACE_NODE
, &ospf_hello_interval_cmd
);
10188 install_element (INTERFACE_NODE
, &no_ospf_hello_interval_cmd
);
10189 install_element (INTERFACE_NODE
, &ospf_network_cmd
);
10190 install_element (INTERFACE_NODE
, &no_ospf_network_cmd
);
10191 install_element (INTERFACE_NODE
, &no_ospf_network_val_cmd
);
10192 install_element (INTERFACE_NODE
, &ospf_priority_cmd
);
10193 install_element (INTERFACE_NODE
, &no_ospf_priority_cmd
);
10194 install_element (INTERFACE_NODE
, &ospf_retransmit_interval_cmd
);
10195 install_element (INTERFACE_NODE
, &no_ospf_retransmit_interval_cmd
);
10196 install_element (INTERFACE_NODE
, &ospf_transmit_delay_cmd
);
10197 install_element (INTERFACE_NODE
, &no_ospf_transmit_delay_cmd
);
10201 ospf_vty_zebra_init (void)
10203 install_element (OSPF_NODE
, &ospf_redistribute_source_cmd
);
10204 install_element (OSPF_NODE
, &no_ospf_redistribute_source_cmd
);
10205 install_element (OSPF_NODE
, &ospf_redistribute_instance_source_cmd
);
10206 install_element (OSPF_NODE
, &no_ospf_redistribute_instance_source_cmd
);
10208 install_element (OSPF_NODE
, &ospf_distribute_list_out_cmd
);
10209 install_element (OSPF_NODE
, &no_ospf_distribute_list_out_cmd
);
10211 install_element (OSPF_NODE
, &ospf_default_information_originate_cmd
);
10212 install_element (OSPF_NODE
, &no_ospf_default_information_originate_cmd
);
10214 install_element (OSPF_NODE
, &ospf_default_metric_cmd
);
10215 install_element (OSPF_NODE
, &no_ospf_default_metric_cmd
);
10216 install_element (OSPF_NODE
, &no_ospf_default_metric_val_cmd
);
10218 install_element (OSPF_NODE
, &ospf_distance_cmd
);
10219 install_element (OSPF_NODE
, &no_ospf_distance_cmd
);
10220 install_element (OSPF_NODE
, &no_ospf_distance_ospf_cmd
);
10221 install_element (OSPF_NODE
, &ospf_distance_ospf_cmd
);
10223 install_element (OSPF_NODE
, &ospf_distance_source_cmd
);
10224 install_element (OSPF_NODE
, &no_ospf_distance_source_cmd
);
10225 install_element (OSPF_NODE
, &ospf_distance_source_access_list_cmd
);
10226 install_element (OSPF_NODE
, &no_ospf_distance_source_access_list_cmd
);
10230 static struct cmd_node ospf_node
=
10233 "%s(config-router)# ",
10238 ospf_interface_clear (struct interface
*ifp
)
10240 if (!if_is_operative (ifp
)) return;
10242 if (IS_DEBUG_OSPF (ism
, ISM_EVENTS
))
10243 zlog (NULL
, LOG_DEBUG
, "ISM[%s]: clear by reset", ifp
->name
);
10245 ospf_if_reset(ifp
);
10248 DEFUN (clear_ip_ospf_interface
,
10249 clear_ip_ospf_interface_cmd
,
10250 "clear ip ospf interface [IFNAME]",
10253 "OSPF information\n"
10254 "Interface information\n"
10255 "Interface name\n")
10257 struct interface
*ifp
;
10258 struct listnode
*node
;
10260 if (argc
== 0) /* Clear all the ospfv2 interfaces. */
10262 for (ALL_LIST_ELEMENTS_RO (iflist
, node
, ifp
))
10263 ospf_interface_clear(ifp
);
10265 else /* Interface name is specified. */
10267 if ((ifp
= if_lookup_by_name (argv
[0])) == NULL
)
10268 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
10270 ospf_interface_clear(ifp
);
10273 return CMD_SUCCESS
;
10277 ospf_vty_clear_init (void)
10279 install_element (ENABLE_NODE
, &clear_ip_ospf_interface_cmd
);
10283 /* Install OSPF related vty commands. */
10285 ospf_vty_init (void)
10287 /* Install ospf top node. */
10288 install_node (&ospf_node
, ospf_config_write
);
10290 /* "router ospf" commands. */
10291 install_element (CONFIG_NODE
, &router_ospf_cmd
);
10292 install_element (CONFIG_NODE
, &no_router_ospf_cmd
);
10294 install_element (CONFIG_NODE
, &router_ospf_instance_cmd
);
10295 install_element (CONFIG_NODE
, &no_router_ospf_instance_cmd
);
10297 install_default (OSPF_NODE
);
10299 /* "ospf router-id" commands. */
10300 install_element (OSPF_NODE
, &ospf_router_id_cmd
);
10301 install_element (OSPF_NODE
, &ospf_router_id_old_cmd
);
10302 install_element (OSPF_NODE
, &no_ospf_router_id_cmd
);
10303 install_element (OSPF_NODE
, &no_ospf_router_id_val_cmd
);
10305 /* "passive-interface" commands. */
10306 install_element (OSPF_NODE
, &ospf_passive_interface_addr_cmd
);
10307 install_element (OSPF_NODE
, &ospf_passive_interface_cmd
);
10308 install_element (OSPF_NODE
, &ospf_passive_interface_default_cmd
);
10309 install_element (OSPF_NODE
, &no_ospf_passive_interface_addr_cmd
);
10310 install_element (OSPF_NODE
, &no_ospf_passive_interface_cmd
);
10311 install_element (OSPF_NODE
, &no_ospf_passive_interface_default_cmd
);
10313 /* "ospf abr-type" commands. */
10314 install_element (OSPF_NODE
, &ospf_abr_type_cmd
);
10315 install_element (OSPF_NODE
, &no_ospf_abr_type_cmd
);
10317 /* "ospf log-adjacency-changes" commands. */
10318 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_cmd
);
10319 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_detail_cmd
);
10320 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_cmd
);
10321 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_detail_cmd
);
10323 /* "ospf rfc1583-compatible" commands. */
10324 install_element (OSPF_NODE
, &ospf_rfc1583_flag_cmd
);
10325 install_element (OSPF_NODE
, &no_ospf_rfc1583_flag_cmd
);
10326 install_element (OSPF_NODE
, &ospf_compatible_rfc1583_cmd
);
10327 install_element (OSPF_NODE
, &no_ospf_compatible_rfc1583_cmd
);
10329 /* "network area" commands. */
10330 install_element (OSPF_NODE
, &ospf_network_area_cmd
);
10331 install_element (OSPF_NODE
, &no_ospf_network_area_cmd
);
10333 /* "area authentication" commands. */
10334 install_element (OSPF_NODE
, &ospf_area_authentication_message_digest_cmd
);
10335 install_element (OSPF_NODE
, &ospf_area_authentication_cmd
);
10336 install_element (OSPF_NODE
, &no_ospf_area_authentication_cmd
);
10338 /* "area range" commands. */
10339 install_element (OSPF_NODE
, &ospf_area_range_cmd
);
10340 install_element (OSPF_NODE
, &ospf_area_range_advertise_cmd
);
10341 install_element (OSPF_NODE
, &ospf_area_range_cost_cmd
);
10342 install_element (OSPF_NODE
, &ospf_area_range_advertise_cost_cmd
);
10343 install_element (OSPF_NODE
, &ospf_area_range_not_advertise_cmd
);
10344 install_element (OSPF_NODE
, &no_ospf_area_range_cmd
);
10345 install_element (OSPF_NODE
, &no_ospf_area_range_advertise_cmd
);
10346 install_element (OSPF_NODE
, &no_ospf_area_range_cost_cmd
);
10347 install_element (OSPF_NODE
, &no_ospf_area_range_advertise_cost_cmd
);
10348 install_element (OSPF_NODE
, &ospf_area_range_substitute_cmd
);
10349 install_element (OSPF_NODE
, &no_ospf_area_range_substitute_cmd
);
10351 /* "area virtual-link" commands. */
10352 install_element (OSPF_NODE
, &ospf_area_vlink_cmd
);
10353 install_element (OSPF_NODE
, &no_ospf_area_vlink_cmd
);
10355 install_element (OSPF_NODE
, &ospf_area_vlink_param1_cmd
);
10356 install_element (OSPF_NODE
, &no_ospf_area_vlink_param1_cmd
);
10358 install_element (OSPF_NODE
, &ospf_area_vlink_param2_cmd
);
10359 install_element (OSPF_NODE
, &no_ospf_area_vlink_param2_cmd
);
10361 install_element (OSPF_NODE
, &ospf_area_vlink_param3_cmd
);
10362 install_element (OSPF_NODE
, &no_ospf_area_vlink_param3_cmd
);
10364 install_element (OSPF_NODE
, &ospf_area_vlink_param4_cmd
);
10365 install_element (OSPF_NODE
, &no_ospf_area_vlink_param4_cmd
);
10367 install_element (OSPF_NODE
, &ospf_area_vlink_authtype_args_cmd
);
10368 install_element (OSPF_NODE
, &no_ospf_area_vlink_authtype_args_cmd
);
10369 install_element (OSPF_NODE
, &ospf_area_vlink_authtype_cmd
);
10370 install_element (OSPF_NODE
, &no_ospf_area_vlink_authtype_cmd
);
10372 install_element (OSPF_NODE
, &ospf_area_vlink_md5_cmd
);
10373 install_element (OSPF_NODE
, &no_ospf_area_vlink_md5_cmd
);
10375 install_element (OSPF_NODE
, &ospf_area_vlink_authkey_cmd
);
10376 install_element (OSPF_NODE
, &no_ospf_area_vlink_authkey_cmd
);
10378 install_element (OSPF_NODE
, &ospf_area_vlink_authtype_args_authkey_cmd
);
10379 install_element (OSPF_NODE
, &no_ospf_area_vlink_authtype_args_authkey_cmd
);
10380 install_element (OSPF_NODE
, &ospf_area_vlink_authtype_authkey_cmd
);
10381 install_element (OSPF_NODE
, &no_ospf_area_vlink_authtype_authkey_cmd
);
10383 install_element (OSPF_NODE
, &ospf_area_vlink_authtype_args_md5_cmd
);
10384 install_element (OSPF_NODE
, &no_ospf_area_vlink_authtype_args_md5_cmd
);
10385 install_element (OSPF_NODE
, &ospf_area_vlink_authtype_md5_cmd
);
10386 install_element (OSPF_NODE
, &no_ospf_area_vlink_authtype_md5_cmd
);
10388 /* "area stub" commands. */
10389 install_element (OSPF_NODE
, &ospf_area_stub_no_summary_cmd
);
10390 install_element (OSPF_NODE
, &ospf_area_stub_cmd
);
10391 install_element (OSPF_NODE
, &no_ospf_area_stub_no_summary_cmd
);
10392 install_element (OSPF_NODE
, &no_ospf_area_stub_cmd
);
10394 /* "area nssa" commands. */
10395 install_element (OSPF_NODE
, &ospf_area_nssa_cmd
);
10396 install_element (OSPF_NODE
, &ospf_area_nssa_translate_no_summary_cmd
);
10397 install_element (OSPF_NODE
, &ospf_area_nssa_translate_cmd
);
10398 install_element (OSPF_NODE
, &ospf_area_nssa_no_summary_cmd
);
10399 install_element (OSPF_NODE
, &no_ospf_area_nssa_cmd
);
10400 install_element (OSPF_NODE
, &no_ospf_area_nssa_no_summary_cmd
);
10402 install_element (OSPF_NODE
, &ospf_area_default_cost_cmd
);
10403 install_element (OSPF_NODE
, &no_ospf_area_default_cost_cmd
);
10405 install_element (OSPF_NODE
, &ospf_area_shortcut_cmd
);
10406 install_element (OSPF_NODE
, &no_ospf_area_shortcut_cmd
);
10408 install_element (OSPF_NODE
, &ospf_area_export_list_cmd
);
10409 install_element (OSPF_NODE
, &no_ospf_area_export_list_cmd
);
10411 install_element (OSPF_NODE
, &ospf_area_filter_list_cmd
);
10412 install_element (OSPF_NODE
, &no_ospf_area_filter_list_cmd
);
10414 install_element (OSPF_NODE
, &ospf_area_import_list_cmd
);
10415 install_element (OSPF_NODE
, &no_ospf_area_import_list_cmd
);
10417 /* SPF timer commands */
10418 install_element (OSPF_NODE
, &ospf_timers_throttle_spf_cmd
);
10419 install_element (OSPF_NODE
, &no_ospf_timers_throttle_spf_cmd
);
10420 install_element (OSPF_NODE
, &no_ospf_timers_throttle_spf_val_cmd
);
10422 /* LSA timers commands */
10423 install_element (OSPF_NODE
, &ospf_timers_min_ls_interval_cmd
);
10424 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_interval_cmd
);
10425 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_interval_val_cmd
);
10426 install_element (OSPF_NODE
, &ospf_timers_min_ls_arrival_cmd
);
10427 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_arrival_cmd
);
10428 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_arrival_val_cmd
);
10429 install_element (OSPF_NODE
, &ospf_timers_lsa_cmd
);
10430 install_element (OSPF_NODE
, &no_ospf_timers_lsa_cmd
);
10431 install_element (OSPF_NODE
, &no_ospf_timers_lsa_val_cmd
);
10433 /* refresh timer commands */
10434 install_element (OSPF_NODE
, &ospf_refresh_timer_cmd
);
10435 install_element (OSPF_NODE
, &no_ospf_refresh_timer_val_cmd
);
10436 install_element (OSPF_NODE
, &no_ospf_refresh_timer_cmd
);
10438 /* max-metric commands */
10439 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_admin_cmd
);
10440 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_admin_cmd
);
10441 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_startup_cmd
);
10442 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_startup_cmd
);
10443 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_startup_no_param_cmd
);
10444 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_shutdown_cmd
);
10445 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_shutdown_cmd
);
10446 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_shutdown_no_param_cmd
);
10448 /* reference bandwidth commands */
10449 install_element (OSPF_NODE
, &ospf_auto_cost_reference_bandwidth_cmd
);
10450 install_element (OSPF_NODE
, &no_ospf_auto_cost_reference_bandwidth_cmd
);
10451 install_element (OSPF_NODE
, &no_ospf_auto_cost_reference_bandwidth_val_cmd
);
10453 /* "neighbor" commands. */
10454 install_element (OSPF_NODE
, &ospf_neighbor_cmd
);
10455 install_element (OSPF_NODE
, &ospf_neighbor_priority_poll_interval_cmd
);
10456 install_element (OSPF_NODE
, &ospf_neighbor_priority_cmd
);
10457 install_element (OSPF_NODE
, &ospf_neighbor_poll_interval_cmd
);
10458 install_element (OSPF_NODE
, &ospf_neighbor_poll_interval_priority_cmd
);
10459 install_element (OSPF_NODE
, &no_ospf_neighbor_cmd
);
10460 install_element (OSPF_NODE
, &no_ospf_neighbor_priority_cmd
);
10461 install_element (OSPF_NODE
, &no_ospf_neighbor_poll_interval_cmd
);
10462 install_element (OSPF_NODE
, &no_ospf_neighbor_poll_interval_priority_cmd
);
10463 install_element (OSPF_NODE
, &no_ospf_neighbor_priority_pollinterval_cmd
);
10465 /* write multiplier commands */
10466 install_element (OSPF_NODE
, &ospf_write_multiplier_cmd
);
10467 install_element (OSPF_NODE
, &no_ospf_write_multiplier_cmd
);
10468 install_element (OSPF_NODE
, &write_multiplier_cmd
);
10469 install_element (OSPF_NODE
, &no_write_multiplier_cmd
);
10470 install_element (OSPF_NODE
, &no_write_multiplier_val_cmd
);
10472 /* Init interface related vty commands. */
10473 ospf_vty_if_init ();
10475 /* Init zebra related vty commands. */
10476 ospf_vty_zebra_init ();