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_addr (struct ospf
*ospf
, struct interface
*ifp
,
327 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
);
351 ospf_passive_interface_update (struct ospf
*ospf
, struct interface
*ifp
,
352 struct ospf_if_params
*params
, u_char value
)
354 params
->passive_interface
= value
;
355 if (params
== IF_DEF_PARAMS (ifp
))
357 if (value
!= ospf
->passive_interface_default
)
358 SET_IF_PARAM (params
, passive_interface
);
360 UNSET_IF_PARAM (params
, passive_interface
);
364 DEFUN (ospf_passive_interface
,
365 ospf_passive_interface_addr_cmd
,
366 "passive-interface IFNAME A.B.C.D",
367 "Suppress routing updates on an interface\n"
368 "Interface's name\n")
370 struct interface
*ifp
;
371 struct in_addr addr
= { .s_addr
= INADDR_ANY
};
373 struct ospf_if_params
*params
;
374 struct route_node
*rn
;
375 struct ospf
*ospf
= vty
->index
;
382 ospf_passive_interface_default (ospf
, OSPF_IF_PASSIVE
);
386 ifp
= if_get_by_name (argv
[0]);
388 params
= IF_DEF_PARAMS (ifp
);
392 ret
= inet_aton(argv
[1], &addr
);
395 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
400 params
= ospf_get_if_params (ifp
, addr
);
401 ospf_if_update_params (ifp
, addr
);
402 ospf_passive_interface_update_addr (ospf
, ifp
, params
,
403 OSPF_IF_PASSIVE
, addr
);
406 ospf_passive_interface_update (ospf
, ifp
, params
, OSPF_IF_PASSIVE
);
408 /* XXX We should call ospf_if_set_multicast on exactly those
409 * interfaces for which the passive property changed. It is too much
410 * work to determine this set, so we do this for every interface.
411 * This is safe and reasonable because ospf_if_set_multicast uses a
412 * record of joined groups to avoid systems calls if the desired
413 * memberships match the current memership.
416 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next (rn
))
418 struct ospf_interface
*oi
= rn
->info
;
420 if (oi
&& (OSPF_IF_PARAM(oi
, passive_interface
) == OSPF_IF_PASSIVE
))
421 ospf_if_set_multicast(oi
);
424 * XXX It is not clear what state transitions the interface needs to
425 * undergo when going from active to passive. Fixing this will
426 * require precise identification of interfaces having such a
433 ALIAS (ospf_passive_interface
,
434 ospf_passive_interface_cmd
,
435 "passive-interface IFNAME",
436 "Suppress routing updates on an interface\n"
437 "Interface's name\n")
439 ALIAS (ospf_passive_interface
,
440 ospf_passive_interface_default_cmd
,
441 "passive-interface default",
442 "Suppress routing updates on an interface\n"
443 "Suppress routing updates on interfaces by default\n")
445 DEFUN (no_ospf_passive_interface
,
446 no_ospf_passive_interface_addr_cmd
,
447 "no passive-interface IFNAME A.B.C.D",
449 "Allow routing updates on an interface\n"
450 "Interface's name\n")
452 struct interface
*ifp
;
453 struct in_addr addr
= { .s_addr
= INADDR_ANY
};
454 struct ospf_if_params
*params
;
456 struct route_node
*rn
;
457 struct ospf
*ospf
= vty
->index
;
464 ospf_passive_interface_default (ospf
, OSPF_IF_ACTIVE
);
468 ifp
= if_get_by_name (argv
[0]);
470 params
= IF_DEF_PARAMS (ifp
);
474 ret
= inet_aton(argv
[1], &addr
);
477 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
482 params
= ospf_lookup_if_params (ifp
, addr
);
485 ospf_passive_interface_update_addr (ospf
, ifp
, params
, OSPF_IF_ACTIVE
,
488 ospf_passive_interface_update (ospf
, ifp
, params
, OSPF_IF_ACTIVE
);
490 /* XXX We should call ospf_if_set_multicast on exactly those
491 * interfaces for which the passive property changed. It is too much
492 * work to determine this set, so we do this for every interface.
493 * This is safe and reasonable because ospf_if_set_multicast uses a
494 * record of joined groups to avoid systems calls if the desired
495 * memberships match the current memership.
497 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next (rn
))
499 struct ospf_interface
*oi
= rn
->info
;
501 if (oi
&& (OSPF_IF_PARAM(oi
, passive_interface
) == OSPF_IF_ACTIVE
))
502 ospf_if_set_multicast(oi
);
508 ALIAS (no_ospf_passive_interface
,
509 no_ospf_passive_interface_cmd
,
510 "no passive-interface IFNAME",
512 "Allow routing updates on an interface\n"
513 "Interface's name\n")
515 ALIAS (no_ospf_passive_interface
,
516 no_ospf_passive_interface_default_cmd
,
517 "no passive-interface default",
519 "Allow routing updates on an interface\n"
520 "Allow routing updates on interfaces by default\n")
522 DEFUN (ospf_network_area
,
523 ospf_network_area_cmd
,
524 "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
525 "Enable routing on an IP network\n"
526 "OSPF network prefix\n"
527 "Set the OSPF area ID\n"
528 "OSPF area ID in IP address format\n"
529 "OSPF area ID as a decimal value\n")
531 struct ospf
*ospf
= vty
->index
;
532 struct prefix_ipv4 p
;
533 struct in_addr area_id
;
541 vty_out (vty
, "The network command is not supported in multi-instance ospf%s",
546 if (ospf
->if_ospf_cli_count
> 0)
548 vty_out (vty
, "Please remove all ip ospf area x.x.x.x commands first.%s",
553 /* Get network prefix and Area ID. */
554 VTY_GET_IPV4_PREFIX ("network prefix", p
, argv
[0]);
555 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[1]);
557 ret
= ospf_network_set (ospf
, &p
, area_id
);
560 vty_out (vty
, "There is already same network statement.%s", VTY_NEWLINE
);
567 DEFUN (no_ospf_network_area
,
568 no_ospf_network_area_cmd
,
569 "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
571 "Enable routing on an IP network\n"
572 "OSPF network prefix\n"
573 "Set the OSPF area ID\n"
574 "OSPF area ID in IP address format\n"
575 "OSPF area ID as a decimal value\n")
577 struct ospf
*ospf
= (struct ospf
*) vty
->index
;
578 struct prefix_ipv4 p
;
579 struct in_addr area_id
;
587 vty_out (vty
, "The network command is not supported in multi-instance ospf%s",
592 /* Get network prefix and Area ID. */
593 VTY_GET_IPV4_PREFIX ("network prefix", p
, argv
[0]);
594 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[1]);
596 ret
= ospf_network_unset (ospf
, &p
, area_id
);
599 vty_out (vty
, "Can't find specified network area configuration.%s",
608 DEFUN (ospf_area_range
,
610 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
611 "OSPF area parameters\n"
612 "OSPF area ID in IP address format\n"
613 "OSPF area ID as a decimal value\n"
614 "Summarize routes matching address/mask (border routers only)\n"
615 "Area range prefix\n")
617 struct ospf
*ospf
= vty
->index
;
618 struct prefix_ipv4 p
;
619 struct in_addr area_id
;
626 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
627 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[1]);
629 ospf_area_range_set (ospf
, area_id
, &p
, OSPF_AREA_RANGE_ADVERTISE
);
632 VTY_GET_INTEGER ("range cost", cost
, argv
[2]);
633 ospf_area_range_cost_set (ospf
, area_id
, &p
, cost
);
639 ALIAS (ospf_area_range
,
640 ospf_area_range_advertise_cmd
,
641 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise",
642 "OSPF area parameters\n"
643 "OSPF area ID in IP address format\n"
644 "OSPF area ID as a decimal value\n"
645 "OSPF area range for route advertise (default)\n"
646 "Area range prefix\n"
647 "Advertise this range (default)\n")
649 ALIAS (ospf_area_range
,
650 ospf_area_range_cost_cmd
,
651 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
652 "OSPF area parameters\n"
653 "OSPF area ID in IP address format\n"
654 "OSPF area ID as a decimal value\n"
655 "Summarize routes matching address/mask (border routers only)\n"
656 "Area range prefix\n"
657 "User specified metric for this range\n"
658 "Advertised metric for this range\n")
660 ALIAS (ospf_area_range
,
661 ospf_area_range_advertise_cost_cmd
,
662 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
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 "Advertise this range (default)\n"
669 "User specified metric for this range\n"
670 "Advertised metric for this range\n")
672 DEFUN (ospf_area_range_not_advertise
,
673 ospf_area_range_not_advertise_cmd
,
674 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise",
675 "OSPF area parameters\n"
676 "OSPF area ID in IP address format\n"
677 "OSPF area ID as a decimal value\n"
678 "Summarize routes matching address/mask (border routers only)\n"
679 "Area range prefix\n"
680 "DoNotAdvertise this range\n")
682 struct ospf
*ospf
= vty
->index
;
683 struct prefix_ipv4 p
;
684 struct in_addr area_id
;
690 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
691 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[1]);
693 ospf_area_range_set (ospf
, area_id
, &p
, 0);
698 DEFUN (no_ospf_area_range
,
699 no_ospf_area_range_cmd
,
700 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
702 "OSPF area parameters\n"
703 "OSPF area ID in IP address format\n"
704 "OSPF area ID as a decimal value\n"
705 "Summarize routes matching address/mask (border routers only)\n"
706 "Area range prefix\n")
708 struct ospf
*ospf
= vty
->index
;
709 struct prefix_ipv4 p
;
710 struct in_addr area_id
;
716 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
717 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[1]);
719 ospf_area_range_unset (ospf
, area_id
, &p
);
724 ALIAS (no_ospf_area_range
,
725 no_ospf_area_range_advertise_cmd
,
726 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)",
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 "Advertise this range (default)\n"
734 "DoNotAdvertise this range\n")
736 ALIAS (no_ospf_area_range
,
737 no_ospf_area_range_cost_cmd
,
738 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M 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 "User specified metric for this range\n"
746 "Advertised metric for this range\n")
748 ALIAS (no_ospf_area_range
,
749 no_ospf_area_range_advertise_cost_cmd
,
750 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
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 "Advertise this range (default)\n"
758 "User specified metric for this range\n"
759 "Advertised metric for this range\n")
761 DEFUN (ospf_area_range_substitute
,
762 ospf_area_range_substitute_cmd
,
763 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
764 "OSPF area parameters\n"
765 "OSPF area ID in IP address format\n"
766 "OSPF area ID as a decimal value\n"
767 "Summarize routes matching address/mask (border routers only)\n"
768 "Area range prefix\n"
769 "Announce area range as another prefix\n"
770 "Network prefix to be announced instead of range\n")
772 struct ospf
*ospf
= vty
->index
;
773 struct prefix_ipv4 p
, s
;
774 struct in_addr area_id
;
780 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
781 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[1]);
782 VTY_GET_IPV4_PREFIX ("substituted network prefix", s
, argv
[2]);
784 ospf_area_range_substitute_set (ospf
, area_id
, &p
, &s
);
789 DEFUN (no_ospf_area_range_substitute
,
790 no_ospf_area_range_substitute_cmd
,
791 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
793 "OSPF area parameters\n"
794 "OSPF area ID in IP address format\n"
795 "OSPF area ID as a decimal value\n"
796 "Summarize routes matching address/mask (border routers only)\n"
797 "Area range prefix\n"
798 "Announce area range as another prefix\n"
799 "Network prefix to be announced instead of range\n")
801 struct ospf
*ospf
= vty
->index
;
802 struct prefix_ipv4 p
, s
;
803 struct in_addr area_id
;
809 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
810 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[1]);
811 VTY_GET_IPV4_PREFIX ("substituted network prefix", s
, argv
[2]);
813 ospf_area_range_substitute_unset (ospf
, area_id
, &p
);
819 /* Command Handler Logic in VLink stuff is delicate!!
821 ALTER AT YOUR OWN RISK!!!!
823 Various dummy values are used to represent 'NoChange' state for
824 VLink configuration NOT being changed by a VLink command, and
825 special syntax is used within the command strings so that the
826 typed in command verbs can be seen in the configuration command
827 bacckend handler. This is to drastically reduce the verbeage
828 required to coe up with a reasonably compatible Cisco VLink command
830 - Matthew Grant <grantma@anathoth.gen.nz>
831 Wed, 21 Feb 2001 15:13:52 +1300
835 /* Configuration data for virtual links
837 struct ospf_vl_config_data
{
838 struct vty
*vty
; /* vty stuff */
839 struct in_addr area_id
; /* area ID from command line */
840 int format
; /* command line area ID format */
841 struct in_addr vl_peer
; /* command line vl_peer */
842 int auth_type
; /* Authehntication type, if given */
843 char *auth_key
; /* simple password if present */
844 int crypto_key_id
; /* Cryptographic key ID */
845 char *md5_key
; /* MD5 authentication key */
846 int hello_interval
; /* Obvious what these are... */
847 int retransmit_interval
;
853 ospf_vl_config_data_init (struct ospf_vl_config_data
*vl_config
,
856 memset (vl_config
, 0, sizeof (struct ospf_vl_config_data
));
857 vl_config
->auth_type
= OSPF_AUTH_CMD_NOTSEEN
;
858 vl_config
->vty
= vty
;
861 static struct ospf_vl_data
*
862 ospf_find_vl_data (struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
864 struct ospf_area
*area
;
865 struct ospf_vl_data
*vl_data
;
867 struct in_addr area_id
;
869 vty
= vl_config
->vty
;
870 area_id
= vl_config
->area_id
;
872 if (area_id
.s_addr
== OSPF_AREA_BACKBONE
)
875 "Configuring VLs over the backbone is not allowed%s",
879 area
= ospf_area_get (ospf
, area_id
, vl_config
->format
);
881 if (area
->external_routing
!= OSPF_AREA_DEFAULT
)
883 if (vl_config
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
884 vty_out (vty
, "Area %s is %s%s",
886 area
->external_routing
== OSPF_AREA_NSSA
?"nssa":"stub",
889 vty_out (vty
, "Area %ld is %s%s",
890 (u_long
)ntohl (area_id
.s_addr
),
891 area
->external_routing
== OSPF_AREA_NSSA
?"nssa":"stub",
896 if ((vl_data
= ospf_vl_lookup (ospf
, area
, vl_config
->vl_peer
)) == NULL
)
898 vl_data
= ospf_vl_data_new (area
, vl_config
->vl_peer
);
899 if (vl_data
->vl_oi
== NULL
)
901 vl_data
->vl_oi
= ospf_vl_new (ospf
, vl_data
);
902 ospf_vl_add (ospf
, vl_data
);
903 ospf_spf_calculate_schedule (ospf
, SPF_FLAG_CONFIG_CHANGE
);
911 ospf_vl_set_security (struct ospf_vl_data
*vl_data
,
912 struct ospf_vl_config_data
*vl_config
)
914 struct crypt_key
*ck
;
916 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
918 vty
= vl_config
->vty
;
920 if (vl_config
->auth_type
!= OSPF_AUTH_CMD_NOTSEEN
)
922 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), auth_type
);
923 IF_DEF_PARAMS (ifp
)->auth_type
= vl_config
->auth_type
;
926 if (vl_config
->auth_key
)
928 memset(IF_DEF_PARAMS (ifp
)->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+1);
929 strncpy ((char *) IF_DEF_PARAMS (ifp
)->auth_simple
, vl_config
->auth_key
,
930 OSPF_AUTH_SIMPLE_SIZE
);
932 else if (vl_config
->md5_key
)
934 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp
)->auth_crypt
, vl_config
->crypto_key_id
)
937 vty_out (vty
, "OSPF: Key %d already exists%s",
938 vl_config
->crypto_key_id
, VTY_NEWLINE
);
941 ck
= ospf_crypt_key_new ();
942 ck
->key_id
= vl_config
->crypto_key_id
;
943 memset(ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
944 strncpy ((char *) ck
->auth_key
, vl_config
->md5_key
, OSPF_AUTH_MD5_SIZE
);
946 ospf_crypt_key_add (IF_DEF_PARAMS (ifp
)->auth_crypt
, ck
);
948 else if (vl_config
->crypto_key_id
!= 0)
952 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp
)->auth_crypt
,
953 vl_config
->crypto_key_id
) == NULL
)
955 vty_out (vty
, "OSPF: Key %d does not exist%s",
956 vl_config
->crypto_key_id
, VTY_NEWLINE
);
960 ospf_crypt_key_delete (IF_DEF_PARAMS (ifp
)->auth_crypt
, vl_config
->crypto_key_id
);
968 ospf_vl_set_timers (struct ospf_vl_data
*vl_data
,
969 struct ospf_vl_config_data
*vl_config
)
971 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
972 /* Virtual Link data initialised to defaults, so only set
974 if (vl_config
->hello_interval
)
976 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), v_hello
);
977 IF_DEF_PARAMS (ifp
)->v_hello
= vl_config
->hello_interval
;
980 if (vl_config
->dead_interval
)
982 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), v_wait
);
983 IF_DEF_PARAMS (ifp
)->v_wait
= vl_config
->dead_interval
;
986 if (vl_config
->retransmit_interval
)
988 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), retransmit_interval
);
989 IF_DEF_PARAMS (ifp
)->retransmit_interval
= vl_config
->retransmit_interval
;
992 if (vl_config
->transmit_delay
)
994 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), transmit_delay
);
995 IF_DEF_PARAMS (ifp
)->transmit_delay
= vl_config
->transmit_delay
;
1003 /* The business end of all of the above */
1005 ospf_vl_set (struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
1007 struct ospf_vl_data
*vl_data
;
1010 vl_data
= ospf_find_vl_data (ospf
, vl_config
);
1014 /* Process this one first as it can have a fatal result, which can
1015 only logically occur if the virtual link exists already
1016 Thus a command error does not result in a change to the
1017 running configuration such as unexpectedly altered timer
1019 ret
= ospf_vl_set_security (vl_data
, vl_config
);
1020 if (ret
!= CMD_SUCCESS
)
1023 /* Set any time based parameters, these area already range checked */
1025 ret
= ospf_vl_set_timers (vl_data
, vl_config
);
1026 if (ret
!= CMD_SUCCESS
)
1033 /* This stuff exists to make specifying all the alias commands A LOT simpler
1035 #define VLINK_HELPSTR_IPADDR \
1036 "OSPF area parameters\n" \
1037 "OSPF area ID in IP address format\n" \
1038 "OSPF area ID as a decimal value\n" \
1039 "Configure a virtual link\n" \
1040 "Router ID of the remote ABR\n"
1042 #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
1043 "Enable authentication on this virtual link\n" \
1046 #define VLINK_HELPSTR_AUTHTYPE_ALL \
1047 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
1048 "Use null authentication\n" \
1049 "Use message-digest authentication\n"
1051 #define VLINK_HELPSTR_TIME_PARAM_NOSECS \
1052 "Time between HELLO packets\n" \
1053 "Time between retransmitting lost link state advertisements\n" \
1054 "Link state transmit delay\n" \
1055 "Interval after which a neighbor is declared dead\n"
1057 #define VLINK_HELPSTR_TIME_PARAM \
1058 VLINK_HELPSTR_TIME_PARAM_NOSECS \
1061 #define VLINK_HELPSTR_AUTH_SIMPLE \
1062 "Authentication password (key)\n" \
1063 "The OSPF password (key)"
1065 #define VLINK_HELPSTR_AUTH_MD5 \
1066 "Message digest authentication password (key)\n" \
1069 "Use MD5 algorithm\n" \
1070 "The OSPF password (key)"
1072 DEFUN (ospf_area_vlink
,
1073 ospf_area_vlink_cmd
,
1074 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
1075 VLINK_HELPSTR_IPADDR
)
1077 struct ospf
*ospf
= vty
->index
;
1078 struct ospf_vl_config_data vl_config
;
1079 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+1];
1080 char md5_key
[OSPF_AUTH_MD5_SIZE
+1];
1087 ospf_vl_config_data_init(&vl_config
, vty
);
1089 /* Read off first 2 parameters and check them */
1090 ret
= ospf_str2area_id (argv
[0], &vl_config
.area_id
, &vl_config
.format
);
1093 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1097 ret
= inet_aton (argv
[1], &vl_config
.vl_peer
);
1100 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s",
1107 /* Thats all folks! - BUGS B. strikes again!!!*/
1109 return ospf_vl_set (ospf
, &vl_config
);
1112 /* Deal with other parameters */
1113 for (i
=2; i
< argc
; i
++)
1116 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1122 if (i
> 2 || strncmp (argv
[i
], "authentication-", 15) == 0)
1124 /* authentication-key - this option can occur anywhere on
1125 command line. At start of command line
1126 must check for authentication option. */
1127 memset (auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1128 strncpy (auth_key
, argv
[i
+1], OSPF_AUTH_SIMPLE_SIZE
);
1129 vl_config
.auth_key
= auth_key
;
1132 else if (strncmp (argv
[i
], "authentication", 14) == 0)
1134 /* authentication - this option can only occur at start
1136 vl_config
.auth_type
= OSPF_AUTH_SIMPLE
;
1139 if (strncmp (argv
[i
+1], "n", 1) == 0)
1141 /* "authentication null" */
1142 vl_config
.auth_type
= OSPF_AUTH_NULL
;
1145 else if (strncmp (argv
[i
+1], "m", 1) == 0
1146 && strcmp (argv
[i
+1], "message-digest-") != 0)
1148 /* "authentication message-digest" */
1149 vl_config
.auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
1157 /* message-digest-key */
1159 vl_config
.crypto_key_id
= strtol (argv
[i
], NULL
, 10);
1160 if (vl_config
.crypto_key_id
< 0)
1163 memset(md5_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
1164 strncpy (md5_key
, argv
[i
], OSPF_AUTH_MD5_SIZE
);
1165 vl_config
.md5_key
= md5_key
;
1169 /* Hello interval */
1171 vl_config
.hello_interval
= strtol (argv
[i
], NULL
, 10);
1172 if (vl_config
.hello_interval
< 0)
1177 /* Retransmit Interval */
1179 vl_config
.retransmit_interval
= strtol (argv
[i
], NULL
, 10);
1180 if (vl_config
.retransmit_interval
< 0)
1185 /* Transmit Delay */
1187 vl_config
.transmit_delay
= strtol (argv
[i
], NULL
, 10);
1188 if (vl_config
.transmit_delay
< 0)
1195 vl_config
.dead_interval
= strtol (argv
[i
], NULL
, 10);
1196 if (vl_config
.dead_interval
< 0)
1203 /* Action configuration */
1205 return ospf_vl_set (ospf
, &vl_config
);
1209 DEFUN (no_ospf_area_vlink
,
1210 no_ospf_area_vlink_cmd
,
1211 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
1213 VLINK_HELPSTR_IPADDR
)
1215 struct ospf
*ospf
= vty
->index
;
1216 struct ospf_area
*area
;
1217 struct ospf_vl_config_data vl_config
;
1218 struct ospf_vl_data
*vl_data
= NULL
;
1219 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+1];
1226 ospf_vl_config_data_init(&vl_config
, vty
);
1228 ret
= ospf_str2area_id (argv
[0], &vl_config
.area_id
, &format
);
1231 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1235 area
= ospf_area_lookup_by_area_id (ospf
, vl_config
.area_id
);
1238 vty_out (vty
, "Area does not exist%s", VTY_NEWLINE
);
1242 ret
= inet_aton (argv
[1], &vl_config
.vl_peer
);
1245 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s",
1252 /* Basic VLink no command */
1253 /* Thats all folks! - BUGS B. strikes again!!!*/
1254 if ((vl_data
= ospf_vl_lookup (ospf
, area
, vl_config
.vl_peer
)))
1255 ospf_vl_delete (ospf
, vl_data
);
1257 ospf_area_check_free (ospf
, vl_config
.area_id
);
1262 /* If we are down here, we are reseting parameters */
1264 /* Deal with other parameters */
1265 for (i
=2; i
< argc
; i
++)
1267 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1273 if (i
> 2 || strncmp (argv
[i
], "authentication-", 15) == 0)
1275 /* authentication-key - this option can occur anywhere on
1276 command line. At start of command line
1277 must check for authentication option. */
1278 memset (auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1279 vl_config
.auth_key
= auth_key
;
1281 else if (strncmp (argv
[i
], "authentication", 14) == 0)
1283 /* authentication - this option can only occur at start
1285 vl_config
.auth_type
= OSPF_AUTH_NOTSET
;
1290 /* message-digest-key */
1291 /* Delete one key */
1293 vl_config
.crypto_key_id
= strtol (argv
[i
], NULL
, 10);
1294 if (vl_config
.crypto_key_id
< 0)
1296 vl_config
.md5_key
= NULL
;
1300 /* Hello interval */
1301 vl_config
.hello_interval
= OSPF_HELLO_INTERVAL_DEFAULT
;
1305 /* Retransmit Interval */
1306 vl_config
.retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
1310 /* Transmit Delay */
1311 vl_config
.transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
1317 vl_config
.dead_interval
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
1323 /* Action configuration */
1325 return ospf_vl_set (ospf
, &vl_config
);
1328 ALIAS (ospf_area_vlink
,
1329 ospf_area_vlink_param1_cmd
,
1330 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1331 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1332 VLINK_HELPSTR_IPADDR
1333 VLINK_HELPSTR_TIME_PARAM
)
1335 ALIAS (no_ospf_area_vlink
,
1336 no_ospf_area_vlink_param1_cmd
,
1337 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1338 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1340 VLINK_HELPSTR_IPADDR
1341 VLINK_HELPSTR_TIME_PARAM
)
1343 ALIAS (ospf_area_vlink
,
1344 ospf_area_vlink_param2_cmd
,
1345 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1346 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1347 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1348 VLINK_HELPSTR_IPADDR
1349 VLINK_HELPSTR_TIME_PARAM
1350 VLINK_HELPSTR_TIME_PARAM
)
1352 ALIAS (no_ospf_area_vlink
,
1353 no_ospf_area_vlink_param2_cmd
,
1354 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1355 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1356 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1358 VLINK_HELPSTR_IPADDR
1359 VLINK_HELPSTR_TIME_PARAM
1360 VLINK_HELPSTR_TIME_PARAM
)
1362 ALIAS (ospf_area_vlink
,
1363 ospf_area_vlink_param3_cmd
,
1364 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1365 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1366 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1367 "(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 (no_ospf_area_vlink
,
1374 no_ospf_area_vlink_param3_cmd
,
1375 "no 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>",
1380 VLINK_HELPSTR_IPADDR
1381 VLINK_HELPSTR_TIME_PARAM
1382 VLINK_HELPSTR_TIME_PARAM
1383 VLINK_HELPSTR_TIME_PARAM
)
1385 ALIAS (ospf_area_vlink
,
1386 ospf_area_vlink_param4_cmd
,
1387 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1388 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
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 VLINK_HELPSTR_IPADDR
1393 VLINK_HELPSTR_TIME_PARAM
1394 VLINK_HELPSTR_TIME_PARAM
1395 VLINK_HELPSTR_TIME_PARAM
1396 VLINK_HELPSTR_TIME_PARAM
)
1398 ALIAS (no_ospf_area_vlink
,
1399 no_ospf_area_vlink_param4_cmd
,
1400 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1401 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1402 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1403 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1404 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1406 VLINK_HELPSTR_IPADDR
1407 VLINK_HELPSTR_TIME_PARAM
1408 VLINK_HELPSTR_TIME_PARAM
1409 VLINK_HELPSTR_TIME_PARAM
1410 VLINK_HELPSTR_TIME_PARAM
)
1412 ALIAS (ospf_area_vlink
,
1413 ospf_area_vlink_authtype_args_cmd
,
1414 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1415 "(authentication|) (message-digest|null)",
1416 VLINK_HELPSTR_IPADDR
1417 VLINK_HELPSTR_AUTHTYPE_ALL
)
1419 ALIAS (no_ospf_area_vlink
,
1420 no_ospf_area_vlink_authtype_args_cmd
,
1421 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1422 "(authentication|) (message-digest|null)",
1424 VLINK_HELPSTR_IPADDR
1425 VLINK_HELPSTR_AUTHTYPE_ALL
)
1427 ALIAS (ospf_area_vlink
,
1428 ospf_area_vlink_authtype_cmd
,
1429 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1430 "(authentication|)",
1431 VLINK_HELPSTR_IPADDR
1432 VLINK_HELPSTR_AUTHTYPE_SIMPLE
)
1434 ALIAS (no_ospf_area_vlink
,
1435 no_ospf_area_vlink_authtype_cmd
,
1436 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1437 "(authentication|)",
1439 VLINK_HELPSTR_IPADDR
1440 VLINK_HELPSTR_AUTHTYPE_SIMPLE
)
1442 ALIAS (ospf_area_vlink
,
1443 ospf_area_vlink_md5_cmd
,
1444 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1445 "(message-digest-key|) <1-255> md5 KEY",
1446 VLINK_HELPSTR_IPADDR
1447 VLINK_HELPSTR_AUTH_MD5
)
1449 ALIAS (no_ospf_area_vlink
,
1450 no_ospf_area_vlink_md5_cmd
,
1451 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1452 "(message-digest-key|) <1-255> md5 KEY",
1454 VLINK_HELPSTR_IPADDR
1455 VLINK_HELPSTR_AUTH_MD5
)
1457 ALIAS (ospf_area_vlink
,
1458 ospf_area_vlink_authkey_cmd
,
1459 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1460 "(authentication-key|) AUTH_KEY",
1461 VLINK_HELPSTR_IPADDR
1462 VLINK_HELPSTR_AUTH_SIMPLE
)
1464 ALIAS (no_ospf_area_vlink
,
1465 no_ospf_area_vlink_authkey_cmd
,
1466 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1467 "(authentication-key|) AUTH_KEY",
1469 VLINK_HELPSTR_IPADDR
1470 VLINK_HELPSTR_AUTH_SIMPLE
)
1472 ALIAS (ospf_area_vlink
,
1473 ospf_area_vlink_authtype_args_authkey_cmd
,
1474 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1475 "(authentication|) (message-digest|null) "
1476 "(authentication-key|) AUTH_KEY",
1477 VLINK_HELPSTR_IPADDR
1478 VLINK_HELPSTR_AUTHTYPE_ALL
1479 VLINK_HELPSTR_AUTH_SIMPLE
)
1481 ALIAS (no_ospf_area_vlink
,
1482 no_ospf_area_vlink_authtype_args_authkey_cmd
,
1483 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1484 "(authentication|) (message-digest|null) "
1485 "(authentication-key|) AUTH_KEY",
1487 VLINK_HELPSTR_IPADDR
1488 VLINK_HELPSTR_AUTHTYPE_ALL
1489 VLINK_HELPSTR_AUTH_SIMPLE
)
1491 ALIAS (ospf_area_vlink
,
1492 ospf_area_vlink_authtype_authkey_cmd
,
1493 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1494 "(authentication|) "
1495 "(authentication-key|) AUTH_KEY",
1496 VLINK_HELPSTR_IPADDR
1497 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1498 VLINK_HELPSTR_AUTH_SIMPLE
)
1500 ALIAS (no_ospf_area_vlink
,
1501 no_ospf_area_vlink_authtype_authkey_cmd
,
1502 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1503 "(authentication|) "
1504 "(authentication-key|) AUTH_KEY",
1506 VLINK_HELPSTR_IPADDR
1507 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1508 VLINK_HELPSTR_AUTH_SIMPLE
)
1510 ALIAS (ospf_area_vlink
,
1511 ospf_area_vlink_authtype_args_md5_cmd
,
1512 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1513 "(authentication|) (message-digest|null) "
1514 "(message-digest-key|) <1-255> md5 KEY",
1515 VLINK_HELPSTR_IPADDR
1516 VLINK_HELPSTR_AUTHTYPE_ALL
1517 VLINK_HELPSTR_AUTH_MD5
)
1519 ALIAS (no_ospf_area_vlink
,
1520 no_ospf_area_vlink_authtype_args_md5_cmd
,
1521 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1522 "(authentication|) (message-digest|null) "
1523 "(message-digest-key|) <1-255> md5 KEY",
1525 VLINK_HELPSTR_IPADDR
1526 VLINK_HELPSTR_AUTHTYPE_ALL
1527 VLINK_HELPSTR_AUTH_MD5
)
1529 ALIAS (ospf_area_vlink
,
1530 ospf_area_vlink_authtype_md5_cmd
,
1531 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1532 "(authentication|) "
1533 "(message-digest-key|) <1-255> md5 KEY",
1534 VLINK_HELPSTR_IPADDR
1535 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1536 VLINK_HELPSTR_AUTH_MD5
)
1538 ALIAS (no_ospf_area_vlink
,
1539 no_ospf_area_vlink_authtype_md5_cmd
,
1540 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1541 "(authentication|) "
1542 "(message-digest-key|) <1-255> md5 KEY",
1544 VLINK_HELPSTR_IPADDR
1545 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1546 VLINK_HELPSTR_AUTH_MD5
)
1549 DEFUN (ospf_area_shortcut
,
1550 ospf_area_shortcut_cmd
,
1551 "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)",
1552 "OSPF area parameters\n"
1553 "OSPF area ID in IP address format\n"
1554 "OSPF area ID as a decimal value\n"
1555 "Configure the area's shortcutting mode\n"
1556 "Set default shortcutting behavior\n"
1557 "Enable shortcutting through the area\n"
1558 "Disable shortcutting through the area\n")
1560 struct ospf
*ospf
= vty
->index
;
1561 struct ospf_area
*area
;
1562 struct in_addr area_id
;
1569 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id
, format
, argv
[0]);
1571 area
= ospf_area_get (ospf
, area_id
, format
);
1573 if (strncmp (argv
[1], "de", 2) == 0)
1574 mode
= OSPF_SHORTCUT_DEFAULT
;
1575 else if (strncmp (argv
[1], "di", 2) == 0)
1576 mode
= OSPF_SHORTCUT_DISABLE
;
1577 else if (strncmp (argv
[1], "e", 1) == 0)
1578 mode
= OSPF_SHORTCUT_ENABLE
;
1582 ospf_area_shortcut_set (ospf
, area
, mode
);
1584 if (ospf
->abr_type
!= OSPF_ABR_SHORTCUT
)
1585 vty_out (vty
, "Shortcut area setting will take effect "
1586 "only when the router is configured as Shortcut ABR%s",
1592 DEFUN (no_ospf_area_shortcut
,
1593 no_ospf_area_shortcut_cmd
,
1594 "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)",
1596 "OSPF area parameters\n"
1597 "OSPF area ID in IP address format\n"
1598 "OSPF area ID as a decimal value\n"
1599 "Deconfigure the area's shortcutting mode\n"
1600 "Deconfigure enabled shortcutting through the area\n"
1601 "Deconfigure disabled shortcutting through the area\n")
1603 struct ospf
*ospf
= vty
->index
;
1604 struct ospf_area
*area
;
1605 struct in_addr area_id
;
1611 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id
, format
, argv
[0]);
1613 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1617 ospf_area_shortcut_unset (ospf
, area
);
1623 DEFUN (ospf_area_stub
,
1625 "area (A.B.C.D|<0-4294967295>) stub",
1626 "OSPF area parameters\n"
1627 "OSPF area ID in IP address format\n"
1628 "OSPF area ID as a decimal value\n"
1629 "Configure OSPF area as stub\n")
1631 struct ospf
*ospf
= vty
->index
;
1632 struct in_addr area_id
;
1638 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[0]);
1640 ret
= ospf_area_stub_set (ospf
, area_id
);
1643 vty_out (vty
, "First deconfigure all virtual link through this area%s",
1648 ospf_area_no_summary_unset (ospf
, area_id
);
1653 DEFUN (ospf_area_stub_no_summary
,
1654 ospf_area_stub_no_summary_cmd
,
1655 "area (A.B.C.D|<0-4294967295>) stub no-summary",
1656 "OSPF stub parameters\n"
1657 "OSPF area ID in IP address format\n"
1658 "OSPF area ID as a decimal value\n"
1659 "Configure OSPF area as stub\n"
1660 "Do not inject inter-area routes into stub\n")
1662 struct ospf
*ospf
= vty
->index
;
1663 struct in_addr area_id
;
1669 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[0]);
1671 ret
= ospf_area_stub_set (ospf
, area_id
);
1674 vty_out (vty
, "%% Area cannot be stub as it contains a virtual link%s",
1679 ospf_area_no_summary_set (ospf
, area_id
);
1684 DEFUN (no_ospf_area_stub
,
1685 no_ospf_area_stub_cmd
,
1686 "no area (A.B.C.D|<0-4294967295>) stub",
1688 "OSPF area parameters\n"
1689 "OSPF area ID in IP address format\n"
1690 "OSPF area ID as a decimal value\n"
1691 "Configure OSPF area as stub\n")
1693 struct ospf
*ospf
= vty
->index
;
1694 struct in_addr area_id
;
1700 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[0]);
1702 ospf_area_stub_unset (ospf
, area_id
);
1703 ospf_area_no_summary_unset (ospf
, area_id
);
1708 DEFUN (no_ospf_area_stub_no_summary
,
1709 no_ospf_area_stub_no_summary_cmd
,
1710 "no area (A.B.C.D|<0-4294967295>) stub no-summary",
1712 "OSPF area parameters\n"
1713 "OSPF area ID in IP address format\n"
1714 "OSPF area ID as a decimal value\n"
1715 "Configure OSPF area as stub\n"
1716 "Do not inject inter-area routes into area\n")
1718 struct ospf
*ospf
= vty
->index
;
1719 struct in_addr area_id
;
1725 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[0]);
1726 ospf_area_no_summary_unset (ospf
, area_id
);
1732 ospf_area_nssa_cmd_handler (struct vty
*vty
, int argc
, const char *argv
[],
1735 struct ospf
*ospf
= vty
->index
;
1736 struct in_addr area_id
;
1742 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id
, format
, argv
[0]);
1744 ret
= ospf_area_nssa_set (ospf
, area_id
);
1747 vty_out (vty
, "%% Area cannot be nssa as it contains a virtual link%s",
1754 if (strncmp (argv
[1], "translate-c", 11) == 0)
1755 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1756 OSPF_NSSA_ROLE_CANDIDATE
);
1757 else if (strncmp (argv
[1], "translate-n", 11) == 0)
1758 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1759 OSPF_NSSA_ROLE_NEVER
);
1760 else if (strncmp (argv
[1], "translate-a", 11) == 0)
1761 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1762 OSPF_NSSA_ROLE_ALWAYS
);
1766 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1767 OSPF_NSSA_ROLE_CANDIDATE
);
1771 ospf_area_no_summary_set (ospf
, area_id
);
1773 ospf_area_no_summary_unset (ospf
, area_id
);
1775 ospf_schedule_abr_task (ospf
);
1780 DEFUN (ospf_area_nssa_translate_no_summary
,
1781 ospf_area_nssa_translate_no_summary_cmd
,
1782 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary",
1783 "OSPF area parameters\n"
1784 "OSPF area ID in IP address format\n"
1785 "OSPF area ID as a decimal value\n"
1786 "Configure OSPF area as nssa\n"
1787 "Configure NSSA-ABR for translate election (default)\n"
1788 "Configure NSSA-ABR to never translate\n"
1789 "Configure NSSA-ABR to always translate\n"
1790 "Do not inject inter-area routes into nssa\n")
1792 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 1);
1795 DEFUN (ospf_area_nssa_translate
,
1796 ospf_area_nssa_translate_cmd
,
1797 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)",
1798 "OSPF area parameters\n"
1799 "OSPF area ID in IP address format\n"
1800 "OSPF area ID as a decimal value\n"
1801 "Configure OSPF area as nssa\n"
1802 "Configure NSSA-ABR for translate election (default)\n"
1803 "Configure NSSA-ABR to never translate\n"
1804 "Configure NSSA-ABR to always translate\n")
1806 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 0);
1809 DEFUN (ospf_area_nssa
,
1811 "area (A.B.C.D|<0-4294967295>) nssa",
1812 "OSPF area parameters\n"
1813 "OSPF area ID in IP address format\n"
1814 "OSPF area ID as a decimal value\n"
1815 "Configure OSPF area as nssa\n")
1817 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 0);
1820 DEFUN (ospf_area_nssa_no_summary
,
1821 ospf_area_nssa_no_summary_cmd
,
1822 "area (A.B.C.D|<0-4294967295>) nssa no-summary",
1823 "OSPF area parameters\n"
1824 "OSPF area ID in IP address format\n"
1825 "OSPF area ID as a decimal value\n"
1826 "Configure OSPF area as nssa\n"
1827 "Do not inject inter-area routes into nssa\n")
1829 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 1);
1832 DEFUN (no_ospf_area_nssa
,
1833 no_ospf_area_nssa_cmd
,
1834 "no area (A.B.C.D|<0-4294967295>) nssa",
1836 "OSPF area parameters\n"
1837 "OSPF area ID in IP address format\n"
1838 "OSPF area ID as a decimal value\n"
1839 "Configure OSPF area as nssa\n")
1841 struct ospf
*ospf
= vty
->index
;
1842 struct in_addr area_id
;
1848 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id
, format
, argv
[0]);
1850 ospf_area_nssa_unset (ospf
, area_id
);
1851 ospf_area_no_summary_unset (ospf
, area_id
);
1853 ospf_schedule_abr_task (ospf
);
1858 ALIAS (no_ospf_area_nssa
,
1859 no_ospf_area_nssa_no_summary_cmd
,
1860 "no area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always|) {no-summary}",
1862 "OSPF area parameters\n"
1863 "OSPF area ID in IP address format\n"
1864 "OSPF area ID as a decimal value\n"
1865 "Configure OSPF area as nssa\n"
1866 "Configure NSSA-ABR for translate election (default)\n"
1867 "Configure NSSA-ABR to never translate\n"
1868 "Configure NSSA-ABR to always translate\n"
1869 "Do not inject inter-area routes into nssa\n")
1871 DEFUN (ospf_area_default_cost
,
1872 ospf_area_default_cost_cmd
,
1873 "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1874 "OSPF area parameters\n"
1875 "OSPF area ID in IP address format\n"
1876 "OSPF area ID as a decimal value\n"
1877 "Set the summary-default cost of a NSSA or stub area\n"
1878 "Stub's advertised default summary cost\n")
1880 struct ospf
*ospf
= vty
->index
;
1881 struct ospf_area
*area
;
1882 struct in_addr area_id
;
1885 struct prefix_ipv4 p
;
1890 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id
, format
, argv
[0]);
1891 VTY_GET_INTEGER_RANGE ("stub default cost", cost
, argv
[1], 0, 16777215);
1893 area
= ospf_area_get (ospf
, area_id
, format
);
1895 if (area
->external_routing
== OSPF_AREA_DEFAULT
)
1897 vty_out (vty
, "The area is neither stub, nor NSSA%s", VTY_NEWLINE
);
1901 area
->default_cost
= cost
;
1904 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1906 if (IS_DEBUG_OSPF_EVENT
)
1907 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1908 "announcing 0.0.0.0/0 to area %s",
1909 inet_ntoa (area
->area_id
));
1910 ospf_abr_announce_network_to_area (&p
, area
->default_cost
, area
);
1915 DEFUN (no_ospf_area_default_cost
,
1916 no_ospf_area_default_cost_cmd
,
1917 "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1919 "OSPF area parameters\n"
1920 "OSPF area ID in IP address format\n"
1921 "OSPF area ID as a decimal value\n"
1922 "Set the summary-default cost of a NSSA or stub area\n"
1923 "Stub's advertised default summary cost\n")
1925 struct ospf
*ospf
= vty
->index
;
1926 struct ospf_area
*area
;
1927 struct in_addr area_id
;
1929 struct prefix_ipv4 p
;
1934 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id
, format
, argv
[0]);
1935 VTY_CHECK_INTEGER_RANGE ("stub default cost", argv
[1], 0, OSPF_LS_INFINITY
);
1937 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1941 if (area
->external_routing
== OSPF_AREA_DEFAULT
)
1943 vty_out (vty
, "The area is neither stub, nor NSSA%s", VTY_NEWLINE
);
1947 area
->default_cost
= 1;
1950 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1952 if (IS_DEBUG_OSPF_EVENT
)
1953 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1954 "announcing 0.0.0.0/0 to area %s",
1955 inet_ntoa (area
->area_id
));
1956 ospf_abr_announce_network_to_area (&p
, area
->default_cost
, area
);
1959 ospf_area_check_free (ospf
, area_id
);
1964 DEFUN (ospf_area_export_list
,
1965 ospf_area_export_list_cmd
,
1966 "area (A.B.C.D|<0-4294967295>) export-list NAME",
1967 "OSPF area parameters\n"
1968 "OSPF area ID in IP address format\n"
1969 "OSPF area ID as a decimal value\n"
1970 "Set the filter for networks announced to other areas\n"
1971 "Name of the access-list\n")
1973 struct ospf
*ospf
= vty
->index
;
1974 struct ospf_area
*area
;
1975 struct in_addr area_id
;
1981 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
1983 area
= ospf_area_get (ospf
, area_id
, format
);
1984 ospf_area_export_list_set (ospf
, area
, argv
[1]);
1989 DEFUN (no_ospf_area_export_list
,
1990 no_ospf_area_export_list_cmd
,
1991 "no area (A.B.C.D|<0-4294967295>) export-list NAME",
1993 "OSPF area parameters\n"
1994 "OSPF area ID in IP address format\n"
1995 "OSPF area ID as a decimal value\n"
1996 "Unset the filter for networks announced to other areas\n"
1997 "Name of the access-list\n")
1999 struct ospf
*ospf
= vty
->index
;
2000 struct ospf_area
*area
;
2001 struct in_addr area_id
;
2007 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
2009 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
2013 ospf_area_export_list_unset (ospf
, area
);
2019 DEFUN (ospf_area_import_list
,
2020 ospf_area_import_list_cmd
,
2021 "area (A.B.C.D|<0-4294967295>) import-list NAME",
2022 "OSPF area parameters\n"
2023 "OSPF area ID in IP address format\n"
2024 "OSPF area ID as a decimal value\n"
2025 "Set the filter for networks from other areas announced to the specified one\n"
2026 "Name of the access-list\n")
2028 struct ospf
*ospf
= vty
->index
;
2029 struct ospf_area
*area
;
2030 struct in_addr area_id
;
2036 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
2038 area
= ospf_area_get (ospf
, area_id
, format
);
2039 ospf_area_import_list_set (ospf
, area
, argv
[1]);
2044 DEFUN (no_ospf_area_import_list
,
2045 no_ospf_area_import_list_cmd
,
2046 "no area (A.B.C.D|<0-4294967295>) import-list NAME",
2048 "OSPF area parameters\n"
2049 "OSPF area ID in IP address format\n"
2050 "OSPF area ID as a decimal value\n"
2051 "Unset the filter for networks announced to other areas\n"
2052 "Name of the access-list\n")
2054 struct ospf
*ospf
= vty
->index
;
2055 struct ospf_area
*area
;
2056 struct in_addr area_id
;
2062 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
2064 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
2068 ospf_area_import_list_unset (ospf
, area
);
2073 DEFUN (ospf_area_filter_list
,
2074 ospf_area_filter_list_cmd
,
2075 "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
2076 "OSPF area parameters\n"
2077 "OSPF area ID in IP address format\n"
2078 "OSPF area ID as a decimal value\n"
2079 "Filter networks between OSPF areas\n"
2080 "Filter prefixes between OSPF areas\n"
2081 "Name of an IP prefix-list\n"
2082 "Filter networks sent to this area\n"
2083 "Filter networks sent from this area\n")
2085 struct ospf
*ospf
= vty
->index
;
2086 struct ospf_area
*area
;
2087 struct in_addr area_id
;
2088 struct prefix_list
*plist
;
2094 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
2096 area
= ospf_area_get (ospf
, area_id
, format
);
2097 plist
= prefix_list_lookup (AFI_IP
, argv
[1]);
2098 if (strncmp (argv
[2], "in", 2) == 0)
2100 PREFIX_LIST_IN (area
) = plist
;
2101 if (PREFIX_NAME_IN (area
))
2102 free (PREFIX_NAME_IN (area
));
2104 PREFIX_NAME_IN (area
) = strdup (argv
[1]);
2105 ospf_schedule_abr_task (ospf
);
2109 PREFIX_LIST_OUT (area
) = plist
;
2110 if (PREFIX_NAME_OUT (area
))
2111 free (PREFIX_NAME_OUT (area
));
2113 PREFIX_NAME_OUT (area
) = strdup (argv
[1]);
2114 ospf_schedule_abr_task (ospf
);
2120 DEFUN (no_ospf_area_filter_list
,
2121 no_ospf_area_filter_list_cmd
,
2122 "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
2124 "OSPF area parameters\n"
2125 "OSPF area ID in IP address format\n"
2126 "OSPF area ID as a decimal value\n"
2127 "Filter networks between OSPF areas\n"
2128 "Filter prefixes between OSPF areas\n"
2129 "Name of an IP prefix-list\n"
2130 "Filter networks sent to this area\n"
2131 "Filter networks sent from this area\n")
2133 struct ospf
*ospf
= vty
->index
;
2134 struct ospf_area
*area
;
2135 struct in_addr area_id
;
2141 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
2143 if ((area
= ospf_area_lookup_by_area_id (ospf
, area_id
)) == NULL
)
2146 if (strncmp (argv
[2], "in", 2) == 0)
2148 if (PREFIX_NAME_IN (area
))
2149 if (strcmp (PREFIX_NAME_IN (area
), argv
[1]) != 0)
2152 PREFIX_LIST_IN (area
) = NULL
;
2153 if (PREFIX_NAME_IN (area
))
2154 free (PREFIX_NAME_IN (area
));
2156 PREFIX_NAME_IN (area
) = NULL
;
2158 ospf_schedule_abr_task (ospf
);
2162 if (PREFIX_NAME_OUT (area
))
2163 if (strcmp (PREFIX_NAME_OUT (area
), argv
[1]) != 0)
2166 PREFIX_LIST_OUT (area
) = NULL
;
2167 if (PREFIX_NAME_OUT (area
))
2168 free (PREFIX_NAME_OUT (area
));
2170 PREFIX_NAME_OUT (area
) = NULL
;
2172 ospf_schedule_abr_task (ospf
);
2179 DEFUN (ospf_area_authentication_message_digest
,
2180 ospf_area_authentication_message_digest_cmd
,
2181 "area (A.B.C.D|<0-4294967295>) authentication message-digest",
2182 "OSPF area parameters\n"
2183 "OSPF area ID in IP address format\n"
2184 "OSPF area ID as a decimal value\n"
2185 "Enable authentication\n"
2186 "Use message-digest authentication\n")
2188 struct ospf
*ospf
= vty
->index
;
2189 struct ospf_area
*area
;
2190 struct in_addr area_id
;
2196 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
2198 area
= ospf_area_get (ospf
, area_id
, format
);
2199 area
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
2204 DEFUN (ospf_area_authentication
,
2205 ospf_area_authentication_cmd
,
2206 "area (A.B.C.D|<0-4294967295>) authentication",
2207 "OSPF area parameters\n"
2208 "OSPF area ID in IP address format\n"
2209 "OSPF area ID as a decimal value\n"
2210 "Enable authentication\n")
2212 struct ospf
*ospf
= vty
->index
;
2213 struct ospf_area
*area
;
2214 struct in_addr area_id
;
2220 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
2222 area
= ospf_area_get (ospf
, area_id
, format
);
2223 area
->auth_type
= OSPF_AUTH_SIMPLE
;
2228 DEFUN (no_ospf_area_authentication
,
2229 no_ospf_area_authentication_cmd
,
2230 "no area (A.B.C.D|<0-4294967295>) authentication",
2232 "OSPF area parameters\n"
2233 "OSPF area ID in IP address format\n"
2234 "OSPF area ID as a decimal value\n"
2235 "Enable authentication\n")
2237 struct ospf
*ospf
= vty
->index
;
2238 struct ospf_area
*area
;
2239 struct in_addr area_id
;
2245 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
2247 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
2251 area
->auth_type
= OSPF_AUTH_NULL
;
2253 ospf_area_check_free (ospf
, area_id
);
2259 DEFUN (ospf_abr_type
,
2261 "ospf abr-type (cisco|ibm|shortcut|standard)",
2262 "OSPF specific commands\n"
2263 "Set OSPF ABR type\n"
2264 "Alternative ABR, cisco implementation\n"
2265 "Alternative ABR, IBM implementation\n"
2267 "Standard behavior (RFC2328)\n")
2269 struct ospf
*ospf
= vty
->index
;
2270 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2275 if (strncmp (argv
[0], "c", 1) == 0)
2276 abr_type
= OSPF_ABR_CISCO
;
2277 else if (strncmp (argv
[0], "i", 1) == 0)
2278 abr_type
= OSPF_ABR_IBM
;
2279 else if (strncmp (argv
[0], "sh", 2) == 0)
2280 abr_type
= OSPF_ABR_SHORTCUT
;
2281 else if (strncmp (argv
[0], "st", 2) == 0)
2282 abr_type
= OSPF_ABR_STAND
;
2286 /* If ABR type value is changed, schedule ABR task. */
2287 if (ospf
->abr_type
!= abr_type
)
2289 ospf
->abr_type
= abr_type
;
2290 ospf_schedule_abr_task (ospf
);
2296 DEFUN (no_ospf_abr_type
,
2297 no_ospf_abr_type_cmd
,
2298 "no ospf abr-type (cisco|ibm|shortcut|standard)",
2300 "OSPF specific commands\n"
2301 "Set OSPF ABR type\n"
2302 "Alternative ABR, cisco implementation\n"
2303 "Alternative ABR, IBM implementation\n"
2306 struct ospf
*ospf
= vty
->index
;
2307 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2312 if (strncmp (argv
[0], "c", 1) == 0)
2313 abr_type
= OSPF_ABR_CISCO
;
2314 else if (strncmp (argv
[0], "i", 1) == 0)
2315 abr_type
= OSPF_ABR_IBM
;
2316 else if (strncmp (argv
[0], "sh", 2) == 0)
2317 abr_type
= OSPF_ABR_SHORTCUT
;
2318 else if (strncmp (argv
[0], "st", 2) == 0)
2319 abr_type
= OSPF_ABR_STAND
;
2323 /* If ABR type value is changed, schedule ABR task. */
2324 if (ospf
->abr_type
== abr_type
)
2326 ospf
->abr_type
= OSPF_ABR_DEFAULT
;
2327 ospf_schedule_abr_task (ospf
);
2333 DEFUN (ospf_log_adjacency_changes
,
2334 ospf_log_adjacency_changes_cmd
,
2335 "log-adjacency-changes",
2336 "Log changes in adjacency state\n")
2338 struct ospf
*ospf
= vty
->index
;
2343 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2344 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2348 DEFUN (ospf_log_adjacency_changes_detail
,
2349 ospf_log_adjacency_changes_detail_cmd
,
2350 "log-adjacency-changes detail",
2351 "Log changes in adjacency state\n"
2352 "Log all state changes\n")
2354 struct ospf
*ospf
= vty
->index
;
2359 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2360 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2364 DEFUN (no_ospf_log_adjacency_changes
,
2365 no_ospf_log_adjacency_changes_cmd
,
2366 "no log-adjacency-changes",
2368 "Log changes in adjacency state\n")
2370 struct ospf
*ospf
= vty
->index
;
2375 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2376 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2380 DEFUN (no_ospf_log_adjacency_changes_detail
,
2381 no_ospf_log_adjacency_changes_detail_cmd
,
2382 "no log-adjacency-changes detail",
2384 "Log changes in adjacency state\n"
2385 "Log all state changes\n")
2387 struct ospf
*ospf
= vty
->index
;
2392 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2393 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2397 DEFUN (ospf_compatible_rfc1583
,
2398 ospf_compatible_rfc1583_cmd
,
2399 "compatible rfc1583",
2400 "OSPF compatibility list\n"
2401 "compatible with RFC 1583\n")
2403 struct ospf
*ospf
= vty
->index
;
2408 if (!CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
2410 SET_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2411 ospf_spf_calculate_schedule (ospf
, SPF_FLAG_CONFIG_CHANGE
);
2416 DEFUN (no_ospf_compatible_rfc1583
,
2417 no_ospf_compatible_rfc1583_cmd
,
2418 "no compatible rfc1583",
2420 "OSPF compatibility list\n"
2421 "compatible with RFC 1583\n")
2423 struct ospf
*ospf
= vty
->index
;
2428 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
2430 UNSET_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2431 ospf_spf_calculate_schedule (ospf
, SPF_FLAG_CONFIG_CHANGE
);
2436 ALIAS (ospf_compatible_rfc1583
,
2437 ospf_rfc1583_flag_cmd
,
2438 "ospf rfc1583compatibility",
2439 "OSPF specific commands\n"
2440 "Enable the RFC1583Compatibility flag\n")
2442 ALIAS (no_ospf_compatible_rfc1583
,
2443 no_ospf_rfc1583_flag_cmd
,
2444 "no ospf rfc1583compatibility",
2446 "OSPF specific commands\n"
2447 "Disable the RFC1583Compatibility flag\n")
2450 ospf_timers_spf_set (struct vty
*vty
, unsigned int delay
,
2454 struct ospf
*ospf
= vty
->index
;
2459 ospf
->spf_delay
= delay
;
2460 ospf
->spf_holdtime
= hold
;
2461 ospf
->spf_max_holdtime
= max
;
2466 DEFUN (ospf_timers_min_ls_interval
,
2467 ospf_timers_min_ls_interval_cmd
,
2468 "timers throttle lsa all <0-5000>",
2469 "Adjust routing timers\n"
2470 "Throttling adaptive timer\n"
2471 "LSA delay between transmissions\n"
2473 "Delay (msec) between sending LSAs\n")
2475 struct ospf
*ospf
= vty
->index
;
2476 unsigned int interval
;
2483 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2487 VTY_GET_INTEGER ("LSA interval", interval
, argv
[0]);
2489 ospf
->min_ls_interval
= interval
;
2494 DEFUN (no_ospf_timers_min_ls_interval
,
2495 no_ospf_timers_min_ls_interval_cmd
,
2496 "no timers throttle lsa all",
2498 "Adjust routing timers\n"
2499 "Throttling adaptive timer\n"
2500 "LSA delay between transmissions\n"
2503 struct ospf
*ospf
= vty
->index
;
2504 ospf
->min_ls_interval
= OSPF_MIN_LS_INTERVAL
;
2509 ALIAS (no_ospf_timers_min_ls_interval
,
2510 no_ospf_timers_min_ls_interval_val_cmd
,
2511 "no timers throttle lsa all <0-5000>",
2513 "Adjust routing timers\n"
2514 "Throttling adaptive timer\n"
2515 "LSA delay between transmissions\n"
2517 "Delay (msec) between sending LSAs\n")
2519 DEFUN (ospf_timers_min_ls_arrival
,
2520 ospf_timers_min_ls_arrival_cmd
,
2521 "timers lsa arrival <0-1000>",
2522 "Adjust routing timers\n"
2523 "Throttling link state advertisement delays\n"
2524 "OSPF minimum arrival interval delay\n"
2525 "Delay (msec) between accepted LSAs\n")
2527 struct ospf
*ospf
= vty
->index
;
2528 unsigned int arrival
;
2535 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2539 VTY_GET_INTEGER_RANGE ("minimum LSA inter-arrival time", arrival
, argv
[0], 0, 1000);
2541 ospf
->min_ls_arrival
= arrival
;
2546 DEFUN (no_ospf_timers_min_ls_arrival
,
2547 no_ospf_timers_min_ls_arrival_cmd
,
2548 "no timers lsa arrival",
2550 "Adjust routing timers\n"
2551 "Throttling link state advertisement delays\n"
2552 "OSPF minimum arrival interval delay\n")
2554 struct ospf
*ospf
= vty
->index
;
2559 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2564 ALIAS (no_ospf_timers_min_ls_arrival
,
2565 no_ospf_timers_min_ls_arrival_val_cmd
,
2566 "no timers lsa arrival <0-1000>",
2568 "Adjust routing timers\n"
2569 "Throttling link state advertisement delays\n"
2570 "OSPF minimum arrival interval delay\n"
2571 "Delay (msec) between accepted LSAs\n")
2573 DEFUN (ospf_timers_throttle_spf
,
2574 ospf_timers_throttle_spf_cmd
,
2575 "timers throttle spf <0-600000> <0-600000> <0-600000>",
2576 "Adjust routing timers\n"
2577 "Throttling adaptive timer\n"
2579 "Delay (msec) from first change received till SPF calculation\n"
2580 "Initial hold time (msec) between consecutive SPF calculations\n"
2581 "Maximum hold time (msec)\n")
2583 unsigned int delay
, hold
, max
;
2587 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2591 VTY_GET_INTEGER_RANGE ("SPF delay timer", delay
, argv
[0], 0, 600000);
2592 VTY_GET_INTEGER_RANGE ("SPF hold timer", hold
, argv
[1], 0, 600000);
2593 VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max
, argv
[2], 0, 600000);
2595 return ospf_timers_spf_set (vty
, delay
, hold
, max
);
2598 DEFUN (no_ospf_timers_throttle_spf
,
2599 no_ospf_timers_throttle_spf_cmd
,
2600 "no timers throttle spf",
2602 "Adjust routing timers\n"
2603 "Throttling adaptive timer\n"
2604 "OSPF SPF timers\n")
2606 return ospf_timers_spf_set (vty
,
2607 OSPF_SPF_DELAY_DEFAULT
,
2608 OSPF_SPF_HOLDTIME_DEFAULT
,
2609 OSPF_SPF_MAX_HOLDTIME_DEFAULT
);
2612 ALIAS (no_ospf_timers_throttle_spf
,
2613 no_ospf_timers_throttle_spf_val_cmd
,
2614 "no timers throttle spf <0-600000> <0-600000> <0-600000>",
2616 "Adjust routing timers\n"
2617 "Throttling adaptive timer\n"
2619 "Delay (msec) from first change received till SPF calculation\n"
2620 "Initial hold time (msec) between consecutive SPF calculations\n"
2621 "Maximum hold time (msec)\n")
2623 DEFUN (ospf_timers_lsa
,
2624 ospf_timers_lsa_cmd
,
2625 "timers lsa min-arrival <0-600000>",
2626 "Adjust routing timers\n"
2628 "Minimum delay in receiving new version of a LSA\n"
2629 "Delay in milliseconds\n")
2631 unsigned int minarrival
;
2632 struct ospf
*ospf
= vty
->index
;
2639 vty_out (vty
, "Insufficient number of arguments%s", VTY_NEWLINE
);
2643 VTY_GET_INTEGER ("LSA min-arrival", minarrival
, argv
[0]);
2645 ospf
->min_ls_arrival
= minarrival
;
2650 DEFUN (no_ospf_timers_lsa
,
2651 no_ospf_timers_lsa_cmd
,
2652 "no timers lsa min-arrival",
2654 "Adjust routing timers\n"
2656 "Minimum delay in receiving new version of a LSA\n")
2658 unsigned int minarrival
;
2659 struct ospf
*ospf
= vty
->index
;
2666 VTY_GET_INTEGER ("LSA min-arrival", minarrival
, argv
[0]);
2668 if (ospf
->min_ls_arrival
!= minarrival
||
2669 minarrival
== OSPF_MIN_LS_ARRIVAL
)
2673 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2678 ALIAS (no_ospf_timers_lsa
,
2679 no_ospf_timers_lsa_val_cmd
,
2680 "no timers lsa min-arrival <0-600000>",
2682 "Adjust routing timers\n"
2684 "Minimum delay in receiving new version of a LSA\n"
2685 "Delay in milliseconds\n")
2688 DEFUN (ospf_neighbor
,
2692 "Neighbor IP address\n")
2694 struct ospf
*ospf
= vty
->index
;
2695 struct in_addr nbr_addr
;
2696 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2697 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2702 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[0]);
2705 VTY_GET_INTEGER_RANGE ("neighbor priority", priority
, argv
[1], 0, 255);
2708 VTY_GET_INTEGER_RANGE ("poll interval", interval
, argv
[2], 1, 65535);
2710 ospf_nbr_nbma_set (ospf
, nbr_addr
);
2712 ospf_nbr_nbma_priority_set (ospf
, nbr_addr
, priority
);
2714 ospf_nbr_nbma_poll_interval_set (ospf
, nbr_addr
, interval
);
2719 ALIAS (ospf_neighbor
,
2720 ospf_neighbor_priority_poll_interval_cmd
,
2721 "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2723 "Neighbor IP address\n"
2724 "Neighbor Priority\n"
2726 "Dead Neighbor Polling interval\n"
2729 ALIAS (ospf_neighbor
,
2730 ospf_neighbor_priority_cmd
,
2731 "neighbor A.B.C.D priority <0-255>",
2733 "Neighbor IP address\n"
2734 "Neighbor Priority\n"
2737 DEFUN (ospf_neighbor_poll_interval
,
2738 ospf_neighbor_poll_interval_cmd
,
2739 "neighbor A.B.C.D poll-interval <1-65535>",
2741 "Neighbor IP address\n"
2742 "Dead Neighbor Polling interval\n"
2745 struct ospf
*ospf
= vty
->index
;
2746 struct in_addr nbr_addr
;
2747 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2748 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2753 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[0]);
2756 VTY_GET_INTEGER_RANGE ("poll interval", interval
, argv
[1], 1, 65535);
2759 VTY_GET_INTEGER_RANGE ("neighbor priority", priority
, argv
[2], 0, 255);
2761 ospf_nbr_nbma_set (ospf
, nbr_addr
);
2763 ospf_nbr_nbma_poll_interval_set (ospf
, nbr_addr
, interval
);
2765 ospf_nbr_nbma_priority_set (ospf
, nbr_addr
, priority
);
2770 ALIAS (ospf_neighbor_poll_interval
,
2771 ospf_neighbor_poll_interval_priority_cmd
,
2772 "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2774 "Neighbor address\n"
2775 "OSPF dead-router polling interval\n"
2777 "OSPF priority of non-broadcast neighbor\n"
2780 DEFUN (no_ospf_neighbor
,
2781 no_ospf_neighbor_cmd
,
2782 "no neighbor A.B.C.D",
2785 "Neighbor IP address\n")
2787 struct ospf
*ospf
= vty
->index
;
2788 struct in_addr nbr_addr
;
2793 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[0]);
2795 (void)ospf_nbr_nbma_unset (ospf
, nbr_addr
);
2800 ALIAS (no_ospf_neighbor
,
2801 no_ospf_neighbor_priority_cmd
,
2802 "no neighbor A.B.C.D priority <0-255>",
2805 "Neighbor IP address\n"
2806 "Neighbor Priority\n"
2809 ALIAS (no_ospf_neighbor
,
2810 no_ospf_neighbor_poll_interval_cmd
,
2811 "no neighbor A.B.C.D poll-interval <1-65535>",
2814 "Neighbor IP address\n"
2815 "Dead Neighbor Polling interval\n"
2818 ALIAS (no_ospf_neighbor
,
2819 no_ospf_neighbor_poll_interval_priority_cmd
,
2820 "no neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2823 "Neighbor IP address\n"
2824 "Dead Neighbor Polling interval\n"
2826 "OSPF priority of non-broadcast neighbor\n"
2829 ALIAS (no_ospf_neighbor
,
2830 no_ospf_neighbor_priority_pollinterval_cmd
,
2831 "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2834 "Neighbor IP address\n"
2835 "Neighbor Priority\n"
2837 "Dead Neighbor Polling interval\n"
2840 DEFUN (ospf_refresh_timer
, ospf_refresh_timer_cmd
,
2841 "refresh timer <10-1800>",
2842 "Adjust refresh parameters\n"
2843 "Set refresh timer\n"
2844 "Timer value in seconds\n")
2846 struct ospf
*ospf
= vty
->index
;
2847 unsigned int interval
;
2852 VTY_GET_INTEGER_RANGE ("refresh timer", interval
, argv
[0], 10, 1800);
2853 interval
= (interval
/ OSPF_LSA_REFRESHER_GRANULARITY
) * OSPF_LSA_REFRESHER_GRANULARITY
;
2855 ospf_timers_refresh_set (ospf
, interval
);
2860 DEFUN (no_ospf_refresh_timer
, no_ospf_refresh_timer_val_cmd
,
2861 "no refresh timer <10-1800>",
2862 "Adjust refresh parameters\n"
2863 "Unset refresh timer\n"
2864 "Timer value in seconds\n")
2866 struct ospf
*ospf
= vty
->index
;
2867 unsigned int interval
;
2874 VTY_GET_INTEGER_RANGE ("refresh timer", interval
, argv
[0], 10, 1800);
2876 if (ospf
->lsa_refresh_interval
!= interval
||
2877 interval
== OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
2881 ospf_timers_refresh_unset (ospf
);
2886 ALIAS (no_ospf_refresh_timer
,
2887 no_ospf_refresh_timer_cmd
,
2889 "Adjust refresh parameters\n"
2890 "Unset refresh timer\n")
2892 DEFUN (ospf_auto_cost_reference_bandwidth
,
2893 ospf_auto_cost_reference_bandwidth_cmd
,
2894 "auto-cost reference-bandwidth <1-4294967>",
2895 "Calculate OSPF interface cost according to bandwidth\n"
2896 "Use reference bandwidth method to assign OSPF cost\n"
2897 "The reference bandwidth in terms of Mbits per second\n")
2899 struct ospf
*ospf
= vty
->index
;
2901 struct listnode
*node
;
2902 struct interface
*ifp
;
2907 refbw
= strtol (argv
[0], NULL
, 10);
2908 if (refbw
< 1 || refbw
> 4294967)
2910 vty_out (vty
, "reference-bandwidth value is invalid%s", VTY_NEWLINE
);
2914 /* If reference bandwidth is changed. */
2915 if ((refbw
) == ospf
->ref_bandwidth
)
2918 ospf
->ref_bandwidth
= refbw
;
2919 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, node
, ifp
))
2920 ospf_if_recalculate_output_cost (ifp
);
2925 DEFUN (no_ospf_auto_cost_reference_bandwidth
,
2926 no_ospf_auto_cost_reference_bandwidth_cmd
,
2927 "no auto-cost reference-bandwidth",
2929 "Calculate OSPF interface cost according to bandwidth\n"
2930 "Use reference bandwidth method to assign OSPF cost\n")
2932 struct ospf
*ospf
= vty
->index
;
2933 struct listnode
*node
, *nnode
;
2934 struct interface
*ifp
;
2939 if (ospf
->ref_bandwidth
== OSPF_DEFAULT_REF_BANDWIDTH
)
2942 ospf
->ref_bandwidth
= OSPF_DEFAULT_REF_BANDWIDTH
;
2943 vty_out (vty
, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE
);
2944 vty_out (vty
, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE
);
2946 for (ALL_LIST_ELEMENTS (om
->iflist
, node
, nnode
, ifp
))
2947 ospf_if_recalculate_output_cost (ifp
);
2952 ALIAS (no_ospf_auto_cost_reference_bandwidth
,
2953 no_ospf_auto_cost_reference_bandwidth_val_cmd
,
2954 "no auto-cost reference-bandwidth <1-4294967>",
2956 "Calculate OSPF interface cost according to bandwidth\n"
2957 "Use reference bandwidth method to assign OSPF cost\n"
2958 "The reference bandwidth in terms of Mbits per second\n")
2960 DEFUN (ospf_write_multiplier
,
2961 ospf_write_multiplier_cmd
,
2962 "ospf write-multiplier <1-100>",
2963 "OSPF specific commands\n"
2964 "Write multiplier\n"
2965 "Maximum number of interface serviced per write\n")
2967 struct ospf
*ospf
= vty
->index
;
2968 u_int32_t write_oi_count
;
2973 write_oi_count
= strtol (argv
[0], NULL
, 10);
2974 if (write_oi_count
< 1 || write_oi_count
> 100)
2976 vty_out (vty
, "write-multiplier value is invalid%s", VTY_NEWLINE
);
2980 ospf
->write_oi_count
= write_oi_count
;
2984 ALIAS (ospf_write_multiplier
,
2985 write_multiplier_cmd
,
2986 "write-multiplier <1-100>",
2987 "Write multiplier\n"
2988 "Maximum number of interface serviced per write\n")
2990 DEFUN (no_ospf_write_multiplier
,
2991 no_ospf_write_multiplier_cmd
,
2992 "no ospf write-multiplier <1-100>",
2994 "OSPF specific commands\n"
2995 "Write multiplier\n"
2996 "Maximum number of interface serviced per write\n")
2998 struct ospf
*ospf
= vty
->index
;
3003 ospf
->write_oi_count
= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
;
3007 ALIAS (no_ospf_write_multiplier
,
3008 no_write_multiplier_cmd
,
3009 "no write-multiplier",
3011 "Write multiplier\n")
3013 ALIAS (no_ospf_write_multiplier
,
3014 no_write_multiplier_val_cmd
,
3015 "no write-multiplier <1-100>",
3017 "Write multiplier\n"
3018 "Maximum number of interface serviced per write\n")
3020 const char *ospf_abr_type_descr_str
[] =
3023 "Standard (RFC2328)",
3025 "Alternative Cisco",
3026 "Alternative Shortcut"
3029 const char *ospf_shortcut_mode_descr_str
[] =
3037 show_ip_ospf_area (struct vty
*vty
, struct ospf_area
*area
, json_object
*json_areas
, u_char use_json
)
3039 json_object
*json_area
= NULL
;
3042 json_area
= json_object_new_object();
3046 vty_out (vty
, " Area ID: %s", inet_ntoa (area
->area_id
));
3048 /* Show Area type/mode. */
3049 if (OSPF_IS_AREA_BACKBONE (area
))
3052 json_object_boolean_true_add(json_area
, "backbone");
3054 vty_out (vty
, " (Backbone)%s", VTY_NEWLINE
);
3060 if (area
->external_routing
== OSPF_AREA_STUB
)
3062 if (area
->no_summary
)
3063 json_object_boolean_true_add(json_area
, "stubNoSummary");
3064 if (area
->shortcut_configured
)
3065 json_object_boolean_true_add(json_area
, "stubShortcut");
3067 else if (area
->external_routing
== OSPF_AREA_NSSA
)
3069 if (area
->no_summary
)
3070 json_object_boolean_true_add(json_area
, "nssaNoSummary");
3071 if (area
->shortcut_configured
)
3072 json_object_boolean_true_add(json_area
, "nssaShortcut");
3075 json_object_string_add(json_area
,"shortcuttingMode",
3076 ospf_shortcut_mode_descr_str
[area
->shortcut_configured
]);
3077 if (area
->shortcut_capability
)
3078 json_object_boolean_true_add(json_area
,"sBitConcensus");
3082 if (area
->external_routing
== OSPF_AREA_STUB
)
3083 vty_out (vty
, " (Stub%s%s)",
3084 area
->no_summary
? ", no summary" : "",
3085 area
->shortcut_configured
? "; " : "");
3086 else if (area
->external_routing
== OSPF_AREA_NSSA
)
3087 vty_out (vty
, " (NSSA%s%s)",
3088 area
->no_summary
? ", no summary" : "",
3089 area
->shortcut_configured
? "; " : "");
3091 vty_out (vty
, "%s", VTY_NEWLINE
);
3092 vty_out (vty
, " Shortcutting mode: %s",
3093 ospf_shortcut_mode_descr_str
[area
->shortcut_configured
]);
3094 vty_out (vty
, ", S-bit consensus: %s%s",
3095 area
->shortcut_capability
? "ok" : "no", VTY_NEWLINE
);
3099 /* Show number of interfaces */
3102 json_object_int_add(json_area
, "areaIfTotalCounter", listcount (area
->oiflist
));
3103 json_object_int_add(json_area
, "areaIfActiveCounter", area
->act_ints
);
3106 vty_out (vty
, " Number of interfaces in this area: Total: %d, "
3107 "Active: %d%s", listcount (area
->oiflist
),
3108 area
->act_ints
, VTY_NEWLINE
);
3110 if (area
->external_routing
== OSPF_AREA_NSSA
)
3114 json_object_boolean_true_add(json_area
, "nssa");
3115 if (! IS_OSPF_ABR (area
->ospf
))
3116 json_object_boolean_false_add(json_area
, "abr");
3117 else if (area
->NSSATranslatorState
)
3119 json_object_boolean_true_add(json_area
, "abr");
3120 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
3121 json_object_boolean_true_add(json_area
, "nssaTranslatorElected");
3122 else if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_ALWAYS
)
3123 json_object_boolean_true_add(json_area
, "nssaTranslatorAlways");
3127 json_object_boolean_true_add(json_area
, "abr");
3128 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
3129 json_object_boolean_false_add(json_area
, "nssaTranslatorElected");
3131 json_object_boolean_true_add(json_area
, "nssaTranslatorNever");
3136 vty_out (vty
, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE
, VTY_NEWLINE
);
3137 if (! IS_OSPF_ABR (area
->ospf
))
3138 vty_out (vty
, " It is not ABR, therefore not Translator. %s",
3140 else if (area
->NSSATranslatorState
)
3142 vty_out (vty
, " We are an ABR and ");
3143 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
3144 vty_out (vty
, "the NSSA Elected Translator. %s",
3146 else if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_ALWAYS
)
3147 vty_out (vty
, "always an NSSA Translator. %s",
3152 vty_out (vty
, " We are an ABR, but ");
3153 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
3154 vty_out (vty
, "not the NSSA Elected Translator. %s",
3157 vty_out (vty
, "never an NSSA Translator. %s",
3163 /* Stub-router state for this area */
3164 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
))
3166 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3170 json_object_boolean_true_add(json_area
, "originStubMaxDistRouterLsa");
3171 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
3172 json_object_boolean_true_add(json_area
, "indefiniteActiveAdmin");
3173 if (area
->t_stub_router
)
3175 struct timeval result
;
3176 unsigned long time_store
= 0;
3177 result
= tv_sub (area
->t_stub_router
->u
.sands
, recent_relative_time());
3178 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3179 json_object_int_add(json_area
, "activeStartupRemainderMsecs", time_store
);
3184 vty_out (vty
, " Originating stub / maximum-distance Router-LSA%s",
3186 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
3187 vty_out (vty
, " Administratively activated (indefinitely)%s",
3189 if (area
->t_stub_router
)
3190 vty_out (vty
, " Active from startup, %s remaining%s",
3191 ospf_timer_dump (area
->t_stub_router
, timebuf
,
3192 sizeof(timebuf
)), VTY_NEWLINE
);
3198 /* Show number of fully adjacent neighbors. */
3199 json_object_int_add(json_area
, "nbrFullAdjacentCounter", area
->full_nbrs
);
3201 /* Show authentication type. */
3202 if (area
->auth_type
== OSPF_AUTH_NULL
)
3203 json_object_string_add(json_area
, "authentication", "authenticationNone");
3204 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
3205 json_object_string_add(json_area
, "authentication", "authenticationSimplePassword");
3206 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
3207 json_object_string_add(json_area
, "authentication", "authenticationMessageDigest");
3209 if (!OSPF_IS_AREA_BACKBONE (area
))
3210 json_object_int_add(json_area
, "virtualAdjacenciesPassingCounter", area
->full_vls
);
3212 /* Show SPF calculation times. */
3213 json_object_int_add(json_area
, "spfExecutedCounter", area
->spf_calculation
);
3214 json_object_int_add(json_area
, "lsaNumber", area
->lsdb
->total
);
3215 json_object_int_add(json_area
, "lsaRouterNumber", ospf_lsdb_count (area
->lsdb
, OSPF_ROUTER_LSA
));
3216 json_object_int_add(json_area
, "lsaRouterChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_ROUTER_LSA
));
3217 json_object_int_add(json_area
, "lsaNetworkNumber", ospf_lsdb_count (area
->lsdb
, OSPF_NETWORK_LSA
));
3218 json_object_int_add(json_area
, "lsaNetworkChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_NETWORK_LSA
));
3219 json_object_int_add(json_area
, "lsaSummaryNumber", ospf_lsdb_count (area
->lsdb
, OSPF_SUMMARY_LSA
));
3220 json_object_int_add(json_area
, "lsaSummaryChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_SUMMARY_LSA
));
3221 json_object_int_add(json_area
, "lsaAsbrNumber", ospf_lsdb_count (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
3222 json_object_int_add(json_area
, "lsaAsbrChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
3223 json_object_int_add(json_area
, "lsaNssaNumber", ospf_lsdb_count (area
->lsdb
, OSPF_AS_NSSA_LSA
));
3224 json_object_int_add(json_area
, "lsaNssaChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_AS_NSSA_LSA
));
3228 /* Show number of fully adjacent neighbors. */
3229 vty_out (vty
, " Number of fully adjacent neighbors in this area:"
3230 " %d%s", area
->full_nbrs
, VTY_NEWLINE
);
3232 /* Show authentication type. */
3233 vty_out (vty
, " Area has ");
3234 if (area
->auth_type
== OSPF_AUTH_NULL
)
3235 vty_out (vty
, "no authentication%s", VTY_NEWLINE
);
3236 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
3237 vty_out (vty
, "simple password authentication%s", VTY_NEWLINE
);
3238 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
3239 vty_out (vty
, "message digest authentication%s", VTY_NEWLINE
);
3241 if (!OSPF_IS_AREA_BACKBONE (area
))
3242 vty_out (vty
, " Number of full virtual adjacencies going through"
3243 " this area: %d%s", area
->full_vls
, VTY_NEWLINE
);
3245 /* Show SPF calculation times. */
3246 vty_out (vty
, " SPF algorithm executed %d times%s",
3247 area
->spf_calculation
, VTY_NEWLINE
);
3249 /* Show number of LSA. */
3250 vty_out (vty
, " Number of LSA %ld%s", area
->lsdb
->total
, VTY_NEWLINE
);
3251 vty_out (vty
, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
3252 ospf_lsdb_count (area
->lsdb
, OSPF_ROUTER_LSA
),
3253 ospf_lsdb_checksum (area
->lsdb
, OSPF_ROUTER_LSA
), VTY_NEWLINE
);
3254 vty_out (vty
, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
3255 ospf_lsdb_count (area
->lsdb
, OSPF_NETWORK_LSA
),
3256 ospf_lsdb_checksum (area
->lsdb
, OSPF_NETWORK_LSA
), VTY_NEWLINE
);
3257 vty_out (vty
, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
3258 ospf_lsdb_count (area
->lsdb
, OSPF_SUMMARY_LSA
),
3259 ospf_lsdb_checksum (area
->lsdb
, OSPF_SUMMARY_LSA
), VTY_NEWLINE
);
3260 vty_out (vty
, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
3261 ospf_lsdb_count (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
),
3262 ospf_lsdb_checksum (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
), VTY_NEWLINE
);
3263 vty_out (vty
, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
3264 ospf_lsdb_count (area
->lsdb
, OSPF_AS_NSSA_LSA
),
3265 ospf_lsdb_checksum (area
->lsdb
, OSPF_AS_NSSA_LSA
), VTY_NEWLINE
);
3270 json_object_int_add(json_area
, "lsaOpaqueLinkNumber", ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
3271 json_object_int_add(json_area
, "lsaOpaqueLinkChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
3272 json_object_int_add(json_area
, "lsaOpaqueAreaNumber", ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
3273 json_object_int_add(json_area
, "lsaOpaqueAreaChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
3277 vty_out (vty
, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
3278 ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
),
3279 ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
), VTY_NEWLINE
);
3280 vty_out (vty
, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
3281 ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
),
3282 ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
), VTY_NEWLINE
);
3286 json_object_object_add(json_areas
, inet_ntoa (area
->area_id
), json_area
);
3288 vty_out (vty
, "%s", VTY_NEWLINE
);
3292 show_ip_ospf_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
3294 struct listnode
*node
, *nnode
;
3295 struct ospf_area
* area
;
3296 struct timeval result
;
3297 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3298 json_object
*json
= NULL
;
3299 json_object
*json_areas
= NULL
;
3303 json
= json_object_new_object();
3304 json_areas
= json_object_new_object();
3311 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3315 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3316 VTY_NEWLINE
, VTY_NEWLINE
);
3320 /* Show Router ID. */
3323 json_object_string_add(json
, "routerId", inet_ntoa (ospf
->router_id
));
3327 vty_out (vty
, " OSPF Routing Process, Router ID: %s%s",
3328 inet_ntoa (ospf
->router_id
),
3332 /* Graceful shutdown */
3333 if (ospf
->t_deferred_shutdown
)
3337 unsigned long time_store
= 0;
3338 result
= tv_sub (ospf
->t_deferred_shutdown
->u
.sands
, recent_relative_time());
3339 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3340 json_object_int_add(json
, "deferredShutdownMsecs", time_store
);
3344 vty_out (vty
, " Deferred shutdown in progress, %s remaining%s",
3345 ospf_timer_dump (ospf
->t_deferred_shutdown
,
3346 timebuf
, sizeof (timebuf
)), VTY_NEWLINE
);
3350 /* Show capability. */
3353 json_object_boolean_true_add(json
, "tosRoutesOnly");
3354 json_object_boolean_true_add(json
, "rfc2328Conform");
3355 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
3357 json_object_boolean_true_add(json
, "rfc1583Compatibility");
3362 vty_out (vty
, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE
);
3363 vty_out (vty
, " This implementation conforms to RFC2328%s", VTY_NEWLINE
);
3364 vty_out (vty
, " RFC1583Compatibility flag is %s%s",
3365 CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
) ?
3366 "enabled" : "disabled", VTY_NEWLINE
);
3371 if (CHECK_FLAG (ospf
->config
, OSPF_OPAQUE_CAPABLE
))
3373 json_object_boolean_true_add(json
, "opaqueCapable");
3378 vty_out (vty
, " OpaqueCapability flag is %s%s",
3379 CHECK_FLAG (ospf
->config
, OSPF_OPAQUE_CAPABLE
) ? "enabled" : "disabled",
3383 /* Show stub-router configuration */
3384 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
3385 || ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3389 json_object_boolean_true_add(json
, "stubAdvertisement");
3390 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3391 json_object_int_add(json
,"postStartEnabledMsecs", ospf
->stub_router_startup_time
/ 1000);
3392 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3393 json_object_int_add(json
,"preShutdownEnabledMsecs", ospf
->stub_router_shutdown_time
/ 1000);
3397 vty_out (vty
, " Stub router advertisement is configured%s",
3399 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3400 vty_out (vty
, " Enabled for %us after start-up%s",
3401 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
3402 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3403 vty_out (vty
, " Enabled for %us prior to full shutdown%s",
3404 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
3408 /* Show SPF timers. */
3411 json_object_int_add(json
, "spfScheduleDelayMsecs", ospf
->spf_delay
);
3412 json_object_int_add(json
, "holdtimeMinMsecs", ospf
->spf_holdtime
);
3413 json_object_int_add(json
, "holdtimeMaxMsecs", ospf
->spf_max_holdtime
);
3414 json_object_int_add(json
, "holdtimeMultplier", ospf
->spf_hold_multiplier
);
3418 vty_out (vty
, " Initial SPF scheduling delay %d millisec(s)%s"
3419 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
3420 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
3421 " Hold time multiplier is currently %d%s",
3422 ospf
->spf_delay
, VTY_NEWLINE
,
3423 ospf
->spf_holdtime
, VTY_NEWLINE
,
3424 ospf
->spf_max_holdtime
, VTY_NEWLINE
,
3425 ospf
->spf_hold_multiplier
, VTY_NEWLINE
);
3430 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
)
3432 unsigned long time_store
= 0;
3434 result
= tv_sub (recent_relative_time(), ospf
->ts_spf
);
3435 result
= tv_sub (result
, recent_relative_time());
3436 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3437 json_object_int_add(json
, "spfLastExecutedMsecs", time_store
);
3439 time_store
= (1000 * ospf
->ts_spf_duration
.tv_sec
) + (ospf
->ts_spf_duration
.tv_usec
/ 1000);
3440 json_object_int_add(json
, "spfLastDurationMsecs", time_store
);
3443 json_object_boolean_true_add(json
, "spfHasNotRun");
3447 vty_out (vty
, " SPF algorithm ");
3448 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
)
3450 result
= tv_sub (recent_relative_time(), ospf
->ts_spf
);
3451 vty_out (vty
, "last executed %s ago%s",
3452 ospf_timeval_dump (&result
, timebuf
, sizeof (timebuf
)),
3454 vty_out (vty
, " Last SPF duration %s%s",
3455 ospf_timeval_dump (&ospf
->ts_spf_duration
, timebuf
, sizeof (timebuf
)),
3459 vty_out (vty
, "has not been run%s", VTY_NEWLINE
);
3464 struct timeval temp_time
;
3465 unsigned long time_store
= 0;
3467 if (ospf
->t_spf_calc
)
3469 temp_time
= tv_sub (ospf
->t_spf_calc
->u
.sands
, recent_relative_time());
3470 time_store
= (1000 * temp_time
.tv_sec
) + (temp_time
.tv_usec
/ 1000);
3471 json_object_int_add(json
, "spfTimerDueInMsecs", time_store
);
3474 json_object_int_add(json
, "lsaMinIntervalMsecs", ospf
->min_ls_interval
);
3475 json_object_int_add(json
, "lsaMinArrivalMsecs", ospf
->min_ls_arrival
);
3476 /* Show write multiplier values */
3477 json_object_int_add(json
, "writeMultiplier", ospf
->write_oi_count
);
3478 /* Show refresh parameters. */
3479 json_object_int_add(json
, "refreshTimerMsecs", ospf
->lsa_refresh_interval
* 1000);
3483 vty_out (vty
, " SPF timer %s%s%s",
3484 (ospf
->t_spf_calc
? "due in " : "is "),
3485 ospf_timer_dump (ospf
->t_spf_calc
, timebuf
, sizeof (timebuf
)),
3488 vty_out (vty
, " LSA minimum interval %d msecs%s",
3489 ospf
->min_ls_interval
, VTY_NEWLINE
);
3490 vty_out (vty
, " LSA minimum arrival %d msecs%s",
3491 ospf
->min_ls_arrival
, VTY_NEWLINE
);
3493 /* Show write multiplier values */
3494 vty_out (vty
, " Write Multiplier set to %d %s",
3495 ospf
->write_oi_count
, VTY_NEWLINE
);
3497 /* Show refresh parameters. */
3498 vty_out (vty
, " Refresh timer %d secs%s",
3499 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
3502 /* Show ABR/ASBR flags. */
3503 if (CHECK_FLAG (ospf
->flags
, OSPF_FLAG_ABR
))
3506 json_object_string_add(json
, "abrType", ospf_abr_type_descr_str
[ospf
->abr_type
]);
3508 vty_out (vty
, " This router is an ABR, ABR type is: %s%s",
3509 ospf_abr_type_descr_str
[ospf
->abr_type
], VTY_NEWLINE
);
3511 if (CHECK_FLAG (ospf
->flags
, OSPF_FLAG_ASBR
))
3514 json_object_string_add(json
, "asbrRouter", "injectingExternalRoutingInformation");
3516 vty_out (vty
, " This router is an ASBR "
3517 "(injecting external routing information)%s", VTY_NEWLINE
);
3520 /* Show Number of AS-external-LSAs. */
3523 json_object_int_add(json
, "lsaExternalCounter",
3524 ospf_lsdb_count (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3525 json_object_int_add(json
, "lsaExternalChecksum",
3526 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3530 vty_out (vty
, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
3531 ospf_lsdb_count (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
),
3532 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
), VTY_NEWLINE
);
3537 json_object_int_add(json
, "lsaAsopaqueCounter",
3538 ospf_lsdb_count (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3539 json_object_int_add(json
, "lsaAsOpaqueChecksum",
3540 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3544 vty_out (vty
, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
3545 ospf_lsdb_count (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
),
3546 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
), VTY_NEWLINE
);
3549 /* Show number of areas attached. */
3551 json_object_int_add(json
, "attachedAreaCounter", listcount (ospf
->areas
));
3553 vty_out (vty
, " Number of areas attached to this router: %d%s",
3554 listcount (ospf
->areas
), VTY_NEWLINE
);
3556 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
))
3558 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
3561 json_object_boolean_true_add(json
, "adjacencyChangesLoggedAll");
3563 vty_out(vty
, " All adjacency changes are logged%s",VTY_NEWLINE
);
3568 json_object_boolean_true_add(json
, "adjacencyChangesLogged");
3570 vty_out(vty
, " Adjacency changes are logged%s",VTY_NEWLINE
);
3573 /* Show each area status. */
3574 for (ALL_LIST_ELEMENTS (ospf
->areas
, node
, nnode
, area
))
3575 show_ip_ospf_area (vty
, area
, json_areas
, use_json
);
3579 json_object_object_add(json
, "areas", json_areas
);
3580 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3581 json_object_free(json
);
3584 vty_out (vty
, "%s",VTY_NEWLINE
);
3589 DEFUN (show_ip_ospf
,
3591 "show ip ospf {json}",
3594 "OSPF information\n"
3595 "JavaScript Object Notation\n")
3598 u_char uj
= use_json(argc
, argv
);
3600 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3603 return (show_ip_ospf_common(vty
, ospf
, uj
));
3606 DEFUN (show_ip_ospf_instance
,
3607 show_ip_ospf_instance_cmd
,
3608 "show ip ospf <1-65535> {json}",
3611 "OSPF information\n"
3613 "JavaScript Object Notation\n")
3616 u_short instance
= 0;
3617 u_char uj
= use_json(argc
, argv
);
3619 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
3620 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
3623 return (show_ip_ospf_common(vty
, ospf
, uj
));
3627 show_ip_ospf_interface_sub (struct vty
*vty
, struct ospf
*ospf
, struct interface
*ifp
,
3628 json_object
*json_interface_sub
, u_char use_json
)
3631 struct ospf_neighbor
*nbr
;
3632 struct route_node
*rn
;
3634 /* Is interface up? */
3637 is_up
= if_is_operative(ifp
);
3639 json_object_boolean_true_add(json_interface_sub
, "ifUp");
3641 json_object_boolean_false_add(json_interface_sub
, "ifDown");
3643 json_object_int_add(json_interface_sub
, "ifIndex", ifp
->ifindex
);
3644 json_object_int_add(json_interface_sub
, "mtuBytes", ifp
->mtu
);
3645 json_object_int_add(json_interface_sub
, "bandwidthMbit", ifp
->bandwidth
);
3646 json_object_string_add(json_interface_sub
, "ifFlags", if_flag_dump(ifp
->flags
));
3650 vty_out (vty
, "%s is %s%s", ifp
->name
,
3651 ((is_up
= if_is_operative(ifp
)) ? "up" : "down"), VTY_NEWLINE
);
3652 vty_out (vty
, " ifindex %u, MTU %u bytes, BW %u Mbit %s%s",
3653 ifp
->ifindex
, ifp
->mtu
, ifp
->bandwidth
, if_flag_dump(ifp
->flags
),
3657 /* Is interface OSPF enabled? */
3660 if (ospf_oi_count(ifp
) == 0)
3662 json_object_boolean_false_add(json_interface_sub
, "ospfEnabled");
3667 json_object_boolean_false_add(json_interface_sub
, "ospfRunning");
3671 json_object_boolean_true_add(json_interface_sub
, "ospfEnabled");
3675 if (ospf_oi_count(ifp
) == 0)
3677 vty_out (vty
, " OSPF not enabled on this interface%s", VTY_NEWLINE
);
3682 vty_out (vty
, " OSPF is enabled, but not running on this interface%s",
3688 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
3690 struct ospf_interface
*oi
= rn
->info
;
3695 if (CHECK_FLAG(oi
->connected
->flags
, ZEBRA_IFA_UNNUMBERED
))
3698 json_object_boolean_true_add(json_interface_sub
, "ifUnnumbered");
3700 vty_out (vty
, " This interface is UNNUMBERED,");
3704 /* Show OSPF interface information. */
3707 json_object_string_add(json_interface_sub
, "ipAddress", inet_ntoa (oi
->address
->u
.prefix4
));
3708 json_object_int_add(json_interface_sub
, "ipAddressPrefixlen", oi
->address
->prefixlen
);
3711 vty_out (vty
, " Internet Address %s/%d,",
3712 inet_ntoa (oi
->address
->u
.prefix4
), oi
->address
->prefixlen
);
3714 if (oi
->connected
->destination
|| oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3716 struct in_addr
*dest
;
3719 if (CONNECTED_PEER(oi
->connected
)
3720 || oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3725 /* For Vlinks, showing the peer address is probably more
3726 * * * * * informative than the local interface that is being used
3728 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3729 dest
= &oi
->vl_data
->peer_addr
;
3731 dest
= &oi
->connected
->destination
->u
.prefix4
;
3735 json_object_string_add(json_interface_sub
, "ospfIfType", dstr
);
3736 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3737 json_object_string_add(json_interface_sub
, "vlinkPeer", inet_ntoa (*dest
));
3739 json_object_string_add(json_interface_sub
, "localIfUsed", inet_ntoa (*dest
));
3742 vty_out (vty
, " %s %s,", dstr
, inet_ntoa (*dest
));
3747 json_object_string_add(json_interface_sub
, "area", ospf_area_desc_string (oi
->area
));
3748 if (OSPF_IF_PARAM(oi
, mtu_ignore
))
3749 json_object_boolean_true_add(json_interface_sub
, "mtuMismatchDetect");
3750 json_object_string_add(json_interface_sub
, "routerId", inet_ntoa (ospf
->router_id
));
3751 json_object_string_add(json_interface_sub
, "networkType", ospf_network_type_str
[oi
->type
]);
3752 json_object_int_add(json_interface_sub
, "cost", oi
->output_cost
);
3753 json_object_int_add(json_interface_sub
, "transmitDelayMsecs", 1000 / OSPF_IF_PARAM (oi
,transmit_delay
));
3754 json_object_string_add(json_interface_sub
, "state", LOOKUP (ospf_ism_state_msg
, oi
->state
));
3755 json_object_int_add(json_interface_sub
, "priority", PRIORITY (oi
));
3759 vty_out (vty
, " Area %s%s", ospf_area_desc_string (oi
->area
),
3762 vty_out (vty
, " MTU mismatch detection:%s%s",
3763 OSPF_IF_PARAM(oi
, mtu_ignore
) ? "disabled" : "enabled", VTY_NEWLINE
);
3765 vty_out (vty
, " Router ID %s, Network Type %s, Cost: %d%s",
3766 inet_ntoa (ospf
->router_id
), ospf_network_type_str
[oi
->type
],
3767 oi
->output_cost
, VTY_NEWLINE
);
3769 vty_out (vty
, " Transmit Delay is %d sec, State %s, Priority %d%s",
3770 OSPF_IF_PARAM (oi
,transmit_delay
), LOOKUP (ospf_ism_state_msg
, oi
->state
),
3771 PRIORITY (oi
), VTY_NEWLINE
);
3774 /* Show DR information. */
3775 if (DR (oi
).s_addr
== 0)
3778 vty_out (vty
, " No backup designated router on this network%s",
3783 nbr
= ospf_nbr_lookup_by_addr (oi
->nbrs
, &BDR (oi
));
3787 vty_out (vty
, " No backup designated router on this network%s",
3794 json_object_string_add(json_interface_sub
, "bdrId", inet_ntoa (nbr
->router_id
));
3795 json_object_string_add(json_interface_sub
, "bdrAddress", inet_ntoa (nbr
->address
.u
.prefix4
));
3799 vty_out (vty
, " Backup Designated Router (ID) %s,",
3800 inet_ntoa (nbr
->router_id
));
3801 vty_out (vty
, " Interface Address %s%s",
3802 inet_ntoa (nbr
->address
.u
.prefix4
), VTY_NEWLINE
);
3807 /* Next network-LSA sequence number we'll use, if we're elected DR */
3808 if (oi
->params
&& ntohl (oi
->params
->network_lsa_seqnum
) != OSPF_INITIAL_SEQUENCE_NUMBER
)
3811 json_object_int_add(json_interface_sub
, "networkLsaSequence", ntohl (oi
->params
->network_lsa_seqnum
));
3813 vty_out (vty
, " Saved Network-LSA sequence number 0x%x%s",
3814 ntohl (oi
->params
->network_lsa_seqnum
), VTY_NEWLINE
);
3819 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3820 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3822 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3823 json_object_boolean_true_add(json_interface_sub
, "mcastMemberOspfAllRouters");
3824 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3825 json_object_boolean_true_add(json_interface_sub
, "mcastMemberOspfDesignatedRouters");
3830 vty_out (vty
, " Multicast group memberships:");
3831 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3832 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3834 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3835 vty_out (vty
, " OSPFAllRouters");
3836 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3837 vty_out (vty
, " OSPFDesignatedRouters");
3840 vty_out (vty
, " <None>");
3841 vty_out (vty
, "%s", VTY_NEWLINE
);
3846 if (OSPF_IF_PARAM (oi
, fast_hello
) == 0)
3847 json_object_int_add(json_interface_sub
, "timerMsecs", 1000 /OSPF_IF_PARAM (oi
, v_hello
));
3849 json_object_int_add(json_interface_sub
, "timerMsecs", 1000 / OSPF_IF_PARAM (oi
, fast_hello
));
3850 json_object_int_add(json_interface_sub
, "timerDeadMsecs", 1000 / OSPF_IF_PARAM (oi
, v_wait
));
3851 json_object_int_add(json_interface_sub
, "timerWaitMsecs", 1000 / OSPF_IF_PARAM (oi
, v_wait
));
3852 json_object_int_add(json_interface_sub
, "timerRetransmit", 1000 / OSPF_IF_PARAM (oi
, retransmit_interval
));
3856 vty_out (vty
, " Timer intervals configured,");
3857 vty_out (vty
, " Hello ");
3858 if (OSPF_IF_PARAM (oi
, fast_hello
) == 0)
3859 vty_out (vty
, "%ds,", OSPF_IF_PARAM (oi
, v_hello
));
3861 vty_out (vty
, "%dms,", 1000 / OSPF_IF_PARAM (oi
, fast_hello
));
3862 vty_out (vty
, " Dead %ds, Wait %ds, Retransmit %d%s",
3863 OSPF_IF_PARAM (oi
, v_wait
),
3864 OSPF_IF_PARAM (oi
, v_wait
),
3865 OSPF_IF_PARAM (oi
, retransmit_interval
),
3869 if (OSPF_IF_PASSIVE_STATUS (oi
) == OSPF_IF_ACTIVE
)
3871 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3874 struct timeval result
;
3875 unsigned long time_store
= 0;
3877 result
= tv_sub (oi
->t_hello
->u
.sands
, recent_relative_time());
3883 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3884 json_object_int_add(json_interface_sub
, "timerHelloInMsecs", time_store
);
3887 vty_out (vty
, " Hello due in %s%s",
3888 ospf_timer_dump (oi
->t_hello
, timebuf
, sizeof(timebuf
)),
3891 else /* passive-interface is set */
3894 json_object_boolean_true_add(json_interface_sub
, "timerPassiveIface");
3896 vty_out (vty
, " No Hellos (Passive interface)%s", VTY_NEWLINE
);
3901 json_object_int_add(json_interface_sub
, "nbrCount", ospf_nbr_count (oi
, 0));
3902 json_object_int_add(json_interface_sub
, "nbrAdjacentCount", ospf_nbr_count (oi
, NSM_Full
));
3905 vty_out (vty
, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
3906 ospf_nbr_count (oi
, 0), ospf_nbr_count (oi
, NSM_Full
),
3908 ospf_bfd_interface_show(vty
, ifp
, json_interface_sub
, use_json
);
3913 show_ip_ospf_interface_common (struct vty
*vty
, struct ospf
*ospf
, int argc
,
3914 const char **argv
, int iface_argv
, u_char use_json
)
3916 struct interface
*ifp
;
3917 struct listnode
*node
;
3918 json_object
*json
= NULL
;
3919 json_object
*json_interface_sub
= NULL
;
3923 json
= json_object_new_object();
3924 json_interface_sub
= json_object_new_object();
3930 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3932 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3933 VTY_NEWLINE
, VTY_NEWLINE
);
3936 if (argc
== (iface_argv
+ 1))
3938 /* Show All Interfaces.*/
3939 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
3941 if (ospf_oi_count(ifp
))
3943 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3945 json_object_object_add (json
, ifp
->name
, json_interface_sub
);
3949 else if (argv
[iface_argv
] && strcmp(argv
[iface_argv
], "json") == 0)
3953 json
= json_object_new_object();
3954 json_interface_sub
= json_object_new_object ();
3957 /* Show All Interfaces. */
3958 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
3960 if (ospf_oi_count(ifp
))
3962 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3964 json_object_object_add(json
, ifp
->name
, json_interface_sub
);
3970 /* Interface name is specified. */
3971 if ((ifp
= if_lookup_by_name (argv
[iface_argv
])) == NULL
)
3974 json_object_boolean_true_add(json
, "noSuchIface");
3976 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
3980 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3982 json_object_object_add(json
, ifp
->name
, json_interface_sub
);
3988 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3989 json_object_free(json
);
3992 vty_out (vty
, "%s", VTY_NEWLINE
);
3997 DEFUN (show_ip_ospf_interface
,
3998 show_ip_ospf_interface_cmd
,
3999 "show ip ospf interface [INTERFACE] {json}",
4002 "OSPF information\n"
4003 "Interface information\n"
4005 "JavaScript Object Notation\n")
4008 u_char uj
= use_json(argc
, argv
);
4010 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4013 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 0, uj
);
4016 DEFUN (show_ip_ospf_instance_interface
,
4017 show_ip_ospf_instance_interface_cmd
,
4018 "show ip ospf <1-65535> interface [INTERFACE] {json}",
4021 "OSPF information\n"
4023 "Interface information\n"
4025 "JavaScript Object Notation\n")
4028 u_short instance
= 0;
4029 u_char uj
= use_json(argc
, argv
);
4031 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
4032 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
4035 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 1, uj
);
4039 show_ip_ospf_neighbour_header (struct vty
*vty
)
4041 vty_out (vty
, "%s%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
4043 "Neighbor ID", "Pri", "State", "Dead Time",
4044 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
4049 show_ip_ospf_neighbor_sub (struct vty
*vty
, struct ospf_interface
*oi
, json_object
*json
, u_char use_json
)
4051 struct route_node
*rn
;
4052 struct ospf_neighbor
*nbr
;
4054 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4055 json_object
*json_neighbor
= NULL
;
4057 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4059 if ((nbr
= rn
->info
))
4061 /* Do not show myself. */
4062 if (nbr
!= oi
->nbr_self
)
4064 /* Down state is not shown. */
4065 if (nbr
->state
!= NSM_Down
)
4069 json_neighbor
= json_object_new_object();
4070 ospf_nbr_state_message (nbr
, msgbuf
, 16);
4072 struct timeval result
;
4073 unsigned long time_store
= 0;
4075 result
= tv_sub (nbr
->t_inactivity
->u
.sands
, recent_relative_time());
4076 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
4078 json_object_int_add (json_neighbor
, "priority", nbr
->priority
);
4079 json_object_string_add (json_neighbor
, "state", msgbuf
);
4080 json_object_int_add (json_neighbor
, "deadTimeMsecs", time_store
);
4081 json_object_string_add (json_neighbor
, "address", inet_ntoa (nbr
->src
));
4082 json_object_string_add (json_neighbor
, "ifaceName", IF_NAME (oi
));
4083 json_object_int_add (json_neighbor
, "retransmitCounter", ospf_ls_retransmit_count (nbr
));
4084 json_object_int_add (json_neighbor
, "requestCounter", ospf_ls_request_count (nbr
));
4085 json_object_int_add (json_neighbor
, "dbSummaryCounter", ospf_db_summary_count (nbr
));
4086 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4087 json_object_object_add(json
, "neighbor", json_neighbor
);
4089 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_neighbor
);
4093 ospf_nbr_state_message (nbr
, msgbuf
, 16);
4095 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4096 vty_out (vty
, "%-15s %3d %-15s ",
4100 vty_out (vty
, "%-15s %3d %-15s ",
4101 inet_ntoa (nbr
->router_id
), nbr
->priority
,
4104 vty_out (vty
, "%9s ",
4105 ospf_timer_dump (nbr
->t_inactivity
, timebuf
,
4107 vty_out (vty
, "%-15s ", inet_ntoa (nbr
->src
));
4108 vty_out (vty
, "%-20s %5ld %5ld %5d%s",
4109 IF_NAME (oi
), ospf_ls_retransmit_count (nbr
),
4110 ospf_ls_request_count (nbr
), ospf_db_summary_count (nbr
),
4120 show_ip_ospf_neighbor_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4122 struct ospf_interface
*oi
;
4123 struct listnode
*node
;
4124 json_object
*json
= NULL
;
4127 json
= json_object_new_object();
4129 show_ip_ospf_neighbour_header (vty
);
4134 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4136 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4137 VTY_NEWLINE
, VTY_NEWLINE
);
4140 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4141 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
4145 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4146 json_object_free(json
);
4149 vty_out (vty
, "%s", VTY_NEWLINE
);
4154 DEFUN (show_ip_ospf_neighbor
,
4155 show_ip_ospf_neighbor_cmd
,
4156 "show ip ospf neighbor {json}",
4159 "OSPF information\n"
4161 "JavaScript Object Notation\n")
4164 u_char uj
= use_json(argc
, argv
);
4166 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4169 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
4173 DEFUN (show_ip_ospf_instance_neighbor
,
4174 show_ip_ospf_instance_neighbor_cmd
,
4175 "show ip ospf <1-65535> neighbor {json}",
4178 "OSPF information\n"
4181 "JavaScript Object Notation\n")
4184 u_short instance
= 0;
4185 u_char uj
= use_json(argc
, argv
);
4187 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
4188 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4191 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
4195 show_ip_ospf_neighbor_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4197 struct listnode
*node
;
4198 struct ospf_interface
*oi
;
4199 json_object
*json
= NULL
;
4200 json_object
*json_neighbor_sub
= NULL
;
4204 json
= json_object_new_object();
4205 json_neighbor_sub
= json_object_new_object();
4208 show_ip_ospf_neighbour_header (vty
);
4213 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4215 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4216 VTY_NEWLINE
, VTY_NEWLINE
);
4219 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4221 struct listnode
*nbr_node
;
4222 struct ospf_nbr_nbma
*nbr_nbma
;
4224 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
4226 /* print Down neighbor status */
4227 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nbr_node
, nbr_nbma
))
4229 if (nbr_nbma
->nbr
== NULL
4230 || nbr_nbma
->nbr
->state
== NSM_Down
)
4234 json_object_int_add (json_neighbor_sub
, "nbrNbmaPriority", nbr_nbma
->priority
);
4235 json_object_boolean_true_add (json_neighbor_sub
, "nbrNbmaDown");
4236 json_object_string_add (json_neighbor_sub
, "nbrNbmaIfaceName", IF_NAME (oi
));
4237 json_object_int_add (json_neighbor_sub
, "nbrNbmaRetransmitCounter", 0);
4238 json_object_int_add (json_neighbor_sub
, "nbrNbmaRequestCounter", 0);
4239 json_object_int_add (json_neighbor_sub
, "nbrNbmaDbSummaryCounter", 0);
4240 json_object_object_add(json
, inet_ntoa (nbr_nbma
->addr
), json_neighbor_sub
);
4244 vty_out (vty
, "%-15s %3d %-15s %9s ",
4245 "-", nbr_nbma
->priority
, "Down", "-");
4246 vty_out (vty
, "%-15s %-20s %5d %5d %5d%s",
4247 inet_ntoa (nbr_nbma
->addr
), IF_NAME (oi
),
4248 0, 0, 0, VTY_NEWLINE
);
4256 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4257 json_object_free(json
);
4260 vty_out (vty
, "%s", VTY_NEWLINE
);
4265 DEFUN (show_ip_ospf_neighbor_all
,
4266 show_ip_ospf_neighbor_all_cmd
,
4267 "show ip ospf neighbor all {json}",
4270 "OSPF information\n"
4272 "include down status neighbor\n"
4273 "JavaScript Object Notation\n")
4276 u_char uj
= use_json(argc
, argv
);
4278 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4281 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
4284 DEFUN (show_ip_ospf_instance_neighbor_all
,
4285 show_ip_ospf_instance_neighbor_all_cmd
,
4286 "show ip ospf <1-65535> neighbor all {json}",
4289 "OSPF information\n"
4292 "include down status neighbor\n"
4293 "JavaScript Object Notation\n")
4296 u_short instance
= 0;
4297 u_char uj
= use_json(argc
, argv
);
4299 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
4300 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4303 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
4307 show_ip_ospf_neighbor_int_common (struct vty
*vty
, struct ospf
*ospf
, int arg_base
,
4308 const char **argv
, u_char use_json
)
4310 struct interface
*ifp
;
4311 struct route_node
*rn
;
4312 json_object
*json
= NULL
;
4315 json
= json_object_new_object();
4317 show_ip_ospf_neighbour_header (vty
);
4322 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4324 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4325 VTY_NEWLINE
, VTY_NEWLINE
);
4328 ifp
= if_lookup_by_name (argv
[arg_base
]);
4332 json_object_boolean_true_add(json
, "noSuchIface");
4334 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
4338 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
4340 struct ospf_interface
*oi
= rn
->info
;
4345 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
4350 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4351 json_object_free(json
);
4354 vty_out (vty
, "%s", VTY_NEWLINE
);
4359 DEFUN (show_ip_ospf_neighbor_int
,
4360 show_ip_ospf_neighbor_int_cmd
,
4361 "show ip ospf neighbor IFNAME {json}",
4364 "OSPF information\n"
4367 "JavaScript Object Notation\n")
4370 u_char uj
= use_json(argc
, argv
);
4372 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4375 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 0, argv
, uj
);
4378 DEFUN (show_ip_ospf_instance_neighbor_int
,
4379 show_ip_ospf_instance_neighbor_int_cmd
,
4380 "show ip ospf <1-65535> neighbor IFNAME {json}",
4383 "OSPF information\n"
4387 "JavaScript Object Notation\n")
4390 u_short instance
= 0;
4391 u_char uj
= use_json(argc
, argv
);
4393 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
4394 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4397 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 1, argv
, uj
);
4401 show_ip_ospf_nbr_nbma_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
, struct ospf_nbr_nbma
*nbr_nbma
,
4402 u_char use_json
, json_object
*json
)
4404 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4405 json_object
*json_sub
= NULL
;
4408 json_sub
= json_object_new_object();
4409 else /* Show neighbor ID. */
4410 vty_out (vty
, " Neighbor %s,", "-");
4412 /* Show interface address. */
4414 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr_nbma
->addr
));
4416 vty_out (vty
, " interface address %s%s",
4417 inet_ntoa (nbr_nbma
->addr
), VTY_NEWLINE
);
4422 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4423 json_object_string_add(json_sub
, "iface", IF_NAME (oi
));
4426 vty_out (vty
, " In the area %s via interface %s%s",
4427 ospf_area_desc_string (oi
->area
), IF_NAME (oi
), VTY_NEWLINE
);
4429 /* Show neighbor priority and state. */
4432 json_object_int_add(json_sub
, "nbrPriority", nbr_nbma
->priority
);
4433 json_object_string_add(json_sub
, "nbrState", "down");
4436 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4437 nbr_nbma
->priority
, "Down");
4439 /* Show state changes. */
4441 json_object_int_add(json_sub
, "stateChangeCounter", nbr_nbma
->state_change
);
4443 vty_out (vty
, " %d state changes%s", nbr_nbma
->state_change
, VTY_NEWLINE
);
4445 /* Show PollInterval */
4447 json_object_int_add(json_sub
, "pollInterval", nbr_nbma
->v_poll
);
4449 vty_out (vty
, " Poll interval %d%s", nbr_nbma
->v_poll
, VTY_NEWLINE
);
4451 /* Show poll-interval timer. */
4454 struct timeval res
= tv_sub (nbr_nbma
->t_poll
->u
.sands
, recent_relative_time ());
4455 unsigned long time_store
= 0;
4456 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4457 json_object_int_add(json_sub
, "pollIntervalTimerDueMsec", time_store
);
4460 vty_out (vty
, " Poll timer due in %s%s",
4461 ospf_timer_dump (nbr_nbma
->t_poll
, timebuf
, sizeof(timebuf
)),
4464 /* Show poll-interval timer thread. */
4467 if (nbr_nbma
->t_poll
!= NULL
)
4468 json_object_string_add(json_sub
, "pollIntervalTimerThread", "on");
4471 vty_out (vty
, " Thread Poll Timer %s%s",
4472 nbr_nbma
->t_poll
!= NULL
? "on" : "off", VTY_NEWLINE
);
4475 json_object_object_add(json
, "noNbrId", json_sub
);
4479 show_ip_ospf_neighbor_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
,
4480 struct ospf_neighbor
*nbr
, u_char use_json
, json_object
*json
)
4482 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4483 json_object
*json_sub
= NULL
;
4486 json_sub
= json_object_new_object();
4489 /* Show neighbor ID. */
4490 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4491 vty_out (vty
, " Neighbor %s,", "-");
4493 vty_out (vty
, " Neighbor %s,", inet_ntoa (nbr
->router_id
));
4496 /* Show interface address. */
4498 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr
->address
.u
.prefix4
));
4500 vty_out (vty
, " interface address %s%s",
4501 inet_ntoa (nbr
->address
.u
.prefix4
), VTY_NEWLINE
);
4506 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4507 json_object_string_add(json_sub
, "ifaceName", oi
->ifp
->name
);
4510 vty_out (vty
, " In the area %s via interface %s%s",
4511 ospf_area_desc_string (oi
->area
), oi
->ifp
->name
, VTY_NEWLINE
);
4513 /* Show neighbor priority and state. */
4516 json_object_int_add(json_sub
, "nbrPriority", nbr
->priority
);
4517 json_object_string_add(json_sub
, "nbrState", LOOKUP (ospf_nsm_state_msg
, nbr
->state
));
4520 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4521 nbr
->priority
, LOOKUP (ospf_nsm_state_msg
, nbr
->state
));
4523 /* Show state changes. */
4525 json_object_int_add(json_sub
, "stateChangeCounter", nbr
->state_change
);
4527 vty_out (vty
, " %d state changes%s", nbr
->state_change
, VTY_NEWLINE
);
4529 if (nbr
->ts_last_progress
.tv_sec
|| nbr
->ts_last_progress
.tv_usec
)
4531 struct timeval res
= tv_sub (recent_relative_time (), nbr
->ts_last_progress
);
4534 unsigned long time_store
= 0;
4535 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4536 json_object_int_add(json_sub
, "lastPrgrsvChangeMsec", time_store
);
4540 vty_out (vty
, " Most recent state change statistics:%s",
4542 vty_out (vty
, " Progressive change %s ago%s",
4543 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4548 if (nbr
->ts_last_regress
.tv_sec
|| nbr
->ts_last_regress
.tv_usec
)
4550 struct timeval res
= tv_sub (recent_relative_time (), nbr
->ts_last_regress
);
4553 unsigned long time_store
= 0;
4554 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4555 json_object_int_add(json_sub
, "lastRegressiveChangeMsec", time_store
);
4556 if (nbr
->last_regress_str
)
4557 json_object_string_add(json_sub
, "lastRegressiveChangeReason", nbr
->last_regress_str
);
4561 vty_out (vty
, " Regressive change %s ago, due to %s%s",
4562 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4563 (nbr
->last_regress_str
? nbr
->last_regress_str
: "??"),
4568 /* Show Designated Rotuer ID. */
4570 json_object_string_add(json_sub
, "routerDesignatedId", inet_ntoa (nbr
->d_router
));
4572 vty_out (vty
, " DR is %s,", inet_ntoa (nbr
->d_router
));
4574 /* Show Backup Designated Rotuer ID. */
4576 json_object_string_add(json_sub
, "routerDesignatedBackupId", inet_ntoa (nbr
->bd_router
));
4578 vty_out (vty
, " BDR is %s%s", inet_ntoa (nbr
->bd_router
), VTY_NEWLINE
);
4583 json_object_int_add(json_sub
, "optionsCounter", nbr
->options
);
4584 json_object_string_add(json_sub
, "optionsList", ospf_options_dump (nbr
->options
));
4587 vty_out (vty
, " Options %d %s%s", nbr
->options
,
4588 ospf_options_dump (nbr
->options
), VTY_NEWLINE
);
4590 /* Show Router Dead interval timer. */
4593 if (nbr
->t_inactivity
)
4595 struct timeval res
= tv_sub (nbr
->t_inactivity
->u
.sands
, recent_relative_time ());
4596 unsigned long time_store
= 0;
4597 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4598 json_object_int_add(json_sub
, "routerDeadIntervalTimerDueMsec", time_store
);
4601 json_object_int_add(json_sub
, "routerDeadIntervalTimerDueMsec", -1);
4604 vty_out (vty
, " Dead timer due in %s%s",
4605 ospf_timer_dump (nbr
->t_inactivity
, timebuf
, sizeof (timebuf
)),
4608 /* Show Database Summary list. */
4610 json_object_int_add(json_sub
, "databaseSummaryListCounter", ospf_db_summary_count (nbr
));
4612 vty_out (vty
, " Database Summary List %d%s",
4613 ospf_db_summary_count (nbr
), VTY_NEWLINE
);
4615 /* Show Link State Request list. */
4617 json_object_int_add(json_sub
, "linkStateRequestListCounter", ospf_ls_request_count (nbr
));
4619 vty_out (vty
, " Link State Request List %ld%s",
4620 ospf_ls_request_count (nbr
), VTY_NEWLINE
);
4622 /* Show Link State Retransmission list. */
4624 json_object_int_add(json_sub
, "linkStateRetransmissionListCounter", ospf_ls_retransmit_count (nbr
));
4626 vty_out (vty
, " Link State Retransmission List %ld%s",
4627 ospf_ls_retransmit_count (nbr
), VTY_NEWLINE
);
4629 /* Show inactivity timer thread. */
4632 if (nbr
->t_inactivity
!= NULL
)
4633 json_object_string_add(json_sub
, "threadInactivityTimer", "on");
4636 vty_out (vty
, " Thread Inactivity Timer %s%s",
4637 nbr
->t_inactivity
!= NULL
? "on" : "off", VTY_NEWLINE
);
4639 /* Show Database Description retransmission thread. */
4642 if (nbr
->t_db_desc
!= NULL
)
4643 json_object_string_add(json_sub
, "threadDatabaseDescriptionRetransmission", "on");
4646 vty_out (vty
, " Thread Database Description Retransmision %s%s",
4647 nbr
->t_db_desc
!= NULL
? "on" : "off", VTY_NEWLINE
);
4649 /* Show Link State Request Retransmission thread. */
4652 if (nbr
->t_ls_req
!= NULL
)
4653 json_object_string_add(json_sub
, "threadLinkStateRequestRetransmission", "on");
4656 vty_out (vty
, " Thread Link State Request Retransmission %s%s",
4657 nbr
->t_ls_req
!= NULL
? "on" : "off", VTY_NEWLINE
);
4659 /* Show Link State Update Retransmission thread. */
4662 if (nbr
->t_ls_upd
!= NULL
)
4663 json_object_string_add(json_sub
, "threadLinkStateUpdateRetransmission", "on");
4666 vty_out (vty
, " Thread Link State Update Retransmission %s%s%s",
4667 nbr
->t_ls_upd
!= NULL
? "on" : "off", VTY_NEWLINE
, VTY_NEWLINE
);
4671 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4672 json_object_object_add(json
, "noNbrId", json_sub
);
4674 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_sub
);
4677 ospf_bfd_show_info(vty
, nbr
->bfd_info
, json
, use_json
, 0);
4681 show_ip_ospf_neighbor_id_common (struct vty
*vty
, struct ospf
*ospf
,
4682 int arg_base
, const char **argv
, u_char use_json
)
4684 struct listnode
*node
;
4685 struct ospf_neighbor
*nbr
;
4686 struct ospf_interface
*oi
;
4687 struct in_addr router_id
;
4689 json_object
*json
= NULL
;
4692 json
= json_object_new_object();
4697 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4699 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4700 VTY_NEWLINE
, VTY_NEWLINE
);
4703 ret
= inet_aton (argv
[arg_base
], &router_id
);
4707 vty_out (vty
, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE
);
4711 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4713 if ((nbr
= ospf_nbr_lookup_by_routerid (oi
->nbrs
, &router_id
)))
4715 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4721 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4722 json_object_free(json
);
4725 vty_out (vty
, "%s", VTY_NEWLINE
);
4730 DEFUN (show_ip_ospf_neighbor_id
,
4731 show_ip_ospf_neighbor_id_cmd
,
4732 "show ip ospf neighbor A.B.C.D {json}",
4735 "OSPF information\n"
4738 "JavaScript Object Notation\n")
4741 u_char uj
= use_json(argc
, argv
);
4743 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4746 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 0, argv
, uj
);
4749 DEFUN (show_ip_ospf_instance_neighbor_id
,
4750 show_ip_ospf_instance_neighbor_id_cmd
,
4751 "show ip ospf <1-65535> neighbor A.B.C.D {json}",
4754 "OSPF information\n"
4758 "JavaScript Object Notation\n")
4761 u_short instance
= 0;
4762 u_char uj
= use_json(argc
, argv
);
4764 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
4765 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4768 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 1, argv
, uj
);
4772 show_ip_ospf_neighbor_detail_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4774 struct ospf_interface
*oi
;
4775 struct listnode
*node
;
4776 json_object
*json
= NULL
;
4779 json
= json_object_new_object();
4784 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4786 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4787 VTY_NEWLINE
, VTY_NEWLINE
);
4790 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4792 struct route_node
*rn
;
4793 struct ospf_neighbor
*nbr
;
4795 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4797 if ((nbr
= rn
->info
))
4799 if (nbr
!= oi
->nbr_self
)
4801 if (nbr
->state
!= NSM_Down
)
4803 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4812 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4813 json_object_free(json
);
4816 vty_out (vty
, "%s", VTY_NEWLINE
);
4821 DEFUN (show_ip_ospf_neighbor_detail
,
4822 show_ip_ospf_neighbor_detail_cmd
,
4823 "show ip ospf neighbor detail {json}",
4826 "OSPF information\n"
4828 "detail of all neighbors\n"
4829 "JavaScript Object Notation\n")
4832 u_char uj
= use_json(argc
, argv
);
4834 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4837 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4840 DEFUN (show_ip_ospf_instance_neighbor_detail
,
4841 show_ip_ospf_instance_neighbor_detail_cmd
,
4842 "show ip ospf <1-65535> neighbor detail {json}",
4845 "OSPF information\n"
4848 "detail of all neighbors\n"
4849 "JavaScript Object Notation\n")
4852 u_short instance
= 0;
4853 u_char uj
= use_json(argc
, argv
);
4855 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
4856 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
4859 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4863 show_ip_ospf_neighbor_detail_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4865 struct listnode
*node
;
4866 struct ospf_interface
*oi
;
4867 json_object
*json
= NULL
;
4870 json
= json_object_new_object();
4875 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4877 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4878 VTY_NEWLINE
, VTY_NEWLINE
);
4881 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4883 struct route_node
*rn
;
4884 struct ospf_neighbor
*nbr
;
4885 struct ospf_nbr_nbma
*nbr_nbma
;
4887 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4888 if ((nbr
= rn
->info
))
4889 if (nbr
!= oi
->nbr_self
)
4890 if (nbr
->state
!= NSM_Down
)
4891 show_ip_ospf_neighbor_detail_sub (vty
, oi
, rn
->info
, use_json
, json
);
4893 if (oi
->type
== OSPF_IFTYPE_NBMA
)
4895 struct listnode
*nd
;
4897 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nd
, nbr_nbma
))
4899 if (nbr_nbma
->nbr
== NULL
|| nbr_nbma
->nbr
->state
== NSM_Down
)
4900 show_ip_ospf_nbr_nbma_detail_sub (vty
, oi
, nbr_nbma
, use_json
, json
);
4907 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4908 json_object_free(json
);
4912 vty_out (vty
, "%s", VTY_NEWLINE
);
4918 DEFUN (show_ip_ospf_neighbor_detail_all
,
4919 show_ip_ospf_neighbor_detail_all_cmd
,
4920 "show ip ospf neighbor detail all {json}",
4923 "OSPF information\n"
4925 "detail of all neighbors\n"
4926 "include down status neighbor\n"
4927 "JavaScript Object Notation\n")
4930 u_char uj
= use_json(argc
, argv
);
4932 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4935 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4938 DEFUN (show_ip_ospf_instance_neighbor_detail_all
,
4939 show_ip_ospf_instance_neighbor_detail_all_cmd
,
4940 "show ip ospf <1-65535> neighbor detail all {json}",
4943 "OSPF information\n"
4946 "detail of all neighbors\n"
4947 "include down status neighbor\n"
4948 "JavaScript Object Notation\n")
4951 u_short instance
= 0;
4952 u_char uj
= use_json(argc
, argv
);
4954 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
4955 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4958 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4962 show_ip_ospf_neighbor_int_detail_common (struct vty
*vty
, struct ospf
*ospf
,
4963 int arg_base
, const char **argv
, u_char use_json
)
4965 struct ospf_interface
*oi
;
4966 struct interface
*ifp
;
4967 struct route_node
*rn
, *nrn
;
4968 struct ospf_neighbor
*nbr
;
4969 json_object
*json
= NULL
;
4972 json
= json_object_new_object();
4977 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4979 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4980 VTY_NEWLINE
, VTY_NEWLINE
);
4983 ifp
= if_lookup_by_name (argv
[arg_base
]);
4987 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
4991 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
4993 if ((oi
= rn
->info
))
4995 for (nrn
= route_top (oi
->nbrs
); nrn
; nrn
= route_next (nrn
))
4997 if ((nbr
= nrn
->info
))
4999 if (nbr
!= oi
->nbr_self
)
5001 if (nbr
->state
!= NSM_Down
)
5002 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
5011 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
5012 json_object_free(json
);
5015 vty_out (vty
, "%s", VTY_NEWLINE
);
5020 DEFUN (show_ip_ospf_neighbor_int_detail
,
5021 show_ip_ospf_neighbor_int_detail_cmd
,
5022 "show ip ospf neighbor IFNAME detail {json}",
5025 "OSPF information\n"
5028 "detail of all neighbors\n"
5029 "JavaScript Object Notation\n")
5032 u_char uj
= use_json(argc
, argv
);
5034 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5037 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 0, argv
, uj
);
5040 DEFUN (show_ip_ospf_instance_neighbor_int_detail
,
5041 show_ip_ospf_instance_neighbor_int_detail_cmd
,
5042 "show ip ospf <1-65535> neighbor IFNAME detail {json}",
5045 "OSPF information\n"
5049 "detail of all neighbors\n"
5050 "JavaScript Object Notation\n")
5053 u_short instance
= 0;
5054 u_char uj
= use_json(argc
, argv
);
5056 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
5057 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
5060 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 1, argv
, uj
);
5063 /* Show functions */
5065 show_lsa_summary (struct vty
*vty
, struct ospf_lsa
*lsa
, int self
)
5067 struct router_lsa
*rl
;
5068 struct summary_lsa
*sl
;
5069 struct as_external_lsa
*asel
;
5070 struct prefix_ipv4 p
;
5073 /* If self option is set, check LSA self flag. */
5074 if (self
== 0 || IS_LSA_SELF (lsa
))
5076 /* LSA common part show. */
5077 vty_out (vty
, "%-15s ", inet_ntoa (lsa
->data
->id
));
5078 vty_out (vty
, "%-15s %4d 0x%08lx 0x%04x",
5079 inet_ntoa (lsa
->data
->adv_router
), LS_AGE (lsa
),
5080 (u_long
)ntohl (lsa
->data
->ls_seqnum
), ntohs (lsa
->data
->checksum
));
5081 /* LSA specific part show. */
5082 switch (lsa
->data
->type
)
5084 case OSPF_ROUTER_LSA
:
5085 rl
= (struct router_lsa
*) lsa
->data
;
5086 vty_out (vty
, " %-d", ntohs (rl
->links
));
5088 case OSPF_SUMMARY_LSA
:
5089 sl
= (struct summary_lsa
*) lsa
->data
;
5092 p
.prefix
= sl
->header
.id
;
5093 p
.prefixlen
= ip_masklen (sl
->mask
);
5094 apply_mask_ipv4 (&p
);
5096 vty_out (vty
, " %s/%d", inet_ntoa (p
.prefix
), p
.prefixlen
);
5098 case OSPF_AS_EXTERNAL_LSA
:
5099 case OSPF_AS_NSSA_LSA
:
5100 asel
= (struct as_external_lsa
*) lsa
->data
;
5103 p
.prefix
= asel
->header
.id
;
5104 p
.prefixlen
= ip_masklen (asel
->mask
);
5105 apply_mask_ipv4 (&p
);
5107 vty_out (vty
, " %s %s/%d [0x%lx]",
5108 IS_EXTERNAL_METRIC (asel
->e
[0].tos
) ? "E2" : "E1",
5109 inet_ntoa (p
.prefix
), p
.prefixlen
,
5110 (u_long
)ntohl (asel
->e
[0].route_tag
));
5112 case OSPF_NETWORK_LSA
:
5113 case OSPF_ASBR_SUMMARY_LSA
:
5114 case OSPF_OPAQUE_LINK_LSA
:
5115 case OSPF_OPAQUE_AREA_LSA
:
5116 case OSPF_OPAQUE_AS_LSA
:
5120 vty_out (vty
, VTY_NEWLINE
);
5126 static const char *show_database_desc
[] =
5129 "Router Link States",
5131 "Summary Link States",
5132 "ASBR-Summary Link States",
5133 "AS External Link States",
5134 "Group Membership LSA",
5135 "NSSA-external Link States",
5137 "Link-Local Opaque-LSA",
5138 "Area-Local Opaque-LSA",
5139 "AS-external Opaque-LSA",
5142 static const char *show_database_header
[] =
5145 "Link ID ADV Router Age Seq# CkSum Link count",
5146 "Link ID ADV Router Age Seq# CkSum",
5147 "Link ID ADV Router Age Seq# CkSum Route",
5148 "Link ID ADV Router Age Seq# CkSum",
5149 "Link ID ADV Router Age Seq# CkSum Route",
5150 " --- header for Group Member ----",
5151 "Link ID ADV Router Age Seq# CkSum Route",
5153 "Opaque-Type/Id ADV Router Age Seq# CkSum",
5154 "Opaque-Type/Id ADV Router Age Seq# CkSum",
5155 "Opaque-Type/Id ADV Router Age Seq# CkSum",
5159 show_ip_ospf_database_header (struct vty
*vty
, struct ospf_lsa
*lsa
)
5161 struct router_lsa
*rlsa
= (struct router_lsa
*) lsa
->data
;
5163 vty_out (vty
, " LS age: %d%s", LS_AGE (lsa
), VTY_NEWLINE
);
5164 vty_out (vty
, " Options: 0x%-2x : %s%s",
5166 ospf_options_dump(lsa
->data
->options
),
5168 vty_out (vty
, " LS Flags: 0x%-2x %s%s",
5170 ((lsa
->flags
& OSPF_LSA_LOCAL_XLT
) ? "(Translated from Type-7)" : ""),
5173 if (lsa
->data
->type
== OSPF_ROUTER_LSA
)
5175 vty_out (vty
, " Flags: 0x%x" , rlsa
->flags
);
5178 vty_out (vty
, " :%s%s%s%s",
5179 IS_ROUTER_LSA_BORDER (rlsa
) ? " ABR" : "",
5180 IS_ROUTER_LSA_EXTERNAL (rlsa
) ? " ASBR" : "",
5181 IS_ROUTER_LSA_VIRTUAL (rlsa
) ? " VL-endpoint" : "",
5182 IS_ROUTER_LSA_SHORTCUT (rlsa
) ? " Shortcut" : "");
5184 vty_out (vty
, "%s", VTY_NEWLINE
);
5186 vty_out (vty
, " LS Type: %s%s",
5187 LOOKUP (ospf_lsa_type_msg
, lsa
->data
->type
), VTY_NEWLINE
);
5188 vty_out (vty
, " Link State ID: %s %s%s", inet_ntoa (lsa
->data
->id
),
5189 LOOKUP (ospf_link_state_id_type_msg
, lsa
->data
->type
), VTY_NEWLINE
);
5190 vty_out (vty
, " Advertising Router: %s%s",
5191 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
5192 vty_out (vty
, " LS Seq Number: %08lx%s", (u_long
)ntohl (lsa
->data
->ls_seqnum
),
5194 vty_out (vty
, " Checksum: 0x%04x%s", ntohs (lsa
->data
->checksum
),
5196 vty_out (vty
, " Length: %d%s", ntohs (lsa
->data
->length
), VTY_NEWLINE
);
5199 const char *link_type_desc
[] =
5202 "another Router (point-to-point)",
5203 "a Transit Network",
5208 const char *link_id_desc
[] =
5211 "Neighboring Router ID",
5212 "Designated Router address",
5214 "Neighboring Router ID",
5217 const char *link_data_desc
[] =
5220 "Router Interface address",
5221 "Router Interface address",
5223 "Router Interface address",
5226 /* Show router-LSA each Link information. */
5228 show_ip_ospf_database_router_links (struct vty
*vty
,
5229 struct router_lsa
*rl
)
5234 len
= ntohs (rl
->header
.length
) - 4;
5235 for (i
= 0; i
< ntohs (rl
->links
) && len
> 0; len
-= 12, i
++)
5237 type
= rl
->link
[i
].type
;
5239 vty_out (vty
, " Link connected to: %s%s",
5240 link_type_desc
[type
], VTY_NEWLINE
);
5241 vty_out (vty
, " (Link ID) %s: %s%s", link_id_desc
[type
],
5242 inet_ntoa (rl
->link
[i
].link_id
), VTY_NEWLINE
);
5243 vty_out (vty
, " (Link Data) %s: %s%s", link_data_desc
[type
],
5244 inet_ntoa (rl
->link
[i
].link_data
), VTY_NEWLINE
);
5245 vty_out (vty
, " Number of TOS metrics: 0%s", VTY_NEWLINE
);
5246 vty_out (vty
, " TOS 0 Metric: %d%s",
5247 ntohs (rl
->link
[i
].metric
), VTY_NEWLINE
);
5248 vty_out (vty
, "%s", VTY_NEWLINE
);
5252 /* Show router-LSA detail information. */
5254 show_router_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5258 struct router_lsa
*rl
= (struct router_lsa
*) lsa
->data
;
5260 show_ip_ospf_database_header (vty
, lsa
);
5262 vty_out (vty
, " Number of Links: %d%s%s", ntohs (rl
->links
),
5263 VTY_NEWLINE
, VTY_NEWLINE
);
5265 show_ip_ospf_database_router_links (vty
, rl
);
5266 vty_out (vty
, "%s", VTY_NEWLINE
);
5272 /* Show network-LSA detail information. */
5274 show_network_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5280 struct network_lsa
*nl
= (struct network_lsa
*) lsa
->data
;
5282 show_ip_ospf_database_header (vty
, lsa
);
5284 vty_out (vty
, " Network Mask: /%d%s",
5285 ip_masklen (nl
->mask
), VTY_NEWLINE
);
5287 length
= ntohs (lsa
->data
->length
) - OSPF_LSA_HEADER_SIZE
- 4;
5289 for (i
= 0; length
> 0; i
++, length
-= 4)
5290 vty_out (vty
, " Attached Router: %s%s",
5291 inet_ntoa (nl
->routers
[i
]), VTY_NEWLINE
);
5293 vty_out (vty
, "%s", VTY_NEWLINE
);
5299 /* Show summary-LSA detail information. */
5301 show_summary_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5305 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
5307 show_ip_ospf_database_header (vty
, lsa
);
5309 vty_out (vty
, " Network Mask: /%d%s", ip_masklen (sl
->mask
),
5311 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
5313 vty_out (vty
, "%s", VTY_NEWLINE
);
5319 /* Show summary-ASBR-LSA detail information. */
5321 show_summary_asbr_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5325 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
5327 show_ip_ospf_database_header (vty
, lsa
);
5329 vty_out (vty
, " Network Mask: /%d%s",
5330 ip_masklen (sl
->mask
), VTY_NEWLINE
);
5331 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
5333 vty_out (vty
, "%s", VTY_NEWLINE
);
5339 /* Show AS-external-LSA detail information. */
5341 show_as_external_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5345 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5347 show_ip_ospf_database_header (vty
, lsa
);
5349 vty_out (vty
, " Network Mask: /%d%s",
5350 ip_masklen (al
->mask
), VTY_NEWLINE
);
5351 vty_out (vty
, " Metric Type: %s%s",
5352 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5353 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
5354 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
5355 vty_out (vty
, " Metric: %d%s",
5356 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
5357 vty_out (vty
, " Forward Address: %s%s",
5358 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
5360 vty_out (vty
, " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5361 (route_tag_t
)ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
5369 show_as_external_lsa_stdvty (struct ospf_lsa
*lsa
)
5371 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5373 /* show_ip_ospf_database_header (vty, lsa); */
5375 zlog_debug( " Network Mask: /%d%s",
5376 ip_masklen (al
->mask
), "\n");
5377 zlog_debug( " Metric Type: %s%s",
5378 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5379 "2 (Larger than any link state path)" : "1", "\n");
5380 zlog_debug( " TOS: 0%s", "\n");
5381 zlog_debug( " Metric: %d%s",
5382 GET_METRIC (al
->e
[0].metric
), "\n");
5383 zlog_debug( " Forward Address: %s%s",
5384 inet_ntoa (al
->e
[0].fwd_addr
), "\n");
5386 zlog_debug( " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5387 (route_tag_t
)ntohl (al
->e
[0].route_tag
), "\n", "\n");
5393 /* Show AS-NSSA-LSA detail information. */
5395 show_as_nssa_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5399 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5401 show_ip_ospf_database_header (vty
, lsa
);
5403 vty_out (vty
, " Network Mask: /%d%s",
5404 ip_masklen (al
->mask
), VTY_NEWLINE
);
5405 vty_out (vty
, " Metric Type: %s%s",
5406 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5407 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
5408 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
5409 vty_out (vty
, " Metric: %d%s",
5410 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
5411 vty_out (vty
, " NSSA: Forward Address: %s%s",
5412 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
5414 vty_out (vty
, " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5415 (route_tag_t
)ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
5422 show_func_dummy (struct vty
*vty
, struct ospf_lsa
*lsa
)
5428 show_opaque_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5432 show_ip_ospf_database_header (vty
, lsa
);
5433 show_opaque_info_detail (vty
, lsa
);
5435 vty_out (vty
, "%s", VTY_NEWLINE
);
5440 int (*show_function
[])(struct vty
*, struct ospf_lsa
*) =
5443 show_router_lsa_detail
,
5444 show_network_lsa_detail
,
5445 show_summary_lsa_detail
,
5446 show_summary_asbr_lsa_detail
,
5447 show_as_external_lsa_detail
,
5449 show_as_nssa_lsa_detail
, /* almost same as external */
5451 show_opaque_lsa_detail
,
5452 show_opaque_lsa_detail
,
5453 show_opaque_lsa_detail
,
5457 show_lsa_prefix_set (struct vty
*vty
, struct prefix_ls
*lp
, struct in_addr
*id
,
5458 struct in_addr
*adv_router
)
5460 memset (lp
, 0, sizeof (struct prefix_ls
));
5464 else if (adv_router
== NULL
)
5473 lp
->adv_router
= *adv_router
;
5478 show_lsa_detail_proc (struct vty
*vty
, struct route_table
*rt
,
5479 struct in_addr
*id
, struct in_addr
*adv_router
)
5481 struct prefix_ls lp
;
5482 struct route_node
*rn
, *start
;
5483 struct ospf_lsa
*lsa
;
5485 show_lsa_prefix_set (vty
, &lp
, id
, adv_router
);
5486 start
= route_node_get (rt
, (struct prefix
*) &lp
);
5489 route_lock_node (start
);
5490 for (rn
= start
; rn
; rn
= route_next_until (rn
, start
))
5491 if ((lsa
= rn
->info
))
5493 if (show_function
[lsa
->data
->type
] != NULL
)
5494 show_function
[lsa
->data
->type
] (vty
, lsa
);
5496 route_unlock_node (start
);
5500 /* Show detail LSA information
5501 -- if id is NULL then show all LSAs. */
5503 show_lsa_detail (struct vty
*vty
, struct ospf
*ospf
, int type
,
5504 struct in_addr
*id
, struct in_addr
*adv_router
)
5506 struct listnode
*node
;
5507 struct ospf_area
*area
;
5511 case OSPF_AS_EXTERNAL_LSA
:
5512 case OSPF_OPAQUE_AS_LSA
:
5513 vty_out (vty
, " %s %s%s",
5514 show_database_desc
[type
],
5515 VTY_NEWLINE
, VTY_NEWLINE
);
5516 show_lsa_detail_proc (vty
, AS_LSDB (ospf
, type
), id
, adv_router
);
5519 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5521 vty_out (vty
, "%s %s (Area %s)%s%s",
5522 VTY_NEWLINE
, show_database_desc
[type
],
5523 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5524 show_lsa_detail_proc (vty
, AREA_LSDB (area
, type
), id
, adv_router
);
5531 show_lsa_detail_adv_router_proc (struct vty
*vty
, struct route_table
*rt
,
5532 struct in_addr
*adv_router
)
5534 struct route_node
*rn
;
5535 struct ospf_lsa
*lsa
;
5537 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
5538 if ((lsa
= rn
->info
))
5539 if (IPV4_ADDR_SAME (adv_router
, &lsa
->data
->adv_router
))
5541 if (CHECK_FLAG (lsa
->flags
, OSPF_LSA_LOCAL_XLT
))
5543 if (show_function
[lsa
->data
->type
] != NULL
)
5544 show_function
[lsa
->data
->type
] (vty
, lsa
);
5548 /* Show detail LSA information. */
5550 show_lsa_detail_adv_router (struct vty
*vty
, struct ospf
*ospf
, int type
,
5551 struct in_addr
*adv_router
)
5553 struct listnode
*node
;
5554 struct ospf_area
*area
;
5558 case OSPF_AS_EXTERNAL_LSA
:
5559 case OSPF_OPAQUE_AS_LSA
:
5560 vty_out (vty
, " %s %s%s",
5561 show_database_desc
[type
],
5562 VTY_NEWLINE
, VTY_NEWLINE
);
5563 show_lsa_detail_adv_router_proc (vty
, AS_LSDB (ospf
, type
),
5567 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5569 vty_out (vty
, "%s %s (Area %s)%s%s",
5570 VTY_NEWLINE
, show_database_desc
[type
],
5571 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5572 show_lsa_detail_adv_router_proc (vty
, AREA_LSDB (area
, type
),
5580 show_ip_ospf_database_summary (struct vty
*vty
, struct ospf
*ospf
, int self
)
5582 struct ospf_lsa
*lsa
;
5583 struct route_node
*rn
;
5584 struct ospf_area
*area
;
5585 struct listnode
*node
;
5588 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5590 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5594 case OSPF_AS_EXTERNAL_LSA
:
5595 case OSPF_OPAQUE_AS_LSA
:
5600 if (ospf_lsdb_count_self (area
->lsdb
, type
) > 0 ||
5601 (!self
&& ospf_lsdb_count (area
->lsdb
, type
) > 0))
5603 vty_out (vty
, " %s (Area %s)%s%s",
5604 show_database_desc
[type
],
5605 ospf_area_desc_string (area
),
5606 VTY_NEWLINE
, VTY_NEWLINE
);
5607 vty_out (vty
, "%s%s", show_database_header
[type
], VTY_NEWLINE
);
5609 LSDB_LOOP (AREA_LSDB (area
, type
), rn
, lsa
)
5610 show_lsa_summary (vty
, lsa
, self
);
5612 vty_out (vty
, "%s", VTY_NEWLINE
);
5617 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5621 case OSPF_AS_EXTERNAL_LSA
:
5622 case OSPF_OPAQUE_AS_LSA
:
5627 if (ospf_lsdb_count_self (ospf
->lsdb
, type
) ||
5628 (!self
&& ospf_lsdb_count (ospf
->lsdb
, type
)))
5630 vty_out (vty
, " %s%s%s",
5631 show_database_desc
[type
],
5632 VTY_NEWLINE
, VTY_NEWLINE
);
5633 vty_out (vty
, "%s%s", show_database_header
[type
],
5636 LSDB_LOOP (AS_LSDB (ospf
, type
), rn
, lsa
)
5637 show_lsa_summary (vty
, lsa
, self
);
5639 vty_out (vty
, "%s", VTY_NEWLINE
);
5643 vty_out (vty
, "%s", VTY_NEWLINE
);
5647 show_ip_ospf_database_maxage (struct vty
*vty
, struct ospf
*ospf
)
5649 struct route_node
*rn
;
5651 vty_out (vty
, "%s MaxAge Link States:%s%s",
5652 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
5654 for (rn
= route_top (ospf
->maxage_lsa
); rn
; rn
= route_next (rn
))
5656 struct ospf_lsa
*lsa
;
5658 if ((lsa
= rn
->info
) != NULL
)
5660 vty_out (vty
, "Link type: %d%s", lsa
->data
->type
, VTY_NEWLINE
);
5661 vty_out (vty
, "Link State ID: %s%s",
5662 inet_ntoa (lsa
->data
->id
), VTY_NEWLINE
);
5663 vty_out (vty
, "Advertising Router: %s%s",
5664 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
5665 vty_out (vty
, "LSA lock count: %d%s", lsa
->lock
, VTY_NEWLINE
);
5666 vty_out (vty
, "%s", VTY_NEWLINE
);
5671 #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
5672 #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
5674 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
5675 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
5676 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
5677 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
5679 #define OSPF_LSA_TYPES_CMD_STR \
5680 "asbr-summary|external|network|router|summary" \
5681 OSPF_LSA_TYPE_NSSA_CMD_STR \
5682 OSPF_LSA_TYPE_OPAQUE_CMD_STR
5684 #define OSPF_LSA_TYPES_DESC \
5685 "ASBR summary link states\n" \
5686 "External link states\n" \
5687 "Network link states\n" \
5688 "Router link states\n" \
5689 "Network summary link states\n" \
5690 OSPF_LSA_TYPE_NSSA_DESC \
5691 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
5692 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
5693 OSPF_LSA_TYPE_OPAQUE_AS_DESC
5696 show_ip_ospf_database_common (struct vty
*vty
, struct ospf
*ospf
,
5697 int arg_base
, int argc
, const char **argv
)
5700 struct in_addr id
, adv_router
;
5703 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5706 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5707 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5710 if (argc
== arg_base
+ 0)
5712 show_ip_ospf_database_summary (vty
, ospf
, 0);
5716 /* Set database type to show. */
5717 if (strncmp (argv
[arg_base
+ 0], "r", 1) == 0)
5718 type
= OSPF_ROUTER_LSA
;
5719 else if (strncmp (argv
[arg_base
+ 0], "ne", 2) == 0)
5720 type
= OSPF_NETWORK_LSA
;
5721 else if (strncmp (argv
[arg_base
+ 0], "ns", 2) == 0)
5722 type
= OSPF_AS_NSSA_LSA
;
5723 else if (strncmp (argv
[arg_base
+ 0], "su", 2) == 0)
5724 type
= OSPF_SUMMARY_LSA
;
5725 else if (strncmp (argv
[arg_base
+ 0], "a", 1) == 0)
5726 type
= OSPF_ASBR_SUMMARY_LSA
;
5727 else if (strncmp (argv
[arg_base
+ 0], "e", 1) == 0)
5728 type
= OSPF_AS_EXTERNAL_LSA
;
5729 else if (strncmp (argv
[arg_base
+ 0], "se", 2) == 0)
5731 show_ip_ospf_database_summary (vty
, ospf
, 1);
5734 else if (strncmp (argv
[arg_base
+ 0], "m", 1) == 0)
5736 show_ip_ospf_database_maxage (vty
, ospf
);
5739 else if (strncmp (argv
[arg_base
+ 0], "opaque-l", 8) == 0)
5740 type
= OSPF_OPAQUE_LINK_LSA
;
5741 else if (strncmp (argv
[arg_base
+ 0], "opaque-ar", 9) == 0)
5742 type
= OSPF_OPAQUE_AREA_LSA
;
5743 else if (strncmp (argv
[arg_base
+ 0], "opaque-as", 9) == 0)
5744 type
= OSPF_OPAQUE_AS_LSA
;
5748 /* `show ip ospf database LSA'. */
5749 if (argc
== arg_base
+ 1)
5750 show_lsa_detail (vty
, ospf
, type
, NULL
, NULL
);
5751 else if (argc
>= arg_base
+ 2)
5753 ret
= inet_aton (argv
[arg_base
+ 1], &id
);
5757 /* `show ip ospf database LSA ID'. */
5758 if (argc
== arg_base
+ 2)
5759 show_lsa_detail (vty
, ospf
, type
, &id
, NULL
);
5760 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
5761 else if (argc
== arg_base
+ 3)
5763 if (strncmp (argv
[arg_base
+ 2], "s", 1) == 0)
5764 adv_router
= ospf
->router_id
;
5767 ret
= inet_aton (argv
[arg_base
+ 2], &adv_router
);
5771 show_lsa_detail (vty
, ospf
, type
, &id
, &adv_router
);
5778 DEFUN (show_ip_ospf_database
,
5779 show_ip_ospf_database_cmd
,
5780 "show ip ospf database",
5783 "OSPF information\n"
5784 "Database summary\n")
5788 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5791 return (show_ip_ospf_database_common(vty
, ospf
, 0, argc
, argv
));
5794 ALIAS (show_ip_ospf_database
,
5795 show_ip_ospf_database_type_cmd
,
5796 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR
"|max-age|self-originate)",
5799 "OSPF information\n"
5800 "Database summary\n"
5802 "LSAs in MaxAge list\n"
5803 "Self-originated link states\n")
5805 ALIAS (show_ip_ospf_database
,
5806 show_ip_ospf_database_type_id_cmd
,
5807 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR
") A.B.C.D",
5810 "OSPF information\n"
5811 "Database summary\n"
5813 "Link State ID (as an IP address)\n")
5815 ALIAS (show_ip_ospf_database
,
5816 show_ip_ospf_database_type_id_adv_router_cmd
,
5817 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR
") A.B.C.D adv-router A.B.C.D",
5820 "OSPF information\n"
5821 "Database summary\n"
5823 "Link State ID (as an IP address)\n"
5824 "Advertising Router link states\n"
5825 "Advertising Router (as an IP address)\n")
5827 ALIAS (show_ip_ospf_database
,
5828 show_ip_ospf_database_type_id_self_cmd
,
5829 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR
") A.B.C.D (self-originate|)",
5832 "OSPF information\n"
5833 "Database summary\n"
5835 "Link State ID (as an IP address)\n"
5836 "Self-originated link states\n"
5839 DEFUN (show_ip_ospf_instance_database
,
5840 show_ip_ospf_instance_database_cmd
,
5841 "show ip ospf <1-65535> database",
5844 "OSPF information\n"
5846 "Database summary\n")
5849 u_short instance
= 0;
5851 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
5853 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5856 return (show_ip_ospf_database_common(vty
, ospf
, 1, argc
, argv
));
5859 ALIAS (show_ip_ospf_instance_database
,
5860 show_ip_ospf_instance_database_type_cmd
,
5861 "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR
"|max-age|self-originate)",
5864 "OSPF information\n"
5866 "Database summary\n"
5868 "LSAs in MaxAge list\n"
5869 "Self-originated link states\n")
5871 ALIAS (show_ip_ospf_instance_database
,
5872 show_ip_ospf_instance_database_type_id_cmd
,
5873 "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR
") A.B.C.D",
5876 "OSPF information\n"
5878 "Database summary\n"
5880 "Link State ID (as an IP address)\n")
5882 ALIAS (show_ip_ospf_instance_database
,
5883 show_ip_ospf_instance_database_type_id_adv_router_cmd
,
5884 "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR
") A.B.C.D adv-router A.B.C.D",
5887 "OSPF information\n"
5889 "Database summary\n"
5891 "Link State ID (as an IP address)\n"
5892 "Advertising Router link states\n"
5893 "Advertising Router (as an IP address)\n")
5895 ALIAS (show_ip_ospf_instance_database
,
5896 show_ip_ospf_instance_database_type_id_self_cmd
,
5897 "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR
") A.B.C.D (self-originate|)",
5900 "OSPF information\n"
5902 "Database summary\n"
5904 "Link State ID (as an IP address)\n"
5905 "Self-originated link states\n"
5910 show_ip_ospf_database_type_adv_router_common (struct vty
*vty
, struct ospf
*ospf
,
5911 int arg_base
, int argc
, const char **argv
)
5914 struct in_addr adv_router
;
5917 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5920 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5921 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5923 if (argc
!= arg_base
+ 2)
5926 /* Set database type to show. */
5927 if (strncmp (argv
[arg_base
+ 0], "r", 1) == 0)
5928 type
= OSPF_ROUTER_LSA
;
5929 else if (strncmp (argv
[arg_base
+ 0], "ne", 2) == 0)
5930 type
= OSPF_NETWORK_LSA
;
5931 else if (strncmp (argv
[arg_base
+ 0], "ns", 2) == 0)
5932 type
= OSPF_AS_NSSA_LSA
;
5933 else if (strncmp (argv
[arg_base
+ 0], "s", 1) == 0)
5934 type
= OSPF_SUMMARY_LSA
;
5935 else if (strncmp (argv
[arg_base
+ 0], "a", 1) == 0)
5936 type
= OSPF_ASBR_SUMMARY_LSA
;
5937 else if (strncmp (argv
[arg_base
+ 0], "e", 1) == 0)
5938 type
= OSPF_AS_EXTERNAL_LSA
;
5939 else if (strncmp (argv
[arg_base
+ 0], "opaque-l", 8) == 0)
5940 type
= OSPF_OPAQUE_LINK_LSA
;
5941 else if (strncmp (argv
[arg_base
+ 0], "opaque-ar", 9) == 0)
5942 type
= OSPF_OPAQUE_AREA_LSA
;
5943 else if (strncmp (argv
[arg_base
+ 0], "opaque-as", 9) == 0)
5944 type
= OSPF_OPAQUE_AS_LSA
;
5948 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
5949 if (strncmp (argv
[arg_base
+ 1], "s", 1) == 0)
5950 adv_router
= ospf
->router_id
;
5953 ret
= inet_aton (argv
[arg_base
+ 1], &adv_router
);
5958 show_lsa_detail_adv_router (vty
, ospf
, type
, &adv_router
);
5963 DEFUN (show_ip_ospf_database_type_adv_router
,
5964 show_ip_ospf_database_type_adv_router_cmd
,
5965 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR
") adv-router A.B.C.D",
5968 "OSPF information\n"
5969 "Database summary\n"
5971 "Advertising Router link states\n"
5972 "Advertising Router (as an IP address)\n")
5976 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5979 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 0, argc
, argv
));
5982 ALIAS (show_ip_ospf_database_type_adv_router
,
5983 show_ip_ospf_database_type_self_cmd
,
5984 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR
") (self-originate|)",
5987 "OSPF information\n"
5988 "Database summary\n"
5990 "Self-originated link states\n")
5992 DEFUN (show_ip_ospf_instance_database_type_adv_router
,
5993 show_ip_ospf_instance_database_type_adv_router_cmd
,
5994 "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR
") adv-router A.B.C.D",
5997 "OSPF information\n"
5999 "Database summary\n"
6001 "Advertising Router link states\n"
6002 "Advertising Router (as an IP address)\n")
6005 u_short instance
= 0;
6007 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
6009 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
6012 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 1, argc
, argv
));
6015 ALIAS (show_ip_ospf_instance_database_type_adv_router
,
6016 show_ip_ospf_instance_database_type_self_cmd
,
6017 "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR
") (self-originate|)",
6020 "OSPF information\n"
6022 "Database summary\n"
6024 "Self-originated link states\n")
6026 DEFUN (ip_ospf_authentication_args
,
6027 ip_ospf_authentication_args_addr_cmd
,
6028 "ip ospf authentication (null|message-digest) A.B.C.D",
6030 "OSPF interface commands\n"
6031 "Enable authentication on this interface\n"
6032 "Use null authentication\n"
6033 "Use message-digest authentication\n"
6034 "Address of interface")
6036 struct interface
*ifp
;
6037 struct in_addr addr
;
6039 struct ospf_if_params
*params
;
6042 params
= IF_DEF_PARAMS (ifp
);
6046 ret
= inet_aton(argv
[1], &addr
);
6049 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6054 params
= ospf_get_if_params (ifp
, addr
);
6055 ospf_if_update_params (ifp
, addr
);
6058 /* Handle null authentication */
6059 if ( argv
[0][0] == 'n' )
6061 SET_IF_PARAM (params
, auth_type
);
6062 params
->auth_type
= OSPF_AUTH_NULL
;
6066 /* Handle message-digest authentication */
6067 if ( argv
[0][0] == 'm' )
6069 SET_IF_PARAM (params
, auth_type
);
6070 params
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
6074 vty_out (vty
, "You shouldn't get here!%s", VTY_NEWLINE
);
6078 ALIAS (ip_ospf_authentication_args
,
6079 ip_ospf_authentication_args_cmd
,
6080 "ip ospf authentication (null|message-digest)",
6082 "OSPF interface commands\n"
6083 "Enable authentication on this interface\n"
6084 "Use null authentication\n"
6085 "Use message-digest authentication\n")
6087 DEFUN (ip_ospf_authentication
,
6088 ip_ospf_authentication_addr_cmd
,
6089 "ip ospf authentication A.B.C.D",
6091 "OSPF interface commands\n"
6092 "Enable authentication on this interface\n"
6093 "Address of interface")
6095 struct interface
*ifp
;
6096 struct in_addr addr
;
6098 struct ospf_if_params
*params
;
6101 params
= IF_DEF_PARAMS (ifp
);
6105 ret
= inet_aton(argv
[0], &addr
);
6108 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6113 params
= ospf_get_if_params (ifp
, addr
);
6114 ospf_if_update_params (ifp
, addr
);
6117 SET_IF_PARAM (params
, auth_type
);
6118 params
->auth_type
= OSPF_AUTH_SIMPLE
;
6123 ALIAS (ip_ospf_authentication
,
6124 ip_ospf_authentication_cmd
,
6125 "ip ospf authentication",
6127 "OSPF interface commands\n"
6128 "Enable authentication on this interface\n")
6130 DEFUN (no_ip_ospf_authentication_args
,
6131 no_ip_ospf_authentication_args_addr_cmd
,
6132 "no ip ospf authentication (null|message-digest) A.B.C.D",
6135 "OSPF interface commands\n"
6136 "Enable authentication on this interface\n"
6137 "Use null authentication\n"
6138 "Use message-digest authentication\n"
6139 "Address of interface")
6141 struct interface
*ifp
;
6142 struct in_addr addr
;
6144 struct ospf_if_params
*params
;
6145 struct route_node
*rn
;
6149 params
= IF_DEF_PARAMS (ifp
);
6153 ret
= inet_aton(argv
[1], &addr
);
6156 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6161 params
= ospf_lookup_if_params (ifp
, addr
);
6164 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
6167 params
->auth_type
= OSPF_AUTH_NOTSET
;
6168 UNSET_IF_PARAM (params
, auth_type
);
6169 if (params
!= IF_DEF_PARAMS (ifp
))
6171 ospf_free_if_params (ifp
, addr
);
6172 ospf_if_update_params (ifp
, addr
);
6177 if ( argv
[0][0] == 'n' )
6179 auth_type
= OSPF_AUTH_NULL
;
6181 else if ( argv
[0][0] == 'm' )
6183 auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
6187 vty_out (vty
, "Unexpected input encountered%s", VTY_NEWLINE
);
6191 * Here we have a case where the user has entered
6192 * 'no ip ospf authentication (null | message_digest )'
6193 * we need to find if we have any ip addresses underneath it that
6194 * correspond to the associated type.
6196 if (params
->auth_type
== auth_type
)
6198 params
->auth_type
= OSPF_AUTH_NOTSET
;
6199 UNSET_IF_PARAM (params
, auth_type
);
6202 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
6204 if ((params
= rn
->info
))
6206 if (params
->auth_type
== auth_type
)
6208 params
->auth_type
= OSPF_AUTH_NOTSET
;
6209 UNSET_IF_PARAM (params
, auth_type
);
6210 if (params
!= IF_DEF_PARAMS (ifp
))
6212 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
6213 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
6223 ALIAS (no_ip_ospf_authentication_args
,
6224 no_ip_ospf_authentication_args_cmd
,
6225 "no ip ospf authentication (null|message-digest)",
6228 "OSPF interface commands\n"
6229 "Enable authentication on this interface\n"
6230 "Use null authentication\n"
6231 "Use message-digest authentication\n")
6233 DEFUN (no_ip_ospf_authentication
,
6234 no_ip_ospf_authentication_addr_cmd
,
6235 "no ip ospf authentication A.B.C.D",
6238 "OSPF interface commands\n"
6239 "Enable authentication on this interface\n"
6240 "Address of interface")
6242 struct interface
*ifp
;
6243 struct in_addr addr
;
6245 struct ospf_if_params
*params
;
6246 struct route_node
*rn
;
6249 params
= IF_DEF_PARAMS (ifp
);
6253 ret
= inet_aton(argv
[0], &addr
);
6256 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6261 params
= ospf_lookup_if_params (ifp
, addr
);
6264 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
6268 params
->auth_type
= OSPF_AUTH_NOTSET
;
6269 UNSET_IF_PARAM (params
, auth_type
);
6270 if (params
!= IF_DEF_PARAMS (ifp
))
6272 ospf_free_if_params (ifp
, addr
);
6273 ospf_if_update_params (ifp
, addr
);
6279 * When a user enters 'no ip ospf authentication'
6280 * We should remove all authentication types from
6283 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
6284 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
6285 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
6287 params
->auth_type
= OSPF_AUTH_NOTSET
;
6288 UNSET_IF_PARAM (params
, auth_type
);
6291 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
6293 if ((params
= rn
->info
))
6296 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
6297 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
6298 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
6300 params
->auth_type
= OSPF_AUTH_NOTSET
;
6301 UNSET_IF_PARAM (params
, auth_type
);
6302 if (params
!= IF_DEF_PARAMS (ifp
))
6304 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
6305 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
6315 ALIAS (no_ip_ospf_authentication
,
6316 no_ip_ospf_authentication_cmd
,
6317 "no ip ospf authentication",
6320 "OSPF interface commands\n"
6321 "Enable authentication on this interface\n")
6323 DEFUN (ip_ospf_authentication_key
,
6324 ip_ospf_authentication_key_addr_cmd
,
6325 "ip ospf authentication-key AUTH_KEY A.B.C.D",
6327 "OSPF interface commands\n"
6328 "Authentication password (key)\n"
6329 "The OSPF password (key)\n"
6330 "Address of interface")
6332 struct interface
*ifp
;
6333 struct in_addr addr
;
6335 struct ospf_if_params
*params
;
6338 params
= IF_DEF_PARAMS (ifp
);
6342 ret
= inet_aton(argv
[1], &addr
);
6345 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6350 params
= ospf_get_if_params (ifp
, addr
);
6351 ospf_if_update_params (ifp
, addr
);
6354 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
6355 strncpy ((char *) params
->auth_simple
, argv
[0], OSPF_AUTH_SIMPLE_SIZE
);
6356 SET_IF_PARAM (params
, auth_simple
);
6361 ALIAS (ip_ospf_authentication_key
,
6362 ip_ospf_authentication_key_cmd
,
6363 "ip ospf authentication-key AUTH_KEY",
6365 "OSPF interface commands\n"
6366 "Authentication password (key)\n"
6367 "The OSPF password (key)")
6369 ALIAS_HIDDEN (ip_ospf_authentication_key
,
6370 ospf_authentication_key_cmd
,
6371 "ospf authentication-key AUTH_KEY",
6372 "OSPF interface commands\n"
6373 "Authentication password (key)\n"
6374 "The OSPF password (key)")
6376 DEFUN (no_ip_ospf_authentication_key
,
6377 no_ip_ospf_authentication_key_authkey_addr_cmd
,
6378 "no ip ospf authentication-key AUTH_KEY A.B.C.D",
6381 "OSPF interface commands\n"
6382 "Authentication password (key)\n"
6383 "The OSPF password (key)")
6385 struct interface
*ifp
;
6386 struct in_addr addr
;
6387 struct ospf_if_params
*params
;
6391 params
= IF_DEF_PARAMS (ifp
);
6395 ret
= inet_aton(argv
[1], &addr
);
6398 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6403 params
= ospf_lookup_if_params (ifp
, addr
);
6408 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
);
6409 UNSET_IF_PARAM (params
, auth_simple
);
6411 if (params
!= IF_DEF_PARAMS (ifp
))
6413 ospf_free_if_params (ifp
, addr
);
6414 ospf_if_update_params (ifp
, addr
);
6420 ALIAS (no_ip_ospf_authentication_key
,
6421 no_ip_ospf_authentication_key_authkey_cmd
,
6422 "no ip ospf authentication-key AUTH_KEY",
6425 "OSPF interface commands\n"
6426 "Authentication password (key)\n")
6428 ALIAS (no_ip_ospf_authentication_key
,
6429 no_ip_ospf_authentication_key_cmd
,
6430 "no ip ospf authentication-key",
6433 "OSPF interface commands\n"
6434 "Authentication password (key)\n")
6436 ALIAS (no_ip_ospf_authentication_key
,
6437 no_ospf_authentication_key_cmd
,
6438 "no ospf authentication-key",
6440 "OSPF interface commands\n"
6441 "Authentication password (key)\n")
6443 ALIAS (no_ip_ospf_authentication_key
,
6444 no_ospf_authentication_key_authkey_cmd
,
6445 "no ospf authentication-key AUTH_KEY",
6447 "OSPF interface commands\n"
6448 "Authentication password (key)\n"
6449 "The OSPF password (key)\n")
6451 ALIAS (no_ip_ospf_authentication_key
,
6452 no_ospf_authentication_key_authkey_ip_cmd
,
6453 "no ospf authentication-key AUTH_KEY A.B.C.D",
6455 "OSPF interface commands\n"
6456 "Authentication password (key)\n"
6457 "The OSPF password (key)\n"
6458 "Address of interface")
6460 DEFUN (ip_ospf_message_digest_key
,
6461 ip_ospf_message_digest_key_addr_cmd
,
6462 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
6464 "OSPF interface commands\n"
6465 "Message digest authentication password (key)\n"
6467 "Use MD5 algorithm\n"
6468 "The OSPF password (key)"
6469 "Address of interface")
6471 struct interface
*ifp
;
6472 struct crypt_key
*ck
;
6474 struct in_addr addr
;
6476 struct ospf_if_params
*params
;
6479 params
= IF_DEF_PARAMS (ifp
);
6483 ret
= inet_aton(argv
[2], &addr
);
6486 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6491 params
= ospf_get_if_params (ifp
, addr
);
6492 ospf_if_update_params (ifp
, addr
);
6495 key_id
= strtol (argv
[0], NULL
, 10);
6496 if (ospf_crypt_key_lookup (params
->auth_crypt
, key_id
) != NULL
)
6498 vty_out (vty
, "OSPF: Key %d already exists%s", key_id
, VTY_NEWLINE
);
6502 ck
= ospf_crypt_key_new ();
6503 ck
->key_id
= (u_char
) key_id
;
6504 memset (ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
6505 strncpy ((char *) ck
->auth_key
, argv
[1], OSPF_AUTH_MD5_SIZE
);
6507 ospf_crypt_key_add (params
->auth_crypt
, ck
);
6508 SET_IF_PARAM (params
, auth_crypt
);
6513 ALIAS (ip_ospf_message_digest_key
,
6514 ip_ospf_message_digest_key_cmd
,
6515 "ip ospf message-digest-key <1-255> md5 KEY",
6517 "OSPF interface commands\n"
6518 "Message digest authentication password (key)\n"
6520 "Use MD5 algorithm\n"
6521 "The OSPF password (key)")
6523 ALIAS_HIDDEN (ip_ospf_message_digest_key
,
6524 ospf_message_digest_key_cmd
,
6525 "ospf message-digest-key <1-255> md5 KEY",
6526 "OSPF interface commands\n"
6527 "Message digest authentication password (key)\n"
6529 "Use MD5 algorithm\n"
6530 "The OSPF password (key)")
6532 DEFUN (no_ip_ospf_message_digest_key_md5
,
6533 no_ip_ospf_message_digest_key_md5_addr_cmd
,
6534 "no ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
6537 "OSPF interface commands\n"
6538 "Message digest authentication password (key)\n"
6540 "Use MD5 algorithm\n"
6541 "The OSPF password (key)"
6542 "Address of interface")
6544 struct interface
*ifp
;
6545 struct crypt_key
*ck
;
6547 struct in_addr addr
;
6549 struct ospf_if_params
*params
;
6552 params
= IF_DEF_PARAMS (ifp
);
6556 ret
= inet_aton(argv
[2], &addr
);
6559 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6564 params
= ospf_lookup_if_params (ifp
, addr
);
6569 key_id
= strtol (argv
[0], NULL
, 10);
6570 ck
= ospf_crypt_key_lookup (params
->auth_crypt
, key_id
);
6573 vty_out (vty
, "OSPF: Key %d does not exist%s", key_id
, VTY_NEWLINE
);
6577 ospf_crypt_key_delete (params
->auth_crypt
, key_id
);
6579 if (params
!= IF_DEF_PARAMS (ifp
))
6581 ospf_free_if_params (ifp
, addr
);
6582 ospf_if_update_params (ifp
, addr
);
6588 ALIAS (no_ip_ospf_message_digest_key_md5
,
6589 no_ip_ospf_message_digest_key_md5_cmd
,
6590 "no ip ospf message-digest-key <1-255> md5 KEY",
6593 "OSPF interface commands\n"
6594 "Message digest authentication password (key)\n"
6596 "Use MD5 algorithm\n"
6597 "The OSPF password (key)")
6599 DEFUN (no_ip_ospf_message_digest_key
,
6600 no_ip_ospf_message_digest_key_addr_cmd
,
6601 "no ip ospf message-digest-key <1-255> A.B.C.D",
6604 "OSPF interface commands\n"
6605 "Message digest authentication password (key)\n"
6607 "Address of interface")
6609 struct interface
*ifp
;
6610 struct crypt_key
*ck
;
6612 struct in_addr addr
;
6614 struct ospf_if_params
*params
;
6617 params
= IF_DEF_PARAMS (ifp
);
6621 ret
= inet_aton(argv
[1], &addr
);
6624 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6629 params
= ospf_lookup_if_params (ifp
, addr
);
6634 key_id
= strtol (argv
[0], NULL
, 10);
6635 ck
= ospf_crypt_key_lookup (params
->auth_crypt
, key_id
);
6638 vty_out (vty
, "OSPF: Key %d does not exist%s", key_id
, VTY_NEWLINE
);
6642 ospf_crypt_key_delete (params
->auth_crypt
, key_id
);
6644 if (params
!= IF_DEF_PARAMS (ifp
))
6646 ospf_free_if_params (ifp
, addr
);
6647 ospf_if_update_params (ifp
, addr
);
6653 ALIAS (no_ip_ospf_message_digest_key
,
6654 no_ip_ospf_message_digest_key_cmd
,
6655 "no ip ospf message-digest-key <1-255>",
6658 "OSPF interface commands\n"
6659 "Message digest authentication password (key)\n"
6662 ALIAS (no_ip_ospf_message_digest_key
,
6663 no_ospf_message_digest_key_cmd
,
6664 "no ospf message-digest-key <1-255>",
6666 "OSPF interface commands\n"
6667 "Message digest authentication password (key)\n"
6670 DEFUN (ip_ospf_cost
,
6671 ip_ospf_cost_u32_inet4_cmd
,
6672 "ip ospf cost <1-65535> A.B.C.D",
6674 "OSPF interface commands\n"
6677 "Address of interface")
6679 struct interface
*ifp
= vty
->index
;
6681 struct in_addr addr
;
6683 struct ospf_if_params
*params
;
6685 params
= IF_DEF_PARAMS (ifp
);
6687 cost
= strtol (argv
[0], NULL
, 10);
6689 /* cost range is <1-65535>. */
6690 if (cost
< 1 || cost
> 65535)
6692 vty_out (vty
, "Interface output cost is invalid%s", VTY_NEWLINE
);
6698 ret
= inet_aton(argv
[1], &addr
);
6701 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6706 params
= ospf_get_if_params (ifp
, addr
);
6707 ospf_if_update_params (ifp
, addr
);
6710 SET_IF_PARAM (params
, output_cost_cmd
);
6711 params
->output_cost_cmd
= cost
;
6713 ospf_if_recalculate_output_cost (ifp
);
6718 ALIAS (ip_ospf_cost
,
6719 ip_ospf_cost_u32_cmd
,
6720 "ip ospf cost <1-65535>",
6722 "OSPF interface commands\n"
6726 ALIAS_HIDDEN (ip_ospf_cost
,
6728 "ospf cost <1-65535>",
6729 "OSPF interface commands\n"
6733 ALIAS_HIDDEN (ip_ospf_cost
,
6734 ospf_cost_u32_inet4_cmd
,
6735 "ospf cost <1-65535> A.B.C.D",
6736 "OSPF interface commands\n"
6739 "Address of interface")
6741 DEFUN (no_ip_ospf_cost
,
6742 no_ip_ospf_cost_inet4_cmd
,
6743 "no ip ospf cost A.B.C.D",
6746 "OSPF interface commands\n"
6748 "Address of interface")
6750 struct interface
*ifp
= vty
->index
;
6751 struct in_addr addr
;
6753 struct ospf_if_params
*params
;
6756 params
= IF_DEF_PARAMS (ifp
);
6760 ret
= inet_aton(argv
[0], &addr
);
6763 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6768 params
= ospf_lookup_if_params (ifp
, addr
);
6773 UNSET_IF_PARAM (params
, output_cost_cmd
);
6775 if (params
!= IF_DEF_PARAMS (ifp
))
6777 ospf_free_if_params (ifp
, addr
);
6778 ospf_if_update_params (ifp
, addr
);
6781 ospf_if_recalculate_output_cost (ifp
);
6786 ALIAS (no_ip_ospf_cost
,
6787 no_ip_ospf_cost_cmd
,
6791 "OSPF interface commands\n"
6794 ALIAS (no_ip_ospf_cost
,
6798 "OSPF interface commands\n"
6801 ALIAS (no_ip_ospf_cost
,
6802 no_ospf_cost_inet4_cmd
,
6803 "no ospf cost A.B.C.D",
6805 "OSPF interface commands\n"
6807 "Address of interface")
6809 DEFUN (no_ip_ospf_cost2
,
6810 no_ip_ospf_cost_u32_cmd
,
6811 "no ip ospf cost <1-65535>",
6814 "OSPF interface commands\n"
6818 struct interface
*ifp
= vty
->index
;
6819 struct in_addr addr
;
6822 struct ospf_if_params
*params
;
6825 params
= IF_DEF_PARAMS (ifp
);
6827 /* According to the semantics we are mimicking "no ip ospf cost N" is
6828 * always treated as "no ip ospf cost" regardless of the actual value
6829 * of N already configured for the interface. Thus the first argument
6830 * is always checked to be a number, but is ignored after that.
6832 cost
= strtol (argv
[0], NULL
, 10);
6833 if (cost
< 1 || cost
> 65535)
6835 vty_out (vty
, "Interface output cost is invalid%s", VTY_NEWLINE
);
6841 ret
= inet_aton(argv
[1], &addr
);
6844 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6849 params
= ospf_lookup_if_params (ifp
, addr
);
6854 UNSET_IF_PARAM (params
, output_cost_cmd
);
6856 if (params
!= IF_DEF_PARAMS (ifp
))
6858 ospf_free_if_params (ifp
, addr
);
6859 ospf_if_update_params (ifp
, addr
);
6862 ospf_if_recalculate_output_cost (ifp
);
6867 ALIAS (no_ip_ospf_cost2
,
6868 no_ospf_cost_u32_cmd
,
6869 "no ospf cost <1-65535>",
6871 "OSPF interface commands\n"
6875 ALIAS (no_ip_ospf_cost2
,
6876 no_ip_ospf_cost_u32_inet4_cmd
,
6877 "no ip ospf cost <1-65535> A.B.C.D",
6880 "OSPF interface commands\n"
6883 "Address of interface")
6885 ALIAS (no_ip_ospf_cost2
,
6886 no_ospf_cost_u32_inet4_cmd
,
6887 "no ospf cost <1-65535> A.B.C.D",
6889 "OSPF interface commands\n"
6892 "Address of interface")
6895 ospf_nbr_timer_update (struct ospf_interface
*oi
)
6897 struct route_node
*rn
;
6898 struct ospf_neighbor
*nbr
;
6900 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
6901 if ((nbr
= rn
->info
))
6903 nbr
->v_inactivity
= OSPF_IF_PARAM (oi
, v_wait
);
6904 nbr
->v_db_desc
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6905 nbr
->v_ls_req
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6906 nbr
->v_ls_upd
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6911 ospf_vty_dead_interval_set (struct vty
*vty
, const char *interval_str
,
6912 const char *nbr_str
,
6913 const char *fast_hello_str
)
6915 struct interface
*ifp
= vty
->index
;
6918 struct in_addr addr
;
6920 struct ospf_if_params
*params
;
6921 struct ospf_interface
*oi
;
6922 struct route_node
*rn
;
6924 params
= IF_DEF_PARAMS (ifp
);
6928 ret
= inet_aton(nbr_str
, &addr
);
6931 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6936 params
= ospf_get_if_params (ifp
, addr
);
6937 ospf_if_update_params (ifp
, addr
);
6942 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds
, interval_str
,
6945 /* reset fast_hello too, just to be sure */
6946 UNSET_IF_PARAM (params
, fast_hello
);
6947 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6949 else if (fast_hello_str
)
6951 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult
, fast_hello_str
,
6953 /* 1s dead-interval with sub-second hellos desired */
6954 seconds
= OSPF_ROUTER_DEAD_INTERVAL_MINIMAL
;
6955 SET_IF_PARAM (params
, fast_hello
);
6956 params
->fast_hello
= hellomult
;
6960 vty_out (vty
, "Please specify dead-interval or hello-multiplier%s",
6965 SET_IF_PARAM (params
, v_wait
);
6966 params
->v_wait
= seconds
;
6968 /* Update timer values in neighbor structure. */
6972 if ((ospf
= ospf_lookup()))
6974 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
6976 ospf_nbr_timer_update (oi
);
6981 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6982 if ((oi
= rn
->info
))
6983 ospf_nbr_timer_update (oi
);
6990 DEFUN (ip_ospf_dead_interval
,
6991 ip_ospf_dead_interval_addr_cmd
,
6992 "ip ospf dead-interval <1-65535> A.B.C.D",
6994 "OSPF interface commands\n"
6995 "Interval after which a neighbor is declared dead\n"
6997 "Address of interface\n")
7000 return ospf_vty_dead_interval_set (vty
, argv
[0], argv
[1], NULL
);
7002 return ospf_vty_dead_interval_set (vty
, argv
[0], NULL
, NULL
);
7005 ALIAS (ip_ospf_dead_interval
,
7006 ip_ospf_dead_interval_cmd
,
7007 "ip ospf dead-interval <1-65535>",
7009 "OSPF interface commands\n"
7010 "Interval after which a neighbor is declared dead\n"
7013 ALIAS_HIDDEN (ip_ospf_dead_interval
,
7014 ospf_dead_interval_cmd
,
7015 "ospf dead-interval <1-65535>",
7016 "OSPF interface commands\n"
7017 "Interval after which a neighbor is declared dead\n"
7020 DEFUN (ip_ospf_dead_interval_minimal
,
7021 ip_ospf_dead_interval_minimal_addr_cmd
,
7022 "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
7024 "OSPF interface commands\n"
7025 "Interval after which a neighbor is declared dead\n"
7026 "Minimal 1s dead-interval with fast sub-second hellos\n"
7027 "Hello multiplier factor\n"
7028 "Number of Hellos to send each second\n"
7029 "Address of interface\n")
7032 return ospf_vty_dead_interval_set (vty
, NULL
, argv
[1], argv
[0]);
7034 return ospf_vty_dead_interval_set (vty
, NULL
, NULL
, argv
[0]);
7037 ALIAS (ip_ospf_dead_interval_minimal
,
7038 ip_ospf_dead_interval_minimal_cmd
,
7039 "ip ospf dead-interval minimal hello-multiplier <1-10>",
7041 "OSPF interface commands\n"
7042 "Interval after which a neighbor is declared dead\n"
7043 "Minimal 1s dead-interval with fast sub-second hellos\n"
7044 "Hello multiplier factor\n"
7045 "Number of Hellos to send each second\n")
7047 DEFUN (no_ip_ospf_dead_interval
,
7048 no_ip_ospf_dead_interval_addr_cmd
,
7049 "no ip ospf dead-interval <1-65535> A.B.C.D",
7052 "OSPF interface commands\n"
7053 "Interval after which a neighbor is declared dead\n"
7055 "Address of interface")
7057 struct interface
*ifp
= vty
->index
;
7058 struct in_addr addr
;
7060 struct ospf_if_params
*params
;
7061 struct ospf_interface
*oi
;
7062 struct route_node
*rn
;
7065 params
= IF_DEF_PARAMS (ifp
);
7069 ret
= inet_aton(argv
[1], &addr
);
7072 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7077 params
= ospf_lookup_if_params (ifp
, addr
);
7082 UNSET_IF_PARAM (params
, v_wait
);
7083 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
7085 UNSET_IF_PARAM (params
, fast_hello
);
7086 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
7088 if (params
!= IF_DEF_PARAMS (ifp
))
7090 ospf_free_if_params (ifp
, addr
);
7091 ospf_if_update_params (ifp
, addr
);
7094 /* Update timer values in neighbor structure. */
7099 if ((ospf
= ospf_lookup()))
7101 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
7103 ospf_nbr_timer_update (oi
);
7108 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7109 if ((oi
= rn
->info
))
7110 ospf_nbr_timer_update (oi
);
7116 ALIAS (no_ip_ospf_dead_interval
,
7117 no_ip_ospf_dead_interval_seconds_cmd
,
7118 "no ip ospf dead-interval <1-65535>",
7121 "OSPF interface commands\n"
7122 "Interval after which a neighbor is declared dead\n"
7125 ALIAS (no_ip_ospf_dead_interval
,
7126 no_ip_ospf_dead_interval_cmd
,
7127 "no ip ospf dead-interval",
7130 "OSPF interface commands\n"
7131 "Interval after which a neighbor is declared dead\n")
7133 ALIAS (no_ip_ospf_dead_interval
,
7134 no_ospf_dead_interval_cmd
,
7135 "no ospf dead-interval",
7137 "OSPF interface commands\n"
7138 "Interval after which a neighbor is declared dead\n")
7140 ALIAS (no_ip_ospf_dead_interval
,
7141 no_ip_ospf_dead_interval_minimal_addr_cmd
,
7142 "no ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
7145 "OSPF interface commands\n"
7146 "Interval after which a neighbor is declared dead\n"
7147 "Minimal 1s dead-interval with fast sub-second hellos\n"
7148 "Hello multiplier factor\n"
7149 "Number of Hellos to send each second\n"
7150 "Address of interface\n")
7152 ALIAS (no_ip_ospf_dead_interval
,
7153 no_ip_ospf_dead_interval_minimal_cmd
,
7154 "no ip ospf dead-interval minimal hello-multiplier <1-10>",
7157 "OSPF interface commands\n"
7158 "Interval after which a neighbor is declared dead\n"
7159 "Minimal 1s dead-interval with fast sub-second hellos\n"
7160 "Hello multiplier factor\n"
7161 "Number of Hellos to send each second\n")
7163 DEFUN (ip_ospf_hello_interval
,
7164 ip_ospf_hello_interval_addr_cmd
,
7165 "ip ospf hello-interval <1-65535> A.B.C.D",
7167 "OSPF interface commands\n"
7168 "Time between HELLO packets\n"
7170 "Address of interface")
7172 struct interface
*ifp
= vty
->index
;
7174 struct in_addr addr
;
7176 struct ospf_if_params
*params
;
7178 params
= IF_DEF_PARAMS (ifp
);
7180 seconds
= strtol (argv
[0], NULL
, 10);
7182 /* HelloInterval range is <1-65535>. */
7183 if (seconds
< 1 || seconds
> 65535)
7185 vty_out (vty
, "Hello Interval is invalid%s", VTY_NEWLINE
);
7191 ret
= inet_aton(argv
[1], &addr
);
7194 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7199 params
= ospf_get_if_params (ifp
, addr
);
7200 ospf_if_update_params (ifp
, addr
);
7203 SET_IF_PARAM (params
, v_hello
);
7204 params
->v_hello
= seconds
;
7209 ALIAS (ip_ospf_hello_interval
,
7210 ip_ospf_hello_interval_cmd
,
7211 "ip ospf hello-interval <1-65535>",
7213 "OSPF interface commands\n"
7214 "Time between HELLO packets\n"
7217 ALIAS_HIDDEN (ip_ospf_hello_interval
,
7218 ospf_hello_interval_cmd
,
7219 "ospf hello-interval <1-65535>",
7220 "OSPF interface commands\n"
7221 "Time between HELLO packets\n"
7224 DEFUN (no_ip_ospf_hello_interval
,
7225 no_ip_ospf_hello_interval_addr_cmd
,
7226 "no ip ospf hello-interval <1-65535> A.B.C.D",
7229 "OSPF interface commands\n"
7230 "Time between HELLO packets\n"
7232 "Address of interface")
7234 struct interface
*ifp
= vty
->index
;
7235 struct in_addr addr
;
7237 struct ospf_if_params
*params
;
7240 params
= IF_DEF_PARAMS (ifp
);
7244 ret
= inet_aton(argv
[1], &addr
);
7247 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7252 params
= ospf_lookup_if_params (ifp
, addr
);
7257 UNSET_IF_PARAM (params
, v_hello
);
7258 params
->v_hello
= OSPF_HELLO_INTERVAL_DEFAULT
;
7260 if (params
!= IF_DEF_PARAMS (ifp
))
7262 ospf_free_if_params (ifp
, addr
);
7263 ospf_if_update_params (ifp
, addr
);
7269 ALIAS (no_ip_ospf_hello_interval
,
7270 no_ip_ospf_hello_interval_seconds_cmd
,
7271 "no ip ospf hello-interval <1-65535>",
7274 "OSPF interface commands\n"
7275 "Time between HELLO packets\n"
7278 ALIAS (no_ip_ospf_hello_interval
,
7279 no_ip_ospf_hello_interval_cmd
,
7280 "no ip ospf hello-interval",
7283 "OSPF interface commands\n"
7284 "Time between HELLO packets\n")
7286 ALIAS (no_ip_ospf_hello_interval
,
7287 no_ospf_hello_interval_cmd
,
7288 "no ospf hello-interval <1-65535>",
7290 "OSPF interface commands\n"
7291 "Time between HELLO packets\n"
7294 DEFUN (ip_ospf_network
,
7295 ip_ospf_network_cmd
,
7296 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
7298 "OSPF interface commands\n"
7300 "Specify OSPF broadcast multi-access network\n"
7301 "Specify OSPF NBMA network\n"
7302 "Specify OSPF point-to-multipoint network\n"
7303 "Specify OSPF point-to-point network\n")
7305 struct interface
*ifp
= vty
->index
;
7306 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
7307 struct route_node
*rn
;
7309 if (old_type
== OSPF_IFTYPE_LOOPBACK
)
7311 vty_out (vty
, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE
);
7315 if (strncmp (argv
[0], "b", 1) == 0)
7316 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_BROADCAST
;
7317 else if (strncmp (argv
[0], "n", 1) == 0)
7318 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_NBMA
;
7319 else if (strncmp (argv
[0], "point-to-m", 10) == 0)
7320 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOMULTIPOINT
;
7321 else if (strncmp (argv
[0], "point-to-p", 10) == 0)
7322 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOPOINT
;
7324 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
7327 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), type
);
7329 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7331 struct ospf_interface
*oi
= rn
->info
;
7336 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
7338 if (oi
->state
> ISM_Down
)
7340 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
7341 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
7348 ALIAS_HIDDEN (ip_ospf_network
,
7350 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
7351 "OSPF interface commands\n"
7353 "Specify OSPF broadcast multi-access network\n"
7354 "Specify OSPF NBMA network\n"
7355 "Specify OSPF point-to-multipoint network\n"
7356 "Specify OSPF point-to-point network\n")
7358 DEFUN (no_ip_ospf_network
,
7359 no_ip_ospf_network_cmd
,
7360 "no ip ospf network",
7363 "OSPF interface commands\n"
7366 struct interface
*ifp
= vty
->index
;
7367 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
7368 struct route_node
*rn
;
7370 IF_DEF_PARAMS (ifp
)->type
= ospf_default_iftype(ifp
);
7372 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
7375 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7377 struct ospf_interface
*oi
= rn
->info
;
7382 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
7384 if (oi
->state
> ISM_Down
)
7386 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
7387 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
7394 ALIAS (no_ip_ospf_network
,
7395 no_ip_ospf_network_val_cmd
,
7396 "no ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
7399 "OSPF interface commands\n"
7401 "Specify OSPF broadcast multi-access network\n"
7402 "Specify OSPF NBMA network\n"
7403 "Specify OSPF point-to-multipoint network\n"
7404 "Specify OSPF point-to-point network\n")
7406 ALIAS (no_ip_ospf_network
,
7407 no_ospf_network_cmd
,
7410 "OSPF interface commands\n"
7413 ALIAS (no_ip_ospf_network
,
7414 no_ospf_network_val_cmd
,
7415 "no ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
7417 "OSPF interface commands\n"
7419 "Specify OSPF broadcast multi-access network\n"
7420 "Specify OSPF NBMA network\n"
7421 "Specify OSPF point-to-multipoint network\n"
7422 "Specify OSPF point-to-point network\n")
7424 DEFUN (ip_ospf_priority
,
7425 ip_ospf_priority_addr_cmd
,
7426 "ip ospf priority <0-255> A.B.C.D",
7428 "OSPF interface commands\n"
7431 "Address of interface")
7433 struct interface
*ifp
= vty
->index
;
7435 struct route_node
*rn
;
7436 struct in_addr addr
;
7438 struct ospf_if_params
*params
;
7440 params
= IF_DEF_PARAMS (ifp
);
7442 priority
= strtol (argv
[0], NULL
, 10);
7444 /* Router Priority range is <0-255>. */
7445 if (priority
< 0 || priority
> 255)
7447 vty_out (vty
, "Router Priority is invalid%s", VTY_NEWLINE
);
7453 ret
= inet_aton(argv
[1], &addr
);
7456 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7461 params
= ospf_get_if_params (ifp
, addr
);
7462 ospf_if_update_params (ifp
, addr
);
7465 SET_IF_PARAM (params
, priority
);
7466 params
->priority
= priority
;
7468 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7470 struct ospf_interface
*oi
= rn
->info
;
7476 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
7478 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
7479 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
7486 ALIAS (ip_ospf_priority
,
7487 ip_ospf_priority_cmd
,
7488 "ip ospf priority <0-255>",
7490 "OSPF interface commands\n"
7494 ALIAS_HIDDEN (ip_ospf_priority
,
7496 "ospf priority <0-255>",
7497 "OSPF interface commands\n"
7501 DEFUN (no_ip_ospf_priority
,
7502 no_ip_ospf_priority_addr_cmd
,
7503 "no ip ospf priority <0-255> A.B.C.D",
7506 "OSPF interface commands\n"
7509 "Address of interface")
7511 struct interface
*ifp
= vty
->index
;
7512 struct route_node
*rn
;
7513 struct in_addr addr
;
7515 struct ospf_if_params
*params
;
7518 params
= IF_DEF_PARAMS (ifp
);
7522 ret
= inet_aton(argv
[1], &addr
);
7525 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7530 params
= ospf_lookup_if_params (ifp
, addr
);
7535 UNSET_IF_PARAM (params
, priority
);
7536 params
->priority
= OSPF_ROUTER_PRIORITY_DEFAULT
;
7538 if (params
!= IF_DEF_PARAMS (ifp
))
7540 ospf_free_if_params (ifp
, addr
);
7541 ospf_if_update_params (ifp
, addr
);
7544 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7546 struct ospf_interface
*oi
= rn
->info
;
7552 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
7554 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
7555 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
7562 ALIAS (no_ip_ospf_priority
,
7563 no_ip_ospf_priority_no_param_cmd
,
7564 "no ip ospf priority",
7567 "OSPF interface commands\n"
7568 "Router priority\n");
7570 ALIAS (no_ip_ospf_priority
,
7571 no_ip_ospf_priority_cmd
,
7572 "no ip ospf priority <0-255>",
7575 "OSPF interface commands\n"
7579 ALIAS (no_ip_ospf_priority
,
7580 no_ospf_priority_cmd
,
7581 "no ospf priority <0-255>",
7583 "OSPF interface commands\n"
7588 DEFUN (ip_ospf_retransmit_interval
,
7589 ip_ospf_retransmit_interval_addr_cmd
,
7590 "ip ospf retransmit-interval <3-65535> A.B.C.D",
7592 "OSPF interface commands\n"
7593 "Time between retransmitting lost link state advertisements\n"
7595 "Address of interface")
7597 struct interface
*ifp
= vty
->index
;
7599 struct in_addr addr
;
7601 struct ospf_if_params
*params
;
7603 params
= IF_DEF_PARAMS (ifp
);
7604 seconds
= strtol (argv
[0], NULL
, 10);
7606 /* Retransmit Interval range is <3-65535>. */
7607 if (seconds
< 3 || seconds
> 65535)
7609 vty_out (vty
, "Retransmit Interval is invalid%s", VTY_NEWLINE
);
7616 ret
= inet_aton(argv
[1], &addr
);
7619 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7624 params
= ospf_get_if_params (ifp
, addr
);
7625 ospf_if_update_params (ifp
, addr
);
7628 SET_IF_PARAM (params
, retransmit_interval
);
7629 params
->retransmit_interval
= seconds
;
7634 ALIAS (ip_ospf_retransmit_interval
,
7635 ip_ospf_retransmit_interval_cmd
,
7636 "ip ospf retransmit-interval <3-65535>",
7638 "OSPF interface commands\n"
7639 "Time between retransmitting lost link state advertisements\n"
7642 ALIAS_HIDDEN (ip_ospf_retransmit_interval
,
7643 ospf_retransmit_interval_cmd
,
7644 "ospf retransmit-interval <3-65535>",
7645 "OSPF interface commands\n"
7646 "Time between retransmitting lost link state advertisements\n"
7649 DEFUN (no_ip_ospf_retransmit_interval
,
7650 no_ip_ospf_retransmit_interval_addr_cmd
,
7651 "no ip ospf retransmit-interval A.B.C.D",
7654 "OSPF interface commands\n"
7655 "Time between retransmitting lost link state advertisements\n"
7656 "Address of interface")
7658 struct interface
*ifp
= vty
->index
;
7659 struct in_addr addr
;
7661 struct ospf_if_params
*params
;
7665 params
= IF_DEF_PARAMS (ifp
);
7674 ret
= inet_aton(argv
[addr_index
], &addr
);
7677 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7682 params
= ospf_lookup_if_params (ifp
, addr
);
7687 UNSET_IF_PARAM (params
, retransmit_interval
);
7688 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
7690 if (params
!= IF_DEF_PARAMS (ifp
))
7692 ospf_free_if_params (ifp
, addr
);
7693 ospf_if_update_params (ifp
, addr
);
7699 ALIAS (no_ip_ospf_retransmit_interval
,
7700 no_ip_ospf_retransmit_interval_sec_addr_cmd
,
7701 "no ip ospf retransmit-interval <3-65535> A.B.C.D",
7704 "OSPF interface commands\n"
7705 "Time between retransmitting lost link state advertisements\n"
7707 "Address of interface")
7709 ALIAS (no_ip_ospf_retransmit_interval
,
7710 no_ip_ospf_retransmit_interval_cmd
,
7711 "no ip ospf retransmit-interval",
7714 "OSPF interface commands\n"
7715 "Time between retransmitting lost link state advertisements\n")
7717 ALIAS (no_ip_ospf_retransmit_interval
,
7718 no_ospf_retransmit_interval_cmd
,
7719 "no ospf retransmit-interval",
7721 "OSPF interface commands\n"
7722 "Time between retransmitting lost link state advertisements\n")
7724 DEFUN (no_ip_ospf_retransmit_interval_sec
,
7725 no_ip_ospf_retransmit_interval_sec_cmd
,
7726 "no ip ospf retransmit-interval <3-65535>",
7729 "OSPF interface commands\n"
7730 "Time between retransmitting lost link state advertisements\n"
7733 struct interface
*ifp
= vty
->index
;
7734 struct ospf_if_params
*params
;
7737 params
= IF_DEF_PARAMS (ifp
);
7739 UNSET_IF_PARAM (params
, retransmit_interval
);
7740 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
7746 DEFUN (ip_ospf_transmit_delay
,
7747 ip_ospf_transmit_delay_addr_cmd
,
7748 "ip ospf transmit-delay <1-65535> A.B.C.D",
7750 "OSPF interface commands\n"
7751 "Link state transmit delay\n"
7753 "Address of interface")
7755 struct interface
*ifp
= vty
->index
;
7757 struct in_addr addr
;
7759 struct ospf_if_params
*params
;
7761 params
= IF_DEF_PARAMS (ifp
);
7762 seconds
= strtol (argv
[0], NULL
, 10);
7764 /* Transmit Delay range is <1-65535>. */
7765 if (seconds
< 1 || seconds
> 65535)
7767 vty_out (vty
, "Transmit Delay is invalid%s", VTY_NEWLINE
);
7773 ret
= inet_aton(argv
[1], &addr
);
7776 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7781 params
= ospf_get_if_params (ifp
, addr
);
7782 ospf_if_update_params (ifp
, addr
);
7785 SET_IF_PARAM (params
, transmit_delay
);
7786 params
->transmit_delay
= seconds
;
7791 ALIAS (ip_ospf_transmit_delay
,
7792 ip_ospf_transmit_delay_cmd
,
7793 "ip ospf transmit-delay <1-65535>",
7795 "OSPF interface commands\n"
7796 "Link state transmit delay\n"
7799 ALIAS_HIDDEN (ip_ospf_transmit_delay
,
7800 ospf_transmit_delay_cmd
,
7801 "ospf transmit-delay <1-65535>",
7802 "OSPF interface commands\n"
7803 "Link state transmit delay\n"
7806 DEFUN (no_ip_ospf_transmit_delay
,
7807 no_ip_ospf_transmit_delay_addr_cmd
,
7808 "no ip ospf transmit-delay A.B.C.D",
7811 "OSPF interface commands\n"
7812 "Link state transmit delay\n"
7813 "Address of interface")
7815 struct interface
*ifp
= vty
->index
;
7816 struct in_addr addr
;
7818 struct ospf_if_params
*params
;
7822 params
= IF_DEF_PARAMS (ifp
);
7831 ret
= inet_aton(argv
[addr_index
], &addr
);
7834 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7839 params
= ospf_lookup_if_params (ifp
, addr
);
7844 UNSET_IF_PARAM (params
, transmit_delay
);
7845 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
7847 if (params
!= IF_DEF_PARAMS (ifp
))
7849 ospf_free_if_params (ifp
, addr
);
7850 ospf_if_update_params (ifp
, addr
);
7856 ALIAS (no_ip_ospf_transmit_delay
,
7857 no_ip_ospf_transmit_delay_sec_addr_cmd
,
7858 "no ip ospf transmit-delay <1-65535> A.B.C.D",
7861 "OSPF interface commands\n"
7862 "Link state transmit delay\n"
7864 "Address of interface")
7866 ALIAS (no_ip_ospf_transmit_delay
,
7867 no_ip_ospf_transmit_delay_cmd
,
7868 "no ip ospf transmit-delay",
7871 "OSPF interface commands\n"
7872 "Link state transmit delay\n")
7874 ALIAS (no_ip_ospf_transmit_delay
,
7875 no_ospf_transmit_delay_cmd
,
7876 "no ospf transmit-delay",
7878 "OSPF interface commands\n"
7879 "Link state transmit delay\n")
7881 DEFUN (no_ip_ospf_transmit_delay_sec
,
7882 no_ip_ospf_transmit_delay_sec_cmd
,
7883 "no ip ospf transmit-delay <1-65535>",
7886 "OSPF interface commands\n"
7887 "Link state transmit delay\n"
7889 "Address of interface")
7891 struct interface
*ifp
= vty
->index
;
7892 struct ospf_if_params
*params
;
7895 params
= IF_DEF_PARAMS (ifp
);
7897 UNSET_IF_PARAM (params
, transmit_delay
);
7898 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
7903 DEFUN (ip_ospf_area
,
7905 "ip ospf area (A.B.C.D|<0-4294967295>)",
7907 "OSPF interface commands\n"
7908 "Enable OSPF on this interface\n"
7909 "OSPF area ID in IP address format\n"
7910 "OSPF area ID as a decimal value\n")
7912 struct interface
*ifp
= vty
->index
;
7914 struct in_addr area_id
;
7916 struct ospf_if_params
*params
;
7917 struct route_node
*rn
;
7918 u_short instance
= 0;
7921 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
7923 ospf
= ospf_lookup_instance (instance
);
7926 params
= IF_DEF_PARAMS (ifp
);
7927 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7929 ospf_interface_unset (ifp
);
7930 ospf
= ospf_lookup();
7931 ospf
->if_ospf_cli_count
--;
7936 ret
= ospf_str2area_id (argv
[instance
? 1 : 0], &area_id
, &format
);
7939 vty_out (vty
, "Please specify area by A.B.C.D|<0-4294967295>%s",
7943 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
7945 vty_out (vty
, "Cannot enable OSPF on a virtual link.%s", VTY_NEWLINE
);
7949 params
= IF_DEF_PARAMS (ifp
);
7950 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7953 "Must remove previous area config before changing ospf area %s",
7958 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
7960 if (rn
->info
!= NULL
)
7962 vty_out (vty
, "Please remove all network commands first.%s", VTY_NEWLINE
);
7967 /* enable ospf on this interface with area_id */
7968 ospf_interface_set (ifp
, area_id
);
7969 ospf
->if_ospf_cli_count
++;
7974 ALIAS (ip_ospf_area
,
7975 ip_ospf_instance_area_cmd
,
7976 "ip ospf <1-65535> area (A.B.C.D|<0-4294967295>)",
7978 "OSPF interface commands\n"
7980 "Enable OSPF on this interface\n"
7981 "OSPF area ID in IP address format\n"
7982 "OSPF area ID as a decimal value\n")
7984 DEFUN (no_ip_ospf_area
,
7985 no_ip_ospf_area_cmd
,
7989 "OSPF interface commands\n"
7990 "Disable OSPF on this interface\n")
7992 struct interface
*ifp
= vty
->index
;
7994 struct ospf_if_params
*params
;
7995 u_short instance
= 0;
7997 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
8000 params
= IF_DEF_PARAMS (ifp
);
8001 if (!OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
8003 vty_out (vty
, "Can't find specified inteface area configuration.%s", VTY_NEWLINE
);
8007 ospf_interface_unset (ifp
);
8008 ospf
->if_ospf_cli_count
--;
8012 ALIAS (no_ip_ospf_area
,
8013 no_ip_ospf_area_val_cmd
,
8014 "no ip ospf area (A.B.C.D|<0-4294967295>)",
8017 "OSPF interface commands\n"
8018 "Disable OSPF on this interface\n"
8019 "OSPF area ID in IP address format\n"
8020 "OSPF area ID as a decimal value\n")
8022 DEFUN (no_ip_ospf_instance_area
,
8023 no_ip_ospf_instance_area_cmd
,
8024 "no ip ospf <1-65535> area",
8027 "OSPF interface commands\n"
8029 "Disable OSPF on this interface\n")
8031 struct interface
*ifp
= vty
->index
;
8033 struct ospf_if_params
*params
;
8034 u_short instance
= 0;
8036 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
8038 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
8041 params
= IF_DEF_PARAMS (ifp
);
8042 if (!OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
8044 vty_out (vty
, "Can't find specified inteface area configuration.%s", VTY_NEWLINE
);
8048 ospf_interface_unset (ifp
);
8049 ospf
->if_ospf_cli_count
--;
8053 ALIAS (no_ip_ospf_instance_area
,
8054 no_ip_ospf_instance_area_val_cmd
,
8055 "no ip ospf <1-65535> area (A.B.C.D|<0-4294967295>)",
8058 "OSPF interface commands\n"
8060 "Disable OSPF on this interface\n"
8061 "OSPF area ID in IP address format\n"
8062 "OSPF area ID as a decimal value\n")
8064 DEFUN (ospf_redistribute_source
,
8065 ospf_redistribute_source_cmd
,
8066 "redistribute " QUAGGA_REDIST_STR_OSPFD
8067 " {metric <0-16777214>|metric-type (1|2)|route-map WORD}",
8069 QUAGGA_REDIST_HELP_STR_OSPFD
8070 "Metric for redistributed routes\n"
8071 "OSPF default metric\n"
8072 "OSPF exterior metric type for redistributed routes\n"
8073 "Set OSPF External Type 1 metrics\n"
8074 "Set OSPF External Type 2 metrics\n"
8075 "Route map reference\n"
8076 "Pointer to route-map entries\n")
8078 struct ospf
*ospf
= vty
->index
;
8082 struct ospf_redist
*red
;
8088 return CMD_WARNING
; /* should not happen */
8093 /* Get distribute source. */
8094 source
= proto_redistnum(AFI_IP
, argv
[0]);
8095 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
8098 /* Get metric value. */
8099 if (argv
[1] != NULL
)
8100 if (!str2metric (argv
[1], &metric
))
8103 /* Get metric type. */
8104 if (argv
[2] != NULL
)
8105 if (!str2metric_type (argv
[2], &type
))
8108 red
= ospf_redist_add(ospf
, source
, 0);
8110 if (argv
[3] != NULL
)
8111 ospf_routemap_set (red
, argv
[3]);
8113 ospf_routemap_unset (red
);
8115 return ospf_redistribute_set (ospf
, source
, 0, type
, metric
);
8118 DEFUN (no_ospf_redistribute_source
,
8119 no_ospf_redistribute_source_cmd
,
8120 "no redistribute " QUAGGA_REDIST_STR_OSPFD
8121 " {metric <0-16777214>|metric-type (1|2)|route-map WORD}",
8124 QUAGGA_REDIST_HELP_STR_OSPFD
8125 "Metric for redistributed routes\n"
8126 "OSPF default metric\n"
8127 "OSPF exterior metric type for redistributed routes\n"
8128 "Set OSPF External Type 1 metrics\n"
8129 "Set OSPF External Type 2 metrics\n"
8130 "Route map reference\n"
8131 "Pointer to route-map entries\n")
8133 struct ospf
*ospf
= vty
->index
;
8135 struct ospf_redist
*red
;
8139 source
= proto_redistnum(AFI_IP
, argv
[0]);
8140 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
8143 red
= ospf_redist_lookup(ospf
, source
, 0);
8147 ospf_routemap_unset (red
);
8148 return ospf_redistribute_unset (ospf
, source
, 0);
8151 DEFUN (ospf_redistribute_instance_source
,
8152 ospf_redistribute_instance_source_cmd
,
8153 "redistribute (ospf|table) <1-65535>"
8154 " {metric <0-16777214>|metric-type (1|2)|route-map WORD}",
8156 "Open Shortest Path First\n"
8157 "Non-main Kernel Routing Table\n"
8158 "Instance ID/Table ID\n"
8159 "Metric for redistributed routes\n"
8160 "OSPF default metric\n"
8161 "OSPF exterior metric type for redistributed routes\n"
8162 "Set OSPF External Type 1 metrics\n"
8163 "Set OSPF External Type 2 metrics\n"
8164 "Route map reference\n"
8165 "Pointer to route-map entries\n")
8167 struct ospf
*ospf
= vty
->index
;
8172 struct ospf_redist
*red
;
8177 if (strncmp(argv
[0], "o", 1) == 0)
8178 source
= ZEBRA_ROUTE_OSPF
;
8180 source
= ZEBRA_ROUTE_TABLE
;
8182 VTY_GET_INTEGER ("Instance ID", instance
, argv
[1]);
8187 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
8189 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
8194 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
8196 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
8201 /* Get metric value. */
8202 if (argv
[2] != NULL
)
8203 if (!str2metric (argv
[2], &metric
))
8206 /* Get metric type. */
8207 if (argv
[3] != NULL
)
8208 if (!str2metric_type (argv
[3], &type
))
8211 red
= ospf_redist_add(ospf
, source
, instance
);
8212 if (argv
[4] != NULL
)
8213 ospf_routemap_set (red
, argv
[4]);
8215 ospf_routemap_unset (red
);
8217 return ospf_redistribute_set (ospf
, source
, instance
, type
, metric
);
8220 DEFUN (no_ospf_redistribute_instance_source
,
8221 no_ospf_redistribute_instance_source_cmd
,
8222 "no redistribute (ospf|table) <1-65535>"
8223 " {metric <0-16777214>|metric-type (1|2)|route-map WORD}",
8226 "Open Shortest Path First\n"
8227 "Non-main Kernel Routing Table\n"
8228 "Instance ID/Table Id\n"
8229 "Metric for redistributed routes\n"
8230 "OSPF default metric\n"
8231 "OSPF exterior metric type for redistributed routes\n"
8232 "Set OSPF External Type 1 metrics\n"
8233 "Set OSPF External Type 2 metrics\n"
8234 "Route map reference\n"
8235 "Pointer to route-map entries\n")
8237 struct ospf
*ospf
= vty
->index
;
8239 struct ospf_redist
*red
;
8245 if (strncmp(argv
[0], "o", 1) == 0)
8246 source
= ZEBRA_ROUTE_OSPF
;
8248 source
= ZEBRA_ROUTE_TABLE
;
8250 VTY_GET_INTEGER ("Instance ID", instance
, argv
[1]);
8252 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
8254 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
8259 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
8261 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
8266 red
= ospf_redist_lookup(ospf
, source
, instance
);
8270 ospf_routemap_unset (red
);
8271 return ospf_redistribute_unset (ospf
, source
, instance
);
8274 DEFUN (ospf_distribute_list_out
,
8275 ospf_distribute_list_out_cmd
,
8276 "distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD
,
8277 "Filter networks in routing updates\n"
8278 "Access-list name\n"
8280 QUAGGA_REDIST_HELP_STR_OSPFD
)
8282 struct ospf
*ospf
= vty
->index
;
8288 /* Get distribute source. */
8289 source
= proto_redistnum(AFI_IP
, argv
[1]);
8290 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
8293 return ospf_distribute_list_out_set (ospf
, source
, argv
[0]);
8296 DEFUN (no_ospf_distribute_list_out
,
8297 no_ospf_distribute_list_out_cmd
,
8298 "no distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD
,
8300 "Filter networks in routing updates\n"
8301 "Access-list name\n"
8303 QUAGGA_REDIST_HELP_STR_OSPFD
)
8305 struct ospf
*ospf
= vty
->index
;
8311 source
= proto_redistnum(AFI_IP
, argv
[1]);
8312 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
8315 return ospf_distribute_list_out_unset (ospf
, source
, argv
[0]);
8318 /* Default information originate. */
8319 DEFUN (ospf_default_information_originate
,
8320 ospf_default_information_originate_cmd
,
8321 "default-information originate "
8322 "{always|metric <0-16777214>|metric-type (1|2)|route-map WORD}",
8323 "Control distribution of default information\n"
8324 "Distribute a default route\n"
8325 "Always advertise default route\n"
8326 "OSPF default metric\n"
8328 "OSPF metric type for default routes\n"
8329 "Set OSPF External Type 1 metrics\n"
8330 "Set OSPF External Type 2 metrics\n"
8331 "Route map reference\n"
8332 "Pointer to route-map entries\n")
8334 struct ospf
*ospf
= vty
->index
;
8335 int default_originate
= DEFAULT_ORIGINATE_ZEBRA
;
8338 struct ospf_redist
*red
;
8344 return CMD_WARNING
; /* this should not happen */
8346 /* Check whether "always" was specified */
8347 if (argv
[0] != NULL
)
8348 default_originate
= DEFAULT_ORIGINATE_ALWAYS
;
8350 red
= ospf_redist_add(ospf
, DEFAULT_ROUTE
, 0);
8352 /* Get metric value. */
8353 if (argv
[1] != NULL
)
8354 if (!str2metric (argv
[1], &metric
))
8357 /* Get metric type. */
8358 if (argv
[2] != NULL
)
8359 if (!str2metric_type (argv
[2], &type
))
8362 if (argv
[3] != NULL
)
8363 ospf_routemap_set (red
, argv
[3]);
8365 ospf_routemap_unset (red
);
8367 return ospf_redistribute_default_set (ospf
, default_originate
,
8371 DEFUN (no_ospf_default_information_originate
,
8372 no_ospf_default_information_originate_cmd
,
8373 "no default-information originate"
8374 "{always|metric <0-16777214>|metric-type (1|2)|route-map WORD}",
8376 "Control distribution of default information\n"
8377 "Distribute a default route\n"
8378 "Always advertise default route\n"
8379 "OSPF default metric\n"
8381 "OSPF metric type for default routes\n"
8382 "Set OSPF External Type 1 metrics\n"
8383 "Set OSPF External Type 2 metrics\n"
8384 "Route map reference\n"
8385 "Pointer to route-map entries\n")
8387 struct ospf
*ospf
= vty
->index
;
8388 struct prefix_ipv4 p
;
8389 struct ospf_external
*ext
;
8390 struct ospf_redist
*red
;
8396 p
.prefix
.s_addr
= 0;
8399 ospf_external_lsa_flush (ospf
, DEFAULT_ROUTE
, &p
, 0);
8401 if ((ext
= ospf_external_lookup(DEFAULT_ROUTE
, 0)) &&
8402 EXTERNAL_INFO (ext
)) {
8403 ospf_external_info_delete (DEFAULT_ROUTE
, 0, p
);
8404 ospf_external_del (DEFAULT_ROUTE
, 0);
8407 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
8411 ospf_routemap_unset (red
);
8412 return ospf_redistribute_default_unset (ospf
);
8415 DEFUN (ospf_default_metric
,
8416 ospf_default_metric_cmd
,
8417 "default-metric <0-16777214>",
8418 "Set metric of redistributed routes\n"
8421 struct ospf
*ospf
= vty
->index
;
8427 if (!str2metric (argv
[0], &metric
))
8430 ospf
->default_metric
= metric
;
8435 DEFUN (no_ospf_default_metric
,
8436 no_ospf_default_metric_cmd
,
8437 "no default-metric",
8439 "Set metric of redistributed routes\n")
8441 struct ospf
*ospf
= vty
->index
;
8446 ospf
->default_metric
= -1;
8451 ALIAS (no_ospf_default_metric
,
8452 no_ospf_default_metric_val_cmd
,
8453 "no default-metric <0-16777214>",
8455 "Set metric of redistributed routes\n"
8458 DEFUN (ospf_distance
,
8461 "Define an administrative distance\n"
8462 "OSPF Administrative distance\n")
8464 struct ospf
*ospf
= vty
->index
;
8469 ospf
->distance_all
= atoi (argv
[0]);
8474 DEFUN (no_ospf_distance
,
8475 no_ospf_distance_cmd
,
8476 "no distance <1-255>",
8478 "Define an administrative distance\n"
8479 "OSPF Administrative distance\n")
8481 struct ospf
*ospf
= vty
->index
;
8486 ospf
->distance_all
= 0;
8491 DEFUN (no_ospf_distance_ospf
,
8492 no_ospf_distance_ospf_cmd
,
8493 "no distance ospf {intra-area <1-255>|inter-area <1-255>|external <1-255>}",
8495 "Define an administrative distance\n"
8496 "OSPF Administrative distance\n"
8497 "Intra-area routes\n"
8498 "Distance for intra-area routes\n"
8499 "Inter-area routes\n"
8500 "Distance for inter-area routes\n"
8502 "Distance for external routes\n")
8504 struct ospf
*ospf
= vty
->index
;
8515 if (argv
[0] != NULL
)
8516 ospf
->distance_intra
= 0;
8518 if (argv
[1] != NULL
)
8519 ospf
->distance_inter
= 0;
8521 if (argv
[2] != NULL
)
8522 ospf
->distance_external
= 0;
8524 if (argv
[0] || argv
[1] || argv
[2])
8527 /* If no arguments are given, clear all distance information */
8528 ospf
->distance_intra
= 0;
8529 ospf
->distance_inter
= 0;
8530 ospf
->distance_external
= 0;
8535 DEFUN (ospf_distance_ospf
,
8536 ospf_distance_ospf_cmd
,
8538 "{intra-area <1-255>|inter-area <1-255>|external <1-255>}",
8539 "Define an administrative distance\n"
8540 "OSPF Administrative distance\n"
8541 "Intra-area routes\n"
8542 "Distance for intra-area routes\n"
8543 "Inter-area routes\n"
8544 "Distance for inter-area routes\n"
8546 "Distance for external routes\n")
8548 struct ospf
*ospf
= vty
->index
;
8553 if (argc
< 3) /* should not happen */
8556 if (!argv
[0] && !argv
[1] && !argv
[2])
8558 vty_out(vty
, "%% Command incomplete. (Arguments required)%s",
8563 if (argv
[0] != NULL
)
8564 ospf
->distance_intra
= atoi(argv
[0]);
8566 if (argv
[1] != NULL
)
8567 ospf
->distance_inter
= atoi(argv
[1]);
8569 if (argv
[2] != NULL
)
8570 ospf
->distance_external
= atoi(argv
[2]);
8575 DEFUN (ospf_distance_source
,
8576 ospf_distance_source_cmd
,
8577 "distance <1-255> A.B.C.D/M",
8578 "Administrative distance\n"
8580 "IP source prefix\n")
8582 struct ospf
*ospf
= vty
->index
;
8587 ospf_distance_set (vty
, ospf
, argv
[0], argv
[1], NULL
);
8592 DEFUN (no_ospf_distance_source
,
8593 no_ospf_distance_source_cmd
,
8594 "no distance <1-255> A.B.C.D/M",
8596 "Administrative distance\n"
8598 "IP source prefix\n")
8600 struct ospf
*ospf
= vty
->index
;
8605 ospf_distance_unset (vty
, ospf
, argv
[0], argv
[1], NULL
);
8610 DEFUN (ospf_distance_source_access_list
,
8611 ospf_distance_source_access_list_cmd
,
8612 "distance <1-255> A.B.C.D/M WORD",
8613 "Administrative distance\n"
8615 "IP source prefix\n"
8616 "Access list name\n")
8618 struct ospf
*ospf
= vty
->index
;
8623 ospf_distance_set (vty
, ospf
, argv
[0], argv
[1], argv
[2]);
8628 DEFUN (no_ospf_distance_source_access_list
,
8629 no_ospf_distance_source_access_list_cmd
,
8630 "no distance <1-255> A.B.C.D/M WORD",
8632 "Administrative distance\n"
8634 "IP source prefix\n"
8635 "Access list name\n")
8637 struct ospf
*ospf
= vty
->index
;
8642 ospf_distance_unset (vty
, ospf
, argv
[0], argv
[1], argv
[2]);
8647 DEFUN (ip_ospf_mtu_ignore
,
8648 ip_ospf_mtu_ignore_addr_cmd
,
8649 "ip ospf mtu-ignore A.B.C.D",
8651 "OSPF interface commands\n"
8652 "Disable mtu mismatch detection\n"
8653 "Address of interface")
8655 struct interface
*ifp
= vty
->index
;
8656 struct in_addr addr
;
8659 struct ospf_if_params
*params
;
8660 params
= IF_DEF_PARAMS (ifp
);
8664 ret
= inet_aton(argv
[0], &addr
);
8667 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
8671 params
= ospf_get_if_params (ifp
, addr
);
8672 ospf_if_update_params (ifp
, addr
);
8674 params
->mtu_ignore
= 1;
8675 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
8676 SET_IF_PARAM (params
, mtu_ignore
);
8679 UNSET_IF_PARAM (params
, mtu_ignore
);
8680 if (params
!= IF_DEF_PARAMS (ifp
))
8682 ospf_free_if_params (ifp
, addr
);
8683 ospf_if_update_params (ifp
, addr
);
8689 ALIAS (ip_ospf_mtu_ignore
,
8690 ip_ospf_mtu_ignore_cmd
,
8691 "ip ospf mtu-ignore",
8693 "OSPF interface commands\n"
8694 "Disable mtu mismatch detection\n")
8697 DEFUN (no_ip_ospf_mtu_ignore
,
8698 no_ip_ospf_mtu_ignore_addr_cmd
,
8699 "no ip ospf mtu-ignore A.B.C.D",
8701 "OSPF interface commands\n"
8702 "Disable mtu mismatch detection\n"
8703 "Address of interface")
8705 struct interface
*ifp
= vty
->index
;
8706 struct in_addr addr
;
8709 struct ospf_if_params
*params
;
8710 params
= IF_DEF_PARAMS (ifp
);
8714 ret
= inet_aton(argv
[0], &addr
);
8717 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
8721 params
= ospf_get_if_params (ifp
, addr
);
8722 ospf_if_update_params (ifp
, addr
);
8724 params
->mtu_ignore
= 0;
8725 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
8726 SET_IF_PARAM (params
, mtu_ignore
);
8729 UNSET_IF_PARAM (params
, mtu_ignore
);
8730 if (params
!= IF_DEF_PARAMS (ifp
))
8732 ospf_free_if_params (ifp
, addr
);
8733 ospf_if_update_params (ifp
, addr
);
8739 ALIAS (no_ip_ospf_mtu_ignore
,
8740 no_ip_ospf_mtu_ignore_cmd
,
8741 "no ip ospf mtu-ignore",
8743 "OSPF interface commands\n"
8744 "Disable mtu mismatch detection\n")
8746 DEFUN (ospf_max_metric_router_lsa_admin
,
8747 ospf_max_metric_router_lsa_admin_cmd
,
8748 "max-metric router-lsa administrative",
8749 "OSPF maximum / infinite-distance metric\n"
8750 "Advertise own Router-LSA with infinite distance (stub router)\n"
8751 "Administratively applied, for an indefinite period\n")
8753 struct listnode
*ln
;
8754 struct ospf_area
*area
;
8755 struct ospf
*ospf
= vty
->index
;
8760 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
8762 SET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
8764 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
))
8765 ospf_router_lsa_update_area (area
);
8768 /* Allows for areas configured later to get the property */
8769 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_SET
;
8774 DEFUN (no_ospf_max_metric_router_lsa_admin
,
8775 no_ospf_max_metric_router_lsa_admin_cmd
,
8776 "no max-metric router-lsa administrative",
8778 "OSPF maximum / infinite-distance metric\n"
8779 "Advertise own Router-LSA with infinite distance (stub router)\n"
8780 "Administratively applied, for an indefinite period\n")
8782 struct listnode
*ln
;
8783 struct ospf_area
*area
;
8784 struct ospf
*ospf
= vty
->index
;
8789 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
8791 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
8793 /* Don't trample on the start-up stub timer */
8794 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
)
8795 && !area
->t_stub_router
)
8797 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
8798 ospf_router_lsa_update_area (area
);
8801 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET
;
8805 DEFUN (ospf_max_metric_router_lsa_startup
,
8806 ospf_max_metric_router_lsa_startup_cmd
,
8807 "max-metric router-lsa on-startup <5-86400>",
8808 "OSPF maximum / infinite-distance metric\n"
8809 "Advertise own Router-LSA with infinite distance (stub router)\n"
8810 "Automatically advertise stub Router-LSA on startup of OSPF\n"
8811 "Time (seconds) to advertise self as stub-router\n")
8813 unsigned int seconds
;
8814 struct ospf
*ospf
= vty
->index
;
8821 vty_out (vty
, "%% Must supply stub-router period");
8825 VTY_GET_INTEGER ("stub-router startup period", seconds
, argv
[0]);
8827 ospf
->stub_router_startup_time
= seconds
;
8832 DEFUN (no_ospf_max_metric_router_lsa_startup
,
8833 no_ospf_max_metric_router_lsa_startup_cmd
,
8834 "no max-metric router-lsa on-startup <5-86400>",
8836 "OSPF maximum / infinite-distance metric\n"
8837 "Advertise own Router-LSA with infinite distance (stub router)\n"
8838 "Automatically advertise stub Router-LSA on startup of OSPF\n"
8839 "Time (seconds) to advertise self as stub-router\n")
8841 struct listnode
*ln
;
8842 struct ospf_area
*area
;
8843 struct ospf
*ospf
= vty
->index
;
8848 ospf
->stub_router_startup_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
8850 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
8852 SET_FLAG (area
->stub_router_state
, OSPF_AREA_WAS_START_STUB_ROUTED
);
8853 OSPF_TIMER_OFF (area
->t_stub_router
);
8855 /* Don't trample on admin stub routed */
8856 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
8858 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
8859 ospf_router_lsa_update_area (area
);
8865 ALIAS (no_ospf_max_metric_router_lsa_startup
,
8866 no_ospf_max_metric_router_lsa_startup_no_param_cmd
,
8867 "no max-metric router-lsa on-startup",
8869 "OSPF maximum / infinite-distance metric\n"
8870 "Advertise own Router-LSA with infinite distance (stub router)\n"
8871 "Automatically advertise stub Router-LSA on startup of OSPF\n");
8873 DEFUN (ospf_max_metric_router_lsa_shutdown
,
8874 ospf_max_metric_router_lsa_shutdown_cmd
,
8875 "max-metric router-lsa on-shutdown <5-100>",
8876 "OSPF maximum / infinite-distance metric\n"
8877 "Advertise own Router-LSA with infinite distance (stub router)\n"
8878 "Advertise stub-router prior to full shutdown of OSPF\n"
8879 "Time (seconds) to wait till full shutdown\n")
8881 unsigned int seconds
;
8882 struct ospf
*ospf
= vty
->index
;
8889 vty_out (vty
, "%% Must supply stub-router shutdown period");
8893 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds
, argv
[0]);
8895 ospf
->stub_router_shutdown_time
= seconds
;
8900 DEFUN (no_ospf_max_metric_router_lsa_shutdown
,
8901 no_ospf_max_metric_router_lsa_shutdown_cmd
,
8902 "no max-metric router-lsa on-shutdown <5-100>",
8904 "OSPF maximum / infinite-distance metric\n"
8905 "Advertise own Router-LSA with infinite distance (stub router)\n"
8906 "Advertise stub-router prior to full shutdown of OSPF\n"
8907 "Time (seconds) to wait till full shutdown\n")
8909 struct ospf
*ospf
= vty
->index
;
8914 ospf
->stub_router_shutdown_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
8919 ALIAS (no_ospf_max_metric_router_lsa_shutdown
,
8920 no_ospf_max_metric_router_lsa_shutdown_no_param_cmd
,
8921 "no max-metric router-lsa on-shutdown",
8923 "OSPF maximum / infinite-distance metric\n"
8924 "Advertise own Router-LSA with infinite distance (stub router)\n"
8925 "Advertise stub-router prior to full shutdown of OSPF\n");
8928 config_write_stub_router (struct vty
*vty
, struct ospf
*ospf
)
8930 struct listnode
*ln
;
8931 struct ospf_area
*area
;
8933 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
8934 vty_out (vty
, " max-metric router-lsa on-startup %u%s",
8935 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
8936 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
8937 vty_out (vty
, " max-metric router-lsa on-shutdown %u%s",
8938 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
8939 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
8941 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
8943 vty_out (vty
, " max-metric router-lsa administrative%s",
8952 show_ip_ospf_route_network (struct vty
*vty
, struct route_table
*rt
)
8954 struct route_node
*rn
;
8955 struct ospf_route
*or;
8956 struct listnode
*pnode
, *pnnode
;
8957 struct ospf_path
*path
;
8959 vty_out (vty
, "============ OSPF network routing table ============%s",
8962 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
8963 if ((or = rn
->info
) != NULL
)
8966 snprintf (buf1
, 19, "%s/%d",
8967 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
8969 switch (or->path_type
)
8971 case OSPF_PATH_INTER_AREA
:
8972 if (or->type
== OSPF_DESTINATION_NETWORK
)
8973 vty_out (vty
, "N IA %-18s [%d] area: %s%s", buf1
, or->cost
,
8974 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
8975 else if (or->type
== OSPF_DESTINATION_DISCARD
)
8976 vty_out (vty
, "D IA %-18s Discard entry%s", buf1
, VTY_NEWLINE
);
8978 case OSPF_PATH_INTRA_AREA
:
8979 vty_out (vty
, "N %-18s [%d] area: %s%s", buf1
, or->cost
,
8980 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
8986 if (or->type
== OSPF_DESTINATION_NETWORK
)
8987 for (ALL_LIST_ELEMENTS (or->paths
, pnode
, pnnode
, path
))
8989 if (if_lookup_by_index(path
->ifindex
))
8991 if (path
->nexthop
.s_addr
== 0)
8992 vty_out (vty
, "%24s directly attached to %s%s",
8993 "", ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
8995 vty_out (vty
, "%24s via %s, %s%s", "",
8996 inet_ntoa (path
->nexthop
),
8997 ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
9001 vty_out (vty
, "%s", VTY_NEWLINE
);
9005 show_ip_ospf_route_router (struct vty
*vty
, struct route_table
*rtrs
)
9007 struct route_node
*rn
;
9008 struct ospf_route
*or;
9009 struct listnode
*pnode
;
9010 struct listnode
*node
;
9011 struct ospf_path
*path
;
9013 vty_out (vty
, "============ OSPF router routing table =============%s",
9015 for (rn
= route_top (rtrs
); rn
; rn
= route_next (rn
))
9020 vty_out (vty
, "R %-15s ", inet_ntoa (rn
->p
.u
.prefix4
));
9022 for (ALL_LIST_ELEMENTS_RO ((struct list
*)rn
->info
, node
, or))
9025 vty_out (vty
, "%24s", "");
9028 vty_out (vty
, "%s [%d] area: %s",
9029 (or->path_type
== OSPF_PATH_INTER_AREA
? "IA" : " "),
9030 or->cost
, inet_ntoa (or->u
.std
.area_id
));
9032 vty_out (vty
, "%s%s%s",
9033 (or->u
.std
.flags
& ROUTER_LSA_BORDER
? ", ABR" : ""),
9034 (or->u
.std
.flags
& ROUTER_LSA_EXTERNAL
? ", ASBR" : ""),
9037 for (ALL_LIST_ELEMENTS_RO (or->paths
, pnode
, path
))
9039 if (if_lookup_by_index(path
->ifindex
))
9041 if (path
->nexthop
.s_addr
== 0)
9042 vty_out (vty
, "%24s directly attached to %s%s",
9043 "", ifindex2ifname (path
->ifindex
),
9046 vty_out (vty
, "%24s via %s, %s%s", "",
9047 inet_ntoa (path
->nexthop
),
9048 ifindex2ifname (path
->ifindex
),
9054 vty_out (vty
, "%s", VTY_NEWLINE
);
9058 show_ip_ospf_route_external (struct vty
*vty
, struct route_table
*rt
)
9060 struct route_node
*rn
;
9061 struct ospf_route
*er
;
9062 struct listnode
*pnode
, *pnnode
;
9063 struct ospf_path
*path
;
9065 vty_out (vty
, "============ OSPF external routing table ===========%s",
9067 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
9068 if ((er
= rn
->info
) != NULL
)
9071 snprintf (buf1
, 19, "%s/%d",
9072 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
9074 switch (er
->path_type
)
9076 case OSPF_PATH_TYPE1_EXTERNAL
:
9077 vty_out (vty
, "N E1 %-18s [%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
,
9078 er
->cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
9080 case OSPF_PATH_TYPE2_EXTERNAL
:
9081 vty_out (vty
, "N E2 %-18s [%d/%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
, er
->cost
,
9082 er
->u
.ext
.type2_cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
9086 for (ALL_LIST_ELEMENTS (er
->paths
, pnode
, pnnode
, path
))
9088 if (if_lookup_by_index(path
->ifindex
))
9090 if (path
->nexthop
.s_addr
== 0)
9091 vty_out (vty
, "%24s directly attached to %s%s",
9092 "", ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
9094 vty_out (vty
, "%24s via %s, %s%s", "",
9095 inet_ntoa (path
->nexthop
),
9096 ifindex2ifname (path
->ifindex
),
9101 vty_out (vty
, "%s", VTY_NEWLINE
);
9105 show_ip_ospf_border_routers_common (struct vty
*vty
, struct ospf
*ospf
)
9108 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
9109 VTY_NEWLINE
, VTY_NEWLINE
);
9111 if (ospf
->new_table
== NULL
)
9113 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
9117 /* Show Network routes.
9118 show_ip_ospf_route_network (vty, ospf->new_table); */
9120 /* Show Router routes. */
9121 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
9123 vty_out (vty
, "%s", VTY_NEWLINE
);
9128 DEFUN (show_ip_ospf_border_routers
,
9129 show_ip_ospf_border_routers_cmd
,
9130 "show ip ospf border-routers",
9133 "OSPF information\n"
9134 "Show all the ABR's and ASBR's\n")
9138 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
9141 return show_ip_ospf_border_routers_common(vty
, ospf
);
9144 DEFUN (show_ip_ospf_instance_border_routers
,
9145 show_ip_ospf_instance_border_routers_cmd
,
9146 "show ip ospf <1-65535> border-routers",
9149 "OSPF information\n"
9151 "Show all the ABR's and ASBR's\n")
9154 u_short instance
= 0;
9156 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
9157 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
9160 return show_ip_ospf_border_routers_common(vty
, ospf
);
9164 show_ip_ospf_route_common (struct vty
*vty
, struct ospf
*ospf
)
9167 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
9168 VTY_NEWLINE
, VTY_NEWLINE
);
9170 if (ospf
->new_table
== NULL
)
9172 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
9176 /* Show Network routes. */
9177 show_ip_ospf_route_network (vty
, ospf
->new_table
);
9179 /* Show Router routes. */
9180 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
9182 /* Show AS External routes. */
9183 show_ip_ospf_route_external (vty
, ospf
->old_external_route
);
9185 vty_out (vty
, "%s", VTY_NEWLINE
);
9190 DEFUN (show_ip_ospf_route
,
9191 show_ip_ospf_route_cmd
,
9192 "show ip ospf route",
9195 "OSPF information\n"
9196 "OSPF routing table\n")
9200 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
9203 return show_ip_ospf_route_common(vty
, ospf
);
9206 DEFUN (show_ip_ospf_instance_route
,
9207 show_ip_ospf_instance_route_cmd
,
9208 "show ip ospf <1-65535> route",
9211 "OSPF information\n"
9213 "OSPF routing table\n")
9216 u_short instance
= 0;
9218 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
9219 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
9222 return show_ip_ospf_route_common(vty
, ospf
);
9225 const char *ospf_abr_type_str
[] =
9234 const char *ospf_shortcut_mode_str
[] =
9243 area_id2str (char *buf
, int length
, struct ospf_area
*area
)
9245 memset (buf
, 0, length
);
9247 if (area
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
9248 strncpy (buf
, inet_ntoa (area
->area_id
), length
);
9250 sprintf (buf
, "%lu", (unsigned long) ntohl (area
->area_id
.s_addr
));
9254 const char *ospf_int_type_str
[] =
9256 "unknown", /* should never be used. */
9260 "point-to-multipoint",
9261 "virtual-link", /* should never be used. */
9265 /* Configuration write function for ospfd. */
9267 config_write_interface (struct vty
*vty
)
9269 struct listnode
*n1
, *n2
;
9270 struct interface
*ifp
;
9271 struct crypt_key
*ck
;
9273 struct route_node
*rn
= NULL
;
9274 struct ospf_if_params
*params
;
9275 struct ospf
*ospf
= ospf_lookup();
9277 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), n1
, ifp
))
9279 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
9282 if (ifp
->ifindex
== IFINDEX_DELETED
)
9285 vty_out (vty
, "!%s", VTY_NEWLINE
);
9286 vty_out (vty
, "interface %s%s", ifp
->name
,
9289 vty_out (vty
, " description %s%s", ifp
->desc
,
9294 params
= IF_DEF_PARAMS (ifp
);
9297 /* Interface Network print. */
9298 if (OSPF_IF_PARAM_CONFIGURED (params
, type
) &&
9299 params
->type
!= OSPF_IFTYPE_LOOPBACK
)
9301 if (params
->type
!= ospf_default_iftype(ifp
))
9303 vty_out (vty
, " ip ospf network %s",
9304 ospf_int_type_str
[params
->type
]);
9305 if (params
!= IF_DEF_PARAMS (ifp
))
9306 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9307 vty_out (vty
, "%s", VTY_NEWLINE
);
9311 /* OSPF interface authentication print */
9312 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_type
) &&
9313 params
->auth_type
!= OSPF_AUTH_NOTSET
)
9315 const char *auth_str
;
9317 /* Translation tables are not that much help here due to syntax
9318 of the simple option */
9319 switch (params
->auth_type
)
9322 case OSPF_AUTH_NULL
:
9326 case OSPF_AUTH_SIMPLE
:
9330 case OSPF_AUTH_CRYPTOGRAPHIC
:
9331 auth_str
= " message-digest";
9339 vty_out (vty
, " ip ospf authentication%s", auth_str
);
9340 if (params
!= IF_DEF_PARAMS (ifp
))
9341 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9342 vty_out (vty
, "%s", VTY_NEWLINE
);
9345 /* Simple Authentication Password print. */
9346 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_simple
) &&
9347 params
->auth_simple
[0] != '\0')
9349 vty_out (vty
, " ip ospf authentication-key %s",
9350 params
->auth_simple
);
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 /* Cryptographic Authentication Key print. */
9357 for (ALL_LIST_ELEMENTS_RO (params
->auth_crypt
, n2
, ck
))
9359 vty_out (vty
, " ip ospf message-digest-key %d md5 %s",
9360 ck
->key_id
, ck
->auth_key
);
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
);
9366 /* Interface Output Cost print. */
9367 if (OSPF_IF_PARAM_CONFIGURED (params
, output_cost_cmd
))
9369 vty_out (vty
, " ip ospf cost %u", params
->output_cost_cmd
);
9370 if (params
!= IF_DEF_PARAMS (ifp
))
9371 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9372 vty_out (vty
, "%s", VTY_NEWLINE
);
9375 /* Hello Interval print. */
9376 if (OSPF_IF_PARAM_CONFIGURED (params
, v_hello
) &&
9377 params
->v_hello
!= OSPF_HELLO_INTERVAL_DEFAULT
)
9379 vty_out (vty
, " ip ospf hello-interval %u", params
->v_hello
);
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
);
9386 /* Router Dead Interval print. */
9387 if (OSPF_IF_PARAM_CONFIGURED (params
, v_wait
) &&
9388 params
->v_wait
!= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
)
9390 vty_out (vty
, " ip ospf dead-interval ");
9393 if (OSPF_IF_PARAM_CONFIGURED (params
, fast_hello
))
9394 vty_out (vty
, "minimal hello-multiplier %d",
9395 params
->fast_hello
);
9397 vty_out (vty
, "%u", params
->v_wait
);
9399 if (params
!= IF_DEF_PARAMS (ifp
))
9400 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9401 vty_out (vty
, "%s", VTY_NEWLINE
);
9404 /* Router Priority print. */
9405 if (OSPF_IF_PARAM_CONFIGURED (params
, priority
) &&
9406 params
->priority
!= OSPF_ROUTER_PRIORITY_DEFAULT
)
9408 vty_out (vty
, " ip ospf priority %u", params
->priority
);
9409 if (params
!= IF_DEF_PARAMS (ifp
))
9410 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9411 vty_out (vty
, "%s", VTY_NEWLINE
);
9414 /* Retransmit Interval print. */
9415 if (OSPF_IF_PARAM_CONFIGURED (params
, retransmit_interval
) &&
9416 params
->retransmit_interval
!= OSPF_RETRANSMIT_INTERVAL_DEFAULT
)
9418 vty_out (vty
, " ip ospf retransmit-interval %u",
9419 params
->retransmit_interval
);
9420 if (params
!= IF_DEF_PARAMS (ifp
))
9421 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9422 vty_out (vty
, "%s", VTY_NEWLINE
);
9425 /* Transmit Delay print. */
9426 if (OSPF_IF_PARAM_CONFIGURED (params
, transmit_delay
) &&
9427 params
->transmit_delay
!= OSPF_TRANSMIT_DELAY_DEFAULT
)
9429 vty_out (vty
, " ip ospf transmit-delay %u", params
->transmit_delay
);
9430 if (params
!= IF_DEF_PARAMS (ifp
))
9431 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9432 vty_out (vty
, "%s", VTY_NEWLINE
);
9436 if (OSPF_IF_PARAM_CONFIGURED (params
, if_area
))
9439 vty_out (vty
, " ip ospf %d area %s%s", ospf
->instance
,
9440 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
9442 vty_out (vty
, " ip ospf area %s%s",
9443 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
9448 ospf_bfd_write_config(vty
, params
);
9450 /* MTU ignore print. */
9451 if (OSPF_IF_PARAM_CONFIGURED (params
, mtu_ignore
) &&
9452 params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
9454 if (params
->mtu_ignore
== 0)
9455 vty_out (vty
, " no ip ospf mtu-ignore");
9457 vty_out (vty
, " ip ospf mtu-ignore");
9458 if (params
!= IF_DEF_PARAMS (ifp
))
9459 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9460 vty_out (vty
, "%s", VTY_NEWLINE
);
9467 rn
= route_top (IF_OIFS_PARAMS (ifp
));
9469 rn
= route_next (rn
);
9479 ospf_opaque_config_write_if (vty
, ifp
);
9486 config_write_network_area (struct vty
*vty
, struct ospf
*ospf
)
9488 struct route_node
*rn
;
9489 u_char buf
[INET_ADDRSTRLEN
];
9491 /* `network area' print. */
9492 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
9495 struct ospf_network
*n
= rn
->info
;
9497 memset (buf
, 0, INET_ADDRSTRLEN
);
9499 /* Create Area ID string by specified Area ID format. */
9500 if (n
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
9501 strncpy ((char *) buf
, inet_ntoa (n
->area_id
), INET_ADDRSTRLEN
);
9503 sprintf ((char *) buf
, "%lu",
9504 (unsigned long int) ntohl (n
->area_id
.s_addr
));
9506 /* Network print. */
9507 vty_out (vty
, " network %s/%d area %s%s",
9508 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
9516 config_write_ospf_area (struct vty
*vty
, struct ospf
*ospf
)
9518 struct listnode
*node
;
9519 struct ospf_area
*area
;
9520 u_char buf
[INET_ADDRSTRLEN
];
9522 /* Area configuration print. */
9523 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
9525 struct route_node
*rn1
;
9527 area_id2str ((char *) buf
, INET_ADDRSTRLEN
, area
);
9529 if (area
->auth_type
!= OSPF_AUTH_NULL
)
9531 if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
9532 vty_out (vty
, " area %s authentication%s", buf
, VTY_NEWLINE
);
9534 vty_out (vty
, " area %s authentication message-digest%s",
9538 if (area
->shortcut_configured
!= OSPF_SHORTCUT_DEFAULT
)
9539 vty_out (vty
, " area %s shortcut %s%s", buf
,
9540 ospf_shortcut_mode_str
[area
->shortcut_configured
],
9543 if ((area
->external_routing
== OSPF_AREA_STUB
)
9544 || (area
->external_routing
== OSPF_AREA_NSSA
)
9547 if (area
->external_routing
== OSPF_AREA_STUB
)
9548 vty_out (vty
, " area %s stub", buf
);
9549 else if (area
->external_routing
== OSPF_AREA_NSSA
)
9551 vty_out (vty
, " area %s nssa", buf
);
9552 switch (area
->NSSATranslatorRole
)
9554 case OSPF_NSSA_ROLE_NEVER
:
9555 vty_out (vty
, " translate-never");
9557 case OSPF_NSSA_ROLE_ALWAYS
:
9558 vty_out (vty
, " translate-always");
9560 case OSPF_NSSA_ROLE_CANDIDATE
:
9562 vty_out (vty
, " translate-candidate");
9566 if (area
->no_summary
)
9567 vty_out (vty
, " no-summary");
9569 vty_out (vty
, "%s", VTY_NEWLINE
);
9571 if (area
->default_cost
!= 1)
9572 vty_out (vty
, " area %s default-cost %d%s", buf
,
9573 area
->default_cost
, VTY_NEWLINE
);
9576 for (rn1
= route_top (area
->ranges
); rn1
; rn1
= route_next (rn1
))
9579 struct ospf_area_range
*range
= rn1
->info
;
9581 vty_out (vty
, " area %s range %s/%d", buf
,
9582 inet_ntoa (rn1
->p
.u
.prefix4
), rn1
->p
.prefixlen
);
9584 if (range
->cost_config
!= OSPF_AREA_RANGE_COST_UNSPEC
)
9585 vty_out (vty
, " cost %d", range
->cost_config
);
9587 if (!CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_ADVERTISE
))
9588 vty_out (vty
, " not-advertise");
9590 if (CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_SUBSTITUTE
))
9591 vty_out (vty
, " substitute %s/%d",
9592 inet_ntoa (range
->subst_addr
), range
->subst_masklen
);
9594 vty_out (vty
, "%s", VTY_NEWLINE
);
9597 if (EXPORT_NAME (area
))
9598 vty_out (vty
, " area %s export-list %s%s", buf
,
9599 EXPORT_NAME (area
), VTY_NEWLINE
);
9601 if (IMPORT_NAME (area
))
9602 vty_out (vty
, " area %s import-list %s%s", buf
,
9603 IMPORT_NAME (area
), VTY_NEWLINE
);
9605 if (PREFIX_NAME_IN (area
))
9606 vty_out (vty
, " area %s filter-list prefix %s in%s", buf
,
9607 PREFIX_NAME_IN (area
), VTY_NEWLINE
);
9609 if (PREFIX_NAME_OUT (area
))
9610 vty_out (vty
, " area %s filter-list prefix %s out%s", buf
,
9611 PREFIX_NAME_OUT (area
), VTY_NEWLINE
);
9618 config_write_ospf_nbr_nbma (struct vty
*vty
, struct ospf
*ospf
)
9620 struct ospf_nbr_nbma
*nbr_nbma
;
9621 struct route_node
*rn
;
9623 /* Static Neighbor configuration print. */
9624 for (rn
= route_top (ospf
->nbr_nbma
); rn
; rn
= route_next (rn
))
9625 if ((nbr_nbma
= rn
->info
))
9627 vty_out (vty
, " neighbor %s", inet_ntoa (nbr_nbma
->addr
));
9629 if (nbr_nbma
->priority
!= OSPF_NEIGHBOR_PRIORITY_DEFAULT
)
9630 vty_out (vty
, " priority %d", nbr_nbma
->priority
);
9632 if (nbr_nbma
->v_poll
!= OSPF_POLL_INTERVAL_DEFAULT
)
9633 vty_out (vty
, " poll-interval %d", nbr_nbma
->v_poll
);
9635 vty_out (vty
, "%s", VTY_NEWLINE
);
9642 config_write_virtual_link (struct vty
*vty
, struct ospf
*ospf
)
9644 struct listnode
*node
;
9645 struct ospf_vl_data
*vl_data
;
9646 u_char buf
[INET_ADDRSTRLEN
];
9648 /* Virtual-Link print */
9649 for (ALL_LIST_ELEMENTS_RO (ospf
->vlinks
, node
, vl_data
))
9651 struct listnode
*n2
;
9652 struct crypt_key
*ck
;
9653 struct ospf_interface
*oi
;
9655 if (vl_data
!= NULL
)
9657 memset (buf
, 0, INET_ADDRSTRLEN
);
9659 if (vl_data
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
9660 strncpy ((char *) buf
, inet_ntoa (vl_data
->vl_area_id
), INET_ADDRSTRLEN
);
9662 sprintf ((char *) buf
, "%lu",
9663 (unsigned long int) ntohl (vl_data
->vl_area_id
.s_addr
));
9664 oi
= vl_data
->vl_oi
;
9667 if (OSPF_IF_PARAM (oi
, v_hello
) != OSPF_HELLO_INTERVAL_DEFAULT
||
9668 OSPF_IF_PARAM (oi
, v_wait
) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
||
9669 OSPF_IF_PARAM (oi
, retransmit_interval
) != OSPF_RETRANSMIT_INTERVAL_DEFAULT
||
9670 OSPF_IF_PARAM (oi
, transmit_delay
) != OSPF_TRANSMIT_DELAY_DEFAULT
)
9671 vty_out (vty
, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
9673 inet_ntoa (vl_data
->vl_peer
),
9674 OSPF_IF_PARAM (oi
, v_hello
),
9675 OSPF_IF_PARAM (oi
, retransmit_interval
),
9676 OSPF_IF_PARAM (oi
, transmit_delay
),
9677 OSPF_IF_PARAM (oi
, v_wait
),
9680 vty_out (vty
, " area %s virtual-link %s%s", buf
,
9681 inet_ntoa (vl_data
->vl_peer
), VTY_NEWLINE
);
9683 if (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
[0] != '\0')
9684 vty_out (vty
, " area %s virtual-link %s authentication-key %s%s",
9686 inet_ntoa (vl_data
->vl_peer
),
9687 IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
,
9690 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_crypt
,
9692 vty_out (vty
, " area %s virtual-link %s"
9693 " message-digest-key %d md5 %s%s",
9695 inet_ntoa (vl_data
->vl_peer
),
9696 ck
->key_id
, ck
->auth_key
, VTY_NEWLINE
);
9706 config_write_ospf_redistribute (struct vty
*vty
, struct ospf
*ospf
)
9710 /* redistribute print. */
9711 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
9713 struct list
*red_list
;
9714 struct listnode
*node
;
9715 struct ospf_redist
*red
;
9717 red_list
= ospf
->redist
[type
];
9721 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
))
9723 vty_out (vty
, " redistribute %s", zebra_route_string(type
));
9725 vty_out (vty
, " %d", red
->instance
);
9727 if (red
->dmetric
.value
>= 0)
9728 vty_out (vty
, " metric %d", red
->dmetric
.value
);
9730 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
9731 vty_out (vty
, " metric-type 1");
9733 if (ROUTEMAP_NAME (red
))
9734 vty_out (vty
, " route-map %s", ROUTEMAP_NAME (red
));
9736 vty_out (vty
, "%s", VTY_NEWLINE
);
9744 config_write_ospf_default_metric (struct vty
*vty
, struct ospf
*ospf
)
9746 if (ospf
->default_metric
!= -1)
9747 vty_out (vty
, " default-metric %d%s", ospf
->default_metric
,
9753 config_write_ospf_distribute (struct vty
*vty
, struct ospf
*ospf
)
9756 struct ospf_redist
*red
;
9760 /* distribute-list print. */
9761 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
9762 if (DISTRIBUTE_NAME (ospf
, type
))
9763 vty_out (vty
, " distribute-list %s out %s%s",
9764 DISTRIBUTE_NAME (ospf
, type
),
9765 zebra_route_string(type
), VTY_NEWLINE
);
9767 /* default-information print. */
9768 if (ospf
->default_originate
!= DEFAULT_ORIGINATE_NONE
)
9770 vty_out (vty
, " default-information originate");
9771 if (ospf
->default_originate
== DEFAULT_ORIGINATE_ALWAYS
)
9772 vty_out (vty
, " always");
9774 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
9777 if (red
->dmetric
.value
>= 0)
9778 vty_out (vty
, " metric %d",
9779 red
->dmetric
.value
);
9780 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
9781 vty_out (vty
, " metric-type 1");
9783 if (ROUTEMAP_NAME (red
))
9784 vty_out (vty
, " route-map %s",
9785 ROUTEMAP_NAME (red
));
9788 vty_out (vty
, "%s", VTY_NEWLINE
);
9797 config_write_ospf_distance (struct vty
*vty
, struct ospf
*ospf
)
9799 struct route_node
*rn
;
9800 struct ospf_distance
*odistance
;
9802 if (ospf
->distance_all
)
9803 vty_out (vty
, " distance %d%s", ospf
->distance_all
, VTY_NEWLINE
);
9805 if (ospf
->distance_intra
9806 || ospf
->distance_inter
9807 || ospf
->distance_external
)
9809 vty_out (vty
, " distance ospf");
9811 if (ospf
->distance_intra
)
9812 vty_out (vty
, " intra-area %d", ospf
->distance_intra
);
9813 if (ospf
->distance_inter
)
9814 vty_out (vty
, " inter-area %d", ospf
->distance_inter
);
9815 if (ospf
->distance_external
)
9816 vty_out (vty
, " external %d", ospf
->distance_external
);
9818 vty_out (vty
, "%s", VTY_NEWLINE
);
9821 for (rn
= route_top (ospf
->distance_table
); rn
; rn
= route_next (rn
))
9822 if ((odistance
= rn
->info
) != NULL
)
9824 vty_out (vty
, " distance %d %s/%d %s%s", odistance
->distance
,
9825 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
9826 odistance
->access_list
? odistance
->access_list
: "",
9832 /* OSPF configuration write function. */
9834 ospf_config_write (struct vty
*vty
)
9837 struct interface
*ifp
;
9838 struct ospf_interface
*oi
;
9839 struct listnode
*node
;
9842 ospf
= ospf_lookup ();
9843 if (ospf
!= NULL
&& ospf
->oi_running
)
9845 /* `router ospf' print. */
9847 vty_out (vty
, "router ospf %d%s", ospf
->instance
, VTY_NEWLINE
);
9849 vty_out (vty
, "router ospf%s", VTY_NEWLINE
);
9853 if (!ospf
->networks
)
9856 /* Router ID print. */
9857 if (ospf
->router_id_static
.s_addr
!= 0)
9858 vty_out (vty
, " ospf router-id %s%s",
9859 inet_ntoa (ospf
->router_id_static
), VTY_NEWLINE
);
9861 /* ABR type print. */
9862 if (ospf
->abr_type
!= OSPF_ABR_DEFAULT
)
9863 vty_out (vty
, " ospf abr-type %s%s",
9864 ospf_abr_type_str
[ospf
->abr_type
], VTY_NEWLINE
);
9866 /* log-adjacency-changes flag print. */
9867 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
))
9869 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
9870 vty_out(vty
, " log-adjacency-changes detail%s", VTY_NEWLINE
);
9874 vty_out(vty
, " no log-adjacency-changes%s", VTY_NEWLINE
);
9877 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
9878 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
9879 vty_out (vty
, " compatible rfc1583%s", VTY_NEWLINE
);
9881 /* auto-cost reference-bandwidth configuration. */
9882 if (ospf
->ref_bandwidth
!= OSPF_DEFAULT_REF_BANDWIDTH
)
9884 vty_out (vty
, "! Important: ensure reference bandwidth "
9885 "is consistent across all routers%s", VTY_NEWLINE
);
9886 vty_out (vty
, " auto-cost reference-bandwidth %d%s",
9887 ospf
->ref_bandwidth
, VTY_NEWLINE
);
9890 /* SPF timers print. */
9891 if (ospf
->spf_delay
!= OSPF_SPF_DELAY_DEFAULT
||
9892 ospf
->spf_holdtime
!= OSPF_SPF_HOLDTIME_DEFAULT
||
9893 ospf
->spf_max_holdtime
!= OSPF_SPF_MAX_HOLDTIME_DEFAULT
)
9894 vty_out (vty
, " timers throttle spf %d %d %d%s",
9895 ospf
->spf_delay
, ospf
->spf_holdtime
,
9896 ospf
->spf_max_holdtime
, VTY_NEWLINE
);
9898 /* LSA timers print. */
9899 if (ospf
->min_ls_interval
!= OSPF_MIN_LS_INTERVAL
)
9900 vty_out (vty
, " timers throttle lsa all %d%s",
9901 ospf
->min_ls_interval
, VTY_NEWLINE
);
9902 if (ospf
->min_ls_arrival
!= OSPF_MIN_LS_ARRIVAL
)
9903 vty_out (vty
, " timers lsa min-arrival %d%s",
9904 ospf
->min_ls_arrival
, VTY_NEWLINE
);
9906 /* Write multiplier print. */
9907 if (ospf
->write_oi_count
!= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
)
9908 vty_out (vty
, " ospf write-multiplier %d%s",
9909 ospf
->write_oi_count
, VTY_NEWLINE
);
9911 /* Max-metric router-lsa print */
9912 config_write_stub_router (vty
, ospf
);
9914 /* SPF refresh parameters print. */
9915 if (ospf
->lsa_refresh_interval
!= OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
9916 vty_out (vty
, " refresh timer %d%s",
9917 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
9919 /* Redistribute information print. */
9920 config_write_ospf_redistribute (vty
, ospf
);
9922 /* passive-interface print. */
9923 if (ospf
->passive_interface_default
== OSPF_IF_PASSIVE
)
9924 vty_out (vty
, " passive-interface default%s", VTY_NEWLINE
);
9926 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, node
, ifp
))
9927 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
)
9928 && IF_DEF_PARAMS (ifp
)->passive_interface
!=
9929 ospf
->passive_interface_default
)
9931 vty_out (vty
, " %spassive-interface %s%s",
9932 IF_DEF_PARAMS (ifp
)->passive_interface
? "" : "no ",
9933 ifp
->name
, VTY_NEWLINE
);
9935 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
9937 if (!OSPF_IF_PARAM_CONFIGURED (oi
->params
, passive_interface
))
9939 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi
->ifp
),
9942 if (oi
->params
->passive_interface
== IF_DEF_PARAMS (oi
->ifp
)->passive_interface
)
9945 else if (oi
->params
->passive_interface
== ospf
->passive_interface_default
)
9948 vty_out (vty
, " %spassive-interface %s %s%s",
9949 oi
->params
->passive_interface
? "" : "no ",
9951 inet_ntoa (oi
->address
->u
.prefix4
), VTY_NEWLINE
);
9954 /* Network area print. */
9955 config_write_network_area (vty
, ospf
);
9957 /* Area config print. */
9958 config_write_ospf_area (vty
, ospf
);
9960 /* static neighbor print. */
9961 config_write_ospf_nbr_nbma (vty
, ospf
);
9963 /* Virtual-Link print. */
9964 config_write_virtual_link (vty
, ospf
);
9966 /* Default metric configuration. */
9967 config_write_ospf_default_metric (vty
, ospf
);
9969 /* Distribute-list and default-information print. */
9970 config_write_ospf_distribute (vty
, ospf
);
9972 /* Distance configuration. */
9973 config_write_ospf_distance (vty
, ospf
);
9975 ospf_opaque_config_write_router (vty
, ospf
);
9982 ospf_vty_show_init (void)
9984 /* "show ip ospf" commands. */
9985 install_element (VIEW_NODE
, &show_ip_ospf_cmd
);
9987 install_element (VIEW_NODE
, &show_ip_ospf_instance_cmd
);
9989 /* "show ip ospf database" commands. */
9990 install_element (VIEW_NODE
, &show_ip_ospf_database_type_cmd
);
9991 install_element (VIEW_NODE
, &show_ip_ospf_database_type_id_cmd
);
9992 install_element (VIEW_NODE
, &show_ip_ospf_database_type_id_adv_router_cmd
);
9993 install_element (VIEW_NODE
, &show_ip_ospf_database_type_adv_router_cmd
);
9994 install_element (VIEW_NODE
, &show_ip_ospf_database_type_id_self_cmd
);
9995 install_element (VIEW_NODE
, &show_ip_ospf_database_type_self_cmd
);
9996 install_element (VIEW_NODE
, &show_ip_ospf_database_cmd
);
9998 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_cmd
);
9999 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_id_cmd
);
10000 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_id_adv_router_cmd
);
10001 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_adv_router_cmd
);
10002 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_id_self_cmd
);
10003 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_self_cmd
);
10004 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_cmd
);
10006 /* "show ip ospf interface" commands. */
10007 install_element (VIEW_NODE
, &show_ip_ospf_interface_cmd
);
10009 install_element (VIEW_NODE
, &show_ip_ospf_instance_interface_cmd
);
10011 /* "show ip ospf neighbor" commands. */
10012 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_detail_cmd
);
10013 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_cmd
);
10014 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_id_cmd
);
10015 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_all_cmd
);
10016 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_cmd
);
10017 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_cmd
);
10018 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_all_cmd
);
10020 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_detail_cmd
);
10021 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_cmd
);
10022 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_id_cmd
);
10023 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_all_cmd
);
10024 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_cmd
);
10025 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_cmd
);
10026 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_all_cmd
);
10028 /* "show ip ospf route" commands. */
10029 install_element (VIEW_NODE
, &show_ip_ospf_route_cmd
);
10030 install_element (VIEW_NODE
, &show_ip_ospf_border_routers_cmd
);
10032 install_element (VIEW_NODE
, &show_ip_ospf_instance_route_cmd
);
10033 install_element (VIEW_NODE
, &show_ip_ospf_instance_border_routers_cmd
);
10037 /* ospfd's interface node. */
10038 static struct cmd_node interface_node
=
10045 /* Initialization of OSPF interface. */
10047 ospf_vty_if_init (void)
10049 /* Install interface node. */
10050 install_node (&interface_node
, config_write_interface
);
10052 install_element (CONFIG_NODE
, &interface_cmd
);
10053 install_element (CONFIG_NODE
, &no_interface_cmd
);
10054 install_default (INTERFACE_NODE
);
10056 /* "description" commands. */
10057 install_element (INTERFACE_NODE
, &interface_desc_cmd
);
10058 install_element (INTERFACE_NODE
, &no_interface_desc_cmd
);
10060 /* "ip ospf authentication" commands. */
10061 install_element (INTERFACE_NODE
, &ip_ospf_authentication_args_addr_cmd
);
10062 install_element (INTERFACE_NODE
, &ip_ospf_authentication_args_cmd
);
10063 install_element (INTERFACE_NODE
, &ip_ospf_authentication_addr_cmd
);
10064 install_element (INTERFACE_NODE
, &ip_ospf_authentication_cmd
);
10065 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_args_addr_cmd
);
10066 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_args_cmd
);
10067 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_addr_cmd
);
10068 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_cmd
);
10069 install_element (INTERFACE_NODE
, &ip_ospf_authentication_key_addr_cmd
);
10070 install_element (INTERFACE_NODE
, &ip_ospf_authentication_key_cmd
);
10071 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_key_authkey_addr_cmd
);
10072 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_key_authkey_cmd
);
10073 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_key_cmd
);
10075 /* "ip ospf message-digest-key" commands. */
10076 install_element (INTERFACE_NODE
, &ip_ospf_message_digest_key_addr_cmd
);
10077 install_element (INTERFACE_NODE
, &ip_ospf_message_digest_key_cmd
);
10078 install_element (INTERFACE_NODE
, &no_ip_ospf_message_digest_key_addr_cmd
);
10079 install_element (INTERFACE_NODE
, &no_ip_ospf_message_digest_key_cmd
);
10080 install_element (INTERFACE_NODE
, &no_ip_ospf_message_digest_key_md5_addr_cmd
);
10081 install_element (INTERFACE_NODE
, &no_ip_ospf_message_digest_key_md5_cmd
);
10083 /* "ip ospf cost" commands. */
10084 install_element (INTERFACE_NODE
, &ip_ospf_cost_u32_inet4_cmd
);
10085 install_element (INTERFACE_NODE
, &ip_ospf_cost_u32_cmd
);
10086 install_element (INTERFACE_NODE
, &no_ip_ospf_cost_u32_cmd
);
10087 install_element (INTERFACE_NODE
, &no_ip_ospf_cost_u32_inet4_cmd
);
10088 install_element (INTERFACE_NODE
, &no_ip_ospf_cost_inet4_cmd
);
10089 install_element (INTERFACE_NODE
, &no_ip_ospf_cost_cmd
);
10091 /* "ip ospf mtu-ignore" commands. */
10092 install_element (INTERFACE_NODE
, &ip_ospf_mtu_ignore_addr_cmd
);
10093 install_element (INTERFACE_NODE
, &ip_ospf_mtu_ignore_cmd
);
10094 install_element (INTERFACE_NODE
, &no_ip_ospf_mtu_ignore_addr_cmd
);
10095 install_element (INTERFACE_NODE
, &no_ip_ospf_mtu_ignore_cmd
);
10097 /* "ip ospf dead-interval" commands. */
10098 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_addr_cmd
);
10099 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_cmd
);
10100 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_minimal_addr_cmd
);
10101 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_minimal_cmd
);
10102 install_element (INTERFACE_NODE
, &no_ip_ospf_dead_interval_addr_cmd
);
10103 install_element (INTERFACE_NODE
, &no_ip_ospf_dead_interval_cmd
);
10104 install_element (INTERFACE_NODE
, &no_ip_ospf_dead_interval_seconds_cmd
);
10106 /* "ip ospf hello-interval" commands. */
10107 install_element (INTERFACE_NODE
, &ip_ospf_hello_interval_addr_cmd
);
10108 install_element (INTERFACE_NODE
, &ip_ospf_hello_interval_cmd
);
10109 install_element (INTERFACE_NODE
, &no_ip_ospf_hello_interval_addr_cmd
);
10110 install_element (INTERFACE_NODE
, &no_ip_ospf_hello_interval_cmd
);
10111 install_element (INTERFACE_NODE
, &no_ip_ospf_hello_interval_seconds_cmd
);
10113 /* "ip ospf network" commands. */
10114 install_element (INTERFACE_NODE
, &ip_ospf_network_cmd
);
10115 install_element (INTERFACE_NODE
, &no_ip_ospf_network_cmd
);
10116 install_element (INTERFACE_NODE
, &no_ip_ospf_network_val_cmd
);
10118 /* "ip ospf priority" commands. */
10119 install_element (INTERFACE_NODE
, &ip_ospf_priority_addr_cmd
);
10120 install_element (INTERFACE_NODE
, &ip_ospf_priority_cmd
);
10121 install_element (INTERFACE_NODE
, &no_ip_ospf_priority_cmd
);
10122 install_element (INTERFACE_NODE
, &no_ip_ospf_priority_no_param_cmd
);
10123 install_element (INTERFACE_NODE
, &no_ip_ospf_priority_addr_cmd
);
10125 /* "ip ospf retransmit-interval" commands. */
10126 install_element (INTERFACE_NODE
, &ip_ospf_retransmit_interval_addr_cmd
);
10127 install_element (INTERFACE_NODE
, &ip_ospf_retransmit_interval_cmd
);
10128 install_element (INTERFACE_NODE
, &no_ip_ospf_retransmit_interval_addr_cmd
);
10129 install_element (INTERFACE_NODE
, &no_ip_ospf_retransmit_interval_cmd
);
10130 install_element (INTERFACE_NODE
, &no_ip_ospf_retransmit_interval_sec_addr_cmd
);
10131 install_element (INTERFACE_NODE
, &no_ip_ospf_retransmit_interval_sec_cmd
);
10133 /* "ip ospf transmit-delay" commands. */
10134 install_element (INTERFACE_NODE
, &ip_ospf_transmit_delay_addr_cmd
);
10135 install_element (INTERFACE_NODE
, &ip_ospf_transmit_delay_cmd
);
10136 install_element (INTERFACE_NODE
, &no_ip_ospf_transmit_delay_addr_cmd
);
10137 install_element (INTERFACE_NODE
, &no_ip_ospf_transmit_delay_cmd
);
10138 install_element (INTERFACE_NODE
, &no_ip_ospf_transmit_delay_sec_addr_cmd
);
10139 install_element (INTERFACE_NODE
, &no_ip_ospf_transmit_delay_sec_cmd
);
10141 /* "ip ospf area" commands. */
10142 install_element (INTERFACE_NODE
, &ip_ospf_area_cmd
);
10143 install_element (INTERFACE_NODE
, &no_ip_ospf_area_cmd
);
10144 install_element (INTERFACE_NODE
, &no_ip_ospf_area_val_cmd
);
10145 install_element (INTERFACE_NODE
, &ip_ospf_instance_area_cmd
);
10146 install_element (INTERFACE_NODE
, &no_ip_ospf_instance_area_cmd
);
10147 install_element (INTERFACE_NODE
, &no_ip_ospf_instance_area_val_cmd
);
10149 /* These commands are compatibitliy for previous version. */
10150 install_element (INTERFACE_NODE
, &ospf_authentication_key_cmd
);
10151 install_element (INTERFACE_NODE
, &no_ospf_authentication_key_cmd
);
10152 install_element (INTERFACE_NODE
, &no_ospf_authentication_key_authkey_cmd
);
10153 install_element (INTERFACE_NODE
, &no_ospf_authentication_key_authkey_ip_cmd
);
10154 install_element (INTERFACE_NODE
, &ospf_message_digest_key_cmd
);
10155 install_element (INTERFACE_NODE
, &no_ospf_message_digest_key_cmd
);
10156 install_element (INTERFACE_NODE
, &ospf_cost_u32_cmd
);
10157 install_element (INTERFACE_NODE
, &ospf_cost_u32_inet4_cmd
);
10158 install_element (INTERFACE_NODE
, &no_ospf_cost_cmd
);
10159 install_element (INTERFACE_NODE
, &no_ospf_cost_u32_cmd
);
10160 install_element (INTERFACE_NODE
, &no_ospf_cost_u32_inet4_cmd
);
10161 install_element (INTERFACE_NODE
, &no_ospf_cost_inet4_cmd
);
10162 install_element (INTERFACE_NODE
, &ospf_dead_interval_cmd
);
10163 install_element (INTERFACE_NODE
, &no_ospf_dead_interval_cmd
);
10164 install_element (INTERFACE_NODE
, &no_ip_ospf_dead_interval_minimal_addr_cmd
);
10165 install_element (INTERFACE_NODE
, &no_ip_ospf_dead_interval_minimal_cmd
);
10166 install_element (INTERFACE_NODE
, &ospf_hello_interval_cmd
);
10167 install_element (INTERFACE_NODE
, &no_ospf_hello_interval_cmd
);
10168 install_element (INTERFACE_NODE
, &ospf_network_cmd
);
10169 install_element (INTERFACE_NODE
, &no_ospf_network_cmd
);
10170 install_element (INTERFACE_NODE
, &no_ospf_network_val_cmd
);
10171 install_element (INTERFACE_NODE
, &ospf_priority_cmd
);
10172 install_element (INTERFACE_NODE
, &no_ospf_priority_cmd
);
10173 install_element (INTERFACE_NODE
, &ospf_retransmit_interval_cmd
);
10174 install_element (INTERFACE_NODE
, &no_ospf_retransmit_interval_cmd
);
10175 install_element (INTERFACE_NODE
, &ospf_transmit_delay_cmd
);
10176 install_element (INTERFACE_NODE
, &no_ospf_transmit_delay_cmd
);
10180 ospf_vty_zebra_init (void)
10182 install_element (OSPF_NODE
, &ospf_redistribute_source_cmd
);
10183 install_element (OSPF_NODE
, &no_ospf_redistribute_source_cmd
);
10184 install_element (OSPF_NODE
, &ospf_redistribute_instance_source_cmd
);
10185 install_element (OSPF_NODE
, &no_ospf_redistribute_instance_source_cmd
);
10187 install_element (OSPF_NODE
, &ospf_distribute_list_out_cmd
);
10188 install_element (OSPF_NODE
, &no_ospf_distribute_list_out_cmd
);
10190 install_element (OSPF_NODE
, &ospf_default_information_originate_cmd
);
10191 install_element (OSPF_NODE
, &no_ospf_default_information_originate_cmd
);
10193 install_element (OSPF_NODE
, &ospf_default_metric_cmd
);
10194 install_element (OSPF_NODE
, &no_ospf_default_metric_cmd
);
10195 install_element (OSPF_NODE
, &no_ospf_default_metric_val_cmd
);
10197 install_element (OSPF_NODE
, &ospf_distance_cmd
);
10198 install_element (OSPF_NODE
, &no_ospf_distance_cmd
);
10199 install_element (OSPF_NODE
, &no_ospf_distance_ospf_cmd
);
10200 install_element (OSPF_NODE
, &ospf_distance_ospf_cmd
);
10202 install_element (OSPF_NODE
, &ospf_distance_source_cmd
);
10203 install_element (OSPF_NODE
, &no_ospf_distance_source_cmd
);
10204 install_element (OSPF_NODE
, &ospf_distance_source_access_list_cmd
);
10205 install_element (OSPF_NODE
, &no_ospf_distance_source_access_list_cmd
);
10209 static struct cmd_node ospf_node
=
10212 "%s(config-router)# ",
10217 ospf_interface_clear (struct interface
*ifp
)
10219 if (!if_is_operative (ifp
)) return;
10221 if (IS_DEBUG_OSPF (ism
, ISM_EVENTS
))
10222 zlog (NULL
, LOG_DEBUG
, "ISM[%s]: clear by reset", ifp
->name
);
10224 ospf_if_reset(ifp
);
10227 DEFUN (clear_ip_ospf_interface
,
10228 clear_ip_ospf_interface_cmd
,
10229 "clear ip ospf interface [IFNAME]",
10232 "OSPF information\n"
10233 "Interface information\n"
10234 "Interface name\n")
10236 struct interface
*ifp
;
10237 struct listnode
*node
;
10239 if (argc
== 0) /* Clear all the ospfv2 interfaces. */
10241 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
10242 ospf_interface_clear(ifp
);
10244 else /* Interface name is specified. */
10246 if ((ifp
= if_lookup_by_name (argv
[0])) == NULL
)
10247 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
10249 ospf_interface_clear(ifp
);
10252 return CMD_SUCCESS
;
10256 ospf_vty_clear_init (void)
10258 install_element (ENABLE_NODE
, &clear_ip_ospf_interface_cmd
);
10262 /* Install OSPF related vty commands. */
10264 ospf_vty_init (void)
10266 /* Install ospf top node. */
10267 install_node (&ospf_node
, ospf_config_write
);
10269 /* "router ospf" commands. */
10270 install_element (CONFIG_NODE
, &router_ospf_cmd
);
10271 install_element (CONFIG_NODE
, &no_router_ospf_cmd
);
10273 install_element (CONFIG_NODE
, &router_ospf_instance_cmd
);
10274 install_element (CONFIG_NODE
, &no_router_ospf_instance_cmd
);
10276 install_default (OSPF_NODE
);
10278 /* "ospf router-id" commands. */
10279 install_element (OSPF_NODE
, &ospf_router_id_cmd
);
10280 install_element (OSPF_NODE
, &ospf_router_id_old_cmd
);
10281 install_element (OSPF_NODE
, &no_ospf_router_id_cmd
);
10282 install_element (OSPF_NODE
, &no_ospf_router_id_val_cmd
);
10284 /* "passive-interface" commands. */
10285 install_element (OSPF_NODE
, &ospf_passive_interface_addr_cmd
);
10286 install_element (OSPF_NODE
, &ospf_passive_interface_cmd
);
10287 install_element (OSPF_NODE
, &ospf_passive_interface_default_cmd
);
10288 install_element (OSPF_NODE
, &no_ospf_passive_interface_addr_cmd
);
10289 install_element (OSPF_NODE
, &no_ospf_passive_interface_cmd
);
10290 install_element (OSPF_NODE
, &no_ospf_passive_interface_default_cmd
);
10292 /* "ospf abr-type" commands. */
10293 install_element (OSPF_NODE
, &ospf_abr_type_cmd
);
10294 install_element (OSPF_NODE
, &no_ospf_abr_type_cmd
);
10296 /* "ospf log-adjacency-changes" commands. */
10297 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_cmd
);
10298 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_detail_cmd
);
10299 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_cmd
);
10300 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_detail_cmd
);
10302 /* "ospf rfc1583-compatible" commands. */
10303 install_element (OSPF_NODE
, &ospf_rfc1583_flag_cmd
);
10304 install_element (OSPF_NODE
, &no_ospf_rfc1583_flag_cmd
);
10305 install_element (OSPF_NODE
, &ospf_compatible_rfc1583_cmd
);
10306 install_element (OSPF_NODE
, &no_ospf_compatible_rfc1583_cmd
);
10308 /* "network area" commands. */
10309 install_element (OSPF_NODE
, &ospf_network_area_cmd
);
10310 install_element (OSPF_NODE
, &no_ospf_network_area_cmd
);
10312 /* "area authentication" commands. */
10313 install_element (OSPF_NODE
, &ospf_area_authentication_message_digest_cmd
);
10314 install_element (OSPF_NODE
, &ospf_area_authentication_cmd
);
10315 install_element (OSPF_NODE
, &no_ospf_area_authentication_cmd
);
10317 /* "area range" commands. */
10318 install_element (OSPF_NODE
, &ospf_area_range_cmd
);
10319 install_element (OSPF_NODE
, &ospf_area_range_advertise_cmd
);
10320 install_element (OSPF_NODE
, &ospf_area_range_cost_cmd
);
10321 install_element (OSPF_NODE
, &ospf_area_range_advertise_cost_cmd
);
10322 install_element (OSPF_NODE
, &ospf_area_range_not_advertise_cmd
);
10323 install_element (OSPF_NODE
, &no_ospf_area_range_cmd
);
10324 install_element (OSPF_NODE
, &no_ospf_area_range_advertise_cmd
);
10325 install_element (OSPF_NODE
, &no_ospf_area_range_cost_cmd
);
10326 install_element (OSPF_NODE
, &no_ospf_area_range_advertise_cost_cmd
);
10327 install_element (OSPF_NODE
, &ospf_area_range_substitute_cmd
);
10328 install_element (OSPF_NODE
, &no_ospf_area_range_substitute_cmd
);
10330 /* "area virtual-link" commands. */
10331 install_element (OSPF_NODE
, &ospf_area_vlink_cmd
);
10332 install_element (OSPF_NODE
, &no_ospf_area_vlink_cmd
);
10334 install_element (OSPF_NODE
, &ospf_area_vlink_param1_cmd
);
10335 install_element (OSPF_NODE
, &no_ospf_area_vlink_param1_cmd
);
10337 install_element (OSPF_NODE
, &ospf_area_vlink_param2_cmd
);
10338 install_element (OSPF_NODE
, &no_ospf_area_vlink_param2_cmd
);
10340 install_element (OSPF_NODE
, &ospf_area_vlink_param3_cmd
);
10341 install_element (OSPF_NODE
, &no_ospf_area_vlink_param3_cmd
);
10343 install_element (OSPF_NODE
, &ospf_area_vlink_param4_cmd
);
10344 install_element (OSPF_NODE
, &no_ospf_area_vlink_param4_cmd
);
10346 install_element (OSPF_NODE
, &ospf_area_vlink_authtype_args_cmd
);
10347 install_element (OSPF_NODE
, &no_ospf_area_vlink_authtype_args_cmd
);
10348 install_element (OSPF_NODE
, &ospf_area_vlink_authtype_cmd
);
10349 install_element (OSPF_NODE
, &no_ospf_area_vlink_authtype_cmd
);
10351 install_element (OSPF_NODE
, &ospf_area_vlink_md5_cmd
);
10352 install_element (OSPF_NODE
, &no_ospf_area_vlink_md5_cmd
);
10354 install_element (OSPF_NODE
, &ospf_area_vlink_authkey_cmd
);
10355 install_element (OSPF_NODE
, &no_ospf_area_vlink_authkey_cmd
);
10357 install_element (OSPF_NODE
, &ospf_area_vlink_authtype_args_authkey_cmd
);
10358 install_element (OSPF_NODE
, &no_ospf_area_vlink_authtype_args_authkey_cmd
);
10359 install_element (OSPF_NODE
, &ospf_area_vlink_authtype_authkey_cmd
);
10360 install_element (OSPF_NODE
, &no_ospf_area_vlink_authtype_authkey_cmd
);
10362 install_element (OSPF_NODE
, &ospf_area_vlink_authtype_args_md5_cmd
);
10363 install_element (OSPF_NODE
, &no_ospf_area_vlink_authtype_args_md5_cmd
);
10364 install_element (OSPF_NODE
, &ospf_area_vlink_authtype_md5_cmd
);
10365 install_element (OSPF_NODE
, &no_ospf_area_vlink_authtype_md5_cmd
);
10367 /* "area stub" commands. */
10368 install_element (OSPF_NODE
, &ospf_area_stub_no_summary_cmd
);
10369 install_element (OSPF_NODE
, &ospf_area_stub_cmd
);
10370 install_element (OSPF_NODE
, &no_ospf_area_stub_no_summary_cmd
);
10371 install_element (OSPF_NODE
, &no_ospf_area_stub_cmd
);
10373 /* "area nssa" commands. */
10374 install_element (OSPF_NODE
, &ospf_area_nssa_cmd
);
10375 install_element (OSPF_NODE
, &ospf_area_nssa_translate_no_summary_cmd
);
10376 install_element (OSPF_NODE
, &ospf_area_nssa_translate_cmd
);
10377 install_element (OSPF_NODE
, &ospf_area_nssa_no_summary_cmd
);
10378 install_element (OSPF_NODE
, &no_ospf_area_nssa_cmd
);
10379 install_element (OSPF_NODE
, &no_ospf_area_nssa_no_summary_cmd
);
10381 install_element (OSPF_NODE
, &ospf_area_default_cost_cmd
);
10382 install_element (OSPF_NODE
, &no_ospf_area_default_cost_cmd
);
10384 install_element (OSPF_NODE
, &ospf_area_shortcut_cmd
);
10385 install_element (OSPF_NODE
, &no_ospf_area_shortcut_cmd
);
10387 install_element (OSPF_NODE
, &ospf_area_export_list_cmd
);
10388 install_element (OSPF_NODE
, &no_ospf_area_export_list_cmd
);
10390 install_element (OSPF_NODE
, &ospf_area_filter_list_cmd
);
10391 install_element (OSPF_NODE
, &no_ospf_area_filter_list_cmd
);
10393 install_element (OSPF_NODE
, &ospf_area_import_list_cmd
);
10394 install_element (OSPF_NODE
, &no_ospf_area_import_list_cmd
);
10396 /* SPF timer commands */
10397 install_element (OSPF_NODE
, &ospf_timers_throttle_spf_cmd
);
10398 install_element (OSPF_NODE
, &no_ospf_timers_throttle_spf_cmd
);
10399 install_element (OSPF_NODE
, &no_ospf_timers_throttle_spf_val_cmd
);
10401 /* LSA timers commands */
10402 install_element (OSPF_NODE
, &ospf_timers_min_ls_interval_cmd
);
10403 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_interval_cmd
);
10404 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_interval_val_cmd
);
10405 install_element (OSPF_NODE
, &ospf_timers_min_ls_arrival_cmd
);
10406 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_arrival_cmd
);
10407 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_arrival_val_cmd
);
10408 install_element (OSPF_NODE
, &ospf_timers_lsa_cmd
);
10409 install_element (OSPF_NODE
, &no_ospf_timers_lsa_cmd
);
10410 install_element (OSPF_NODE
, &no_ospf_timers_lsa_val_cmd
);
10412 /* refresh timer commands */
10413 install_element (OSPF_NODE
, &ospf_refresh_timer_cmd
);
10414 install_element (OSPF_NODE
, &no_ospf_refresh_timer_val_cmd
);
10415 install_element (OSPF_NODE
, &no_ospf_refresh_timer_cmd
);
10417 /* max-metric commands */
10418 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_admin_cmd
);
10419 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_admin_cmd
);
10420 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_startup_cmd
);
10421 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_startup_cmd
);
10422 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_startup_no_param_cmd
);
10423 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_shutdown_cmd
);
10424 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_shutdown_cmd
);
10425 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_shutdown_no_param_cmd
);
10427 /* reference bandwidth commands */
10428 install_element (OSPF_NODE
, &ospf_auto_cost_reference_bandwidth_cmd
);
10429 install_element (OSPF_NODE
, &no_ospf_auto_cost_reference_bandwidth_cmd
);
10430 install_element (OSPF_NODE
, &no_ospf_auto_cost_reference_bandwidth_val_cmd
);
10432 /* "neighbor" commands. */
10433 install_element (OSPF_NODE
, &ospf_neighbor_cmd
);
10434 install_element (OSPF_NODE
, &ospf_neighbor_priority_poll_interval_cmd
);
10435 install_element (OSPF_NODE
, &ospf_neighbor_priority_cmd
);
10436 install_element (OSPF_NODE
, &ospf_neighbor_poll_interval_cmd
);
10437 install_element (OSPF_NODE
, &ospf_neighbor_poll_interval_priority_cmd
);
10438 install_element (OSPF_NODE
, &no_ospf_neighbor_cmd
);
10439 install_element (OSPF_NODE
, &no_ospf_neighbor_priority_cmd
);
10440 install_element (OSPF_NODE
, &no_ospf_neighbor_poll_interval_cmd
);
10441 install_element (OSPF_NODE
, &no_ospf_neighbor_poll_interval_priority_cmd
);
10442 install_element (OSPF_NODE
, &no_ospf_neighbor_priority_pollinterval_cmd
);
10444 /* write multiplier commands */
10445 install_element (OSPF_NODE
, &ospf_write_multiplier_cmd
);
10446 install_element (OSPF_NODE
, &no_ospf_write_multiplier_cmd
);
10447 install_element (OSPF_NODE
, &write_multiplier_cmd
);
10448 install_element (OSPF_NODE
, &no_write_multiplier_cmd
);
10449 install_element (OSPF_NODE
, &no_write_multiplier_val_cmd
);
10451 /* Init interface related vty commands. */
10452 ospf_vty_if_init ();
10454 /* Init zebra related vty commands. */
10455 ospf_vty_zebra_init ();