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
))
148 "router ospf [(1-65535)]",
149 "Enable a routing process\n"
150 "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
[2]->arg
);
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
);
184 DEFUN (no_router_ospf
,
186 "no router ospf [(1-65535)]",
188 "Enable a routing process\n"
189 "Start OSPF configuration\n"
193 u_short instance
= 0;
196 VTY_GET_INTEGER ("Instance", instance
, argv
[3]->arg
);
198 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
207 DEFUN (ospf_router_id
,
209 "ospf router-id A.B.C.D",
210 "OSPF specific commands\n"
211 "router-id for the OSPF process\n"
212 "OSPF router-id in IP address format\n")
215 struct ospf
*ospf
= vty
->index
;
216 struct listnode
*node
;
217 struct ospf_area
*area
;
218 struct in_addr router_id
;
224 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &router_id
);
227 vty_out (vty
, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE
);
231 ospf
->router_id_static
= router_id
;
233 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
236 vty_out (vty
, "For this router-id change to take effect,"
237 " save config and restart ospfd%s", VTY_NEWLINE
);
241 ospf_router_id_update (ospf
);
246 DEFUN_HIDDEN (ospf_router_id_old
,
247 ospf_router_id_old_cmd
,
249 "router-id for the OSPF process\n"
250 "OSPF router-id in IP address format\n")
253 struct ospf
*ospf
= vty
->index
;
254 struct listnode
*node
;
255 struct ospf_area
*area
;
256 struct in_addr router_id
;
262 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &router_id
);
265 vty_out (vty
, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE
);
269 ospf
->router_id_static
= router_id
;
271 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
274 vty_out (vty
, "For this router-id change to take effect,"
275 " save config and restart ospfd%s", VTY_NEWLINE
);
279 ospf_router_id_update (ospf
);
284 DEFUN (no_ospf_router_id
,
285 no_ospf_router_id_cmd
,
286 "no ospf router-id [A.B.C.D]",
288 "OSPF specific commands\n"
289 "router-id for the OSPF process\n"
290 "OSPF router-id in IP address format\n")
292 struct ospf
*ospf
= vty
->index
;
293 struct listnode
*node
;
294 struct ospf_area
*area
;
299 ospf
->router_id_static
.s_addr
= 0;
301 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
304 vty_out (vty
, "For this router-id change to take effect,"
305 " save config and restart ospfd%s", VTY_NEWLINE
);
309 ospf_router_id_update (ospf
);
316 ospf_passive_interface_default (struct ospf
*ospf
, u_char newval
)
319 struct interface
*ifp
;
320 struct ospf_interface
*oi
;
322 ospf
->passive_interface_default
= newval
;
324 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, ln
, ifp
))
327 OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
))
328 UNSET_IF_PARAM (IF_DEF_PARAMS (ifp
), passive_interface
);
330 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, ln
, oi
))
332 if (OSPF_IF_PARAM_CONFIGURED (oi
->params
, passive_interface
))
333 UNSET_IF_PARAM (oi
->params
, passive_interface
);
334 /* update multicast memberships */
335 ospf_if_set_multicast(oi
);
340 ospf_passive_interface_update_addr (struct ospf
*ospf
, struct interface
*ifp
,
341 struct ospf_if_params
*params
, u_char value
,
346 params
->passive_interface
= value
;
347 if (params
!= IF_DEF_PARAMS (ifp
))
349 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
))
350 dflt
= IF_DEF_PARAMS (ifp
)->passive_interface
;
352 dflt
= ospf
->passive_interface_default
;
355 SET_IF_PARAM (params
, passive_interface
);
357 UNSET_IF_PARAM (params
, passive_interface
);
359 ospf_free_if_params (ifp
, addr
);
360 ospf_if_update_params (ifp
, addr
);
365 ospf_passive_interface_update (struct ospf
*ospf
, struct interface
*ifp
,
366 struct ospf_if_params
*params
, u_char value
)
368 params
->passive_interface
= value
;
369 if (params
== IF_DEF_PARAMS (ifp
))
371 if (value
!= ospf
->passive_interface_default
)
372 SET_IF_PARAM (params
, passive_interface
);
374 UNSET_IF_PARAM (params
, passive_interface
);
378 DEFUN (ospf_passive_interface
,
379 ospf_passive_interface_addr_cmd
,
380 "passive-interface <IFNAME [A.B.C.D]|default>",
381 "Suppress routing updates on an interface\n"
384 "Suppress routing updates on interfaces by default\n")
387 struct interface
*ifp
;
388 struct in_addr addr
= { .s_addr
= INADDR_ANY
};
390 struct ospf_if_params
*params
;
391 struct route_node
*rn
;
392 struct ospf
*ospf
= vty
->index
;
397 if (strcmp (argv
[1]->text
, "default") == 0)
399 ospf_passive_interface_default (ospf
, OSPF_IF_PASSIVE
);
403 ifp
= if_get_by_name (argv
[1]->arg
);
405 params
= IF_DEF_PARAMS (ifp
);
409 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
412 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
417 params
= ospf_get_if_params (ifp
, addr
);
418 ospf_if_update_params (ifp
, addr
);
419 ospf_passive_interface_update_addr (ospf
, ifp
, params
,
420 OSPF_IF_PASSIVE
, addr
);
423 ospf_passive_interface_update (ospf
, ifp
, params
, OSPF_IF_PASSIVE
);
425 /* XXX We should call ospf_if_set_multicast on exactly those
426 * interfaces for which the passive property changed. It is too much
427 * work to determine this set, so we do this for every interface.
428 * This is safe and reasonable because ospf_if_set_multicast uses a
429 * record of joined groups to avoid systems calls if the desired
430 * memberships match the current memership.
433 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next (rn
))
435 struct ospf_interface
*oi
= rn
->info
;
437 if (oi
&& (OSPF_IF_PARAM(oi
, passive_interface
) == OSPF_IF_PASSIVE
))
438 ospf_if_set_multicast(oi
);
441 * XXX It is not clear what state transitions the interface needs to
442 * undergo when going from active to passive. Fixing this will
443 * require precise identification of interfaces having such a
450 DEFUN (no_ospf_passive_interface
,
451 no_ospf_passive_interface_addr_cmd
,
452 "no passive-interface <IFNAME [A.B.C.D]|default>",
454 "Allow routing updates on an interface\n"
457 "Allow routing updates on interfaces by default\n")
460 struct interface
*ifp
;
461 struct in_addr addr
= { .s_addr
= INADDR_ANY
};
462 struct ospf_if_params
*params
;
464 struct route_node
*rn
;
465 struct ospf
*ospf
= vty
->index
;
470 if (strcmp (argv
[2]->text
, "default") == 0)
472 ospf_passive_interface_default (ospf
, OSPF_IF_ACTIVE
);
476 ifp
= if_get_by_name (argv
[2]->arg
);
478 params
= IF_DEF_PARAMS (ifp
);
482 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
485 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
490 params
= ospf_lookup_if_params (ifp
, addr
);
493 ospf_passive_interface_update_addr (ospf
, ifp
, params
, OSPF_IF_ACTIVE
,
496 ospf_passive_interface_update (ospf
, ifp
, params
, OSPF_IF_ACTIVE
);
498 /* XXX We should call ospf_if_set_multicast on exactly those
499 * interfaces for which the passive property changed. It is too much
500 * work to determine this set, so we do this for every interface.
501 * This is safe and reasonable because ospf_if_set_multicast uses a
502 * record of joined groups to avoid systems calls if the desired
503 * memberships match the current memership.
505 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next (rn
))
507 struct ospf_interface
*oi
= rn
->info
;
509 if (oi
&& (OSPF_IF_PARAM(oi
, passive_interface
) == OSPF_IF_ACTIVE
))
510 ospf_if_set_multicast(oi
);
518 DEFUN (ospf_network_area
,
519 ospf_network_area_cmd
,
520 "network A.B.C.D/M area <A.B.C.D|(0-4294967295)>",
521 "Enable routing on an IP network\n"
522 "OSPF network prefix\n"
523 "Set the OSPF area ID\n"
524 "OSPF area ID in IP address format\n"
525 "OSPF area ID as a decimal value\n")
527 int idx_ipv4_prefixlen
= 1;
528 int idx_ipv4_number
= 3;
529 struct ospf
*ospf
= vty
->index
;
530 struct prefix_ipv4 p
;
531 struct in_addr area_id
;
539 vty_out (vty
, "The network command is not supported in multi-instance ospf%s",
544 if (ospf
->if_ospf_cli_count
> 0)
546 vty_out (vty
, "Please remove all ip ospf area x.x.x.x commands first.%s",
551 /* Get network prefix and Area ID. */
552 VTY_GET_IPV4_PREFIX ("network prefix", p
, argv
[idx_ipv4_prefixlen
]->arg
);
553 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
555 ret
= ospf_network_set (ospf
, &p
, area_id
);
558 vty_out (vty
, "There is already same network statement.%s", VTY_NEWLINE
);
565 DEFUN (no_ospf_network_area
,
566 no_ospf_network_area_cmd
,
567 "no network A.B.C.D/M area <A.B.C.D|(0-4294967295)>",
569 "Enable routing on an IP network\n"
570 "OSPF network prefix\n"
571 "Set the OSPF area ID\n"
572 "OSPF area ID in IP address format\n"
573 "OSPF area ID as a decimal value\n")
575 int idx_ipv4_prefixlen
= 2;
576 int idx_ipv4_number
= 4;
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
[idx_ipv4_prefixlen
]->arg
);
594 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
596 ret
= ospf_network_unset (ospf
, &p
, area_id
);
599 vty_out (vty
, "Can't find specified network area configuration.%s",
607 DEFUN (ospf_area_range
,
609 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [advertise [cost (0-16777215)]]",
610 "OSPF area parameters\n"
611 "OSPF area ID in IP address format\n"
612 "OSPF area ID as a decimal value\n"
613 "Summarize routes matching address/mask (border routers only)\n"
614 "Area range prefix\n"
615 "Advertise this range (default)\n"
616 "User specified metric for this range\n"
617 "Advertised metric for this range\n")
619 int idx_ipv4_number
= 1;
620 int idx_ipv4_prefixlen
= 3;
622 struct ospf
*ospf
= vty
->index
;
623 struct prefix_ipv4 p
;
624 struct in_addr area_id
;
631 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
632 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
634 ospf_area_range_set (ospf
, area_id
, &p
, OSPF_AREA_RANGE_ADVERTISE
);
637 VTY_GET_INTEGER ("range cost", cost
, argv
[idx_cost
]->arg
);
638 ospf_area_range_cost_set (ospf
, area_id
, &p
, cost
);
644 DEFUN (ospf_area_range_cost
,
645 ospf_area_range_cost_cmd
,
646 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M cost (0-16777215)",
647 "OSPF area parameters\n"
648 "OSPF area ID in IP address format\n"
649 "OSPF area ID as a decimal value\n"
650 "Summarize routes matching address/mask (border routers only)\n"
651 "Area range prefix\n"
652 "User specified metric for this range\n"
653 "Advertised metric for this range\n")
655 int idx_ipv4_number
= 1;
656 int idx_ipv4_prefixlen
= 3;
658 struct ospf
*ospf
= vty
->index
;
659 struct prefix_ipv4 p
;
660 struct in_addr area_id
;
667 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
668 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
670 ospf_area_range_set (ospf
, area_id
, &p
, OSPF_AREA_RANGE_ADVERTISE
);
672 VTY_GET_INTEGER ("range cost", cost
, argv
[idx_cost
]->arg
);
673 ospf_area_range_cost_set (ospf
, area_id
, &p
, cost
);
678 DEFUN (ospf_area_range_not_advertise
,
679 ospf_area_range_not_advertise_cmd
,
680 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M not-advertise",
681 "OSPF area parameters\n"
682 "OSPF area ID in IP address format\n"
683 "OSPF area ID as a decimal value\n"
684 "Summarize routes matching address/mask (border routers only)\n"
685 "Area range prefix\n"
686 "DoNotAdvertise this range\n")
688 int idx_ipv4_number
= 1;
689 int idx_ipv4_prefixlen
= 3;
690 struct ospf
*ospf
= vty
->index
;
691 struct prefix_ipv4 p
;
692 struct in_addr area_id
;
698 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
699 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
701 ospf_area_range_set (ospf
, area_id
, &p
, 0);
706 DEFUN (no_ospf_area_range
,
707 no_ospf_area_range_cmd
,
708 "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [<cost (0-16777215)|advertise [cost (0-16777215)]|not-advertise>]",
710 "OSPF area parameters\n"
711 "OSPF area ID in IP address format\n"
712 "OSPF area ID as a decimal value\n"
713 "Summarize routes matching address/mask (border routers only)\n"
714 "Area range prefix\n"
715 "User specified metric for this range\n"
716 "Advertised metric for this range\n"
717 "Advertise this range (default)\n"
718 "User specified metric for this range\n"
719 "Advertised metric for this range\n"
720 "DoNotAdvertise this range\n")
722 int idx_ipv4_number
= 2;
723 int idx_ipv4_prefixlen
= 4;
724 struct ospf
*ospf
= vty
->index
;
725 struct prefix_ipv4 p
;
726 struct in_addr area_id
;
732 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
733 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
735 ospf_area_range_unset (ospf
, area_id
, &p
);
740 DEFUN (ospf_area_range_substitute
,
741 ospf_area_range_substitute_cmd
,
742 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M",
743 "OSPF area parameters\n"
744 "OSPF area ID in IP address format\n"
745 "OSPF area ID as a decimal value\n"
746 "Summarize routes matching address/mask (border routers only)\n"
747 "Area range prefix\n"
748 "Announce area range as another prefix\n"
749 "Network prefix to be announced instead of range\n")
751 int idx_ipv4_number
= 1;
752 int idx_ipv4_prefixlen
= 3;
753 int idx_ipv4_prefixlen_2
= 5;
754 struct ospf
*ospf
= vty
->index
;
755 struct prefix_ipv4 p
, s
;
756 struct in_addr area_id
;
762 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
763 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
764 VTY_GET_IPV4_PREFIX ("substituted network prefix", s
, argv
[idx_ipv4_prefixlen_2
]->arg
);
766 ospf_area_range_substitute_set (ospf
, area_id
, &p
, &s
);
771 DEFUN (no_ospf_area_range_substitute
,
772 no_ospf_area_range_substitute_cmd
,
773 "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M",
775 "OSPF area parameters\n"
776 "OSPF area ID in IP address format\n"
777 "OSPF area ID as a decimal value\n"
778 "Summarize routes matching address/mask (border routers only)\n"
779 "Area range prefix\n"
780 "Announce area range as another prefix\n"
781 "Network prefix to be announced instead of range\n")
783 int idx_ipv4_number
= 2;
784 int idx_ipv4_prefixlen
= 4;
785 int idx_ipv4_prefixlen_2
= 6;
786 struct ospf
*ospf
= vty
->index
;
787 struct prefix_ipv4 p
, s
;
788 struct in_addr area_id
;
794 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
795 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
796 VTY_GET_IPV4_PREFIX ("substituted network prefix", s
, argv
[idx_ipv4_prefixlen_2
]->arg
);
798 ospf_area_range_substitute_unset (ospf
, area_id
, &p
);
804 /* Command Handler Logic in VLink stuff is delicate!!
806 ALTER AT YOUR OWN RISK!!!!
808 Various dummy values are used to represent 'NoChange' state for
809 VLink configuration NOT being changed by a VLink command, and
810 special syntax is used within the command strings so that the
811 typed in command verbs can be seen in the configuration command
812 bacckend handler. This is to drastically reduce the verbeage
813 required to coe up with a reasonably compatible Cisco VLink command
815 - Matthew Grant <grantma@anathoth.gen.nz>
816 Wed, 21 Feb 2001 15:13:52 +1300
819 /* Configuration data for virtual links
821 struct ospf_vl_config_data
{
822 struct vty
*vty
; /* vty stuff */
823 struct in_addr area_id
; /* area ID from command line */
824 int format
; /* command line area ID format */
825 struct in_addr vl_peer
; /* command line vl_peer */
826 int auth_type
; /* Authehntication type, if given */
827 char *auth_key
; /* simple password if present */
828 int crypto_key_id
; /* Cryptographic key ID */
829 char *md5_key
; /* MD5 authentication key */
830 int hello_interval
; /* Obvious what these are... */
831 int retransmit_interval
;
837 ospf_vl_config_data_init (struct ospf_vl_config_data
*vl_config
,
840 memset (vl_config
, 0, sizeof (struct ospf_vl_config_data
));
841 vl_config
->auth_type
= OSPF_AUTH_CMD_NOTSEEN
;
842 vl_config
->vty
= vty
;
845 static struct ospf_vl_data
*
846 ospf_find_vl_data (struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
848 struct ospf_area
*area
;
849 struct ospf_vl_data
*vl_data
;
851 struct in_addr area_id
;
853 vty
= vl_config
->vty
;
854 area_id
= vl_config
->area_id
;
856 if (area_id
.s_addr
== OSPF_AREA_BACKBONE
)
859 "Configuring VLs over the backbone is not allowed%s",
863 area
= ospf_area_get (ospf
, area_id
, vl_config
->format
);
865 if (area
->external_routing
!= OSPF_AREA_DEFAULT
)
867 if (vl_config
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
868 vty_out (vty
, "Area %s is %s%s",
870 area
->external_routing
== OSPF_AREA_NSSA
?"nssa":"stub",
873 vty_out (vty
, "Area %ld is %s%s",
874 (u_long
)ntohl (area_id
.s_addr
),
875 area
->external_routing
== OSPF_AREA_NSSA
?"nssa":"stub",
880 if ((vl_data
= ospf_vl_lookup (ospf
, area
, vl_config
->vl_peer
)) == NULL
)
882 vl_data
= ospf_vl_data_new (area
, vl_config
->vl_peer
);
883 if (vl_data
->vl_oi
== NULL
)
885 vl_data
->vl_oi
= ospf_vl_new (ospf
, vl_data
);
886 ospf_vl_add (ospf
, vl_data
);
887 ospf_spf_calculate_schedule (ospf
, SPF_FLAG_CONFIG_CHANGE
);
895 ospf_vl_set_security (struct ospf_vl_data
*vl_data
,
896 struct ospf_vl_config_data
*vl_config
)
898 struct crypt_key
*ck
;
900 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
902 vty
= vl_config
->vty
;
904 if (vl_config
->auth_type
!= OSPF_AUTH_CMD_NOTSEEN
)
906 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), auth_type
);
907 IF_DEF_PARAMS (ifp
)->auth_type
= vl_config
->auth_type
;
910 if (vl_config
->auth_key
)
912 memset(IF_DEF_PARAMS (ifp
)->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+1);
913 strncpy ((char *) IF_DEF_PARAMS (ifp
)->auth_simple
, vl_config
->auth_key
,
914 OSPF_AUTH_SIMPLE_SIZE
);
916 else if (vl_config
->md5_key
)
918 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp
)->auth_crypt
, vl_config
->crypto_key_id
)
921 vty_out (vty
, "OSPF: Key %d already exists%s",
922 vl_config
->crypto_key_id
, VTY_NEWLINE
);
925 ck
= ospf_crypt_key_new ();
926 ck
->key_id
= vl_config
->crypto_key_id
;
927 memset(ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
928 strncpy ((char *) ck
->auth_key
, vl_config
->md5_key
, OSPF_AUTH_MD5_SIZE
);
930 ospf_crypt_key_add (IF_DEF_PARAMS (ifp
)->auth_crypt
, ck
);
932 else if (vl_config
->crypto_key_id
!= 0)
936 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp
)->auth_crypt
,
937 vl_config
->crypto_key_id
) == NULL
)
939 vty_out (vty
, "OSPF: Key %d does not exist%s",
940 vl_config
->crypto_key_id
, VTY_NEWLINE
);
944 ospf_crypt_key_delete (IF_DEF_PARAMS (ifp
)->auth_crypt
, vl_config
->crypto_key_id
);
952 ospf_vl_set_timers (struct ospf_vl_data
*vl_data
,
953 struct ospf_vl_config_data
*vl_config
)
955 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
956 /* Virtual Link data initialised to defaults, so only set
958 if (vl_config
->hello_interval
)
960 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), v_hello
);
961 IF_DEF_PARAMS (ifp
)->v_hello
= vl_config
->hello_interval
;
964 if (vl_config
->dead_interval
)
966 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), v_wait
);
967 IF_DEF_PARAMS (ifp
)->v_wait
= vl_config
->dead_interval
;
970 if (vl_config
->retransmit_interval
)
972 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), retransmit_interval
);
973 IF_DEF_PARAMS (ifp
)->retransmit_interval
= vl_config
->retransmit_interval
;
976 if (vl_config
->transmit_delay
)
978 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), transmit_delay
);
979 IF_DEF_PARAMS (ifp
)->transmit_delay
= vl_config
->transmit_delay
;
986 /* The business end of all of the above */
988 ospf_vl_set (struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
990 struct ospf_vl_data
*vl_data
;
993 vl_data
= ospf_find_vl_data (ospf
, vl_config
);
997 /* Process this one first as it can have a fatal result, which can
998 only logically occur if the virtual link exists already
999 Thus a command error does not result in a change to the
1000 running configuration such as unexpectedly altered timer
1002 ret
= ospf_vl_set_security (vl_data
, vl_config
);
1003 if (ret
!= CMD_SUCCESS
)
1006 /* Set any time based parameters, these area already range checked */
1008 ret
= ospf_vl_set_timers (vl_data
, vl_config
);
1009 if (ret
!= CMD_SUCCESS
)
1016 /* This stuff exists to make specifying all the alias commands A LOT simpler
1018 #define VLINK_HELPSTR_IPADDR \
1019 "OSPF area parameters\n" \
1020 "OSPF area ID in IP address format\n" \
1021 "OSPF area ID as a decimal value\n" \
1022 "Configure a virtual link\n" \
1023 "Router ID of the remote ABR\n"
1025 #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
1026 "Enable authentication on this virtual link\n" \
1029 #define VLINK_HELPSTR_AUTHTYPE_ALL \
1030 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
1031 "Use null authentication\n" \
1032 "Use message-digest authentication\n"
1034 #define VLINK_HELPSTR_TIME_PARAM_NOSECS \
1035 "Time between HELLO packets\n" \
1036 "Time between retransmitting lost link state advertisements\n" \
1037 "Link state transmit delay\n" \
1038 "Interval time after which a neighbor is declared down\n"
1040 #define VLINK_HELPSTR_TIME_PARAM \
1041 VLINK_HELPSTR_TIME_PARAM_NOSECS \
1044 #define VLINK_HELPSTR_AUTH_SIMPLE \
1045 "Authentication password (key)\n" \
1046 "The OSPF password (key)"
1048 #define VLINK_HELPSTR_AUTH_MD5 \
1049 "Message digest authentication password (key)\n" \
1052 "Use MD5 algorithm\n" \
1053 "The OSPF password (key)"
1055 DEFUN (ospf_area_vlink
,
1056 ospf_area_vlink_cmd
,
1057 "area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D [authentication] [<message-digest|null>] [<message-digest-key (1-255) md5 KEY|authentication-key AUTH_KEY>]",
1058 VLINK_HELPSTR_IPADDR
1059 "Enable authentication on this virtual link\n" \
1060 "Use null authentication\n" \
1061 "Use message-digest authentication\n"
1062 "Message digest authentication password (key)\n" \
1064 "Use MD5 algorithm\n" \
1065 "The OSPF password (key)")
1067 int idx_ipv4_number
= 1;
1069 struct ospf
*ospf
= vty
->index
;
1070 struct ospf_vl_config_data vl_config
;
1071 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+1];
1072 char md5_key
[OSPF_AUTH_MD5_SIZE
+1];
1079 ospf_vl_config_data_init(&vl_config
, vty
);
1081 /* Read off first 2 parameters and check them */
1082 ret
= ospf_str2area_id (argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
, &vl_config
.format
);
1085 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1089 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1092 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s",
1099 /* Thats all folks! - BUGS B. strikes again!!!*/
1101 return ospf_vl_set (ospf
, &vl_config
);
1104 /* Deal with other parameters */
1105 for (i
=5; i
< argc
; i
++)
1108 /* vty_out (vty, "argv[%d]->arg - %s%s", i, argv[i]->text, VTY_NEWLINE); */
1110 switch (argv
[i
]->arg
[0])
1114 if (i
>5 || strncmp (argv
[i
]->arg
, "authentication-", 15) == 0)
1116 /* authentication-key - this option can occur anywhere on
1117 command line. At start of command line
1118 must check for authentication option. */
1119 memset (auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1120 strncpy (auth_key
, argv
[i
+1]->text
, OSPF_AUTH_SIMPLE_SIZE
);
1121 vl_config
.auth_key
= auth_key
;
1124 else if (strncmp (argv
[i
]->arg
, "authentication", 14) == 0)
1126 /* authentication - this option can only occur at start
1128 vl_config
.auth_type
= OSPF_AUTH_SIMPLE
;
1131 if (strncmp (argv
[i
+1]->arg
, "n", 1) == 0)
1133 /* "authentication null" */
1134 vl_config
.auth_type
= OSPF_AUTH_NULL
;
1137 else if (strncmp (argv
[i
+1]->arg
, "m", 1) == 0
1138 && strcmp (argv
[i
+1]->arg
, "message-digest-") != 0)
1140 /* "authentication message-digest" */
1141 vl_config
.auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
1149 /* message-digest-key */
1151 vl_config
.crypto_key_id
= strtol (argv
[i
]->arg
, NULL
, 10);
1152 if (vl_config
.crypto_key_id
< 0)
1155 memset(md5_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
1156 strncpy (md5_key
, argv
[i
]->arg
, OSPF_AUTH_MD5_SIZE
);
1157 vl_config
.md5_key
= md5_key
;
1164 /* Action configuration */
1166 return ospf_vl_set (ospf
, &vl_config
);
1170 DEFUN (ospf_area_vlink_intervals
,
1171 ospf_area_vlink_intervals_cmd
,
1172 "area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D"
1173 "<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1174 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1175 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1176 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1178 VLINK_HELPSTR_IPADDR
1179 VLINK_HELPSTR_TIME_PARAM
1180 VLINK_HELPSTR_TIME_PARAM
1181 VLINK_HELPSTR_TIME_PARAM
1182 VLINK_HELPSTR_TIME_PARAM
)
1184 struct ospf
*ospf
= vty
->index
;
1185 struct ospf_vl_config_data vl_config
;
1191 ospf_vl_config_data_init(&vl_config
, vty
);
1193 char *area_id
= argv
[1]->arg
;
1194 char *router_id
= argv
[3]->arg
;
1196 ret
= ospf_str2area_id (area_id
, &vl_config
.area_id
, &vl_config
.format
);
1199 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1203 ret
= inet_aton (router_id
, &vl_config
.vl_peer
);
1206 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE
);
1209 for (unsigned int i
= 0; i
< 4; i
++)
1212 if (argv_find (argv
, argc
, "hello-interval", &idx
))
1213 vl_config
.hello_interval
= strtol(argv
[idx
+1]->arg
, NULL
, 10);
1214 else if (argv_find (argv
, argc
, "retransmit-interval", &idx
))
1215 vl_config
.retransmit_interval
= strtol(argv
[idx
+1]->arg
, NULL
, 10);
1216 else if (argv_find (argv
, argc
, "transmit-delay", &idx
))
1217 vl_config
.transmit_delay
= strtol(argv
[idx
+1]->arg
, NULL
, 10);
1218 else if (argv_find (argv
, argc
, "dead-interval", &idx
))
1219 vl_config
.dead_interval
= strtol(argv
[idx
+1]->arg
, NULL
, 10);
1222 /* Action configuration */
1223 return ospf_vl_set (ospf
, &vl_config
);
1226 DEFUN (no_ospf_area_vlink
,
1227 no_ospf_area_vlink_cmd
,
1228 "no area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D [authentication] [<message-digest|null>] [<message-digest-key (1-255) md5 KEY|authentication-key AUTH_KEY>]",
1230 VLINK_HELPSTR_IPADDR
1231 "Enable authentication on this virtual link\n" \
1232 "Use null authentication\n" \
1233 "Use message-digest authentication\n"
1234 "Message digest authentication password (key)\n" \
1236 "Use MD5 algorithm\n" \
1237 "The OSPF password (key)")
1239 int idx_ipv4_number
= 2;
1241 struct ospf
*ospf
= vty
->index
;
1242 struct ospf_area
*area
;
1243 struct ospf_vl_config_data vl_config
;
1244 struct ospf_vl_data
*vl_data
= NULL
;
1245 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+1];
1252 ospf_vl_config_data_init(&vl_config
, vty
);
1254 ret
= ospf_str2area_id (argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
, &format
);
1257 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1261 area
= ospf_area_lookup_by_area_id (ospf
, vl_config
.area_id
);
1264 vty_out (vty
, "Area does not exist%s", VTY_NEWLINE
);
1268 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1271 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s",
1278 /* Basic VLink no command */
1279 /* Thats all folks! - BUGS B. strikes again!!!*/
1280 if ((vl_data
= ospf_vl_lookup (ospf
, area
, vl_config
.vl_peer
)))
1281 ospf_vl_delete (ospf
, vl_data
);
1283 ospf_area_check_free (ospf
, vl_config
.area_id
);
1288 /* If we are down here, we are reseting parameters */
1290 /* Deal with other parameters */
1291 for (i
=6; argc
; i
++)
1293 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1295 switch (argv
[i
]->arg
[0])
1299 if (i
> 2 || strncmp (argv
[i
]->text
, "authentication-", 15) == 0)
1301 /* authentication-key - this option can occur anywhere on
1302 command line. At start of command line
1303 must check for authentication option. */
1304 memset (auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1305 vl_config
.auth_key
= auth_key
;
1307 else if (strncmp (argv
[i
]->text
, "authentication", 14) == 0)
1309 /* authentication - this option can only occur at start
1311 vl_config
.auth_type
= OSPF_AUTH_NOTSET
;
1316 /* message-digest-key */
1317 /* Delete one key */
1319 vl_config
.crypto_key_id
= strtol (argv
[i
]->arg
, NULL
, 10);
1320 if (vl_config
.crypto_key_id
< 0)
1322 vl_config
.md5_key
= NULL
;
1329 /* Action configuration */
1331 return ospf_vl_set (ospf
, &vl_config
);
1334 DEFUN (no_ospf_area_vlink_intervals
,
1335 no_ospf_area_vlink_intervals_cmd
,
1336 "no area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D"
1337 "<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1338 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1339 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1340 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1343 VLINK_HELPSTR_IPADDR
1344 VLINK_HELPSTR_TIME_PARAM
1345 VLINK_HELPSTR_TIME_PARAM
1346 VLINK_HELPSTR_TIME_PARAM
1347 VLINK_HELPSTR_TIME_PARAM
)
1349 struct ospf
*ospf
= vty
->index
;
1350 struct ospf_vl_config_data vl_config
;
1356 ospf_vl_config_data_init(&vl_config
, vty
);
1358 char *area_id
= argv
[2]->arg
;
1359 char *router_id
= argv
[4]->arg
;
1361 ret
= ospf_str2area_id (area_id
, &vl_config
.area_id
, &vl_config
.format
);
1364 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1368 ret
= inet_aton (router_id
, &vl_config
.vl_peer
);
1371 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE
);
1375 for (unsigned int i
= 0; i
< 4; i
++)
1378 if (argv_find (argv
, argc
, "hello-interval", &idx
))
1379 vl_config
.hello_interval
= OSPF_HELLO_INTERVAL_DEFAULT
;
1380 else if (argv_find (argv
, argc
, "retransmit-interval", &idx
))
1381 vl_config
.retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
1382 else if (argv_find (argv
, argc
, "transmit-delay", &idx
))
1383 vl_config
.transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
1384 else if (argv_find (argv
, argc
, "dead-interval", &idx
))
1385 vl_config
.dead_interval
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
1388 /* Action configuration */
1389 return ospf_vl_set (ospf
, &vl_config
);
1392 DEFUN (ospf_area_shortcut
,
1393 ospf_area_shortcut_cmd
,
1394 "area <A.B.C.D|(0-4294967295)> shortcut <default|enable|disable>",
1395 "OSPF area parameters\n"
1396 "OSPF area ID in IP address format\n"
1397 "OSPF area ID as a decimal value\n"
1398 "Configure the area's shortcutting mode\n"
1399 "Set default shortcutting behavior\n"
1400 "Enable shortcutting through the area\n"
1401 "Disable shortcutting through the area\n")
1403 int idx_ipv4_number
= 1;
1404 int idx_enable_disable
= 3;
1405 struct ospf
*ospf
= vty
->index
;
1406 struct ospf_area
*area
;
1407 struct in_addr area_id
;
1414 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1416 area
= ospf_area_get (ospf
, area_id
, format
);
1418 if (strncmp (argv
[idx_enable_disable
]->arg
, "de", 2) == 0)
1419 mode
= OSPF_SHORTCUT_DEFAULT
;
1420 else if (strncmp (argv
[idx_enable_disable
]->arg
, "di", 2) == 0)
1421 mode
= OSPF_SHORTCUT_DISABLE
;
1422 else if (strncmp (argv
[idx_enable_disable
]->arg
, "e", 1) == 0)
1423 mode
= OSPF_SHORTCUT_ENABLE
;
1427 ospf_area_shortcut_set (ospf
, area
, mode
);
1429 if (ospf
->abr_type
!= OSPF_ABR_SHORTCUT
)
1430 vty_out (vty
, "Shortcut area setting will take effect "
1431 "only when the router is configured as Shortcut ABR%s",
1437 DEFUN (no_ospf_area_shortcut
,
1438 no_ospf_area_shortcut_cmd
,
1439 "no area <A.B.C.D|(0-4294967295)> shortcut <enable|disable>",
1441 "OSPF area parameters\n"
1442 "OSPF area ID in IP address format\n"
1443 "OSPF area ID as a decimal value\n"
1444 "Deconfigure the area's shortcutting mode\n"
1445 "Deconfigure enabled shortcutting through the area\n"
1446 "Deconfigure disabled shortcutting through the area\n")
1448 int idx_ipv4_number
= 2;
1449 struct ospf
*ospf
= vty
->index
;
1450 struct ospf_area
*area
;
1451 struct in_addr area_id
;
1457 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1459 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1463 ospf_area_shortcut_unset (ospf
, area
);
1469 DEFUN (ospf_area_stub
,
1471 "area <A.B.C.D|(0-4294967295)> stub",
1472 "OSPF area parameters\n"
1473 "OSPF area ID in IP address format\n"
1474 "OSPF area ID as a decimal value\n"
1475 "Configure OSPF area as stub\n")
1477 int idx_ipv4_number
= 1;
1478 struct ospf
*ospf
= vty
->index
;
1479 struct in_addr area_id
;
1485 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1487 ret
= ospf_area_stub_set (ospf
, area_id
);
1490 vty_out (vty
, "First deconfigure all virtual link through this area%s",
1495 ospf_area_no_summary_unset (ospf
, area_id
);
1500 DEFUN (ospf_area_stub_no_summary
,
1501 ospf_area_stub_no_summary_cmd
,
1502 "area <A.B.C.D|(0-4294967295)> stub no-summary",
1503 "OSPF stub parameters\n"
1504 "OSPF area ID in IP address format\n"
1505 "OSPF area ID as a decimal value\n"
1506 "Configure OSPF area as stub\n"
1507 "Do not inject inter-area routes into stub\n")
1509 int idx_ipv4_number
= 1;
1510 struct ospf
*ospf
= vty
->index
;
1511 struct in_addr area_id
;
1517 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1519 ret
= ospf_area_stub_set (ospf
, area_id
);
1522 vty_out (vty
, "%% Area cannot be stub as it contains a virtual link%s",
1527 ospf_area_no_summary_set (ospf
, area_id
);
1532 DEFUN (no_ospf_area_stub
,
1533 no_ospf_area_stub_cmd
,
1534 "no area <A.B.C.D|(0-4294967295)> stub",
1536 "OSPF area parameters\n"
1537 "OSPF area ID in IP address format\n"
1538 "OSPF area ID as a decimal value\n"
1539 "Configure OSPF area as stub\n")
1541 int idx_ipv4_number
= 2;
1542 struct ospf
*ospf
= vty
->index
;
1543 struct in_addr area_id
;
1549 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1551 ospf_area_stub_unset (ospf
, area_id
);
1552 ospf_area_no_summary_unset (ospf
, area_id
);
1557 DEFUN (no_ospf_area_stub_no_summary
,
1558 no_ospf_area_stub_no_summary_cmd
,
1559 "no area <A.B.C.D|(0-4294967295)> stub no-summary",
1561 "OSPF area parameters\n"
1562 "OSPF area ID in IP address format\n"
1563 "OSPF area ID as a decimal value\n"
1564 "Configure OSPF area as stub\n"
1565 "Do not inject inter-area routes into area\n")
1567 int idx_ipv4_number
= 2;
1568 struct ospf
*ospf
= vty
->index
;
1569 struct in_addr area_id
;
1575 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1576 ospf_area_no_summary_unset (ospf
, area_id
);
1582 ospf_area_nssa_cmd_handler (struct vty
*vty
, int argc
, struct cmd_token
**argv
,
1585 struct ospf
*ospf
= vty
->index
;
1586 struct in_addr area_id
;
1592 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id
, format
, argv
[1]->arg
);
1594 ret
= ospf_area_nssa_set (ospf
, area_id
);
1597 vty_out (vty
, "%% Area cannot be nssa as it contains a virtual link%s",
1604 if (strncmp (argv
[3]->text
, "translate-c", 11) == 0)
1605 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1606 OSPF_NSSA_ROLE_CANDIDATE
);
1607 else if (strncmp (argv
[3]->text
, "translate-n", 11) == 0)
1608 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1609 OSPF_NSSA_ROLE_NEVER
);
1610 else if (strncmp (argv
[3]->text
, "translate-a", 11) == 0)
1611 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1612 OSPF_NSSA_ROLE_ALWAYS
);
1616 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1617 OSPF_NSSA_ROLE_CANDIDATE
);
1621 ospf_area_no_summary_set (ospf
, area_id
);
1623 ospf_area_no_summary_unset (ospf
, area_id
);
1625 ospf_schedule_abr_task (ospf
);
1630 DEFUN (ospf_area_nssa_translate_no_summary
,
1631 ospf_area_nssa_translate_no_summary_cmd
,
1632 "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always> no-summary",
1633 "OSPF area parameters\n"
1634 "OSPF area ID in IP address format\n"
1635 "OSPF area ID as a decimal value\n"
1636 "Configure OSPF area as nssa\n"
1637 "Configure NSSA-ABR for translate election (default)\n"
1638 "Configure NSSA-ABR to never translate\n"
1639 "Configure NSSA-ABR to always translate\n"
1640 "Do not inject inter-area routes into nssa\n")
1642 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 1);
1645 DEFUN (ospf_area_nssa_translate
,
1646 ospf_area_nssa_translate_cmd
,
1647 "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always>",
1648 "OSPF area parameters\n"
1649 "OSPF area ID in IP address format\n"
1650 "OSPF area ID as a decimal value\n"
1651 "Configure OSPF area as nssa\n"
1652 "Configure NSSA-ABR for translate election (default)\n"
1653 "Configure NSSA-ABR to never translate\n"
1654 "Configure NSSA-ABR to always translate\n")
1656 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 0);
1659 DEFUN (ospf_area_nssa
,
1661 "area <A.B.C.D|(0-4294967295)> nssa",
1662 "OSPF area parameters\n"
1663 "OSPF area ID in IP address format\n"
1664 "OSPF area ID as a decimal value\n"
1665 "Configure OSPF area as nssa\n")
1667 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 0);
1670 DEFUN (ospf_area_nssa_no_summary
,
1671 ospf_area_nssa_no_summary_cmd
,
1672 "area <A.B.C.D|(0-4294967295)> nssa no-summary",
1673 "OSPF area parameters\n"
1674 "OSPF area ID in IP address format\n"
1675 "OSPF area ID as a decimal value\n"
1676 "Configure OSPF area as nssa\n"
1677 "Do not inject inter-area routes into nssa\n")
1679 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 1);
1682 DEFUN (no_ospf_area_nssa
,
1683 no_ospf_area_nssa_cmd
,
1684 "no area <A.B.C.D|(0-4294967295)> nssa [<translate-candidate|translate-never|translate-always> [no-summary]]",
1686 "OSPF area parameters\n"
1687 "OSPF area ID in IP address format\n"
1688 "OSPF area ID as a decimal value\n"
1689 "Configure OSPF area as nssa\n"
1690 "Configure NSSA-ABR for translate election (default)\n"
1691 "Configure NSSA-ABR to never translate\n"
1692 "Configure NSSA-ABR to always translate\n"
1693 "Do not inject inter-area routes into nssa\n")
1695 int idx_ipv4_number
= 2;
1696 struct ospf
*ospf
= vty
->index
;
1697 struct in_addr area_id
;
1703 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1705 ospf_area_nssa_unset (ospf
, area_id
);
1706 ospf_area_no_summary_unset (ospf
, area_id
);
1708 ospf_schedule_abr_task (ospf
);
1714 DEFUN (ospf_area_default_cost
,
1715 ospf_area_default_cost_cmd
,
1716 "area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1717 "OSPF area parameters\n"
1718 "OSPF area ID in IP address format\n"
1719 "OSPF area ID as a decimal value\n"
1720 "Set the summary-default cost of a NSSA or stub area\n"
1721 "Stub's advertised default summary cost\n")
1723 int idx_ipv4_number
= 1;
1725 struct ospf
*ospf
= vty
->index
;
1726 struct ospf_area
*area
;
1727 struct in_addr area_id
;
1730 struct prefix_ipv4 p
;
1735 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1736 VTY_GET_INTEGER_RANGE ("stub default cost", cost
, argv
[idx_number
]->arg
, 0, 16777215);
1738 area
= ospf_area_get (ospf
, area_id
, format
);
1740 if (area
->external_routing
== OSPF_AREA_DEFAULT
)
1742 vty_out (vty
, "The area is neither stub, nor NSSA%s", VTY_NEWLINE
);
1746 area
->default_cost
= cost
;
1749 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1751 if (IS_DEBUG_OSPF_EVENT
)
1752 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1753 "announcing 0.0.0.0/0 to area %s",
1754 inet_ntoa (area
->area_id
));
1755 ospf_abr_announce_network_to_area (&p
, area
->default_cost
, area
);
1760 DEFUN (no_ospf_area_default_cost
,
1761 no_ospf_area_default_cost_cmd
,
1762 "no area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1764 "OSPF area parameters\n"
1765 "OSPF area ID in IP address format\n"
1766 "OSPF area ID as a decimal value\n"
1767 "Set the summary-default cost of a NSSA or stub area\n"
1768 "Stub's advertised default summary cost\n")
1770 int idx_ipv4_number
= 2;
1772 struct ospf
*ospf
= vty
->index
;
1773 struct ospf_area
*area
;
1774 struct in_addr area_id
;
1776 struct prefix_ipv4 p
;
1781 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1782 VTY_CHECK_INTEGER_RANGE ("stub default cost", argv
[idx_number
]->arg
, 0, OSPF_LS_INFINITY
);
1784 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1788 if (area
->external_routing
== OSPF_AREA_DEFAULT
)
1790 vty_out (vty
, "The area is neither stub, nor NSSA%s", VTY_NEWLINE
);
1794 area
->default_cost
= 1;
1797 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1799 if (IS_DEBUG_OSPF_EVENT
)
1800 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1801 "announcing 0.0.0.0/0 to area %s",
1802 inet_ntoa (area
->area_id
));
1803 ospf_abr_announce_network_to_area (&p
, area
->default_cost
, area
);
1806 ospf_area_check_free (ospf
, area_id
);
1811 DEFUN (ospf_area_export_list
,
1812 ospf_area_export_list_cmd
,
1813 "area <A.B.C.D|(0-4294967295)> export-list NAME",
1814 "OSPF area parameters\n"
1815 "OSPF area ID in IP address format\n"
1816 "OSPF area ID as a decimal value\n"
1817 "Set the filter for networks announced to other areas\n"
1818 "Name of the access-list\n")
1820 int idx_ipv4_number
= 1;
1821 struct ospf
*ospf
= vty
->index
;
1822 struct ospf_area
*area
;
1823 struct in_addr area_id
;
1829 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1831 area
= ospf_area_get (ospf
, area_id
, format
);
1832 ospf_area_export_list_set (ospf
, area
, argv
[3]->arg
);
1837 DEFUN (no_ospf_area_export_list
,
1838 no_ospf_area_export_list_cmd
,
1839 "no area <A.B.C.D|(0-4294967295)> export-list NAME",
1841 "OSPF area parameters\n"
1842 "OSPF area ID in IP address format\n"
1843 "OSPF area ID as a decimal value\n"
1844 "Unset the filter for networks announced to other areas\n"
1845 "Name of the access-list\n")
1847 int idx_ipv4_number
= 2;
1848 struct ospf
*ospf
= vty
->index
;
1849 struct ospf_area
*area
;
1850 struct in_addr area_id
;
1856 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1858 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1862 ospf_area_export_list_unset (ospf
, area
);
1868 DEFUN (ospf_area_import_list
,
1869 ospf_area_import_list_cmd
,
1870 "area <A.B.C.D|(0-4294967295)> import-list NAME",
1871 "OSPF area parameters\n"
1872 "OSPF area ID in IP address format\n"
1873 "OSPF area ID as a decimal value\n"
1874 "Set the filter for networks from other areas announced to the specified one\n"
1875 "Name of the access-list\n")
1877 int idx_ipv4_number
= 1;
1878 struct ospf
*ospf
= vty
->index
;
1879 struct ospf_area
*area
;
1880 struct in_addr area_id
;
1886 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1888 area
= ospf_area_get (ospf
, area_id
, format
);
1889 ospf_area_import_list_set (ospf
, area
, argv
[3]->arg
);
1894 DEFUN (no_ospf_area_import_list
,
1895 no_ospf_area_import_list_cmd
,
1896 "no area <A.B.C.D|(0-4294967295)> import-list NAME",
1898 "OSPF area parameters\n"
1899 "OSPF area ID in IP address format\n"
1900 "OSPF area ID as a decimal value\n"
1901 "Unset the filter for networks announced to other areas\n"
1902 "Name of the access-list\n")
1904 int idx_ipv4_number
= 2;
1905 struct ospf
*ospf
= vty
->index
;
1906 struct ospf_area
*area
;
1907 struct in_addr area_id
;
1913 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1915 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1919 ospf_area_import_list_unset (ospf
, area
);
1924 DEFUN (ospf_area_filter_list
,
1925 ospf_area_filter_list_cmd
,
1926 "area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>",
1927 "OSPF area parameters\n"
1928 "OSPF area ID in IP address format\n"
1929 "OSPF area ID as a decimal value\n"
1930 "Filter networks between OSPF areas\n"
1931 "Filter prefixes between OSPF areas\n"
1932 "Name of an IP prefix-list\n"
1933 "Filter networks sent to this area\n"
1934 "Filter networks sent from this area\n")
1936 int idx_ipv4_number
= 1;
1939 struct ospf
*ospf
= vty
->index
;
1940 struct ospf_area
*area
;
1941 struct in_addr area_id
;
1942 struct prefix_list
*plist
;
1948 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1950 area
= ospf_area_get (ospf
, area_id
, format
);
1951 plist
= prefix_list_lookup (AFI_IP
, argv
[idx_word
]->arg
);
1952 if (strncmp (argv
[idx_in_out
]->arg
, "in", 2) == 0)
1954 PREFIX_LIST_IN (area
) = plist
;
1955 if (PREFIX_NAME_IN (area
))
1956 free (PREFIX_NAME_IN (area
));
1958 PREFIX_NAME_IN (area
) = strdup (argv
[idx_word
]->arg
);
1959 ospf_schedule_abr_task (ospf
);
1963 PREFIX_LIST_OUT (area
) = plist
;
1964 if (PREFIX_NAME_OUT (area
))
1965 free (PREFIX_NAME_OUT (area
));
1967 PREFIX_NAME_OUT (area
) = strdup (argv
[idx_word
]->arg
);
1968 ospf_schedule_abr_task (ospf
);
1974 DEFUN (no_ospf_area_filter_list
,
1975 no_ospf_area_filter_list_cmd
,
1976 "no area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>",
1978 "OSPF area parameters\n"
1979 "OSPF area ID in IP address format\n"
1980 "OSPF area ID as a decimal value\n"
1981 "Filter networks between OSPF areas\n"
1982 "Filter prefixes between OSPF areas\n"
1983 "Name of an IP prefix-list\n"
1984 "Filter networks sent to this area\n"
1985 "Filter networks sent from this area\n")
1987 int idx_ipv4_number
= 2;
1990 struct ospf
*ospf
= vty
->index
;
1991 struct ospf_area
*area
;
1992 struct in_addr area_id
;
1998 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
2000 if ((area
= ospf_area_lookup_by_area_id (ospf
, area_id
)) == NULL
)
2003 if (strncmp (argv
[idx_in_out
]->arg
, "in", 2) == 0)
2005 if (PREFIX_NAME_IN (area
))
2006 if (strcmp (PREFIX_NAME_IN (area
), argv
[idx_word
]->arg
) != 0)
2009 PREFIX_LIST_IN (area
) = NULL
;
2010 if (PREFIX_NAME_IN (area
))
2011 free (PREFIX_NAME_IN (area
));
2013 PREFIX_NAME_IN (area
) = NULL
;
2015 ospf_schedule_abr_task (ospf
);
2019 if (PREFIX_NAME_OUT (area
))
2020 if (strcmp (PREFIX_NAME_OUT (area
), argv
[idx_word
]->arg
) != 0)
2023 PREFIX_LIST_OUT (area
) = NULL
;
2024 if (PREFIX_NAME_OUT (area
))
2025 free (PREFIX_NAME_OUT (area
));
2027 PREFIX_NAME_OUT (area
) = NULL
;
2029 ospf_schedule_abr_task (ospf
);
2036 DEFUN (ospf_area_authentication_message_digest
,
2037 ospf_area_authentication_message_digest_cmd
,
2038 "area <A.B.C.D|(0-4294967295)> authentication message-digest",
2039 "OSPF area parameters\n"
2040 "OSPF area ID in IP address format\n"
2041 "OSPF area ID as a decimal value\n"
2042 "Enable authentication\n"
2043 "Use message-digest authentication\n")
2045 int idx_ipv4_number
= 1;
2046 struct ospf
*ospf
= vty
->index
;
2047 struct ospf_area
*area
;
2048 struct in_addr area_id
;
2054 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
2056 area
= ospf_area_get (ospf
, area_id
, format
);
2057 area
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
2062 DEFUN (ospf_area_authentication
,
2063 ospf_area_authentication_cmd
,
2064 "area <A.B.C.D|(0-4294967295)> authentication",
2065 "OSPF area parameters\n"
2066 "OSPF area ID in IP address format\n"
2067 "OSPF area ID as a decimal value\n"
2068 "Enable authentication\n")
2070 int idx_ipv4_number
= 1;
2071 struct ospf
*ospf
= vty
->index
;
2072 struct ospf_area
*area
;
2073 struct in_addr area_id
;
2079 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
2081 area
= ospf_area_get (ospf
, area_id
, format
);
2082 area
->auth_type
= OSPF_AUTH_SIMPLE
;
2087 DEFUN (no_ospf_area_authentication
,
2088 no_ospf_area_authentication_cmd
,
2089 "no area <A.B.C.D|(0-4294967295)> authentication",
2091 "OSPF area parameters\n"
2092 "OSPF area ID in IP address format\n"
2093 "OSPF area ID as a decimal value\n"
2094 "Enable authentication\n")
2096 int idx_ipv4_number
= 2;
2097 struct ospf
*ospf
= vty
->index
;
2098 struct ospf_area
*area
;
2099 struct in_addr area_id
;
2105 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
2107 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
2111 area
->auth_type
= OSPF_AUTH_NULL
;
2113 ospf_area_check_free (ospf
, area_id
);
2119 DEFUN (ospf_abr_type
,
2121 "ospf abr-type <cisco|ibm|shortcut|standard>",
2122 "OSPF specific commands\n"
2123 "Set OSPF ABR type\n"
2124 "Alternative ABR, cisco implementation\n"
2125 "Alternative ABR, IBM implementation\n"
2127 "Standard behavior (RFC2328)\n")
2130 struct ospf
*ospf
= vty
->index
;
2131 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2136 if (strncmp (argv
[idx_vendor
]->arg
, "c", 1) == 0)
2137 abr_type
= OSPF_ABR_CISCO
;
2138 else if (strncmp (argv
[idx_vendor
]->arg
, "i", 1) == 0)
2139 abr_type
= OSPF_ABR_IBM
;
2140 else if (strncmp (argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2141 abr_type
= OSPF_ABR_SHORTCUT
;
2142 else if (strncmp (argv
[idx_vendor
]->arg
, "st", 2) == 0)
2143 abr_type
= OSPF_ABR_STAND
;
2147 /* If ABR type value is changed, schedule ABR task. */
2148 if (ospf
->abr_type
!= abr_type
)
2150 ospf
->abr_type
= abr_type
;
2151 ospf_schedule_abr_task (ospf
);
2157 DEFUN (no_ospf_abr_type
,
2158 no_ospf_abr_type_cmd
,
2159 "no ospf abr-type <cisco|ibm|shortcut|standard>",
2161 "OSPF specific commands\n"
2162 "Set OSPF ABR type\n"
2163 "Alternative ABR, cisco implementation\n"
2164 "Alternative ABR, IBM implementation\n"
2169 struct ospf
*ospf
= vty
->index
;
2170 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2175 if (strncmp (argv
[idx_vendor
]->arg
, "c", 1) == 0)
2176 abr_type
= OSPF_ABR_CISCO
;
2177 else if (strncmp (argv
[idx_vendor
]->arg
, "i", 1) == 0)
2178 abr_type
= OSPF_ABR_IBM
;
2179 else if (strncmp (argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2180 abr_type
= OSPF_ABR_SHORTCUT
;
2181 else if (strncmp (argv
[idx_vendor
]->arg
, "st", 2) == 0)
2182 abr_type
= OSPF_ABR_STAND
;
2186 /* If ABR type value is changed, schedule ABR task. */
2187 if (ospf
->abr_type
== abr_type
)
2189 ospf
->abr_type
= OSPF_ABR_DEFAULT
;
2190 ospf_schedule_abr_task (ospf
);
2196 DEFUN (ospf_log_adjacency_changes
,
2197 ospf_log_adjacency_changes_cmd
,
2198 "log-adjacency-changes",
2199 "Log changes in adjacency state\n")
2201 struct ospf
*ospf
= vty
->index
;
2206 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2207 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2211 DEFUN (ospf_log_adjacency_changes_detail
,
2212 ospf_log_adjacency_changes_detail_cmd
,
2213 "log-adjacency-changes detail",
2214 "Log changes in adjacency state\n"
2215 "Log all state changes\n")
2217 struct ospf
*ospf
= vty
->index
;
2222 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2223 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2227 DEFUN (no_ospf_log_adjacency_changes
,
2228 no_ospf_log_adjacency_changes_cmd
,
2229 "no log-adjacency-changes",
2231 "Log changes in adjacency state\n")
2233 struct ospf
*ospf
= vty
->index
;
2238 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2239 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2243 DEFUN (no_ospf_log_adjacency_changes_detail
,
2244 no_ospf_log_adjacency_changes_detail_cmd
,
2245 "no log-adjacency-changes detail",
2247 "Log changes in adjacency state\n"
2248 "Log all state changes\n")
2250 struct ospf
*ospf
= vty
->index
;
2255 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2256 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2260 DEFUN (ospf_compatible_rfc1583
,
2261 ospf_compatible_rfc1583_cmd
,
2262 "compatible rfc1583",
2263 "OSPF compatibility list\n"
2264 "compatible with RFC 1583\n")
2266 struct ospf
*ospf
= vty
->index
;
2271 if (!CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
2273 SET_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2274 ospf_spf_calculate_schedule (ospf
, SPF_FLAG_CONFIG_CHANGE
);
2279 DEFUN (no_ospf_compatible_rfc1583
,
2280 no_ospf_compatible_rfc1583_cmd
,
2281 "no compatible rfc1583",
2283 "OSPF compatibility list\n"
2284 "compatible with RFC 1583\n")
2286 struct ospf
*ospf
= vty
->index
;
2291 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
2293 UNSET_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2294 ospf_spf_calculate_schedule (ospf
, SPF_FLAG_CONFIG_CHANGE
);
2299 ALIAS (ospf_compatible_rfc1583
,
2300 ospf_rfc1583_flag_cmd
,
2301 "ospf rfc1583compatibility",
2302 "OSPF specific commands\n"
2303 "Enable the RFC1583Compatibility flag\n")
2305 ALIAS (no_ospf_compatible_rfc1583
,
2306 no_ospf_rfc1583_flag_cmd
,
2307 "no ospf rfc1583compatibility",
2309 "OSPF specific commands\n"
2310 "Disable the RFC1583Compatibility flag\n")
2313 ospf_timers_spf_set (struct vty
*vty
, unsigned int delay
,
2317 struct ospf
*ospf
= vty
->index
;
2322 ospf
->spf_delay
= delay
;
2323 ospf
->spf_holdtime
= hold
;
2324 ospf
->spf_max_holdtime
= max
;
2329 DEFUN (ospf_timers_min_ls_interval
,
2330 ospf_timers_min_ls_interval_cmd
,
2331 "timers throttle lsa all (0-5000)",
2332 "Adjust routing timers\n"
2333 "Throttling adaptive timer\n"
2334 "LSA delay between transmissions\n"
2336 "Delay (msec) between sending LSAs\n")
2339 struct ospf
*ospf
= vty
->index
;
2340 unsigned int interval
;
2347 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2351 VTY_GET_INTEGER ("LSA interval", interval
, argv
[idx_number
]->arg
);
2353 ospf
->min_ls_interval
= interval
;
2358 DEFUN (no_ospf_timers_min_ls_interval
,
2359 no_ospf_timers_min_ls_interval_cmd
,
2360 "no timers throttle lsa all [(0-5000)]",
2362 "Adjust routing timers\n"
2363 "Throttling adaptive timer\n"
2364 "LSA delay between transmissions\n"
2366 "Delay (msec) between sending LSAs\n")
2368 struct ospf
*ospf
= vty
->index
;
2369 ospf
->min_ls_interval
= OSPF_MIN_LS_INTERVAL
;
2375 DEFUN (ospf_timers_min_ls_arrival
,
2376 ospf_timers_min_ls_arrival_cmd
,
2377 "timers lsa arrival (0-1000)",
2378 "Adjust routing timers\n"
2379 "Throttling link state advertisement delays\n"
2380 "OSPF minimum arrival interval delay\n"
2381 "Delay (msec) between accepted LSAs\n")
2384 struct ospf
*ospf
= vty
->index
;
2385 unsigned int arrival
;
2392 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2396 VTY_GET_INTEGER_RANGE ("minimum LSA inter-arrival time", arrival
, argv
[idx_number
]->arg
, 0, 1000);
2398 ospf
->min_ls_arrival
= arrival
;
2403 DEFUN (no_ospf_timers_min_ls_arrival
,
2404 no_ospf_timers_min_ls_arrival_cmd
,
2405 "no timers lsa arrival [(0-1000)]",
2407 "Adjust routing timers\n"
2408 "Throttling link state advertisement delays\n"
2409 "OSPF minimum arrival interval delay\n"
2410 "Delay (msec) between accepted LSAs\n")
2412 struct ospf
*ospf
= vty
->index
;
2417 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2423 DEFUN (ospf_timers_throttle_spf
,
2424 ospf_timers_throttle_spf_cmd
,
2425 "timers throttle spf (0-600000) (0-600000) (0-600000)",
2426 "Adjust routing timers\n"
2427 "Throttling adaptive timer\n"
2429 "Delay (msec) from first change received till SPF calculation\n"
2430 "Initial hold time (msec) between consecutive SPF calculations\n"
2431 "Maximum hold time (msec)\n")
2434 int idx_number_2
= 4;
2435 int idx_number_3
= 5;
2436 unsigned int delay
, hold
, max
;
2440 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2444 VTY_GET_INTEGER_RANGE ("SPF delay timer", delay
, argv
[idx_number
]->arg
, 0, 600000);
2445 VTY_GET_INTEGER_RANGE ("SPF hold timer", hold
, argv
[idx_number_2
]->arg
, 0, 600000);
2446 VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max
, argv
[idx_number_3
]->arg
, 0, 600000);
2448 return ospf_timers_spf_set (vty
, delay
, hold
, max
);
2451 DEFUN (no_ospf_timers_throttle_spf
,
2452 no_ospf_timers_throttle_spf_cmd
,
2453 "no timers throttle spf [(0-600000)(0-600000)(0-600000)]",
2455 "Adjust routing timers\n"
2456 "Throttling adaptive timer\n"
2458 "Delay (msec) from first change received till SPF calculation\n"
2459 "Initial hold time (msec) between consecutive SPF calculations\n"
2460 "Maximum hold time (msec)\n")
2462 return ospf_timers_spf_set (vty
,
2463 OSPF_SPF_DELAY_DEFAULT
,
2464 OSPF_SPF_HOLDTIME_DEFAULT
,
2465 OSPF_SPF_MAX_HOLDTIME_DEFAULT
);
2469 DEFUN (ospf_timers_lsa
,
2470 ospf_timers_lsa_cmd
,
2471 "timers lsa min-arrival (0-600000)",
2472 "Adjust routing timers\n"
2474 "Minimum delay in receiving new version of a LSA\n"
2475 "Delay in milliseconds\n")
2478 unsigned int minarrival
;
2479 struct ospf
*ospf
= vty
->index
;
2486 vty_out (vty
, "Insufficient number of arguments%s", VTY_NEWLINE
);
2490 VTY_GET_INTEGER ("LSA min-arrival", minarrival
, argv
[idx_number
]->arg
);
2492 ospf
->min_ls_arrival
= minarrival
;
2497 DEFUN (no_ospf_timers_lsa
,
2498 no_ospf_timers_lsa_cmd
,
2499 "no timers lsa min-arrival [(0-600000)]",
2501 "Adjust routing timers\n"
2503 "Minimum delay in receiving new version of a LSA\n"
2504 "Delay in milliseconds\n")
2506 unsigned int minarrival
;
2507 struct ospf
*ospf
= vty
->index
;
2514 VTY_GET_INTEGER ("LSA min-arrival", minarrival
, argv
[4]->arg
);
2516 if (ospf
->min_ls_arrival
!= minarrival
||
2517 minarrival
== OSPF_MIN_LS_ARRIVAL
)
2521 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2526 DEFUN (ospf_neighbor
,
2528 "neighbor A.B.C.D [priority (0-255) [poll-interval (1-65535)]]",
2530 "Neighbor IP address\n"
2531 "Neighbor Priority\n"
2533 "Dead Neighbor Polling interval\n"
2539 struct ospf
*ospf
= vty
->index
;
2540 struct in_addr nbr_addr
;
2541 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2542 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2547 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2550 VTY_GET_INTEGER_RANGE ("neighbor priority", priority
, argv
[idx_pri
]->arg
, 0, 255);
2553 VTY_GET_INTEGER_RANGE ("poll interval", interval
, argv
[idx_poll
]->arg
, 1, 65535);
2555 ospf_nbr_nbma_set (ospf
, nbr_addr
);
2558 ospf_nbr_nbma_priority_set (ospf
, nbr_addr
, priority
);
2561 ospf_nbr_nbma_poll_interval_set (ospf
, nbr_addr
, interval
);
2566 DEFUN (ospf_neighbor_poll_interval
,
2567 ospf_neighbor_poll_interval_cmd
,
2568 "neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2570 "Neighbor IP address\n"
2571 "Dead Neighbor Polling interval\n"
2573 "OSPF priority of non-broadcast neighbor\n"
2579 struct ospf
*ospf
= vty
->index
;
2580 struct in_addr nbr_addr
;
2581 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2582 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2587 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2589 VTY_GET_INTEGER_RANGE ("poll interval", interval
, argv
[idx_poll
]->arg
, 1, 65535);
2592 VTY_GET_INTEGER_RANGE ("neighbor priority", priority
, argv
[idx_pri
]->arg
, 0, 255);
2594 ospf_nbr_nbma_set (ospf
, nbr_addr
);
2595 ospf_nbr_nbma_poll_interval_set (ospf
, nbr_addr
, interval
);
2598 ospf_nbr_nbma_priority_set (ospf
, nbr_addr
, priority
);
2603 DEFUN (no_ospf_neighbor
,
2604 no_ospf_neighbor_cmd
,
2605 "no neighbor A.B.C.D [priority (0-255) [poll-interval (1-65525)]]",
2608 "Neighbor IP address\n"
2609 "Neighbor Priority\n"
2611 "Dead Neighbor Polling interval\n"
2615 struct ospf
*ospf
= vty
->index
;
2616 struct in_addr nbr_addr
;
2621 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2623 (void)ospf_nbr_nbma_unset (ospf
, nbr_addr
);
2628 DEFUN (no_ospf_neighbor_poll
,
2629 no_ospf_neighbor_poll_cmd
,
2630 "no neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2633 "Neighbor IP address\n"
2634 "Dead Neighbor Polling interval\n"
2636 "Neighbor Priority\n"
2640 struct ospf
*ospf
= vty
->index
;
2641 struct in_addr nbr_addr
;
2646 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2648 (void)ospf_nbr_nbma_unset (ospf
, nbr_addr
);
2653 DEFUN (ospf_refresh_timer
,
2654 ospf_refresh_timer_cmd
,
2655 "refresh timer (10-1800)",
2656 "Adjust refresh parameters\n"
2657 "Set refresh timer\n"
2658 "Timer value in seconds\n")
2661 struct ospf
*ospf
= vty
->index
;
2662 unsigned int interval
;
2667 VTY_GET_INTEGER_RANGE ("refresh timer", interval
, argv
[idx_number
]->arg
, 10, 1800);
2668 interval
= (interval
/ OSPF_LSA_REFRESHER_GRANULARITY
) * OSPF_LSA_REFRESHER_GRANULARITY
;
2670 ospf_timers_refresh_set (ospf
, interval
);
2675 DEFUN (no_ospf_refresh_timer
,
2676 no_ospf_refresh_timer_val_cmd
,
2677 "no refresh timer [(10-1800)]",
2679 "Adjust refresh parameters\n"
2680 "Unset refresh timer\n"
2681 "Timer value in seconds\n")
2684 struct ospf
*ospf
= vty
->index
;
2685 unsigned int interval
;
2692 VTY_GET_INTEGER_RANGE ("refresh timer", interval
, argv
[idx_number
]->arg
, 10, 1800);
2694 if (ospf
->lsa_refresh_interval
!= interval
||
2695 interval
== OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
2699 ospf_timers_refresh_unset (ospf
);
2705 DEFUN (ospf_auto_cost_reference_bandwidth
,
2706 ospf_auto_cost_reference_bandwidth_cmd
,
2707 "auto-cost reference-bandwidth (1-4294967)",
2708 "Calculate OSPF interface cost according to bandwidth\n"
2709 "Use reference bandwidth method to assign OSPF cost\n"
2710 "The reference bandwidth in terms of Mbits per second\n")
2713 struct ospf
*ospf
= vty
->index
;
2715 struct listnode
*node
;
2716 struct interface
*ifp
;
2721 refbw
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
2722 if (refbw
< 1 || refbw
> 4294967)
2724 vty_out (vty
, "reference-bandwidth value is invalid%s", VTY_NEWLINE
);
2728 /* If reference bandwidth is changed. */
2729 if ((refbw
) == ospf
->ref_bandwidth
)
2732 ospf
->ref_bandwidth
= refbw
;
2733 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, node
, ifp
))
2734 ospf_if_recalculate_output_cost (ifp
);
2739 DEFUN (no_ospf_auto_cost_reference_bandwidth
,
2740 no_ospf_auto_cost_reference_bandwidth_cmd
,
2741 "no auto-cost reference-bandwidth [(1-4294967)]",
2743 "Calculate OSPF interface cost according to bandwidth\n"
2744 "Use reference bandwidth method to assign OSPF cost\n"
2745 "The reference bandwidth in terms of Mbits per second\n")
2747 struct ospf
*ospf
= vty
->index
;
2748 struct listnode
*node
, *nnode
;
2749 struct interface
*ifp
;
2754 if (ospf
->ref_bandwidth
== OSPF_DEFAULT_REF_BANDWIDTH
)
2757 ospf
->ref_bandwidth
= OSPF_DEFAULT_REF_BANDWIDTH
;
2758 vty_out (vty
, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE
);
2759 vty_out (vty
, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE
);
2761 for (ALL_LIST_ELEMENTS (om
->iflist
, node
, nnode
, ifp
))
2762 ospf_if_recalculate_output_cost (ifp
);
2767 DEFUN (ospf_write_multiplier
,
2768 ospf_write_multiplier_cmd
,
2769 "ospf write-multiplier (1-100)",
2770 "OSPF specific commands\n"
2771 "Write multiplier\n"
2772 "Maximum number of interface serviced per write\n")
2775 struct ospf
*ospf
= vty
->index
;
2776 u_int32_t write_oi_count
;
2786 write_oi_count
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
2787 if (write_oi_count
< 1 || write_oi_count
> 100)
2789 vty_out (vty
, "write-multiplier value is invalid%s", VTY_NEWLINE
);
2793 ospf
->write_oi_count
= write_oi_count
;
2797 ALIAS (ospf_write_multiplier
,
2798 write_multiplier_cmd
,
2799 "write-multiplier (1-100)",
2800 "Write multiplier\n"
2801 "Maximum number of interface serviced per write\n")
2803 DEFUN (no_ospf_write_multiplier
,
2804 no_ospf_write_multiplier_cmd
,
2805 "no ospf write-multiplier (1-100)",
2807 "OSPF specific commands\n"
2808 "Write multiplier\n"
2809 "Maximum number of interface serviced per write\n")
2811 struct ospf
*ospf
= vty
->index
;
2816 ospf
->write_oi_count
= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
;
2820 ALIAS (no_ospf_write_multiplier
,
2821 no_write_multiplier_cmd
,
2822 "no write-multiplier (1-100)",
2824 "Write multiplier\n"
2825 "Maximum number of interface serviced per write\n")
2827 const char *ospf_abr_type_descr_str
[] =
2830 "Standard (RFC2328)",
2832 "Alternative Cisco",
2833 "Alternative Shortcut"
2836 const char *ospf_shortcut_mode_descr_str
[] =
2844 show_ip_ospf_area (struct vty
*vty
, struct ospf_area
*area
, json_object
*json_areas
, u_char use_json
)
2846 json_object
*json_area
= NULL
;
2849 json_area
= json_object_new_object();
2853 vty_out (vty
, " Area ID: %s", inet_ntoa (area
->area_id
));
2855 /* Show Area type/mode. */
2856 if (OSPF_IS_AREA_BACKBONE (area
))
2859 json_object_boolean_true_add(json_area
, "backbone");
2861 vty_out (vty
, " (Backbone)%s", VTY_NEWLINE
);
2867 if (area
->external_routing
== OSPF_AREA_STUB
)
2869 if (area
->no_summary
)
2870 json_object_boolean_true_add(json_area
, "stubNoSummary");
2871 if (area
->shortcut_configured
)
2872 json_object_boolean_true_add(json_area
, "stubShortcut");
2874 else if (area
->external_routing
== OSPF_AREA_NSSA
)
2876 if (area
->no_summary
)
2877 json_object_boolean_true_add(json_area
, "nssaNoSummary");
2878 if (area
->shortcut_configured
)
2879 json_object_boolean_true_add(json_area
, "nssaShortcut");
2882 json_object_string_add(json_area
,"shortcuttingMode",
2883 ospf_shortcut_mode_descr_str
[area
->shortcut_configured
]);
2884 if (area
->shortcut_capability
)
2885 json_object_boolean_true_add(json_area
,"sBitConcensus");
2889 if (area
->external_routing
== OSPF_AREA_STUB
)
2890 vty_out (vty
, " (Stub%s%s)",
2891 area
->no_summary
? ", no summary" : "",
2892 area
->shortcut_configured
? "; " : "");
2893 else if (area
->external_routing
== OSPF_AREA_NSSA
)
2894 vty_out (vty
, " (NSSA%s%s)",
2895 area
->no_summary
? ", no summary" : "",
2896 area
->shortcut_configured
? "; " : "");
2898 vty_out (vty
, "%s", VTY_NEWLINE
);
2899 vty_out (vty
, " Shortcutting mode: %s",
2900 ospf_shortcut_mode_descr_str
[area
->shortcut_configured
]);
2901 vty_out (vty
, ", S-bit consensus: %s%s",
2902 area
->shortcut_capability
? "ok" : "no", VTY_NEWLINE
);
2906 /* Show number of interfaces */
2909 json_object_int_add(json_area
, "areaIfTotalCounter", listcount (area
->oiflist
));
2910 json_object_int_add(json_area
, "areaIfActiveCounter", area
->act_ints
);
2913 vty_out (vty
, " Number of interfaces in this area: Total: %d, "
2914 "Active: %d%s", listcount (area
->oiflist
),
2915 area
->act_ints
, VTY_NEWLINE
);
2917 if (area
->external_routing
== OSPF_AREA_NSSA
)
2921 json_object_boolean_true_add(json_area
, "nssa");
2922 if (! IS_OSPF_ABR (area
->ospf
))
2923 json_object_boolean_false_add(json_area
, "abr");
2924 else if (area
->NSSATranslatorState
)
2926 json_object_boolean_true_add(json_area
, "abr");
2927 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
2928 json_object_boolean_true_add(json_area
, "nssaTranslatorElected");
2929 else if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_ALWAYS
)
2930 json_object_boolean_true_add(json_area
, "nssaTranslatorAlways");
2934 json_object_boolean_true_add(json_area
, "abr");
2935 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
2936 json_object_boolean_false_add(json_area
, "nssaTranslatorElected");
2938 json_object_boolean_true_add(json_area
, "nssaTranslatorNever");
2943 vty_out (vty
, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE
, VTY_NEWLINE
);
2944 if (! IS_OSPF_ABR (area
->ospf
))
2945 vty_out (vty
, " It is not ABR, therefore not Translator. %s",
2947 else if (area
->NSSATranslatorState
)
2949 vty_out (vty
, " We are an ABR and ");
2950 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
2951 vty_out (vty
, "the NSSA Elected Translator. %s",
2953 else if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_ALWAYS
)
2954 vty_out (vty
, "always an NSSA Translator. %s",
2959 vty_out (vty
, " We are an ABR, but ");
2960 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
2961 vty_out (vty
, "not the NSSA Elected Translator. %s",
2964 vty_out (vty
, "never an NSSA Translator. %s",
2970 /* Stub-router state for this area */
2971 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
))
2973 char timebuf
[OSPF_TIME_DUMP_SIZE
];
2977 json_object_boolean_true_add(json_area
, "originStubMaxDistRouterLsa");
2978 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
2979 json_object_boolean_true_add(json_area
, "indefiniteActiveAdmin");
2980 if (area
->t_stub_router
)
2982 struct timeval result
;
2983 unsigned long time_store
= 0;
2984 result
= tv_sub (area
->t_stub_router
->u
.sands
, recent_relative_time());
2985 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
2986 json_object_int_add(json_area
, "activeStartupRemainderMsecs", time_store
);
2991 vty_out (vty
, " Originating stub / maximum-distance Router-LSA%s",
2993 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
2994 vty_out (vty
, " Administratively activated (indefinitely)%s",
2996 if (area
->t_stub_router
)
2997 vty_out (vty
, " Active from startup, %s remaining%s",
2998 ospf_timer_dump (area
->t_stub_router
, timebuf
,
2999 sizeof(timebuf
)), VTY_NEWLINE
);
3005 /* Show number of fully adjacent neighbors. */
3006 json_object_int_add(json_area
, "nbrFullAdjacentCounter", area
->full_nbrs
);
3008 /* Show authentication type. */
3009 if (area
->auth_type
== OSPF_AUTH_NULL
)
3010 json_object_string_add(json_area
, "authentication", "authenticationNone");
3011 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
3012 json_object_string_add(json_area
, "authentication", "authenticationSimplePassword");
3013 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
3014 json_object_string_add(json_area
, "authentication", "authenticationMessageDigest");
3016 if (!OSPF_IS_AREA_BACKBONE (area
))
3017 json_object_int_add(json_area
, "virtualAdjacenciesPassingCounter", area
->full_vls
);
3019 /* Show SPF calculation times. */
3020 json_object_int_add(json_area
, "spfExecutedCounter", area
->spf_calculation
);
3021 json_object_int_add(json_area
, "lsaNumber", area
->lsdb
->total
);
3022 json_object_int_add(json_area
, "lsaRouterNumber", ospf_lsdb_count (area
->lsdb
, OSPF_ROUTER_LSA
));
3023 json_object_int_add(json_area
, "lsaRouterChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_ROUTER_LSA
));
3024 json_object_int_add(json_area
, "lsaNetworkNumber", ospf_lsdb_count (area
->lsdb
, OSPF_NETWORK_LSA
));
3025 json_object_int_add(json_area
, "lsaNetworkChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_NETWORK_LSA
));
3026 json_object_int_add(json_area
, "lsaSummaryNumber", ospf_lsdb_count (area
->lsdb
, OSPF_SUMMARY_LSA
));
3027 json_object_int_add(json_area
, "lsaSummaryChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_SUMMARY_LSA
));
3028 json_object_int_add(json_area
, "lsaAsbrNumber", ospf_lsdb_count (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
3029 json_object_int_add(json_area
, "lsaAsbrChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
3030 json_object_int_add(json_area
, "lsaNssaNumber", ospf_lsdb_count (area
->lsdb
, OSPF_AS_NSSA_LSA
));
3031 json_object_int_add(json_area
, "lsaNssaChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_AS_NSSA_LSA
));
3035 /* Show number of fully adjacent neighbors. */
3036 vty_out (vty
, " Number of fully adjacent neighbors in this area:"
3037 " %d%s", area
->full_nbrs
, VTY_NEWLINE
);
3039 /* Show authentication type. */
3040 vty_out (vty
, " Area has ");
3041 if (area
->auth_type
== OSPF_AUTH_NULL
)
3042 vty_out (vty
, "no authentication%s", VTY_NEWLINE
);
3043 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
3044 vty_out (vty
, "simple password authentication%s", VTY_NEWLINE
);
3045 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
3046 vty_out (vty
, "message digest authentication%s", VTY_NEWLINE
);
3048 if (!OSPF_IS_AREA_BACKBONE (area
))
3049 vty_out (vty
, " Number of full virtual adjacencies going through"
3050 " this area: %d%s", area
->full_vls
, VTY_NEWLINE
);
3052 /* Show SPF calculation times. */
3053 vty_out (vty
, " SPF algorithm executed %d times%s",
3054 area
->spf_calculation
, VTY_NEWLINE
);
3056 /* Show number of LSA. */
3057 vty_out (vty
, " Number of LSA %ld%s", area
->lsdb
->total
, VTY_NEWLINE
);
3058 vty_out (vty
, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
3059 ospf_lsdb_count (area
->lsdb
, OSPF_ROUTER_LSA
),
3060 ospf_lsdb_checksum (area
->lsdb
, OSPF_ROUTER_LSA
), VTY_NEWLINE
);
3061 vty_out (vty
, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
3062 ospf_lsdb_count (area
->lsdb
, OSPF_NETWORK_LSA
),
3063 ospf_lsdb_checksum (area
->lsdb
, OSPF_NETWORK_LSA
), VTY_NEWLINE
);
3064 vty_out (vty
, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
3065 ospf_lsdb_count (area
->lsdb
, OSPF_SUMMARY_LSA
),
3066 ospf_lsdb_checksum (area
->lsdb
, OSPF_SUMMARY_LSA
), VTY_NEWLINE
);
3067 vty_out (vty
, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
3068 ospf_lsdb_count (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
),
3069 ospf_lsdb_checksum (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
), VTY_NEWLINE
);
3070 vty_out (vty
, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
3071 ospf_lsdb_count (area
->lsdb
, OSPF_AS_NSSA_LSA
),
3072 ospf_lsdb_checksum (area
->lsdb
, OSPF_AS_NSSA_LSA
), VTY_NEWLINE
);
3077 json_object_int_add(json_area
, "lsaOpaqueLinkNumber", ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
3078 json_object_int_add(json_area
, "lsaOpaqueLinkChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
3079 json_object_int_add(json_area
, "lsaOpaqueAreaNumber", ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
3080 json_object_int_add(json_area
, "lsaOpaqueAreaChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
3084 vty_out (vty
, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
3085 ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
),
3086 ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
), VTY_NEWLINE
);
3087 vty_out (vty
, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
3088 ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
),
3089 ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
), VTY_NEWLINE
);
3093 json_object_object_add(json_areas
, inet_ntoa (area
->area_id
), json_area
);
3095 vty_out (vty
, "%s", VTY_NEWLINE
);
3099 show_ip_ospf_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
3101 struct listnode
*node
, *nnode
;
3102 struct ospf_area
* area
;
3103 struct timeval result
;
3104 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3105 json_object
*json
= NULL
;
3106 json_object
*json_areas
= NULL
;
3110 json
= json_object_new_object();
3111 json_areas
= json_object_new_object();
3118 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3122 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3123 VTY_NEWLINE
, VTY_NEWLINE
);
3127 /* Show Router ID. */
3130 json_object_string_add(json
, "routerId", inet_ntoa (ospf
->router_id
));
3134 vty_out (vty
, " OSPF Routing Process, Router ID: %s%s",
3135 inet_ntoa (ospf
->router_id
),
3139 /* Graceful shutdown */
3140 if (ospf
->t_deferred_shutdown
)
3144 unsigned long time_store
= 0;
3145 result
= tv_sub (ospf
->t_deferred_shutdown
->u
.sands
, recent_relative_time());
3146 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3147 json_object_int_add(json
, "deferredShutdownMsecs", time_store
);
3151 vty_out (vty
, " Deferred shutdown in progress, %s remaining%s",
3152 ospf_timer_dump (ospf
->t_deferred_shutdown
,
3153 timebuf
, sizeof (timebuf
)), VTY_NEWLINE
);
3157 /* Show capability. */
3160 json_object_boolean_true_add(json
, "tosRoutesOnly");
3161 json_object_boolean_true_add(json
, "rfc2328Conform");
3162 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
3164 json_object_boolean_true_add(json
, "rfc1583Compatibility");
3169 vty_out (vty
, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE
);
3170 vty_out (vty
, " This implementation conforms to RFC2328%s", VTY_NEWLINE
);
3171 vty_out (vty
, " RFC1583Compatibility flag is %s%s",
3172 CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
) ?
3173 "enabled" : "disabled", VTY_NEWLINE
);
3178 if (CHECK_FLAG (ospf
->config
, OSPF_OPAQUE_CAPABLE
))
3180 json_object_boolean_true_add(json
, "opaqueCapable");
3185 vty_out (vty
, " OpaqueCapability flag is %s%s",
3186 CHECK_FLAG (ospf
->config
, OSPF_OPAQUE_CAPABLE
) ? "enabled" : "disabled",
3190 /* Show stub-router configuration */
3191 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
3192 || ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3196 json_object_boolean_true_add(json
, "stubAdvertisement");
3197 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3198 json_object_int_add(json
,"postStartEnabledMsecs", ospf
->stub_router_startup_time
/ 1000);
3199 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3200 json_object_int_add(json
,"preShutdownEnabledMsecs", ospf
->stub_router_shutdown_time
/ 1000);
3204 vty_out (vty
, " Stub router advertisement is configured%s",
3206 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3207 vty_out (vty
, " Enabled for %us after start-up%s",
3208 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
3209 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3210 vty_out (vty
, " Enabled for %us prior to full shutdown%s",
3211 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
3215 /* Show SPF timers. */
3218 json_object_int_add(json
, "spfScheduleDelayMsecs", ospf
->spf_delay
);
3219 json_object_int_add(json
, "holdtimeMinMsecs", ospf
->spf_holdtime
);
3220 json_object_int_add(json
, "holdtimeMaxMsecs", ospf
->spf_max_holdtime
);
3221 json_object_int_add(json
, "holdtimeMultplier", ospf
->spf_hold_multiplier
);
3225 vty_out (vty
, " Initial SPF scheduling delay %d millisec(s)%s"
3226 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
3227 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
3228 " Hold time multiplier is currently %d%s",
3229 ospf
->spf_delay
, VTY_NEWLINE
,
3230 ospf
->spf_holdtime
, VTY_NEWLINE
,
3231 ospf
->spf_max_holdtime
, VTY_NEWLINE
,
3232 ospf
->spf_hold_multiplier
, VTY_NEWLINE
);
3237 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
)
3239 unsigned long time_store
= 0;
3241 result
= tv_sub (recent_relative_time(), ospf
->ts_spf
);
3242 result
= tv_sub (result
, recent_relative_time());
3243 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3244 json_object_int_add(json
, "spfLastExecutedMsecs", time_store
);
3246 time_store
= (1000 * ospf
->ts_spf_duration
.tv_sec
) + (ospf
->ts_spf_duration
.tv_usec
/ 1000);
3247 json_object_int_add(json
, "spfLastDurationMsecs", time_store
);
3250 json_object_boolean_true_add(json
, "spfHasNotRun");
3254 vty_out (vty
, " SPF algorithm ");
3255 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
)
3257 result
= tv_sub (recent_relative_time(), ospf
->ts_spf
);
3258 vty_out (vty
, "last executed %s ago%s",
3259 ospf_timeval_dump (&result
, timebuf
, sizeof (timebuf
)),
3261 vty_out (vty
, " Last SPF duration %s%s",
3262 ospf_timeval_dump (&ospf
->ts_spf_duration
, timebuf
, sizeof (timebuf
)),
3266 vty_out (vty
, "has not been run%s", VTY_NEWLINE
);
3271 struct timeval temp_time
;
3272 unsigned long time_store
= 0;
3274 if (ospf
->t_spf_calc
)
3276 temp_time
= tv_sub (ospf
->t_spf_calc
->u
.sands
, recent_relative_time());
3277 time_store
= (1000 * temp_time
.tv_sec
) + (temp_time
.tv_usec
/ 1000);
3278 json_object_int_add(json
, "spfTimerDueInMsecs", time_store
);
3281 json_object_int_add(json
, "lsaMinIntervalMsecs", ospf
->min_ls_interval
);
3282 json_object_int_add(json
, "lsaMinArrivalMsecs", ospf
->min_ls_arrival
);
3283 /* Show write multiplier values */
3284 json_object_int_add(json
, "writeMultiplier", ospf
->write_oi_count
);
3285 /* Show refresh parameters. */
3286 json_object_int_add(json
, "refreshTimerMsecs", ospf
->lsa_refresh_interval
* 1000);
3290 vty_out (vty
, " SPF timer %s%s%s",
3291 (ospf
->t_spf_calc
? "due in " : "is "),
3292 ospf_timer_dump (ospf
->t_spf_calc
, timebuf
, sizeof (timebuf
)),
3295 vty_out (vty
, " LSA minimum interval %d msecs%s",
3296 ospf
->min_ls_interval
, VTY_NEWLINE
);
3297 vty_out (vty
, " LSA minimum arrival %d msecs%s",
3298 ospf
->min_ls_arrival
, VTY_NEWLINE
);
3300 /* Show write multiplier values */
3301 vty_out (vty
, " Write Multiplier set to %d %s",
3302 ospf
->write_oi_count
, VTY_NEWLINE
);
3304 /* Show refresh parameters. */
3305 vty_out (vty
, " Refresh timer %d secs%s",
3306 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
3309 /* Show ABR/ASBR flags. */
3310 if (CHECK_FLAG (ospf
->flags
, OSPF_FLAG_ABR
))
3313 json_object_string_add(json
, "abrType", ospf_abr_type_descr_str
[ospf
->abr_type
]);
3315 vty_out (vty
, " This router is an ABR, ABR type is: %s%s",
3316 ospf_abr_type_descr_str
[ospf
->abr_type
], VTY_NEWLINE
);
3318 if (CHECK_FLAG (ospf
->flags
, OSPF_FLAG_ASBR
))
3321 json_object_string_add(json
, "asbrRouter", "injectingExternalRoutingInformation");
3323 vty_out (vty
, " This router is an ASBR "
3324 "(injecting external routing information)%s", VTY_NEWLINE
);
3327 /* Show Number of AS-external-LSAs. */
3330 json_object_int_add(json
, "lsaExternalCounter",
3331 ospf_lsdb_count (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3332 json_object_int_add(json
, "lsaExternalChecksum",
3333 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3337 vty_out (vty
, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
3338 ospf_lsdb_count (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
),
3339 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
), VTY_NEWLINE
);
3344 json_object_int_add(json
, "lsaAsopaqueCounter",
3345 ospf_lsdb_count (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3346 json_object_int_add(json
, "lsaAsOpaqueChecksum",
3347 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3351 vty_out (vty
, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
3352 ospf_lsdb_count (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
),
3353 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
), VTY_NEWLINE
);
3356 /* Show number of areas attached. */
3358 json_object_int_add(json
, "attachedAreaCounter", listcount (ospf
->areas
));
3360 vty_out (vty
, " Number of areas attached to this router: %d%s",
3361 listcount (ospf
->areas
), VTY_NEWLINE
);
3363 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
))
3365 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
3368 json_object_boolean_true_add(json
, "adjacencyChangesLoggedAll");
3370 vty_out(vty
, " All adjacency changes are logged%s",VTY_NEWLINE
);
3375 json_object_boolean_true_add(json
, "adjacencyChangesLogged");
3377 vty_out(vty
, " Adjacency changes are logged%s",VTY_NEWLINE
);
3380 /* Show each area status. */
3381 for (ALL_LIST_ELEMENTS (ospf
->areas
, node
, nnode
, area
))
3382 show_ip_ospf_area (vty
, area
, json_areas
, use_json
);
3386 json_object_object_add(json
, "areas", json_areas
);
3387 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3388 json_object_free(json
);
3391 vty_out (vty
, "%s",VTY_NEWLINE
);
3396 DEFUN (show_ip_ospf
,
3398 "show ip ospf [json]",
3401 "OSPF information\n"
3405 u_char uj
= use_json(argc
, argv
);
3407 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3410 return (show_ip_ospf_common(vty
, ospf
, uj
));
3413 DEFUN (show_ip_ospf_instance
,
3414 show_ip_ospf_instance_cmd
,
3415 "show ip ospf (1-65535) [json]",
3418 "OSPF information\n"
3424 u_short instance
= 0;
3425 u_char uj
= use_json(argc
, argv
);
3427 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3428 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
3431 return (show_ip_ospf_common(vty
, ospf
, uj
));
3435 show_ip_ospf_interface_sub (struct vty
*vty
, struct ospf
*ospf
, struct interface
*ifp
,
3436 json_object
*json_interface_sub
, u_char use_json
)
3439 struct ospf_neighbor
*nbr
;
3440 struct route_node
*rn
;
3442 /* Is interface up? */
3445 is_up
= if_is_operative(ifp
);
3447 json_object_boolean_true_add(json_interface_sub
, "ifUp");
3449 json_object_boolean_false_add(json_interface_sub
, "ifDown");
3451 json_object_int_add(json_interface_sub
, "ifIndex", ifp
->ifindex
);
3452 json_object_int_add(json_interface_sub
, "mtuBytes", ifp
->mtu
);
3453 json_object_int_add(json_interface_sub
, "bandwidthMbit", ifp
->bandwidth
);
3454 json_object_string_add(json_interface_sub
, "ifFlags", if_flag_dump(ifp
->flags
));
3458 vty_out (vty
, "%s is %s%s", ifp
->name
,
3459 ((is_up
= if_is_operative(ifp
)) ? "up" : "down"), VTY_NEWLINE
);
3460 vty_out (vty
, " ifindex %u, MTU %u bytes, BW %u Mbit %s%s",
3461 ifp
->ifindex
, ifp
->mtu
, ifp
->bandwidth
, if_flag_dump(ifp
->flags
),
3465 /* Is interface OSPF enabled? */
3468 if (ospf_oi_count(ifp
) == 0)
3470 json_object_boolean_false_add(json_interface_sub
, "ospfEnabled");
3475 json_object_boolean_false_add(json_interface_sub
, "ospfRunning");
3479 json_object_boolean_true_add(json_interface_sub
, "ospfEnabled");
3483 if (ospf_oi_count(ifp
) == 0)
3485 vty_out (vty
, " OSPF not enabled on this interface%s", VTY_NEWLINE
);
3490 vty_out (vty
, " OSPF is enabled, but not running on this interface%s",
3496 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
3498 struct ospf_interface
*oi
= rn
->info
;
3503 if (CHECK_FLAG(oi
->connected
->flags
, ZEBRA_IFA_UNNUMBERED
))
3506 json_object_boolean_true_add(json_interface_sub
, "ifUnnumbered");
3508 vty_out (vty
, " This interface is UNNUMBERED,");
3512 /* Show OSPF interface information. */
3515 json_object_string_add(json_interface_sub
, "ipAddress", inet_ntoa (oi
->address
->u
.prefix4
));
3516 json_object_int_add(json_interface_sub
, "ipAddressPrefixlen", oi
->address
->prefixlen
);
3519 vty_out (vty
, " Internet Address %s/%d,",
3520 inet_ntoa (oi
->address
->u
.prefix4
), oi
->address
->prefixlen
);
3522 if (oi
->connected
->destination
|| oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3524 struct in_addr
*dest
;
3527 if (CONNECTED_PEER(oi
->connected
)
3528 || oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3533 /* For Vlinks, showing the peer address is probably more
3534 * * * * * informative than the local interface that is being used
3536 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3537 dest
= &oi
->vl_data
->peer_addr
;
3539 dest
= &oi
->connected
->destination
->u
.prefix4
;
3543 json_object_string_add(json_interface_sub
, "ospfIfType", dstr
);
3544 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3545 json_object_string_add(json_interface_sub
, "vlinkPeer", inet_ntoa (*dest
));
3547 json_object_string_add(json_interface_sub
, "localIfUsed", inet_ntoa (*dest
));
3550 vty_out (vty
, " %s %s,", dstr
, inet_ntoa (*dest
));
3555 json_object_string_add(json_interface_sub
, "area", ospf_area_desc_string (oi
->area
));
3556 if (OSPF_IF_PARAM(oi
, mtu_ignore
))
3557 json_object_boolean_true_add(json_interface_sub
, "mtuMismatchDetect");
3558 json_object_string_add(json_interface_sub
, "routerId", inet_ntoa (ospf
->router_id
));
3559 json_object_string_add(json_interface_sub
, "networkType", ospf_network_type_str
[oi
->type
]);
3560 json_object_int_add(json_interface_sub
, "cost", oi
->output_cost
);
3561 json_object_int_add(json_interface_sub
, "transmitDelayMsecs", 1000 / OSPF_IF_PARAM (oi
,transmit_delay
));
3562 json_object_string_add(json_interface_sub
, "state", LOOKUP (ospf_ism_state_msg
, oi
->state
));
3563 json_object_int_add(json_interface_sub
, "priority", PRIORITY (oi
));
3567 vty_out (vty
, " Area %s%s", ospf_area_desc_string (oi
->area
),
3570 vty_out (vty
, " MTU mismatch detection:%s%s",
3571 OSPF_IF_PARAM(oi
, mtu_ignore
) ? "disabled" : "enabled", VTY_NEWLINE
);
3573 vty_out (vty
, " Router ID %s, Network Type %s, Cost: %d%s",
3574 inet_ntoa (ospf
->router_id
), ospf_network_type_str
[oi
->type
],
3575 oi
->output_cost
, VTY_NEWLINE
);
3577 vty_out (vty
, " Transmit Delay is %d sec, State %s, Priority %d%s",
3578 OSPF_IF_PARAM (oi
,transmit_delay
), LOOKUP (ospf_ism_state_msg
, oi
->state
),
3579 PRIORITY (oi
), VTY_NEWLINE
);
3582 /* Show DR information. */
3583 if (DR (oi
).s_addr
== 0)
3586 vty_out (vty
, " No backup designated router on this network%s",
3591 nbr
= ospf_nbr_lookup_by_addr (oi
->nbrs
, &BDR (oi
));
3595 vty_out (vty
, " No backup designated router on this network%s",
3602 json_object_string_add(json_interface_sub
, "bdrId", inet_ntoa (nbr
->router_id
));
3603 json_object_string_add(json_interface_sub
, "bdrAddress", inet_ntoa (nbr
->address
.u
.prefix4
));
3607 vty_out (vty
, " Backup Designated Router (ID) %s,",
3608 inet_ntoa (nbr
->router_id
));
3609 vty_out (vty
, " Interface Address %s%s",
3610 inet_ntoa (nbr
->address
.u
.prefix4
), VTY_NEWLINE
);
3615 /* Next network-LSA sequence number we'll use, if we're elected DR */
3616 if (oi
->params
&& ntohl (oi
->params
->network_lsa_seqnum
) != OSPF_INITIAL_SEQUENCE_NUMBER
)
3619 json_object_int_add(json_interface_sub
, "networkLsaSequence", ntohl (oi
->params
->network_lsa_seqnum
));
3621 vty_out (vty
, " Saved Network-LSA sequence number 0x%x%s",
3622 ntohl (oi
->params
->network_lsa_seqnum
), VTY_NEWLINE
);
3627 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3628 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3630 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3631 json_object_boolean_true_add(json_interface_sub
, "mcastMemberOspfAllRouters");
3632 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3633 json_object_boolean_true_add(json_interface_sub
, "mcastMemberOspfDesignatedRouters");
3638 vty_out (vty
, " Multicast group memberships:");
3639 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3640 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3642 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3643 vty_out (vty
, " OSPFAllRouters");
3644 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3645 vty_out (vty
, " OSPFDesignatedRouters");
3648 vty_out (vty
, " <None>");
3649 vty_out (vty
, "%s", VTY_NEWLINE
);
3654 if (OSPF_IF_PARAM (oi
, fast_hello
) == 0)
3655 json_object_int_add(json_interface_sub
, "timerMsecs", 1000 /OSPF_IF_PARAM (oi
, v_hello
));
3657 json_object_int_add(json_interface_sub
, "timerMsecs", 1000 / OSPF_IF_PARAM (oi
, fast_hello
));
3658 json_object_int_add(json_interface_sub
, "timerDeadMsecs", 1000 / OSPF_IF_PARAM (oi
, v_wait
));
3659 json_object_int_add(json_interface_sub
, "timerWaitMsecs", 1000 / OSPF_IF_PARAM (oi
, v_wait
));
3660 json_object_int_add(json_interface_sub
, "timerRetransmit", 1000 / OSPF_IF_PARAM (oi
, retransmit_interval
));
3664 vty_out (vty
, " Timer intervals configured,");
3665 vty_out (vty
, " Hello ");
3666 if (OSPF_IF_PARAM (oi
, fast_hello
) == 0)
3667 vty_out (vty
, "%ds,", OSPF_IF_PARAM (oi
, v_hello
));
3669 vty_out (vty
, "%dms,", 1000 / OSPF_IF_PARAM (oi
, fast_hello
));
3670 vty_out (vty
, " Dead %ds, Wait %ds, Retransmit %d%s",
3671 OSPF_IF_PARAM (oi
, v_wait
),
3672 OSPF_IF_PARAM (oi
, v_wait
),
3673 OSPF_IF_PARAM (oi
, retransmit_interval
),
3677 if (OSPF_IF_PASSIVE_STATUS (oi
) == OSPF_IF_ACTIVE
)
3679 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3682 struct timeval result
;
3683 unsigned long time_store
= 0;
3685 result
= tv_sub (oi
->t_hello
->u
.sands
, recent_relative_time());
3691 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3692 json_object_int_add(json_interface_sub
, "timerHelloInMsecs", time_store
);
3695 vty_out (vty
, " Hello due in %s%s",
3696 ospf_timer_dump (oi
->t_hello
, timebuf
, sizeof(timebuf
)),
3699 else /* passive-interface is set */
3702 json_object_boolean_true_add(json_interface_sub
, "timerPassiveIface");
3704 vty_out (vty
, " No Hellos (Passive interface)%s", VTY_NEWLINE
);
3709 json_object_int_add(json_interface_sub
, "nbrCount", ospf_nbr_count (oi
, 0));
3710 json_object_int_add(json_interface_sub
, "nbrAdjacentCount", ospf_nbr_count (oi
, NSM_Full
));
3713 vty_out (vty
, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
3714 ospf_nbr_count (oi
, 0), ospf_nbr_count (oi
, NSM_Full
),
3716 ospf_bfd_interface_show(vty
, ifp
, json_interface_sub
, use_json
);
3721 show_ip_ospf_interface_common (struct vty
*vty
, struct ospf
*ospf
, int argc
,
3722 struct cmd_token
**argv
, int iface_argv
, u_char use_json
)
3724 struct interface
*ifp
;
3725 struct listnode
*node
;
3726 json_object
*json
= NULL
;
3727 json_object
*json_interface_sub
= NULL
;
3731 json
= json_object_new_object();
3732 json_interface_sub
= json_object_new_object();
3738 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3740 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3741 VTY_NEWLINE
, VTY_NEWLINE
);
3744 if (argc
== (iface_argv
+ 1))
3746 /* Show All Interfaces.*/
3747 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
3749 if (ospf_oi_count(ifp
))
3751 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3753 json_object_object_add (json
, ifp
->name
, json_interface_sub
);
3757 else if (argv
[iface_argv
] && strcmp(argv
[iface_argv
]->arg
, "json") == 0)
3761 json
= json_object_new_object();
3762 json_interface_sub
= json_object_new_object ();
3765 /* Show All Interfaces. */
3766 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
3768 if (ospf_oi_count(ifp
))
3770 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3772 json_object_object_add(json
, ifp
->name
, json_interface_sub
);
3778 /* Interface name is specified. */
3779 if ((ifp
= if_lookup_by_name (argv
[iface_argv
]->arg
)) == NULL
)
3782 json_object_boolean_true_add(json
, "noSuchIface");
3784 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
3788 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3790 json_object_object_add(json
, ifp
->name
, json_interface_sub
);
3796 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3797 json_object_free(json
);
3800 vty_out (vty
, "%s", VTY_NEWLINE
);
3805 DEFUN (show_ip_ospf_interface
,
3806 show_ip_ospf_interface_cmd
,
3807 "show ip ospf interface [INTERFACE] [json]",
3810 "OSPF information\n"
3811 "Interface information\n"
3816 u_char uj
= use_json(argc
, argv
);
3818 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3821 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 0, uj
);
3824 DEFUN (show_ip_ospf_instance_interface
,
3825 show_ip_ospf_instance_interface_cmd
,
3826 "show ip ospf (1-65535) interface [INTERFACE] [json]",
3829 "OSPF information\n"
3831 "Interface information\n"
3837 u_short instance
= 0;
3838 u_char uj
= use_json(argc
, argv
);
3840 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3841 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
3844 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 1, uj
);
3848 show_ip_ospf_neighbour_header (struct vty
*vty
)
3850 vty_out (vty
, "%s%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
3852 "Neighbor ID", "Pri", "State", "Dead Time",
3853 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
3858 show_ip_ospf_neighbor_sub (struct vty
*vty
, struct ospf_interface
*oi
, json_object
*json
, u_char use_json
)
3860 struct route_node
*rn
;
3861 struct ospf_neighbor
*nbr
;
3863 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3864 json_object
*json_neighbor
= NULL
;
3866 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
3868 if ((nbr
= rn
->info
))
3870 /* Do not show myself. */
3871 if (nbr
!= oi
->nbr_self
)
3873 /* Down state is not shown. */
3874 if (nbr
->state
!= NSM_Down
)
3878 json_neighbor
= json_object_new_object();
3879 ospf_nbr_state_message (nbr
, msgbuf
, 16);
3881 struct timeval result
;
3882 unsigned long time_store
= 0;
3884 result
= tv_sub (nbr
->t_inactivity
->u
.sands
, recent_relative_time());
3885 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3887 json_object_int_add (json_neighbor
, "priority", nbr
->priority
);
3888 json_object_string_add (json_neighbor
, "state", msgbuf
);
3889 json_object_int_add (json_neighbor
, "deadTimeMsecs", time_store
);
3890 json_object_string_add (json_neighbor
, "address", inet_ntoa (nbr
->src
));
3891 json_object_string_add (json_neighbor
, "ifaceName", IF_NAME (oi
));
3892 json_object_int_add (json_neighbor
, "retransmitCounter", ospf_ls_retransmit_count (nbr
));
3893 json_object_int_add (json_neighbor
, "requestCounter", ospf_ls_request_count (nbr
));
3894 json_object_int_add (json_neighbor
, "dbSummaryCounter", ospf_db_summary_count (nbr
));
3895 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
3896 json_object_object_add(json
, "neighbor", json_neighbor
);
3898 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_neighbor
);
3902 ospf_nbr_state_message (nbr
, msgbuf
, 16);
3904 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
3905 vty_out (vty
, "%-15s %3d %-15s ",
3909 vty_out (vty
, "%-15s %3d %-15s ",
3910 inet_ntoa (nbr
->router_id
), nbr
->priority
,
3913 vty_out (vty
, "%9s ",
3914 ospf_timer_dump (nbr
->t_inactivity
, timebuf
,
3916 vty_out (vty
, "%-15s ", inet_ntoa (nbr
->src
));
3917 vty_out (vty
, "%-20s %5ld %5ld %5d%s",
3918 IF_NAME (oi
), ospf_ls_retransmit_count (nbr
),
3919 ospf_ls_request_count (nbr
), ospf_db_summary_count (nbr
),
3929 show_ip_ospf_neighbor_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
3931 struct ospf_interface
*oi
;
3932 struct listnode
*node
;
3933 json_object
*json
= NULL
;
3936 json
= json_object_new_object();
3938 show_ip_ospf_neighbour_header (vty
);
3943 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3945 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3946 VTY_NEWLINE
, VTY_NEWLINE
);
3949 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
3950 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
3954 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3955 json_object_free(json
);
3958 vty_out (vty
, "%s", VTY_NEWLINE
);
3963 DEFUN (show_ip_ospf_neighbor
,
3964 show_ip_ospf_neighbor_cmd
,
3965 "show ip ospf neighbor [json]",
3968 "OSPF information\n"
3973 u_char uj
= use_json(argc
, argv
);
3975 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3978 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
3982 DEFUN (show_ip_ospf_instance_neighbor
,
3983 show_ip_ospf_instance_neighbor_cmd
,
3984 "show ip ospf (1-65535) neighbor [json]",
3987 "OSPF information\n"
3994 u_short instance
= 0;
3995 u_char uj
= use_json(argc
, argv
);
3997 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3998 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4001 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
4005 show_ip_ospf_neighbor_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4007 struct listnode
*node
;
4008 struct ospf_interface
*oi
;
4009 json_object
*json
= NULL
;
4010 json_object
*json_neighbor_sub
= NULL
;
4014 json
= json_object_new_object();
4015 json_neighbor_sub
= json_object_new_object();
4018 show_ip_ospf_neighbour_header (vty
);
4023 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4025 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4026 VTY_NEWLINE
, VTY_NEWLINE
);
4029 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4031 struct listnode
*nbr_node
;
4032 struct ospf_nbr_nbma
*nbr_nbma
;
4034 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
4036 /* print Down neighbor status */
4037 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nbr_node
, nbr_nbma
))
4039 if (nbr_nbma
->nbr
== NULL
4040 || nbr_nbma
->nbr
->state
== NSM_Down
)
4044 json_object_int_add (json_neighbor_sub
, "nbrNbmaPriority", nbr_nbma
->priority
);
4045 json_object_boolean_true_add (json_neighbor_sub
, "nbrNbmaDown");
4046 json_object_string_add (json_neighbor_sub
, "nbrNbmaIfaceName", IF_NAME (oi
));
4047 json_object_int_add (json_neighbor_sub
, "nbrNbmaRetransmitCounter", 0);
4048 json_object_int_add (json_neighbor_sub
, "nbrNbmaRequestCounter", 0);
4049 json_object_int_add (json_neighbor_sub
, "nbrNbmaDbSummaryCounter", 0);
4050 json_object_object_add(json
, inet_ntoa (nbr_nbma
->addr
), json_neighbor_sub
);
4054 vty_out (vty
, "%-15s %3d %-15s %9s ",
4055 "-", nbr_nbma
->priority
, "Down", "-");
4056 vty_out (vty
, "%-15s %-20s %5d %5d %5d%s",
4057 inet_ntoa (nbr_nbma
->addr
), IF_NAME (oi
),
4058 0, 0, 0, VTY_NEWLINE
);
4066 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4067 json_object_free(json
);
4070 vty_out (vty
, "%s", VTY_NEWLINE
);
4075 DEFUN (show_ip_ospf_neighbor_all
,
4076 show_ip_ospf_neighbor_all_cmd
,
4077 "show ip ospf neighbor all [json]",
4080 "OSPF information\n"
4082 "include down status neighbor\n"
4086 u_char uj
= use_json(argc
, argv
);
4088 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4091 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
4094 DEFUN (show_ip_ospf_instance_neighbor_all
,
4095 show_ip_ospf_instance_neighbor_all_cmd
,
4096 "show ip ospf (1-65535) neighbor all [json]",
4099 "OSPF information\n"
4102 "include down status neighbor\n"
4107 u_short instance
= 0;
4108 u_char uj
= use_json(argc
, argv
);
4110 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4111 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4114 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
4118 show_ip_ospf_neighbor_int_common (struct vty
*vty
, struct ospf
*ospf
, int arg_base
,
4119 struct cmd_token
**argv
, u_char use_json
)
4121 struct interface
*ifp
;
4122 struct route_node
*rn
;
4123 json_object
*json
= NULL
;
4126 json
= json_object_new_object();
4128 show_ip_ospf_neighbour_header (vty
);
4133 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4135 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4136 VTY_NEWLINE
, VTY_NEWLINE
);
4139 ifp
= if_lookup_by_name (argv
[arg_base
]->arg
);
4143 json_object_boolean_true_add(json
, "noSuchIface");
4145 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
4149 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
4151 struct ospf_interface
*oi
= rn
->info
;
4156 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
4161 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4162 json_object_free(json
);
4165 vty_out (vty
, "%s", VTY_NEWLINE
);
4170 DEFUN (show_ip_ospf_neighbor_int
,
4171 show_ip_ospf_neighbor_int_cmd
,
4172 "show ip ospf neighbor IFNAME [json]",
4175 "OSPF information\n"
4181 u_char uj
= use_json(argc
, argv
);
4183 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4186 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 0, argv
, uj
);
4189 DEFUN (show_ip_ospf_instance_neighbor_int
,
4190 show_ip_ospf_instance_neighbor_int_cmd
,
4191 "show ip ospf (1-65535) neighbor IFNAME [json]",
4194 "OSPF information\n"
4202 u_short instance
= 0;
4203 u_char uj
= use_json(argc
, argv
);
4205 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4206 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4209 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 1, argv
, uj
);
4213 show_ip_ospf_nbr_nbma_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
, struct ospf_nbr_nbma
*nbr_nbma
,
4214 u_char use_json
, json_object
*json
)
4216 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4217 json_object
*json_sub
= NULL
;
4220 json_sub
= json_object_new_object();
4221 else /* Show neighbor ID. */
4222 vty_out (vty
, " Neighbor %s,", "-");
4224 /* Show interface address. */
4226 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr_nbma
->addr
));
4228 vty_out (vty
, " interface address %s%s",
4229 inet_ntoa (nbr_nbma
->addr
), VTY_NEWLINE
);
4234 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4235 json_object_string_add(json_sub
, "iface", IF_NAME (oi
));
4238 vty_out (vty
, " In the area %s via interface %s%s",
4239 ospf_area_desc_string (oi
->area
), IF_NAME (oi
), VTY_NEWLINE
);
4241 /* Show neighbor priority and state. */
4244 json_object_int_add(json_sub
, "nbrPriority", nbr_nbma
->priority
);
4245 json_object_string_add(json_sub
, "nbrState", "down");
4248 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4249 nbr_nbma
->priority
, "Down");
4251 /* Show state changes. */
4253 json_object_int_add(json_sub
, "stateChangeCounter", nbr_nbma
->state_change
);
4255 vty_out (vty
, " %d state changes%s", nbr_nbma
->state_change
, VTY_NEWLINE
);
4257 /* Show PollInterval */
4259 json_object_int_add(json_sub
, "pollInterval", nbr_nbma
->v_poll
);
4261 vty_out (vty
, " Poll interval %d%s", nbr_nbma
->v_poll
, VTY_NEWLINE
);
4263 /* Show poll-interval timer. */
4266 struct timeval res
= tv_sub (nbr_nbma
->t_poll
->u
.sands
, recent_relative_time ());
4267 unsigned long time_store
= 0;
4268 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4269 json_object_int_add(json_sub
, "pollIntervalTimerDueMsec", time_store
);
4272 vty_out (vty
, " Poll timer due in %s%s",
4273 ospf_timer_dump (nbr_nbma
->t_poll
, timebuf
, sizeof(timebuf
)),
4276 /* Show poll-interval timer thread. */
4279 if (nbr_nbma
->t_poll
!= NULL
)
4280 json_object_string_add(json_sub
, "pollIntervalTimerThread", "on");
4283 vty_out (vty
, " Thread Poll Timer %s%s",
4284 nbr_nbma
->t_poll
!= NULL
? "on" : "off", VTY_NEWLINE
);
4287 json_object_object_add(json
, "noNbrId", json_sub
);
4291 show_ip_ospf_neighbor_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
,
4292 struct ospf_neighbor
*nbr
, u_char use_json
, json_object
*json
)
4294 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4295 json_object
*json_sub
= NULL
;
4298 json_sub
= json_object_new_object();
4301 /* Show neighbor ID. */
4302 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4303 vty_out (vty
, " Neighbor %s,", "-");
4305 vty_out (vty
, " Neighbor %s,", inet_ntoa (nbr
->router_id
));
4308 /* Show interface address. */
4310 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr
->address
.u
.prefix4
));
4312 vty_out (vty
, " interface address %s%s",
4313 inet_ntoa (nbr
->address
.u
.prefix4
), VTY_NEWLINE
);
4318 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4319 json_object_string_add(json_sub
, "ifaceName", oi
->ifp
->name
);
4322 vty_out (vty
, " In the area %s via interface %s%s",
4323 ospf_area_desc_string (oi
->area
), oi
->ifp
->name
, VTY_NEWLINE
);
4325 /* Show neighbor priority and state. */
4328 json_object_int_add(json_sub
, "nbrPriority", nbr
->priority
);
4329 json_object_string_add(json_sub
, "nbrState", LOOKUP (ospf_nsm_state_msg
, nbr
->state
));
4332 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4333 nbr
->priority
, LOOKUP (ospf_nsm_state_msg
, nbr
->state
));
4335 /* Show state changes. */
4337 json_object_int_add(json_sub
, "stateChangeCounter", nbr
->state_change
);
4339 vty_out (vty
, " %d state changes%s", nbr
->state_change
, VTY_NEWLINE
);
4341 if (nbr
->ts_last_progress
.tv_sec
|| nbr
->ts_last_progress
.tv_usec
)
4343 struct timeval res
= tv_sub (recent_relative_time (), nbr
->ts_last_progress
);
4346 unsigned long time_store
= 0;
4347 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4348 json_object_int_add(json_sub
, "lastPrgrsvChangeMsec", time_store
);
4352 vty_out (vty
, " Most recent state change statistics:%s",
4354 vty_out (vty
, " Progressive change %s ago%s",
4355 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4360 if (nbr
->ts_last_regress
.tv_sec
|| nbr
->ts_last_regress
.tv_usec
)
4362 struct timeval res
= tv_sub (recent_relative_time (), nbr
->ts_last_regress
);
4365 unsigned long time_store
= 0;
4366 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4367 json_object_int_add(json_sub
, "lastRegressiveChangeMsec", time_store
);
4368 if (nbr
->last_regress_str
)
4369 json_object_string_add(json_sub
, "lastRegressiveChangeReason", nbr
->last_regress_str
);
4373 vty_out (vty
, " Regressive change %s ago, due to %s%s",
4374 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4375 (nbr
->last_regress_str
? nbr
->last_regress_str
: "??"),
4380 /* Show Designated Rotuer ID. */
4382 json_object_string_add(json_sub
, "routerDesignatedId", inet_ntoa (nbr
->d_router
));
4384 vty_out (vty
, " DR is %s,", inet_ntoa (nbr
->d_router
));
4386 /* Show Backup Designated Rotuer ID. */
4388 json_object_string_add(json_sub
, "routerDesignatedBackupId", inet_ntoa (nbr
->bd_router
));
4390 vty_out (vty
, " BDR is %s%s", inet_ntoa (nbr
->bd_router
), VTY_NEWLINE
);
4395 json_object_int_add(json_sub
, "optionsCounter", nbr
->options
);
4396 json_object_string_add(json_sub
, "optionsList", ospf_options_dump (nbr
->options
));
4399 vty_out (vty
, " Options %d %s%s", nbr
->options
,
4400 ospf_options_dump (nbr
->options
), VTY_NEWLINE
);
4402 /* Show Router Dead interval timer. */
4405 if (nbr
->t_inactivity
)
4407 struct timeval res
= tv_sub (nbr
->t_inactivity
->u
.sands
, recent_relative_time ());
4408 unsigned long time_store
= 0;
4409 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4410 json_object_int_add(json_sub
, "routerDeadIntervalTimerDueMsec", time_store
);
4413 json_object_int_add(json_sub
, "routerDeadIntervalTimerDueMsec", -1);
4416 vty_out (vty
, " Dead timer due in %s%s",
4417 ospf_timer_dump (nbr
->t_inactivity
, timebuf
, sizeof (timebuf
)),
4420 /* Show Database Summary list. */
4422 json_object_int_add(json_sub
, "databaseSummaryListCounter", ospf_db_summary_count (nbr
));
4424 vty_out (vty
, " Database Summary List %d%s",
4425 ospf_db_summary_count (nbr
), VTY_NEWLINE
);
4427 /* Show Link State Request list. */
4429 json_object_int_add(json_sub
, "linkStateRequestListCounter", ospf_ls_request_count (nbr
));
4431 vty_out (vty
, " Link State Request List %ld%s",
4432 ospf_ls_request_count (nbr
), VTY_NEWLINE
);
4434 /* Show Link State Retransmission list. */
4436 json_object_int_add(json_sub
, "linkStateRetransmissionListCounter", ospf_ls_retransmit_count (nbr
));
4438 vty_out (vty
, " Link State Retransmission List %ld%s",
4439 ospf_ls_retransmit_count (nbr
), VTY_NEWLINE
);
4441 /* Show inactivity timer thread. */
4444 if (nbr
->t_inactivity
!= NULL
)
4445 json_object_string_add(json_sub
, "threadInactivityTimer", "on");
4448 vty_out (vty
, " Thread Inactivity Timer %s%s",
4449 nbr
->t_inactivity
!= NULL
? "on" : "off", VTY_NEWLINE
);
4451 /* Show Database Description retransmission thread. */
4454 if (nbr
->t_db_desc
!= NULL
)
4455 json_object_string_add(json_sub
, "threadDatabaseDescriptionRetransmission", "on");
4458 vty_out (vty
, " Thread Database Description Retransmision %s%s",
4459 nbr
->t_db_desc
!= NULL
? "on" : "off", VTY_NEWLINE
);
4461 /* Show Link State Request Retransmission thread. */
4464 if (nbr
->t_ls_req
!= NULL
)
4465 json_object_string_add(json_sub
, "threadLinkStateRequestRetransmission", "on");
4468 vty_out (vty
, " Thread Link State Request Retransmission %s%s",
4469 nbr
->t_ls_req
!= NULL
? "on" : "off", VTY_NEWLINE
);
4471 /* Show Link State Update Retransmission thread. */
4474 if (nbr
->t_ls_upd
!= NULL
)
4475 json_object_string_add(json_sub
, "threadLinkStateUpdateRetransmission", "on");
4478 vty_out (vty
, " Thread Link State Update Retransmission %s%s%s",
4479 nbr
->t_ls_upd
!= NULL
? "on" : "off", VTY_NEWLINE
, VTY_NEWLINE
);
4483 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4484 json_object_object_add(json
, "noNbrId", json_sub
);
4486 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_sub
);
4489 ospf_bfd_show_info(vty
, nbr
->bfd_info
, json
, use_json
, 0);
4493 show_ip_ospf_neighbor_id_common (struct vty
*vty
, struct ospf
*ospf
,
4494 int arg_base
, struct cmd_token
**argv
, u_char use_json
)
4496 struct listnode
*node
;
4497 struct ospf_neighbor
*nbr
;
4498 struct ospf_interface
*oi
;
4499 struct in_addr router_id
;
4501 json_object
*json
= NULL
;
4504 json
= json_object_new_object();
4509 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4511 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4512 VTY_NEWLINE
, VTY_NEWLINE
);
4515 ret
= inet_aton (argv
[arg_base
]->arg
, &router_id
);
4519 vty_out (vty
, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE
);
4523 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4525 if ((nbr
= ospf_nbr_lookup_by_routerid (oi
->nbrs
, &router_id
)))
4527 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4533 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4534 json_object_free(json
);
4537 vty_out (vty
, "%s", VTY_NEWLINE
);
4542 DEFUN (show_ip_ospf_neighbor_id
,
4543 show_ip_ospf_neighbor_id_cmd
,
4544 "show ip ospf neighbor A.B.C.D [json]",
4547 "OSPF information\n"
4553 u_char uj
= use_json(argc
, argv
);
4555 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4558 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 0, argv
, uj
);
4561 DEFUN (show_ip_ospf_instance_neighbor_id
,
4562 show_ip_ospf_instance_neighbor_id_cmd
,
4563 "show ip ospf (1-65535) neighbor A.B.C.D [json]",
4566 "OSPF information\n"
4574 u_short instance
= 0;
4575 u_char uj
= use_json(argc
, argv
);
4577 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4578 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4581 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 1, argv
, uj
);
4585 show_ip_ospf_neighbor_detail_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4587 struct ospf_interface
*oi
;
4588 struct listnode
*node
;
4589 json_object
*json
= NULL
;
4592 json
= json_object_new_object();
4597 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4599 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4600 VTY_NEWLINE
, VTY_NEWLINE
);
4603 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4605 struct route_node
*rn
;
4606 struct ospf_neighbor
*nbr
;
4608 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4610 if ((nbr
= rn
->info
))
4612 if (nbr
!= oi
->nbr_self
)
4614 if (nbr
->state
!= NSM_Down
)
4616 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4625 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4626 json_object_free(json
);
4629 vty_out (vty
, "%s", VTY_NEWLINE
);
4634 DEFUN (show_ip_ospf_neighbor_detail
,
4635 show_ip_ospf_neighbor_detail_cmd
,
4636 "show ip ospf neighbor detail [json]",
4639 "OSPF information\n"
4641 "detail of all neighbors\n"
4645 u_char uj
= use_json(argc
, argv
);
4647 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4650 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4653 DEFUN (show_ip_ospf_instance_neighbor_detail
,
4654 show_ip_ospf_instance_neighbor_detail_cmd
,
4655 "show ip ospf (1-65535) neighbor detail [json]",
4658 "OSPF information\n"
4661 "detail of all neighbors\n"
4666 u_short instance
= 0;
4667 u_char uj
= use_json(argc
, argv
);
4669 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4670 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
4673 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4677 show_ip_ospf_neighbor_detail_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4679 struct listnode
*node
;
4680 struct ospf_interface
*oi
;
4681 json_object
*json
= NULL
;
4684 json
= json_object_new_object();
4689 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4691 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4692 VTY_NEWLINE
, VTY_NEWLINE
);
4695 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4697 struct route_node
*rn
;
4698 struct ospf_neighbor
*nbr
;
4699 struct ospf_nbr_nbma
*nbr_nbma
;
4701 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4702 if ((nbr
= rn
->info
))
4703 if (nbr
!= oi
->nbr_self
)
4704 if (nbr
->state
!= NSM_Down
)
4705 show_ip_ospf_neighbor_detail_sub (vty
, oi
, rn
->info
, use_json
, json
);
4707 if (oi
->type
== OSPF_IFTYPE_NBMA
)
4709 struct listnode
*nd
;
4711 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nd
, nbr_nbma
))
4713 if (nbr_nbma
->nbr
== NULL
|| nbr_nbma
->nbr
->state
== NSM_Down
)
4714 show_ip_ospf_nbr_nbma_detail_sub (vty
, oi
, nbr_nbma
, use_json
, json
);
4721 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4722 json_object_free(json
);
4726 vty_out (vty
, "%s", VTY_NEWLINE
);
4732 DEFUN (show_ip_ospf_neighbor_detail_all
,
4733 show_ip_ospf_neighbor_detail_all_cmd
,
4734 "show ip ospf neighbor detail all [json]",
4737 "OSPF information\n"
4739 "detail of all neighbors\n"
4740 "include down status neighbor\n"
4744 u_char uj
= use_json(argc
, argv
);
4746 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4749 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4752 DEFUN (show_ip_ospf_instance_neighbor_detail_all
,
4753 show_ip_ospf_instance_neighbor_detail_all_cmd
,
4754 "show ip ospf (1-65535) neighbor detail all [json]",
4757 "OSPF information\n"
4760 "detail of all neighbors\n"
4761 "include down status neighbor\n"
4766 u_short instance
= 0;
4767 u_char uj
= use_json(argc
, argv
);
4769 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4770 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4773 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4777 show_ip_ospf_neighbor_int_detail_common (struct vty
*vty
, struct ospf
*ospf
,
4778 int arg_base
, struct cmd_token
**argv
, u_char use_json
)
4780 struct ospf_interface
*oi
;
4781 struct interface
*ifp
;
4782 struct route_node
*rn
, *nrn
;
4783 struct ospf_neighbor
*nbr
;
4784 json_object
*json
= NULL
;
4787 json
= json_object_new_object();
4792 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4794 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4795 VTY_NEWLINE
, VTY_NEWLINE
);
4798 ifp
= if_lookup_by_name (argv
[arg_base
]->arg
);
4802 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
4806 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
4808 if ((oi
= rn
->info
))
4810 for (nrn
= route_top (oi
->nbrs
); nrn
; nrn
= route_next (nrn
))
4812 if ((nbr
= nrn
->info
))
4814 if (nbr
!= oi
->nbr_self
)
4816 if (nbr
->state
!= NSM_Down
)
4817 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4826 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4827 json_object_free(json
);
4830 vty_out (vty
, "%s", VTY_NEWLINE
);
4835 DEFUN (show_ip_ospf_neighbor_int_detail
,
4836 show_ip_ospf_neighbor_int_detail_cmd
,
4837 "show ip ospf neighbor IFNAME detail [json]",
4840 "OSPF information\n"
4843 "detail of all neighbors\n"
4847 u_char uj
= use_json(argc
, argv
);
4849 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4852 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 0, argv
, uj
);
4855 DEFUN (show_ip_ospf_instance_neighbor_int_detail
,
4856 show_ip_ospf_instance_neighbor_int_detail_cmd
,
4857 "show ip ospf (1-65535) neighbor IFNAME detail [json]",
4860 "OSPF information\n"
4864 "detail of all neighbors\n"
4869 u_short instance
= 0;
4870 u_char uj
= use_json(argc
, argv
);
4872 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4873 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4876 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 1, argv
, uj
);
4879 /* Show functions */
4881 show_lsa_summary (struct vty
*vty
, struct ospf_lsa
*lsa
, int self
)
4883 struct router_lsa
*rl
;
4884 struct summary_lsa
*sl
;
4885 struct as_external_lsa
*asel
;
4886 struct prefix_ipv4 p
;
4889 /* If self option is set, check LSA self flag. */
4890 if (self
== 0 || IS_LSA_SELF (lsa
))
4892 /* LSA common part show. */
4893 vty_out (vty
, "%-15s ", inet_ntoa (lsa
->data
->id
));
4894 vty_out (vty
, "%-15s %4d 0x%08lx 0x%04x",
4895 inet_ntoa (lsa
->data
->adv_router
), LS_AGE (lsa
),
4896 (u_long
)ntohl (lsa
->data
->ls_seqnum
), ntohs (lsa
->data
->checksum
));
4897 /* LSA specific part show. */
4898 switch (lsa
->data
->type
)
4900 case OSPF_ROUTER_LSA
:
4901 rl
= (struct router_lsa
*) lsa
->data
;
4902 vty_out (vty
, " %-d", ntohs (rl
->links
));
4904 case OSPF_SUMMARY_LSA
:
4905 sl
= (struct summary_lsa
*) lsa
->data
;
4908 p
.prefix
= sl
->header
.id
;
4909 p
.prefixlen
= ip_masklen (sl
->mask
);
4910 apply_mask_ipv4 (&p
);
4912 vty_out (vty
, " %s/%d", inet_ntoa (p
.prefix
), p
.prefixlen
);
4914 case OSPF_AS_EXTERNAL_LSA
:
4915 case OSPF_AS_NSSA_LSA
:
4916 asel
= (struct as_external_lsa
*) lsa
->data
;
4919 p
.prefix
= asel
->header
.id
;
4920 p
.prefixlen
= ip_masklen (asel
->mask
);
4921 apply_mask_ipv4 (&p
);
4923 vty_out (vty
, " %s %s/%d [0x%lx]",
4924 IS_EXTERNAL_METRIC (asel
->e
[0].tos
) ? "E2" : "E1",
4925 inet_ntoa (p
.prefix
), p
.prefixlen
,
4926 (u_long
)ntohl (asel
->e
[0].route_tag
));
4928 case OSPF_NETWORK_LSA
:
4929 case OSPF_ASBR_SUMMARY_LSA
:
4930 case OSPF_OPAQUE_LINK_LSA
:
4931 case OSPF_OPAQUE_AREA_LSA
:
4932 case OSPF_OPAQUE_AS_LSA
:
4936 vty_out (vty
, VTY_NEWLINE
);
4942 static const char *show_database_desc
[] =
4945 "Router Link States",
4947 "Summary Link States",
4948 "ASBR-Summary Link States",
4949 "AS External Link States",
4950 "Group Membership LSA",
4951 "NSSA-external Link States",
4953 "Link-Local Opaque-LSA",
4954 "Area-Local Opaque-LSA",
4955 "AS-external Opaque-LSA",
4958 static const char *show_database_header
[] =
4961 "Link ID ADV Router Age Seq# CkSum Link count",
4962 "Link ID ADV Router Age Seq# CkSum",
4963 "Link ID ADV Router Age Seq# CkSum Route",
4964 "Link ID ADV Router Age Seq# CkSum",
4965 "Link ID ADV Router Age Seq# CkSum Route",
4966 " --- header for Group Member ----",
4967 "Link ID ADV Router Age Seq# CkSum Route",
4969 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4970 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4971 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4975 show_ip_ospf_database_header (struct vty
*vty
, struct ospf_lsa
*lsa
)
4977 struct router_lsa
*rlsa
= (struct router_lsa
*) lsa
->data
;
4979 vty_out (vty
, " LS age: %d%s", LS_AGE (lsa
), VTY_NEWLINE
);
4980 vty_out (vty
, " Options: 0x%-2x : %s%s",
4982 ospf_options_dump(lsa
->data
->options
),
4984 vty_out (vty
, " LS Flags: 0x%-2x %s%s",
4986 ((lsa
->flags
& OSPF_LSA_LOCAL_XLT
) ? "(Translated from Type-7)" : ""),
4989 if (lsa
->data
->type
== OSPF_ROUTER_LSA
)
4991 vty_out (vty
, " Flags: 0x%x" , rlsa
->flags
);
4994 vty_out (vty
, " :%s%s%s%s",
4995 IS_ROUTER_LSA_BORDER (rlsa
) ? " ABR" : "",
4996 IS_ROUTER_LSA_EXTERNAL (rlsa
) ? " ASBR" : "",
4997 IS_ROUTER_LSA_VIRTUAL (rlsa
) ? " VL-endpoint" : "",
4998 IS_ROUTER_LSA_SHORTCUT (rlsa
) ? " Shortcut" : "");
5000 vty_out (vty
, "%s", VTY_NEWLINE
);
5002 vty_out (vty
, " LS Type: %s%s",
5003 LOOKUP (ospf_lsa_type_msg
, lsa
->data
->type
), VTY_NEWLINE
);
5004 vty_out (vty
, " Link State ID: %s %s%s", inet_ntoa (lsa
->data
->id
),
5005 LOOKUP (ospf_link_state_id_type_msg
, lsa
->data
->type
), VTY_NEWLINE
);
5006 vty_out (vty
, " Advertising Router: %s%s",
5007 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
5008 vty_out (vty
, " LS Seq Number: %08lx%s", (u_long
)ntohl (lsa
->data
->ls_seqnum
),
5010 vty_out (vty
, " Checksum: 0x%04x%s", ntohs (lsa
->data
->checksum
),
5012 vty_out (vty
, " Length: %d%s", ntohs (lsa
->data
->length
), VTY_NEWLINE
);
5015 const char *link_type_desc
[] =
5018 "another Router (point-to-point)",
5019 "a Transit Network",
5024 const char *link_id_desc
[] =
5027 "Neighboring Router ID",
5028 "Designated Router address",
5030 "Neighboring Router ID",
5033 const char *link_data_desc
[] =
5036 "Router Interface address",
5037 "Router Interface address",
5039 "Router Interface address",
5042 /* Show router-LSA each Link information. */
5044 show_ip_ospf_database_router_links (struct vty
*vty
,
5045 struct router_lsa
*rl
)
5050 len
= ntohs (rl
->header
.length
) - 4;
5051 for (i
= 0; i
< ntohs (rl
->links
) && len
> 0; len
-= 12, i
++)
5053 type
= rl
->link
[i
].type
;
5055 vty_out (vty
, " Link connected to: %s%s",
5056 link_type_desc
[type
], VTY_NEWLINE
);
5057 vty_out (vty
, " (Link ID) %s: %s%s", link_id_desc
[type
],
5058 inet_ntoa (rl
->link
[i
].link_id
), VTY_NEWLINE
);
5059 vty_out (vty
, " (Link Data) %s: %s%s", link_data_desc
[type
],
5060 inet_ntoa (rl
->link
[i
].link_data
), VTY_NEWLINE
);
5061 vty_out (vty
, " Number of TOS metrics: 0%s", VTY_NEWLINE
);
5062 vty_out (vty
, " TOS 0 Metric: %d%s",
5063 ntohs (rl
->link
[i
].metric
), VTY_NEWLINE
);
5064 vty_out (vty
, "%s", VTY_NEWLINE
);
5068 /* Show router-LSA detail information. */
5070 show_router_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5074 struct router_lsa
*rl
= (struct router_lsa
*) lsa
->data
;
5076 show_ip_ospf_database_header (vty
, lsa
);
5078 vty_out (vty
, " Number of Links: %d%s%s", ntohs (rl
->links
),
5079 VTY_NEWLINE
, VTY_NEWLINE
);
5081 show_ip_ospf_database_router_links (vty
, rl
);
5082 vty_out (vty
, "%s", VTY_NEWLINE
);
5088 /* Show network-LSA detail information. */
5090 show_network_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5096 struct network_lsa
*nl
= (struct network_lsa
*) lsa
->data
;
5098 show_ip_ospf_database_header (vty
, lsa
);
5100 vty_out (vty
, " Network Mask: /%d%s",
5101 ip_masklen (nl
->mask
), VTY_NEWLINE
);
5103 length
= ntohs (lsa
->data
->length
) - OSPF_LSA_HEADER_SIZE
- 4;
5105 for (i
= 0; length
> 0; i
++, length
-= 4)
5106 vty_out (vty
, " Attached Router: %s%s",
5107 inet_ntoa (nl
->routers
[i
]), VTY_NEWLINE
);
5109 vty_out (vty
, "%s", VTY_NEWLINE
);
5115 /* Show summary-LSA detail information. */
5117 show_summary_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5121 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
5123 show_ip_ospf_database_header (vty
, lsa
);
5125 vty_out (vty
, " Network Mask: /%d%s", ip_masklen (sl
->mask
),
5127 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
5129 vty_out (vty
, "%s", VTY_NEWLINE
);
5135 /* Show summary-ASBR-LSA detail information. */
5137 show_summary_asbr_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5141 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
5143 show_ip_ospf_database_header (vty
, lsa
);
5145 vty_out (vty
, " Network Mask: /%d%s",
5146 ip_masklen (sl
->mask
), VTY_NEWLINE
);
5147 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
5149 vty_out (vty
, "%s", VTY_NEWLINE
);
5155 /* Show AS-external-LSA detail information. */
5157 show_as_external_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5161 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5163 show_ip_ospf_database_header (vty
, lsa
);
5165 vty_out (vty
, " Network Mask: /%d%s",
5166 ip_masklen (al
->mask
), VTY_NEWLINE
);
5167 vty_out (vty
, " Metric Type: %s%s",
5168 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5169 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
5170 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
5171 vty_out (vty
, " Metric: %d%s",
5172 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
5173 vty_out (vty
, " Forward Address: %s%s",
5174 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
5176 vty_out (vty
, " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5177 (route_tag_t
)ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
5184 show_as_external_lsa_stdvty (struct ospf_lsa
*lsa
)
5186 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5188 /* show_ip_ospf_database_header (vty, lsa); */
5190 zlog_debug( " Network Mask: /%d%s",
5191 ip_masklen (al
->mask
), "\n");
5192 zlog_debug( " Metric Type: %s%s",
5193 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5194 "2 (Larger than any link state path)" : "1", "\n");
5195 zlog_debug( " TOS: 0%s", "\n");
5196 zlog_debug( " Metric: %d%s",
5197 GET_METRIC (al
->e
[0].metric
), "\n");
5198 zlog_debug( " Forward Address: %s%s",
5199 inet_ntoa (al
->e
[0].fwd_addr
), "\n");
5201 zlog_debug( " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5202 (route_tag_t
)ntohl (al
->e
[0].route_tag
), "\n", "\n");
5207 /* Show AS-NSSA-LSA detail information. */
5209 show_as_nssa_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5213 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5215 show_ip_ospf_database_header (vty
, lsa
);
5217 vty_out (vty
, " Network Mask: /%d%s",
5218 ip_masklen (al
->mask
), VTY_NEWLINE
);
5219 vty_out (vty
, " Metric Type: %s%s",
5220 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5221 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
5222 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
5223 vty_out (vty
, " Metric: %d%s",
5224 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
5225 vty_out (vty
, " NSSA: Forward Address: %s%s",
5226 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
5228 vty_out (vty
, " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5229 (route_tag_t
)ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
5236 show_func_dummy (struct vty
*vty
, struct ospf_lsa
*lsa
)
5242 show_opaque_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5246 show_ip_ospf_database_header (vty
, lsa
);
5247 show_opaque_info_detail (vty
, lsa
);
5249 vty_out (vty
, "%s", VTY_NEWLINE
);
5254 int (*show_function
[])(struct vty
*, struct ospf_lsa
*) =
5257 show_router_lsa_detail
,
5258 show_network_lsa_detail
,
5259 show_summary_lsa_detail
,
5260 show_summary_asbr_lsa_detail
,
5261 show_as_external_lsa_detail
,
5263 show_as_nssa_lsa_detail
, /* almost same as external */
5265 show_opaque_lsa_detail
,
5266 show_opaque_lsa_detail
,
5267 show_opaque_lsa_detail
,
5271 show_lsa_prefix_set (struct vty
*vty
, struct prefix_ls
*lp
, struct in_addr
*id
,
5272 struct in_addr
*adv_router
)
5274 memset (lp
, 0, sizeof (struct prefix_ls
));
5278 else if (adv_router
== NULL
)
5287 lp
->adv_router
= *adv_router
;
5292 show_lsa_detail_proc (struct vty
*vty
, struct route_table
*rt
,
5293 struct in_addr
*id
, struct in_addr
*adv_router
)
5295 struct prefix_ls lp
;
5296 struct route_node
*rn
, *start
;
5297 struct ospf_lsa
*lsa
;
5299 show_lsa_prefix_set (vty
, &lp
, id
, adv_router
);
5300 start
= route_node_get (rt
, (struct prefix
*) &lp
);
5303 route_lock_node (start
);
5304 for (rn
= start
; rn
; rn
= route_next_until (rn
, start
))
5305 if ((lsa
= rn
->info
))
5307 if (show_function
[lsa
->data
->type
] != NULL
)
5308 show_function
[lsa
->data
->type
] (vty
, lsa
);
5310 route_unlock_node (start
);
5314 /* Show detail LSA information
5315 -- if id is NULL then show all LSAs. */
5317 show_lsa_detail (struct vty
*vty
, struct ospf
*ospf
, int type
,
5318 struct in_addr
*id
, struct in_addr
*adv_router
)
5320 struct listnode
*node
;
5321 struct ospf_area
*area
;
5325 case OSPF_AS_EXTERNAL_LSA
:
5326 case OSPF_OPAQUE_AS_LSA
:
5327 vty_out (vty
, " %s %s%s",
5328 show_database_desc
[type
],
5329 VTY_NEWLINE
, VTY_NEWLINE
);
5330 show_lsa_detail_proc (vty
, AS_LSDB (ospf
, type
), id
, adv_router
);
5333 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5335 vty_out (vty
, "%s %s (Area %s)%s%s",
5336 VTY_NEWLINE
, show_database_desc
[type
],
5337 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5338 show_lsa_detail_proc (vty
, AREA_LSDB (area
, type
), id
, adv_router
);
5345 show_lsa_detail_adv_router_proc (struct vty
*vty
, struct route_table
*rt
,
5346 struct in_addr
*adv_router
)
5348 struct route_node
*rn
;
5349 struct ospf_lsa
*lsa
;
5351 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
5352 if ((lsa
= rn
->info
))
5353 if (IPV4_ADDR_SAME (adv_router
, &lsa
->data
->adv_router
))
5355 if (CHECK_FLAG (lsa
->flags
, OSPF_LSA_LOCAL_XLT
))
5357 if (show_function
[lsa
->data
->type
] != NULL
)
5358 show_function
[lsa
->data
->type
] (vty
, lsa
);
5362 /* Show detail LSA information. */
5364 show_lsa_detail_adv_router (struct vty
*vty
, struct ospf
*ospf
, int type
,
5365 struct in_addr
*adv_router
)
5367 struct listnode
*node
;
5368 struct ospf_area
*area
;
5372 case OSPF_AS_EXTERNAL_LSA
:
5373 case OSPF_OPAQUE_AS_LSA
:
5374 vty_out (vty
, " %s %s%s",
5375 show_database_desc
[type
],
5376 VTY_NEWLINE
, VTY_NEWLINE
);
5377 show_lsa_detail_adv_router_proc (vty
, AS_LSDB (ospf
, type
),
5381 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5383 vty_out (vty
, "%s %s (Area %s)%s%s",
5384 VTY_NEWLINE
, show_database_desc
[type
],
5385 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5386 show_lsa_detail_adv_router_proc (vty
, AREA_LSDB (area
, type
),
5394 show_ip_ospf_database_summary (struct vty
*vty
, struct ospf
*ospf
, int self
)
5396 struct ospf_lsa
*lsa
;
5397 struct route_node
*rn
;
5398 struct ospf_area
*area
;
5399 struct listnode
*node
;
5402 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5404 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5408 case OSPF_AS_EXTERNAL_LSA
:
5409 case OSPF_OPAQUE_AS_LSA
:
5414 if (ospf_lsdb_count_self (area
->lsdb
, type
) > 0 ||
5415 (!self
&& ospf_lsdb_count (area
->lsdb
, type
) > 0))
5417 vty_out (vty
, " %s (Area %s)%s%s",
5418 show_database_desc
[type
],
5419 ospf_area_desc_string (area
),
5420 VTY_NEWLINE
, VTY_NEWLINE
);
5421 vty_out (vty
, "%s%s", show_database_header
[type
], VTY_NEWLINE
);
5423 LSDB_LOOP (AREA_LSDB (area
, type
), rn
, lsa
)
5424 show_lsa_summary (vty
, lsa
, self
);
5426 vty_out (vty
, "%s", VTY_NEWLINE
);
5431 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5435 case OSPF_AS_EXTERNAL_LSA
:
5436 case OSPF_OPAQUE_AS_LSA
:
5441 if (ospf_lsdb_count_self (ospf
->lsdb
, type
) ||
5442 (!self
&& ospf_lsdb_count (ospf
->lsdb
, type
)))
5444 vty_out (vty
, " %s%s%s",
5445 show_database_desc
[type
],
5446 VTY_NEWLINE
, VTY_NEWLINE
);
5447 vty_out (vty
, "%s%s", show_database_header
[type
],
5450 LSDB_LOOP (AS_LSDB (ospf
, type
), rn
, lsa
)
5451 show_lsa_summary (vty
, lsa
, self
);
5453 vty_out (vty
, "%s", VTY_NEWLINE
);
5457 vty_out (vty
, "%s", VTY_NEWLINE
);
5461 show_ip_ospf_database_maxage (struct vty
*vty
, struct ospf
*ospf
)
5463 struct route_node
*rn
;
5465 vty_out (vty
, "%s MaxAge Link States:%s%s",
5466 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
5468 for (rn
= route_top (ospf
->maxage_lsa
); rn
; rn
= route_next (rn
))
5470 struct ospf_lsa
*lsa
;
5472 if ((lsa
= rn
->info
) != NULL
)
5474 vty_out (vty
, "Link type: %d%s", lsa
->data
->type
, VTY_NEWLINE
);
5475 vty_out (vty
, "Link State ID: %s%s",
5476 inet_ntoa (lsa
->data
->id
), VTY_NEWLINE
);
5477 vty_out (vty
, "Advertising Router: %s%s",
5478 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
5479 vty_out (vty
, "LSA lock count: %d%s", lsa
->lock
, VTY_NEWLINE
);
5480 vty_out (vty
, "%s", VTY_NEWLINE
);
5485 #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
5486 #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
5488 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
5489 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
5490 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
5491 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
5493 #define OSPF_LSA_TYPES_DESC \
5494 "ASBR summary link states\n" \
5495 "External link states\n" \
5496 "Network link states\n" \
5497 "Router link states\n" \
5498 "Network summary link states\n" \
5499 OSPF_LSA_TYPE_NSSA_DESC \
5500 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
5501 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
5502 OSPF_LSA_TYPE_OPAQUE_AS_DESC
5505 show_ip_ospf_database_common (struct vty
*vty
, struct ospf
*ospf
,
5506 int arg_base
, int argc
, struct cmd_token
**argv
)
5510 struct in_addr id
, adv_router
;
5513 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5516 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5517 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5520 if (argc
== arg_base
+ 4)
5522 show_ip_ospf_database_summary (vty
, ospf
, 0);
5526 /* Set database type to show. */
5527 if (strncmp (argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5528 type
= OSPF_ROUTER_LSA
;
5529 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5530 type
= OSPF_NETWORK_LSA
;
5531 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5532 type
= OSPF_AS_NSSA_LSA
;
5533 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "su", 2) == 0)
5534 type
= OSPF_SUMMARY_LSA
;
5535 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5536 type
= OSPF_ASBR_SUMMARY_LSA
;
5537 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5538 type
= OSPF_AS_EXTERNAL_LSA
;
5539 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "se", 2) == 0)
5541 show_ip_ospf_database_summary (vty
, ospf
, 1);
5544 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "m", 1) == 0)
5546 show_ip_ospf_database_maxage (vty
, ospf
);
5549 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5550 type
= OSPF_OPAQUE_LINK_LSA
;
5551 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5552 type
= OSPF_OPAQUE_AREA_LSA
;
5553 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5554 type
= OSPF_OPAQUE_AS_LSA
;
5558 /* `show ip ospf database LSA'. */
5559 if (argc
== arg_base
+ 5)
5560 show_lsa_detail (vty
, ospf
, type
, NULL
, NULL
);
5561 else if (argc
>= arg_base
+ 6)
5563 ret
= inet_aton (argv
[arg_base
+ 5]->arg
, &id
);
5567 /* `show ip ospf database LSA ID'. */
5568 if (argc
== arg_base
+ 6)
5569 show_lsa_detail (vty
, ospf
, type
, &id
, NULL
);
5570 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
5571 else if (argc
== arg_base
+ 7)
5573 if (strncmp (argv
[arg_base
+ 6]->text
, "s", 1) == 0)
5574 adv_router
= ospf
->router_id
;
5577 ret
= inet_aton (argv
[arg_base
+ 7]->arg
, &adv_router
);
5581 show_lsa_detail (vty
, ospf
, type
, &id
, &adv_router
);
5588 DEFUN (show_ip_ospf_database_max
,
5589 show_ip_ospf_database_max_cmd
,
5590 "show ip ospf database <max-age|self-originate>",
5593 "OSPF information\n"
5594 "Database summary\n"
5595 "LSAs in MaxAge list\n"
5596 "Self-originated link states\n")
5600 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5603 return (show_ip_ospf_database_common(vty
, ospf
, 0, argc
, argv
));
5606 DEFUN (show_ip_ospf_instance_database
,
5607 show_ip_ospf_instance_database_cmd
,
5608 "show ip ospf [(1-65535)] database [<asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as> [A.B.C.D [<self-originate|adv-router A.B.C.D>]]]",
5611 "OSPF information\n"
5613 "Database summary\n"
5615 "Link State ID (as an IP address)\n"
5616 "Self-originated link states\n"
5617 "Advertising Router link states\n"
5618 "Advertising Router (as an IP address)\n")
5621 u_short instance
= 0;
5624 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
5626 VTY_GET_INTEGER ("Instance", instance
, argv
[idx
]->arg
);
5627 ospf
= ospf_lookup_instance (instance
);
5630 ospf
= ospf_lookup();
5633 if (!ospf
|| !ospf
->oi_running
)
5636 return (show_ip_ospf_database_common(vty
, ospf
, idx
? 1 : 0, argc
, argv
));
5639 DEFUN (show_ip_ospf_instance_database_max
,
5640 show_ip_ospf_instance_database_max_cmd
,
5641 "show ip ospf (1-65535) database <max-age|self-originate>",
5644 "OSPF information\n"
5646 "Database summary\n"
5647 "LSAs in MaxAge list\n"
5648 "Self-originated link states\n")
5652 u_short instance
= 0;
5654 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
5656 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5659 return (show_ip_ospf_database_common(vty
, ospf
, 1, argc
, argv
));
5664 show_ip_ospf_database_type_adv_router_common (struct vty
*vty
, struct ospf
*ospf
,
5665 int arg_base
, int argc
, struct cmd_token
**argv
)
5669 struct in_addr adv_router
;
5672 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5675 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5676 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5678 if (argc
!= arg_base
+ 7)
5681 /* Set database type to show. */
5682 if (strncmp (argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5683 type
= OSPF_ROUTER_LSA
;
5684 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5685 type
= OSPF_NETWORK_LSA
;
5686 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5687 type
= OSPF_AS_NSSA_LSA
;
5688 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "s", 1) == 0)
5689 type
= OSPF_SUMMARY_LSA
;
5690 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5691 type
= OSPF_ASBR_SUMMARY_LSA
;
5692 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5693 type
= OSPF_AS_EXTERNAL_LSA
;
5694 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5695 type
= OSPF_OPAQUE_LINK_LSA
;
5696 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5697 type
= OSPF_OPAQUE_AREA_LSA
;
5698 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5699 type
= OSPF_OPAQUE_AS_LSA
;
5703 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
5704 if (strncmp (argv
[arg_base
+ 5]->text
, "s", 1) == 0)
5705 adv_router
= ospf
->router_id
;
5708 ret
= inet_aton (argv
[arg_base
+ 6]->arg
, &adv_router
);
5713 show_lsa_detail_adv_router (vty
, ospf
, type
, &adv_router
);
5718 DEFUN (show_ip_ospf_database_type_adv_router
,
5719 show_ip_ospf_database_type_adv_router_cmd
,
5720 "show ip ospf database <asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as> <adv-router A.B.C.D|self-originate>",
5723 "OSPF information\n"
5724 "Database summary\n"
5726 "Advertising Router link states\n"
5727 "Advertising Router (as an IP address)\n"
5728 "Self-originated link states\n")
5732 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5735 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 0, argc
, argv
));
5738 DEFUN (show_ip_ospf_instance_database_type_adv_router
,
5739 show_ip_ospf_instance_database_type_adv_router_cmd
,
5740 "show ip ospf (1-65535) database <asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as> <adv-router A.B.C.D|self-originate>",
5743 "OSPF information\n"
5745 "Database summary\n"
5747 "Advertising Router link states\n"
5748 "Advertising Router (as an IP address)\n"
5749 "Self-originated link states\n")
5753 u_short instance
= 0;
5755 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
5757 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5760 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 1, argc
, argv
));
5763 DEFUN (ip_ospf_authentication_args
,
5764 ip_ospf_authentication_args_addr_cmd
,
5765 "ip ospf authentication <null|message-digest> [A.B.C.D]",
5767 "OSPF interface commands\n"
5768 "Enable authentication on this interface\n"
5769 "Use null authentication\n"
5770 "Use message-digest authentication\n"
5771 "Address of interface\n")
5773 int idx_encryption
= 3;
5775 struct interface
*ifp
;
5776 struct in_addr addr
;
5778 struct ospf_if_params
*params
;
5781 params
= IF_DEF_PARAMS (ifp
);
5785 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5788 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5793 params
= ospf_get_if_params (ifp
, addr
);
5794 ospf_if_update_params (ifp
, addr
);
5797 /* Handle null authentication */
5798 if ( argv
[idx_encryption
]->arg
[0] == 'n' )
5800 SET_IF_PARAM (params
, auth_type
);
5801 params
->auth_type
= OSPF_AUTH_NULL
;
5805 /* Handle message-digest authentication */
5806 if ( argv
[idx_encryption
]->arg
[0] == 'm' )
5808 SET_IF_PARAM (params
, auth_type
);
5809 params
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5813 vty_out (vty
, "You shouldn't get here!%s", VTY_NEWLINE
);
5817 DEFUN (ip_ospf_authentication
,
5818 ip_ospf_authentication_addr_cmd
,
5819 "ip ospf authentication [A.B.C.D]",
5821 "OSPF interface commands\n"
5822 "Enable authentication on this interface\n"
5823 "Address of interface")
5826 struct interface
*ifp
;
5827 struct in_addr addr
;
5829 struct ospf_if_params
*params
;
5832 params
= IF_DEF_PARAMS (ifp
);
5836 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5839 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5844 params
= ospf_get_if_params (ifp
, addr
);
5845 ospf_if_update_params (ifp
, addr
);
5848 SET_IF_PARAM (params
, auth_type
);
5849 params
->auth_type
= OSPF_AUTH_SIMPLE
;
5854 DEFUN (no_ip_ospf_authentication_args
,
5855 no_ip_ospf_authentication_args_addr_cmd
,
5856 "no ip ospf authentication <null|message-digest> [A.B.C.D]",
5859 "OSPF interface commands\n"
5860 "Enable authentication on this interface\n"
5861 "Use null authentication\n"
5862 "Use message-digest authentication\n"
5863 "Address of interface")
5865 int idx_encryption
= 4;
5867 struct interface
*ifp
;
5868 struct in_addr addr
;
5870 struct ospf_if_params
*params
;
5871 struct route_node
*rn
;
5875 params
= IF_DEF_PARAMS (ifp
);
5879 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5882 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5887 params
= ospf_lookup_if_params (ifp
, addr
);
5890 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
5893 params
->auth_type
= OSPF_AUTH_NOTSET
;
5894 UNSET_IF_PARAM (params
, auth_type
);
5895 if (params
!= IF_DEF_PARAMS (ifp
))
5897 ospf_free_if_params (ifp
, addr
);
5898 ospf_if_update_params (ifp
, addr
);
5903 if ( argv
[idx_encryption
]->arg
[0] == 'n' )
5905 auth_type
= OSPF_AUTH_NULL
;
5907 else if ( argv
[idx_encryption
]->arg
[0] == 'm' )
5909 auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5913 vty_out (vty
, "Unexpected input encountered%s", VTY_NEWLINE
);
5917 * Here we have a case where the user has entered
5918 * 'no ip ospf authentication (null | message_digest )'
5919 * we need to find if we have any ip addresses underneath it that
5920 * correspond to the associated type.
5922 if (params
->auth_type
== auth_type
)
5924 params
->auth_type
= OSPF_AUTH_NOTSET
;
5925 UNSET_IF_PARAM (params
, auth_type
);
5928 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
5930 if ((params
= rn
->info
))
5932 if (params
->auth_type
== auth_type
)
5934 params
->auth_type
= OSPF_AUTH_NOTSET
;
5935 UNSET_IF_PARAM (params
, auth_type
);
5936 if (params
!= IF_DEF_PARAMS (ifp
))
5938 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
5939 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
5949 DEFUN (no_ip_ospf_authentication
,
5950 no_ip_ospf_authentication_addr_cmd
,
5951 "no ip ospf authentication [A.B.C.D]",
5954 "OSPF interface commands\n"
5955 "Enable authentication on this interface\n"
5956 "Address of interface")
5959 struct interface
*ifp
;
5960 struct in_addr addr
;
5962 struct ospf_if_params
*params
;
5963 struct route_node
*rn
;
5966 params
= IF_DEF_PARAMS (ifp
);
5970 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5973 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5978 params
= ospf_lookup_if_params (ifp
, addr
);
5981 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
5985 params
->auth_type
= OSPF_AUTH_NOTSET
;
5986 UNSET_IF_PARAM (params
, auth_type
);
5987 if (params
!= IF_DEF_PARAMS (ifp
))
5989 ospf_free_if_params (ifp
, addr
);
5990 ospf_if_update_params (ifp
, addr
);
5996 * When a user enters 'no ip ospf authentication'
5997 * We should remove all authentication types from
6000 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
6001 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
6002 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
6004 params
->auth_type
= OSPF_AUTH_NOTSET
;
6005 UNSET_IF_PARAM (params
, auth_type
);
6008 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
6010 if ((params
= rn
->info
))
6013 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
6014 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
6015 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
6017 params
->auth_type
= OSPF_AUTH_NOTSET
;
6018 UNSET_IF_PARAM (params
, auth_type
);
6019 if (params
!= IF_DEF_PARAMS (ifp
))
6021 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
6022 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
6033 DEFUN (ip_ospf_authentication_key
,
6034 ip_ospf_authentication_key_addr_cmd
,
6035 "ip ospf authentication-key AUTH_KEY [A.B.C.D]",
6037 "OSPF interface commands\n"
6038 "Authentication password (key)\n"
6039 "The OSPF password (key)\n"
6040 "Address of interface")
6043 struct interface
*ifp
;
6044 struct in_addr addr
;
6045 struct ospf_if_params
*params
;
6048 params
= IF_DEF_PARAMS (ifp
);
6050 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6052 if (!inet_aton(argv
[idx
]->arg
, &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 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
6064 strncpy ((char *) params
->auth_simple
, argv
[3]->arg
, OSPF_AUTH_SIMPLE_SIZE
);
6065 SET_IF_PARAM (params
, auth_simple
);
6070 DEFUN_HIDDEN (ospf_authentication_key
,
6071 ospf_authentication_key_cmd
,
6072 "ospf authentication-key AUTH_KEY [A.B.C.D]",
6073 "OSPF interface commands\n"
6074 "Authentication password (key)\n"
6075 "The OSPF password (key)\n"
6076 "Address of interface\n")
6078 return ip_ospf_authentication_key (self
, vty
, argc
, argv
);
6081 DEFUN (no_ip_ospf_authentication_key
,
6082 no_ip_ospf_authentication_key_authkey_addr_cmd
,
6083 "no ip ospf authentication-key [AUTH_KEY [A.B.C.D]]",
6086 "OSPF interface commands\n"
6087 "Authentication password (key)\n"
6088 "The OSPF password (key)")
6091 struct interface
*ifp
;
6092 struct in_addr addr
;
6093 struct ospf_if_params
*params
;
6095 params
= IF_DEF_PARAMS (ifp
);
6097 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6099 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6101 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6106 params
= ospf_lookup_if_params (ifp
, addr
);
6111 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
);
6112 UNSET_IF_PARAM (params
, auth_simple
);
6114 if (params
!= IF_DEF_PARAMS (ifp
))
6116 ospf_free_if_params (ifp
, addr
);
6117 ospf_if_update_params (ifp
, addr
);
6123 DEFUN_HIDDEN (no_ospf_authentication_key
,
6124 no_ospf_authentication_key_authkey_addr_cmd
,
6125 "no ospf authentication-key [AUTH_KEY [A.B.C.D]]",
6127 "OSPF interface commands\n"
6128 "Authentication password (key)\n"
6129 "The OSPF password (key)")
6131 return no_ip_ospf_authentication_key (self
, vty
, argc
, argv
);
6134 DEFUN (ip_ospf_message_digest_key
,
6135 ip_ospf_message_digest_key_cmd
,
6136 "ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
6138 "OSPF interface commands\n"
6139 "Message digest authentication password (key)\n"
6141 "Use MD5 algorithm\n"
6142 "The OSPF password (key)\n"
6143 "Address of interface\n")
6145 struct interface
*ifp
;
6146 struct crypt_key
*ck
;
6148 struct in_addr addr
;
6149 struct ospf_if_params
*params
;
6152 params
= IF_DEF_PARAMS (ifp
);
6155 argv_find (argv
, argc
, "(1-255)", &idx
);
6156 char *keyid
= argv
[idx
]->arg
;
6157 argv_find (argv
, argc
, "KEY", &idx
);
6158 char *cryptkey
= argv
[idx
]->arg
;
6160 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6162 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6164 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6169 params
= ospf_get_if_params (ifp
, addr
);
6170 ospf_if_update_params (ifp
, addr
);
6173 key_id
= strtol (keyid
, NULL
, 10);
6174 if (ospf_crypt_key_lookup (params
->auth_crypt
, key_id
) != NULL
)
6176 vty_out (vty
, "OSPF: Key %d already exists%s", key_id
, VTY_NEWLINE
);
6180 ck
= ospf_crypt_key_new ();
6181 ck
->key_id
= (u_char
) key_id
;
6182 memset (ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
6183 strncpy ((char *) ck
->auth_key
, cryptkey
, OSPF_AUTH_MD5_SIZE
);
6185 ospf_crypt_key_add (params
->auth_crypt
, ck
);
6186 SET_IF_PARAM (params
, auth_crypt
);
6191 DEFUN_HIDDEN (ospf_message_digest_key
,
6192 ospf_message_digest_key_cmd
,
6193 "ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
6194 "OSPF interface commands\n"
6195 "Message digest authentication password (key)\n"
6197 "Use MD5 algorithm\n"
6198 "The OSPF password (key)\n"
6199 "Address of interface\n")
6201 return ip_ospf_message_digest_key (self
, vty
, argc
, argv
);
6204 DEFUN (no_ip_ospf_message_digest_key
,
6205 no_ip_ospf_message_digest_key_cmd
,
6206 "no ip ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
6209 "OSPF interface commands\n"
6210 "Message digest authentication password (key)\n"
6212 "Use MD5 algorithm\n"
6213 "The OSPF password (key)\n"
6214 "Address of interface\n")
6217 struct interface
*ifp
;
6218 struct crypt_key
*ck
;
6220 struct in_addr addr
;
6221 struct ospf_if_params
*params
;
6223 params
= IF_DEF_PARAMS (ifp
);
6225 argv_find (argv
, argc
, "(1-255)", &idx
);
6226 char *keyid
= argv
[idx
]->arg
;
6228 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6230 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6232 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6237 params
= ospf_lookup_if_params (ifp
, addr
);
6242 key_id
= strtol (keyid
, NULL
, 10);
6243 ck
= ospf_crypt_key_lookup (params
->auth_crypt
, key_id
);
6246 vty_out (vty
, "OSPF: Key %d does not exist%s", key_id
, VTY_NEWLINE
);
6250 ospf_crypt_key_delete (params
->auth_crypt
, key_id
);
6252 if (params
!= IF_DEF_PARAMS (ifp
))
6254 ospf_free_if_params (ifp
, addr
);
6255 ospf_if_update_params (ifp
, addr
);
6261 DEFUN_HIDDEN (no_ospf_message_digest_key
,
6262 no_ospf_message_digest_key_cmd
,
6263 "no ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
6265 "OSPF interface commands\n"
6266 "Message digest authentication password (key)\n"
6268 "Address of interface")
6270 return no_ip_ospf_message_digest_key (self
, vty
, argc
, argv
);
6273 DEFUN (ip_ospf_cost
,
6275 "ip ospf cost (1-65535) [A.B.C.D]",
6277 "OSPF interface commands\n"
6280 "Address of interface\n")
6283 struct interface
*ifp
= vty
->index
;
6285 struct in_addr addr
;
6286 struct ospf_if_params
*params
;
6287 params
= IF_DEF_PARAMS (ifp
);
6290 char *coststr
= NULL
, *ifaddr
= NULL
;
6291 coststr
= argv_find (argv
, argc
, "(1-65535)", &idx
) ? argv
[idx
]->arg
: NULL
;
6292 ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6294 cost
= strtol (coststr
, NULL
, 10);
6298 if(!inet_aton(ifaddr
, &addr
))
6300 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6305 params
= ospf_get_if_params (ifp
, addr
);
6306 ospf_if_update_params (ifp
, addr
);
6309 SET_IF_PARAM (params
, output_cost_cmd
);
6310 params
->output_cost_cmd
= cost
;
6312 ospf_if_recalculate_output_cost (ifp
);
6317 DEFUN_HIDDEN (ospf_cost
,
6319 "ospf cost (1-65535) [A.B.C.D]",
6320 "OSPF interface commands\n"
6323 "Address of interface\n")
6325 return ip_ospf_cost (self
, vty
, argc
, argv
);
6328 DEFUN (no_ip_ospf_cost
,
6329 no_ip_ospf_cost_cmd
,
6330 "no ip ospf cost [(1-65535)] [A.B.C.D]",
6332 "OSPF interface commands\n"
6334 "Address of interface")
6337 struct interface
*ifp
= vty
->index
;
6338 struct in_addr addr
;
6339 struct ospf_if_params
*params
;
6342 params
= IF_DEF_PARAMS (ifp
);
6345 char *ifaddr
= NULL
;
6346 ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6348 /* According to the semantics we are mimicking "no ip ospf cost N" is
6349 * always treated as "no ip ospf cost" regardless of the actual value
6350 * of N already configured for the interface. Thus ignore cost. */
6354 if (!inet_aton(ifaddr
, &addr
))
6356 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6361 params
= ospf_lookup_if_params (ifp
, addr
);
6366 UNSET_IF_PARAM (params
, output_cost_cmd
);
6368 if (params
!= IF_DEF_PARAMS (ifp
))
6370 ospf_free_if_params (ifp
, addr
);
6371 ospf_if_update_params (ifp
, addr
);
6374 ospf_if_recalculate_output_cost (ifp
);
6379 DEFUN_HIDDEN (no_ospf_cost
,
6381 "no ospf cost [(1-65535)] [A.B.C.D]",
6383 "OSPF interface commands\n"
6386 "Address of interface\n")
6388 return no_ip_ospf_cost (self
, vty
, argc
, argv
);
6392 ospf_nbr_timer_update (struct ospf_interface
*oi
)
6394 struct route_node
*rn
;
6395 struct ospf_neighbor
*nbr
;
6397 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
6398 if ((nbr
= rn
->info
))
6400 nbr
->v_inactivity
= OSPF_IF_PARAM (oi
, v_wait
);
6401 nbr
->v_db_desc
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6402 nbr
->v_ls_req
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6403 nbr
->v_ls_upd
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6408 ospf_vty_dead_interval_set (struct vty
*vty
, const char *interval_str
,
6409 const char *nbr_str
,
6410 const char *fast_hello_str
)
6412 struct interface
*ifp
= vty
->index
;
6415 struct in_addr addr
;
6417 struct ospf_if_params
*params
;
6418 struct ospf_interface
*oi
;
6419 struct route_node
*rn
;
6421 params
= IF_DEF_PARAMS (ifp
);
6425 ret
= inet_aton(nbr_str
, &addr
);
6428 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6433 params
= ospf_get_if_params (ifp
, addr
);
6434 ospf_if_update_params (ifp
, addr
);
6439 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds
, interval_str
,
6442 /* reset fast_hello too, just to be sure */
6443 UNSET_IF_PARAM (params
, fast_hello
);
6444 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6446 else if (fast_hello_str
)
6448 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult
, fast_hello_str
,
6450 /* 1s dead-interval with sub-second hellos desired */
6451 seconds
= OSPF_ROUTER_DEAD_INTERVAL_MINIMAL
;
6452 SET_IF_PARAM (params
, fast_hello
);
6453 params
->fast_hello
= hellomult
;
6457 vty_out (vty
, "Please specify dead-interval or hello-multiplier%s",
6462 SET_IF_PARAM (params
, v_wait
);
6463 params
->v_wait
= seconds
;
6465 /* Update timer values in neighbor structure. */
6469 if ((ospf
= ospf_lookup()))
6471 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
6473 ospf_nbr_timer_update (oi
);
6478 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6479 if ((oi
= rn
->info
))
6480 ospf_nbr_timer_update (oi
);
6486 DEFUN (ip_ospf_dead_interval
,
6487 ip_ospf_dead_interval_cmd
,
6488 "ip ospf dead-interval (1-65535) [A.B.C.D]",
6490 "OSPF interface commands\n"
6491 "Interval time after which a neighbor is declared down\n"
6493 "Address of interface\n")
6496 char *interval
= argv_find (argv
, argc
, "(1-65535)", &idx
) ? argv
[idx
]->arg
: NULL
;
6497 char *ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6498 return ospf_vty_dead_interval_set (vty
, interval
, ifaddr
, NULL
);
6502 DEFUN_HIDDEN (ospf_dead_interval
,
6503 ospf_dead_interval_cmd
,
6504 "ospf dead-interval (1-65535) [A.B.C.D]",
6505 "OSPF interface commands\n"
6506 "Interval time after which a neighbor is declared down\n"
6508 "Address of interface\n")
6510 return ip_ospf_dead_interval (self
, vty
, argc
, argv
);
6513 DEFUN (ip_ospf_dead_interval_minimal
,
6514 ip_ospf_dead_interval_minimal_addr_cmd
,
6515 "ip ospf dead-interval minimal hello-multiplier (1-10) [A.B.C.D]",
6517 "OSPF interface commands\n"
6518 "Interval time after which a neighbor is declared down\n"
6519 "Minimal 1s dead-interval with fast sub-second hellos\n"
6520 "Hello multiplier factor\n"
6521 "Number of Hellos to send each second\n"
6522 "Address of interface\n")
6527 return ospf_vty_dead_interval_set (vty
, NULL
, argv
[idx_ipv4
]->arg
, argv
[idx_number
]->arg
);
6529 return ospf_vty_dead_interval_set (vty
, NULL
, NULL
, argv
[idx_number
]->arg
);
6532 DEFUN (no_ip_ospf_dead_interval
,
6533 no_ip_ospf_dead_interval_cmd
,
6534 "no ip ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6537 "OSPF interface commands\n"
6538 "Interval time after which a neighbor is declared down\n"
6540 "Address of interface")
6542 int idx_ipv4
= argc
- 1;
6543 struct interface
*ifp
= vty
->index
;
6544 struct in_addr addr
;
6546 struct ospf_if_params
*params
;
6547 struct ospf_interface
*oi
;
6548 struct route_node
*rn
;
6551 params
= IF_DEF_PARAMS (ifp
);
6553 if (argv
[idx_ipv4
]->type
== IPV4_TKN
)
6555 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6558 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6563 params
= ospf_lookup_if_params (ifp
, addr
);
6568 UNSET_IF_PARAM (params
, v_wait
);
6569 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
6571 UNSET_IF_PARAM (params
, fast_hello
);
6572 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6574 if (params
!= IF_DEF_PARAMS (ifp
))
6576 ospf_free_if_params (ifp
, addr
);
6577 ospf_if_update_params (ifp
, addr
);
6580 /* Update timer values in neighbor structure. */
6585 if ((ospf
= ospf_lookup()))
6587 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
6589 ospf_nbr_timer_update (oi
);
6594 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6595 if ((oi
= rn
->info
))
6596 ospf_nbr_timer_update (oi
);
6602 DEFUN_HIDDEN (no_ospf_dead_interval
,
6603 no_ospf_dead_interval_cmd
,
6604 "no ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6606 "OSPF interface commands\n"
6607 "Interval time after which a neighbor is declared down\n"
6609 "Address of interface")
6611 return no_ip_ospf_dead_interval (self
, vty
, argc
, argv
);
6614 DEFUN (ip_ospf_hello_interval
,
6615 ip_ospf_hello_interval_cmd
,
6616 "ip ospf hello-interval (1-65535) [A.B.C.D]",
6618 "OSPF interface commands\n"
6619 "Time between HELLO packets\n"
6621 "Address of interface\n")
6624 struct interface
*ifp
= vty
->index
;
6625 struct in_addr addr
;
6626 struct ospf_if_params
*params
;
6627 params
= IF_DEF_PARAMS (ifp
);
6628 u_int32_t seconds
= 0;
6630 argv_find (argv
, argc
, "(1-65535)", &idx
);
6631 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
6633 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6635 if(!inet_aton(argv
[idx
]->arg
, &addr
))
6637 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6642 params
= ospf_get_if_params (ifp
, addr
);
6643 ospf_if_update_params (ifp
, addr
);
6646 SET_IF_PARAM (params
, v_hello
);
6647 params
->v_hello
= seconds
;
6652 DEFUN_HIDDEN (ospf_hello_interval
,
6653 ospf_hello_interval_cmd
,
6654 "ospf hello-interval (1-65535) [A.B.C.D]",
6655 "OSPF interface commands\n"
6656 "Time between HELLO packets\n"
6658 "Address of interface\n")
6660 return ip_ospf_hello_interval (self
, vty
, argc
, argv
);
6663 DEFUN (no_ip_ospf_hello_interval
,
6664 no_ip_ospf_hello_interval_cmd
,
6665 "no ip ospf hello-interval [(1-65535) [A.B.C.D]]",
6668 "OSPF interface commands\n"
6669 "Time between HELLO packets\n" // ignored
6671 "Address of interface\n")
6674 struct interface
*ifp
= vty
->index
;
6675 struct in_addr addr
;
6676 struct ospf_if_params
*params
;
6677 params
= IF_DEF_PARAMS (ifp
);
6679 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6681 if(!inet_aton(argv
[idx
]->arg
, &addr
))
6683 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6688 params
= ospf_lookup_if_params (ifp
, addr
);
6693 UNSET_IF_PARAM (params
, v_hello
);
6694 params
->v_hello
= OSPF_HELLO_INTERVAL_DEFAULT
;
6696 if (params
!= IF_DEF_PARAMS (ifp
))
6698 ospf_free_if_params (ifp
, addr
);
6699 ospf_if_update_params (ifp
, addr
);
6705 DEFUN_HIDDEN (no_ospf_hello_interval
,
6706 no_ospf_hello_interval_cmd
,
6707 "no ospf hello-interval [(1-65535) [A.B.C.D]]",
6709 "OSPF interface commands\n"
6710 "Time between HELLO packets\n" // ignored
6712 "Address of interface\n")
6714 return no_ip_ospf_hello_interval (self
, vty
, argc
, argv
);
6717 DEFUN (ip_ospf_network
,
6718 ip_ospf_network_cmd
,
6719 "ip ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
6721 "OSPF interface commands\n"
6723 "Specify OSPF broadcast multi-access network\n"
6724 "Specify OSPF NBMA network\n"
6725 "Specify OSPF point-to-multipoint network\n"
6726 "Specify OSPF point-to-point network\n")
6729 struct interface
*ifp
= vty
->index
;
6730 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
6731 struct route_node
*rn
;
6733 if (old_type
== OSPF_IFTYPE_LOOPBACK
)
6735 vty_out (vty
, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE
);
6739 if (argv_find (argv
, argc
, "broadcast", &idx
))
6740 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_BROADCAST
;
6741 else if (argv_find (argv
, argc
, "non-broadcast", &idx
))
6742 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_NBMA
;
6743 else if (argv_find (argv
, argc
, "point-to-multipoint", &idx
))
6744 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOMULTIPOINT
;
6745 else if (argv_find (argv
, argc
, "point-to-point", &idx
))
6746 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOPOINT
;
6748 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
6751 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), type
);
6753 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6755 struct ospf_interface
*oi
= rn
->info
;
6760 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
6762 if (oi
->state
> ISM_Down
)
6764 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
6765 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
6772 DEFUN_HIDDEN (ospf_network
,
6774 "ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
6775 "OSPF interface commands\n"
6777 "Specify OSPF broadcast multi-access network\n"
6778 "Specify OSPF NBMA network\n"
6779 "Specify OSPF point-to-multipoint network\n"
6780 "Specify OSPF point-to-point network\n")
6782 return ip_ospf_network (self
, vty
, argc
, argv
);
6785 DEFUN (no_ip_ospf_network
,
6786 no_ip_ospf_network_cmd
,
6787 "no ip ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
6790 "OSPF interface commands\n"
6792 "Specify OSPF broadcast multi-access network\n"
6793 "Specify OSPF NBMA network\n"
6794 "Specify OSPF point-to-multipoint network\n"
6795 "Specify OSPF point-to-point network\n")
6797 struct interface
*ifp
= vty
->index
;
6798 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
6799 struct route_node
*rn
;
6801 IF_DEF_PARAMS (ifp
)->type
= ospf_default_iftype(ifp
);
6803 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
6806 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6808 struct ospf_interface
*oi
= rn
->info
;
6813 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
6815 if (oi
->state
> ISM_Down
)
6817 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
6818 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
6825 DEFUN_HIDDEN (no_ospf_network
,
6826 no_ospf_network_cmd
,
6827 "no ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
6829 "OSPF interface commands\n"
6831 "Specify OSPF broadcast multi-access network\n"
6832 "Specify OSPF NBMA network\n"
6833 "Specify OSPF point-to-multipoint network\n"
6834 "Specify OSPF point-to-point network\n")
6836 return no_ip_ospf_network (self
, vty
, argc
, argv
);
6839 DEFUN (ip_ospf_priority
,
6840 ip_ospf_priority_cmd
,
6841 "ip ospf priority (0-255) [A.B.C.D]",
6843 "OSPF interface commands\n"
6846 "Address of interface")
6849 struct interface
*ifp
= vty
->index
;
6851 struct route_node
*rn
;
6852 struct in_addr addr
;
6853 struct ospf_if_params
*params
;
6854 params
= IF_DEF_PARAMS (ifp
);
6856 argv_find (argv
, argc
, "(0-255)", &idx
);
6857 priority
= strtol (argv
[idx
]->arg
, NULL
, 10);
6859 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6861 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6863 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6868 params
= ospf_get_if_params (ifp
, addr
);
6869 ospf_if_update_params (ifp
, addr
);
6872 SET_IF_PARAM (params
, priority
);
6873 params
->priority
= priority
;
6875 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6877 struct ospf_interface
*oi
= rn
->info
;
6882 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
6884 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
6885 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
6892 DEFUN_HIDDEN (ospf_priority
,
6894 "ospf priority (0-255) [A.B.C.D]",
6895 "OSPF interface commands\n"
6898 "Address of interface")
6900 return ip_ospf_priority (self
, vty
, argc
, argv
);
6903 DEFUN (no_ip_ospf_priority
,
6904 no_ip_ospf_priority_cmd
,
6905 "no ip ospf priority [(0-255) [A.B.C.D]]",
6908 "OSPF interface commands\n"
6909 "Router priority\n" // ignored
6911 "Address of interface")
6914 struct interface
*ifp
= vty
->index
;
6915 struct route_node
*rn
;
6916 struct in_addr addr
;
6917 struct ospf_if_params
*params
;
6920 params
= IF_DEF_PARAMS (ifp
);
6922 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6924 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6926 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6931 params
= ospf_lookup_if_params (ifp
, addr
);
6936 UNSET_IF_PARAM (params
, priority
);
6937 params
->priority
= OSPF_ROUTER_PRIORITY_DEFAULT
;
6939 if (params
!= IF_DEF_PARAMS (ifp
))
6941 ospf_free_if_params (ifp
, addr
);
6942 ospf_if_update_params (ifp
, addr
);
6945 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6947 struct ospf_interface
*oi
= rn
->info
;
6952 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
6954 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
6955 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
6962 DEFUN_HIDDEN (no_ospf_priority
,
6963 no_ospf_priority_cmd
,
6964 "no ospf priority [(0-255) [A.B.C.D]]",
6966 "OSPF interface commands\n"
6969 "Address of interface")
6971 return no_ip_ospf_priority (self
, vty
, argc
, argv
);
6974 DEFUN (ip_ospf_retransmit_interval
,
6975 ip_ospf_retransmit_interval_addr_cmd
,
6976 "ip ospf retransmit-interval (3-65535) [A.B.C.D]",
6978 "OSPF interface commands\n"
6979 "Time between retransmitting lost link state advertisements\n"
6981 "Address of interface")
6984 struct interface
*ifp
= vty
->index
;
6986 struct in_addr addr
;
6987 struct ospf_if_params
*params
;
6988 params
= IF_DEF_PARAMS (ifp
);
6990 argv_find (argv
, argc
, "(3-65535)", &idx
);
6991 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
6993 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6995 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6997 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7002 params
= ospf_get_if_params (ifp
, addr
);
7003 ospf_if_update_params (ifp
, addr
);
7006 SET_IF_PARAM (params
, retransmit_interval
);
7007 params
->retransmit_interval
= seconds
;
7012 DEFUN_HIDDEN (ospf_retransmit_interval
,
7013 ospf_retransmit_interval_cmd
,
7014 "ospf retransmit-interval (3-65535) [A.B.C.D]",
7015 "OSPF interface commands\n"
7016 "Time between retransmitting lost link state advertisements\n"
7018 "Address of interface")
7020 return ip_ospf_retransmit_interval (self
, vty
, argc
, argv
);
7023 DEFUN (no_ip_ospf_retransmit_interval
,
7024 no_ip_ospf_retransmit_interval_addr_cmd
,
7025 "no ip ospf retransmit-interval [(3-65535)] [A.B.C.D]",
7028 "OSPF interface commands\n"
7029 "Time between retransmitting lost link state advertisements\n"
7031 "Address of interface\n")
7034 struct interface
*ifp
= vty
->index
;
7035 struct in_addr addr
;
7036 struct ospf_if_params
*params
;
7039 params
= IF_DEF_PARAMS (ifp
);
7041 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
7043 if (!inet_aton(argv
[idx
]->arg
, &addr
))
7045 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7050 params
= ospf_lookup_if_params (ifp
, addr
);
7055 UNSET_IF_PARAM (params
, retransmit_interval
);
7056 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
7058 if (params
!= IF_DEF_PARAMS (ifp
))
7060 ospf_free_if_params (ifp
, addr
);
7061 ospf_if_update_params (ifp
, addr
);
7067 DEFUN_HIDDEN (no_ospf_retransmit_interval
,
7068 no_ospf_retransmit_interval_cmd
,
7069 "no ospf retransmit-interval [(3-65535)] [A.B.C.D]",
7071 "OSPF interface commands\n"
7072 "Time between retransmitting lost link state advertisements\n"
7074 "Address of interface\n")
7076 return no_ip_ospf_retransmit_interval (self
, vty
, argc
, argv
);
7079 DEFUN (ip_ospf_transmit_delay
,
7080 ip_ospf_transmit_delay_addr_cmd
,
7081 "ip ospf transmit-delay (1-65535) [A.B.C.D]",
7083 "OSPF interface commands\n"
7084 "Link state transmit delay\n"
7086 "Address of interface")
7089 struct interface
*ifp
= vty
->index
;
7091 struct in_addr addr
;
7092 struct ospf_if_params
*params
;
7094 params
= IF_DEF_PARAMS (ifp
);
7095 argv_find (argv
, argc
, "(1-65535)", &idx
);
7096 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
7098 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
7100 if (!inet_aton(argv
[idx
]->arg
, &addr
))
7102 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7107 params
= ospf_get_if_params (ifp
, addr
);
7108 ospf_if_update_params (ifp
, addr
);
7111 SET_IF_PARAM (params
, transmit_delay
);
7112 params
->transmit_delay
= seconds
;
7117 DEFUN_HIDDEN (ospf_transmit_delay
,
7118 ospf_transmit_delay_cmd
,
7119 "ospf transmit-delay (1-65535) [A.B.C.D]",
7120 "OSPF interface commands\n"
7121 "Link state transmit delay\n"
7123 "Address of interface")
7125 return ip_ospf_transmit_delay (self
, vty
, argc
, argv
);
7128 DEFUN (no_ip_ospf_transmit_delay
,
7129 no_ip_ospf_transmit_delay_addr_cmd
,
7130 "no ip ospf transmit-delay [(1-65535)] [A.B.C.D]",
7133 "OSPF interface commands\n"
7134 "Link state transmit delay\n"
7135 "Address of interface")
7138 struct interface
*ifp
= vty
->index
;
7139 struct in_addr addr
;
7140 struct ospf_if_params
*params
;
7143 params
= IF_DEF_PARAMS (ifp
);
7145 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
7147 if (!inet_aton(argv
[idx
]->arg
, &addr
))
7149 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7154 params
= ospf_lookup_if_params (ifp
, addr
);
7159 UNSET_IF_PARAM (params
, transmit_delay
);
7160 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
7162 if (params
!= IF_DEF_PARAMS (ifp
))
7164 ospf_free_if_params (ifp
, addr
);
7165 ospf_if_update_params (ifp
, addr
);
7172 DEFUN_HIDDEN (no_ospf_transmit_delay
,
7173 no_ospf_transmit_delay_cmd
,
7174 "no ospf transmit-delay",
7176 "OSPF interface commands\n"
7177 "Link state transmit delay\n")
7179 return no_ip_ospf_transmit_delay (self
, vty
, argc
, argv
);
7182 DEFUN (ip_ospf_area
,
7184 "ip ospf [(1-65535)] area <A.B.C.D|(0-4294967295)>",
7186 "OSPF interface commands\n"
7188 "Enable OSPF on this interface\n"
7189 "OSPF area ID in IP address format\n"
7190 "OSPF area ID as a decimal value\n")
7193 struct interface
*ifp
= vty
->index
;
7195 struct in_addr area_id
;
7197 struct ospf_if_params
*params
;
7198 struct route_node
*rn
;
7199 u_short instance
= 0;
7201 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
7202 instance
= strtol (argv
[idx
]->arg
, NULL
, 10);
7203 char *areaid
= argv
[argc
- 1]->arg
;
7205 ospf
= ospf_lookup_instance (instance
);
7208 params
= IF_DEF_PARAMS (ifp
);
7209 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7211 ospf_interface_unset (ifp
);
7212 ospf
= ospf_lookup();
7213 ospf
->if_ospf_cli_count
--;
7218 ret
= ospf_str2area_id (areaid
, &area_id
, &format
);
7221 vty_out (vty
, "Please specify area by A.B.C.D|<0-4294967295>%s",
7225 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
7227 vty_out (vty
, "Cannot enable OSPF on a virtual link.%s", VTY_NEWLINE
);
7231 params
= IF_DEF_PARAMS (ifp
);
7232 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7235 "Must remove previous area config before changing ospf area %s",
7240 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
7242 if (rn
->info
!= NULL
)
7244 vty_out (vty
, "Please remove all network commands first.%s", VTY_NEWLINE
);
7249 /* enable ospf on this interface with area_id */
7250 ospf_interface_set (ifp
, area_id
);
7251 ospf
->if_ospf_cli_count
++;
7256 DEFUN (no_ip_ospf_area
,
7257 no_ip_ospf_area_cmd
,
7258 "no ip ospf [(1-65535)] area [<A.B.C.D|(0-4294967295)>]",
7261 "OSPF interface commands\n"
7263 "Disable OSPF on this interface\n"
7264 "OSPF area ID in IP address format\n"
7265 "OSPF area ID as a decimal value\n")
7268 struct interface
*ifp
= vty
->index
;
7270 struct ospf_if_params
*params
;
7271 u_short instance
= 0;
7273 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
7274 instance
= strtol (argv
[idx
]->arg
, NULL
, 10);
7276 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
7279 params
= IF_DEF_PARAMS (ifp
);
7280 if (!OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7282 vty_out (vty
, "Can't find specified interface area configuration.%s", VTY_NEWLINE
);
7286 ospf_interface_unset (ifp
);
7287 ospf
->if_ospf_cli_count
--;
7291 DEFUN (ospf_redistribute_source
,
7292 ospf_redistribute_source_cmd
,
7293 "redistribute <kernel|connected|static|rip|isis|bgp|pim|table> [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7295 QUAGGA_REDIST_HELP_STR_OSPFD
7296 "Metric for redistributed routes\n"
7297 "OSPF default metric\n"
7298 "OSPF exterior metric type for redistributed routes\n"
7299 "Set OSPF External Type 1 metrics\n"
7300 "Set OSPF External Type 2 metrics\n"
7301 "Route map reference\n"
7302 "Pointer to route-map entries\n")
7304 int idx_protocol
= 1;
7305 int idx_redist_param
= 2;
7306 struct ospf
*ospf
= vty
->index
;
7310 struct ospf_redist
*red
;
7316 return CMD_WARNING
; /* should not happen */
7321 /* Get distribute source. */
7322 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->arg
);
7323 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
7326 /* Get metric value. */
7327 if (strcmp (argv
[idx_redist_param
]->arg
, "metric") == 0)
7328 if (!str2metric (argv
[idx_redist_param
+1]->arg
, &metric
))
7331 /* Get metric type. */
7332 if (strcmp (argv
[idx_redist_param
]->arg
, "metric-type") == 0)
7333 if (!str2metric_type (argv
[idx_redist_param
+1]->arg
, &type
))
7336 red
= ospf_redist_add(ospf
, source
, 0);
7338 if (strcmp (argv
[idx_redist_param
]->arg
, "route-map") == 0)
7339 ospf_routemap_set (red
, argv
[idx_redist_param
+1]->arg
);
7341 ospf_routemap_unset (red
);
7343 return ospf_redistribute_set (ospf
, source
, 0, type
, metric
);
7346 DEFUN (no_ospf_redistribute_source
,
7347 no_ospf_redistribute_source_cmd
,
7348 "no redistribute <kernel|connected|static|rip|isis|bgp|pim|table> [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7351 QUAGGA_REDIST_HELP_STR_OSPFD
7352 "Metric for redistributed routes\n"
7353 "OSPF default metric\n"
7354 "OSPF exterior metric type for redistributed routes\n"
7355 "Set OSPF External Type 1 metrics\n"
7356 "Set OSPF External Type 2 metrics\n"
7357 "Route map reference\n"
7358 "Pointer to route-map entries\n")
7360 int idx_protocol
= 2;
7361 struct ospf
*ospf
= vty
->index
;
7363 struct ospf_redist
*red
;
7367 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->arg
);
7368 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
7371 red
= ospf_redist_lookup(ospf
, source
, 0);
7375 ospf_routemap_unset (red
);
7376 return ospf_redistribute_unset (ospf
, source
, 0);
7379 DEFUN (ospf_redistribute_instance_source
,
7380 ospf_redistribute_instance_source_cmd
,
7381 "redistribute <ospf|table> (1-65535) [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7383 "Open Shortest Path First\n"
7384 "Non-main Kernel Routing Table\n"
7385 "Instance ID/Table ID\n"
7386 "Metric for redistributed routes\n"
7387 "OSPF default metric\n"
7388 "OSPF exterior metric type for redistributed routes\n"
7389 "Set OSPF External Type 1 metrics\n"
7390 "Set OSPF External Type 2 metrics\n"
7391 "Route map reference\n"
7392 "Pointer to route-map entries\n")
7394 int idx_ospf_table
= 1;
7396 int idx_redist_param
= 3;
7397 struct ospf
*ospf
= vty
->index
;
7402 struct ospf_redist
*red
;
7407 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
7408 source
= ZEBRA_ROUTE_OSPF
;
7410 source
= ZEBRA_ROUTE_TABLE
;
7412 VTY_GET_INTEGER ("Instance ID", instance
, argv
[idx_number
]->arg
);
7417 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
7419 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
7424 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
7426 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
7431 /* Get metric value. */
7432 if (strcmp (argv
[idx_redist_param
]->arg
, "metric") == 0)
7433 if (!str2metric (argv
[idx_redist_param
+1]->arg
, &metric
))
7436 /* Get metric type. */
7437 if (strcmp (argv
[idx_redist_param
]->arg
, "metric-type") == 0)
7438 if (!str2metric_type (argv
[idx_redist_param
+1]->arg
, &type
))
7441 red
= ospf_redist_add(ospf
, source
, instance
);
7443 if (strcmp (argv
[idx_redist_param
]->arg
, "route-map") == 0)
7444 ospf_routemap_set (red
, argv
[idx_redist_param
+1]->arg
);
7446 ospf_routemap_unset (red
);
7448 return ospf_redistribute_set (ospf
, source
, instance
, type
, metric
);
7451 DEFUN (no_ospf_redistribute_instance_source
,
7452 no_ospf_redistribute_instance_source_cmd
,
7453 "no redistribute <ospf|table> (1-65535) [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7456 "Open Shortest Path First\n"
7457 "Non-main Kernel Routing Table\n"
7458 "Instance ID/Table Id\n"
7459 "Metric for redistributed routes\n"
7460 "OSPF default metric\n"
7461 "OSPF exterior metric type for redistributed routes\n"
7462 "Set OSPF External Type 1 metrics\n"
7463 "Set OSPF External Type 2 metrics\n"
7464 "Route map reference\n"
7465 "Pointer to route-map entries\n")
7467 int idx_ospf_table
= 2;
7469 struct ospf
*ospf
= vty
->index
;
7471 struct ospf_redist
*red
;
7477 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
7478 source
= ZEBRA_ROUTE_OSPF
;
7480 source
= ZEBRA_ROUTE_TABLE
;
7482 VTY_GET_INTEGER ("Instance ID", instance
, argv
[idx_number
]->arg
);
7484 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
7486 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
7491 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
7493 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
7498 red
= ospf_redist_lookup(ospf
, source
, instance
);
7502 ospf_routemap_unset (red
);
7503 return ospf_redistribute_unset (ospf
, source
, instance
);
7506 DEFUN (ospf_distribute_list_out
,
7507 ospf_distribute_list_out_cmd
,
7508 "distribute-list WORD out <kernel|connected|static|rip|isis|bgp|pim|table>",
7509 "Filter networks in routing updates\n"
7510 "Access-list name\n"
7512 QUAGGA_REDIST_HELP_STR_OSPFD
)
7515 struct ospf
*ospf
= vty
->index
;
7521 /* Get distribute source. */
7522 source
= proto_redistnum(AFI_IP
, argv
[4]->arg
);
7523 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
7526 return ospf_distribute_list_out_set (ospf
, source
, argv
[idx_word
]->arg
);
7529 DEFUN (no_ospf_distribute_list_out
,
7530 no_ospf_distribute_list_out_cmd
,
7531 "no distribute-list WORD out <kernel|connected|static|rip|isis|bgp|pim|table>",
7533 "Filter networks in routing updates\n"
7534 "Access-list name\n"
7536 QUAGGA_REDIST_HELP_STR_OSPFD
)
7539 struct ospf
*ospf
= vty
->index
;
7545 source
= proto_redistnum(AFI_IP
, argv
[5]->arg
);
7546 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
7549 return ospf_distribute_list_out_unset (ospf
, source
, argv
[idx_word
]->arg
);
7552 /* Default information originate. */
7553 DEFUN (ospf_default_information_originate
,
7554 ospf_default_information_originate_cmd
,
7555 "default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7556 "Control distribution of default information\n"
7557 "Distribute a default route\n"
7558 "Always advertise default route\n"
7559 "OSPF default metric\n"
7561 "OSPF metric type for default routes\n"
7562 "Set OSPF External Type 1 metrics\n"
7563 "Set OSPF External Type 2 metrics\n"
7564 "Route map reference\n"
7565 "Pointer to route-map entries\n")
7567 int idx_redist_param
= 2;
7568 struct ospf
*ospf
= vty
->index
;
7569 int default_originate
= DEFAULT_ORIGINATE_ZEBRA
;
7572 struct ospf_redist
*red
;
7578 return CMD_WARNING
; /* this should not happen */
7580 /* Check whether "always" was specified */
7581 if (argv
[idx_redist_param
]->arg
!= NULL
)
7582 default_originate
= DEFAULT_ORIGINATE_ALWAYS
;
7584 red
= ospf_redist_add(ospf
, DEFAULT_ROUTE
, 0);
7586 /* Get metric value. */
7587 if (strcmp (argv
[idx_redist_param
]->arg
, "metric") == 0)
7588 if (!str2metric (argv
[idx_redist_param
+1]->arg
, &metric
))
7591 /* Get metric type. */
7592 if (strcmp (argv
[idx_redist_param
]->arg
, "metric-type") == 0)
7593 if (!str2metric_type (argv
[idx_redist_param
+1]->arg
, &type
))
7596 if (strcmp (argv
[idx_redist_param
]->arg
, "route-map") == 0)
7597 ospf_routemap_set (red
, argv
[idx_redist_param
+1]->arg
);
7599 ospf_routemap_unset (red
);
7601 return ospf_redistribute_default_set (ospf
, default_originate
,
7605 DEFUN (no_ospf_default_information_originate
,
7606 no_ospf_default_information_originate_cmd
,
7607 "no default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7609 "Control distribution of default information\n"
7610 "Distribute a default route\n"
7611 "Always advertise default route\n"
7612 "OSPF default metric\n"
7614 "OSPF metric type for default routes\n"
7615 "Set OSPF External Type 1 metrics\n"
7616 "Set OSPF External Type 2 metrics\n"
7617 "Route map reference\n"
7618 "Pointer to route-map entries\n")
7620 struct ospf
*ospf
= vty
->index
;
7621 struct prefix_ipv4 p
;
7622 struct ospf_external
*ext
;
7623 struct ospf_redist
*red
;
7629 p
.prefix
.s_addr
= 0;
7632 ospf_external_lsa_flush (ospf
, DEFAULT_ROUTE
, &p
, 0);
7634 if ((ext
= ospf_external_lookup(DEFAULT_ROUTE
, 0)) &&
7635 EXTERNAL_INFO (ext
)) {
7636 ospf_external_info_delete (DEFAULT_ROUTE
, 0, p
);
7637 ospf_external_del (DEFAULT_ROUTE
, 0);
7640 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
7644 ospf_routemap_unset (red
);
7645 return ospf_redistribute_default_unset (ospf
);
7648 DEFUN (ospf_default_metric
,
7649 ospf_default_metric_cmd
,
7650 "default-metric (0-16777214)",
7651 "Set metric of redistributed routes\n"
7655 struct ospf
*ospf
= vty
->index
;
7661 if (!str2metric (argv
[idx_number
]->arg
, &metric
))
7664 ospf
->default_metric
= metric
;
7669 DEFUN (no_ospf_default_metric
,
7670 no_ospf_default_metric_cmd
,
7671 "no default-metric [(0-16777214)]",
7673 "Set metric of redistributed routes\n"
7676 struct ospf
*ospf
= vty
->index
;
7681 ospf
->default_metric
= -1;
7687 DEFUN (ospf_distance
,
7690 "Define an administrative distance\n"
7691 "OSPF Administrative distance\n")
7694 struct ospf
*ospf
= vty
->index
;
7699 ospf
->distance_all
= atoi (argv
[idx_number
]->arg
);
7704 DEFUN (no_ospf_distance
,
7705 no_ospf_distance_cmd
,
7706 "no distance (1-255)",
7708 "Define an administrative distance\n"
7709 "OSPF Administrative distance\n")
7711 struct ospf
*ospf
= vty
->index
;
7716 ospf
->distance_all
= 0;
7721 DEFUN (no_ospf_distance_ospf
,
7722 no_ospf_distance_ospf_cmd
,
7723 "no distance ospf [<intra-area (1-255)|inter-area (1-255)|external (1-255)>]",
7725 "Define an administrative distance\n"
7726 "OSPF Administrative distance\n"
7727 "Intra-area routes\n"
7728 "Distance for intra-area routes\n"
7729 "Inter-area routes\n"
7730 "Distance for inter-area routes\n"
7732 "Distance for external routes\n")
7734 int idx_area_distance
= 3;
7735 struct ospf
*ospf
= vty
->index
;
7746 if (argv
[idx_area_distance
]->arg
!= NULL
)
7747 ospf
->distance_intra
= 0;
7749 if (argv
[1] != NULL
)
7750 ospf
->distance_inter
= 0;
7752 if (argv
[2] != NULL
)
7753 ospf
->distance_external
= 0;
7755 if (argv
[idx_area_distance
]->arg
|| argv
[1] || argv
[2])
7758 /* If no arguments are given, clear all distance information */
7759 ospf
->distance_intra
= 0;
7760 ospf
->distance_inter
= 0;
7761 ospf
->distance_external
= 0;
7766 DEFUN (ospf_distance_ospf
,
7767 ospf_distance_ospf_cmd
,
7768 "distance ospf [<intra-area (1-255)|inter-area (1-255)|external (1-255)>]",
7769 "Define an administrative distance\n"
7770 "OSPF Administrative distance\n"
7771 "Intra-area routes\n"
7772 "Distance for intra-area routes\n"
7773 "Inter-area routes\n"
7774 "Distance for inter-area routes\n"
7776 "Distance for external routes\n")
7778 int idx_area_distance
= 2;
7779 struct ospf
*ospf
= vty
->index
;
7784 if (argc
< 3) /* should not happen */
7787 if (!argv
[idx_area_distance
]->arg
&& !argv
[1] && !argv
[2])
7789 vty_out(vty
, "%% Command incomplete. (Arguments required)%s",
7794 if (strcmp (argv
[idx_area_distance
]->text
, "intra") == 0)
7795 ospf
->distance_intra
= atoi(argv
[idx_area_distance
+1]->arg
);
7797 if (strcmp (argv
[idx_area_distance
]->text
, "inter") == 0)
7798 ospf
->distance_inter
= atoi(argv
[idx_area_distance
+1]->arg
);
7800 if (strcmp (argv
[idx_area_distance
]->text
, "external") == 0)
7801 ospf
->distance_external
= atoi(argv
[idx_area_distance
+1]->arg
);
7807 DEFUN (ospf_distance_source
,
7808 ospf_distance_source_cmd
,
7809 "distance (1-255) A.B.C.D/M",
7810 "Administrative distance\n"
7812 "IP source prefix\n")
7815 int idx_ipv4_prefixlen
= 2;
7816 struct ospf
*ospf
= vty
->index
;
7821 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
7826 DEFUN (no_ospf_distance_source
,
7827 no_ospf_distance_source_cmd
,
7828 "no distance (1-255) A.B.C.D/M",
7830 "Administrative distance\n"
7832 "IP source prefix\n")
7835 int idx_ipv4_prefixlen
= 3;
7836 struct ospf
*ospf
= vty
->index
;
7841 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
7846 DEFUN (ospf_distance_source_access_list
,
7847 ospf_distance_source_access_list_cmd
,
7848 "distance (1-255) A.B.C.D/M WORD",
7849 "Administrative distance\n"
7851 "IP source prefix\n"
7852 "Access list name\n")
7855 int idx_ipv4_prefixlen
= 2;
7857 struct ospf
*ospf
= vty
->index
;
7862 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
7867 DEFUN (no_ospf_distance_source_access_list
,
7868 no_ospf_distance_source_access_list_cmd
,
7869 "no distance (1-255) A.B.C.D/M WORD",
7871 "Administrative distance\n"
7873 "IP source prefix\n"
7874 "Access list name\n")
7877 int idx_ipv4_prefixlen
= 3;
7879 struct ospf
*ospf
= vty
->index
;
7884 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
7890 DEFUN (ip_ospf_mtu_ignore
,
7891 ip_ospf_mtu_ignore_addr_cmd
,
7892 "ip ospf mtu-ignore [A.B.C.D]",
7894 "OSPF interface commands\n"
7895 "Disable MTU mismatch detection on this interface\n"
7896 "Address of interface")
7899 struct interface
*ifp
= vty
->index
;
7900 struct in_addr addr
;
7903 struct ospf_if_params
*params
;
7904 params
= IF_DEF_PARAMS (ifp
);
7908 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7911 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7915 params
= ospf_get_if_params (ifp
, addr
);
7916 ospf_if_update_params (ifp
, addr
);
7918 params
->mtu_ignore
= 1;
7919 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
7920 SET_IF_PARAM (params
, mtu_ignore
);
7923 UNSET_IF_PARAM (params
, mtu_ignore
);
7924 if (params
!= IF_DEF_PARAMS (ifp
))
7926 ospf_free_if_params (ifp
, addr
);
7927 ospf_if_update_params (ifp
, addr
);
7933 DEFUN (no_ip_ospf_mtu_ignore
,
7934 no_ip_ospf_mtu_ignore_addr_cmd
,
7935 "no ip ospf mtu-ignore [A.B.C.D]",
7937 "OSPF interface commands\n"
7938 "Disable MTU mismatch detection on this interface\n"
7939 "Address of interface")
7942 struct interface
*ifp
= vty
->index
;
7943 struct in_addr addr
;
7946 struct ospf_if_params
*params
;
7947 params
= IF_DEF_PARAMS (ifp
);
7951 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7954 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7958 params
= ospf_get_if_params (ifp
, addr
);
7959 ospf_if_update_params (ifp
, addr
);
7961 params
->mtu_ignore
= 0;
7962 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
7963 SET_IF_PARAM (params
, mtu_ignore
);
7966 UNSET_IF_PARAM (params
, mtu_ignore
);
7967 if (params
!= IF_DEF_PARAMS (ifp
))
7969 ospf_free_if_params (ifp
, addr
);
7970 ospf_if_update_params (ifp
, addr
);
7977 DEFUN (ospf_max_metric_router_lsa_admin
,
7978 ospf_max_metric_router_lsa_admin_cmd
,
7979 "max-metric router-lsa administrative",
7980 "OSPF maximum / infinite-distance metric\n"
7981 "Advertise own Router-LSA with infinite distance (stub router)\n"
7982 "Administratively applied, for an indefinite period\n")
7984 struct listnode
*ln
;
7985 struct ospf_area
*area
;
7986 struct ospf
*ospf
= vty
->index
;
7991 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7993 SET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
7995 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
))
7996 ospf_router_lsa_update_area (area
);
7999 /* Allows for areas configured later to get the property */
8000 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_SET
;
8005 DEFUN (no_ospf_max_metric_router_lsa_admin
,
8006 no_ospf_max_metric_router_lsa_admin_cmd
,
8007 "no max-metric router-lsa administrative",
8009 "OSPF maximum / infinite-distance metric\n"
8010 "Advertise own Router-LSA with infinite distance (stub router)\n"
8011 "Administratively applied, for an indefinite period\n")
8013 struct listnode
*ln
;
8014 struct ospf_area
*area
;
8015 struct ospf
*ospf
= vty
->index
;
8020 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
8022 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
8024 /* Don't trample on the start-up stub timer */
8025 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
)
8026 && !area
->t_stub_router
)
8028 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
8029 ospf_router_lsa_update_area (area
);
8032 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET
;
8036 DEFUN (ospf_max_metric_router_lsa_startup
,
8037 ospf_max_metric_router_lsa_startup_cmd
,
8038 "max-metric router-lsa on-startup (5-86400)",
8039 "OSPF maximum / infinite-distance metric\n"
8040 "Advertise own Router-LSA with infinite distance (stub router)\n"
8041 "Automatically advertise stub Router-LSA on startup of OSPF\n"
8042 "Time (seconds) to advertise self as stub-router\n")
8045 unsigned int seconds
;
8046 struct ospf
*ospf
= vty
->index
;
8053 vty_out (vty
, "%% Must supply stub-router period");
8057 VTY_GET_INTEGER ("stub-router startup period", seconds
, argv
[idx_number
]->arg
);
8059 ospf
->stub_router_startup_time
= seconds
;
8064 DEFUN (no_ospf_max_metric_router_lsa_startup
,
8065 no_ospf_max_metric_router_lsa_startup_cmd
,
8066 "no max-metric router-lsa on-startup [(5-86400)]",
8068 "OSPF maximum / infinite-distance metric\n"
8069 "Advertise own Router-LSA with infinite distance (stub router)\n"
8070 "Automatically advertise stub Router-LSA on startup of OSPF\n"
8071 "Time (seconds) to advertise self as stub-router\n")
8073 struct listnode
*ln
;
8074 struct ospf_area
*area
;
8075 struct ospf
*ospf
= vty
->index
;
8080 ospf
->stub_router_startup_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
8082 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
8084 SET_FLAG (area
->stub_router_state
, OSPF_AREA_WAS_START_STUB_ROUTED
);
8085 OSPF_TIMER_OFF (area
->t_stub_router
);
8087 /* Don't trample on admin stub routed */
8088 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
8090 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
8091 ospf_router_lsa_update_area (area
);
8098 DEFUN (ospf_max_metric_router_lsa_shutdown
,
8099 ospf_max_metric_router_lsa_shutdown_cmd
,
8100 "max-metric router-lsa on-shutdown (5-100)",
8101 "OSPF maximum / infinite-distance metric\n"
8102 "Advertise own Router-LSA with infinite distance (stub router)\n"
8103 "Advertise stub-router prior to full shutdown of OSPF\n"
8104 "Time (seconds) to wait till full shutdown\n")
8107 unsigned int seconds
;
8108 struct ospf
*ospf
= vty
->index
;
8115 vty_out (vty
, "%% Must supply stub-router shutdown period");
8119 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds
, argv
[idx_number
]->arg
);
8121 ospf
->stub_router_shutdown_time
= seconds
;
8126 DEFUN (no_ospf_max_metric_router_lsa_shutdown
,
8127 no_ospf_max_metric_router_lsa_shutdown_cmd
,
8128 "no max-metric router-lsa on-shutdown [(5-100)]",
8130 "OSPF maximum / infinite-distance metric\n"
8131 "Advertise own Router-LSA with infinite distance (stub router)\n"
8132 "Advertise stub-router prior to full shutdown of OSPF\n"
8133 "Time (seconds) to wait till full shutdown\n")
8135 struct ospf
*ospf
= vty
->index
;
8140 ospf
->stub_router_shutdown_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
8146 config_write_stub_router (struct vty
*vty
, struct ospf
*ospf
)
8148 struct listnode
*ln
;
8149 struct ospf_area
*area
;
8151 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
8152 vty_out (vty
, " max-metric router-lsa on-startup %u%s",
8153 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
8154 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
8155 vty_out (vty
, " max-metric router-lsa on-shutdown %u%s",
8156 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
8157 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
8159 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
8161 vty_out (vty
, " max-metric router-lsa administrative%s",
8170 show_ip_ospf_route_network (struct vty
*vty
, struct route_table
*rt
)
8172 struct route_node
*rn
;
8173 struct ospf_route
*or;
8174 struct listnode
*pnode
, *pnnode
;
8175 struct ospf_path
*path
;
8177 vty_out (vty
, "============ OSPF network routing table ============%s",
8180 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
8181 if ((or = rn
->info
) != NULL
)
8184 snprintf (buf1
, 19, "%s/%d",
8185 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
8187 switch (or->path_type
)
8189 case OSPF_PATH_INTER_AREA
:
8190 if (or->type
== OSPF_DESTINATION_NETWORK
)
8191 vty_out (vty
, "N IA %-18s [%d] area: %s%s", buf1
, or->cost
,
8192 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
8193 else if (or->type
== OSPF_DESTINATION_DISCARD
)
8194 vty_out (vty
, "D IA %-18s Discard entry%s", buf1
, VTY_NEWLINE
);
8196 case OSPF_PATH_INTRA_AREA
:
8197 vty_out (vty
, "N %-18s [%d] area: %s%s", buf1
, or->cost
,
8198 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
8204 if (or->type
== OSPF_DESTINATION_NETWORK
)
8205 for (ALL_LIST_ELEMENTS (or->paths
, pnode
, pnnode
, path
))
8207 if (if_lookup_by_index(path
->ifindex
))
8209 if (path
->nexthop
.s_addr
== 0)
8210 vty_out (vty
, "%24s directly attached to %s%s",
8211 "", ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
8213 vty_out (vty
, "%24s via %s, %s%s", "",
8214 inet_ntoa (path
->nexthop
),
8215 ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
8219 vty_out (vty
, "%s", VTY_NEWLINE
);
8223 show_ip_ospf_route_router (struct vty
*vty
, struct route_table
*rtrs
)
8225 struct route_node
*rn
;
8226 struct ospf_route
*or;
8227 struct listnode
*pnode
;
8228 struct listnode
*node
;
8229 struct ospf_path
*path
;
8231 vty_out (vty
, "============ OSPF router routing table =============%s",
8233 for (rn
= route_top (rtrs
); rn
; rn
= route_next (rn
))
8238 vty_out (vty
, "R %-15s ", inet_ntoa (rn
->p
.u
.prefix4
));
8240 for (ALL_LIST_ELEMENTS_RO ((struct list
*)rn
->info
, node
, or))
8243 vty_out (vty
, "%24s", "");
8246 vty_out (vty
, "%s [%d] area: %s",
8247 (or->path_type
== OSPF_PATH_INTER_AREA
? "IA" : " "),
8248 or->cost
, inet_ntoa (or->u
.std
.area_id
));
8250 vty_out (vty
, "%s%s%s",
8251 (or->u
.std
.flags
& ROUTER_LSA_BORDER
? ", ABR" : ""),
8252 (or->u
.std
.flags
& ROUTER_LSA_EXTERNAL
? ", ASBR" : ""),
8255 for (ALL_LIST_ELEMENTS_RO (or->paths
, pnode
, path
))
8257 if (if_lookup_by_index(path
->ifindex
))
8259 if (path
->nexthop
.s_addr
== 0)
8260 vty_out (vty
, "%24s directly attached to %s%s",
8261 "", ifindex2ifname (path
->ifindex
),
8264 vty_out (vty
, "%24s via %s, %s%s", "",
8265 inet_ntoa (path
->nexthop
),
8266 ifindex2ifname (path
->ifindex
),
8272 vty_out (vty
, "%s", VTY_NEWLINE
);
8276 show_ip_ospf_route_external (struct vty
*vty
, struct route_table
*rt
)
8278 struct route_node
*rn
;
8279 struct ospf_route
*er
;
8280 struct listnode
*pnode
, *pnnode
;
8281 struct ospf_path
*path
;
8283 vty_out (vty
, "============ OSPF external routing table ===========%s",
8285 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
8286 if ((er
= rn
->info
) != NULL
)
8289 snprintf (buf1
, 19, "%s/%d",
8290 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
8292 switch (er
->path_type
)
8294 case OSPF_PATH_TYPE1_EXTERNAL
:
8295 vty_out (vty
, "N E1 %-18s [%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
,
8296 er
->cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
8298 case OSPF_PATH_TYPE2_EXTERNAL
:
8299 vty_out (vty
, "N E2 %-18s [%d/%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
, er
->cost
,
8300 er
->u
.ext
.type2_cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
8304 for (ALL_LIST_ELEMENTS (er
->paths
, pnode
, pnnode
, path
))
8306 if (if_lookup_by_index(path
->ifindex
))
8308 if (path
->nexthop
.s_addr
== 0)
8309 vty_out (vty
, "%24s directly attached to %s%s",
8310 "", ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
8312 vty_out (vty
, "%24s via %s, %s%s", "",
8313 inet_ntoa (path
->nexthop
),
8314 ifindex2ifname (path
->ifindex
),
8319 vty_out (vty
, "%s", VTY_NEWLINE
);
8323 show_ip_ospf_border_routers_common (struct vty
*vty
, struct ospf
*ospf
)
8326 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
8327 VTY_NEWLINE
, VTY_NEWLINE
);
8329 if (ospf
->new_table
== NULL
)
8331 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
8335 /* Show Network routes.
8336 show_ip_ospf_route_network (vty, ospf->new_table); */
8338 /* Show Router routes. */
8339 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
8341 vty_out (vty
, "%s", VTY_NEWLINE
);
8346 DEFUN (show_ip_ospf_border_routers
,
8347 show_ip_ospf_border_routers_cmd
,
8348 "show ip ospf border-routers",
8351 "OSPF information\n"
8352 "Show all the ABR's and ASBR's\n")
8356 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
8359 return show_ip_ospf_border_routers_common(vty
, ospf
);
8362 DEFUN (show_ip_ospf_instance_border_routers
,
8363 show_ip_ospf_instance_border_routers_cmd
,
8364 "show ip ospf (1-65535) border-routers",
8367 "OSPF information\n"
8369 "Show all the ABR's and ASBR's\n")
8373 u_short instance
= 0;
8375 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
8376 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
8379 return show_ip_ospf_border_routers_common(vty
, ospf
);
8383 show_ip_ospf_route_common (struct vty
*vty
, struct ospf
*ospf
)
8386 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
8387 VTY_NEWLINE
, VTY_NEWLINE
);
8389 if (ospf
->new_table
== NULL
)
8391 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
8395 /* Show Network routes. */
8396 show_ip_ospf_route_network (vty
, ospf
->new_table
);
8398 /* Show Router routes. */
8399 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
8401 /* Show AS External routes. */
8402 show_ip_ospf_route_external (vty
, ospf
->old_external_route
);
8404 vty_out (vty
, "%s", VTY_NEWLINE
);
8409 DEFUN (show_ip_ospf_route
,
8410 show_ip_ospf_route_cmd
,
8411 "show ip ospf route",
8414 "OSPF information\n"
8415 "OSPF routing table\n")
8419 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
8422 return show_ip_ospf_route_common(vty
, ospf
);
8425 DEFUN (show_ip_ospf_instance_route
,
8426 show_ip_ospf_instance_route_cmd
,
8427 "show ip ospf (1-65535) route",
8430 "OSPF information\n"
8432 "OSPF routing table\n")
8436 u_short instance
= 0;
8438 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
8439 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
8442 return show_ip_ospf_route_common(vty
, ospf
);
8445 const char *ospf_abr_type_str
[] =
8454 const char *ospf_shortcut_mode_str
[] =
8463 area_id2str (char *buf
, int length
, struct ospf_area
*area
)
8465 memset (buf
, 0, length
);
8467 if (area
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
8468 strncpy (buf
, inet_ntoa (area
->area_id
), length
);
8470 sprintf (buf
, "%lu", (unsigned long) ntohl (area
->area_id
.s_addr
));
8474 const char *ospf_int_type_str
[] =
8476 "unknown", /* should never be used. */
8480 "point-to-multipoint",
8481 "virtual-link", /* should never be used. */
8485 /* Configuration write function for ospfd. */
8487 config_write_interface (struct vty
*vty
)
8489 struct listnode
*n1
, *n2
;
8490 struct interface
*ifp
;
8491 struct crypt_key
*ck
;
8493 struct route_node
*rn
= NULL
;
8494 struct ospf_if_params
*params
;
8495 struct ospf
*ospf
= ospf_lookup();
8497 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), n1
, ifp
))
8499 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
8502 if (ifp
->ifindex
== IFINDEX_DELETED
)
8505 vty_out (vty
, "!%s", VTY_NEWLINE
);
8506 vty_out (vty
, "interface %s%s", ifp
->name
,
8509 vty_out (vty
, " description %s%s", ifp
->desc
,
8514 params
= IF_DEF_PARAMS (ifp
);
8517 /* Interface Network print. */
8518 if (OSPF_IF_PARAM_CONFIGURED (params
, type
) &&
8519 params
->type
!= OSPF_IFTYPE_LOOPBACK
)
8521 if (params
->type
!= ospf_default_iftype(ifp
))
8523 vty_out (vty
, " ip ospf network %s",
8524 ospf_int_type_str
[params
->type
]);
8525 if (params
!= IF_DEF_PARAMS (ifp
))
8526 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8527 vty_out (vty
, "%s", VTY_NEWLINE
);
8531 /* OSPF interface authentication print */
8532 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_type
) &&
8533 params
->auth_type
!= OSPF_AUTH_NOTSET
)
8535 const char *auth_str
;
8537 /* Translation tables are not that much help here due to syntax
8538 of the simple option */
8539 switch (params
->auth_type
)
8542 case OSPF_AUTH_NULL
:
8546 case OSPF_AUTH_SIMPLE
:
8550 case OSPF_AUTH_CRYPTOGRAPHIC
:
8551 auth_str
= " message-digest";
8559 vty_out (vty
, " ip ospf authentication%s", auth_str
);
8560 if (params
!= IF_DEF_PARAMS (ifp
))
8561 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8562 vty_out (vty
, "%s", VTY_NEWLINE
);
8565 /* Simple Authentication Password print. */
8566 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_simple
) &&
8567 params
->auth_simple
[0] != '\0')
8569 vty_out (vty
, " ip ospf authentication-key %s",
8570 params
->auth_simple
);
8571 if (params
!= IF_DEF_PARAMS (ifp
))
8572 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8573 vty_out (vty
, "%s", VTY_NEWLINE
);
8576 /* Cryptographic Authentication Key print. */
8577 for (ALL_LIST_ELEMENTS_RO (params
->auth_crypt
, n2
, ck
))
8579 vty_out (vty
, " ip ospf message-digest-key %d md5 %s",
8580 ck
->key_id
, ck
->auth_key
);
8581 if (params
!= IF_DEF_PARAMS (ifp
))
8582 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8583 vty_out (vty
, "%s", VTY_NEWLINE
);
8586 /* Interface Output Cost print. */
8587 if (OSPF_IF_PARAM_CONFIGURED (params
, output_cost_cmd
))
8589 vty_out (vty
, " ip ospf cost %u", params
->output_cost_cmd
);
8590 if (params
!= IF_DEF_PARAMS (ifp
))
8591 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8592 vty_out (vty
, "%s", VTY_NEWLINE
);
8595 /* Hello Interval print. */
8596 if (OSPF_IF_PARAM_CONFIGURED (params
, v_hello
) &&
8597 params
->v_hello
!= OSPF_HELLO_INTERVAL_DEFAULT
)
8599 vty_out (vty
, " ip ospf hello-interval %u", params
->v_hello
);
8600 if (params
!= IF_DEF_PARAMS (ifp
))
8601 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8602 vty_out (vty
, "%s", VTY_NEWLINE
);
8606 /* Router Dead Interval print. */
8607 if (OSPF_IF_PARAM_CONFIGURED (params
, v_wait
) &&
8608 params
->v_wait
!= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
)
8610 vty_out (vty
, " ip ospf dead-interval ");
8613 if (OSPF_IF_PARAM_CONFIGURED (params
, fast_hello
))
8614 vty_out (vty
, "minimal hello-multiplier %d",
8615 params
->fast_hello
);
8617 vty_out (vty
, "%u", params
->v_wait
);
8619 if (params
!= IF_DEF_PARAMS (ifp
))
8620 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8621 vty_out (vty
, "%s", VTY_NEWLINE
);
8624 /* Router Priority print. */
8625 if (OSPF_IF_PARAM_CONFIGURED (params
, priority
) &&
8626 params
->priority
!= OSPF_ROUTER_PRIORITY_DEFAULT
)
8628 vty_out (vty
, " ip ospf priority %u", params
->priority
);
8629 if (params
!= IF_DEF_PARAMS (ifp
))
8630 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8631 vty_out (vty
, "%s", VTY_NEWLINE
);
8634 /* Retransmit Interval print. */
8635 if (OSPF_IF_PARAM_CONFIGURED (params
, retransmit_interval
) &&
8636 params
->retransmit_interval
!= OSPF_RETRANSMIT_INTERVAL_DEFAULT
)
8638 vty_out (vty
, " ip ospf retransmit-interval %u",
8639 params
->retransmit_interval
);
8640 if (params
!= IF_DEF_PARAMS (ifp
))
8641 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8642 vty_out (vty
, "%s", VTY_NEWLINE
);
8645 /* Transmit Delay print. */
8646 if (OSPF_IF_PARAM_CONFIGURED (params
, transmit_delay
) &&
8647 params
->transmit_delay
!= OSPF_TRANSMIT_DELAY_DEFAULT
)
8649 vty_out (vty
, " ip ospf transmit-delay %u", params
->transmit_delay
);
8650 if (params
!= IF_DEF_PARAMS (ifp
))
8651 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8652 vty_out (vty
, "%s", VTY_NEWLINE
);
8656 if (OSPF_IF_PARAM_CONFIGURED (params
, if_area
))
8659 vty_out (vty
, " ip ospf %d area %s%s", ospf
->instance
,
8660 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
8662 vty_out (vty
, " ip ospf area %s%s",
8663 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
8668 ospf_bfd_write_config(vty
, params
);
8670 /* MTU ignore print. */
8671 if (OSPF_IF_PARAM_CONFIGURED (params
, mtu_ignore
) &&
8672 params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
8674 if (params
->mtu_ignore
== 0)
8675 vty_out (vty
, " no ip ospf mtu-ignore");
8677 vty_out (vty
, " ip ospf mtu-ignore");
8678 if (params
!= IF_DEF_PARAMS (ifp
))
8679 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8680 vty_out (vty
, "%s", VTY_NEWLINE
);
8687 rn
= route_top (IF_OIFS_PARAMS (ifp
));
8689 rn
= route_next (rn
);
8699 ospf_opaque_config_write_if (vty
, ifp
);
8706 config_write_network_area (struct vty
*vty
, struct ospf
*ospf
)
8708 struct route_node
*rn
;
8709 u_char buf
[INET_ADDRSTRLEN
];
8711 /* `network area' print. */
8712 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
8715 struct ospf_network
*n
= rn
->info
;
8717 memset (buf
, 0, INET_ADDRSTRLEN
);
8719 /* Create Area ID string by specified Area ID format. */
8720 if (n
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
8721 strncpy ((char *) buf
, inet_ntoa (n
->area_id
), INET_ADDRSTRLEN
);
8723 sprintf ((char *) buf
, "%lu",
8724 (unsigned long int) ntohl (n
->area_id
.s_addr
));
8726 /* Network print. */
8727 vty_out (vty
, " network %s/%d area %s%s",
8728 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
8736 config_write_ospf_area (struct vty
*vty
, struct ospf
*ospf
)
8738 struct listnode
*node
;
8739 struct ospf_area
*area
;
8740 u_char buf
[INET_ADDRSTRLEN
];
8742 /* Area configuration print. */
8743 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
8745 struct route_node
*rn1
;
8747 area_id2str ((char *) buf
, INET_ADDRSTRLEN
, area
);
8749 if (area
->auth_type
!= OSPF_AUTH_NULL
)
8751 if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
8752 vty_out (vty
, " area %s authentication%s", buf
, VTY_NEWLINE
);
8754 vty_out (vty
, " area %s authentication message-digest%s",
8758 if (area
->shortcut_configured
!= OSPF_SHORTCUT_DEFAULT
)
8759 vty_out (vty
, " area %s shortcut %s%s", buf
,
8760 ospf_shortcut_mode_str
[area
->shortcut_configured
],
8763 if ((area
->external_routing
== OSPF_AREA_STUB
)
8764 || (area
->external_routing
== OSPF_AREA_NSSA
)
8767 if (area
->external_routing
== OSPF_AREA_STUB
)
8768 vty_out (vty
, " area %s stub", buf
);
8769 else if (area
->external_routing
== OSPF_AREA_NSSA
)
8771 vty_out (vty
, " area %s nssa", buf
);
8772 switch (area
->NSSATranslatorRole
)
8774 case OSPF_NSSA_ROLE_NEVER
:
8775 vty_out (vty
, " translate-never");
8777 case OSPF_NSSA_ROLE_ALWAYS
:
8778 vty_out (vty
, " translate-always");
8780 case OSPF_NSSA_ROLE_CANDIDATE
:
8782 vty_out (vty
, " translate-candidate");
8786 if (area
->no_summary
)
8787 vty_out (vty
, " no-summary");
8789 vty_out (vty
, "%s", VTY_NEWLINE
);
8791 if (area
->default_cost
!= 1)
8792 vty_out (vty
, " area %s default-cost %d%s", buf
,
8793 area
->default_cost
, VTY_NEWLINE
);
8796 for (rn1
= route_top (area
->ranges
); rn1
; rn1
= route_next (rn1
))
8799 struct ospf_area_range
*range
= rn1
->info
;
8801 vty_out (vty
, " area %s range %s/%d", buf
,
8802 inet_ntoa (rn1
->p
.u
.prefix4
), rn1
->p
.prefixlen
);
8804 if (range
->cost_config
!= OSPF_AREA_RANGE_COST_UNSPEC
)
8805 vty_out (vty
, " cost %d", range
->cost_config
);
8807 if (!CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_ADVERTISE
))
8808 vty_out (vty
, " not-advertise");
8810 if (CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_SUBSTITUTE
))
8811 vty_out (vty
, " substitute %s/%d",
8812 inet_ntoa (range
->subst_addr
), range
->subst_masklen
);
8814 vty_out (vty
, "%s", VTY_NEWLINE
);
8817 if (EXPORT_NAME (area
))
8818 vty_out (vty
, " area %s export-list %s%s", buf
,
8819 EXPORT_NAME (area
), VTY_NEWLINE
);
8821 if (IMPORT_NAME (area
))
8822 vty_out (vty
, " area %s import-list %s%s", buf
,
8823 IMPORT_NAME (area
), VTY_NEWLINE
);
8825 if (PREFIX_NAME_IN (area
))
8826 vty_out (vty
, " area %s filter-list prefix %s in%s", buf
,
8827 PREFIX_NAME_IN (area
), VTY_NEWLINE
);
8829 if (PREFIX_NAME_OUT (area
))
8830 vty_out (vty
, " area %s filter-list prefix %s out%s", buf
,
8831 PREFIX_NAME_OUT (area
), VTY_NEWLINE
);
8838 config_write_ospf_nbr_nbma (struct vty
*vty
, struct ospf
*ospf
)
8840 struct ospf_nbr_nbma
*nbr_nbma
;
8841 struct route_node
*rn
;
8843 /* Static Neighbor configuration print. */
8844 for (rn
= route_top (ospf
->nbr_nbma
); rn
; rn
= route_next (rn
))
8845 if ((nbr_nbma
= rn
->info
))
8847 vty_out (vty
, " neighbor %s", inet_ntoa (nbr_nbma
->addr
));
8849 if (nbr_nbma
->priority
!= OSPF_NEIGHBOR_PRIORITY_DEFAULT
)
8850 vty_out (vty
, " priority %d", nbr_nbma
->priority
);
8852 if (nbr_nbma
->v_poll
!= OSPF_POLL_INTERVAL_DEFAULT
)
8853 vty_out (vty
, " poll-interval %d", nbr_nbma
->v_poll
);
8855 vty_out (vty
, "%s", VTY_NEWLINE
);
8862 config_write_virtual_link (struct vty
*vty
, struct ospf
*ospf
)
8864 struct listnode
*node
;
8865 struct ospf_vl_data
*vl_data
;
8866 u_char buf
[INET_ADDRSTRLEN
];
8868 /* Virtual-Link print */
8869 for (ALL_LIST_ELEMENTS_RO (ospf
->vlinks
, node
, vl_data
))
8871 struct listnode
*n2
;
8872 struct crypt_key
*ck
;
8873 struct ospf_interface
*oi
;
8875 if (vl_data
!= NULL
)
8877 memset (buf
, 0, INET_ADDRSTRLEN
);
8879 if (vl_data
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
8880 strncpy ((char *) buf
, inet_ntoa (vl_data
->vl_area_id
), INET_ADDRSTRLEN
);
8882 sprintf ((char *) buf
, "%lu",
8883 (unsigned long int) ntohl (vl_data
->vl_area_id
.s_addr
));
8884 oi
= vl_data
->vl_oi
;
8887 if (OSPF_IF_PARAM (oi
, v_hello
) != OSPF_HELLO_INTERVAL_DEFAULT
||
8888 OSPF_IF_PARAM (oi
, v_wait
) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
||
8889 OSPF_IF_PARAM (oi
, retransmit_interval
) != OSPF_RETRANSMIT_INTERVAL_DEFAULT
||
8890 OSPF_IF_PARAM (oi
, transmit_delay
) != OSPF_TRANSMIT_DELAY_DEFAULT
)
8891 vty_out (vty
, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
8893 inet_ntoa (vl_data
->vl_peer
),
8894 OSPF_IF_PARAM (oi
, v_hello
),
8895 OSPF_IF_PARAM (oi
, retransmit_interval
),
8896 OSPF_IF_PARAM (oi
, transmit_delay
),
8897 OSPF_IF_PARAM (oi
, v_wait
),
8900 vty_out (vty
, " area %s virtual-link %s%s", buf
,
8901 inet_ntoa (vl_data
->vl_peer
), VTY_NEWLINE
);
8903 if (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
[0] != '\0')
8904 vty_out (vty
, " area %s virtual-link %s authentication-key %s%s",
8906 inet_ntoa (vl_data
->vl_peer
),
8907 IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
,
8910 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_crypt
,
8912 vty_out (vty
, " area %s virtual-link %s"
8913 " message-digest-key %d md5 %s%s",
8915 inet_ntoa (vl_data
->vl_peer
),
8916 ck
->key_id
, ck
->auth_key
, VTY_NEWLINE
);
8926 config_write_ospf_redistribute (struct vty
*vty
, struct ospf
*ospf
)
8930 /* redistribute print. */
8931 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
8933 struct list
*red_list
;
8934 struct listnode
*node
;
8935 struct ospf_redist
*red
;
8937 red_list
= ospf
->redist
[type
];
8941 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
))
8943 vty_out (vty
, " redistribute %s", zebra_route_string(type
));
8945 vty_out (vty
, " %d", red
->instance
);
8947 if (red
->dmetric
.value
>= 0)
8948 vty_out (vty
, " metric %d", red
->dmetric
.value
);
8950 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
8951 vty_out (vty
, " metric-type 1");
8953 if (ROUTEMAP_NAME (red
))
8954 vty_out (vty
, " route-map %s", ROUTEMAP_NAME (red
));
8956 vty_out (vty
, "%s", VTY_NEWLINE
);
8964 config_write_ospf_default_metric (struct vty
*vty
, struct ospf
*ospf
)
8966 if (ospf
->default_metric
!= -1)
8967 vty_out (vty
, " default-metric %d%s", ospf
->default_metric
,
8973 config_write_ospf_distribute (struct vty
*vty
, struct ospf
*ospf
)
8976 struct ospf_redist
*red
;
8980 /* distribute-list print. */
8981 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
8982 if (DISTRIBUTE_NAME (ospf
, type
))
8983 vty_out (vty
, " distribute-list %s out %s%s",
8984 DISTRIBUTE_NAME (ospf
, type
),
8985 zebra_route_string(type
), VTY_NEWLINE
);
8987 /* default-information print. */
8988 if (ospf
->default_originate
!= DEFAULT_ORIGINATE_NONE
)
8990 vty_out (vty
, " default-information originate");
8991 if (ospf
->default_originate
== DEFAULT_ORIGINATE_ALWAYS
)
8992 vty_out (vty
, " always");
8994 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
8997 if (red
->dmetric
.value
>= 0)
8998 vty_out (vty
, " metric %d",
8999 red
->dmetric
.value
);
9000 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
9001 vty_out (vty
, " metric-type 1");
9003 if (ROUTEMAP_NAME (red
))
9004 vty_out (vty
, " route-map %s",
9005 ROUTEMAP_NAME (red
));
9008 vty_out (vty
, "%s", VTY_NEWLINE
);
9017 config_write_ospf_distance (struct vty
*vty
, struct ospf
*ospf
)
9019 struct route_node
*rn
;
9020 struct ospf_distance
*odistance
;
9022 if (ospf
->distance_all
)
9023 vty_out (vty
, " distance %d%s", ospf
->distance_all
, VTY_NEWLINE
);
9025 if (ospf
->distance_intra
9026 || ospf
->distance_inter
9027 || ospf
->distance_external
)
9029 vty_out (vty
, " distance ospf");
9031 if (ospf
->distance_intra
)
9032 vty_out (vty
, " intra-area %d", ospf
->distance_intra
);
9033 if (ospf
->distance_inter
)
9034 vty_out (vty
, " inter-area %d", ospf
->distance_inter
);
9035 if (ospf
->distance_external
)
9036 vty_out (vty
, " external %d", ospf
->distance_external
);
9038 vty_out (vty
, "%s", VTY_NEWLINE
);
9041 for (rn
= route_top (ospf
->distance_table
); rn
; rn
= route_next (rn
))
9042 if ((odistance
= rn
->info
) != NULL
)
9044 vty_out (vty
, " distance %d %s/%d %s%s", odistance
->distance
,
9045 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
9046 odistance
->access_list
? odistance
->access_list
: "",
9052 /* OSPF configuration write function. */
9054 ospf_config_write (struct vty
*vty
)
9057 struct interface
*ifp
;
9058 struct ospf_interface
*oi
;
9059 struct listnode
*node
;
9062 ospf
= ospf_lookup ();
9063 if (ospf
!= NULL
&& ospf
->oi_running
)
9065 /* `router ospf' print. */
9067 vty_out (vty
, "router ospf %d%s", ospf
->instance
, VTY_NEWLINE
);
9069 vty_out (vty
, "router ospf%s", VTY_NEWLINE
);
9073 if (!ospf
->networks
)
9076 /* Router ID print. */
9077 if (ospf
->router_id_static
.s_addr
!= 0)
9078 vty_out (vty
, " ospf router-id %s%s",
9079 inet_ntoa (ospf
->router_id_static
), VTY_NEWLINE
);
9081 /* ABR type print. */
9082 if (ospf
->abr_type
!= OSPF_ABR_DEFAULT
)
9083 vty_out (vty
, " ospf abr-type %s%s",
9084 ospf_abr_type_str
[ospf
->abr_type
], VTY_NEWLINE
);
9086 /* log-adjacency-changes flag print. */
9087 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
))
9089 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
9090 vty_out(vty
, " log-adjacency-changes detail%s", VTY_NEWLINE
);
9094 vty_out(vty
, " no log-adjacency-changes%s", VTY_NEWLINE
);
9097 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
9098 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
9099 vty_out (vty
, " compatible rfc1583%s", VTY_NEWLINE
);
9101 /* auto-cost reference-bandwidth configuration. */
9102 if (ospf
->ref_bandwidth
!= OSPF_DEFAULT_REF_BANDWIDTH
)
9104 vty_out (vty
, "! Important: ensure reference bandwidth "
9105 "is consistent across all routers%s", VTY_NEWLINE
);
9106 vty_out (vty
, " auto-cost reference-bandwidth %d%s",
9107 ospf
->ref_bandwidth
, VTY_NEWLINE
);
9110 /* SPF timers print. */
9111 if (ospf
->spf_delay
!= OSPF_SPF_DELAY_DEFAULT
||
9112 ospf
->spf_holdtime
!= OSPF_SPF_HOLDTIME_DEFAULT
||
9113 ospf
->spf_max_holdtime
!= OSPF_SPF_MAX_HOLDTIME_DEFAULT
)
9114 vty_out (vty
, " timers throttle spf %d %d %d%s",
9115 ospf
->spf_delay
, ospf
->spf_holdtime
,
9116 ospf
->spf_max_holdtime
, VTY_NEWLINE
);
9118 /* LSA timers print. */
9119 if (ospf
->min_ls_interval
!= OSPF_MIN_LS_INTERVAL
)
9120 vty_out (vty
, " timers throttle lsa all %d%s",
9121 ospf
->min_ls_interval
, VTY_NEWLINE
);
9122 if (ospf
->min_ls_arrival
!= OSPF_MIN_LS_ARRIVAL
)
9123 vty_out (vty
, " timers lsa min-arrival %d%s",
9124 ospf
->min_ls_arrival
, VTY_NEWLINE
);
9126 /* Write multiplier print. */
9127 if (ospf
->write_oi_count
!= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
)
9128 vty_out (vty
, " ospf write-multiplier %d%s",
9129 ospf
->write_oi_count
, VTY_NEWLINE
);
9131 /* Max-metric router-lsa print */
9132 config_write_stub_router (vty
, ospf
);
9134 /* SPF refresh parameters print. */
9135 if (ospf
->lsa_refresh_interval
!= OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
9136 vty_out (vty
, " refresh timer %d%s",
9137 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
9139 /* Redistribute information print. */
9140 config_write_ospf_redistribute (vty
, ospf
);
9142 /* passive-interface print. */
9143 if (ospf
->passive_interface_default
== OSPF_IF_PASSIVE
)
9144 vty_out (vty
, " passive-interface default%s", VTY_NEWLINE
);
9146 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, node
, ifp
))
9147 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
)
9148 && IF_DEF_PARAMS (ifp
)->passive_interface
!=
9149 ospf
->passive_interface_default
)
9151 vty_out (vty
, " %spassive-interface %s%s",
9152 IF_DEF_PARAMS (ifp
)->passive_interface
? "" : "no ",
9153 ifp
->name
, VTY_NEWLINE
);
9155 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
9157 if (!OSPF_IF_PARAM_CONFIGURED (oi
->params
, passive_interface
))
9159 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi
->ifp
),
9162 if (oi
->params
->passive_interface
== IF_DEF_PARAMS (oi
->ifp
)->passive_interface
)
9165 else if (oi
->params
->passive_interface
== ospf
->passive_interface_default
)
9168 vty_out (vty
, " %spassive-interface %s %s%s",
9169 oi
->params
->passive_interface
? "" : "no ",
9171 inet_ntoa (oi
->address
->u
.prefix4
), VTY_NEWLINE
);
9174 /* Network area print. */
9175 config_write_network_area (vty
, ospf
);
9177 /* Area config print. */
9178 config_write_ospf_area (vty
, ospf
);
9180 /* static neighbor print. */
9181 config_write_ospf_nbr_nbma (vty
, ospf
);
9183 /* Virtual-Link print. */
9184 config_write_virtual_link (vty
, ospf
);
9186 /* Default metric configuration. */
9187 config_write_ospf_default_metric (vty
, ospf
);
9189 /* Distribute-list and default-information print. */
9190 config_write_ospf_distribute (vty
, ospf
);
9192 /* Distance configuration. */
9193 config_write_ospf_distance (vty
, ospf
);
9195 ospf_opaque_config_write_router (vty
, ospf
);
9202 ospf_vty_show_init (void)
9204 /* "show ip ospf" commands. */
9205 install_element (VIEW_NODE
, &show_ip_ospf_cmd
);
9207 install_element (VIEW_NODE
, &show_ip_ospf_instance_cmd
);
9209 /* "show ip ospf database" commands. */
9210 install_element (VIEW_NODE
, &show_ip_ospf_database_type_adv_router_cmd
);
9211 install_element (VIEW_NODE
, &show_ip_ospf_database_max_cmd
);
9213 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_adv_router_cmd
);
9214 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_cmd
);
9215 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_max_cmd
);
9217 /* "show ip ospf interface" commands. */
9218 install_element (VIEW_NODE
, &show_ip_ospf_interface_cmd
);
9220 install_element (VIEW_NODE
, &show_ip_ospf_instance_interface_cmd
);
9222 /* "show ip ospf neighbor" commands. */
9223 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_detail_cmd
);
9224 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_cmd
);
9225 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_id_cmd
);
9226 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_all_cmd
);
9227 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_cmd
);
9228 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_cmd
);
9229 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_all_cmd
);
9231 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_detail_cmd
);
9232 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_cmd
);
9233 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_id_cmd
);
9234 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_all_cmd
);
9235 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_cmd
);
9236 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_cmd
);
9237 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_all_cmd
);
9239 /* "show ip ospf route" commands. */
9240 install_element (VIEW_NODE
, &show_ip_ospf_route_cmd
);
9241 install_element (VIEW_NODE
, &show_ip_ospf_border_routers_cmd
);
9243 install_element (VIEW_NODE
, &show_ip_ospf_instance_route_cmd
);
9244 install_element (VIEW_NODE
, &show_ip_ospf_instance_border_routers_cmd
);
9248 /* ospfd's interface node. */
9249 static struct cmd_node interface_node
=
9256 /* Initialization of OSPF interface. */
9258 ospf_vty_if_init (void)
9260 /* Install interface node. */
9261 install_node (&interface_node
, config_write_interface
);
9264 /* "ip ospf authentication" commands. */
9265 install_element (INTERFACE_NODE
, &ip_ospf_authentication_args_addr_cmd
);
9266 install_element (INTERFACE_NODE
, &ip_ospf_authentication_addr_cmd
);
9267 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_args_addr_cmd
);
9268 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_addr_cmd
);
9269 install_element (INTERFACE_NODE
, &ip_ospf_authentication_key_addr_cmd
);
9270 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_key_authkey_addr_cmd
);
9271 install_element (INTERFACE_NODE
, &no_ospf_authentication_key_authkey_addr_cmd
);
9273 /* "ip ospf message-digest-key" commands. */
9274 install_element (INTERFACE_NODE
, &ip_ospf_message_digest_key_cmd
);
9275 install_element (INTERFACE_NODE
, &no_ip_ospf_message_digest_key_cmd
);
9277 /* "ip ospf cost" commands. */
9278 install_element (INTERFACE_NODE
, &ip_ospf_cost_cmd
);
9279 install_element (INTERFACE_NODE
, &no_ip_ospf_cost_cmd
);
9281 /* "ip ospf mtu-ignore" commands. */
9282 install_element (INTERFACE_NODE
, &ip_ospf_mtu_ignore_addr_cmd
);
9283 install_element (INTERFACE_NODE
, &no_ip_ospf_mtu_ignore_addr_cmd
);
9285 /* "ip ospf dead-interval" commands. */
9286 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_cmd
);
9287 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_minimal_addr_cmd
);
9288 install_element (INTERFACE_NODE
, &no_ip_ospf_dead_interval_cmd
);
9290 /* "ip ospf hello-interval" commands. */
9291 install_element (INTERFACE_NODE
, &ip_ospf_hello_interval_cmd
);
9292 install_element (INTERFACE_NODE
, &no_ip_ospf_hello_interval_cmd
);
9294 /* "ip ospf network" commands. */
9295 install_element (INTERFACE_NODE
, &ip_ospf_network_cmd
);
9296 install_element (INTERFACE_NODE
, &no_ip_ospf_network_cmd
);
9298 /* "ip ospf priority" commands. */
9299 install_element (INTERFACE_NODE
, &ip_ospf_priority_cmd
);
9300 install_element (INTERFACE_NODE
, &no_ip_ospf_priority_cmd
);
9302 /* "ip ospf retransmit-interval" commands. */
9303 install_element (INTERFACE_NODE
, &ip_ospf_retransmit_interval_addr_cmd
);
9304 install_element (INTERFACE_NODE
, &no_ip_ospf_retransmit_interval_addr_cmd
);
9306 /* "ip ospf transmit-delay" commands. */
9307 install_element (INTERFACE_NODE
, &ip_ospf_transmit_delay_addr_cmd
);
9308 install_element (INTERFACE_NODE
, &no_ip_ospf_transmit_delay_addr_cmd
);
9310 /* "ip ospf area" commands. */
9311 install_element (INTERFACE_NODE
, &ip_ospf_area_cmd
);
9312 install_element (INTERFACE_NODE
, &no_ip_ospf_area_cmd
);
9314 /* These commands are compatibitliy for previous version. */
9315 install_element (INTERFACE_NODE
, &ospf_authentication_key_cmd
);
9316 install_element (INTERFACE_NODE
, &ospf_message_digest_key_cmd
);
9317 install_element (INTERFACE_NODE
, &no_ospf_message_digest_key_cmd
);
9318 install_element (INTERFACE_NODE
, &ospf_dead_interval_cmd
);
9319 install_element (INTERFACE_NODE
, &no_ospf_dead_interval_cmd
);
9320 install_element (INTERFACE_NODE
, &ospf_hello_interval_cmd
);
9321 install_element (INTERFACE_NODE
, &no_ospf_hello_interval_cmd
);
9322 install_element (INTERFACE_NODE
, &ospf_cost_cmd
);
9323 install_element (INTERFACE_NODE
, &no_ospf_cost_cmd
);
9324 install_element (INTERFACE_NODE
, &ospf_network_cmd
);
9325 install_element (INTERFACE_NODE
, &no_ospf_network_cmd
);
9326 install_element (INTERFACE_NODE
, &ospf_priority_cmd
);
9327 install_element (INTERFACE_NODE
, &no_ospf_priority_cmd
);
9328 install_element (INTERFACE_NODE
, &ospf_retransmit_interval_cmd
);
9329 install_element (INTERFACE_NODE
, &no_ospf_retransmit_interval_cmd
);
9330 install_element (INTERFACE_NODE
, &ospf_transmit_delay_cmd
);
9331 install_element (INTERFACE_NODE
, &no_ospf_transmit_delay_cmd
);
9335 ospf_vty_zebra_init (void)
9337 install_element (OSPF_NODE
, &ospf_redistribute_source_cmd
);
9338 install_element (OSPF_NODE
, &no_ospf_redistribute_source_cmd
);
9339 install_element (OSPF_NODE
, &ospf_redistribute_instance_source_cmd
);
9340 install_element (OSPF_NODE
, &no_ospf_redistribute_instance_source_cmd
);
9342 install_element (OSPF_NODE
, &ospf_distribute_list_out_cmd
);
9343 install_element (OSPF_NODE
, &no_ospf_distribute_list_out_cmd
);
9345 install_element (OSPF_NODE
, &ospf_default_information_originate_cmd
);
9346 install_element (OSPF_NODE
, &no_ospf_default_information_originate_cmd
);
9348 install_element (OSPF_NODE
, &ospf_default_metric_cmd
);
9349 install_element (OSPF_NODE
, &no_ospf_default_metric_cmd
);
9351 install_element (OSPF_NODE
, &ospf_distance_cmd
);
9352 install_element (OSPF_NODE
, &no_ospf_distance_cmd
);
9353 install_element (OSPF_NODE
, &no_ospf_distance_ospf_cmd
);
9354 install_element (OSPF_NODE
, &ospf_distance_ospf_cmd
);
9356 install_element (OSPF_NODE
, &ospf_distance_source_cmd
);
9357 install_element (OSPF_NODE
, &no_ospf_distance_source_cmd
);
9358 install_element (OSPF_NODE
, &ospf_distance_source_access_list_cmd
);
9359 install_element (OSPF_NODE
, &no_ospf_distance_source_access_list_cmd
);
9363 static struct cmd_node ospf_node
=
9366 "%s(config-router)# ",
9371 ospf_interface_clear (struct interface
*ifp
)
9373 if (!if_is_operative (ifp
)) return;
9375 if (IS_DEBUG_OSPF (ism
, ISM_EVENTS
))
9376 zlog (NULL
, LOG_DEBUG
, "ISM[%s]: clear by reset", ifp
->name
);
9381 DEFUN (clear_ip_ospf_interface
,
9382 clear_ip_ospf_interface_cmd
,
9383 "clear ip ospf interface [IFNAME]",
9386 "OSPF information\n"
9387 "Interface information\n"
9391 struct interface
*ifp
;
9392 struct listnode
*node
;
9394 if (argc
== 4) /* Clear all the ospfv2 interfaces. */
9396 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
9397 ospf_interface_clear(ifp
);
9399 else /* Interface name is specified. */
9401 if ((ifp
= if_lookup_by_name (argv
[idx_ifname
]->text
)) == NULL
)
9402 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
9404 ospf_interface_clear(ifp
);
9411 ospf_vty_clear_init (void)
9413 install_element (ENABLE_NODE
, &clear_ip_ospf_interface_cmd
);
9417 /* Install OSPF related vty commands. */
9419 ospf_vty_init (void)
9421 /* Install ospf top node. */
9422 install_node (&ospf_node
, ospf_config_write
);
9424 /* "router ospf" commands. */
9425 install_element (CONFIG_NODE
, &router_ospf_cmd
);
9426 install_element (CONFIG_NODE
, &no_router_ospf_cmd
);
9429 install_default (OSPF_NODE
);
9431 /* "ospf router-id" commands. */
9432 install_element (OSPF_NODE
, &ospf_router_id_cmd
);
9433 install_element (OSPF_NODE
, &ospf_router_id_old_cmd
);
9434 install_element (OSPF_NODE
, &no_ospf_router_id_cmd
);
9436 /* "passive-interface" commands. */
9437 install_element (OSPF_NODE
, &ospf_passive_interface_addr_cmd
);
9438 install_element (OSPF_NODE
, &no_ospf_passive_interface_addr_cmd
);
9440 /* "ospf abr-type" commands. */
9441 install_element (OSPF_NODE
, &ospf_abr_type_cmd
);
9442 install_element (OSPF_NODE
, &no_ospf_abr_type_cmd
);
9444 /* "ospf log-adjacency-changes" commands. */
9445 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_cmd
);
9446 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_detail_cmd
);
9447 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_cmd
);
9448 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_detail_cmd
);
9450 /* "ospf rfc1583-compatible" commands. */
9451 install_element (OSPF_NODE
, &ospf_compatible_rfc1583_cmd
);
9452 install_element (OSPF_NODE
, &no_ospf_compatible_rfc1583_cmd
);
9453 install_element (OSPF_NODE
, &ospf_rfc1583_flag_cmd
);
9454 install_element (OSPF_NODE
, &no_ospf_rfc1583_flag_cmd
);
9456 /* "network area" commands. */
9457 install_element (OSPF_NODE
, &ospf_network_area_cmd
);
9458 install_element (OSPF_NODE
, &no_ospf_network_area_cmd
);
9460 /* "area authentication" commands. */
9461 install_element (OSPF_NODE
, &ospf_area_authentication_message_digest_cmd
);
9462 install_element (OSPF_NODE
, &ospf_area_authentication_cmd
);
9463 install_element (OSPF_NODE
, &no_ospf_area_authentication_cmd
);
9465 /* "area range" commands. */
9466 install_element (OSPF_NODE
, &ospf_area_range_cmd
);
9467 install_element (OSPF_NODE
, &ospf_area_range_cost_cmd
);
9468 install_element (OSPF_NODE
, &ospf_area_range_not_advertise_cmd
);
9469 install_element (OSPF_NODE
, &no_ospf_area_range_cmd
);
9470 install_element (OSPF_NODE
, &ospf_area_range_substitute_cmd
);
9471 install_element (OSPF_NODE
, &no_ospf_area_range_substitute_cmd
);
9473 /* "area virtual-link" commands. */
9474 install_element (OSPF_NODE
, &ospf_area_vlink_cmd
);
9475 install_element (OSPF_NODE
, &ospf_area_vlink_intervals_cmd
);
9476 install_element (OSPF_NODE
, &no_ospf_area_vlink_cmd
);
9477 install_element (OSPF_NODE
, &no_ospf_area_vlink_intervals_cmd
);
9488 /* "area stub" commands. */
9489 install_element (OSPF_NODE
, &ospf_area_stub_no_summary_cmd
);
9490 install_element (OSPF_NODE
, &ospf_area_stub_cmd
);
9491 install_element (OSPF_NODE
, &no_ospf_area_stub_no_summary_cmd
);
9492 install_element (OSPF_NODE
, &no_ospf_area_stub_cmd
);
9494 /* "area nssa" commands. */
9495 install_element (OSPF_NODE
, &ospf_area_nssa_cmd
);
9496 install_element (OSPF_NODE
, &ospf_area_nssa_translate_no_summary_cmd
);
9497 install_element (OSPF_NODE
, &ospf_area_nssa_translate_cmd
);
9498 install_element (OSPF_NODE
, &ospf_area_nssa_no_summary_cmd
);
9499 install_element (OSPF_NODE
, &no_ospf_area_nssa_cmd
);
9501 install_element (OSPF_NODE
, &ospf_area_default_cost_cmd
);
9502 install_element (OSPF_NODE
, &no_ospf_area_default_cost_cmd
);
9504 install_element (OSPF_NODE
, &ospf_area_shortcut_cmd
);
9505 install_element (OSPF_NODE
, &no_ospf_area_shortcut_cmd
);
9507 install_element (OSPF_NODE
, &ospf_area_export_list_cmd
);
9508 install_element (OSPF_NODE
, &no_ospf_area_export_list_cmd
);
9510 install_element (OSPF_NODE
, &ospf_area_filter_list_cmd
);
9511 install_element (OSPF_NODE
, &no_ospf_area_filter_list_cmd
);
9513 install_element (OSPF_NODE
, &ospf_area_import_list_cmd
);
9514 install_element (OSPF_NODE
, &no_ospf_area_import_list_cmd
);
9516 /* SPF timer commands */
9517 install_element (OSPF_NODE
, &ospf_timers_throttle_spf_cmd
);
9518 install_element (OSPF_NODE
, &no_ospf_timers_throttle_spf_cmd
);
9520 /* LSA timers commands */
9521 install_element (OSPF_NODE
, &ospf_timers_min_ls_interval_cmd
);
9522 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_interval_cmd
);
9523 install_element (OSPF_NODE
, &ospf_timers_min_ls_arrival_cmd
);
9524 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_arrival_cmd
);
9525 install_element (OSPF_NODE
, &ospf_timers_lsa_cmd
);
9526 install_element (OSPF_NODE
, &no_ospf_timers_lsa_cmd
);
9528 /* refresh timer commands */
9529 install_element (OSPF_NODE
, &ospf_refresh_timer_cmd
);
9530 install_element (OSPF_NODE
, &no_ospf_refresh_timer_val_cmd
);
9532 /* max-metric commands */
9533 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_admin_cmd
);
9534 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_admin_cmd
);
9535 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_startup_cmd
);
9536 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_startup_cmd
);
9537 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_shutdown_cmd
);
9538 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_shutdown_cmd
);
9540 /* reference bandwidth commands */
9541 install_element (OSPF_NODE
, &ospf_auto_cost_reference_bandwidth_cmd
);
9542 install_element (OSPF_NODE
, &no_ospf_auto_cost_reference_bandwidth_cmd
);
9544 /* "neighbor" commands. */
9545 install_element (OSPF_NODE
, &ospf_neighbor_cmd
);
9546 install_element (OSPF_NODE
, &ospf_neighbor_poll_interval_cmd
);
9547 install_element (OSPF_NODE
, &no_ospf_neighbor_cmd
);
9548 install_element (OSPF_NODE
, &no_ospf_neighbor_poll_cmd
);
9550 /* write multiplier commands */
9551 install_element (OSPF_NODE
, &ospf_write_multiplier_cmd
);
9552 install_element (OSPF_NODE
, &write_multiplier_cmd
);
9553 install_element (OSPF_NODE
, &no_ospf_write_multiplier_cmd
);
9554 install_element (OSPF_NODE
, &no_write_multiplier_cmd
);
9556 /* Init interface related vty commands. */
9557 ospf_vty_if_init ();
9559 /* Init zebra related vty commands. */
9560 ospf_vty_zebra_init ();