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 */
1295 vl_config
.crypto_key_id
= strtol (argv
[i
], NULL
, 10);
1296 if (vl_config
.crypto_key_id
< 0)
1298 vl_config
.md5_key
= NULL
;
1305 /* Hello interval */
1306 vl_config
.hello_interval
= OSPF_HELLO_INTERVAL_DEFAULT
;
1310 /* Retransmit Interval */
1311 vl_config
.retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
1315 /* Transmit Delay */
1316 vl_config
.transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
1322 vl_config
.dead_interval
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
1328 /* Action configuration */
1330 return ospf_vl_set (ospf
, &vl_config
);
1333 ALIAS (ospf_area_vlink
,
1334 ospf_area_vlink_param1_cmd
,
1335 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1336 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1337 VLINK_HELPSTR_IPADDR
1338 VLINK_HELPSTR_TIME_PARAM
)
1340 ALIAS (no_ospf_area_vlink
,
1341 no_ospf_area_vlink_param1_cmd
,
1342 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1343 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1345 VLINK_HELPSTR_IPADDR
1346 VLINK_HELPSTR_TIME_PARAM
)
1348 ALIAS (ospf_area_vlink
,
1349 ospf_area_vlink_param2_cmd
,
1350 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1351 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1352 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1353 VLINK_HELPSTR_IPADDR
1354 VLINK_HELPSTR_TIME_PARAM
1355 VLINK_HELPSTR_TIME_PARAM
)
1357 ALIAS (no_ospf_area_vlink
,
1358 no_ospf_area_vlink_param2_cmd
,
1359 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1360 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1361 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1363 VLINK_HELPSTR_IPADDR
1364 VLINK_HELPSTR_TIME_PARAM
1365 VLINK_HELPSTR_TIME_PARAM
)
1367 ALIAS (ospf_area_vlink
,
1368 ospf_area_vlink_param3_cmd
,
1369 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1370 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1371 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1372 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1373 VLINK_HELPSTR_IPADDR
1374 VLINK_HELPSTR_TIME_PARAM
1375 VLINK_HELPSTR_TIME_PARAM
1376 VLINK_HELPSTR_TIME_PARAM
)
1378 ALIAS (no_ospf_area_vlink
,
1379 no_ospf_area_vlink_param3_cmd
,
1380 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1381 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1382 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1383 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1385 VLINK_HELPSTR_IPADDR
1386 VLINK_HELPSTR_TIME_PARAM
1387 VLINK_HELPSTR_TIME_PARAM
1388 VLINK_HELPSTR_TIME_PARAM
)
1390 ALIAS (ospf_area_vlink
,
1391 ospf_area_vlink_param4_cmd
,
1392 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1393 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1394 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1395 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1396 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1397 VLINK_HELPSTR_IPADDR
1398 VLINK_HELPSTR_TIME_PARAM
1399 VLINK_HELPSTR_TIME_PARAM
1400 VLINK_HELPSTR_TIME_PARAM
1401 VLINK_HELPSTR_TIME_PARAM
)
1403 ALIAS (no_ospf_area_vlink
,
1404 no_ospf_area_vlink_param4_cmd
,
1405 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1406 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1407 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1408 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1409 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1411 VLINK_HELPSTR_IPADDR
1412 VLINK_HELPSTR_TIME_PARAM
1413 VLINK_HELPSTR_TIME_PARAM
1414 VLINK_HELPSTR_TIME_PARAM
1415 VLINK_HELPSTR_TIME_PARAM
)
1417 ALIAS (ospf_area_vlink
,
1418 ospf_area_vlink_authtype_args_cmd
,
1419 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1420 "(authentication|) (message-digest|null)",
1421 VLINK_HELPSTR_IPADDR
1422 VLINK_HELPSTR_AUTHTYPE_ALL
)
1424 ALIAS (no_ospf_area_vlink
,
1425 no_ospf_area_vlink_authtype_args_cmd
,
1426 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1427 "(authentication|) (message-digest|null)",
1429 VLINK_HELPSTR_IPADDR
1430 VLINK_HELPSTR_AUTHTYPE_ALL
)
1432 ALIAS (ospf_area_vlink
,
1433 ospf_area_vlink_authtype_cmd
,
1434 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1435 "(authentication|)",
1436 VLINK_HELPSTR_IPADDR
1437 VLINK_HELPSTR_AUTHTYPE_SIMPLE
)
1439 ALIAS (no_ospf_area_vlink
,
1440 no_ospf_area_vlink_authtype_cmd
,
1441 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1442 "(authentication|)",
1444 VLINK_HELPSTR_IPADDR
1445 VLINK_HELPSTR_AUTHTYPE_SIMPLE
)
1447 ALIAS (ospf_area_vlink
,
1448 ospf_area_vlink_md5_cmd
,
1449 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1450 "(message-digest-key|) <1-255> md5 KEY",
1451 VLINK_HELPSTR_IPADDR
1452 VLINK_HELPSTR_AUTH_MD5
)
1454 ALIAS (no_ospf_area_vlink
,
1455 no_ospf_area_vlink_md5_cmd
,
1456 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1457 "(message-digest-key|) <1-255> md5 KEY",
1459 VLINK_HELPSTR_IPADDR
1460 VLINK_HELPSTR_AUTH_MD5
)
1462 ALIAS (ospf_area_vlink
,
1463 ospf_area_vlink_authkey_cmd
,
1464 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1465 "(authentication-key|) AUTH_KEY",
1466 VLINK_HELPSTR_IPADDR
1467 VLINK_HELPSTR_AUTH_SIMPLE
)
1469 ALIAS (no_ospf_area_vlink
,
1470 no_ospf_area_vlink_authkey_cmd
,
1471 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1472 "(authentication-key|) AUTH_KEY",
1474 VLINK_HELPSTR_IPADDR
1475 VLINK_HELPSTR_AUTH_SIMPLE
)
1477 ALIAS (ospf_area_vlink
,
1478 ospf_area_vlink_authtype_args_authkey_cmd
,
1479 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1480 "(authentication|) (message-digest|null) "
1481 "(authentication-key|) AUTH_KEY",
1482 VLINK_HELPSTR_IPADDR
1483 VLINK_HELPSTR_AUTHTYPE_ALL
1484 VLINK_HELPSTR_AUTH_SIMPLE
)
1486 ALIAS (no_ospf_area_vlink
,
1487 no_ospf_area_vlink_authtype_args_authkey_cmd
,
1488 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1489 "(authentication|) (message-digest|null) "
1490 "(authentication-key|) AUTH_KEY",
1492 VLINK_HELPSTR_IPADDR
1493 VLINK_HELPSTR_AUTHTYPE_ALL
1494 VLINK_HELPSTR_AUTH_SIMPLE
)
1496 ALIAS (ospf_area_vlink
,
1497 ospf_area_vlink_authtype_authkey_cmd
,
1498 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1499 "(authentication|) "
1500 "(authentication-key|) AUTH_KEY",
1501 VLINK_HELPSTR_IPADDR
1502 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1503 VLINK_HELPSTR_AUTH_SIMPLE
)
1505 ALIAS (no_ospf_area_vlink
,
1506 no_ospf_area_vlink_authtype_authkey_cmd
,
1507 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1508 "(authentication|) "
1509 "(authentication-key|) AUTH_KEY",
1511 VLINK_HELPSTR_IPADDR
1512 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1513 VLINK_HELPSTR_AUTH_SIMPLE
)
1515 ALIAS (ospf_area_vlink
,
1516 ospf_area_vlink_authtype_args_md5_cmd
,
1517 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1518 "(authentication|) (message-digest|null) "
1519 "(message-digest-key|) <1-255> md5 KEY",
1520 VLINK_HELPSTR_IPADDR
1521 VLINK_HELPSTR_AUTHTYPE_ALL
1522 VLINK_HELPSTR_AUTH_MD5
)
1524 ALIAS (no_ospf_area_vlink
,
1525 no_ospf_area_vlink_authtype_args_md5_cmd
,
1526 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1527 "(authentication|) (message-digest|null) "
1528 "(message-digest-key|) <1-255> md5 KEY",
1530 VLINK_HELPSTR_IPADDR
1531 VLINK_HELPSTR_AUTHTYPE_ALL
1532 VLINK_HELPSTR_AUTH_MD5
)
1534 ALIAS (ospf_area_vlink
,
1535 ospf_area_vlink_authtype_md5_cmd
,
1536 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1537 "(authentication|) "
1538 "(message-digest-key|) <1-255> md5 KEY",
1539 VLINK_HELPSTR_IPADDR
1540 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1541 VLINK_HELPSTR_AUTH_MD5
)
1543 ALIAS (no_ospf_area_vlink
,
1544 no_ospf_area_vlink_authtype_md5_cmd
,
1545 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1546 "(authentication|) "
1547 "(message-digest-key|) <1-255> md5 KEY",
1549 VLINK_HELPSTR_IPADDR
1550 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1551 VLINK_HELPSTR_AUTH_MD5
)
1554 DEFUN (ospf_area_shortcut
,
1555 ospf_area_shortcut_cmd
,
1556 "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)",
1557 "OSPF area parameters\n"
1558 "OSPF area ID in IP address format\n"
1559 "OSPF area ID as a decimal value\n"
1560 "Configure the area's shortcutting mode\n"
1561 "Set default shortcutting behavior\n"
1562 "Enable shortcutting through the area\n"
1563 "Disable shortcutting through the area\n")
1565 struct ospf
*ospf
= vty
->index
;
1566 struct ospf_area
*area
;
1567 struct in_addr area_id
;
1574 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id
, format
, argv
[0]);
1576 area
= ospf_area_get (ospf
, area_id
, format
);
1578 if (strncmp (argv
[1], "de", 2) == 0)
1579 mode
= OSPF_SHORTCUT_DEFAULT
;
1580 else if (strncmp (argv
[1], "di", 2) == 0)
1581 mode
= OSPF_SHORTCUT_DISABLE
;
1582 else if (strncmp (argv
[1], "e", 1) == 0)
1583 mode
= OSPF_SHORTCUT_ENABLE
;
1587 ospf_area_shortcut_set (ospf
, area
, mode
);
1589 if (ospf
->abr_type
!= OSPF_ABR_SHORTCUT
)
1590 vty_out (vty
, "Shortcut area setting will take effect "
1591 "only when the router is configured as Shortcut ABR%s",
1597 DEFUN (no_ospf_area_shortcut
,
1598 no_ospf_area_shortcut_cmd
,
1599 "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)",
1601 "OSPF area parameters\n"
1602 "OSPF area ID in IP address format\n"
1603 "OSPF area ID as a decimal value\n"
1604 "Deconfigure the area's shortcutting mode\n"
1605 "Deconfigure enabled shortcutting through the area\n"
1606 "Deconfigure disabled shortcutting through the area\n")
1608 struct ospf
*ospf
= vty
->index
;
1609 struct ospf_area
*area
;
1610 struct in_addr area_id
;
1616 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id
, format
, argv
[0]);
1618 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1622 ospf_area_shortcut_unset (ospf
, area
);
1628 DEFUN (ospf_area_stub
,
1630 "area (A.B.C.D|<0-4294967295>) stub",
1631 "OSPF area parameters\n"
1632 "OSPF area ID in IP address format\n"
1633 "OSPF area ID as a decimal value\n"
1634 "Configure OSPF area as stub\n")
1636 struct ospf
*ospf
= vty
->index
;
1637 struct in_addr area_id
;
1643 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[0]);
1645 ret
= ospf_area_stub_set (ospf
, area_id
);
1648 vty_out (vty
, "First deconfigure all virtual link through this area%s",
1653 ospf_area_no_summary_unset (ospf
, area_id
);
1658 DEFUN (ospf_area_stub_no_summary
,
1659 ospf_area_stub_no_summary_cmd
,
1660 "area (A.B.C.D|<0-4294967295>) stub no-summary",
1661 "OSPF stub parameters\n"
1662 "OSPF area ID in IP address format\n"
1663 "OSPF area ID as a decimal value\n"
1664 "Configure OSPF area as stub\n"
1665 "Do not inject inter-area routes into stub\n")
1667 struct ospf
*ospf
= vty
->index
;
1668 struct in_addr area_id
;
1674 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[0]);
1676 ret
= ospf_area_stub_set (ospf
, area_id
);
1679 vty_out (vty
, "%% Area cannot be stub as it contains a virtual link%s",
1684 ospf_area_no_summary_set (ospf
, area_id
);
1689 DEFUN (no_ospf_area_stub
,
1690 no_ospf_area_stub_cmd
,
1691 "no area (A.B.C.D|<0-4294967295>) stub",
1693 "OSPF area parameters\n"
1694 "OSPF area ID in IP address format\n"
1695 "OSPF area ID as a decimal value\n"
1696 "Configure OSPF area as stub\n")
1698 struct ospf
*ospf
= vty
->index
;
1699 struct in_addr area_id
;
1705 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[0]);
1707 ospf_area_stub_unset (ospf
, area_id
);
1708 ospf_area_no_summary_unset (ospf
, area_id
);
1713 DEFUN (no_ospf_area_stub_no_summary
,
1714 no_ospf_area_stub_no_summary_cmd
,
1715 "no area (A.B.C.D|<0-4294967295>) stub no-summary",
1717 "OSPF area parameters\n"
1718 "OSPF area ID in IP address format\n"
1719 "OSPF area ID as a decimal value\n"
1720 "Configure OSPF area as stub\n"
1721 "Do not inject inter-area routes into area\n")
1723 struct ospf
*ospf
= vty
->index
;
1724 struct in_addr area_id
;
1730 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[0]);
1731 ospf_area_no_summary_unset (ospf
, area_id
);
1737 ospf_area_nssa_cmd_handler (struct vty
*vty
, int argc
, const char *argv
[],
1740 struct ospf
*ospf
= vty
->index
;
1741 struct in_addr area_id
;
1747 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id
, format
, argv
[0]);
1749 ret
= ospf_area_nssa_set (ospf
, area_id
);
1752 vty_out (vty
, "%% Area cannot be nssa as it contains a virtual link%s",
1759 if (strncmp (argv
[1], "translate-c", 11) == 0)
1760 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1761 OSPF_NSSA_ROLE_CANDIDATE
);
1762 else if (strncmp (argv
[1], "translate-n", 11) == 0)
1763 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1764 OSPF_NSSA_ROLE_NEVER
);
1765 else if (strncmp (argv
[1], "translate-a", 11) == 0)
1766 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1767 OSPF_NSSA_ROLE_ALWAYS
);
1771 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1772 OSPF_NSSA_ROLE_CANDIDATE
);
1776 ospf_area_no_summary_set (ospf
, area_id
);
1778 ospf_area_no_summary_unset (ospf
, area_id
);
1780 ospf_schedule_abr_task (ospf
);
1785 DEFUN (ospf_area_nssa_translate_no_summary
,
1786 ospf_area_nssa_translate_no_summary_cmd
,
1787 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary",
1788 "OSPF area parameters\n"
1789 "OSPF area ID in IP address format\n"
1790 "OSPF area ID as a decimal value\n"
1791 "Configure OSPF area as nssa\n"
1792 "Configure NSSA-ABR for translate election (default)\n"
1793 "Configure NSSA-ABR to never translate\n"
1794 "Configure NSSA-ABR to always translate\n"
1795 "Do not inject inter-area routes into nssa\n")
1797 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 1);
1800 DEFUN (ospf_area_nssa_translate
,
1801 ospf_area_nssa_translate_cmd
,
1802 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)",
1803 "OSPF area parameters\n"
1804 "OSPF area ID in IP address format\n"
1805 "OSPF area ID as a decimal value\n"
1806 "Configure OSPF area as nssa\n"
1807 "Configure NSSA-ABR for translate election (default)\n"
1808 "Configure NSSA-ABR to never translate\n"
1809 "Configure NSSA-ABR to always translate\n")
1811 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 0);
1814 DEFUN (ospf_area_nssa
,
1816 "area (A.B.C.D|<0-4294967295>) nssa",
1817 "OSPF area parameters\n"
1818 "OSPF area ID in IP address format\n"
1819 "OSPF area ID as a decimal value\n"
1820 "Configure OSPF area as nssa\n")
1822 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 0);
1825 DEFUN (ospf_area_nssa_no_summary
,
1826 ospf_area_nssa_no_summary_cmd
,
1827 "area (A.B.C.D|<0-4294967295>) nssa no-summary",
1828 "OSPF area parameters\n"
1829 "OSPF area ID in IP address format\n"
1830 "OSPF area ID as a decimal value\n"
1831 "Configure OSPF area as nssa\n"
1832 "Do not inject inter-area routes into nssa\n")
1834 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 1);
1837 DEFUN (no_ospf_area_nssa
,
1838 no_ospf_area_nssa_cmd
,
1839 "no area (A.B.C.D|<0-4294967295>) nssa",
1841 "OSPF area parameters\n"
1842 "OSPF area ID in IP address format\n"
1843 "OSPF area ID as a decimal value\n"
1844 "Configure OSPF area as nssa\n")
1846 struct ospf
*ospf
= vty
->index
;
1847 struct in_addr area_id
;
1853 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id
, format
, argv
[0]);
1855 ospf_area_nssa_unset (ospf
, area_id
);
1856 ospf_area_no_summary_unset (ospf
, area_id
);
1858 ospf_schedule_abr_task (ospf
);
1863 ALIAS (no_ospf_area_nssa
,
1864 no_ospf_area_nssa_no_summary_cmd
,
1865 "no area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always|) {no-summary}",
1867 "OSPF area parameters\n"
1868 "OSPF area ID in IP address format\n"
1869 "OSPF area ID as a decimal value\n"
1870 "Configure OSPF area as nssa\n"
1871 "Configure NSSA-ABR for translate election (default)\n"
1872 "Configure NSSA-ABR to never translate\n"
1873 "Configure NSSA-ABR to always translate\n"
1874 "Do not inject inter-area routes into nssa\n")
1876 DEFUN (ospf_area_default_cost
,
1877 ospf_area_default_cost_cmd
,
1878 "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1879 "OSPF area parameters\n"
1880 "OSPF area ID in IP address format\n"
1881 "OSPF area ID as a decimal value\n"
1882 "Set the summary-default cost of a NSSA or stub area\n"
1883 "Stub's advertised default summary cost\n")
1885 struct ospf
*ospf
= vty
->index
;
1886 struct ospf_area
*area
;
1887 struct in_addr area_id
;
1890 struct prefix_ipv4 p
;
1895 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id
, format
, argv
[0]);
1896 VTY_GET_INTEGER_RANGE ("stub default cost", cost
, argv
[1], 0, 16777215);
1898 area
= ospf_area_get (ospf
, area_id
, format
);
1900 if (area
->external_routing
== OSPF_AREA_DEFAULT
)
1902 vty_out (vty
, "The area is neither stub, nor NSSA%s", VTY_NEWLINE
);
1906 area
->default_cost
= cost
;
1909 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1911 if (IS_DEBUG_OSPF_EVENT
)
1912 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1913 "announcing 0.0.0.0/0 to area %s",
1914 inet_ntoa (area
->area_id
));
1915 ospf_abr_announce_network_to_area (&p
, area
->default_cost
, area
);
1920 DEFUN (no_ospf_area_default_cost
,
1921 no_ospf_area_default_cost_cmd
,
1922 "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1924 "OSPF area parameters\n"
1925 "OSPF area ID in IP address format\n"
1926 "OSPF area ID as a decimal value\n"
1927 "Set the summary-default cost of a NSSA or stub area\n"
1928 "Stub's advertised default summary cost\n")
1930 struct ospf
*ospf
= vty
->index
;
1931 struct ospf_area
*area
;
1932 struct in_addr area_id
;
1934 struct prefix_ipv4 p
;
1939 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id
, format
, argv
[0]);
1940 VTY_CHECK_INTEGER_RANGE ("stub default cost", argv
[1], 0, OSPF_LS_INFINITY
);
1942 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1946 if (area
->external_routing
== OSPF_AREA_DEFAULT
)
1948 vty_out (vty
, "The area is neither stub, nor NSSA%s", VTY_NEWLINE
);
1952 area
->default_cost
= 1;
1955 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1957 if (IS_DEBUG_OSPF_EVENT
)
1958 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1959 "announcing 0.0.0.0/0 to area %s",
1960 inet_ntoa (area
->area_id
));
1961 ospf_abr_announce_network_to_area (&p
, area
->default_cost
, area
);
1964 ospf_area_check_free (ospf
, area_id
);
1969 DEFUN (ospf_area_export_list
,
1970 ospf_area_export_list_cmd
,
1971 "area (A.B.C.D|<0-4294967295>) export-list NAME",
1972 "OSPF area parameters\n"
1973 "OSPF area ID in IP address format\n"
1974 "OSPF area ID as a decimal value\n"
1975 "Set the filter for networks announced to other areas\n"
1976 "Name of the access-list\n")
1978 struct ospf
*ospf
= vty
->index
;
1979 struct ospf_area
*area
;
1980 struct in_addr area_id
;
1986 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
1988 area
= ospf_area_get (ospf
, area_id
, format
);
1989 ospf_area_export_list_set (ospf
, area
, argv
[1]);
1994 DEFUN (no_ospf_area_export_list
,
1995 no_ospf_area_export_list_cmd
,
1996 "no area (A.B.C.D|<0-4294967295>) export-list NAME",
1998 "OSPF area parameters\n"
1999 "OSPF area ID in IP address format\n"
2000 "OSPF area ID as a decimal value\n"
2001 "Unset the filter for networks announced to other areas\n"
2002 "Name of the access-list\n")
2004 struct ospf
*ospf
= vty
->index
;
2005 struct ospf_area
*area
;
2006 struct in_addr area_id
;
2012 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
2014 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
2018 ospf_area_export_list_unset (ospf
, area
);
2024 DEFUN (ospf_area_import_list
,
2025 ospf_area_import_list_cmd
,
2026 "area (A.B.C.D|<0-4294967295>) import-list NAME",
2027 "OSPF area parameters\n"
2028 "OSPF area ID in IP address format\n"
2029 "OSPF area ID as a decimal value\n"
2030 "Set the filter for networks from other areas announced to the specified one\n"
2031 "Name of the access-list\n")
2033 struct ospf
*ospf
= vty
->index
;
2034 struct ospf_area
*area
;
2035 struct in_addr area_id
;
2041 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
2043 area
= ospf_area_get (ospf
, area_id
, format
);
2044 ospf_area_import_list_set (ospf
, area
, argv
[1]);
2049 DEFUN (no_ospf_area_import_list
,
2050 no_ospf_area_import_list_cmd
,
2051 "no area (A.B.C.D|<0-4294967295>) import-list NAME",
2053 "OSPF area parameters\n"
2054 "OSPF area ID in IP address format\n"
2055 "OSPF area ID as a decimal value\n"
2056 "Unset the filter for networks announced to other areas\n"
2057 "Name of the access-list\n")
2059 struct ospf
*ospf
= vty
->index
;
2060 struct ospf_area
*area
;
2061 struct in_addr area_id
;
2067 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
2069 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
2073 ospf_area_import_list_unset (ospf
, area
);
2078 DEFUN (ospf_area_filter_list
,
2079 ospf_area_filter_list_cmd
,
2080 "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
2081 "OSPF area parameters\n"
2082 "OSPF area ID in IP address format\n"
2083 "OSPF area ID as a decimal value\n"
2084 "Filter networks between OSPF areas\n"
2085 "Filter prefixes between OSPF areas\n"
2086 "Name of an IP prefix-list\n"
2087 "Filter networks sent to this area\n"
2088 "Filter networks sent from this area\n")
2090 struct ospf
*ospf
= vty
->index
;
2091 struct ospf_area
*area
;
2092 struct in_addr area_id
;
2093 struct prefix_list
*plist
;
2099 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
2101 area
= ospf_area_get (ospf
, area_id
, format
);
2102 plist
= prefix_list_lookup (AFI_IP
, argv
[1]);
2103 if (strncmp (argv
[2], "in", 2) == 0)
2105 PREFIX_LIST_IN (area
) = plist
;
2106 if (PREFIX_NAME_IN (area
))
2107 free (PREFIX_NAME_IN (area
));
2109 PREFIX_NAME_IN (area
) = strdup (argv
[1]);
2110 ospf_schedule_abr_task (ospf
);
2114 PREFIX_LIST_OUT (area
) = plist
;
2115 if (PREFIX_NAME_OUT (area
))
2116 free (PREFIX_NAME_OUT (area
));
2118 PREFIX_NAME_OUT (area
) = strdup (argv
[1]);
2119 ospf_schedule_abr_task (ospf
);
2125 DEFUN (no_ospf_area_filter_list
,
2126 no_ospf_area_filter_list_cmd
,
2127 "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
2129 "OSPF area parameters\n"
2130 "OSPF area ID in IP address format\n"
2131 "OSPF area ID as a decimal value\n"
2132 "Filter networks between OSPF areas\n"
2133 "Filter prefixes between OSPF areas\n"
2134 "Name of an IP prefix-list\n"
2135 "Filter networks sent to this area\n"
2136 "Filter networks sent from this area\n")
2138 struct ospf
*ospf
= vty
->index
;
2139 struct ospf_area
*area
;
2140 struct in_addr area_id
;
2146 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
2148 if ((area
= ospf_area_lookup_by_area_id (ospf
, area_id
)) == NULL
)
2151 if (strncmp (argv
[2], "in", 2) == 0)
2153 if (PREFIX_NAME_IN (area
))
2154 if (strcmp (PREFIX_NAME_IN (area
), argv
[1]) != 0)
2157 PREFIX_LIST_IN (area
) = NULL
;
2158 if (PREFIX_NAME_IN (area
))
2159 free (PREFIX_NAME_IN (area
));
2161 PREFIX_NAME_IN (area
) = NULL
;
2163 ospf_schedule_abr_task (ospf
);
2167 if (PREFIX_NAME_OUT (area
))
2168 if (strcmp (PREFIX_NAME_OUT (area
), argv
[1]) != 0)
2171 PREFIX_LIST_OUT (area
) = NULL
;
2172 if (PREFIX_NAME_OUT (area
))
2173 free (PREFIX_NAME_OUT (area
));
2175 PREFIX_NAME_OUT (area
) = NULL
;
2177 ospf_schedule_abr_task (ospf
);
2184 DEFUN (ospf_area_authentication_message_digest
,
2185 ospf_area_authentication_message_digest_cmd
,
2186 "area (A.B.C.D|<0-4294967295>) authentication message-digest",
2187 "OSPF area parameters\n"
2188 "OSPF area ID in IP address format\n"
2189 "OSPF area ID as a decimal value\n"
2190 "Enable authentication\n"
2191 "Use message-digest authentication\n")
2193 struct ospf
*ospf
= vty
->index
;
2194 struct ospf_area
*area
;
2195 struct in_addr area_id
;
2201 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
2203 area
= ospf_area_get (ospf
, area_id
, format
);
2204 area
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
2209 DEFUN (ospf_area_authentication
,
2210 ospf_area_authentication_cmd
,
2211 "area (A.B.C.D|<0-4294967295>) authentication",
2212 "OSPF area parameters\n"
2213 "OSPF area ID in IP address format\n"
2214 "OSPF area ID as a decimal value\n"
2215 "Enable authentication\n")
2217 struct ospf
*ospf
= vty
->index
;
2218 struct ospf_area
*area
;
2219 struct in_addr area_id
;
2225 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
2227 area
= ospf_area_get (ospf
, area_id
, format
);
2228 area
->auth_type
= OSPF_AUTH_SIMPLE
;
2233 DEFUN (no_ospf_area_authentication
,
2234 no_ospf_area_authentication_cmd
,
2235 "no area (A.B.C.D|<0-4294967295>) authentication",
2237 "OSPF area parameters\n"
2238 "OSPF area ID in IP address format\n"
2239 "OSPF area ID as a decimal value\n"
2240 "Enable authentication\n")
2242 struct ospf
*ospf
= vty
->index
;
2243 struct ospf_area
*area
;
2244 struct in_addr area_id
;
2250 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[0]);
2252 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
2256 area
->auth_type
= OSPF_AUTH_NULL
;
2258 ospf_area_check_free (ospf
, area_id
);
2264 DEFUN (ospf_abr_type
,
2266 "ospf abr-type (cisco|ibm|shortcut|standard)",
2267 "OSPF specific commands\n"
2268 "Set OSPF ABR type\n"
2269 "Alternative ABR, cisco implementation\n"
2270 "Alternative ABR, IBM implementation\n"
2272 "Standard behavior (RFC2328)\n")
2274 struct ospf
*ospf
= vty
->index
;
2275 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2280 if (strncmp (argv
[0], "c", 1) == 0)
2281 abr_type
= OSPF_ABR_CISCO
;
2282 else if (strncmp (argv
[0], "i", 1) == 0)
2283 abr_type
= OSPF_ABR_IBM
;
2284 else if (strncmp (argv
[0], "sh", 2) == 0)
2285 abr_type
= OSPF_ABR_SHORTCUT
;
2286 else if (strncmp (argv
[0], "st", 2) == 0)
2287 abr_type
= OSPF_ABR_STAND
;
2291 /* If ABR type value is changed, schedule ABR task. */
2292 if (ospf
->abr_type
!= abr_type
)
2294 ospf
->abr_type
= abr_type
;
2295 ospf_schedule_abr_task (ospf
);
2301 DEFUN (no_ospf_abr_type
,
2302 no_ospf_abr_type_cmd
,
2303 "no ospf abr-type (cisco|ibm|shortcut|standard)",
2305 "OSPF specific commands\n"
2306 "Set OSPF ABR type\n"
2307 "Alternative ABR, cisco implementation\n"
2308 "Alternative ABR, IBM implementation\n"
2311 struct ospf
*ospf
= vty
->index
;
2312 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2317 if (strncmp (argv
[0], "c", 1) == 0)
2318 abr_type
= OSPF_ABR_CISCO
;
2319 else if (strncmp (argv
[0], "i", 1) == 0)
2320 abr_type
= OSPF_ABR_IBM
;
2321 else if (strncmp (argv
[0], "sh", 2) == 0)
2322 abr_type
= OSPF_ABR_SHORTCUT
;
2323 else if (strncmp (argv
[0], "st", 2) == 0)
2324 abr_type
= OSPF_ABR_STAND
;
2328 /* If ABR type value is changed, schedule ABR task. */
2329 if (ospf
->abr_type
== abr_type
)
2331 ospf
->abr_type
= OSPF_ABR_DEFAULT
;
2332 ospf_schedule_abr_task (ospf
);
2338 DEFUN (ospf_log_adjacency_changes
,
2339 ospf_log_adjacency_changes_cmd
,
2340 "log-adjacency-changes",
2341 "Log changes in adjacency state\n")
2343 struct ospf
*ospf
= vty
->index
;
2348 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2349 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2353 DEFUN (ospf_log_adjacency_changes_detail
,
2354 ospf_log_adjacency_changes_detail_cmd
,
2355 "log-adjacency-changes detail",
2356 "Log changes in adjacency state\n"
2357 "Log all state changes\n")
2359 struct ospf
*ospf
= vty
->index
;
2364 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2365 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2369 DEFUN (no_ospf_log_adjacency_changes
,
2370 no_ospf_log_adjacency_changes_cmd
,
2371 "no log-adjacency-changes",
2373 "Log changes in adjacency state\n")
2375 struct ospf
*ospf
= vty
->index
;
2380 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2381 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2385 DEFUN (no_ospf_log_adjacency_changes_detail
,
2386 no_ospf_log_adjacency_changes_detail_cmd
,
2387 "no log-adjacency-changes detail",
2389 "Log changes in adjacency state\n"
2390 "Log all state changes\n")
2392 struct ospf
*ospf
= vty
->index
;
2397 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2398 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2402 DEFUN (ospf_compatible_rfc1583
,
2403 ospf_compatible_rfc1583_cmd
,
2404 "compatible rfc1583",
2405 "OSPF compatibility list\n"
2406 "compatible with RFC 1583\n")
2408 struct ospf
*ospf
= vty
->index
;
2413 if (!CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
2415 SET_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2416 ospf_spf_calculate_schedule (ospf
, SPF_FLAG_CONFIG_CHANGE
);
2421 DEFUN (no_ospf_compatible_rfc1583
,
2422 no_ospf_compatible_rfc1583_cmd
,
2423 "no compatible rfc1583",
2425 "OSPF compatibility list\n"
2426 "compatible with RFC 1583\n")
2428 struct ospf
*ospf
= vty
->index
;
2433 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
2435 UNSET_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2436 ospf_spf_calculate_schedule (ospf
, SPF_FLAG_CONFIG_CHANGE
);
2441 ALIAS (ospf_compatible_rfc1583
,
2442 ospf_rfc1583_flag_cmd
,
2443 "ospf rfc1583compatibility",
2444 "OSPF specific commands\n"
2445 "Enable the RFC1583Compatibility flag\n")
2447 ALIAS (no_ospf_compatible_rfc1583
,
2448 no_ospf_rfc1583_flag_cmd
,
2449 "no ospf rfc1583compatibility",
2451 "OSPF specific commands\n"
2452 "Disable the RFC1583Compatibility flag\n")
2455 ospf_timers_spf_set (struct vty
*vty
, unsigned int delay
,
2459 struct ospf
*ospf
= vty
->index
;
2464 ospf
->spf_delay
= delay
;
2465 ospf
->spf_holdtime
= hold
;
2466 ospf
->spf_max_holdtime
= max
;
2471 DEFUN (ospf_timers_min_ls_interval
,
2472 ospf_timers_min_ls_interval_cmd
,
2473 "timers throttle lsa all <0-5000>",
2474 "Adjust routing timers\n"
2475 "Throttling adaptive timer\n"
2476 "LSA delay between transmissions\n"
2478 "Delay (msec) between sending LSAs\n")
2480 struct ospf
*ospf
= vty
->index
;
2481 unsigned int interval
;
2488 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2492 VTY_GET_INTEGER ("LSA interval", interval
, argv
[0]);
2494 ospf
->min_ls_interval
= interval
;
2499 DEFUN (no_ospf_timers_min_ls_interval
,
2500 no_ospf_timers_min_ls_interval_cmd
,
2501 "no timers throttle lsa all",
2503 "Adjust routing timers\n"
2504 "Throttling adaptive timer\n"
2505 "LSA delay between transmissions\n"
2508 struct ospf
*ospf
= vty
->index
;
2509 ospf
->min_ls_interval
= OSPF_MIN_LS_INTERVAL
;
2514 ALIAS (no_ospf_timers_min_ls_interval
,
2515 no_ospf_timers_min_ls_interval_val_cmd
,
2516 "no timers throttle lsa all <0-5000>",
2518 "Adjust routing timers\n"
2519 "Throttling adaptive timer\n"
2520 "LSA delay between transmissions\n"
2522 "Delay (msec) between sending LSAs\n")
2524 DEFUN (ospf_timers_min_ls_arrival
,
2525 ospf_timers_min_ls_arrival_cmd
,
2526 "timers lsa arrival <0-1000>",
2527 "Adjust routing timers\n"
2528 "Throttling link state advertisement delays\n"
2529 "OSPF minimum arrival interval delay\n"
2530 "Delay (msec) between accepted LSAs\n")
2532 struct ospf
*ospf
= vty
->index
;
2533 unsigned int arrival
;
2540 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2544 VTY_GET_INTEGER_RANGE ("minimum LSA inter-arrival time", arrival
, argv
[0], 0, 1000);
2546 ospf
->min_ls_arrival
= arrival
;
2551 DEFUN (no_ospf_timers_min_ls_arrival
,
2552 no_ospf_timers_min_ls_arrival_cmd
,
2553 "no timers lsa arrival",
2555 "Adjust routing timers\n"
2556 "Throttling link state advertisement delays\n"
2557 "OSPF minimum arrival interval delay\n")
2559 struct ospf
*ospf
= vty
->index
;
2564 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2569 ALIAS (no_ospf_timers_min_ls_arrival
,
2570 no_ospf_timers_min_ls_arrival_val_cmd
,
2571 "no timers lsa arrival <0-1000>",
2573 "Adjust routing timers\n"
2574 "Throttling link state advertisement delays\n"
2575 "OSPF minimum arrival interval delay\n"
2576 "Delay (msec) between accepted LSAs\n")
2578 DEFUN (ospf_timers_throttle_spf
,
2579 ospf_timers_throttle_spf_cmd
,
2580 "timers throttle spf <0-600000> <0-600000> <0-600000>",
2581 "Adjust routing timers\n"
2582 "Throttling adaptive timer\n"
2584 "Delay (msec) from first change received till SPF calculation\n"
2585 "Initial hold time (msec) between consecutive SPF calculations\n"
2586 "Maximum hold time (msec)\n")
2588 unsigned int delay
, hold
, max
;
2592 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2596 VTY_GET_INTEGER_RANGE ("SPF delay timer", delay
, argv
[0], 0, 600000);
2597 VTY_GET_INTEGER_RANGE ("SPF hold timer", hold
, argv
[1], 0, 600000);
2598 VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max
, argv
[2], 0, 600000);
2600 return ospf_timers_spf_set (vty
, delay
, hold
, max
);
2603 DEFUN (no_ospf_timers_throttle_spf
,
2604 no_ospf_timers_throttle_spf_cmd
,
2605 "no timers throttle spf",
2607 "Adjust routing timers\n"
2608 "Throttling adaptive timer\n"
2609 "OSPF SPF timers\n")
2611 return ospf_timers_spf_set (vty
,
2612 OSPF_SPF_DELAY_DEFAULT
,
2613 OSPF_SPF_HOLDTIME_DEFAULT
,
2614 OSPF_SPF_MAX_HOLDTIME_DEFAULT
);
2617 ALIAS (no_ospf_timers_throttle_spf
,
2618 no_ospf_timers_throttle_spf_val_cmd
,
2619 "no timers throttle spf <0-600000> <0-600000> <0-600000>",
2621 "Adjust routing timers\n"
2622 "Throttling adaptive timer\n"
2624 "Delay (msec) from first change received till SPF calculation\n"
2625 "Initial hold time (msec) between consecutive SPF calculations\n"
2626 "Maximum hold time (msec)\n")
2628 DEFUN (ospf_timers_lsa
,
2629 ospf_timers_lsa_cmd
,
2630 "timers lsa min-arrival <0-600000>",
2631 "Adjust routing timers\n"
2633 "Minimum delay in receiving new version of a LSA\n"
2634 "Delay in milliseconds\n")
2636 unsigned int minarrival
;
2637 struct ospf
*ospf
= vty
->index
;
2644 vty_out (vty
, "Insufficient number of arguments%s", VTY_NEWLINE
);
2648 VTY_GET_INTEGER ("LSA min-arrival", minarrival
, argv
[0]);
2650 ospf
->min_ls_arrival
= minarrival
;
2655 DEFUN (no_ospf_timers_lsa
,
2656 no_ospf_timers_lsa_cmd
,
2657 "no timers lsa min-arrival",
2659 "Adjust routing timers\n"
2661 "Minimum delay in receiving new version of a LSA\n")
2663 unsigned int minarrival
;
2664 struct ospf
*ospf
= vty
->index
;
2671 VTY_GET_INTEGER ("LSA min-arrival", minarrival
, argv
[0]);
2673 if (ospf
->min_ls_arrival
!= minarrival
||
2674 minarrival
== OSPF_MIN_LS_ARRIVAL
)
2678 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2683 ALIAS (no_ospf_timers_lsa
,
2684 no_ospf_timers_lsa_val_cmd
,
2685 "no timers lsa min-arrival <0-600000>",
2687 "Adjust routing timers\n"
2689 "Minimum delay in receiving new version of a LSA\n"
2690 "Delay in milliseconds\n")
2693 DEFUN (ospf_neighbor
,
2697 "Neighbor IP address\n")
2699 struct ospf
*ospf
= vty
->index
;
2700 struct in_addr nbr_addr
;
2701 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2702 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2707 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[0]);
2710 VTY_GET_INTEGER_RANGE ("neighbor priority", priority
, argv
[1], 0, 255);
2713 VTY_GET_INTEGER_RANGE ("poll interval", interval
, argv
[2], 1, 65535);
2715 ospf_nbr_nbma_set (ospf
, nbr_addr
);
2717 ospf_nbr_nbma_priority_set (ospf
, nbr_addr
, priority
);
2719 ospf_nbr_nbma_poll_interval_set (ospf
, nbr_addr
, interval
);
2724 ALIAS (ospf_neighbor
,
2725 ospf_neighbor_priority_poll_interval_cmd
,
2726 "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2728 "Neighbor IP address\n"
2729 "Neighbor Priority\n"
2731 "Dead Neighbor Polling interval\n"
2734 ALIAS (ospf_neighbor
,
2735 ospf_neighbor_priority_cmd
,
2736 "neighbor A.B.C.D priority <0-255>",
2738 "Neighbor IP address\n"
2739 "Neighbor Priority\n"
2742 DEFUN (ospf_neighbor_poll_interval
,
2743 ospf_neighbor_poll_interval_cmd
,
2744 "neighbor A.B.C.D poll-interval <1-65535>",
2746 "Neighbor IP address\n"
2747 "Dead Neighbor Polling interval\n"
2750 struct ospf
*ospf
= vty
->index
;
2751 struct in_addr nbr_addr
;
2752 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2753 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2758 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[0]);
2761 VTY_GET_INTEGER_RANGE ("poll interval", interval
, argv
[1], 1, 65535);
2764 VTY_GET_INTEGER_RANGE ("neighbor priority", priority
, argv
[2], 0, 255);
2766 ospf_nbr_nbma_set (ospf
, nbr_addr
);
2768 ospf_nbr_nbma_poll_interval_set (ospf
, nbr_addr
, interval
);
2770 ospf_nbr_nbma_priority_set (ospf
, nbr_addr
, priority
);
2775 ALIAS (ospf_neighbor_poll_interval
,
2776 ospf_neighbor_poll_interval_priority_cmd
,
2777 "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2779 "Neighbor address\n"
2780 "OSPF dead-router polling interval\n"
2782 "OSPF priority of non-broadcast neighbor\n"
2785 DEFUN (no_ospf_neighbor
,
2786 no_ospf_neighbor_cmd
,
2787 "no neighbor A.B.C.D",
2790 "Neighbor IP address\n")
2792 struct ospf
*ospf
= vty
->index
;
2793 struct in_addr nbr_addr
;
2798 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[0]);
2800 (void)ospf_nbr_nbma_unset (ospf
, nbr_addr
);
2805 ALIAS (no_ospf_neighbor
,
2806 no_ospf_neighbor_priority_cmd
,
2807 "no neighbor A.B.C.D priority <0-255>",
2810 "Neighbor IP address\n"
2811 "Neighbor Priority\n"
2814 ALIAS (no_ospf_neighbor
,
2815 no_ospf_neighbor_poll_interval_cmd
,
2816 "no neighbor A.B.C.D poll-interval <1-65535>",
2819 "Neighbor IP address\n"
2820 "Dead Neighbor Polling interval\n"
2823 ALIAS (no_ospf_neighbor
,
2824 no_ospf_neighbor_poll_interval_priority_cmd
,
2825 "no neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2828 "Neighbor IP address\n"
2829 "Dead Neighbor Polling interval\n"
2831 "OSPF priority of non-broadcast neighbor\n"
2834 ALIAS (no_ospf_neighbor
,
2835 no_ospf_neighbor_priority_pollinterval_cmd
,
2836 "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2839 "Neighbor IP address\n"
2840 "Neighbor Priority\n"
2842 "Dead Neighbor Polling interval\n"
2845 DEFUN (ospf_refresh_timer
, ospf_refresh_timer_cmd
,
2846 "refresh timer <10-1800>",
2847 "Adjust refresh parameters\n"
2848 "Set refresh timer\n"
2849 "Timer value in seconds\n")
2851 struct ospf
*ospf
= vty
->index
;
2852 unsigned int interval
;
2857 VTY_GET_INTEGER_RANGE ("refresh timer", interval
, argv
[0], 10, 1800);
2858 interval
= (interval
/ OSPF_LSA_REFRESHER_GRANULARITY
) * OSPF_LSA_REFRESHER_GRANULARITY
;
2860 ospf_timers_refresh_set (ospf
, interval
);
2865 DEFUN (no_ospf_refresh_timer
, no_ospf_refresh_timer_val_cmd
,
2866 "no refresh timer <10-1800>",
2867 "Adjust refresh parameters\n"
2868 "Unset refresh timer\n"
2869 "Timer value in seconds\n")
2871 struct ospf
*ospf
= vty
->index
;
2872 unsigned int interval
;
2879 VTY_GET_INTEGER_RANGE ("refresh timer", interval
, argv
[0], 10, 1800);
2881 if (ospf
->lsa_refresh_interval
!= interval
||
2882 interval
== OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
2886 ospf_timers_refresh_unset (ospf
);
2891 ALIAS (no_ospf_refresh_timer
,
2892 no_ospf_refresh_timer_cmd
,
2894 "Adjust refresh parameters\n"
2895 "Unset refresh timer\n")
2897 DEFUN (ospf_auto_cost_reference_bandwidth
,
2898 ospf_auto_cost_reference_bandwidth_cmd
,
2899 "auto-cost reference-bandwidth <1-4294967>",
2900 "Calculate OSPF interface cost according to bandwidth\n"
2901 "Use reference bandwidth method to assign OSPF cost\n"
2902 "The reference bandwidth in terms of Mbits per second\n")
2904 struct ospf
*ospf
= vty
->index
;
2906 struct listnode
*node
;
2907 struct interface
*ifp
;
2912 refbw
= strtol (argv
[0], NULL
, 10);
2913 if (refbw
< 1 || refbw
> 4294967)
2915 vty_out (vty
, "reference-bandwidth value is invalid%s", VTY_NEWLINE
);
2919 /* If reference bandwidth is changed. */
2920 if ((refbw
) == ospf
->ref_bandwidth
)
2923 ospf
->ref_bandwidth
= refbw
;
2924 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, node
, ifp
))
2925 ospf_if_recalculate_output_cost (ifp
);
2930 DEFUN (no_ospf_auto_cost_reference_bandwidth
,
2931 no_ospf_auto_cost_reference_bandwidth_cmd
,
2932 "no auto-cost reference-bandwidth",
2934 "Calculate OSPF interface cost according to bandwidth\n"
2935 "Use reference bandwidth method to assign OSPF cost\n")
2937 struct ospf
*ospf
= vty
->index
;
2938 struct listnode
*node
, *nnode
;
2939 struct interface
*ifp
;
2944 if (ospf
->ref_bandwidth
== OSPF_DEFAULT_REF_BANDWIDTH
)
2947 ospf
->ref_bandwidth
= OSPF_DEFAULT_REF_BANDWIDTH
;
2948 vty_out (vty
, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE
);
2949 vty_out (vty
, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE
);
2951 for (ALL_LIST_ELEMENTS (om
->iflist
, node
, nnode
, ifp
))
2952 ospf_if_recalculate_output_cost (ifp
);
2957 ALIAS (no_ospf_auto_cost_reference_bandwidth
,
2958 no_ospf_auto_cost_reference_bandwidth_val_cmd
,
2959 "no auto-cost reference-bandwidth <1-4294967>",
2961 "Calculate OSPF interface cost according to bandwidth\n"
2962 "Use reference bandwidth method to assign OSPF cost\n"
2963 "The reference bandwidth in terms of Mbits per second\n")
2965 DEFUN (ospf_write_multiplier
,
2966 ospf_write_multiplier_cmd
,
2967 "ospf write-multiplier <1-100>",
2968 "OSPF specific commands\n"
2969 "Write multiplier\n"
2970 "Maximum number of interface serviced per write\n")
2972 struct ospf
*ospf
= vty
->index
;
2973 u_int32_t write_oi_count
;
2978 write_oi_count
= strtol (argv
[0], NULL
, 10);
2979 if (write_oi_count
< 1 || write_oi_count
> 100)
2981 vty_out (vty
, "write-multiplier value is invalid%s", VTY_NEWLINE
);
2985 ospf
->write_oi_count
= write_oi_count
;
2989 ALIAS (ospf_write_multiplier
,
2990 write_multiplier_cmd
,
2991 "write-multiplier <1-100>",
2992 "Write multiplier\n"
2993 "Maximum number of interface serviced per write\n")
2995 DEFUN (no_ospf_write_multiplier
,
2996 no_ospf_write_multiplier_cmd
,
2997 "no ospf write-multiplier <1-100>",
2999 "OSPF specific commands\n"
3000 "Write multiplier\n"
3001 "Maximum number of interface serviced per write\n")
3003 struct ospf
*ospf
= vty
->index
;
3008 ospf
->write_oi_count
= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
;
3012 ALIAS (no_ospf_write_multiplier
,
3013 no_write_multiplier_cmd
,
3014 "no write-multiplier",
3016 "Write multiplier\n")
3018 ALIAS (no_ospf_write_multiplier
,
3019 no_write_multiplier_val_cmd
,
3020 "no write-multiplier <1-100>",
3022 "Write multiplier\n"
3023 "Maximum number of interface serviced per write\n")
3025 const char *ospf_abr_type_descr_str
[] =
3028 "Standard (RFC2328)",
3030 "Alternative Cisco",
3031 "Alternative Shortcut"
3034 const char *ospf_shortcut_mode_descr_str
[] =
3042 show_ip_ospf_area (struct vty
*vty
, struct ospf_area
*area
, json_object
*json_areas
, u_char use_json
)
3044 json_object
*json_area
= NULL
;
3047 json_area
= json_object_new_object();
3051 vty_out (vty
, " Area ID: %s", inet_ntoa (area
->area_id
));
3053 /* Show Area type/mode. */
3054 if (OSPF_IS_AREA_BACKBONE (area
))
3057 json_object_boolean_true_add(json_area
, "backbone");
3059 vty_out (vty
, " (Backbone)%s", VTY_NEWLINE
);
3065 if (area
->external_routing
== OSPF_AREA_STUB
)
3067 if (area
->no_summary
)
3068 json_object_boolean_true_add(json_area
, "stubNoSummary");
3069 if (area
->shortcut_configured
)
3070 json_object_boolean_true_add(json_area
, "stubShortcut");
3072 else if (area
->external_routing
== OSPF_AREA_NSSA
)
3074 if (area
->no_summary
)
3075 json_object_boolean_true_add(json_area
, "nssaNoSummary");
3076 if (area
->shortcut_configured
)
3077 json_object_boolean_true_add(json_area
, "nssaShortcut");
3080 json_object_string_add(json_area
,"shortcuttingMode",
3081 ospf_shortcut_mode_descr_str
[area
->shortcut_configured
]);
3082 if (area
->shortcut_capability
)
3083 json_object_boolean_true_add(json_area
,"sBitConcensus");
3087 if (area
->external_routing
== OSPF_AREA_STUB
)
3088 vty_out (vty
, " (Stub%s%s)",
3089 area
->no_summary
? ", no summary" : "",
3090 area
->shortcut_configured
? "; " : "");
3091 else if (area
->external_routing
== OSPF_AREA_NSSA
)
3092 vty_out (vty
, " (NSSA%s%s)",
3093 area
->no_summary
? ", no summary" : "",
3094 area
->shortcut_configured
? "; " : "");
3096 vty_out (vty
, "%s", VTY_NEWLINE
);
3097 vty_out (vty
, " Shortcutting mode: %s",
3098 ospf_shortcut_mode_descr_str
[area
->shortcut_configured
]);
3099 vty_out (vty
, ", S-bit consensus: %s%s",
3100 area
->shortcut_capability
? "ok" : "no", VTY_NEWLINE
);
3104 /* Show number of interfaces */
3107 json_object_int_add(json_area
, "areaIfTotalCounter", listcount (area
->oiflist
));
3108 json_object_int_add(json_area
, "areaIfActiveCounter", area
->act_ints
);
3111 vty_out (vty
, " Number of interfaces in this area: Total: %d, "
3112 "Active: %d%s", listcount (area
->oiflist
),
3113 area
->act_ints
, VTY_NEWLINE
);
3115 if (area
->external_routing
== OSPF_AREA_NSSA
)
3119 json_object_boolean_true_add(json_area
, "nssa");
3120 if (! IS_OSPF_ABR (area
->ospf
))
3121 json_object_boolean_false_add(json_area
, "abr");
3122 else if (area
->NSSATranslatorState
)
3124 json_object_boolean_true_add(json_area
, "abr");
3125 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
3126 json_object_boolean_true_add(json_area
, "nssaTranslatorElected");
3127 else if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_ALWAYS
)
3128 json_object_boolean_true_add(json_area
, "nssaTranslatorAlways");
3132 json_object_boolean_true_add(json_area
, "abr");
3133 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
3134 json_object_boolean_false_add(json_area
, "nssaTranslatorElected");
3136 json_object_boolean_true_add(json_area
, "nssaTranslatorNever");
3141 vty_out (vty
, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE
, VTY_NEWLINE
);
3142 if (! IS_OSPF_ABR (area
->ospf
))
3143 vty_out (vty
, " It is not ABR, therefore not Translator. %s",
3145 else if (area
->NSSATranslatorState
)
3147 vty_out (vty
, " We are an ABR and ");
3148 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
3149 vty_out (vty
, "the NSSA Elected Translator. %s",
3151 else if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_ALWAYS
)
3152 vty_out (vty
, "always an NSSA Translator. %s",
3157 vty_out (vty
, " We are an ABR, but ");
3158 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
3159 vty_out (vty
, "not the NSSA Elected Translator. %s",
3162 vty_out (vty
, "never an NSSA Translator. %s",
3168 /* Stub-router state for this area */
3169 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
))
3171 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3175 json_object_boolean_true_add(json_area
, "originStubMaxDistRouterLsa");
3176 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
3177 json_object_boolean_true_add(json_area
, "indefiniteActiveAdmin");
3178 if (area
->t_stub_router
)
3180 struct timeval result
;
3181 unsigned long time_store
= 0;
3182 result
= tv_sub (area
->t_stub_router
->u
.sands
, recent_relative_time());
3183 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3184 json_object_int_add(json_area
, "activeStartupRemainderMsecs", time_store
);
3189 vty_out (vty
, " Originating stub / maximum-distance Router-LSA%s",
3191 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
3192 vty_out (vty
, " Administratively activated (indefinitely)%s",
3194 if (area
->t_stub_router
)
3195 vty_out (vty
, " Active from startup, %s remaining%s",
3196 ospf_timer_dump (area
->t_stub_router
, timebuf
,
3197 sizeof(timebuf
)), VTY_NEWLINE
);
3203 /* Show number of fully adjacent neighbors. */
3204 json_object_int_add(json_area
, "nbrFullAdjacentCounter", area
->full_nbrs
);
3206 /* Show authentication type. */
3207 if (area
->auth_type
== OSPF_AUTH_NULL
)
3208 json_object_string_add(json_area
, "authentication", "authenticationNone");
3209 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
3210 json_object_string_add(json_area
, "authentication", "authenticationSimplePassword");
3211 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
3212 json_object_string_add(json_area
, "authentication", "authenticationMessageDigest");
3214 if (!OSPF_IS_AREA_BACKBONE (area
))
3215 json_object_int_add(json_area
, "virtualAdjacenciesPassingCounter", area
->full_vls
);
3217 /* Show SPF calculation times. */
3218 json_object_int_add(json_area
, "spfExecutedCounter", area
->spf_calculation
);
3219 json_object_int_add(json_area
, "lsaNumber", area
->lsdb
->total
);
3220 json_object_int_add(json_area
, "lsaRouterNumber", ospf_lsdb_count (area
->lsdb
, OSPF_ROUTER_LSA
));
3221 json_object_int_add(json_area
, "lsaRouterChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_ROUTER_LSA
));
3222 json_object_int_add(json_area
, "lsaNetworkNumber", ospf_lsdb_count (area
->lsdb
, OSPF_NETWORK_LSA
));
3223 json_object_int_add(json_area
, "lsaNetworkChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_NETWORK_LSA
));
3224 json_object_int_add(json_area
, "lsaSummaryNumber", ospf_lsdb_count (area
->lsdb
, OSPF_SUMMARY_LSA
));
3225 json_object_int_add(json_area
, "lsaSummaryChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_SUMMARY_LSA
));
3226 json_object_int_add(json_area
, "lsaAsbrNumber", ospf_lsdb_count (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
3227 json_object_int_add(json_area
, "lsaAsbrChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
3228 json_object_int_add(json_area
, "lsaNssaNumber", ospf_lsdb_count (area
->lsdb
, OSPF_AS_NSSA_LSA
));
3229 json_object_int_add(json_area
, "lsaNssaChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_AS_NSSA_LSA
));
3233 /* Show number of fully adjacent neighbors. */
3234 vty_out (vty
, " Number of fully adjacent neighbors in this area:"
3235 " %d%s", area
->full_nbrs
, VTY_NEWLINE
);
3237 /* Show authentication type. */
3238 vty_out (vty
, " Area has ");
3239 if (area
->auth_type
== OSPF_AUTH_NULL
)
3240 vty_out (vty
, "no authentication%s", VTY_NEWLINE
);
3241 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
3242 vty_out (vty
, "simple password authentication%s", VTY_NEWLINE
);
3243 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
3244 vty_out (vty
, "message digest authentication%s", VTY_NEWLINE
);
3246 if (!OSPF_IS_AREA_BACKBONE (area
))
3247 vty_out (vty
, " Number of full virtual adjacencies going through"
3248 " this area: %d%s", area
->full_vls
, VTY_NEWLINE
);
3250 /* Show SPF calculation times. */
3251 vty_out (vty
, " SPF algorithm executed %d times%s",
3252 area
->spf_calculation
, VTY_NEWLINE
);
3254 /* Show number of LSA. */
3255 vty_out (vty
, " Number of LSA %ld%s", area
->lsdb
->total
, VTY_NEWLINE
);
3256 vty_out (vty
, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
3257 ospf_lsdb_count (area
->lsdb
, OSPF_ROUTER_LSA
),
3258 ospf_lsdb_checksum (area
->lsdb
, OSPF_ROUTER_LSA
), VTY_NEWLINE
);
3259 vty_out (vty
, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
3260 ospf_lsdb_count (area
->lsdb
, OSPF_NETWORK_LSA
),
3261 ospf_lsdb_checksum (area
->lsdb
, OSPF_NETWORK_LSA
), VTY_NEWLINE
);
3262 vty_out (vty
, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
3263 ospf_lsdb_count (area
->lsdb
, OSPF_SUMMARY_LSA
),
3264 ospf_lsdb_checksum (area
->lsdb
, OSPF_SUMMARY_LSA
), VTY_NEWLINE
);
3265 vty_out (vty
, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
3266 ospf_lsdb_count (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
),
3267 ospf_lsdb_checksum (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
), VTY_NEWLINE
);
3268 vty_out (vty
, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
3269 ospf_lsdb_count (area
->lsdb
, OSPF_AS_NSSA_LSA
),
3270 ospf_lsdb_checksum (area
->lsdb
, OSPF_AS_NSSA_LSA
), VTY_NEWLINE
);
3275 json_object_int_add(json_area
, "lsaOpaqueLinkNumber", ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
3276 json_object_int_add(json_area
, "lsaOpaqueLinkChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
3277 json_object_int_add(json_area
, "lsaOpaqueAreaNumber", ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
3278 json_object_int_add(json_area
, "lsaOpaqueAreaChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
3282 vty_out (vty
, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
3283 ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
),
3284 ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
), VTY_NEWLINE
);
3285 vty_out (vty
, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
3286 ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
),
3287 ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
), VTY_NEWLINE
);
3291 json_object_object_add(json_areas
, inet_ntoa (area
->area_id
), json_area
);
3293 vty_out (vty
, "%s", VTY_NEWLINE
);
3297 show_ip_ospf_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
3299 struct listnode
*node
, *nnode
;
3300 struct ospf_area
* area
;
3301 struct timeval result
;
3302 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3303 json_object
*json
= NULL
;
3304 json_object
*json_areas
= NULL
;
3308 json
= json_object_new_object();
3309 json_areas
= json_object_new_object();
3316 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3320 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3321 VTY_NEWLINE
, VTY_NEWLINE
);
3325 /* Show Router ID. */
3328 json_object_string_add(json
, "routerId", inet_ntoa (ospf
->router_id
));
3332 vty_out (vty
, " OSPF Routing Process, Router ID: %s%s",
3333 inet_ntoa (ospf
->router_id
),
3337 /* Graceful shutdown */
3338 if (ospf
->t_deferred_shutdown
)
3342 unsigned long time_store
= 0;
3343 result
= tv_sub (ospf
->t_deferred_shutdown
->u
.sands
, recent_relative_time());
3344 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3345 json_object_int_add(json
, "deferredShutdownMsecs", time_store
);
3349 vty_out (vty
, " Deferred shutdown in progress, %s remaining%s",
3350 ospf_timer_dump (ospf
->t_deferred_shutdown
,
3351 timebuf
, sizeof (timebuf
)), VTY_NEWLINE
);
3355 /* Show capability. */
3358 json_object_boolean_true_add(json
, "tosRoutesOnly");
3359 json_object_boolean_true_add(json
, "rfc2328Conform");
3360 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
3362 json_object_boolean_true_add(json
, "rfc1583Compatibility");
3367 vty_out (vty
, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE
);
3368 vty_out (vty
, " This implementation conforms to RFC2328%s", VTY_NEWLINE
);
3369 vty_out (vty
, " RFC1583Compatibility flag is %s%s",
3370 CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
) ?
3371 "enabled" : "disabled", VTY_NEWLINE
);
3376 if (CHECK_FLAG (ospf
->config
, OSPF_OPAQUE_CAPABLE
))
3378 json_object_boolean_true_add(json
, "opaqueCapable");
3383 vty_out (vty
, " OpaqueCapability flag is %s%s",
3384 CHECK_FLAG (ospf
->config
, OSPF_OPAQUE_CAPABLE
) ? "enabled" : "disabled",
3388 /* Show stub-router configuration */
3389 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
3390 || ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3394 json_object_boolean_true_add(json
, "stubAdvertisement");
3395 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3396 json_object_int_add(json
,"postStartEnabledMsecs", ospf
->stub_router_startup_time
/ 1000);
3397 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3398 json_object_int_add(json
,"preShutdownEnabledMsecs", ospf
->stub_router_shutdown_time
/ 1000);
3402 vty_out (vty
, " Stub router advertisement is configured%s",
3404 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3405 vty_out (vty
, " Enabled for %us after start-up%s",
3406 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
3407 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3408 vty_out (vty
, " Enabled for %us prior to full shutdown%s",
3409 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
3413 /* Show SPF timers. */
3416 json_object_int_add(json
, "spfScheduleDelayMsecs", ospf
->spf_delay
);
3417 json_object_int_add(json
, "holdtimeMinMsecs", ospf
->spf_holdtime
);
3418 json_object_int_add(json
, "holdtimeMaxMsecs", ospf
->spf_max_holdtime
);
3419 json_object_int_add(json
, "holdtimeMultplier", ospf
->spf_hold_multiplier
);
3423 vty_out (vty
, " Initial SPF scheduling delay %d millisec(s)%s"
3424 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
3425 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
3426 " Hold time multiplier is currently %d%s",
3427 ospf
->spf_delay
, VTY_NEWLINE
,
3428 ospf
->spf_holdtime
, VTY_NEWLINE
,
3429 ospf
->spf_max_holdtime
, VTY_NEWLINE
,
3430 ospf
->spf_hold_multiplier
, VTY_NEWLINE
);
3435 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
)
3437 unsigned long time_store
= 0;
3439 result
= tv_sub (recent_relative_time(), ospf
->ts_spf
);
3440 result
= tv_sub (result
, recent_relative_time());
3441 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3442 json_object_int_add(json
, "spfLastExecutedMsecs", time_store
);
3444 time_store
= (1000 * ospf
->ts_spf_duration
.tv_sec
) + (ospf
->ts_spf_duration
.tv_usec
/ 1000);
3445 json_object_int_add(json
, "spfLastDurationMsecs", time_store
);
3448 json_object_boolean_true_add(json
, "spfHasNotRun");
3452 vty_out (vty
, " SPF algorithm ");
3453 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
)
3455 result
= tv_sub (recent_relative_time(), ospf
->ts_spf
);
3456 vty_out (vty
, "last executed %s ago%s",
3457 ospf_timeval_dump (&result
, timebuf
, sizeof (timebuf
)),
3459 vty_out (vty
, " Last SPF duration %s%s",
3460 ospf_timeval_dump (&ospf
->ts_spf_duration
, timebuf
, sizeof (timebuf
)),
3464 vty_out (vty
, "has not been run%s", VTY_NEWLINE
);
3469 struct timeval temp_time
;
3470 unsigned long time_store
= 0;
3472 if (ospf
->t_spf_calc
)
3474 temp_time
= tv_sub (ospf
->t_spf_calc
->u
.sands
, recent_relative_time());
3475 time_store
= (1000 * temp_time
.tv_sec
) + (temp_time
.tv_usec
/ 1000);
3476 json_object_int_add(json
, "spfTimerDueInMsecs", time_store
);
3479 json_object_int_add(json
, "lsaMinIntervalMsecs", ospf
->min_ls_interval
);
3480 json_object_int_add(json
, "lsaMinArrivalMsecs", ospf
->min_ls_arrival
);
3481 /* Show write multiplier values */
3482 json_object_int_add(json
, "writeMultiplier", ospf
->write_oi_count
);
3483 /* Show refresh parameters. */
3484 json_object_int_add(json
, "refreshTimerMsecs", ospf
->lsa_refresh_interval
* 1000);
3488 vty_out (vty
, " SPF timer %s%s%s",
3489 (ospf
->t_spf_calc
? "due in " : "is "),
3490 ospf_timer_dump (ospf
->t_spf_calc
, timebuf
, sizeof (timebuf
)),
3493 vty_out (vty
, " LSA minimum interval %d msecs%s",
3494 ospf
->min_ls_interval
, VTY_NEWLINE
);
3495 vty_out (vty
, " LSA minimum arrival %d msecs%s",
3496 ospf
->min_ls_arrival
, VTY_NEWLINE
);
3498 /* Show write multiplier values */
3499 vty_out (vty
, " Write Multiplier set to %d %s",
3500 ospf
->write_oi_count
, VTY_NEWLINE
);
3502 /* Show refresh parameters. */
3503 vty_out (vty
, " Refresh timer %d secs%s",
3504 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
3507 /* Show ABR/ASBR flags. */
3508 if (CHECK_FLAG (ospf
->flags
, OSPF_FLAG_ABR
))
3511 json_object_string_add(json
, "abrType", ospf_abr_type_descr_str
[ospf
->abr_type
]);
3513 vty_out (vty
, " This router is an ABR, ABR type is: %s%s",
3514 ospf_abr_type_descr_str
[ospf
->abr_type
], VTY_NEWLINE
);
3516 if (CHECK_FLAG (ospf
->flags
, OSPF_FLAG_ASBR
))
3519 json_object_string_add(json
, "asbrRouter", "injectingExternalRoutingInformation");
3521 vty_out (vty
, " This router is an ASBR "
3522 "(injecting external routing information)%s", VTY_NEWLINE
);
3525 /* Show Number of AS-external-LSAs. */
3528 json_object_int_add(json
, "lsaExternalCounter",
3529 ospf_lsdb_count (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3530 json_object_int_add(json
, "lsaExternalChecksum",
3531 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3535 vty_out (vty
, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
3536 ospf_lsdb_count (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
),
3537 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
), VTY_NEWLINE
);
3542 json_object_int_add(json
, "lsaAsopaqueCounter",
3543 ospf_lsdb_count (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3544 json_object_int_add(json
, "lsaAsOpaqueChecksum",
3545 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3549 vty_out (vty
, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
3550 ospf_lsdb_count (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
),
3551 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
), VTY_NEWLINE
);
3554 /* Show number of areas attached. */
3556 json_object_int_add(json
, "attachedAreaCounter", listcount (ospf
->areas
));
3558 vty_out (vty
, " Number of areas attached to this router: %d%s",
3559 listcount (ospf
->areas
), VTY_NEWLINE
);
3561 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
))
3563 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
3566 json_object_boolean_true_add(json
, "adjacencyChangesLoggedAll");
3568 vty_out(vty
, " All adjacency changes are logged%s",VTY_NEWLINE
);
3573 json_object_boolean_true_add(json
, "adjacencyChangesLogged");
3575 vty_out(vty
, " Adjacency changes are logged%s",VTY_NEWLINE
);
3578 /* Show each area status. */
3579 for (ALL_LIST_ELEMENTS (ospf
->areas
, node
, nnode
, area
))
3580 show_ip_ospf_area (vty
, area
, json_areas
, use_json
);
3584 json_object_object_add(json
, "areas", json_areas
);
3585 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3586 json_object_free(json
);
3589 vty_out (vty
, "%s",VTY_NEWLINE
);
3594 DEFUN (show_ip_ospf
,
3596 "show ip ospf {json}",
3599 "OSPF information\n"
3600 "JavaScript Object Notation\n")
3603 u_char uj
= use_json(argc
, argv
);
3605 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3608 return (show_ip_ospf_common(vty
, ospf
, uj
));
3611 DEFUN (show_ip_ospf_instance
,
3612 show_ip_ospf_instance_cmd
,
3613 "show ip ospf <1-65535> {json}",
3616 "OSPF information\n"
3618 "JavaScript Object Notation\n")
3621 u_short instance
= 0;
3622 u_char uj
= use_json(argc
, argv
);
3624 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
3625 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
3628 return (show_ip_ospf_common(vty
, ospf
, uj
));
3632 show_ip_ospf_interface_sub (struct vty
*vty
, struct ospf
*ospf
, struct interface
*ifp
,
3633 json_object
*json_interface_sub
, u_char use_json
)
3636 struct ospf_neighbor
*nbr
;
3637 struct route_node
*rn
;
3639 /* Is interface up? */
3642 is_up
= if_is_operative(ifp
);
3644 json_object_boolean_true_add(json_interface_sub
, "ifUp");
3646 json_object_boolean_false_add(json_interface_sub
, "ifDown");
3648 json_object_int_add(json_interface_sub
, "ifIndex", ifp
->ifindex
);
3649 json_object_int_add(json_interface_sub
, "mtuBytes", ifp
->mtu
);
3650 json_object_int_add(json_interface_sub
, "bandwidthMbit", ifp
->bandwidth
);
3651 json_object_string_add(json_interface_sub
, "ifFlags", if_flag_dump(ifp
->flags
));
3655 vty_out (vty
, "%s is %s%s", ifp
->name
,
3656 ((is_up
= if_is_operative(ifp
)) ? "up" : "down"), VTY_NEWLINE
);
3657 vty_out (vty
, " ifindex %u, MTU %u bytes, BW %u Mbit %s%s",
3658 ifp
->ifindex
, ifp
->mtu
, ifp
->bandwidth
, if_flag_dump(ifp
->flags
),
3662 /* Is interface OSPF enabled? */
3665 if (ospf_oi_count(ifp
) == 0)
3667 json_object_boolean_false_add(json_interface_sub
, "ospfEnabled");
3672 json_object_boolean_false_add(json_interface_sub
, "ospfRunning");
3676 json_object_boolean_true_add(json_interface_sub
, "ospfEnabled");
3680 if (ospf_oi_count(ifp
) == 0)
3682 vty_out (vty
, " OSPF not enabled on this interface%s", VTY_NEWLINE
);
3687 vty_out (vty
, " OSPF is enabled, but not running on this interface%s",
3693 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
3695 struct ospf_interface
*oi
= rn
->info
;
3700 if (CHECK_FLAG(oi
->connected
->flags
, ZEBRA_IFA_UNNUMBERED
))
3703 json_object_boolean_true_add(json_interface_sub
, "ifUnnumbered");
3705 vty_out (vty
, " This interface is UNNUMBERED,");
3709 /* Show OSPF interface information. */
3712 json_object_string_add(json_interface_sub
, "ipAddress", inet_ntoa (oi
->address
->u
.prefix4
));
3713 json_object_int_add(json_interface_sub
, "ipAddressPrefixlen", oi
->address
->prefixlen
);
3716 vty_out (vty
, " Internet Address %s/%d,",
3717 inet_ntoa (oi
->address
->u
.prefix4
), oi
->address
->prefixlen
);
3719 if (oi
->connected
->destination
|| oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3721 struct in_addr
*dest
;
3724 if (CONNECTED_PEER(oi
->connected
)
3725 || oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3730 /* For Vlinks, showing the peer address is probably more
3731 * * * * * informative than the local interface that is being used
3733 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3734 dest
= &oi
->vl_data
->peer_addr
;
3736 dest
= &oi
->connected
->destination
->u
.prefix4
;
3740 json_object_string_add(json_interface_sub
, "ospfIfType", dstr
);
3741 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3742 json_object_string_add(json_interface_sub
, "vlinkPeer", inet_ntoa (*dest
));
3744 json_object_string_add(json_interface_sub
, "localIfUsed", inet_ntoa (*dest
));
3747 vty_out (vty
, " %s %s,", dstr
, inet_ntoa (*dest
));
3752 json_object_string_add(json_interface_sub
, "area", ospf_area_desc_string (oi
->area
));
3753 if (OSPF_IF_PARAM(oi
, mtu_ignore
))
3754 json_object_boolean_true_add(json_interface_sub
, "mtuMismatchDetect");
3755 json_object_string_add(json_interface_sub
, "routerId", inet_ntoa (ospf
->router_id
));
3756 json_object_string_add(json_interface_sub
, "networkType", ospf_network_type_str
[oi
->type
]);
3757 json_object_int_add(json_interface_sub
, "cost", oi
->output_cost
);
3758 json_object_int_add(json_interface_sub
, "transmitDelayMsecs", 1000 / OSPF_IF_PARAM (oi
,transmit_delay
));
3759 json_object_string_add(json_interface_sub
, "state", LOOKUP (ospf_ism_state_msg
, oi
->state
));
3760 json_object_int_add(json_interface_sub
, "priority", PRIORITY (oi
));
3764 vty_out (vty
, " Area %s%s", ospf_area_desc_string (oi
->area
),
3767 vty_out (vty
, " MTU mismatch detection:%s%s",
3768 OSPF_IF_PARAM(oi
, mtu_ignore
) ? "disabled" : "enabled", VTY_NEWLINE
);
3770 vty_out (vty
, " Router ID %s, Network Type %s, Cost: %d%s",
3771 inet_ntoa (ospf
->router_id
), ospf_network_type_str
[oi
->type
],
3772 oi
->output_cost
, VTY_NEWLINE
);
3774 vty_out (vty
, " Transmit Delay is %d sec, State %s, Priority %d%s",
3775 OSPF_IF_PARAM (oi
,transmit_delay
), LOOKUP (ospf_ism_state_msg
, oi
->state
),
3776 PRIORITY (oi
), VTY_NEWLINE
);
3779 /* Show DR information. */
3780 if (DR (oi
).s_addr
== 0)
3783 vty_out (vty
, " No backup designated router on this network%s",
3788 nbr
= ospf_nbr_lookup_by_addr (oi
->nbrs
, &BDR (oi
));
3792 vty_out (vty
, " No backup designated router on this network%s",
3799 json_object_string_add(json_interface_sub
, "bdrId", inet_ntoa (nbr
->router_id
));
3800 json_object_string_add(json_interface_sub
, "bdrAddress", inet_ntoa (nbr
->address
.u
.prefix4
));
3804 vty_out (vty
, " Backup Designated Router (ID) %s,",
3805 inet_ntoa (nbr
->router_id
));
3806 vty_out (vty
, " Interface Address %s%s",
3807 inet_ntoa (nbr
->address
.u
.prefix4
), VTY_NEWLINE
);
3812 /* Next network-LSA sequence number we'll use, if we're elected DR */
3813 if (oi
->params
&& ntohl (oi
->params
->network_lsa_seqnum
) != OSPF_INITIAL_SEQUENCE_NUMBER
)
3816 json_object_int_add(json_interface_sub
, "networkLsaSequence", ntohl (oi
->params
->network_lsa_seqnum
));
3818 vty_out (vty
, " Saved Network-LSA sequence number 0x%x%s",
3819 ntohl (oi
->params
->network_lsa_seqnum
), VTY_NEWLINE
);
3824 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3825 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3827 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3828 json_object_boolean_true_add(json_interface_sub
, "mcastMemberOspfAllRouters");
3829 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3830 json_object_boolean_true_add(json_interface_sub
, "mcastMemberOspfDesignatedRouters");
3835 vty_out (vty
, " Multicast group memberships:");
3836 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3837 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3839 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3840 vty_out (vty
, " OSPFAllRouters");
3841 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3842 vty_out (vty
, " OSPFDesignatedRouters");
3845 vty_out (vty
, " <None>");
3846 vty_out (vty
, "%s", VTY_NEWLINE
);
3851 if (OSPF_IF_PARAM (oi
, fast_hello
) == 0)
3852 json_object_int_add(json_interface_sub
, "timerMsecs", 1000 /OSPF_IF_PARAM (oi
, v_hello
));
3854 json_object_int_add(json_interface_sub
, "timerMsecs", 1000 / OSPF_IF_PARAM (oi
, fast_hello
));
3855 json_object_int_add(json_interface_sub
, "timerDeadMsecs", 1000 / OSPF_IF_PARAM (oi
, v_wait
));
3856 json_object_int_add(json_interface_sub
, "timerWaitMsecs", 1000 / OSPF_IF_PARAM (oi
, v_wait
));
3857 json_object_int_add(json_interface_sub
, "timerRetransmit", 1000 / OSPF_IF_PARAM (oi
, retransmit_interval
));
3861 vty_out (vty
, " Timer intervals configured,");
3862 vty_out (vty
, " Hello ");
3863 if (OSPF_IF_PARAM (oi
, fast_hello
) == 0)
3864 vty_out (vty
, "%ds,", OSPF_IF_PARAM (oi
, v_hello
));
3866 vty_out (vty
, "%dms,", 1000 / OSPF_IF_PARAM (oi
, fast_hello
));
3867 vty_out (vty
, " Dead %ds, Wait %ds, Retransmit %d%s",
3868 OSPF_IF_PARAM (oi
, v_wait
),
3869 OSPF_IF_PARAM (oi
, v_wait
),
3870 OSPF_IF_PARAM (oi
, retransmit_interval
),
3874 if (OSPF_IF_PASSIVE_STATUS (oi
) == OSPF_IF_ACTIVE
)
3876 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3879 struct timeval result
;
3880 unsigned long time_store
= 0;
3882 result
= tv_sub (oi
->t_hello
->u
.sands
, recent_relative_time());
3888 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3889 json_object_int_add(json_interface_sub
, "timerHelloInMsecs", time_store
);
3892 vty_out (vty
, " Hello due in %s%s",
3893 ospf_timer_dump (oi
->t_hello
, timebuf
, sizeof(timebuf
)),
3896 else /* passive-interface is set */
3899 json_object_boolean_true_add(json_interface_sub
, "timerPassiveIface");
3901 vty_out (vty
, " No Hellos (Passive interface)%s", VTY_NEWLINE
);
3906 json_object_int_add(json_interface_sub
, "nbrCount", ospf_nbr_count (oi
, 0));
3907 json_object_int_add(json_interface_sub
, "nbrAdjacentCount", ospf_nbr_count (oi
, NSM_Full
));
3910 vty_out (vty
, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
3911 ospf_nbr_count (oi
, 0), ospf_nbr_count (oi
, NSM_Full
),
3913 ospf_bfd_interface_show(vty
, ifp
, json_interface_sub
, use_json
);
3918 show_ip_ospf_interface_common (struct vty
*vty
, struct ospf
*ospf
, int argc
,
3919 const char **argv
, int iface_argv
, u_char use_json
)
3921 struct interface
*ifp
;
3922 struct listnode
*node
;
3923 json_object
*json
= NULL
;
3924 json_object
*json_interface_sub
= NULL
;
3928 json
= json_object_new_object();
3929 json_interface_sub
= json_object_new_object();
3935 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3937 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3938 VTY_NEWLINE
, VTY_NEWLINE
);
3941 if (argc
== (iface_argv
+ 1))
3943 /* Show All Interfaces.*/
3944 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
3946 if (ospf_oi_count(ifp
))
3948 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3950 json_object_object_add (json
, ifp
->name
, json_interface_sub
);
3954 else if (argv
[iface_argv
] && strcmp(argv
[iface_argv
], "json") == 0)
3958 json
= json_object_new_object();
3959 json_interface_sub
= json_object_new_object ();
3962 /* Show All Interfaces. */
3963 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
3965 if (ospf_oi_count(ifp
))
3967 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3969 json_object_object_add(json
, ifp
->name
, json_interface_sub
);
3975 /* Interface name is specified. */
3976 if ((ifp
= if_lookup_by_name (argv
[iface_argv
])) == NULL
)
3979 json_object_boolean_true_add(json
, "noSuchIface");
3981 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
3985 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3987 json_object_object_add(json
, ifp
->name
, json_interface_sub
);
3993 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3994 json_object_free(json
);
3997 vty_out (vty
, "%s", VTY_NEWLINE
);
4002 DEFUN (show_ip_ospf_interface
,
4003 show_ip_ospf_interface_cmd
,
4004 "show ip ospf interface [INTERFACE] {json}",
4007 "OSPF information\n"
4008 "Interface information\n"
4010 "JavaScript Object Notation\n")
4013 u_char uj
= use_json(argc
, argv
);
4015 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4018 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 0, uj
);
4021 DEFUN (show_ip_ospf_instance_interface
,
4022 show_ip_ospf_instance_interface_cmd
,
4023 "show ip ospf <1-65535> interface [INTERFACE] {json}",
4026 "OSPF information\n"
4028 "Interface information\n"
4030 "JavaScript Object Notation\n")
4033 u_short instance
= 0;
4034 u_char uj
= use_json(argc
, argv
);
4036 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
4037 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
4040 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 1, uj
);
4044 show_ip_ospf_neighbour_header (struct vty
*vty
)
4046 vty_out (vty
, "%s%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
4048 "Neighbor ID", "Pri", "State", "Dead Time",
4049 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
4054 show_ip_ospf_neighbor_sub (struct vty
*vty
, struct ospf_interface
*oi
, json_object
*json
, u_char use_json
)
4056 struct route_node
*rn
;
4057 struct ospf_neighbor
*nbr
;
4059 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4060 json_object
*json_neighbor
= NULL
;
4062 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4064 if ((nbr
= rn
->info
))
4066 /* Do not show myself. */
4067 if (nbr
!= oi
->nbr_self
)
4069 /* Down state is not shown. */
4070 if (nbr
->state
!= NSM_Down
)
4074 json_neighbor
= json_object_new_object();
4075 ospf_nbr_state_message (nbr
, msgbuf
, 16);
4077 struct timeval result
;
4078 unsigned long time_store
= 0;
4080 result
= tv_sub (nbr
->t_inactivity
->u
.sands
, recent_relative_time());
4081 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
4083 json_object_int_add (json_neighbor
, "priority", nbr
->priority
);
4084 json_object_string_add (json_neighbor
, "state", msgbuf
);
4085 json_object_int_add (json_neighbor
, "deadTimeMsecs", time_store
);
4086 json_object_string_add (json_neighbor
, "address", inet_ntoa (nbr
->src
));
4087 json_object_string_add (json_neighbor
, "ifaceName", IF_NAME (oi
));
4088 json_object_int_add (json_neighbor
, "retransmitCounter", ospf_ls_retransmit_count (nbr
));
4089 json_object_int_add (json_neighbor
, "requestCounter", ospf_ls_request_count (nbr
));
4090 json_object_int_add (json_neighbor
, "dbSummaryCounter", ospf_db_summary_count (nbr
));
4091 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4092 json_object_object_add(json
, "neighbor", json_neighbor
);
4094 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_neighbor
);
4098 ospf_nbr_state_message (nbr
, msgbuf
, 16);
4100 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4101 vty_out (vty
, "%-15s %3d %-15s ",
4105 vty_out (vty
, "%-15s %3d %-15s ",
4106 inet_ntoa (nbr
->router_id
), nbr
->priority
,
4109 vty_out (vty
, "%9s ",
4110 ospf_timer_dump (nbr
->t_inactivity
, timebuf
,
4112 vty_out (vty
, "%-15s ", inet_ntoa (nbr
->src
));
4113 vty_out (vty
, "%-20s %5ld %5ld %5d%s",
4114 IF_NAME (oi
), ospf_ls_retransmit_count (nbr
),
4115 ospf_ls_request_count (nbr
), ospf_db_summary_count (nbr
),
4125 show_ip_ospf_neighbor_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4127 struct ospf_interface
*oi
;
4128 struct listnode
*node
;
4129 json_object
*json
= NULL
;
4132 json
= json_object_new_object();
4134 show_ip_ospf_neighbour_header (vty
);
4139 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4141 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4142 VTY_NEWLINE
, VTY_NEWLINE
);
4145 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4146 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
4150 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4151 json_object_free(json
);
4154 vty_out (vty
, "%s", VTY_NEWLINE
);
4159 DEFUN (show_ip_ospf_neighbor
,
4160 show_ip_ospf_neighbor_cmd
,
4161 "show ip ospf neighbor {json}",
4164 "OSPF information\n"
4166 "JavaScript Object Notation\n")
4169 u_char uj
= use_json(argc
, argv
);
4171 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4174 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
4178 DEFUN (show_ip_ospf_instance_neighbor
,
4179 show_ip_ospf_instance_neighbor_cmd
,
4180 "show ip ospf <1-65535> neighbor {json}",
4183 "OSPF information\n"
4186 "JavaScript Object Notation\n")
4189 u_short instance
= 0;
4190 u_char uj
= use_json(argc
, argv
);
4192 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
4193 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4196 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
4200 show_ip_ospf_neighbor_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4202 struct listnode
*node
;
4203 struct ospf_interface
*oi
;
4204 json_object
*json
= NULL
;
4205 json_object
*json_neighbor_sub
= NULL
;
4209 json
= json_object_new_object();
4210 json_neighbor_sub
= json_object_new_object();
4213 show_ip_ospf_neighbour_header (vty
);
4218 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4220 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4221 VTY_NEWLINE
, VTY_NEWLINE
);
4224 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4226 struct listnode
*nbr_node
;
4227 struct ospf_nbr_nbma
*nbr_nbma
;
4229 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
4231 /* print Down neighbor status */
4232 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nbr_node
, nbr_nbma
))
4234 if (nbr_nbma
->nbr
== NULL
4235 || nbr_nbma
->nbr
->state
== NSM_Down
)
4239 json_object_int_add (json_neighbor_sub
, "nbrNbmaPriority", nbr_nbma
->priority
);
4240 json_object_boolean_true_add (json_neighbor_sub
, "nbrNbmaDown");
4241 json_object_string_add (json_neighbor_sub
, "nbrNbmaIfaceName", IF_NAME (oi
));
4242 json_object_int_add (json_neighbor_sub
, "nbrNbmaRetransmitCounter", 0);
4243 json_object_int_add (json_neighbor_sub
, "nbrNbmaRequestCounter", 0);
4244 json_object_int_add (json_neighbor_sub
, "nbrNbmaDbSummaryCounter", 0);
4245 json_object_object_add(json
, inet_ntoa (nbr_nbma
->addr
), json_neighbor_sub
);
4249 vty_out (vty
, "%-15s %3d %-15s %9s ",
4250 "-", nbr_nbma
->priority
, "Down", "-");
4251 vty_out (vty
, "%-15s %-20s %5d %5d %5d%s",
4252 inet_ntoa (nbr_nbma
->addr
), IF_NAME (oi
),
4253 0, 0, 0, VTY_NEWLINE
);
4261 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4262 json_object_free(json
);
4265 vty_out (vty
, "%s", VTY_NEWLINE
);
4270 DEFUN (show_ip_ospf_neighbor_all
,
4271 show_ip_ospf_neighbor_all_cmd
,
4272 "show ip ospf neighbor all {json}",
4275 "OSPF information\n"
4277 "include down status neighbor\n"
4278 "JavaScript Object Notation\n")
4281 u_char uj
= use_json(argc
, argv
);
4283 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4286 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
4289 DEFUN (show_ip_ospf_instance_neighbor_all
,
4290 show_ip_ospf_instance_neighbor_all_cmd
,
4291 "show ip ospf <1-65535> neighbor all {json}",
4294 "OSPF information\n"
4297 "include down status neighbor\n"
4298 "JavaScript Object Notation\n")
4301 u_short instance
= 0;
4302 u_char uj
= use_json(argc
, argv
);
4304 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
4305 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4308 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
4312 show_ip_ospf_neighbor_int_common (struct vty
*vty
, struct ospf
*ospf
, int arg_base
,
4313 const char **argv
, u_char use_json
)
4315 struct interface
*ifp
;
4316 struct route_node
*rn
;
4317 json_object
*json
= NULL
;
4320 json
= json_object_new_object();
4322 show_ip_ospf_neighbour_header (vty
);
4327 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4329 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4330 VTY_NEWLINE
, VTY_NEWLINE
);
4333 ifp
= if_lookup_by_name (argv
[arg_base
]);
4337 json_object_boolean_true_add(json
, "noSuchIface");
4339 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
4343 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
4345 struct ospf_interface
*oi
= rn
->info
;
4350 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
4355 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4356 json_object_free(json
);
4359 vty_out (vty
, "%s", VTY_NEWLINE
);
4364 DEFUN (show_ip_ospf_neighbor_int
,
4365 show_ip_ospf_neighbor_int_cmd
,
4366 "show ip ospf neighbor IFNAME {json}",
4369 "OSPF information\n"
4372 "JavaScript Object Notation\n")
4375 u_char uj
= use_json(argc
, argv
);
4377 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4380 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 0, argv
, uj
);
4383 DEFUN (show_ip_ospf_instance_neighbor_int
,
4384 show_ip_ospf_instance_neighbor_int_cmd
,
4385 "show ip ospf <1-65535> neighbor IFNAME {json}",
4388 "OSPF information\n"
4392 "JavaScript Object Notation\n")
4395 u_short instance
= 0;
4396 u_char uj
= use_json(argc
, argv
);
4398 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
4399 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4402 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 1, argv
, uj
);
4406 show_ip_ospf_nbr_nbma_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
, struct ospf_nbr_nbma
*nbr_nbma
,
4407 u_char use_json
, json_object
*json
)
4409 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4410 json_object
*json_sub
= NULL
;
4413 json_sub
= json_object_new_object();
4414 else /* Show neighbor ID. */
4415 vty_out (vty
, " Neighbor %s,", "-");
4417 /* Show interface address. */
4419 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr_nbma
->addr
));
4421 vty_out (vty
, " interface address %s%s",
4422 inet_ntoa (nbr_nbma
->addr
), VTY_NEWLINE
);
4427 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4428 json_object_string_add(json_sub
, "iface", IF_NAME (oi
));
4431 vty_out (vty
, " In the area %s via interface %s%s",
4432 ospf_area_desc_string (oi
->area
), IF_NAME (oi
), VTY_NEWLINE
);
4434 /* Show neighbor priority and state. */
4437 json_object_int_add(json_sub
, "nbrPriority", nbr_nbma
->priority
);
4438 json_object_string_add(json_sub
, "nbrState", "down");
4441 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4442 nbr_nbma
->priority
, "Down");
4444 /* Show state changes. */
4446 json_object_int_add(json_sub
, "stateChangeCounter", nbr_nbma
->state_change
);
4448 vty_out (vty
, " %d state changes%s", nbr_nbma
->state_change
, VTY_NEWLINE
);
4450 /* Show PollInterval */
4452 json_object_int_add(json_sub
, "pollInterval", nbr_nbma
->v_poll
);
4454 vty_out (vty
, " Poll interval %d%s", nbr_nbma
->v_poll
, VTY_NEWLINE
);
4456 /* Show poll-interval timer. */
4459 struct timeval res
= tv_sub (nbr_nbma
->t_poll
->u
.sands
, recent_relative_time ());
4460 unsigned long time_store
= 0;
4461 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4462 json_object_int_add(json_sub
, "pollIntervalTimerDueMsec", time_store
);
4465 vty_out (vty
, " Poll timer due in %s%s",
4466 ospf_timer_dump (nbr_nbma
->t_poll
, timebuf
, sizeof(timebuf
)),
4469 /* Show poll-interval timer thread. */
4472 if (nbr_nbma
->t_poll
!= NULL
)
4473 json_object_string_add(json_sub
, "pollIntervalTimerThread", "on");
4476 vty_out (vty
, " Thread Poll Timer %s%s",
4477 nbr_nbma
->t_poll
!= NULL
? "on" : "off", VTY_NEWLINE
);
4480 json_object_object_add(json
, "noNbrId", json_sub
);
4484 show_ip_ospf_neighbor_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
,
4485 struct ospf_neighbor
*nbr
, u_char use_json
, json_object
*json
)
4487 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4488 json_object
*json_sub
= NULL
;
4491 json_sub
= json_object_new_object();
4494 /* Show neighbor ID. */
4495 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4496 vty_out (vty
, " Neighbor %s,", "-");
4498 vty_out (vty
, " Neighbor %s,", inet_ntoa (nbr
->router_id
));
4501 /* Show interface address. */
4503 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr
->address
.u
.prefix4
));
4505 vty_out (vty
, " interface address %s%s",
4506 inet_ntoa (nbr
->address
.u
.prefix4
), VTY_NEWLINE
);
4511 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4512 json_object_string_add(json_sub
, "ifaceName", oi
->ifp
->name
);
4515 vty_out (vty
, " In the area %s via interface %s%s",
4516 ospf_area_desc_string (oi
->area
), oi
->ifp
->name
, VTY_NEWLINE
);
4518 /* Show neighbor priority and state. */
4521 json_object_int_add(json_sub
, "nbrPriority", nbr
->priority
);
4522 json_object_string_add(json_sub
, "nbrState", LOOKUP (ospf_nsm_state_msg
, nbr
->state
));
4525 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4526 nbr
->priority
, LOOKUP (ospf_nsm_state_msg
, nbr
->state
));
4528 /* Show state changes. */
4530 json_object_int_add(json_sub
, "stateChangeCounter", nbr
->state_change
);
4532 vty_out (vty
, " %d state changes%s", nbr
->state_change
, VTY_NEWLINE
);
4534 if (nbr
->ts_last_progress
.tv_sec
|| nbr
->ts_last_progress
.tv_usec
)
4536 struct timeval res
= tv_sub (recent_relative_time (), nbr
->ts_last_progress
);
4539 unsigned long time_store
= 0;
4540 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4541 json_object_int_add(json_sub
, "lastPrgrsvChangeMsec", time_store
);
4545 vty_out (vty
, " Most recent state change statistics:%s",
4547 vty_out (vty
, " Progressive change %s ago%s",
4548 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4553 if (nbr
->ts_last_regress
.tv_sec
|| nbr
->ts_last_regress
.tv_usec
)
4555 struct timeval res
= tv_sub (recent_relative_time (), nbr
->ts_last_regress
);
4558 unsigned long time_store
= 0;
4559 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4560 json_object_int_add(json_sub
, "lastRegressiveChangeMsec", time_store
);
4561 if (nbr
->last_regress_str
)
4562 json_object_string_add(json_sub
, "lastRegressiveChangeReason", nbr
->last_regress_str
);
4566 vty_out (vty
, " Regressive change %s ago, due to %s%s",
4567 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4568 (nbr
->last_regress_str
? nbr
->last_regress_str
: "??"),
4573 /* Show Designated Rotuer ID. */
4575 json_object_string_add(json_sub
, "routerDesignatedId", inet_ntoa (nbr
->d_router
));
4577 vty_out (vty
, " DR is %s,", inet_ntoa (nbr
->d_router
));
4579 /* Show Backup Designated Rotuer ID. */
4581 json_object_string_add(json_sub
, "routerDesignatedBackupId", inet_ntoa (nbr
->bd_router
));
4583 vty_out (vty
, " BDR is %s%s", inet_ntoa (nbr
->bd_router
), VTY_NEWLINE
);
4588 json_object_int_add(json_sub
, "optionsCounter", nbr
->options
);
4589 json_object_string_add(json_sub
, "optionsList", ospf_options_dump (nbr
->options
));
4592 vty_out (vty
, " Options %d %s%s", nbr
->options
,
4593 ospf_options_dump (nbr
->options
), VTY_NEWLINE
);
4595 /* Show Router Dead interval timer. */
4598 if (nbr
->t_inactivity
)
4600 struct timeval res
= tv_sub (nbr
->t_inactivity
->u
.sands
, recent_relative_time ());
4601 unsigned long time_store
= 0;
4602 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4603 json_object_int_add(json_sub
, "routerDeadIntervalTimerDueMsec", time_store
);
4606 json_object_int_add(json_sub
, "routerDeadIntervalTimerDueMsec", -1);
4609 vty_out (vty
, " Dead timer due in %s%s",
4610 ospf_timer_dump (nbr
->t_inactivity
, timebuf
, sizeof (timebuf
)),
4613 /* Show Database Summary list. */
4615 json_object_int_add(json_sub
, "databaseSummaryListCounter", ospf_db_summary_count (nbr
));
4617 vty_out (vty
, " Database Summary List %d%s",
4618 ospf_db_summary_count (nbr
), VTY_NEWLINE
);
4620 /* Show Link State Request list. */
4622 json_object_int_add(json_sub
, "linkStateRequestListCounter", ospf_ls_request_count (nbr
));
4624 vty_out (vty
, " Link State Request List %ld%s",
4625 ospf_ls_request_count (nbr
), VTY_NEWLINE
);
4627 /* Show Link State Retransmission list. */
4629 json_object_int_add(json_sub
, "linkStateRetransmissionListCounter", ospf_ls_retransmit_count (nbr
));
4631 vty_out (vty
, " Link State Retransmission List %ld%s",
4632 ospf_ls_retransmit_count (nbr
), VTY_NEWLINE
);
4634 /* Show inactivity timer thread. */
4637 if (nbr
->t_inactivity
!= NULL
)
4638 json_object_string_add(json_sub
, "threadInactivityTimer", "on");
4641 vty_out (vty
, " Thread Inactivity Timer %s%s",
4642 nbr
->t_inactivity
!= NULL
? "on" : "off", VTY_NEWLINE
);
4644 /* Show Database Description retransmission thread. */
4647 if (nbr
->t_db_desc
!= NULL
)
4648 json_object_string_add(json_sub
, "threadDatabaseDescriptionRetransmission", "on");
4651 vty_out (vty
, " Thread Database Description Retransmision %s%s",
4652 nbr
->t_db_desc
!= NULL
? "on" : "off", VTY_NEWLINE
);
4654 /* Show Link State Request Retransmission thread. */
4657 if (nbr
->t_ls_req
!= NULL
)
4658 json_object_string_add(json_sub
, "threadLinkStateRequestRetransmission", "on");
4661 vty_out (vty
, " Thread Link State Request Retransmission %s%s",
4662 nbr
->t_ls_req
!= NULL
? "on" : "off", VTY_NEWLINE
);
4664 /* Show Link State Update Retransmission thread. */
4667 if (nbr
->t_ls_upd
!= NULL
)
4668 json_object_string_add(json_sub
, "threadLinkStateUpdateRetransmission", "on");
4671 vty_out (vty
, " Thread Link State Update Retransmission %s%s%s",
4672 nbr
->t_ls_upd
!= NULL
? "on" : "off", VTY_NEWLINE
, VTY_NEWLINE
);
4676 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4677 json_object_object_add(json
, "noNbrId", json_sub
);
4679 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_sub
);
4682 ospf_bfd_show_info(vty
, nbr
->bfd_info
, json
, use_json
, 0);
4686 show_ip_ospf_neighbor_id_common (struct vty
*vty
, struct ospf
*ospf
,
4687 int arg_base
, const char **argv
, u_char use_json
)
4689 struct listnode
*node
;
4690 struct ospf_neighbor
*nbr
;
4691 struct ospf_interface
*oi
;
4692 struct in_addr router_id
;
4694 json_object
*json
= NULL
;
4697 json
= json_object_new_object();
4702 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4704 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4705 VTY_NEWLINE
, VTY_NEWLINE
);
4708 ret
= inet_aton (argv
[arg_base
], &router_id
);
4712 vty_out (vty
, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE
);
4716 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4718 if ((nbr
= ospf_nbr_lookup_by_routerid (oi
->nbrs
, &router_id
)))
4720 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4726 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4727 json_object_free(json
);
4730 vty_out (vty
, "%s", VTY_NEWLINE
);
4735 DEFUN (show_ip_ospf_neighbor_id
,
4736 show_ip_ospf_neighbor_id_cmd
,
4737 "show ip ospf neighbor A.B.C.D {json}",
4740 "OSPF information\n"
4743 "JavaScript Object Notation\n")
4746 u_char uj
= use_json(argc
, argv
);
4748 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4751 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 0, argv
, uj
);
4754 DEFUN (show_ip_ospf_instance_neighbor_id
,
4755 show_ip_ospf_instance_neighbor_id_cmd
,
4756 "show ip ospf <1-65535> neighbor A.B.C.D {json}",
4759 "OSPF information\n"
4763 "JavaScript Object Notation\n")
4766 u_short instance
= 0;
4767 u_char uj
= use_json(argc
, argv
);
4769 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
4770 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4773 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 1, argv
, uj
);
4777 show_ip_ospf_neighbor_detail_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4779 struct ospf_interface
*oi
;
4780 struct listnode
*node
;
4781 json_object
*json
= NULL
;
4784 json
= json_object_new_object();
4789 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4791 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4792 VTY_NEWLINE
, VTY_NEWLINE
);
4795 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4797 struct route_node
*rn
;
4798 struct ospf_neighbor
*nbr
;
4800 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4802 if ((nbr
= rn
->info
))
4804 if (nbr
!= oi
->nbr_self
)
4806 if (nbr
->state
!= NSM_Down
)
4808 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4817 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4818 json_object_free(json
);
4821 vty_out (vty
, "%s", VTY_NEWLINE
);
4826 DEFUN (show_ip_ospf_neighbor_detail
,
4827 show_ip_ospf_neighbor_detail_cmd
,
4828 "show ip ospf neighbor detail {json}",
4831 "OSPF information\n"
4833 "detail of all neighbors\n"
4834 "JavaScript Object Notation\n")
4837 u_char uj
= use_json(argc
, argv
);
4839 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4842 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4845 DEFUN (show_ip_ospf_instance_neighbor_detail
,
4846 show_ip_ospf_instance_neighbor_detail_cmd
,
4847 "show ip ospf <1-65535> neighbor detail {json}",
4850 "OSPF information\n"
4853 "detail of all neighbors\n"
4854 "JavaScript Object Notation\n")
4857 u_short instance
= 0;
4858 u_char uj
= use_json(argc
, argv
);
4860 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
4861 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
4864 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4868 show_ip_ospf_neighbor_detail_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4870 struct listnode
*node
;
4871 struct ospf_interface
*oi
;
4872 json_object
*json
= NULL
;
4875 json
= json_object_new_object();
4880 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4882 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4883 VTY_NEWLINE
, VTY_NEWLINE
);
4886 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4888 struct route_node
*rn
;
4889 struct ospf_neighbor
*nbr
;
4890 struct ospf_nbr_nbma
*nbr_nbma
;
4892 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4893 if ((nbr
= rn
->info
))
4894 if (nbr
!= oi
->nbr_self
)
4895 if (nbr
->state
!= NSM_Down
)
4896 show_ip_ospf_neighbor_detail_sub (vty
, oi
, rn
->info
, use_json
, json
);
4898 if (oi
->type
== OSPF_IFTYPE_NBMA
)
4900 struct listnode
*nd
;
4902 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nd
, nbr_nbma
))
4904 if (nbr_nbma
->nbr
== NULL
|| nbr_nbma
->nbr
->state
== NSM_Down
)
4905 show_ip_ospf_nbr_nbma_detail_sub (vty
, oi
, nbr_nbma
, use_json
, json
);
4912 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4913 json_object_free(json
);
4917 vty_out (vty
, "%s", VTY_NEWLINE
);
4923 DEFUN (show_ip_ospf_neighbor_detail_all
,
4924 show_ip_ospf_neighbor_detail_all_cmd
,
4925 "show ip ospf neighbor detail all {json}",
4928 "OSPF information\n"
4930 "detail of all neighbors\n"
4931 "include down status neighbor\n"
4932 "JavaScript Object Notation\n")
4935 u_char uj
= use_json(argc
, argv
);
4937 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4940 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4943 DEFUN (show_ip_ospf_instance_neighbor_detail_all
,
4944 show_ip_ospf_instance_neighbor_detail_all_cmd
,
4945 "show ip ospf <1-65535> neighbor detail all {json}",
4948 "OSPF information\n"
4951 "detail of all neighbors\n"
4952 "include down status neighbor\n"
4953 "JavaScript Object Notation\n")
4956 u_short instance
= 0;
4957 u_char uj
= use_json(argc
, argv
);
4959 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
4960 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4963 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4967 show_ip_ospf_neighbor_int_detail_common (struct vty
*vty
, struct ospf
*ospf
,
4968 int arg_base
, const char **argv
, u_char use_json
)
4970 struct ospf_interface
*oi
;
4971 struct interface
*ifp
;
4972 struct route_node
*rn
, *nrn
;
4973 struct ospf_neighbor
*nbr
;
4974 json_object
*json
= NULL
;
4977 json
= json_object_new_object();
4982 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4984 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4985 VTY_NEWLINE
, VTY_NEWLINE
);
4988 ifp
= if_lookup_by_name (argv
[arg_base
]);
4992 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
4996 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
4998 if ((oi
= rn
->info
))
5000 for (nrn
= route_top (oi
->nbrs
); nrn
; nrn
= route_next (nrn
))
5002 if ((nbr
= nrn
->info
))
5004 if (nbr
!= oi
->nbr_self
)
5006 if (nbr
->state
!= NSM_Down
)
5007 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
5016 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
5017 json_object_free(json
);
5020 vty_out (vty
, "%s", VTY_NEWLINE
);
5025 DEFUN (show_ip_ospf_neighbor_int_detail
,
5026 show_ip_ospf_neighbor_int_detail_cmd
,
5027 "show ip ospf neighbor IFNAME detail {json}",
5030 "OSPF information\n"
5033 "detail of all neighbors\n"
5034 "JavaScript Object Notation\n")
5037 u_char uj
= use_json(argc
, argv
);
5039 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5042 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 0, argv
, uj
);
5045 DEFUN (show_ip_ospf_instance_neighbor_int_detail
,
5046 show_ip_ospf_instance_neighbor_int_detail_cmd
,
5047 "show ip ospf <1-65535> neighbor IFNAME detail {json}",
5050 "OSPF information\n"
5054 "detail of all neighbors\n"
5055 "JavaScript Object Notation\n")
5058 u_short instance
= 0;
5059 u_char uj
= use_json(argc
, argv
);
5061 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
5062 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
5065 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 1, argv
, uj
);
5068 /* Show functions */
5070 show_lsa_summary (struct vty
*vty
, struct ospf_lsa
*lsa
, int self
)
5072 struct router_lsa
*rl
;
5073 struct summary_lsa
*sl
;
5074 struct as_external_lsa
*asel
;
5075 struct prefix_ipv4 p
;
5078 /* If self option is set, check LSA self flag. */
5079 if (self
== 0 || IS_LSA_SELF (lsa
))
5081 /* LSA common part show. */
5082 vty_out (vty
, "%-15s ", inet_ntoa (lsa
->data
->id
));
5083 vty_out (vty
, "%-15s %4d 0x%08lx 0x%04x",
5084 inet_ntoa (lsa
->data
->adv_router
), LS_AGE (lsa
),
5085 (u_long
)ntohl (lsa
->data
->ls_seqnum
), ntohs (lsa
->data
->checksum
));
5086 /* LSA specific part show. */
5087 switch (lsa
->data
->type
)
5089 case OSPF_ROUTER_LSA
:
5090 rl
= (struct router_lsa
*) lsa
->data
;
5091 vty_out (vty
, " %-d", ntohs (rl
->links
));
5093 case OSPF_SUMMARY_LSA
:
5094 sl
= (struct summary_lsa
*) lsa
->data
;
5097 p
.prefix
= sl
->header
.id
;
5098 p
.prefixlen
= ip_masklen (sl
->mask
);
5099 apply_mask_ipv4 (&p
);
5101 vty_out (vty
, " %s/%d", inet_ntoa (p
.prefix
), p
.prefixlen
);
5103 case OSPF_AS_EXTERNAL_LSA
:
5104 case OSPF_AS_NSSA_LSA
:
5105 asel
= (struct as_external_lsa
*) lsa
->data
;
5108 p
.prefix
= asel
->header
.id
;
5109 p
.prefixlen
= ip_masklen (asel
->mask
);
5110 apply_mask_ipv4 (&p
);
5112 vty_out (vty
, " %s %s/%d [0x%lx]",
5113 IS_EXTERNAL_METRIC (asel
->e
[0].tos
) ? "E2" : "E1",
5114 inet_ntoa (p
.prefix
), p
.prefixlen
,
5115 (u_long
)ntohl (asel
->e
[0].route_tag
));
5117 case OSPF_NETWORK_LSA
:
5118 case OSPF_ASBR_SUMMARY_LSA
:
5119 case OSPF_OPAQUE_LINK_LSA
:
5120 case OSPF_OPAQUE_AREA_LSA
:
5121 case OSPF_OPAQUE_AS_LSA
:
5125 vty_out (vty
, VTY_NEWLINE
);
5131 static const char *show_database_desc
[] =
5134 "Router Link States",
5136 "Summary Link States",
5137 "ASBR-Summary Link States",
5138 "AS External Link States",
5139 "Group Membership LSA",
5140 "NSSA-external Link States",
5142 "Link-Local Opaque-LSA",
5143 "Area-Local Opaque-LSA",
5144 "AS-external Opaque-LSA",
5147 static const char *show_database_header
[] =
5150 "Link ID ADV Router Age Seq# CkSum Link count",
5151 "Link ID ADV Router Age Seq# CkSum",
5152 "Link ID ADV Router Age Seq# CkSum Route",
5153 "Link ID ADV Router Age Seq# CkSum",
5154 "Link ID ADV Router Age Seq# CkSum Route",
5155 " --- header for Group Member ----",
5156 "Link ID ADV Router Age Seq# CkSum Route",
5158 "Opaque-Type/Id ADV Router Age Seq# CkSum",
5159 "Opaque-Type/Id ADV Router Age Seq# CkSum",
5160 "Opaque-Type/Id ADV Router Age Seq# CkSum",
5164 show_ip_ospf_database_header (struct vty
*vty
, struct ospf_lsa
*lsa
)
5166 struct router_lsa
*rlsa
= (struct router_lsa
*) lsa
->data
;
5168 vty_out (vty
, " LS age: %d%s", LS_AGE (lsa
), VTY_NEWLINE
);
5169 vty_out (vty
, " Options: 0x%-2x : %s%s",
5171 ospf_options_dump(lsa
->data
->options
),
5173 vty_out (vty
, " LS Flags: 0x%-2x %s%s",
5175 ((lsa
->flags
& OSPF_LSA_LOCAL_XLT
) ? "(Translated from Type-7)" : ""),
5178 if (lsa
->data
->type
== OSPF_ROUTER_LSA
)
5180 vty_out (vty
, " Flags: 0x%x" , rlsa
->flags
);
5183 vty_out (vty
, " :%s%s%s%s",
5184 IS_ROUTER_LSA_BORDER (rlsa
) ? " ABR" : "",
5185 IS_ROUTER_LSA_EXTERNAL (rlsa
) ? " ASBR" : "",
5186 IS_ROUTER_LSA_VIRTUAL (rlsa
) ? " VL-endpoint" : "",
5187 IS_ROUTER_LSA_SHORTCUT (rlsa
) ? " Shortcut" : "");
5189 vty_out (vty
, "%s", VTY_NEWLINE
);
5191 vty_out (vty
, " LS Type: %s%s",
5192 LOOKUP (ospf_lsa_type_msg
, lsa
->data
->type
), VTY_NEWLINE
);
5193 vty_out (vty
, " Link State ID: %s %s%s", inet_ntoa (lsa
->data
->id
),
5194 LOOKUP (ospf_link_state_id_type_msg
, lsa
->data
->type
), VTY_NEWLINE
);
5195 vty_out (vty
, " Advertising Router: %s%s",
5196 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
5197 vty_out (vty
, " LS Seq Number: %08lx%s", (u_long
)ntohl (lsa
->data
->ls_seqnum
),
5199 vty_out (vty
, " Checksum: 0x%04x%s", ntohs (lsa
->data
->checksum
),
5201 vty_out (vty
, " Length: %d%s", ntohs (lsa
->data
->length
), VTY_NEWLINE
);
5204 const char *link_type_desc
[] =
5207 "another Router (point-to-point)",
5208 "a Transit Network",
5213 const char *link_id_desc
[] =
5216 "Neighboring Router ID",
5217 "Designated Router address",
5219 "Neighboring Router ID",
5222 const char *link_data_desc
[] =
5225 "Router Interface address",
5226 "Router Interface address",
5228 "Router Interface address",
5231 /* Show router-LSA each Link information. */
5233 show_ip_ospf_database_router_links (struct vty
*vty
,
5234 struct router_lsa
*rl
)
5239 len
= ntohs (rl
->header
.length
) - 4;
5240 for (i
= 0; i
< ntohs (rl
->links
) && len
> 0; len
-= 12, i
++)
5242 type
= rl
->link
[i
].type
;
5244 vty_out (vty
, " Link connected to: %s%s",
5245 link_type_desc
[type
], VTY_NEWLINE
);
5246 vty_out (vty
, " (Link ID) %s: %s%s", link_id_desc
[type
],
5247 inet_ntoa (rl
->link
[i
].link_id
), VTY_NEWLINE
);
5248 vty_out (vty
, " (Link Data) %s: %s%s", link_data_desc
[type
],
5249 inet_ntoa (rl
->link
[i
].link_data
), VTY_NEWLINE
);
5250 vty_out (vty
, " Number of TOS metrics: 0%s", VTY_NEWLINE
);
5251 vty_out (vty
, " TOS 0 Metric: %d%s",
5252 ntohs (rl
->link
[i
].metric
), VTY_NEWLINE
);
5253 vty_out (vty
, "%s", VTY_NEWLINE
);
5257 /* Show router-LSA detail information. */
5259 show_router_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5263 struct router_lsa
*rl
= (struct router_lsa
*) lsa
->data
;
5265 show_ip_ospf_database_header (vty
, lsa
);
5267 vty_out (vty
, " Number of Links: %d%s%s", ntohs (rl
->links
),
5268 VTY_NEWLINE
, VTY_NEWLINE
);
5270 show_ip_ospf_database_router_links (vty
, rl
);
5271 vty_out (vty
, "%s", VTY_NEWLINE
);
5277 /* Show network-LSA detail information. */
5279 show_network_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5285 struct network_lsa
*nl
= (struct network_lsa
*) lsa
->data
;
5287 show_ip_ospf_database_header (vty
, lsa
);
5289 vty_out (vty
, " Network Mask: /%d%s",
5290 ip_masklen (nl
->mask
), VTY_NEWLINE
);
5292 length
= ntohs (lsa
->data
->length
) - OSPF_LSA_HEADER_SIZE
- 4;
5294 for (i
= 0; length
> 0; i
++, length
-= 4)
5295 vty_out (vty
, " Attached Router: %s%s",
5296 inet_ntoa (nl
->routers
[i
]), VTY_NEWLINE
);
5298 vty_out (vty
, "%s", VTY_NEWLINE
);
5304 /* Show summary-LSA detail information. */
5306 show_summary_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5310 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
5312 show_ip_ospf_database_header (vty
, lsa
);
5314 vty_out (vty
, " Network Mask: /%d%s", ip_masklen (sl
->mask
),
5316 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
5318 vty_out (vty
, "%s", VTY_NEWLINE
);
5324 /* Show summary-ASBR-LSA detail information. */
5326 show_summary_asbr_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5330 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
5332 show_ip_ospf_database_header (vty
, lsa
);
5334 vty_out (vty
, " Network Mask: /%d%s",
5335 ip_masklen (sl
->mask
), VTY_NEWLINE
);
5336 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
5338 vty_out (vty
, "%s", VTY_NEWLINE
);
5344 /* Show AS-external-LSA detail information. */
5346 show_as_external_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5350 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5352 show_ip_ospf_database_header (vty
, lsa
);
5354 vty_out (vty
, " Network Mask: /%d%s",
5355 ip_masklen (al
->mask
), VTY_NEWLINE
);
5356 vty_out (vty
, " Metric Type: %s%s",
5357 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5358 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
5359 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
5360 vty_out (vty
, " Metric: %d%s",
5361 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
5362 vty_out (vty
, " Forward Address: %s%s",
5363 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
5365 vty_out (vty
, " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5366 (route_tag_t
)ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
5374 show_as_external_lsa_stdvty (struct ospf_lsa
*lsa
)
5376 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5378 /* show_ip_ospf_database_header (vty, lsa); */
5380 zlog_debug( " Network Mask: /%d%s",
5381 ip_masklen (al
->mask
), "\n");
5382 zlog_debug( " Metric Type: %s%s",
5383 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5384 "2 (Larger than any link state path)" : "1", "\n");
5385 zlog_debug( " TOS: 0%s", "\n");
5386 zlog_debug( " Metric: %d%s",
5387 GET_METRIC (al
->e
[0].metric
), "\n");
5388 zlog_debug( " Forward Address: %s%s",
5389 inet_ntoa (al
->e
[0].fwd_addr
), "\n");
5391 zlog_debug( " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5392 (route_tag_t
)ntohl (al
->e
[0].route_tag
), "\n", "\n");
5398 /* Show AS-NSSA-LSA detail information. */
5400 show_as_nssa_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5404 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5406 show_ip_ospf_database_header (vty
, lsa
);
5408 vty_out (vty
, " Network Mask: /%d%s",
5409 ip_masklen (al
->mask
), VTY_NEWLINE
);
5410 vty_out (vty
, " Metric Type: %s%s",
5411 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5412 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
5413 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
5414 vty_out (vty
, " Metric: %d%s",
5415 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
5416 vty_out (vty
, " NSSA: Forward Address: %s%s",
5417 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
5419 vty_out (vty
, " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5420 (route_tag_t
)ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
5427 show_func_dummy (struct vty
*vty
, struct ospf_lsa
*lsa
)
5433 show_opaque_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5437 show_ip_ospf_database_header (vty
, lsa
);
5438 show_opaque_info_detail (vty
, lsa
);
5440 vty_out (vty
, "%s", VTY_NEWLINE
);
5445 int (*show_function
[])(struct vty
*, struct ospf_lsa
*) =
5448 show_router_lsa_detail
,
5449 show_network_lsa_detail
,
5450 show_summary_lsa_detail
,
5451 show_summary_asbr_lsa_detail
,
5452 show_as_external_lsa_detail
,
5454 show_as_nssa_lsa_detail
, /* almost same as external */
5456 show_opaque_lsa_detail
,
5457 show_opaque_lsa_detail
,
5458 show_opaque_lsa_detail
,
5462 show_lsa_prefix_set (struct vty
*vty
, struct prefix_ls
*lp
, struct in_addr
*id
,
5463 struct in_addr
*adv_router
)
5465 memset (lp
, 0, sizeof (struct prefix_ls
));
5469 else if (adv_router
== NULL
)
5478 lp
->adv_router
= *adv_router
;
5483 show_lsa_detail_proc (struct vty
*vty
, struct route_table
*rt
,
5484 struct in_addr
*id
, struct in_addr
*adv_router
)
5486 struct prefix_ls lp
;
5487 struct route_node
*rn
, *start
;
5488 struct ospf_lsa
*lsa
;
5490 show_lsa_prefix_set (vty
, &lp
, id
, adv_router
);
5491 start
= route_node_get (rt
, (struct prefix
*) &lp
);
5494 route_lock_node (start
);
5495 for (rn
= start
; rn
; rn
= route_next_until (rn
, start
))
5496 if ((lsa
= rn
->info
))
5498 if (show_function
[lsa
->data
->type
] != NULL
)
5499 show_function
[lsa
->data
->type
] (vty
, lsa
);
5501 route_unlock_node (start
);
5505 /* Show detail LSA information
5506 -- if id is NULL then show all LSAs. */
5508 show_lsa_detail (struct vty
*vty
, struct ospf
*ospf
, int type
,
5509 struct in_addr
*id
, struct in_addr
*adv_router
)
5511 struct listnode
*node
;
5512 struct ospf_area
*area
;
5516 case OSPF_AS_EXTERNAL_LSA
:
5517 case OSPF_OPAQUE_AS_LSA
:
5518 vty_out (vty
, " %s %s%s",
5519 show_database_desc
[type
],
5520 VTY_NEWLINE
, VTY_NEWLINE
);
5521 show_lsa_detail_proc (vty
, AS_LSDB (ospf
, type
), id
, adv_router
);
5524 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5526 vty_out (vty
, "%s %s (Area %s)%s%s",
5527 VTY_NEWLINE
, show_database_desc
[type
],
5528 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5529 show_lsa_detail_proc (vty
, AREA_LSDB (area
, type
), id
, adv_router
);
5536 show_lsa_detail_adv_router_proc (struct vty
*vty
, struct route_table
*rt
,
5537 struct in_addr
*adv_router
)
5539 struct route_node
*rn
;
5540 struct ospf_lsa
*lsa
;
5542 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
5543 if ((lsa
= rn
->info
))
5544 if (IPV4_ADDR_SAME (adv_router
, &lsa
->data
->adv_router
))
5546 if (CHECK_FLAG (lsa
->flags
, OSPF_LSA_LOCAL_XLT
))
5548 if (show_function
[lsa
->data
->type
] != NULL
)
5549 show_function
[lsa
->data
->type
] (vty
, lsa
);
5553 /* Show detail LSA information. */
5555 show_lsa_detail_adv_router (struct vty
*vty
, struct ospf
*ospf
, int type
,
5556 struct in_addr
*adv_router
)
5558 struct listnode
*node
;
5559 struct ospf_area
*area
;
5563 case OSPF_AS_EXTERNAL_LSA
:
5564 case OSPF_OPAQUE_AS_LSA
:
5565 vty_out (vty
, " %s %s%s",
5566 show_database_desc
[type
],
5567 VTY_NEWLINE
, VTY_NEWLINE
);
5568 show_lsa_detail_adv_router_proc (vty
, AS_LSDB (ospf
, type
),
5572 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5574 vty_out (vty
, "%s %s (Area %s)%s%s",
5575 VTY_NEWLINE
, show_database_desc
[type
],
5576 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5577 show_lsa_detail_adv_router_proc (vty
, AREA_LSDB (area
, type
),
5585 show_ip_ospf_database_summary (struct vty
*vty
, struct ospf
*ospf
, int self
)
5587 struct ospf_lsa
*lsa
;
5588 struct route_node
*rn
;
5589 struct ospf_area
*area
;
5590 struct listnode
*node
;
5593 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5595 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5599 case OSPF_AS_EXTERNAL_LSA
:
5600 case OSPF_OPAQUE_AS_LSA
:
5605 if (ospf_lsdb_count_self (area
->lsdb
, type
) > 0 ||
5606 (!self
&& ospf_lsdb_count (area
->lsdb
, type
) > 0))
5608 vty_out (vty
, " %s (Area %s)%s%s",
5609 show_database_desc
[type
],
5610 ospf_area_desc_string (area
),
5611 VTY_NEWLINE
, VTY_NEWLINE
);
5612 vty_out (vty
, "%s%s", show_database_header
[type
], VTY_NEWLINE
);
5614 LSDB_LOOP (AREA_LSDB (area
, type
), rn
, lsa
)
5615 show_lsa_summary (vty
, lsa
, self
);
5617 vty_out (vty
, "%s", VTY_NEWLINE
);
5622 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5626 case OSPF_AS_EXTERNAL_LSA
:
5627 case OSPF_OPAQUE_AS_LSA
:
5632 if (ospf_lsdb_count_self (ospf
->lsdb
, type
) ||
5633 (!self
&& ospf_lsdb_count (ospf
->lsdb
, type
)))
5635 vty_out (vty
, " %s%s%s",
5636 show_database_desc
[type
],
5637 VTY_NEWLINE
, VTY_NEWLINE
);
5638 vty_out (vty
, "%s%s", show_database_header
[type
],
5641 LSDB_LOOP (AS_LSDB (ospf
, type
), rn
, lsa
)
5642 show_lsa_summary (vty
, lsa
, self
);
5644 vty_out (vty
, "%s", VTY_NEWLINE
);
5648 vty_out (vty
, "%s", VTY_NEWLINE
);
5652 show_ip_ospf_database_maxage (struct vty
*vty
, struct ospf
*ospf
)
5654 struct route_node
*rn
;
5656 vty_out (vty
, "%s MaxAge Link States:%s%s",
5657 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
5659 for (rn
= route_top (ospf
->maxage_lsa
); rn
; rn
= route_next (rn
))
5661 struct ospf_lsa
*lsa
;
5663 if ((lsa
= rn
->info
) != NULL
)
5665 vty_out (vty
, "Link type: %d%s", lsa
->data
->type
, VTY_NEWLINE
);
5666 vty_out (vty
, "Link State ID: %s%s",
5667 inet_ntoa (lsa
->data
->id
), VTY_NEWLINE
);
5668 vty_out (vty
, "Advertising Router: %s%s",
5669 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
5670 vty_out (vty
, "LSA lock count: %d%s", lsa
->lock
, VTY_NEWLINE
);
5671 vty_out (vty
, "%s", VTY_NEWLINE
);
5676 #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
5677 #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
5679 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
5680 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
5681 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
5682 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
5684 #define OSPF_LSA_TYPES_CMD_STR \
5685 "asbr-summary|external|network|router|summary" \
5686 OSPF_LSA_TYPE_NSSA_CMD_STR \
5687 OSPF_LSA_TYPE_OPAQUE_CMD_STR
5689 #define OSPF_LSA_TYPES_DESC \
5690 "ASBR summary link states\n" \
5691 "External link states\n" \
5692 "Network link states\n" \
5693 "Router link states\n" \
5694 "Network summary link states\n" \
5695 OSPF_LSA_TYPE_NSSA_DESC \
5696 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
5697 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
5698 OSPF_LSA_TYPE_OPAQUE_AS_DESC
5701 show_ip_ospf_database_common (struct vty
*vty
, struct ospf
*ospf
,
5702 int arg_base
, int argc
, const char **argv
)
5705 struct in_addr id
, adv_router
;
5708 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5711 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5712 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5715 if (argc
== arg_base
+ 0)
5717 show_ip_ospf_database_summary (vty
, ospf
, 0);
5721 /* Set database type to show. */
5722 if (strncmp (argv
[arg_base
+ 0], "r", 1) == 0)
5723 type
= OSPF_ROUTER_LSA
;
5724 else if (strncmp (argv
[arg_base
+ 0], "ne", 2) == 0)
5725 type
= OSPF_NETWORK_LSA
;
5726 else if (strncmp (argv
[arg_base
+ 0], "ns", 2) == 0)
5727 type
= OSPF_AS_NSSA_LSA
;
5728 else if (strncmp (argv
[arg_base
+ 0], "su", 2) == 0)
5729 type
= OSPF_SUMMARY_LSA
;
5730 else if (strncmp (argv
[arg_base
+ 0], "a", 1) == 0)
5731 type
= OSPF_ASBR_SUMMARY_LSA
;
5732 else if (strncmp (argv
[arg_base
+ 0], "e", 1) == 0)
5733 type
= OSPF_AS_EXTERNAL_LSA
;
5734 else if (strncmp (argv
[arg_base
+ 0], "se", 2) == 0)
5736 show_ip_ospf_database_summary (vty
, ospf
, 1);
5739 else if (strncmp (argv
[arg_base
+ 0], "m", 1) == 0)
5741 show_ip_ospf_database_maxage (vty
, ospf
);
5744 else if (strncmp (argv
[arg_base
+ 0], "opaque-l", 8) == 0)
5745 type
= OSPF_OPAQUE_LINK_LSA
;
5746 else if (strncmp (argv
[arg_base
+ 0], "opaque-ar", 9) == 0)
5747 type
= OSPF_OPAQUE_AREA_LSA
;
5748 else if (strncmp (argv
[arg_base
+ 0], "opaque-as", 9) == 0)
5749 type
= OSPF_OPAQUE_AS_LSA
;
5753 /* `show ip ospf database LSA'. */
5754 if (argc
== arg_base
+ 1)
5755 show_lsa_detail (vty
, ospf
, type
, NULL
, NULL
);
5756 else if (argc
>= arg_base
+ 2)
5758 ret
= inet_aton (argv
[arg_base
+ 1], &id
);
5762 /* `show ip ospf database LSA ID'. */
5763 if (argc
== arg_base
+ 2)
5764 show_lsa_detail (vty
, ospf
, type
, &id
, NULL
);
5765 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
5766 else if (argc
== arg_base
+ 3)
5768 if (strncmp (argv
[arg_base
+ 2], "s", 1) == 0)
5769 adv_router
= ospf
->router_id
;
5772 ret
= inet_aton (argv
[arg_base
+ 2], &adv_router
);
5776 show_lsa_detail (vty
, ospf
, type
, &id
, &adv_router
);
5783 DEFUN (show_ip_ospf_database
,
5784 show_ip_ospf_database_cmd
,
5785 "show ip ospf database",
5788 "OSPF information\n"
5789 "Database summary\n")
5793 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5796 return (show_ip_ospf_database_common(vty
, ospf
, 0, argc
, argv
));
5799 ALIAS (show_ip_ospf_database
,
5800 show_ip_ospf_database_type_cmd
,
5801 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR
"|max-age|self-originate)",
5804 "OSPF information\n"
5805 "Database summary\n"
5807 "LSAs in MaxAge list\n"
5808 "Self-originated link states\n")
5810 ALIAS (show_ip_ospf_database
,
5811 show_ip_ospf_database_type_id_cmd
,
5812 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR
") A.B.C.D",
5815 "OSPF information\n"
5816 "Database summary\n"
5818 "Link State ID (as an IP address)\n")
5820 ALIAS (show_ip_ospf_database
,
5821 show_ip_ospf_database_type_id_adv_router_cmd
,
5822 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR
") A.B.C.D adv-router A.B.C.D",
5825 "OSPF information\n"
5826 "Database summary\n"
5828 "Link State ID (as an IP address)\n"
5829 "Advertising Router link states\n"
5830 "Advertising Router (as an IP address)\n")
5832 ALIAS (show_ip_ospf_database
,
5833 show_ip_ospf_database_type_id_self_cmd
,
5834 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR
") A.B.C.D (self-originate|)",
5837 "OSPF information\n"
5838 "Database summary\n"
5840 "Link State ID (as an IP address)\n"
5841 "Self-originated link states\n"
5844 DEFUN (show_ip_ospf_instance_database
,
5845 show_ip_ospf_instance_database_cmd
,
5846 "show ip ospf <1-65535> database",
5849 "OSPF information\n"
5851 "Database summary\n")
5854 u_short instance
= 0;
5856 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
5858 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5861 return (show_ip_ospf_database_common(vty
, ospf
, 1, argc
, argv
));
5864 ALIAS (show_ip_ospf_instance_database
,
5865 show_ip_ospf_instance_database_type_cmd
,
5866 "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR
"|max-age|self-originate)",
5869 "OSPF information\n"
5871 "Database summary\n"
5873 "LSAs in MaxAge list\n"
5874 "Self-originated link states\n")
5876 ALIAS (show_ip_ospf_instance_database
,
5877 show_ip_ospf_instance_database_type_id_cmd
,
5878 "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR
") A.B.C.D",
5881 "OSPF information\n"
5883 "Database summary\n"
5885 "Link State ID (as an IP address)\n")
5887 ALIAS (show_ip_ospf_instance_database
,
5888 show_ip_ospf_instance_database_type_id_adv_router_cmd
,
5889 "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR
") A.B.C.D adv-router A.B.C.D",
5892 "OSPF information\n"
5894 "Database summary\n"
5896 "Link State ID (as an IP address)\n"
5897 "Advertising Router link states\n"
5898 "Advertising Router (as an IP address)\n")
5900 ALIAS (show_ip_ospf_instance_database
,
5901 show_ip_ospf_instance_database_type_id_self_cmd
,
5902 "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR
") A.B.C.D (self-originate|)",
5905 "OSPF information\n"
5907 "Database summary\n"
5909 "Link State ID (as an IP address)\n"
5910 "Self-originated link states\n"
5915 show_ip_ospf_database_type_adv_router_common (struct vty
*vty
, struct ospf
*ospf
,
5916 int arg_base
, int argc
, const char **argv
)
5919 struct in_addr adv_router
;
5922 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5925 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5926 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5928 if (argc
!= arg_base
+ 2)
5931 /* Set database type to show. */
5932 if (strncmp (argv
[arg_base
+ 0], "r", 1) == 0)
5933 type
= OSPF_ROUTER_LSA
;
5934 else if (strncmp (argv
[arg_base
+ 0], "ne", 2) == 0)
5935 type
= OSPF_NETWORK_LSA
;
5936 else if (strncmp (argv
[arg_base
+ 0], "ns", 2) == 0)
5937 type
= OSPF_AS_NSSA_LSA
;
5938 else if (strncmp (argv
[arg_base
+ 0], "s", 1) == 0)
5939 type
= OSPF_SUMMARY_LSA
;
5940 else if (strncmp (argv
[arg_base
+ 0], "a", 1) == 0)
5941 type
= OSPF_ASBR_SUMMARY_LSA
;
5942 else if (strncmp (argv
[arg_base
+ 0], "e", 1) == 0)
5943 type
= OSPF_AS_EXTERNAL_LSA
;
5944 else if (strncmp (argv
[arg_base
+ 0], "opaque-l", 8) == 0)
5945 type
= OSPF_OPAQUE_LINK_LSA
;
5946 else if (strncmp (argv
[arg_base
+ 0], "opaque-ar", 9) == 0)
5947 type
= OSPF_OPAQUE_AREA_LSA
;
5948 else if (strncmp (argv
[arg_base
+ 0], "opaque-as", 9) == 0)
5949 type
= OSPF_OPAQUE_AS_LSA
;
5953 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
5954 if (strncmp (argv
[arg_base
+ 1], "s", 1) == 0)
5955 adv_router
= ospf
->router_id
;
5958 ret
= inet_aton (argv
[arg_base
+ 1], &adv_router
);
5963 show_lsa_detail_adv_router (vty
, ospf
, type
, &adv_router
);
5968 DEFUN (show_ip_ospf_database_type_adv_router
,
5969 show_ip_ospf_database_type_adv_router_cmd
,
5970 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR
") adv-router A.B.C.D",
5973 "OSPF information\n"
5974 "Database summary\n"
5976 "Advertising Router link states\n"
5977 "Advertising Router (as an IP address)\n")
5981 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5984 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 0, argc
, argv
));
5987 ALIAS (show_ip_ospf_database_type_adv_router
,
5988 show_ip_ospf_database_type_self_cmd
,
5989 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR
") (self-originate|)",
5992 "OSPF information\n"
5993 "Database summary\n"
5995 "Self-originated link states\n")
5997 DEFUN (show_ip_ospf_instance_database_type_adv_router
,
5998 show_ip_ospf_instance_database_type_adv_router_cmd
,
5999 "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR
") adv-router A.B.C.D",
6002 "OSPF information\n"
6004 "Database summary\n"
6006 "Advertising Router link states\n"
6007 "Advertising Router (as an IP address)\n")
6010 u_short instance
= 0;
6012 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
6014 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
6017 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 1, argc
, argv
));
6020 ALIAS (show_ip_ospf_instance_database_type_adv_router
,
6021 show_ip_ospf_instance_database_type_self_cmd
,
6022 "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR
") (self-originate|)",
6025 "OSPF information\n"
6027 "Database summary\n"
6029 "Self-originated link states\n")
6031 DEFUN (ip_ospf_authentication_args
,
6032 ip_ospf_authentication_args_addr_cmd
,
6033 "ip ospf authentication (null|message-digest) A.B.C.D",
6035 "OSPF interface commands\n"
6036 "Enable authentication on this interface\n"
6037 "Use null authentication\n"
6038 "Use message-digest authentication\n"
6039 "Address of interface")
6041 struct interface
*ifp
;
6042 struct in_addr addr
;
6044 struct ospf_if_params
*params
;
6047 params
= IF_DEF_PARAMS (ifp
);
6051 ret
= inet_aton(argv
[1], &addr
);
6054 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6059 params
= ospf_get_if_params (ifp
, addr
);
6060 ospf_if_update_params (ifp
, addr
);
6063 /* Handle null authentication */
6064 if ( argv
[0][0] == 'n' )
6066 SET_IF_PARAM (params
, auth_type
);
6067 params
->auth_type
= OSPF_AUTH_NULL
;
6071 /* Handle message-digest authentication */
6072 if ( argv
[0][0] == 'm' )
6074 SET_IF_PARAM (params
, auth_type
);
6075 params
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
6079 vty_out (vty
, "You shouldn't get here!%s", VTY_NEWLINE
);
6083 ALIAS (ip_ospf_authentication_args
,
6084 ip_ospf_authentication_args_cmd
,
6085 "ip ospf authentication (null|message-digest)",
6087 "OSPF interface commands\n"
6088 "Enable authentication on this interface\n"
6089 "Use null authentication\n"
6090 "Use message-digest authentication\n")
6092 DEFUN (ip_ospf_authentication
,
6093 ip_ospf_authentication_addr_cmd
,
6094 "ip ospf authentication A.B.C.D",
6096 "OSPF interface commands\n"
6097 "Enable authentication on this interface\n"
6098 "Address of interface")
6100 struct interface
*ifp
;
6101 struct in_addr addr
;
6103 struct ospf_if_params
*params
;
6106 params
= IF_DEF_PARAMS (ifp
);
6110 ret
= inet_aton(argv
[0], &addr
);
6113 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6118 params
= ospf_get_if_params (ifp
, addr
);
6119 ospf_if_update_params (ifp
, addr
);
6122 SET_IF_PARAM (params
, auth_type
);
6123 params
->auth_type
= OSPF_AUTH_SIMPLE
;
6128 ALIAS (ip_ospf_authentication
,
6129 ip_ospf_authentication_cmd
,
6130 "ip ospf authentication",
6132 "OSPF interface commands\n"
6133 "Enable authentication on this interface\n")
6135 DEFUN (no_ip_ospf_authentication_args
,
6136 no_ip_ospf_authentication_args_addr_cmd
,
6137 "no ip ospf authentication (null|message-digest) A.B.C.D",
6140 "OSPF interface commands\n"
6141 "Enable authentication on this interface\n"
6142 "Use null authentication\n"
6143 "Use message-digest authentication\n"
6144 "Address of interface")
6146 struct interface
*ifp
;
6147 struct in_addr addr
;
6149 struct ospf_if_params
*params
;
6150 struct route_node
*rn
;
6154 params
= IF_DEF_PARAMS (ifp
);
6158 ret
= inet_aton(argv
[1], &addr
);
6161 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6166 params
= ospf_lookup_if_params (ifp
, addr
);
6169 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
6172 params
->auth_type
= OSPF_AUTH_NOTSET
;
6173 UNSET_IF_PARAM (params
, auth_type
);
6174 if (params
!= IF_DEF_PARAMS (ifp
))
6176 ospf_free_if_params (ifp
, addr
);
6177 ospf_if_update_params (ifp
, addr
);
6182 if ( argv
[0][0] == 'n' )
6184 auth_type
= OSPF_AUTH_NULL
;
6186 else if ( argv
[0][0] == 'm' )
6188 auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
6192 vty_out (vty
, "Unexpected input encountered%s", VTY_NEWLINE
);
6196 * Here we have a case where the user has entered
6197 * 'no ip ospf authentication (null | message_digest )'
6198 * we need to find if we have any ip addresses underneath it that
6199 * correspond to the associated type.
6201 if (params
->auth_type
== auth_type
)
6203 params
->auth_type
= OSPF_AUTH_NOTSET
;
6204 UNSET_IF_PARAM (params
, auth_type
);
6207 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
6209 if ((params
= rn
->info
))
6211 if (params
->auth_type
== auth_type
)
6213 params
->auth_type
= OSPF_AUTH_NOTSET
;
6214 UNSET_IF_PARAM (params
, auth_type
);
6215 if (params
!= IF_DEF_PARAMS (ifp
))
6217 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
6218 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
6228 ALIAS (no_ip_ospf_authentication_args
,
6229 no_ip_ospf_authentication_args_cmd
,
6230 "no ip ospf authentication (null|message-digest)",
6233 "OSPF interface commands\n"
6234 "Enable authentication on this interface\n"
6235 "Use null authentication\n"
6236 "Use message-digest authentication\n")
6238 DEFUN (no_ip_ospf_authentication
,
6239 no_ip_ospf_authentication_addr_cmd
,
6240 "no ip ospf authentication A.B.C.D",
6243 "OSPF interface commands\n"
6244 "Enable authentication on this interface\n"
6245 "Address of interface")
6247 struct interface
*ifp
;
6248 struct in_addr addr
;
6250 struct ospf_if_params
*params
;
6251 struct route_node
*rn
;
6254 params
= IF_DEF_PARAMS (ifp
);
6258 ret
= inet_aton(argv
[0], &addr
);
6261 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6266 params
= ospf_lookup_if_params (ifp
, addr
);
6269 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
6273 params
->auth_type
= OSPF_AUTH_NOTSET
;
6274 UNSET_IF_PARAM (params
, auth_type
);
6275 if (params
!= IF_DEF_PARAMS (ifp
))
6277 ospf_free_if_params (ifp
, addr
);
6278 ospf_if_update_params (ifp
, addr
);
6284 * When a user enters 'no ip ospf authentication'
6285 * We should remove all authentication types from
6288 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
6289 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
6290 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
6292 params
->auth_type
= OSPF_AUTH_NOTSET
;
6293 UNSET_IF_PARAM (params
, auth_type
);
6296 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
6298 if ((params
= rn
->info
))
6301 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
6302 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
6303 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
6305 params
->auth_type
= OSPF_AUTH_NOTSET
;
6306 UNSET_IF_PARAM (params
, auth_type
);
6307 if (params
!= IF_DEF_PARAMS (ifp
))
6309 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
6310 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
6320 ALIAS (no_ip_ospf_authentication
,
6321 no_ip_ospf_authentication_cmd
,
6322 "no ip ospf authentication",
6325 "OSPF interface commands\n"
6326 "Enable authentication on this interface\n")
6328 DEFUN (ip_ospf_authentication_key
,
6329 ip_ospf_authentication_key_addr_cmd
,
6330 "ip ospf authentication-key AUTH_KEY A.B.C.D",
6332 "OSPF interface commands\n"
6333 "Authentication password (key)\n"
6334 "The OSPF password (key)\n"
6335 "Address of interface")
6337 struct interface
*ifp
;
6338 struct in_addr addr
;
6340 struct ospf_if_params
*params
;
6343 params
= IF_DEF_PARAMS (ifp
);
6347 ret
= inet_aton(argv
[1], &addr
);
6350 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6355 params
= ospf_get_if_params (ifp
, addr
);
6356 ospf_if_update_params (ifp
, addr
);
6359 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
6360 strncpy ((char *) params
->auth_simple
, argv
[0], OSPF_AUTH_SIMPLE_SIZE
);
6361 SET_IF_PARAM (params
, auth_simple
);
6366 ALIAS (ip_ospf_authentication_key
,
6367 ip_ospf_authentication_key_cmd
,
6368 "ip ospf authentication-key AUTH_KEY",
6370 "OSPF interface commands\n"
6371 "Authentication password (key)\n"
6372 "The OSPF password (key)")
6374 ALIAS_HIDDEN (ip_ospf_authentication_key
,
6375 ospf_authentication_key_cmd
,
6376 "ospf authentication-key AUTH_KEY",
6377 "OSPF interface commands\n"
6378 "Authentication password (key)\n"
6379 "The OSPF password (key)")
6381 DEFUN (no_ip_ospf_authentication_key
,
6382 no_ip_ospf_authentication_key_authkey_addr_cmd
,
6383 "no ip ospf authentication-key AUTH_KEY A.B.C.D",
6386 "OSPF interface commands\n"
6387 "Authentication password (key)\n"
6388 "The OSPF password (key)")
6390 struct interface
*ifp
;
6391 struct in_addr addr
;
6392 struct ospf_if_params
*params
;
6396 params
= IF_DEF_PARAMS (ifp
);
6400 ret
= inet_aton(argv
[1], &addr
);
6403 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6408 params
= ospf_lookup_if_params (ifp
, addr
);
6413 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
);
6414 UNSET_IF_PARAM (params
, auth_simple
);
6416 if (params
!= IF_DEF_PARAMS (ifp
))
6418 ospf_free_if_params (ifp
, addr
);
6419 ospf_if_update_params (ifp
, addr
);
6425 ALIAS (no_ip_ospf_authentication_key
,
6426 no_ip_ospf_authentication_key_authkey_cmd
,
6427 "no ip ospf authentication-key AUTH_KEY",
6430 "OSPF interface commands\n"
6431 "Authentication password (key)\n")
6433 ALIAS (no_ip_ospf_authentication_key
,
6434 no_ip_ospf_authentication_key_cmd
,
6435 "no ip ospf authentication-key",
6438 "OSPF interface commands\n"
6439 "Authentication password (key)\n")
6441 ALIAS (no_ip_ospf_authentication_key
,
6442 no_ospf_authentication_key_cmd
,
6443 "no ospf authentication-key",
6445 "OSPF interface commands\n"
6446 "Authentication password (key)\n")
6448 ALIAS (no_ip_ospf_authentication_key
,
6449 no_ospf_authentication_key_authkey_cmd
,
6450 "no ospf authentication-key AUTH_KEY",
6452 "OSPF interface commands\n"
6453 "Authentication password (key)\n"
6454 "The OSPF password (key)\n")
6456 ALIAS (no_ip_ospf_authentication_key
,
6457 no_ospf_authentication_key_authkey_ip_cmd
,
6458 "no ospf authentication-key AUTH_KEY A.B.C.D",
6460 "OSPF interface commands\n"
6461 "Authentication password (key)\n"
6462 "The OSPF password (key)\n"
6463 "Address of interface")
6465 DEFUN (ip_ospf_message_digest_key
,
6466 ip_ospf_message_digest_key_addr_cmd
,
6467 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
6469 "OSPF interface commands\n"
6470 "Message digest authentication password (key)\n"
6472 "Use MD5 algorithm\n"
6473 "The OSPF password (key)"
6474 "Address of interface")
6476 struct interface
*ifp
;
6477 struct crypt_key
*ck
;
6479 struct in_addr addr
;
6481 struct ospf_if_params
*params
;
6484 params
= IF_DEF_PARAMS (ifp
);
6488 ret
= inet_aton(argv
[2], &addr
);
6491 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6496 params
= ospf_get_if_params (ifp
, addr
);
6497 ospf_if_update_params (ifp
, addr
);
6500 key_id
= strtol (argv
[0], NULL
, 10);
6501 if (ospf_crypt_key_lookup (params
->auth_crypt
, key_id
) != NULL
)
6503 vty_out (vty
, "OSPF: Key %d already exists%s", key_id
, VTY_NEWLINE
);
6507 ck
= ospf_crypt_key_new ();
6508 ck
->key_id
= (u_char
) key_id
;
6509 memset (ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
6510 strncpy ((char *) ck
->auth_key
, argv
[1], OSPF_AUTH_MD5_SIZE
);
6512 ospf_crypt_key_add (params
->auth_crypt
, ck
);
6513 SET_IF_PARAM (params
, auth_crypt
);
6518 ALIAS (ip_ospf_message_digest_key
,
6519 ip_ospf_message_digest_key_cmd
,
6520 "ip ospf message-digest-key <1-255> md5 KEY",
6522 "OSPF interface commands\n"
6523 "Message digest authentication password (key)\n"
6525 "Use MD5 algorithm\n"
6526 "The OSPF password (key)")
6528 ALIAS_HIDDEN (ip_ospf_message_digest_key
,
6529 ospf_message_digest_key_cmd
,
6530 "ospf message-digest-key <1-255> md5 KEY",
6531 "OSPF interface commands\n"
6532 "Message digest authentication password (key)\n"
6534 "Use MD5 algorithm\n"
6535 "The OSPF password (key)")
6537 DEFUN (no_ip_ospf_message_digest_key_md5
,
6538 no_ip_ospf_message_digest_key_md5_addr_cmd
,
6539 "no ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
6542 "OSPF interface commands\n"
6543 "Message digest authentication password (key)\n"
6545 "Use MD5 algorithm\n"
6546 "The OSPF password (key)"
6547 "Address of interface")
6549 struct interface
*ifp
;
6550 struct crypt_key
*ck
;
6552 struct in_addr addr
;
6554 struct ospf_if_params
*params
;
6557 params
= IF_DEF_PARAMS (ifp
);
6561 ret
= inet_aton(argv
[2], &addr
);
6564 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6569 params
= ospf_lookup_if_params (ifp
, addr
);
6574 key_id
= strtol (argv
[0], NULL
, 10);
6575 ck
= ospf_crypt_key_lookup (params
->auth_crypt
, key_id
);
6578 vty_out (vty
, "OSPF: Key %d does not exist%s", key_id
, VTY_NEWLINE
);
6582 ospf_crypt_key_delete (params
->auth_crypt
, key_id
);
6584 if (params
!= IF_DEF_PARAMS (ifp
))
6586 ospf_free_if_params (ifp
, addr
);
6587 ospf_if_update_params (ifp
, addr
);
6593 ALIAS (no_ip_ospf_message_digest_key_md5
,
6594 no_ip_ospf_message_digest_key_md5_cmd
,
6595 "no ip ospf message-digest-key <1-255> md5 KEY",
6598 "OSPF interface commands\n"
6599 "Message digest authentication password (key)\n"
6601 "Use MD5 algorithm\n"
6602 "The OSPF password (key)")
6604 DEFUN (no_ip_ospf_message_digest_key
,
6605 no_ip_ospf_message_digest_key_addr_cmd
,
6606 "no ip ospf message-digest-key <1-255> A.B.C.D",
6609 "OSPF interface commands\n"
6610 "Message digest authentication password (key)\n"
6612 "Address of interface")
6614 struct interface
*ifp
;
6615 struct crypt_key
*ck
;
6617 struct in_addr addr
;
6619 struct ospf_if_params
*params
;
6622 params
= IF_DEF_PARAMS (ifp
);
6626 ret
= inet_aton(argv
[1], &addr
);
6629 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6634 params
= ospf_lookup_if_params (ifp
, addr
);
6639 key_id
= strtol (argv
[0], NULL
, 10);
6640 ck
= ospf_crypt_key_lookup (params
->auth_crypt
, key_id
);
6643 vty_out (vty
, "OSPF: Key %d does not exist%s", key_id
, VTY_NEWLINE
);
6647 ospf_crypt_key_delete (params
->auth_crypt
, key_id
);
6649 if (params
!= IF_DEF_PARAMS (ifp
))
6651 ospf_free_if_params (ifp
, addr
);
6652 ospf_if_update_params (ifp
, addr
);
6658 ALIAS (no_ip_ospf_message_digest_key
,
6659 no_ip_ospf_message_digest_key_cmd
,
6660 "no ip ospf message-digest-key <1-255>",
6663 "OSPF interface commands\n"
6664 "Message digest authentication password (key)\n"
6667 ALIAS (no_ip_ospf_message_digest_key
,
6668 no_ospf_message_digest_key_cmd
,
6669 "no ospf message-digest-key <1-255>",
6671 "OSPF interface commands\n"
6672 "Message digest authentication password (key)\n"
6675 DEFUN (ip_ospf_cost
,
6676 ip_ospf_cost_u32_inet4_cmd
,
6677 "ip ospf cost <1-65535> A.B.C.D",
6679 "OSPF interface commands\n"
6682 "Address of interface")
6684 struct interface
*ifp
= vty
->index
;
6686 struct in_addr addr
;
6688 struct ospf_if_params
*params
;
6690 params
= IF_DEF_PARAMS (ifp
);
6692 cost
= strtol (argv
[0], NULL
, 10);
6694 /* cost range is <1-65535>. */
6695 if (cost
< 1 || cost
> 65535)
6697 vty_out (vty
, "Interface output cost is invalid%s", VTY_NEWLINE
);
6703 ret
= inet_aton(argv
[1], &addr
);
6706 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6711 params
= ospf_get_if_params (ifp
, addr
);
6712 ospf_if_update_params (ifp
, addr
);
6715 SET_IF_PARAM (params
, output_cost_cmd
);
6716 params
->output_cost_cmd
= cost
;
6718 ospf_if_recalculate_output_cost (ifp
);
6723 ALIAS (ip_ospf_cost
,
6724 ip_ospf_cost_u32_cmd
,
6725 "ip ospf cost <1-65535>",
6727 "OSPF interface commands\n"
6731 ALIAS_HIDDEN (ip_ospf_cost
,
6733 "ospf cost <1-65535>",
6734 "OSPF interface commands\n"
6738 ALIAS_HIDDEN (ip_ospf_cost
,
6739 ospf_cost_u32_inet4_cmd
,
6740 "ospf cost <1-65535> A.B.C.D",
6741 "OSPF interface commands\n"
6744 "Address of interface")
6746 DEFUN (no_ip_ospf_cost
,
6747 no_ip_ospf_cost_inet4_cmd
,
6748 "no ip ospf cost A.B.C.D",
6751 "OSPF interface commands\n"
6753 "Address of interface")
6755 struct interface
*ifp
= vty
->index
;
6756 struct in_addr addr
;
6758 struct ospf_if_params
*params
;
6761 params
= IF_DEF_PARAMS (ifp
);
6765 ret
= inet_aton(argv
[0], &addr
);
6768 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6773 params
= ospf_lookup_if_params (ifp
, addr
);
6778 UNSET_IF_PARAM (params
, output_cost_cmd
);
6780 if (params
!= IF_DEF_PARAMS (ifp
))
6782 ospf_free_if_params (ifp
, addr
);
6783 ospf_if_update_params (ifp
, addr
);
6786 ospf_if_recalculate_output_cost (ifp
);
6791 ALIAS (no_ip_ospf_cost
,
6792 no_ip_ospf_cost_cmd
,
6796 "OSPF interface commands\n"
6799 ALIAS (no_ip_ospf_cost
,
6803 "OSPF interface commands\n"
6806 ALIAS (no_ip_ospf_cost
,
6807 no_ospf_cost_inet4_cmd
,
6808 "no ospf cost A.B.C.D",
6810 "OSPF interface commands\n"
6812 "Address of interface")
6814 DEFUN (no_ip_ospf_cost2
,
6815 no_ip_ospf_cost_u32_cmd
,
6816 "no ip ospf cost <1-65535>",
6819 "OSPF interface commands\n"
6823 struct interface
*ifp
= vty
->index
;
6824 struct in_addr addr
;
6827 struct ospf_if_params
*params
;
6830 params
= IF_DEF_PARAMS (ifp
);
6832 /* According to the semantics we are mimicking "no ip ospf cost N" is
6833 * always treated as "no ip ospf cost" regardless of the actual value
6834 * of N already configured for the interface. Thus the first argument
6835 * is always checked to be a number, but is ignored after that.
6837 cost
= strtol (argv
[0], NULL
, 10);
6838 if (cost
< 1 || cost
> 65535)
6840 vty_out (vty
, "Interface output cost is invalid%s", VTY_NEWLINE
);
6846 ret
= inet_aton(argv
[1], &addr
);
6849 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6854 params
= ospf_lookup_if_params (ifp
, addr
);
6859 UNSET_IF_PARAM (params
, output_cost_cmd
);
6861 if (params
!= IF_DEF_PARAMS (ifp
))
6863 ospf_free_if_params (ifp
, addr
);
6864 ospf_if_update_params (ifp
, addr
);
6867 ospf_if_recalculate_output_cost (ifp
);
6872 ALIAS (no_ip_ospf_cost2
,
6873 no_ospf_cost_u32_cmd
,
6874 "no ospf cost <1-65535>",
6876 "OSPF interface commands\n"
6880 ALIAS (no_ip_ospf_cost2
,
6881 no_ip_ospf_cost_u32_inet4_cmd
,
6882 "no ip ospf cost <1-65535> A.B.C.D",
6885 "OSPF interface commands\n"
6888 "Address of interface")
6890 ALIAS (no_ip_ospf_cost2
,
6891 no_ospf_cost_u32_inet4_cmd
,
6892 "no ospf cost <1-65535> A.B.C.D",
6894 "OSPF interface commands\n"
6897 "Address of interface")
6900 ospf_nbr_timer_update (struct ospf_interface
*oi
)
6902 struct route_node
*rn
;
6903 struct ospf_neighbor
*nbr
;
6905 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
6906 if ((nbr
= rn
->info
))
6908 nbr
->v_inactivity
= OSPF_IF_PARAM (oi
, v_wait
);
6909 nbr
->v_db_desc
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6910 nbr
->v_ls_req
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6911 nbr
->v_ls_upd
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6916 ospf_vty_dead_interval_set (struct vty
*vty
, const char *interval_str
,
6917 const char *nbr_str
,
6918 const char *fast_hello_str
)
6920 struct interface
*ifp
= vty
->index
;
6923 struct in_addr addr
;
6925 struct ospf_if_params
*params
;
6926 struct ospf_interface
*oi
;
6927 struct route_node
*rn
;
6929 params
= IF_DEF_PARAMS (ifp
);
6933 ret
= inet_aton(nbr_str
, &addr
);
6936 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6941 params
= ospf_get_if_params (ifp
, addr
);
6942 ospf_if_update_params (ifp
, addr
);
6947 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds
, interval_str
,
6950 /* reset fast_hello too, just to be sure */
6951 UNSET_IF_PARAM (params
, fast_hello
);
6952 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6954 else if (fast_hello_str
)
6956 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult
, fast_hello_str
,
6958 /* 1s dead-interval with sub-second hellos desired */
6959 seconds
= OSPF_ROUTER_DEAD_INTERVAL_MINIMAL
;
6960 SET_IF_PARAM (params
, fast_hello
);
6961 params
->fast_hello
= hellomult
;
6965 vty_out (vty
, "Please specify dead-interval or hello-multiplier%s",
6970 SET_IF_PARAM (params
, v_wait
);
6971 params
->v_wait
= seconds
;
6973 /* Update timer values in neighbor structure. */
6977 if ((ospf
= ospf_lookup()))
6979 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
6981 ospf_nbr_timer_update (oi
);
6986 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6987 if ((oi
= rn
->info
))
6988 ospf_nbr_timer_update (oi
);
6995 DEFUN (ip_ospf_dead_interval
,
6996 ip_ospf_dead_interval_addr_cmd
,
6997 "ip ospf dead-interval <1-65535> A.B.C.D",
6999 "OSPF interface commands\n"
7000 "Interval after which a neighbor is declared dead\n"
7002 "Address of interface\n")
7005 return ospf_vty_dead_interval_set (vty
, argv
[0], argv
[1], NULL
);
7007 return ospf_vty_dead_interval_set (vty
, argv
[0], NULL
, NULL
);
7010 ALIAS (ip_ospf_dead_interval
,
7011 ip_ospf_dead_interval_cmd
,
7012 "ip ospf dead-interval <1-65535>",
7014 "OSPF interface commands\n"
7015 "Interval after which a neighbor is declared dead\n"
7018 ALIAS_HIDDEN (ip_ospf_dead_interval
,
7019 ospf_dead_interval_cmd
,
7020 "ospf dead-interval <1-65535>",
7021 "OSPF interface commands\n"
7022 "Interval after which a neighbor is declared dead\n"
7025 DEFUN (ip_ospf_dead_interval_minimal
,
7026 ip_ospf_dead_interval_minimal_addr_cmd
,
7027 "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
7029 "OSPF interface commands\n"
7030 "Interval after which a neighbor is declared dead\n"
7031 "Minimal 1s dead-interval with fast sub-second hellos\n"
7032 "Hello multiplier factor\n"
7033 "Number of Hellos to send each second\n"
7034 "Address of interface\n")
7037 return ospf_vty_dead_interval_set (vty
, NULL
, argv
[1], argv
[0]);
7039 return ospf_vty_dead_interval_set (vty
, NULL
, NULL
, argv
[0]);
7042 ALIAS (ip_ospf_dead_interval_minimal
,
7043 ip_ospf_dead_interval_minimal_cmd
,
7044 "ip ospf dead-interval minimal hello-multiplier <1-10>",
7046 "OSPF interface commands\n"
7047 "Interval after which a neighbor is declared dead\n"
7048 "Minimal 1s dead-interval with fast sub-second hellos\n"
7049 "Hello multiplier factor\n"
7050 "Number of Hellos to send each second\n")
7052 DEFUN (no_ip_ospf_dead_interval
,
7053 no_ip_ospf_dead_interval_addr_cmd
,
7054 "no ip ospf dead-interval <1-65535> A.B.C.D",
7057 "OSPF interface commands\n"
7058 "Interval after which a neighbor is declared dead\n"
7060 "Address of interface")
7062 struct interface
*ifp
= vty
->index
;
7063 struct in_addr addr
;
7065 struct ospf_if_params
*params
;
7066 struct ospf_interface
*oi
;
7067 struct route_node
*rn
;
7070 params
= IF_DEF_PARAMS (ifp
);
7074 ret
= inet_aton(argv
[1], &addr
);
7077 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7082 params
= ospf_lookup_if_params (ifp
, addr
);
7087 UNSET_IF_PARAM (params
, v_wait
);
7088 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
7090 UNSET_IF_PARAM (params
, fast_hello
);
7091 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
7093 if (params
!= IF_DEF_PARAMS (ifp
))
7095 ospf_free_if_params (ifp
, addr
);
7096 ospf_if_update_params (ifp
, addr
);
7099 /* Update timer values in neighbor structure. */
7104 if ((ospf
= ospf_lookup()))
7106 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
7108 ospf_nbr_timer_update (oi
);
7113 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7114 if ((oi
= rn
->info
))
7115 ospf_nbr_timer_update (oi
);
7121 ALIAS (no_ip_ospf_dead_interval
,
7122 no_ip_ospf_dead_interval_seconds_cmd
,
7123 "no ip ospf dead-interval <1-65535>",
7126 "OSPF interface commands\n"
7127 "Interval after which a neighbor is declared dead\n"
7130 ALIAS (no_ip_ospf_dead_interval
,
7131 no_ip_ospf_dead_interval_cmd
,
7132 "no ip ospf dead-interval",
7135 "OSPF interface commands\n"
7136 "Interval after which a neighbor is declared dead\n")
7138 ALIAS (no_ip_ospf_dead_interval
,
7139 no_ospf_dead_interval_cmd
,
7140 "no ospf dead-interval",
7142 "OSPF interface commands\n"
7143 "Interval after which a neighbor is declared dead\n")
7145 ALIAS (no_ip_ospf_dead_interval
,
7146 no_ip_ospf_dead_interval_minimal_addr_cmd
,
7147 "no ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
7150 "OSPF interface commands\n"
7151 "Interval after which a neighbor is declared dead\n"
7152 "Minimal 1s dead-interval with fast sub-second hellos\n"
7153 "Hello multiplier factor\n"
7154 "Number of Hellos to send each second\n"
7155 "Address of interface\n")
7157 ALIAS (no_ip_ospf_dead_interval
,
7158 no_ip_ospf_dead_interval_minimal_cmd
,
7159 "no ip ospf dead-interval minimal hello-multiplier <1-10>",
7162 "OSPF interface commands\n"
7163 "Interval after which a neighbor is declared dead\n"
7164 "Minimal 1s dead-interval with fast sub-second hellos\n"
7165 "Hello multiplier factor\n"
7166 "Number of Hellos to send each second\n")
7168 DEFUN (ip_ospf_hello_interval
,
7169 ip_ospf_hello_interval_addr_cmd
,
7170 "ip ospf hello-interval <1-65535> A.B.C.D",
7172 "OSPF interface commands\n"
7173 "Time between HELLO packets\n"
7175 "Address of interface")
7177 struct interface
*ifp
= vty
->index
;
7179 struct in_addr addr
;
7181 struct ospf_if_params
*params
;
7183 params
= IF_DEF_PARAMS (ifp
);
7185 seconds
= strtol (argv
[0], NULL
, 10);
7187 /* HelloInterval range is <1-65535>. */
7188 if (seconds
< 1 || seconds
> 65535)
7190 vty_out (vty
, "Hello Interval is invalid%s", VTY_NEWLINE
);
7196 ret
= inet_aton(argv
[1], &addr
);
7199 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7204 params
= ospf_get_if_params (ifp
, addr
);
7205 ospf_if_update_params (ifp
, addr
);
7208 SET_IF_PARAM (params
, v_hello
);
7209 params
->v_hello
= seconds
;
7214 ALIAS (ip_ospf_hello_interval
,
7215 ip_ospf_hello_interval_cmd
,
7216 "ip ospf hello-interval <1-65535>",
7218 "OSPF interface commands\n"
7219 "Time between HELLO packets\n"
7222 ALIAS_HIDDEN (ip_ospf_hello_interval
,
7223 ospf_hello_interval_cmd
,
7224 "ospf hello-interval <1-65535>",
7225 "OSPF interface commands\n"
7226 "Time between HELLO packets\n"
7229 DEFUN (no_ip_ospf_hello_interval
,
7230 no_ip_ospf_hello_interval_addr_cmd
,
7231 "no ip ospf hello-interval <1-65535> A.B.C.D",
7234 "OSPF interface commands\n"
7235 "Time between HELLO packets\n"
7237 "Address of interface")
7239 struct interface
*ifp
= vty
->index
;
7240 struct in_addr addr
;
7242 struct ospf_if_params
*params
;
7245 params
= IF_DEF_PARAMS (ifp
);
7249 ret
= inet_aton(argv
[1], &addr
);
7252 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7257 params
= ospf_lookup_if_params (ifp
, addr
);
7262 UNSET_IF_PARAM (params
, v_hello
);
7263 params
->v_hello
= OSPF_HELLO_INTERVAL_DEFAULT
;
7265 if (params
!= IF_DEF_PARAMS (ifp
))
7267 ospf_free_if_params (ifp
, addr
);
7268 ospf_if_update_params (ifp
, addr
);
7274 ALIAS (no_ip_ospf_hello_interval
,
7275 no_ip_ospf_hello_interval_seconds_cmd
,
7276 "no ip ospf hello-interval <1-65535>",
7279 "OSPF interface commands\n"
7280 "Time between HELLO packets\n"
7283 ALIAS (no_ip_ospf_hello_interval
,
7284 no_ip_ospf_hello_interval_cmd
,
7285 "no ip ospf hello-interval",
7288 "OSPF interface commands\n"
7289 "Time between HELLO packets\n")
7291 ALIAS (no_ip_ospf_hello_interval
,
7292 no_ospf_hello_interval_cmd
,
7293 "no ospf hello-interval <1-65535>",
7295 "OSPF interface commands\n"
7296 "Time between HELLO packets\n"
7299 DEFUN (ip_ospf_network
,
7300 ip_ospf_network_cmd
,
7301 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
7303 "OSPF interface commands\n"
7305 "Specify OSPF broadcast multi-access network\n"
7306 "Specify OSPF NBMA network\n"
7307 "Specify OSPF point-to-multipoint network\n"
7308 "Specify OSPF point-to-point network\n")
7310 struct interface
*ifp
= vty
->index
;
7311 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
7312 struct route_node
*rn
;
7314 if (old_type
== OSPF_IFTYPE_LOOPBACK
)
7316 vty_out (vty
, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE
);
7320 if (strncmp (argv
[0], "b", 1) == 0)
7321 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_BROADCAST
;
7322 else if (strncmp (argv
[0], "n", 1) == 0)
7323 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_NBMA
;
7324 else if (strncmp (argv
[0], "point-to-m", 10) == 0)
7325 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOMULTIPOINT
;
7326 else if (strncmp (argv
[0], "point-to-p", 10) == 0)
7327 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOPOINT
;
7329 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
7332 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), type
);
7334 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7336 struct ospf_interface
*oi
= rn
->info
;
7341 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
7343 if (oi
->state
> ISM_Down
)
7345 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
7346 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
7353 ALIAS_HIDDEN (ip_ospf_network
,
7355 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
7356 "OSPF interface commands\n"
7358 "Specify OSPF broadcast multi-access network\n"
7359 "Specify OSPF NBMA network\n"
7360 "Specify OSPF point-to-multipoint network\n"
7361 "Specify OSPF point-to-point network\n")
7363 DEFUN (no_ip_ospf_network
,
7364 no_ip_ospf_network_cmd
,
7365 "no ip ospf network",
7368 "OSPF interface commands\n"
7371 struct interface
*ifp
= vty
->index
;
7372 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
7373 struct route_node
*rn
;
7375 IF_DEF_PARAMS (ifp
)->type
= ospf_default_iftype(ifp
);
7377 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
7380 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7382 struct ospf_interface
*oi
= rn
->info
;
7387 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
7389 if (oi
->state
> ISM_Down
)
7391 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
7392 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
7399 ALIAS (no_ip_ospf_network
,
7400 no_ip_ospf_network_val_cmd
,
7401 "no ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
7404 "OSPF interface commands\n"
7406 "Specify OSPF broadcast multi-access network\n"
7407 "Specify OSPF NBMA network\n"
7408 "Specify OSPF point-to-multipoint network\n"
7409 "Specify OSPF point-to-point network\n")
7411 ALIAS (no_ip_ospf_network
,
7412 no_ospf_network_cmd
,
7415 "OSPF interface commands\n"
7418 ALIAS (no_ip_ospf_network
,
7419 no_ospf_network_val_cmd
,
7420 "no ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
7422 "OSPF interface commands\n"
7424 "Specify OSPF broadcast multi-access network\n"
7425 "Specify OSPF NBMA network\n"
7426 "Specify OSPF point-to-multipoint network\n"
7427 "Specify OSPF point-to-point network\n")
7429 DEFUN (ip_ospf_priority
,
7430 ip_ospf_priority_addr_cmd
,
7431 "ip ospf priority <0-255> A.B.C.D",
7433 "OSPF interface commands\n"
7436 "Address of interface")
7438 struct interface
*ifp
= vty
->index
;
7440 struct route_node
*rn
;
7441 struct in_addr addr
;
7443 struct ospf_if_params
*params
;
7445 params
= IF_DEF_PARAMS (ifp
);
7447 priority
= strtol (argv
[0], NULL
, 10);
7449 /* Router Priority range is <0-255>. */
7450 if (priority
< 0 || priority
> 255)
7452 vty_out (vty
, "Router Priority is invalid%s", VTY_NEWLINE
);
7458 ret
= inet_aton(argv
[1], &addr
);
7461 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7466 params
= ospf_get_if_params (ifp
, addr
);
7467 ospf_if_update_params (ifp
, addr
);
7470 SET_IF_PARAM (params
, priority
);
7471 params
->priority
= priority
;
7473 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7475 struct ospf_interface
*oi
= rn
->info
;
7481 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
7483 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
7484 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
7491 ALIAS (ip_ospf_priority
,
7492 ip_ospf_priority_cmd
,
7493 "ip ospf priority <0-255>",
7495 "OSPF interface commands\n"
7499 ALIAS_HIDDEN (ip_ospf_priority
,
7501 "ospf priority <0-255>",
7502 "OSPF interface commands\n"
7506 DEFUN (no_ip_ospf_priority
,
7507 no_ip_ospf_priority_addr_cmd
,
7508 "no ip ospf priority <0-255> A.B.C.D",
7511 "OSPF interface commands\n"
7514 "Address of interface")
7516 struct interface
*ifp
= vty
->index
;
7517 struct route_node
*rn
;
7518 struct in_addr addr
;
7520 struct ospf_if_params
*params
;
7523 params
= IF_DEF_PARAMS (ifp
);
7527 ret
= inet_aton(argv
[1], &addr
);
7530 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7535 params
= ospf_lookup_if_params (ifp
, addr
);
7540 UNSET_IF_PARAM (params
, priority
);
7541 params
->priority
= OSPF_ROUTER_PRIORITY_DEFAULT
;
7543 if (params
!= IF_DEF_PARAMS (ifp
))
7545 ospf_free_if_params (ifp
, addr
);
7546 ospf_if_update_params (ifp
, addr
);
7549 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
7551 struct ospf_interface
*oi
= rn
->info
;
7557 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
7559 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
7560 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
7567 ALIAS (no_ip_ospf_priority
,
7568 no_ip_ospf_priority_no_param_cmd
,
7569 "no ip ospf priority",
7572 "OSPF interface commands\n"
7573 "Router priority\n");
7575 ALIAS (no_ip_ospf_priority
,
7576 no_ip_ospf_priority_cmd
,
7577 "no ip ospf priority <0-255>",
7580 "OSPF interface commands\n"
7584 ALIAS (no_ip_ospf_priority
,
7585 no_ospf_priority_cmd
,
7586 "no ospf priority <0-255>",
7588 "OSPF interface commands\n"
7593 DEFUN (ip_ospf_retransmit_interval
,
7594 ip_ospf_retransmit_interval_addr_cmd
,
7595 "ip ospf retransmit-interval <3-65535> A.B.C.D",
7597 "OSPF interface commands\n"
7598 "Time between retransmitting lost link state advertisements\n"
7600 "Address of interface")
7602 struct interface
*ifp
= vty
->index
;
7604 struct in_addr addr
;
7606 struct ospf_if_params
*params
;
7608 params
= IF_DEF_PARAMS (ifp
);
7609 seconds
= strtol (argv
[0], NULL
, 10);
7611 /* Retransmit Interval range is <3-65535>. */
7612 if (seconds
< 3 || seconds
> 65535)
7614 vty_out (vty
, "Retransmit Interval is invalid%s", VTY_NEWLINE
);
7621 ret
= inet_aton(argv
[1], &addr
);
7624 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7629 params
= ospf_get_if_params (ifp
, addr
);
7630 ospf_if_update_params (ifp
, addr
);
7633 SET_IF_PARAM (params
, retransmit_interval
);
7634 params
->retransmit_interval
= seconds
;
7639 ALIAS (ip_ospf_retransmit_interval
,
7640 ip_ospf_retransmit_interval_cmd
,
7641 "ip ospf retransmit-interval <3-65535>",
7643 "OSPF interface commands\n"
7644 "Time between retransmitting lost link state advertisements\n"
7647 ALIAS_HIDDEN (ip_ospf_retransmit_interval
,
7648 ospf_retransmit_interval_cmd
,
7649 "ospf retransmit-interval <3-65535>",
7650 "OSPF interface commands\n"
7651 "Time between retransmitting lost link state advertisements\n"
7654 DEFUN (no_ip_ospf_retransmit_interval
,
7655 no_ip_ospf_retransmit_interval_addr_cmd
,
7656 "no ip ospf retransmit-interval A.B.C.D",
7659 "OSPF interface commands\n"
7660 "Time between retransmitting lost link state advertisements\n"
7661 "Address of interface")
7663 struct interface
*ifp
= vty
->index
;
7664 struct in_addr addr
;
7666 struct ospf_if_params
*params
;
7670 params
= IF_DEF_PARAMS (ifp
);
7679 ret
= inet_aton(argv
[addr_index
], &addr
);
7682 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7687 params
= ospf_lookup_if_params (ifp
, addr
);
7692 UNSET_IF_PARAM (params
, retransmit_interval
);
7693 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
7695 if (params
!= IF_DEF_PARAMS (ifp
))
7697 ospf_free_if_params (ifp
, addr
);
7698 ospf_if_update_params (ifp
, addr
);
7704 ALIAS (no_ip_ospf_retransmit_interval
,
7705 no_ip_ospf_retransmit_interval_sec_addr_cmd
,
7706 "no ip ospf retransmit-interval <3-65535> A.B.C.D",
7709 "OSPF interface commands\n"
7710 "Time between retransmitting lost link state advertisements\n"
7712 "Address of interface")
7714 ALIAS (no_ip_ospf_retransmit_interval
,
7715 no_ip_ospf_retransmit_interval_cmd
,
7716 "no ip ospf retransmit-interval",
7719 "OSPF interface commands\n"
7720 "Time between retransmitting lost link state advertisements\n")
7722 ALIAS (no_ip_ospf_retransmit_interval
,
7723 no_ospf_retransmit_interval_cmd
,
7724 "no ospf retransmit-interval",
7726 "OSPF interface commands\n"
7727 "Time between retransmitting lost link state advertisements\n")
7729 DEFUN (no_ip_ospf_retransmit_interval_sec
,
7730 no_ip_ospf_retransmit_interval_sec_cmd
,
7731 "no ip ospf retransmit-interval <3-65535>",
7734 "OSPF interface commands\n"
7735 "Time between retransmitting lost link state advertisements\n"
7738 struct interface
*ifp
= vty
->index
;
7739 struct ospf_if_params
*params
;
7742 params
= IF_DEF_PARAMS (ifp
);
7744 UNSET_IF_PARAM (params
, retransmit_interval
);
7745 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
7751 DEFUN (ip_ospf_transmit_delay
,
7752 ip_ospf_transmit_delay_addr_cmd
,
7753 "ip ospf transmit-delay <1-65535> A.B.C.D",
7755 "OSPF interface commands\n"
7756 "Link state transmit delay\n"
7758 "Address of interface")
7760 struct interface
*ifp
= vty
->index
;
7762 struct in_addr addr
;
7764 struct ospf_if_params
*params
;
7766 params
= IF_DEF_PARAMS (ifp
);
7767 seconds
= strtol (argv
[0], NULL
, 10);
7769 /* Transmit Delay range is <1-65535>. */
7770 if (seconds
< 1 || seconds
> 65535)
7772 vty_out (vty
, "Transmit Delay is invalid%s", VTY_NEWLINE
);
7778 ret
= inet_aton(argv
[1], &addr
);
7781 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7786 params
= ospf_get_if_params (ifp
, addr
);
7787 ospf_if_update_params (ifp
, addr
);
7790 SET_IF_PARAM (params
, transmit_delay
);
7791 params
->transmit_delay
= seconds
;
7796 ALIAS (ip_ospf_transmit_delay
,
7797 ip_ospf_transmit_delay_cmd
,
7798 "ip ospf transmit-delay <1-65535>",
7800 "OSPF interface commands\n"
7801 "Link state transmit delay\n"
7804 ALIAS_HIDDEN (ip_ospf_transmit_delay
,
7805 ospf_transmit_delay_cmd
,
7806 "ospf transmit-delay <1-65535>",
7807 "OSPF interface commands\n"
7808 "Link state transmit delay\n"
7811 DEFUN (no_ip_ospf_transmit_delay
,
7812 no_ip_ospf_transmit_delay_addr_cmd
,
7813 "no ip ospf transmit-delay A.B.C.D",
7816 "OSPF interface commands\n"
7817 "Link state transmit delay\n"
7818 "Address of interface")
7820 struct interface
*ifp
= vty
->index
;
7821 struct in_addr addr
;
7823 struct ospf_if_params
*params
;
7827 params
= IF_DEF_PARAMS (ifp
);
7836 ret
= inet_aton(argv
[addr_index
], &addr
);
7839 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7844 params
= ospf_lookup_if_params (ifp
, addr
);
7849 UNSET_IF_PARAM (params
, transmit_delay
);
7850 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
7852 if (params
!= IF_DEF_PARAMS (ifp
))
7854 ospf_free_if_params (ifp
, addr
);
7855 ospf_if_update_params (ifp
, addr
);
7861 ALIAS (no_ip_ospf_transmit_delay
,
7862 no_ip_ospf_transmit_delay_sec_addr_cmd
,
7863 "no ip ospf transmit-delay <1-65535> A.B.C.D",
7866 "OSPF interface commands\n"
7867 "Link state transmit delay\n"
7869 "Address of interface")
7871 ALIAS (no_ip_ospf_transmit_delay
,
7872 no_ip_ospf_transmit_delay_cmd
,
7873 "no ip ospf transmit-delay",
7876 "OSPF interface commands\n"
7877 "Link state transmit delay\n")
7879 ALIAS (no_ip_ospf_transmit_delay
,
7880 no_ospf_transmit_delay_cmd
,
7881 "no ospf transmit-delay",
7883 "OSPF interface commands\n"
7884 "Link state transmit delay\n")
7886 DEFUN (no_ip_ospf_transmit_delay_sec
,
7887 no_ip_ospf_transmit_delay_sec_cmd
,
7888 "no ip ospf transmit-delay <1-65535>",
7891 "OSPF interface commands\n"
7892 "Link state transmit delay\n"
7894 "Address of interface")
7896 struct interface
*ifp
= vty
->index
;
7897 struct ospf_if_params
*params
;
7900 params
= IF_DEF_PARAMS (ifp
);
7902 UNSET_IF_PARAM (params
, transmit_delay
);
7903 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
7908 DEFUN (ip_ospf_area
,
7910 "ip ospf area (A.B.C.D|<0-4294967295>)",
7912 "OSPF interface commands\n"
7913 "Enable OSPF on this interface\n"
7914 "OSPF area ID in IP address format\n"
7915 "OSPF area ID as a decimal value\n")
7917 struct interface
*ifp
= vty
->index
;
7919 struct in_addr area_id
;
7921 struct ospf_if_params
*params
;
7922 struct route_node
*rn
;
7923 u_short instance
= 0;
7926 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
7928 ospf
= ospf_lookup_instance (instance
);
7931 params
= IF_DEF_PARAMS (ifp
);
7932 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7934 ospf_interface_unset (ifp
);
7935 ospf
= ospf_lookup();
7936 ospf
->if_ospf_cli_count
--;
7941 ret
= ospf_str2area_id (argv
[instance
? 1 : 0], &area_id
, &format
);
7944 vty_out (vty
, "Please specify area by A.B.C.D|<0-4294967295>%s",
7948 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
7950 vty_out (vty
, "Cannot enable OSPF on a virtual link.%s", VTY_NEWLINE
);
7954 params
= IF_DEF_PARAMS (ifp
);
7955 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7958 "Must remove previous area config before changing ospf area %s",
7963 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
7965 if (rn
->info
!= NULL
)
7967 vty_out (vty
, "Please remove all network commands first.%s", VTY_NEWLINE
);
7972 /* enable ospf on this interface with area_id */
7973 ospf_interface_set (ifp
, area_id
);
7974 ospf
->if_ospf_cli_count
++;
7979 ALIAS (ip_ospf_area
,
7980 ip_ospf_instance_area_cmd
,
7981 "ip ospf <1-65535> area (A.B.C.D|<0-4294967295>)",
7983 "OSPF interface commands\n"
7985 "Enable OSPF on this interface\n"
7986 "OSPF area ID in IP address format\n"
7987 "OSPF area ID as a decimal value\n")
7989 DEFUN (no_ip_ospf_area
,
7990 no_ip_ospf_area_cmd
,
7994 "OSPF interface commands\n"
7995 "Disable OSPF on this interface\n")
7997 struct interface
*ifp
= vty
->index
;
7999 struct ospf_if_params
*params
;
8000 u_short instance
= 0;
8002 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
8005 params
= IF_DEF_PARAMS (ifp
);
8006 if (!OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
8008 vty_out (vty
, "Can't find specified inteface area configuration.%s", VTY_NEWLINE
);
8012 ospf_interface_unset (ifp
);
8013 ospf
->if_ospf_cli_count
--;
8017 ALIAS (no_ip_ospf_area
,
8018 no_ip_ospf_area_val_cmd
,
8019 "no ip ospf area (A.B.C.D|<0-4294967295>)",
8022 "OSPF interface commands\n"
8023 "Disable OSPF on this interface\n"
8024 "OSPF area ID in IP address format\n"
8025 "OSPF area ID as a decimal value\n")
8027 DEFUN (no_ip_ospf_instance_area
,
8028 no_ip_ospf_instance_area_cmd
,
8029 "no ip ospf <1-65535> area",
8032 "OSPF interface commands\n"
8034 "Disable OSPF on this interface\n")
8036 struct interface
*ifp
= vty
->index
;
8038 struct ospf_if_params
*params
;
8039 u_short instance
= 0;
8041 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
8043 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
8046 params
= IF_DEF_PARAMS (ifp
);
8047 if (!OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
8049 vty_out (vty
, "Can't find specified inteface area configuration.%s", VTY_NEWLINE
);
8053 ospf_interface_unset (ifp
);
8054 ospf
->if_ospf_cli_count
--;
8058 ALIAS (no_ip_ospf_instance_area
,
8059 no_ip_ospf_instance_area_val_cmd
,
8060 "no ip ospf <1-65535> area (A.B.C.D|<0-4294967295>)",
8063 "OSPF interface commands\n"
8065 "Disable OSPF on this interface\n"
8066 "OSPF area ID in IP address format\n"
8067 "OSPF area ID as a decimal value\n")
8069 DEFUN (ospf_redistribute_source
,
8070 ospf_redistribute_source_cmd
,
8071 "redistribute " FRR_REDIST_STR_OSPFD
8072 " {metric <0-16777214>|metric-type (1|2)|route-map WORD}",
8074 FRR_REDIST_HELP_STR_OSPFD
8075 "Metric for redistributed routes\n"
8076 "OSPF default metric\n"
8077 "OSPF exterior metric type for redistributed routes\n"
8078 "Set OSPF External Type 1 metrics\n"
8079 "Set OSPF External Type 2 metrics\n"
8080 "Route map reference\n"
8081 "Pointer to route-map entries\n")
8083 struct ospf
*ospf
= vty
->index
;
8087 struct ospf_redist
*red
;
8093 return CMD_WARNING
; /* should not happen */
8098 /* Get distribute source. */
8099 source
= proto_redistnum(AFI_IP
, argv
[0]);
8100 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
8103 /* Get metric value. */
8104 if (argv
[1] != NULL
)
8105 if (!str2metric (argv
[1], &metric
))
8108 /* Get metric type. */
8109 if (argv
[2] != NULL
)
8110 if (!str2metric_type (argv
[2], &type
))
8113 red
= ospf_redist_add(ospf
, source
, 0);
8115 if (argv
[3] != NULL
)
8116 ospf_routemap_set (red
, argv
[3]);
8118 ospf_routemap_unset (red
);
8120 return ospf_redistribute_set (ospf
, source
, 0, type
, metric
);
8123 DEFUN (no_ospf_redistribute_source
,
8124 no_ospf_redistribute_source_cmd
,
8125 "no redistribute " FRR_REDIST_STR_OSPFD
8126 " {metric <0-16777214>|metric-type (1|2)|route-map WORD}",
8129 FRR_REDIST_HELP_STR_OSPFD
8130 "Metric for redistributed routes\n"
8131 "OSPF default metric\n"
8132 "OSPF exterior metric type for redistributed routes\n"
8133 "Set OSPF External Type 1 metrics\n"
8134 "Set OSPF External Type 2 metrics\n"
8135 "Route map reference\n"
8136 "Pointer to route-map entries\n")
8138 struct ospf
*ospf
= vty
->index
;
8140 struct ospf_redist
*red
;
8144 source
= proto_redistnum(AFI_IP
, argv
[0]);
8145 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
8148 red
= ospf_redist_lookup(ospf
, source
, 0);
8152 ospf_routemap_unset (red
);
8153 return ospf_redistribute_unset (ospf
, source
, 0);
8156 DEFUN (ospf_redistribute_instance_source
,
8157 ospf_redistribute_instance_source_cmd
,
8158 "redistribute (ospf|table) <1-65535>"
8159 " {metric <0-16777214>|metric-type (1|2)|route-map WORD}",
8161 "Open Shortest Path First\n"
8162 "Non-main Kernel Routing Table\n"
8163 "Instance ID/Table ID\n"
8164 "Metric for redistributed routes\n"
8165 "OSPF default metric\n"
8166 "OSPF exterior metric type for redistributed routes\n"
8167 "Set OSPF External Type 1 metrics\n"
8168 "Set OSPF External Type 2 metrics\n"
8169 "Route map reference\n"
8170 "Pointer to route-map entries\n")
8172 struct ospf
*ospf
= vty
->index
;
8177 struct ospf_redist
*red
;
8182 if (strncmp(argv
[0], "o", 1) == 0)
8183 source
= ZEBRA_ROUTE_OSPF
;
8185 source
= ZEBRA_ROUTE_TABLE
;
8187 VTY_GET_INTEGER ("Instance ID", instance
, argv
[1]);
8192 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
8194 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
8199 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
8201 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
8206 /* Get metric value. */
8207 if (argv
[2] != NULL
)
8208 if (!str2metric (argv
[2], &metric
))
8211 /* Get metric type. */
8212 if (argv
[3] != NULL
)
8213 if (!str2metric_type (argv
[3], &type
))
8216 red
= ospf_redist_add(ospf
, source
, instance
);
8217 if (argv
[4] != NULL
)
8218 ospf_routemap_set (red
, argv
[4]);
8220 ospf_routemap_unset (red
);
8222 return ospf_redistribute_set (ospf
, source
, instance
, type
, metric
);
8225 DEFUN (no_ospf_redistribute_instance_source
,
8226 no_ospf_redistribute_instance_source_cmd
,
8227 "no redistribute (ospf|table) <1-65535>"
8228 " {metric <0-16777214>|metric-type (1|2)|route-map WORD}",
8231 "Open Shortest Path First\n"
8232 "Non-main Kernel Routing Table\n"
8233 "Instance ID/Table Id\n"
8234 "Metric for redistributed routes\n"
8235 "OSPF default metric\n"
8236 "OSPF exterior metric type for redistributed routes\n"
8237 "Set OSPF External Type 1 metrics\n"
8238 "Set OSPF External Type 2 metrics\n"
8239 "Route map reference\n"
8240 "Pointer to route-map entries\n")
8242 struct ospf
*ospf
= vty
->index
;
8244 struct ospf_redist
*red
;
8250 if (strncmp(argv
[0], "o", 1) == 0)
8251 source
= ZEBRA_ROUTE_OSPF
;
8253 source
= ZEBRA_ROUTE_TABLE
;
8255 VTY_GET_INTEGER ("Instance ID", instance
, argv
[1]);
8257 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
8259 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
8264 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
8266 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
8271 red
= ospf_redist_lookup(ospf
, source
, instance
);
8275 ospf_routemap_unset (red
);
8276 return ospf_redistribute_unset (ospf
, source
, instance
);
8279 DEFUN (ospf_distribute_list_out
,
8280 ospf_distribute_list_out_cmd
,
8281 "distribute-list WORD out " FRR_REDIST_STR_OSPFD
,
8282 "Filter networks in routing updates\n"
8283 "Access-list name\n"
8285 FRR_REDIST_HELP_STR_OSPFD
)
8287 struct ospf
*ospf
= vty
->index
;
8293 /* Get distribute source. */
8294 source
= proto_redistnum(AFI_IP
, argv
[1]);
8295 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
8298 return ospf_distribute_list_out_set (ospf
, source
, argv
[0]);
8301 DEFUN (no_ospf_distribute_list_out
,
8302 no_ospf_distribute_list_out_cmd
,
8303 "no distribute-list WORD out " FRR_REDIST_STR_OSPFD
,
8305 "Filter networks in routing updates\n"
8306 "Access-list name\n"
8308 FRR_REDIST_HELP_STR_OSPFD
)
8310 struct ospf
*ospf
= vty
->index
;
8316 source
= proto_redistnum(AFI_IP
, argv
[1]);
8317 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
8320 return ospf_distribute_list_out_unset (ospf
, source
, argv
[0]);
8323 /* Default information originate. */
8324 DEFUN (ospf_default_information_originate
,
8325 ospf_default_information_originate_cmd
,
8326 "default-information originate "
8327 "{always|metric <0-16777214>|metric-type (1|2)|route-map WORD}",
8328 "Control distribution of default information\n"
8329 "Distribute a default route\n"
8330 "Always advertise default route\n"
8331 "OSPF default metric\n"
8333 "OSPF metric type for default routes\n"
8334 "Set OSPF External Type 1 metrics\n"
8335 "Set OSPF External Type 2 metrics\n"
8336 "Route map reference\n"
8337 "Pointer to route-map entries\n")
8339 struct ospf
*ospf
= vty
->index
;
8340 int default_originate
= DEFAULT_ORIGINATE_ZEBRA
;
8343 struct ospf_redist
*red
;
8349 return CMD_WARNING
; /* this should not happen */
8351 /* Check whether "always" was specified */
8352 if (argv
[0] != NULL
)
8353 default_originate
= DEFAULT_ORIGINATE_ALWAYS
;
8355 red
= ospf_redist_add(ospf
, DEFAULT_ROUTE
, 0);
8357 /* Get metric value. */
8358 if (argv
[1] != NULL
)
8359 if (!str2metric (argv
[1], &metric
))
8362 /* Get metric type. */
8363 if (argv
[2] != NULL
)
8364 if (!str2metric_type (argv
[2], &type
))
8367 if (argv
[3] != NULL
)
8368 ospf_routemap_set (red
, argv
[3]);
8370 ospf_routemap_unset (red
);
8372 return ospf_redistribute_default_set (ospf
, default_originate
,
8376 DEFUN (no_ospf_default_information_originate
,
8377 no_ospf_default_information_originate_cmd
,
8378 "no default-information originate"
8379 "{always|metric <0-16777214>|metric-type (1|2)|route-map WORD}",
8381 "Control distribution of default information\n"
8382 "Distribute a default route\n"
8383 "Always advertise default route\n"
8384 "OSPF default metric\n"
8386 "OSPF metric type for default routes\n"
8387 "Set OSPF External Type 1 metrics\n"
8388 "Set OSPF External Type 2 metrics\n"
8389 "Route map reference\n"
8390 "Pointer to route-map entries\n")
8392 struct ospf
*ospf
= vty
->index
;
8393 struct prefix_ipv4 p
;
8394 struct ospf_external
*ext
;
8395 struct ospf_redist
*red
;
8401 p
.prefix
.s_addr
= 0;
8404 ospf_external_lsa_flush (ospf
, DEFAULT_ROUTE
, &p
, 0);
8406 if ((ext
= ospf_external_lookup(DEFAULT_ROUTE
, 0)) &&
8407 EXTERNAL_INFO (ext
)) {
8408 ospf_external_info_delete (DEFAULT_ROUTE
, 0, p
);
8409 ospf_external_del (DEFAULT_ROUTE
, 0);
8412 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
8416 ospf_routemap_unset (red
);
8417 return ospf_redistribute_default_unset (ospf
);
8420 DEFUN (ospf_default_metric
,
8421 ospf_default_metric_cmd
,
8422 "default-metric <0-16777214>",
8423 "Set metric of redistributed routes\n"
8426 struct ospf
*ospf
= vty
->index
;
8432 if (!str2metric (argv
[0], &metric
))
8435 ospf
->default_metric
= metric
;
8440 DEFUN (no_ospf_default_metric
,
8441 no_ospf_default_metric_cmd
,
8442 "no default-metric",
8444 "Set metric of redistributed routes\n")
8446 struct ospf
*ospf
= vty
->index
;
8451 ospf
->default_metric
= -1;
8456 ALIAS (no_ospf_default_metric
,
8457 no_ospf_default_metric_val_cmd
,
8458 "no default-metric <0-16777214>",
8460 "Set metric of redistributed routes\n"
8463 DEFUN (ospf_distance
,
8466 "Define an administrative distance\n"
8467 "OSPF Administrative distance\n")
8469 struct ospf
*ospf
= vty
->index
;
8474 ospf
->distance_all
= atoi (argv
[0]);
8479 DEFUN (no_ospf_distance
,
8480 no_ospf_distance_cmd
,
8481 "no distance <1-255>",
8483 "Define an administrative distance\n"
8484 "OSPF Administrative distance\n")
8486 struct ospf
*ospf
= vty
->index
;
8491 ospf
->distance_all
= 0;
8496 DEFUN (no_ospf_distance_ospf
,
8497 no_ospf_distance_ospf_cmd
,
8498 "no distance ospf {intra-area <1-255>|inter-area <1-255>|external <1-255>}",
8500 "Define an administrative distance\n"
8501 "OSPF Administrative distance\n"
8502 "Intra-area routes\n"
8503 "Distance for intra-area routes\n"
8504 "Inter-area routes\n"
8505 "Distance for inter-area routes\n"
8507 "Distance for external routes\n")
8509 struct ospf
*ospf
= vty
->index
;
8520 if (argv
[0] != NULL
)
8521 ospf
->distance_intra
= 0;
8523 if (argv
[1] != NULL
)
8524 ospf
->distance_inter
= 0;
8526 if (argv
[2] != NULL
)
8527 ospf
->distance_external
= 0;
8529 if (argv
[0] || argv
[1] || argv
[2])
8532 /* If no arguments are given, clear all distance information */
8533 ospf
->distance_intra
= 0;
8534 ospf
->distance_inter
= 0;
8535 ospf
->distance_external
= 0;
8540 DEFUN (ospf_distance_ospf
,
8541 ospf_distance_ospf_cmd
,
8543 "{intra-area <1-255>|inter-area <1-255>|external <1-255>}",
8544 "Define an administrative distance\n"
8545 "OSPF Administrative distance\n"
8546 "Intra-area routes\n"
8547 "Distance for intra-area routes\n"
8548 "Inter-area routes\n"
8549 "Distance for inter-area routes\n"
8551 "Distance for external routes\n")
8553 struct ospf
*ospf
= vty
->index
;
8558 if (argc
< 3) /* should not happen */
8561 if (!argv
[0] && !argv
[1] && !argv
[2])
8563 vty_out(vty
, "%% Command incomplete. (Arguments required)%s",
8568 if (argv
[0] != NULL
)
8569 ospf
->distance_intra
= atoi(argv
[0]);
8571 if (argv
[1] != NULL
)
8572 ospf
->distance_inter
= atoi(argv
[1]);
8574 if (argv
[2] != NULL
)
8575 ospf
->distance_external
= atoi(argv
[2]);
8580 DEFUN (ospf_distance_source
,
8581 ospf_distance_source_cmd
,
8582 "distance <1-255> A.B.C.D/M",
8583 "Administrative distance\n"
8585 "IP source prefix\n")
8587 struct ospf
*ospf
= vty
->index
;
8592 ospf_distance_set (vty
, ospf
, argv
[0], argv
[1], NULL
);
8597 DEFUN (no_ospf_distance_source
,
8598 no_ospf_distance_source_cmd
,
8599 "no distance <1-255> A.B.C.D/M",
8601 "Administrative distance\n"
8603 "IP source prefix\n")
8605 struct ospf
*ospf
= vty
->index
;
8610 ospf_distance_unset (vty
, ospf
, argv
[0], argv
[1], NULL
);
8615 DEFUN (ospf_distance_source_access_list
,
8616 ospf_distance_source_access_list_cmd
,
8617 "distance <1-255> A.B.C.D/M WORD",
8618 "Administrative distance\n"
8620 "IP source prefix\n"
8621 "Access list name\n")
8623 struct ospf
*ospf
= vty
->index
;
8628 ospf_distance_set (vty
, ospf
, argv
[0], argv
[1], argv
[2]);
8633 DEFUN (no_ospf_distance_source_access_list
,
8634 no_ospf_distance_source_access_list_cmd
,
8635 "no distance <1-255> A.B.C.D/M WORD",
8637 "Administrative distance\n"
8639 "IP source prefix\n"
8640 "Access list name\n")
8642 struct ospf
*ospf
= vty
->index
;
8647 ospf_distance_unset (vty
, ospf
, argv
[0], argv
[1], argv
[2]);
8652 DEFUN (ip_ospf_mtu_ignore
,
8653 ip_ospf_mtu_ignore_addr_cmd
,
8654 "ip ospf mtu-ignore A.B.C.D",
8656 "OSPF interface commands\n"
8657 "Disable mtu mismatch detection\n"
8658 "Address of interface")
8660 struct interface
*ifp
= vty
->index
;
8661 struct in_addr addr
;
8664 struct ospf_if_params
*params
;
8665 params
= IF_DEF_PARAMS (ifp
);
8669 ret
= inet_aton(argv
[0], &addr
);
8672 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
8676 params
= ospf_get_if_params (ifp
, addr
);
8677 ospf_if_update_params (ifp
, addr
);
8679 params
->mtu_ignore
= 1;
8680 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
8681 SET_IF_PARAM (params
, mtu_ignore
);
8684 UNSET_IF_PARAM (params
, mtu_ignore
);
8685 if (params
!= IF_DEF_PARAMS (ifp
))
8687 ospf_free_if_params (ifp
, addr
);
8688 ospf_if_update_params (ifp
, addr
);
8694 ALIAS (ip_ospf_mtu_ignore
,
8695 ip_ospf_mtu_ignore_cmd
,
8696 "ip ospf mtu-ignore",
8698 "OSPF interface commands\n"
8699 "Disable mtu mismatch detection\n")
8702 DEFUN (no_ip_ospf_mtu_ignore
,
8703 no_ip_ospf_mtu_ignore_addr_cmd
,
8704 "no ip ospf mtu-ignore A.B.C.D",
8706 "OSPF interface commands\n"
8707 "Disable mtu mismatch detection\n"
8708 "Address of interface")
8710 struct interface
*ifp
= vty
->index
;
8711 struct in_addr addr
;
8714 struct ospf_if_params
*params
;
8715 params
= IF_DEF_PARAMS (ifp
);
8719 ret
= inet_aton(argv
[0], &addr
);
8722 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
8726 params
= ospf_get_if_params (ifp
, addr
);
8727 ospf_if_update_params (ifp
, addr
);
8729 params
->mtu_ignore
= 0;
8730 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
8731 SET_IF_PARAM (params
, mtu_ignore
);
8734 UNSET_IF_PARAM (params
, mtu_ignore
);
8735 if (params
!= IF_DEF_PARAMS (ifp
))
8737 ospf_free_if_params (ifp
, addr
);
8738 ospf_if_update_params (ifp
, addr
);
8744 ALIAS (no_ip_ospf_mtu_ignore
,
8745 no_ip_ospf_mtu_ignore_cmd
,
8746 "no ip ospf mtu-ignore",
8748 "OSPF interface commands\n"
8749 "Disable mtu mismatch detection\n")
8751 DEFUN (ospf_max_metric_router_lsa_admin
,
8752 ospf_max_metric_router_lsa_admin_cmd
,
8753 "max-metric router-lsa administrative",
8754 "OSPF maximum / infinite-distance metric\n"
8755 "Advertise own Router-LSA with infinite distance (stub router)\n"
8756 "Administratively applied, for an indefinite period\n")
8758 struct listnode
*ln
;
8759 struct ospf_area
*area
;
8760 struct ospf
*ospf
= vty
->index
;
8765 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
8767 SET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
8769 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
))
8770 ospf_router_lsa_update_area (area
);
8773 /* Allows for areas configured later to get the property */
8774 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_SET
;
8779 DEFUN (no_ospf_max_metric_router_lsa_admin
,
8780 no_ospf_max_metric_router_lsa_admin_cmd
,
8781 "no max-metric router-lsa administrative",
8783 "OSPF maximum / infinite-distance metric\n"
8784 "Advertise own Router-LSA with infinite distance (stub router)\n"
8785 "Administratively applied, for an indefinite period\n")
8787 struct listnode
*ln
;
8788 struct ospf_area
*area
;
8789 struct ospf
*ospf
= vty
->index
;
8794 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
8796 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
8798 /* Don't trample on the start-up stub timer */
8799 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
)
8800 && !area
->t_stub_router
)
8802 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
8803 ospf_router_lsa_update_area (area
);
8806 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET
;
8810 DEFUN (ospf_max_metric_router_lsa_startup
,
8811 ospf_max_metric_router_lsa_startup_cmd
,
8812 "max-metric router-lsa on-startup <5-86400>",
8813 "OSPF maximum / infinite-distance metric\n"
8814 "Advertise own Router-LSA with infinite distance (stub router)\n"
8815 "Automatically advertise stub Router-LSA on startup of OSPF\n"
8816 "Time (seconds) to advertise self as stub-router\n")
8818 unsigned int seconds
;
8819 struct ospf
*ospf
= vty
->index
;
8826 vty_out (vty
, "%% Must supply stub-router period");
8830 VTY_GET_INTEGER ("stub-router startup period", seconds
, argv
[0]);
8832 ospf
->stub_router_startup_time
= seconds
;
8837 DEFUN (no_ospf_max_metric_router_lsa_startup
,
8838 no_ospf_max_metric_router_lsa_startup_cmd
,
8839 "no max-metric router-lsa on-startup <5-86400>",
8841 "OSPF maximum / infinite-distance metric\n"
8842 "Advertise own Router-LSA with infinite distance (stub router)\n"
8843 "Automatically advertise stub Router-LSA on startup of OSPF\n"
8844 "Time (seconds) to advertise self as stub-router\n")
8846 struct listnode
*ln
;
8847 struct ospf_area
*area
;
8848 struct ospf
*ospf
= vty
->index
;
8853 ospf
->stub_router_startup_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
8855 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
8857 SET_FLAG (area
->stub_router_state
, OSPF_AREA_WAS_START_STUB_ROUTED
);
8858 OSPF_TIMER_OFF (area
->t_stub_router
);
8860 /* Don't trample on admin stub routed */
8861 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
8863 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
8864 ospf_router_lsa_update_area (area
);
8870 ALIAS (no_ospf_max_metric_router_lsa_startup
,
8871 no_ospf_max_metric_router_lsa_startup_no_param_cmd
,
8872 "no max-metric router-lsa on-startup",
8874 "OSPF maximum / infinite-distance metric\n"
8875 "Advertise own Router-LSA with infinite distance (stub router)\n"
8876 "Automatically advertise stub Router-LSA on startup of OSPF\n");
8878 DEFUN (ospf_max_metric_router_lsa_shutdown
,
8879 ospf_max_metric_router_lsa_shutdown_cmd
,
8880 "max-metric router-lsa on-shutdown <5-100>",
8881 "OSPF maximum / infinite-distance metric\n"
8882 "Advertise own Router-LSA with infinite distance (stub router)\n"
8883 "Advertise stub-router prior to full shutdown of OSPF\n"
8884 "Time (seconds) to wait till full shutdown\n")
8886 unsigned int seconds
;
8887 struct ospf
*ospf
= vty
->index
;
8894 vty_out (vty
, "%% Must supply stub-router shutdown period");
8898 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds
, argv
[0]);
8900 ospf
->stub_router_shutdown_time
= seconds
;
8905 DEFUN (no_ospf_max_metric_router_lsa_shutdown
,
8906 no_ospf_max_metric_router_lsa_shutdown_cmd
,
8907 "no max-metric router-lsa on-shutdown <5-100>",
8909 "OSPF maximum / infinite-distance metric\n"
8910 "Advertise own Router-LSA with infinite distance (stub router)\n"
8911 "Advertise stub-router prior to full shutdown of OSPF\n"
8912 "Time (seconds) to wait till full shutdown\n")
8914 struct ospf
*ospf
= vty
->index
;
8919 ospf
->stub_router_shutdown_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
8924 ALIAS (no_ospf_max_metric_router_lsa_shutdown
,
8925 no_ospf_max_metric_router_lsa_shutdown_no_param_cmd
,
8926 "no max-metric router-lsa on-shutdown",
8928 "OSPF maximum / infinite-distance metric\n"
8929 "Advertise own Router-LSA with infinite distance (stub router)\n"
8930 "Advertise stub-router prior to full shutdown of OSPF\n");
8933 config_write_stub_router (struct vty
*vty
, struct ospf
*ospf
)
8935 struct listnode
*ln
;
8936 struct ospf_area
*area
;
8938 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
8939 vty_out (vty
, " max-metric router-lsa on-startup %u%s",
8940 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
8941 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
8942 vty_out (vty
, " max-metric router-lsa on-shutdown %u%s",
8943 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
8944 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
8946 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
8948 vty_out (vty
, " max-metric router-lsa administrative%s",
8957 show_ip_ospf_route_network (struct vty
*vty
, struct route_table
*rt
)
8959 struct route_node
*rn
;
8960 struct ospf_route
*or;
8961 struct listnode
*pnode
, *pnnode
;
8962 struct ospf_path
*path
;
8964 vty_out (vty
, "============ OSPF network routing table ============%s",
8967 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
8968 if ((or = rn
->info
) != NULL
)
8971 snprintf (buf1
, 19, "%s/%d",
8972 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
8974 switch (or->path_type
)
8976 case OSPF_PATH_INTER_AREA
:
8977 if (or->type
== OSPF_DESTINATION_NETWORK
)
8978 vty_out (vty
, "N IA %-18s [%d] area: %s%s", buf1
, or->cost
,
8979 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
8980 else if (or->type
== OSPF_DESTINATION_DISCARD
)
8981 vty_out (vty
, "D IA %-18s Discard entry%s", buf1
, VTY_NEWLINE
);
8983 case OSPF_PATH_INTRA_AREA
:
8984 vty_out (vty
, "N %-18s [%d] area: %s%s", buf1
, or->cost
,
8985 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
8991 if (or->type
== OSPF_DESTINATION_NETWORK
)
8992 for (ALL_LIST_ELEMENTS (or->paths
, pnode
, pnnode
, path
))
8994 if (if_lookup_by_index(path
->ifindex
))
8996 if (path
->nexthop
.s_addr
== 0)
8997 vty_out (vty
, "%24s directly attached to %s%s",
8998 "", ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
9000 vty_out (vty
, "%24s via %s, %s%s", "",
9001 inet_ntoa (path
->nexthop
),
9002 ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
9006 vty_out (vty
, "%s", VTY_NEWLINE
);
9010 show_ip_ospf_route_router (struct vty
*vty
, struct route_table
*rtrs
)
9012 struct route_node
*rn
;
9013 struct ospf_route
*or;
9014 struct listnode
*pnode
;
9015 struct listnode
*node
;
9016 struct ospf_path
*path
;
9018 vty_out (vty
, "============ OSPF router routing table =============%s",
9020 for (rn
= route_top (rtrs
); rn
; rn
= route_next (rn
))
9025 vty_out (vty
, "R %-15s ", inet_ntoa (rn
->p
.u
.prefix4
));
9027 for (ALL_LIST_ELEMENTS_RO ((struct list
*)rn
->info
, node
, or))
9030 vty_out (vty
, "%24s", "");
9033 vty_out (vty
, "%s [%d] area: %s",
9034 (or->path_type
== OSPF_PATH_INTER_AREA
? "IA" : " "),
9035 or->cost
, inet_ntoa (or->u
.std
.area_id
));
9037 vty_out (vty
, "%s%s%s",
9038 (or->u
.std
.flags
& ROUTER_LSA_BORDER
? ", ABR" : ""),
9039 (or->u
.std
.flags
& ROUTER_LSA_EXTERNAL
? ", ASBR" : ""),
9042 for (ALL_LIST_ELEMENTS_RO (or->paths
, pnode
, path
))
9044 if (if_lookup_by_index(path
->ifindex
))
9046 if (path
->nexthop
.s_addr
== 0)
9047 vty_out (vty
, "%24s directly attached to %s%s",
9048 "", ifindex2ifname (path
->ifindex
),
9051 vty_out (vty
, "%24s via %s, %s%s", "",
9052 inet_ntoa (path
->nexthop
),
9053 ifindex2ifname (path
->ifindex
),
9059 vty_out (vty
, "%s", VTY_NEWLINE
);
9063 show_ip_ospf_route_external (struct vty
*vty
, struct route_table
*rt
)
9065 struct route_node
*rn
;
9066 struct ospf_route
*er
;
9067 struct listnode
*pnode
, *pnnode
;
9068 struct ospf_path
*path
;
9070 vty_out (vty
, "============ OSPF external routing table ===========%s",
9072 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
9073 if ((er
= rn
->info
) != NULL
)
9076 snprintf (buf1
, 19, "%s/%d",
9077 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
9079 switch (er
->path_type
)
9081 case OSPF_PATH_TYPE1_EXTERNAL
:
9082 vty_out (vty
, "N E1 %-18s [%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
,
9083 er
->cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
9085 case OSPF_PATH_TYPE2_EXTERNAL
:
9086 vty_out (vty
, "N E2 %-18s [%d/%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
, er
->cost
,
9087 er
->u
.ext
.type2_cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
9091 for (ALL_LIST_ELEMENTS (er
->paths
, pnode
, pnnode
, path
))
9093 if (if_lookup_by_index(path
->ifindex
))
9095 if (path
->nexthop
.s_addr
== 0)
9096 vty_out (vty
, "%24s directly attached to %s%s",
9097 "", ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
9099 vty_out (vty
, "%24s via %s, %s%s", "",
9100 inet_ntoa (path
->nexthop
),
9101 ifindex2ifname (path
->ifindex
),
9106 vty_out (vty
, "%s", VTY_NEWLINE
);
9110 show_ip_ospf_border_routers_common (struct vty
*vty
, struct ospf
*ospf
)
9113 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
9114 VTY_NEWLINE
, VTY_NEWLINE
);
9116 if (ospf
->new_table
== NULL
)
9118 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
9122 /* Show Network routes.
9123 show_ip_ospf_route_network (vty, ospf->new_table); */
9125 /* Show Router routes. */
9126 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
9128 vty_out (vty
, "%s", VTY_NEWLINE
);
9133 DEFUN (show_ip_ospf_border_routers
,
9134 show_ip_ospf_border_routers_cmd
,
9135 "show ip ospf border-routers",
9138 "OSPF information\n"
9139 "Show all the ABR's and ASBR's\n")
9143 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
9146 return show_ip_ospf_border_routers_common(vty
, ospf
);
9149 DEFUN (show_ip_ospf_instance_border_routers
,
9150 show_ip_ospf_instance_border_routers_cmd
,
9151 "show ip ospf <1-65535> border-routers",
9154 "OSPF information\n"
9156 "Show all the ABR's and ASBR's\n")
9159 u_short instance
= 0;
9161 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
9162 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
9165 return show_ip_ospf_border_routers_common(vty
, ospf
);
9169 show_ip_ospf_route_common (struct vty
*vty
, struct ospf
*ospf
)
9172 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
9173 VTY_NEWLINE
, VTY_NEWLINE
);
9175 if (ospf
->new_table
== NULL
)
9177 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
9181 /* Show Network routes. */
9182 show_ip_ospf_route_network (vty
, ospf
->new_table
);
9184 /* Show Router routes. */
9185 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
9187 /* Show AS External routes. */
9188 show_ip_ospf_route_external (vty
, ospf
->old_external_route
);
9190 vty_out (vty
, "%s", VTY_NEWLINE
);
9195 DEFUN (show_ip_ospf_route
,
9196 show_ip_ospf_route_cmd
,
9197 "show ip ospf route",
9200 "OSPF information\n"
9201 "OSPF routing table\n")
9205 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
9208 return show_ip_ospf_route_common(vty
, ospf
);
9211 DEFUN (show_ip_ospf_instance_route
,
9212 show_ip_ospf_instance_route_cmd
,
9213 "show ip ospf <1-65535> route",
9216 "OSPF information\n"
9218 "OSPF routing table\n")
9221 u_short instance
= 0;
9223 VTY_GET_INTEGER ("Instance", instance
, argv
[0]);
9224 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
9227 return show_ip_ospf_route_common(vty
, ospf
);
9230 const char *ospf_abr_type_str
[] =
9239 const char *ospf_shortcut_mode_str
[] =
9248 area_id2str (char *buf
, int length
, struct ospf_area
*area
)
9250 memset (buf
, 0, length
);
9252 if (area
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
9253 strncpy (buf
, inet_ntoa (area
->area_id
), length
);
9255 sprintf (buf
, "%lu", (unsigned long) ntohl (area
->area_id
.s_addr
));
9259 const char *ospf_int_type_str
[] =
9261 "unknown", /* should never be used. */
9265 "point-to-multipoint",
9266 "virtual-link", /* should never be used. */
9270 /* Configuration write function for ospfd. */
9272 config_write_interface (struct vty
*vty
)
9274 struct listnode
*n1
, *n2
;
9275 struct interface
*ifp
;
9276 struct crypt_key
*ck
;
9278 struct route_node
*rn
= NULL
;
9279 struct ospf_if_params
*params
;
9280 struct ospf
*ospf
= ospf_lookup();
9282 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), n1
, ifp
))
9284 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
9287 if (ifp
->ifindex
== IFINDEX_DELETED
)
9290 vty_out (vty
, "!%s", VTY_NEWLINE
);
9291 vty_out (vty
, "interface %s%s", ifp
->name
,
9294 vty_out (vty
, " description %s%s", ifp
->desc
,
9299 params
= IF_DEF_PARAMS (ifp
);
9302 /* Interface Network print. */
9303 if (OSPF_IF_PARAM_CONFIGURED (params
, type
) &&
9304 params
->type
!= OSPF_IFTYPE_LOOPBACK
)
9306 if (params
->type
!= ospf_default_iftype(ifp
))
9308 vty_out (vty
, " ip ospf network %s",
9309 ospf_int_type_str
[params
->type
]);
9310 if (params
!= IF_DEF_PARAMS (ifp
))
9311 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9312 vty_out (vty
, "%s", VTY_NEWLINE
);
9316 /* OSPF interface authentication print */
9317 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_type
) &&
9318 params
->auth_type
!= OSPF_AUTH_NOTSET
)
9320 const char *auth_str
;
9322 /* Translation tables are not that much help here due to syntax
9323 of the simple option */
9324 switch (params
->auth_type
)
9327 case OSPF_AUTH_NULL
:
9331 case OSPF_AUTH_SIMPLE
:
9335 case OSPF_AUTH_CRYPTOGRAPHIC
:
9336 auth_str
= " message-digest";
9344 vty_out (vty
, " ip ospf authentication%s", auth_str
);
9345 if (params
!= IF_DEF_PARAMS (ifp
))
9346 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9347 vty_out (vty
, "%s", VTY_NEWLINE
);
9350 /* Simple Authentication Password print. */
9351 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_simple
) &&
9352 params
->auth_simple
[0] != '\0')
9354 vty_out (vty
, " ip ospf authentication-key %s",
9355 params
->auth_simple
);
9356 if (params
!= IF_DEF_PARAMS (ifp
))
9357 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9358 vty_out (vty
, "%s", VTY_NEWLINE
);
9361 /* Cryptographic Authentication Key print. */
9362 for (ALL_LIST_ELEMENTS_RO (params
->auth_crypt
, n2
, ck
))
9364 vty_out (vty
, " ip ospf message-digest-key %d md5 %s",
9365 ck
->key_id
, ck
->auth_key
);
9366 if (params
!= IF_DEF_PARAMS (ifp
))
9367 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9368 vty_out (vty
, "%s", VTY_NEWLINE
);
9371 /* Interface Output Cost print. */
9372 if (OSPF_IF_PARAM_CONFIGURED (params
, output_cost_cmd
))
9374 vty_out (vty
, " ip ospf cost %u", params
->output_cost_cmd
);
9375 if (params
!= IF_DEF_PARAMS (ifp
))
9376 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9377 vty_out (vty
, "%s", VTY_NEWLINE
);
9380 /* Hello Interval print. */
9381 if (OSPF_IF_PARAM_CONFIGURED (params
, v_hello
) &&
9382 params
->v_hello
!= OSPF_HELLO_INTERVAL_DEFAULT
)
9384 vty_out (vty
, " ip ospf hello-interval %u", params
->v_hello
);
9385 if (params
!= IF_DEF_PARAMS (ifp
))
9386 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9387 vty_out (vty
, "%s", VTY_NEWLINE
);
9391 /* Router Dead Interval print. */
9392 if (OSPF_IF_PARAM_CONFIGURED (params
, v_wait
) &&
9393 params
->v_wait
!= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
)
9395 vty_out (vty
, " ip ospf dead-interval ");
9398 if (OSPF_IF_PARAM_CONFIGURED (params
, fast_hello
))
9399 vty_out (vty
, "minimal hello-multiplier %d",
9400 params
->fast_hello
);
9402 vty_out (vty
, "%u", params
->v_wait
);
9404 if (params
!= IF_DEF_PARAMS (ifp
))
9405 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9406 vty_out (vty
, "%s", VTY_NEWLINE
);
9409 /* Router Priority print. */
9410 if (OSPF_IF_PARAM_CONFIGURED (params
, priority
) &&
9411 params
->priority
!= OSPF_ROUTER_PRIORITY_DEFAULT
)
9413 vty_out (vty
, " ip ospf priority %u", params
->priority
);
9414 if (params
!= IF_DEF_PARAMS (ifp
))
9415 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9416 vty_out (vty
, "%s", VTY_NEWLINE
);
9419 /* Retransmit Interval print. */
9420 if (OSPF_IF_PARAM_CONFIGURED (params
, retransmit_interval
) &&
9421 params
->retransmit_interval
!= OSPF_RETRANSMIT_INTERVAL_DEFAULT
)
9423 vty_out (vty
, " ip ospf retransmit-interval %u",
9424 params
->retransmit_interval
);
9425 if (params
!= IF_DEF_PARAMS (ifp
))
9426 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9427 vty_out (vty
, "%s", VTY_NEWLINE
);
9430 /* Transmit Delay print. */
9431 if (OSPF_IF_PARAM_CONFIGURED (params
, transmit_delay
) &&
9432 params
->transmit_delay
!= OSPF_TRANSMIT_DELAY_DEFAULT
)
9434 vty_out (vty
, " ip ospf transmit-delay %u", params
->transmit_delay
);
9435 if (params
!= IF_DEF_PARAMS (ifp
))
9436 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9437 vty_out (vty
, "%s", VTY_NEWLINE
);
9441 if (OSPF_IF_PARAM_CONFIGURED (params
, if_area
))
9444 vty_out (vty
, " ip ospf %d area %s%s", ospf
->instance
,
9445 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
9447 vty_out (vty
, " ip ospf area %s%s",
9448 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
9453 ospf_bfd_write_config(vty
, params
);
9455 /* MTU ignore print. */
9456 if (OSPF_IF_PARAM_CONFIGURED (params
, mtu_ignore
) &&
9457 params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
9459 if (params
->mtu_ignore
== 0)
9460 vty_out (vty
, " no ip ospf mtu-ignore");
9462 vty_out (vty
, " ip ospf mtu-ignore");
9463 if (params
!= IF_DEF_PARAMS (ifp
))
9464 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
9465 vty_out (vty
, "%s", VTY_NEWLINE
);
9472 rn
= route_top (IF_OIFS_PARAMS (ifp
));
9474 rn
= route_next (rn
);
9484 ospf_opaque_config_write_if (vty
, ifp
);
9491 config_write_network_area (struct vty
*vty
, struct ospf
*ospf
)
9493 struct route_node
*rn
;
9494 u_char buf
[INET_ADDRSTRLEN
];
9496 /* `network area' print. */
9497 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
9500 struct ospf_network
*n
= rn
->info
;
9502 memset (buf
, 0, INET_ADDRSTRLEN
);
9504 /* Create Area ID string by specified Area ID format. */
9505 if (n
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
9506 strncpy ((char *) buf
, inet_ntoa (n
->area_id
), INET_ADDRSTRLEN
);
9508 sprintf ((char *) buf
, "%lu",
9509 (unsigned long int) ntohl (n
->area_id
.s_addr
));
9511 /* Network print. */
9512 vty_out (vty
, " network %s/%d area %s%s",
9513 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
9521 config_write_ospf_area (struct vty
*vty
, struct ospf
*ospf
)
9523 struct listnode
*node
;
9524 struct ospf_area
*area
;
9525 u_char buf
[INET_ADDRSTRLEN
];
9527 /* Area configuration print. */
9528 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
9530 struct route_node
*rn1
;
9532 area_id2str ((char *) buf
, INET_ADDRSTRLEN
, area
);
9534 if (area
->auth_type
!= OSPF_AUTH_NULL
)
9536 if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
9537 vty_out (vty
, " area %s authentication%s", buf
, VTY_NEWLINE
);
9539 vty_out (vty
, " area %s authentication message-digest%s",
9543 if (area
->shortcut_configured
!= OSPF_SHORTCUT_DEFAULT
)
9544 vty_out (vty
, " area %s shortcut %s%s", buf
,
9545 ospf_shortcut_mode_str
[area
->shortcut_configured
],
9548 if ((area
->external_routing
== OSPF_AREA_STUB
)
9549 || (area
->external_routing
== OSPF_AREA_NSSA
)
9552 if (area
->external_routing
== OSPF_AREA_STUB
)
9553 vty_out (vty
, " area %s stub", buf
);
9554 else if (area
->external_routing
== OSPF_AREA_NSSA
)
9556 vty_out (vty
, " area %s nssa", buf
);
9557 switch (area
->NSSATranslatorRole
)
9559 case OSPF_NSSA_ROLE_NEVER
:
9560 vty_out (vty
, " translate-never");
9562 case OSPF_NSSA_ROLE_ALWAYS
:
9563 vty_out (vty
, " translate-always");
9565 case OSPF_NSSA_ROLE_CANDIDATE
:
9567 vty_out (vty
, " translate-candidate");
9571 if (area
->no_summary
)
9572 vty_out (vty
, " no-summary");
9574 vty_out (vty
, "%s", VTY_NEWLINE
);
9576 if (area
->default_cost
!= 1)
9577 vty_out (vty
, " area %s default-cost %d%s", buf
,
9578 area
->default_cost
, VTY_NEWLINE
);
9581 for (rn1
= route_top (area
->ranges
); rn1
; rn1
= route_next (rn1
))
9584 struct ospf_area_range
*range
= rn1
->info
;
9586 vty_out (vty
, " area %s range %s/%d", buf
,
9587 inet_ntoa (rn1
->p
.u
.prefix4
), rn1
->p
.prefixlen
);
9589 if (range
->cost_config
!= OSPF_AREA_RANGE_COST_UNSPEC
)
9590 vty_out (vty
, " cost %d", range
->cost_config
);
9592 if (!CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_ADVERTISE
))
9593 vty_out (vty
, " not-advertise");
9595 if (CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_SUBSTITUTE
))
9596 vty_out (vty
, " substitute %s/%d",
9597 inet_ntoa (range
->subst_addr
), range
->subst_masklen
);
9599 vty_out (vty
, "%s", VTY_NEWLINE
);
9602 if (EXPORT_NAME (area
))
9603 vty_out (vty
, " area %s export-list %s%s", buf
,
9604 EXPORT_NAME (area
), VTY_NEWLINE
);
9606 if (IMPORT_NAME (area
))
9607 vty_out (vty
, " area %s import-list %s%s", buf
,
9608 IMPORT_NAME (area
), VTY_NEWLINE
);
9610 if (PREFIX_NAME_IN (area
))
9611 vty_out (vty
, " area %s filter-list prefix %s in%s", buf
,
9612 PREFIX_NAME_IN (area
), VTY_NEWLINE
);
9614 if (PREFIX_NAME_OUT (area
))
9615 vty_out (vty
, " area %s filter-list prefix %s out%s", buf
,
9616 PREFIX_NAME_OUT (area
), VTY_NEWLINE
);
9623 config_write_ospf_nbr_nbma (struct vty
*vty
, struct ospf
*ospf
)
9625 struct ospf_nbr_nbma
*nbr_nbma
;
9626 struct route_node
*rn
;
9628 /* Static Neighbor configuration print. */
9629 for (rn
= route_top (ospf
->nbr_nbma
); rn
; rn
= route_next (rn
))
9630 if ((nbr_nbma
= rn
->info
))
9632 vty_out (vty
, " neighbor %s", inet_ntoa (nbr_nbma
->addr
));
9634 if (nbr_nbma
->priority
!= OSPF_NEIGHBOR_PRIORITY_DEFAULT
)
9635 vty_out (vty
, " priority %d", nbr_nbma
->priority
);
9637 if (nbr_nbma
->v_poll
!= OSPF_POLL_INTERVAL_DEFAULT
)
9638 vty_out (vty
, " poll-interval %d", nbr_nbma
->v_poll
);
9640 vty_out (vty
, "%s", VTY_NEWLINE
);
9647 config_write_virtual_link (struct vty
*vty
, struct ospf
*ospf
)
9649 struct listnode
*node
;
9650 struct ospf_vl_data
*vl_data
;
9651 u_char buf
[INET_ADDRSTRLEN
];
9653 /* Virtual-Link print */
9654 for (ALL_LIST_ELEMENTS_RO (ospf
->vlinks
, node
, vl_data
))
9656 struct listnode
*n2
;
9657 struct crypt_key
*ck
;
9658 struct ospf_interface
*oi
;
9660 if (vl_data
!= NULL
)
9662 memset (buf
, 0, INET_ADDRSTRLEN
);
9664 if (vl_data
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
9665 strncpy ((char *) buf
, inet_ntoa (vl_data
->vl_area_id
), INET_ADDRSTRLEN
);
9667 sprintf ((char *) buf
, "%lu",
9668 (unsigned long int) ntohl (vl_data
->vl_area_id
.s_addr
));
9669 oi
= vl_data
->vl_oi
;
9672 if (OSPF_IF_PARAM (oi
, v_hello
) != OSPF_HELLO_INTERVAL_DEFAULT
||
9673 OSPF_IF_PARAM (oi
, v_wait
) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
||
9674 OSPF_IF_PARAM (oi
, retransmit_interval
) != OSPF_RETRANSMIT_INTERVAL_DEFAULT
||
9675 OSPF_IF_PARAM (oi
, transmit_delay
) != OSPF_TRANSMIT_DELAY_DEFAULT
)
9676 vty_out (vty
, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
9678 inet_ntoa (vl_data
->vl_peer
),
9679 OSPF_IF_PARAM (oi
, v_hello
),
9680 OSPF_IF_PARAM (oi
, retransmit_interval
),
9681 OSPF_IF_PARAM (oi
, transmit_delay
),
9682 OSPF_IF_PARAM (oi
, v_wait
),
9685 vty_out (vty
, " area %s virtual-link %s%s", buf
,
9686 inet_ntoa (vl_data
->vl_peer
), VTY_NEWLINE
);
9688 if (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
[0] != '\0')
9689 vty_out (vty
, " area %s virtual-link %s authentication-key %s%s",
9691 inet_ntoa (vl_data
->vl_peer
),
9692 IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
,
9695 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_crypt
,
9697 vty_out (vty
, " area %s virtual-link %s"
9698 " message-digest-key %d md5 %s%s",
9700 inet_ntoa (vl_data
->vl_peer
),
9701 ck
->key_id
, ck
->auth_key
, VTY_NEWLINE
);
9711 config_write_ospf_redistribute (struct vty
*vty
, struct ospf
*ospf
)
9715 /* redistribute print. */
9716 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
9718 struct list
*red_list
;
9719 struct listnode
*node
;
9720 struct ospf_redist
*red
;
9722 red_list
= ospf
->redist
[type
];
9726 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
))
9728 vty_out (vty
, " redistribute %s", zebra_route_string(type
));
9730 vty_out (vty
, " %d", red
->instance
);
9732 if (red
->dmetric
.value
>= 0)
9733 vty_out (vty
, " metric %d", red
->dmetric
.value
);
9735 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
9736 vty_out (vty
, " metric-type 1");
9738 if (ROUTEMAP_NAME (red
))
9739 vty_out (vty
, " route-map %s", ROUTEMAP_NAME (red
));
9741 vty_out (vty
, "%s", VTY_NEWLINE
);
9749 config_write_ospf_default_metric (struct vty
*vty
, struct ospf
*ospf
)
9751 if (ospf
->default_metric
!= -1)
9752 vty_out (vty
, " default-metric %d%s", ospf
->default_metric
,
9758 config_write_ospf_distribute (struct vty
*vty
, struct ospf
*ospf
)
9761 struct ospf_redist
*red
;
9765 /* distribute-list print. */
9766 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
9767 if (DISTRIBUTE_NAME (ospf
, type
))
9768 vty_out (vty
, " distribute-list %s out %s%s",
9769 DISTRIBUTE_NAME (ospf
, type
),
9770 zebra_route_string(type
), VTY_NEWLINE
);
9772 /* default-information print. */
9773 if (ospf
->default_originate
!= DEFAULT_ORIGINATE_NONE
)
9775 vty_out (vty
, " default-information originate");
9776 if (ospf
->default_originate
== DEFAULT_ORIGINATE_ALWAYS
)
9777 vty_out (vty
, " always");
9779 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
9782 if (red
->dmetric
.value
>= 0)
9783 vty_out (vty
, " metric %d",
9784 red
->dmetric
.value
);
9785 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
9786 vty_out (vty
, " metric-type 1");
9788 if (ROUTEMAP_NAME (red
))
9789 vty_out (vty
, " route-map %s",
9790 ROUTEMAP_NAME (red
));
9793 vty_out (vty
, "%s", VTY_NEWLINE
);
9802 config_write_ospf_distance (struct vty
*vty
, struct ospf
*ospf
)
9804 struct route_node
*rn
;
9805 struct ospf_distance
*odistance
;
9807 if (ospf
->distance_all
)
9808 vty_out (vty
, " distance %d%s", ospf
->distance_all
, VTY_NEWLINE
);
9810 if (ospf
->distance_intra
9811 || ospf
->distance_inter
9812 || ospf
->distance_external
)
9814 vty_out (vty
, " distance ospf");
9816 if (ospf
->distance_intra
)
9817 vty_out (vty
, " intra-area %d", ospf
->distance_intra
);
9818 if (ospf
->distance_inter
)
9819 vty_out (vty
, " inter-area %d", ospf
->distance_inter
);
9820 if (ospf
->distance_external
)
9821 vty_out (vty
, " external %d", ospf
->distance_external
);
9823 vty_out (vty
, "%s", VTY_NEWLINE
);
9826 for (rn
= route_top (ospf
->distance_table
); rn
; rn
= route_next (rn
))
9827 if ((odistance
= rn
->info
) != NULL
)
9829 vty_out (vty
, " distance %d %s/%d %s%s", odistance
->distance
,
9830 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
9831 odistance
->access_list
? odistance
->access_list
: "",
9837 /* OSPF configuration write function. */
9839 ospf_config_write (struct vty
*vty
)
9842 struct interface
*ifp
;
9843 struct ospf_interface
*oi
;
9844 struct listnode
*node
;
9847 ospf
= ospf_lookup ();
9848 if (ospf
!= NULL
&& ospf
->oi_running
)
9850 /* `router ospf' print. */
9852 vty_out (vty
, "router ospf %d%s", ospf
->instance
, VTY_NEWLINE
);
9854 vty_out (vty
, "router ospf%s", VTY_NEWLINE
);
9858 if (!ospf
->networks
)
9861 /* Router ID print. */
9862 if (ospf
->router_id_static
.s_addr
!= 0)
9863 vty_out (vty
, " ospf router-id %s%s",
9864 inet_ntoa (ospf
->router_id_static
), VTY_NEWLINE
);
9866 /* ABR type print. */
9867 if (ospf
->abr_type
!= OSPF_ABR_DEFAULT
)
9868 vty_out (vty
, " ospf abr-type %s%s",
9869 ospf_abr_type_str
[ospf
->abr_type
], VTY_NEWLINE
);
9871 /* log-adjacency-changes flag print. */
9872 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
))
9874 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
9875 vty_out(vty
, " log-adjacency-changes detail%s", VTY_NEWLINE
);
9879 vty_out(vty
, " no log-adjacency-changes%s", VTY_NEWLINE
);
9882 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
9883 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
9884 vty_out (vty
, " compatible rfc1583%s", VTY_NEWLINE
);
9886 /* auto-cost reference-bandwidth configuration. */
9887 if (ospf
->ref_bandwidth
!= OSPF_DEFAULT_REF_BANDWIDTH
)
9889 vty_out (vty
, "! Important: ensure reference bandwidth "
9890 "is consistent across all routers%s", VTY_NEWLINE
);
9891 vty_out (vty
, " auto-cost reference-bandwidth %d%s",
9892 ospf
->ref_bandwidth
, VTY_NEWLINE
);
9895 /* SPF timers print. */
9896 if (ospf
->spf_delay
!= OSPF_SPF_DELAY_DEFAULT
||
9897 ospf
->spf_holdtime
!= OSPF_SPF_HOLDTIME_DEFAULT
||
9898 ospf
->spf_max_holdtime
!= OSPF_SPF_MAX_HOLDTIME_DEFAULT
)
9899 vty_out (vty
, " timers throttle spf %d %d %d%s",
9900 ospf
->spf_delay
, ospf
->spf_holdtime
,
9901 ospf
->spf_max_holdtime
, VTY_NEWLINE
);
9903 /* LSA timers print. */
9904 if (ospf
->min_ls_interval
!= OSPF_MIN_LS_INTERVAL
)
9905 vty_out (vty
, " timers throttle lsa all %d%s",
9906 ospf
->min_ls_interval
, VTY_NEWLINE
);
9907 if (ospf
->min_ls_arrival
!= OSPF_MIN_LS_ARRIVAL
)
9908 vty_out (vty
, " timers lsa min-arrival %d%s",
9909 ospf
->min_ls_arrival
, VTY_NEWLINE
);
9911 /* Write multiplier print. */
9912 if (ospf
->write_oi_count
!= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
)
9913 vty_out (vty
, " ospf write-multiplier %d%s",
9914 ospf
->write_oi_count
, VTY_NEWLINE
);
9916 /* Max-metric router-lsa print */
9917 config_write_stub_router (vty
, ospf
);
9919 /* SPF refresh parameters print. */
9920 if (ospf
->lsa_refresh_interval
!= OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
9921 vty_out (vty
, " refresh timer %d%s",
9922 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
9924 /* Redistribute information print. */
9925 config_write_ospf_redistribute (vty
, ospf
);
9927 /* passive-interface print. */
9928 if (ospf
->passive_interface_default
== OSPF_IF_PASSIVE
)
9929 vty_out (vty
, " passive-interface default%s", VTY_NEWLINE
);
9931 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, node
, ifp
))
9932 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
)
9933 && IF_DEF_PARAMS (ifp
)->passive_interface
!=
9934 ospf
->passive_interface_default
)
9936 vty_out (vty
, " %spassive-interface %s%s",
9937 IF_DEF_PARAMS (ifp
)->passive_interface
? "" : "no ",
9938 ifp
->name
, VTY_NEWLINE
);
9940 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
9942 if (!OSPF_IF_PARAM_CONFIGURED (oi
->params
, passive_interface
))
9944 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi
->ifp
),
9947 if (oi
->params
->passive_interface
== IF_DEF_PARAMS (oi
->ifp
)->passive_interface
)
9950 else if (oi
->params
->passive_interface
== ospf
->passive_interface_default
)
9953 vty_out (vty
, " %spassive-interface %s %s%s",
9954 oi
->params
->passive_interface
? "" : "no ",
9956 inet_ntoa (oi
->address
->u
.prefix4
), VTY_NEWLINE
);
9959 /* Network area print. */
9960 config_write_network_area (vty
, ospf
);
9962 /* Area config print. */
9963 config_write_ospf_area (vty
, ospf
);
9965 /* static neighbor print. */
9966 config_write_ospf_nbr_nbma (vty
, ospf
);
9968 /* Virtual-Link print. */
9969 config_write_virtual_link (vty
, ospf
);
9971 /* Default metric configuration. */
9972 config_write_ospf_default_metric (vty
, ospf
);
9974 /* Distribute-list and default-information print. */
9975 config_write_ospf_distribute (vty
, ospf
);
9977 /* Distance configuration. */
9978 config_write_ospf_distance (vty
, ospf
);
9980 ospf_opaque_config_write_router (vty
, ospf
);
9987 ospf_vty_show_init (void)
9989 /* "show ip ospf" commands. */
9990 install_element (VIEW_NODE
, &show_ip_ospf_cmd
);
9992 install_element (VIEW_NODE
, &show_ip_ospf_instance_cmd
);
9994 /* "show ip ospf database" commands. */
9995 install_element (VIEW_NODE
, &show_ip_ospf_database_type_cmd
);
9996 install_element (VIEW_NODE
, &show_ip_ospf_database_type_id_cmd
);
9997 install_element (VIEW_NODE
, &show_ip_ospf_database_type_id_adv_router_cmd
);
9998 install_element (VIEW_NODE
, &show_ip_ospf_database_type_adv_router_cmd
);
9999 install_element (VIEW_NODE
, &show_ip_ospf_database_type_id_self_cmd
);
10000 install_element (VIEW_NODE
, &show_ip_ospf_database_type_self_cmd
);
10001 install_element (VIEW_NODE
, &show_ip_ospf_database_cmd
);
10003 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_cmd
);
10004 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_id_cmd
);
10005 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_id_adv_router_cmd
);
10006 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_adv_router_cmd
);
10007 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_id_self_cmd
);
10008 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_self_cmd
);
10009 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_cmd
);
10011 /* "show ip ospf interface" commands. */
10012 install_element (VIEW_NODE
, &show_ip_ospf_interface_cmd
);
10014 install_element (VIEW_NODE
, &show_ip_ospf_instance_interface_cmd
);
10016 /* "show ip ospf neighbor" commands. */
10017 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_detail_cmd
);
10018 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_cmd
);
10019 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_id_cmd
);
10020 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_all_cmd
);
10021 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_cmd
);
10022 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_cmd
);
10023 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_all_cmd
);
10025 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_detail_cmd
);
10026 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_cmd
);
10027 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_id_cmd
);
10028 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_all_cmd
);
10029 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_cmd
);
10030 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_cmd
);
10031 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_all_cmd
);
10033 /* "show ip ospf route" commands. */
10034 install_element (VIEW_NODE
, &show_ip_ospf_route_cmd
);
10035 install_element (VIEW_NODE
, &show_ip_ospf_border_routers_cmd
);
10037 install_element (VIEW_NODE
, &show_ip_ospf_instance_route_cmd
);
10038 install_element (VIEW_NODE
, &show_ip_ospf_instance_border_routers_cmd
);
10042 /* ospfd's interface node. */
10043 static struct cmd_node interface_node
=
10050 /* Initialization of OSPF interface. */
10052 ospf_vty_if_init (void)
10054 /* Install interface node. */
10055 install_node (&interface_node
, config_write_interface
);
10057 install_element (CONFIG_NODE
, &interface_cmd
);
10058 install_element (CONFIG_NODE
, &no_interface_cmd
);
10059 install_default (INTERFACE_NODE
);
10061 /* "description" commands. */
10062 install_element (INTERFACE_NODE
, &interface_desc_cmd
);
10063 install_element (INTERFACE_NODE
, &no_interface_desc_cmd
);
10065 /* "ip ospf authentication" commands. */
10066 install_element (INTERFACE_NODE
, &ip_ospf_authentication_args_addr_cmd
);
10067 install_element (INTERFACE_NODE
, &ip_ospf_authentication_args_cmd
);
10068 install_element (INTERFACE_NODE
, &ip_ospf_authentication_addr_cmd
);
10069 install_element (INTERFACE_NODE
, &ip_ospf_authentication_cmd
);
10070 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_args_addr_cmd
);
10071 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_args_cmd
);
10072 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_addr_cmd
);
10073 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_cmd
);
10074 install_element (INTERFACE_NODE
, &ip_ospf_authentication_key_addr_cmd
);
10075 install_element (INTERFACE_NODE
, &ip_ospf_authentication_key_cmd
);
10076 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_key_authkey_addr_cmd
);
10077 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_key_authkey_cmd
);
10078 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_key_cmd
);
10080 /* "ip ospf message-digest-key" commands. */
10081 install_element (INTERFACE_NODE
, &ip_ospf_message_digest_key_addr_cmd
);
10082 install_element (INTERFACE_NODE
, &ip_ospf_message_digest_key_cmd
);
10083 install_element (INTERFACE_NODE
, &no_ip_ospf_message_digest_key_addr_cmd
);
10084 install_element (INTERFACE_NODE
, &no_ip_ospf_message_digest_key_cmd
);
10085 install_element (INTERFACE_NODE
, &no_ip_ospf_message_digest_key_md5_addr_cmd
);
10086 install_element (INTERFACE_NODE
, &no_ip_ospf_message_digest_key_md5_cmd
);
10088 /* "ip ospf cost" commands. */
10089 install_element (INTERFACE_NODE
, &ip_ospf_cost_u32_inet4_cmd
);
10090 install_element (INTERFACE_NODE
, &ip_ospf_cost_u32_cmd
);
10091 install_element (INTERFACE_NODE
, &no_ip_ospf_cost_u32_cmd
);
10092 install_element (INTERFACE_NODE
, &no_ip_ospf_cost_u32_inet4_cmd
);
10093 install_element (INTERFACE_NODE
, &no_ip_ospf_cost_inet4_cmd
);
10094 install_element (INTERFACE_NODE
, &no_ip_ospf_cost_cmd
);
10096 /* "ip ospf mtu-ignore" commands. */
10097 install_element (INTERFACE_NODE
, &ip_ospf_mtu_ignore_addr_cmd
);
10098 install_element (INTERFACE_NODE
, &ip_ospf_mtu_ignore_cmd
);
10099 install_element (INTERFACE_NODE
, &no_ip_ospf_mtu_ignore_addr_cmd
);
10100 install_element (INTERFACE_NODE
, &no_ip_ospf_mtu_ignore_cmd
);
10102 /* "ip ospf dead-interval" commands. */
10103 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_addr_cmd
);
10104 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_cmd
);
10105 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_minimal_addr_cmd
);
10106 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_minimal_cmd
);
10107 install_element (INTERFACE_NODE
, &no_ip_ospf_dead_interval_addr_cmd
);
10108 install_element (INTERFACE_NODE
, &no_ip_ospf_dead_interval_cmd
);
10109 install_element (INTERFACE_NODE
, &no_ip_ospf_dead_interval_seconds_cmd
);
10111 /* "ip ospf hello-interval" commands. */
10112 install_element (INTERFACE_NODE
, &ip_ospf_hello_interval_addr_cmd
);
10113 install_element (INTERFACE_NODE
, &ip_ospf_hello_interval_cmd
);
10114 install_element (INTERFACE_NODE
, &no_ip_ospf_hello_interval_addr_cmd
);
10115 install_element (INTERFACE_NODE
, &no_ip_ospf_hello_interval_cmd
);
10116 install_element (INTERFACE_NODE
, &no_ip_ospf_hello_interval_seconds_cmd
);
10118 /* "ip ospf network" commands. */
10119 install_element (INTERFACE_NODE
, &ip_ospf_network_cmd
);
10120 install_element (INTERFACE_NODE
, &no_ip_ospf_network_cmd
);
10121 install_element (INTERFACE_NODE
, &no_ip_ospf_network_val_cmd
);
10123 /* "ip ospf priority" commands. */
10124 install_element (INTERFACE_NODE
, &ip_ospf_priority_addr_cmd
);
10125 install_element (INTERFACE_NODE
, &ip_ospf_priority_cmd
);
10126 install_element (INTERFACE_NODE
, &no_ip_ospf_priority_cmd
);
10127 install_element (INTERFACE_NODE
, &no_ip_ospf_priority_no_param_cmd
);
10128 install_element (INTERFACE_NODE
, &no_ip_ospf_priority_addr_cmd
);
10130 /* "ip ospf retransmit-interval" commands. */
10131 install_element (INTERFACE_NODE
, &ip_ospf_retransmit_interval_addr_cmd
);
10132 install_element (INTERFACE_NODE
, &ip_ospf_retransmit_interval_cmd
);
10133 install_element (INTERFACE_NODE
, &no_ip_ospf_retransmit_interval_addr_cmd
);
10134 install_element (INTERFACE_NODE
, &no_ip_ospf_retransmit_interval_cmd
);
10135 install_element (INTERFACE_NODE
, &no_ip_ospf_retransmit_interval_sec_addr_cmd
);
10136 install_element (INTERFACE_NODE
, &no_ip_ospf_retransmit_interval_sec_cmd
);
10138 /* "ip ospf transmit-delay" commands. */
10139 install_element (INTERFACE_NODE
, &ip_ospf_transmit_delay_addr_cmd
);
10140 install_element (INTERFACE_NODE
, &ip_ospf_transmit_delay_cmd
);
10141 install_element (INTERFACE_NODE
, &no_ip_ospf_transmit_delay_addr_cmd
);
10142 install_element (INTERFACE_NODE
, &no_ip_ospf_transmit_delay_cmd
);
10143 install_element (INTERFACE_NODE
, &no_ip_ospf_transmit_delay_sec_addr_cmd
);
10144 install_element (INTERFACE_NODE
, &no_ip_ospf_transmit_delay_sec_cmd
);
10146 /* "ip ospf area" commands. */
10147 install_element (INTERFACE_NODE
, &ip_ospf_area_cmd
);
10148 install_element (INTERFACE_NODE
, &no_ip_ospf_area_cmd
);
10149 install_element (INTERFACE_NODE
, &no_ip_ospf_area_val_cmd
);
10150 install_element (INTERFACE_NODE
, &ip_ospf_instance_area_cmd
);
10151 install_element (INTERFACE_NODE
, &no_ip_ospf_instance_area_cmd
);
10152 install_element (INTERFACE_NODE
, &no_ip_ospf_instance_area_val_cmd
);
10154 /* These commands are compatibitliy for previous version. */
10155 install_element (INTERFACE_NODE
, &ospf_authentication_key_cmd
);
10156 install_element (INTERFACE_NODE
, &no_ospf_authentication_key_cmd
);
10157 install_element (INTERFACE_NODE
, &no_ospf_authentication_key_authkey_cmd
);
10158 install_element (INTERFACE_NODE
, &no_ospf_authentication_key_authkey_ip_cmd
);
10159 install_element (INTERFACE_NODE
, &ospf_message_digest_key_cmd
);
10160 install_element (INTERFACE_NODE
, &no_ospf_message_digest_key_cmd
);
10161 install_element (INTERFACE_NODE
, &ospf_cost_u32_cmd
);
10162 install_element (INTERFACE_NODE
, &ospf_cost_u32_inet4_cmd
);
10163 install_element (INTERFACE_NODE
, &no_ospf_cost_cmd
);
10164 install_element (INTERFACE_NODE
, &no_ospf_cost_u32_cmd
);
10165 install_element (INTERFACE_NODE
, &no_ospf_cost_u32_inet4_cmd
);
10166 install_element (INTERFACE_NODE
, &no_ospf_cost_inet4_cmd
);
10167 install_element (INTERFACE_NODE
, &ospf_dead_interval_cmd
);
10168 install_element (INTERFACE_NODE
, &no_ospf_dead_interval_cmd
);
10169 install_element (INTERFACE_NODE
, &no_ip_ospf_dead_interval_minimal_addr_cmd
);
10170 install_element (INTERFACE_NODE
, &no_ip_ospf_dead_interval_minimal_cmd
);
10171 install_element (INTERFACE_NODE
, &ospf_hello_interval_cmd
);
10172 install_element (INTERFACE_NODE
, &no_ospf_hello_interval_cmd
);
10173 install_element (INTERFACE_NODE
, &ospf_network_cmd
);
10174 install_element (INTERFACE_NODE
, &no_ospf_network_cmd
);
10175 install_element (INTERFACE_NODE
, &no_ospf_network_val_cmd
);
10176 install_element (INTERFACE_NODE
, &ospf_priority_cmd
);
10177 install_element (INTERFACE_NODE
, &no_ospf_priority_cmd
);
10178 install_element (INTERFACE_NODE
, &ospf_retransmit_interval_cmd
);
10179 install_element (INTERFACE_NODE
, &no_ospf_retransmit_interval_cmd
);
10180 install_element (INTERFACE_NODE
, &ospf_transmit_delay_cmd
);
10181 install_element (INTERFACE_NODE
, &no_ospf_transmit_delay_cmd
);
10185 ospf_vty_zebra_init (void)
10187 install_element (OSPF_NODE
, &ospf_redistribute_source_cmd
);
10188 install_element (OSPF_NODE
, &no_ospf_redistribute_source_cmd
);
10189 install_element (OSPF_NODE
, &ospf_redistribute_instance_source_cmd
);
10190 install_element (OSPF_NODE
, &no_ospf_redistribute_instance_source_cmd
);
10192 install_element (OSPF_NODE
, &ospf_distribute_list_out_cmd
);
10193 install_element (OSPF_NODE
, &no_ospf_distribute_list_out_cmd
);
10195 install_element (OSPF_NODE
, &ospf_default_information_originate_cmd
);
10196 install_element (OSPF_NODE
, &no_ospf_default_information_originate_cmd
);
10198 install_element (OSPF_NODE
, &ospf_default_metric_cmd
);
10199 install_element (OSPF_NODE
, &no_ospf_default_metric_cmd
);
10200 install_element (OSPF_NODE
, &no_ospf_default_metric_val_cmd
);
10202 install_element (OSPF_NODE
, &ospf_distance_cmd
);
10203 install_element (OSPF_NODE
, &no_ospf_distance_cmd
);
10204 install_element (OSPF_NODE
, &no_ospf_distance_ospf_cmd
);
10205 install_element (OSPF_NODE
, &ospf_distance_ospf_cmd
);
10207 install_element (OSPF_NODE
, &ospf_distance_source_cmd
);
10208 install_element (OSPF_NODE
, &no_ospf_distance_source_cmd
);
10209 install_element (OSPF_NODE
, &ospf_distance_source_access_list_cmd
);
10210 install_element (OSPF_NODE
, &no_ospf_distance_source_access_list_cmd
);
10214 static struct cmd_node ospf_node
=
10217 "%s(config-router)# ",
10222 ospf_interface_clear (struct interface
*ifp
)
10224 if (!if_is_operative (ifp
)) return;
10226 if (IS_DEBUG_OSPF (ism
, ISM_EVENTS
))
10227 zlog (NULL
, LOG_DEBUG
, "ISM[%s]: clear by reset", ifp
->name
);
10229 ospf_if_reset(ifp
);
10232 DEFUN (clear_ip_ospf_interface
,
10233 clear_ip_ospf_interface_cmd
,
10234 "clear ip ospf interface [IFNAME]",
10237 "OSPF information\n"
10238 "Interface information\n"
10239 "Interface name\n")
10241 struct interface
*ifp
;
10242 struct listnode
*node
;
10244 if (argc
== 0) /* Clear all the ospfv2 interfaces. */
10246 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
10247 ospf_interface_clear(ifp
);
10249 else /* Interface name is specified. */
10251 if ((ifp
= if_lookup_by_name (argv
[0])) == NULL
)
10252 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
10254 ospf_interface_clear(ifp
);
10257 return CMD_SUCCESS
;
10261 ospf_vty_clear_init (void)
10263 install_element (ENABLE_NODE
, &clear_ip_ospf_interface_cmd
);
10267 /* Install OSPF related vty commands. */
10269 ospf_vty_init (void)
10271 /* Install ospf top node. */
10272 install_node (&ospf_node
, ospf_config_write
);
10274 /* "router ospf" commands. */
10275 install_element (CONFIG_NODE
, &router_ospf_cmd
);
10276 install_element (CONFIG_NODE
, &no_router_ospf_cmd
);
10278 install_element (CONFIG_NODE
, &router_ospf_instance_cmd
);
10279 install_element (CONFIG_NODE
, &no_router_ospf_instance_cmd
);
10281 install_default (OSPF_NODE
);
10283 /* "ospf router-id" commands. */
10284 install_element (OSPF_NODE
, &ospf_router_id_cmd
);
10285 install_element (OSPF_NODE
, &ospf_router_id_old_cmd
);
10286 install_element (OSPF_NODE
, &no_ospf_router_id_cmd
);
10287 install_element (OSPF_NODE
, &no_ospf_router_id_val_cmd
);
10289 /* "passive-interface" commands. */
10290 install_element (OSPF_NODE
, &ospf_passive_interface_addr_cmd
);
10291 install_element (OSPF_NODE
, &ospf_passive_interface_cmd
);
10292 install_element (OSPF_NODE
, &ospf_passive_interface_default_cmd
);
10293 install_element (OSPF_NODE
, &no_ospf_passive_interface_addr_cmd
);
10294 install_element (OSPF_NODE
, &no_ospf_passive_interface_cmd
);
10295 install_element (OSPF_NODE
, &no_ospf_passive_interface_default_cmd
);
10297 /* "ospf abr-type" commands. */
10298 install_element (OSPF_NODE
, &ospf_abr_type_cmd
);
10299 install_element (OSPF_NODE
, &no_ospf_abr_type_cmd
);
10301 /* "ospf log-adjacency-changes" commands. */
10302 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_cmd
);
10303 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_detail_cmd
);
10304 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_cmd
);
10305 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_detail_cmd
);
10307 /* "ospf rfc1583-compatible" commands. */
10308 install_element (OSPF_NODE
, &ospf_rfc1583_flag_cmd
);
10309 install_element (OSPF_NODE
, &no_ospf_rfc1583_flag_cmd
);
10310 install_element (OSPF_NODE
, &ospf_compatible_rfc1583_cmd
);
10311 install_element (OSPF_NODE
, &no_ospf_compatible_rfc1583_cmd
);
10313 /* "network area" commands. */
10314 install_element (OSPF_NODE
, &ospf_network_area_cmd
);
10315 install_element (OSPF_NODE
, &no_ospf_network_area_cmd
);
10317 /* "area authentication" commands. */
10318 install_element (OSPF_NODE
, &ospf_area_authentication_message_digest_cmd
);
10319 install_element (OSPF_NODE
, &ospf_area_authentication_cmd
);
10320 install_element (OSPF_NODE
, &no_ospf_area_authentication_cmd
);
10322 /* "area range" commands. */
10323 install_element (OSPF_NODE
, &ospf_area_range_cmd
);
10324 install_element (OSPF_NODE
, &ospf_area_range_advertise_cmd
);
10325 install_element (OSPF_NODE
, &ospf_area_range_cost_cmd
);
10326 install_element (OSPF_NODE
, &ospf_area_range_advertise_cost_cmd
);
10327 install_element (OSPF_NODE
, &ospf_area_range_not_advertise_cmd
);
10328 install_element (OSPF_NODE
, &no_ospf_area_range_cmd
);
10329 install_element (OSPF_NODE
, &no_ospf_area_range_advertise_cmd
);
10330 install_element (OSPF_NODE
, &no_ospf_area_range_cost_cmd
);
10331 install_element (OSPF_NODE
, &no_ospf_area_range_advertise_cost_cmd
);
10332 install_element (OSPF_NODE
, &ospf_area_range_substitute_cmd
);
10333 install_element (OSPF_NODE
, &no_ospf_area_range_substitute_cmd
);
10335 /* "area virtual-link" commands. */
10336 install_element (OSPF_NODE
, &ospf_area_vlink_cmd
);
10337 install_element (OSPF_NODE
, &no_ospf_area_vlink_cmd
);
10339 install_element (OSPF_NODE
, &ospf_area_vlink_param1_cmd
);
10340 install_element (OSPF_NODE
, &no_ospf_area_vlink_param1_cmd
);
10342 install_element (OSPF_NODE
, &ospf_area_vlink_param2_cmd
);
10343 install_element (OSPF_NODE
, &no_ospf_area_vlink_param2_cmd
);
10345 install_element (OSPF_NODE
, &ospf_area_vlink_param3_cmd
);
10346 install_element (OSPF_NODE
, &no_ospf_area_vlink_param3_cmd
);
10348 install_element (OSPF_NODE
, &ospf_area_vlink_param4_cmd
);
10349 install_element (OSPF_NODE
, &no_ospf_area_vlink_param4_cmd
);
10351 install_element (OSPF_NODE
, &ospf_area_vlink_authtype_args_cmd
);
10352 install_element (OSPF_NODE
, &no_ospf_area_vlink_authtype_args_cmd
);
10353 install_element (OSPF_NODE
, &ospf_area_vlink_authtype_cmd
);
10354 install_element (OSPF_NODE
, &no_ospf_area_vlink_authtype_cmd
);
10356 install_element (OSPF_NODE
, &ospf_area_vlink_md5_cmd
);
10357 install_element (OSPF_NODE
, &no_ospf_area_vlink_md5_cmd
);
10359 install_element (OSPF_NODE
, &ospf_area_vlink_authkey_cmd
);
10360 install_element (OSPF_NODE
, &no_ospf_area_vlink_authkey_cmd
);
10362 install_element (OSPF_NODE
, &ospf_area_vlink_authtype_args_authkey_cmd
);
10363 install_element (OSPF_NODE
, &no_ospf_area_vlink_authtype_args_authkey_cmd
);
10364 install_element (OSPF_NODE
, &ospf_area_vlink_authtype_authkey_cmd
);
10365 install_element (OSPF_NODE
, &no_ospf_area_vlink_authtype_authkey_cmd
);
10367 install_element (OSPF_NODE
, &ospf_area_vlink_authtype_args_md5_cmd
);
10368 install_element (OSPF_NODE
, &no_ospf_area_vlink_authtype_args_md5_cmd
);
10369 install_element (OSPF_NODE
, &ospf_area_vlink_authtype_md5_cmd
);
10370 install_element (OSPF_NODE
, &no_ospf_area_vlink_authtype_md5_cmd
);
10372 /* "area stub" commands. */
10373 install_element (OSPF_NODE
, &ospf_area_stub_no_summary_cmd
);
10374 install_element (OSPF_NODE
, &ospf_area_stub_cmd
);
10375 install_element (OSPF_NODE
, &no_ospf_area_stub_no_summary_cmd
);
10376 install_element (OSPF_NODE
, &no_ospf_area_stub_cmd
);
10378 /* "area nssa" commands. */
10379 install_element (OSPF_NODE
, &ospf_area_nssa_cmd
);
10380 install_element (OSPF_NODE
, &ospf_area_nssa_translate_no_summary_cmd
);
10381 install_element (OSPF_NODE
, &ospf_area_nssa_translate_cmd
);
10382 install_element (OSPF_NODE
, &ospf_area_nssa_no_summary_cmd
);
10383 install_element (OSPF_NODE
, &no_ospf_area_nssa_cmd
);
10384 install_element (OSPF_NODE
, &no_ospf_area_nssa_no_summary_cmd
);
10386 install_element (OSPF_NODE
, &ospf_area_default_cost_cmd
);
10387 install_element (OSPF_NODE
, &no_ospf_area_default_cost_cmd
);
10389 install_element (OSPF_NODE
, &ospf_area_shortcut_cmd
);
10390 install_element (OSPF_NODE
, &no_ospf_area_shortcut_cmd
);
10392 install_element (OSPF_NODE
, &ospf_area_export_list_cmd
);
10393 install_element (OSPF_NODE
, &no_ospf_area_export_list_cmd
);
10395 install_element (OSPF_NODE
, &ospf_area_filter_list_cmd
);
10396 install_element (OSPF_NODE
, &no_ospf_area_filter_list_cmd
);
10398 install_element (OSPF_NODE
, &ospf_area_import_list_cmd
);
10399 install_element (OSPF_NODE
, &no_ospf_area_import_list_cmd
);
10401 /* SPF timer commands */
10402 install_element (OSPF_NODE
, &ospf_timers_throttle_spf_cmd
);
10403 install_element (OSPF_NODE
, &no_ospf_timers_throttle_spf_cmd
);
10404 install_element (OSPF_NODE
, &no_ospf_timers_throttle_spf_val_cmd
);
10406 /* LSA timers commands */
10407 install_element (OSPF_NODE
, &ospf_timers_min_ls_interval_cmd
);
10408 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_interval_cmd
);
10409 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_interval_val_cmd
);
10410 install_element (OSPF_NODE
, &ospf_timers_min_ls_arrival_cmd
);
10411 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_arrival_cmd
);
10412 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_arrival_val_cmd
);
10413 install_element (OSPF_NODE
, &ospf_timers_lsa_cmd
);
10414 install_element (OSPF_NODE
, &no_ospf_timers_lsa_cmd
);
10415 install_element (OSPF_NODE
, &no_ospf_timers_lsa_val_cmd
);
10417 /* refresh timer commands */
10418 install_element (OSPF_NODE
, &ospf_refresh_timer_cmd
);
10419 install_element (OSPF_NODE
, &no_ospf_refresh_timer_val_cmd
);
10420 install_element (OSPF_NODE
, &no_ospf_refresh_timer_cmd
);
10422 /* max-metric commands */
10423 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_admin_cmd
);
10424 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_admin_cmd
);
10425 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_startup_cmd
);
10426 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_startup_cmd
);
10427 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_startup_no_param_cmd
);
10428 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_shutdown_cmd
);
10429 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_shutdown_cmd
);
10430 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_shutdown_no_param_cmd
);
10432 /* reference bandwidth commands */
10433 install_element (OSPF_NODE
, &ospf_auto_cost_reference_bandwidth_cmd
);
10434 install_element (OSPF_NODE
, &no_ospf_auto_cost_reference_bandwidth_cmd
);
10435 install_element (OSPF_NODE
, &no_ospf_auto_cost_reference_bandwidth_val_cmd
);
10437 /* "neighbor" commands. */
10438 install_element (OSPF_NODE
, &ospf_neighbor_cmd
);
10439 install_element (OSPF_NODE
, &ospf_neighbor_priority_poll_interval_cmd
);
10440 install_element (OSPF_NODE
, &ospf_neighbor_priority_cmd
);
10441 install_element (OSPF_NODE
, &ospf_neighbor_poll_interval_cmd
);
10442 install_element (OSPF_NODE
, &ospf_neighbor_poll_interval_priority_cmd
);
10443 install_element (OSPF_NODE
, &no_ospf_neighbor_cmd
);
10444 install_element (OSPF_NODE
, &no_ospf_neighbor_priority_cmd
);
10445 install_element (OSPF_NODE
, &no_ospf_neighbor_poll_interval_cmd
);
10446 install_element (OSPF_NODE
, &no_ospf_neighbor_poll_interval_priority_cmd
);
10447 install_element (OSPF_NODE
, &no_ospf_neighbor_priority_pollinterval_cmd
);
10449 /* write multiplier commands */
10450 install_element (OSPF_NODE
, &ospf_write_multiplier_cmd
);
10451 install_element (OSPF_NODE
, &no_ospf_write_multiplier_cmd
);
10452 install_element (OSPF_NODE
, &write_multiplier_cmd
);
10453 install_element (OSPF_NODE
, &no_write_multiplier_cmd
);
10454 install_element (OSPF_NODE
, &no_write_multiplier_val_cmd
);
10456 /* Init interface related vty commands. */
10457 ospf_vty_if_init ();
10459 /* Init zebra related vty commands. */
10460 ospf_vty_zebra_init ();