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
;
3109 json
= json_object_new_object();
3110 json_areas
= json_object_new_object();
3116 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3120 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3121 VTY_NEWLINE
, VTY_NEWLINE
);
3125 /* Show Router ID. */
3128 json_object_string_add(json
, "routerId", inet_ntoa (ospf
->router_id
));
3132 vty_out (vty
, " OSPF Routing Process, Router ID: %s%s",
3133 inet_ntoa (ospf
->router_id
),
3137 /* Graceful shutdown */
3138 if (ospf
->t_deferred_shutdown
)
3142 unsigned long time_store
= 0;
3143 result
= tv_sub (ospf
->t_deferred_shutdown
->u
.sands
, recent_relative_time());
3144 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3145 json_object_int_add(json
, "deferredShutdownMsecs", time_store
);
3149 vty_out (vty
, " Deferred shutdown in progress, %s remaining%s",
3150 ospf_timer_dump (ospf
->t_deferred_shutdown
,
3151 timebuf
, sizeof (timebuf
)), VTY_NEWLINE
);
3155 /* Show capability. */
3158 json_object_boolean_true_add(json
, "tosRoutesOnly");
3159 json_object_boolean_true_add(json
, "rfc2328Conform");
3160 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
3162 json_object_boolean_true_add(json
, "rfc1583Compatibility");
3167 vty_out (vty
, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE
);
3168 vty_out (vty
, " This implementation conforms to RFC2328%s", VTY_NEWLINE
);
3169 vty_out (vty
, " RFC1583Compatibility flag is %s%s",
3170 CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
) ?
3171 "enabled" : "disabled", VTY_NEWLINE
);
3176 if (CHECK_FLAG (ospf
->config
, OSPF_OPAQUE_CAPABLE
))
3178 json_object_boolean_true_add(json
, "opaqueCapable");
3183 vty_out (vty
, " OpaqueCapability flag is %s%s",
3184 CHECK_FLAG (ospf
->config
, OSPF_OPAQUE_CAPABLE
) ? "enabled" : "disabled",
3188 /* Show stub-router configuration */
3189 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
3190 || ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3194 json_object_boolean_true_add(json
, "stubAdvertisement");
3195 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3196 json_object_int_add(json
,"postStartEnabledMsecs", ospf
->stub_router_startup_time
/ 1000);
3197 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3198 json_object_int_add(json
,"preShutdownEnabledMsecs", ospf
->stub_router_shutdown_time
/ 1000);
3202 vty_out (vty
, " Stub router advertisement is configured%s",
3204 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3205 vty_out (vty
, " Enabled for %us after start-up%s",
3206 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
3207 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3208 vty_out (vty
, " Enabled for %us prior to full shutdown%s",
3209 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
3213 /* Show SPF timers. */
3216 json_object_int_add(json
, "spfScheduleDelayMsecs", ospf
->spf_delay
);
3217 json_object_int_add(json
, "holdtimeMinMsecs", ospf
->spf_holdtime
);
3218 json_object_int_add(json
, "holdtimeMaxMsecs", ospf
->spf_max_holdtime
);
3219 json_object_int_add(json
, "holdtimeMultplier", ospf
->spf_hold_multiplier
);
3223 vty_out (vty
, " Initial SPF scheduling delay %d millisec(s)%s"
3224 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
3225 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
3226 " Hold time multiplier is currently %d%s",
3227 ospf
->spf_delay
, VTY_NEWLINE
,
3228 ospf
->spf_holdtime
, VTY_NEWLINE
,
3229 ospf
->spf_max_holdtime
, VTY_NEWLINE
,
3230 ospf
->spf_hold_multiplier
, VTY_NEWLINE
);
3235 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
)
3237 unsigned long time_store
= 0;
3239 result
= tv_sub (recent_relative_time(), ospf
->ts_spf
);
3240 result
= tv_sub (result
, recent_relative_time());
3241 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3242 json_object_int_add(json
, "spfLastExecutedMsecs", time_store
);
3244 time_store
= (1000 * ospf
->ts_spf_duration
.tv_sec
) + (ospf
->ts_spf_duration
.tv_usec
/ 1000);
3245 json_object_int_add(json
, "spfLastDurationMsecs", time_store
);
3248 json_object_boolean_true_add(json
, "spfHasNotRun");
3252 vty_out (vty
, " SPF algorithm ");
3253 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
)
3255 result
= tv_sub (recent_relative_time(), ospf
->ts_spf
);
3256 vty_out (vty
, "last executed %s ago%s",
3257 ospf_timeval_dump (&result
, timebuf
, sizeof (timebuf
)),
3259 vty_out (vty
, " Last SPF duration %s%s",
3260 ospf_timeval_dump (&ospf
->ts_spf_duration
, timebuf
, sizeof (timebuf
)),
3264 vty_out (vty
, "has not been run%s", VTY_NEWLINE
);
3269 struct timeval temp_time
;
3270 unsigned long time_store
= 0;
3272 if (ospf
->t_spf_calc
)
3274 temp_time
= tv_sub (ospf
->t_spf_calc
->u
.sands
, recent_relative_time());
3275 time_store
= (1000 * temp_time
.tv_sec
) + (temp_time
.tv_usec
/ 1000);
3276 json_object_int_add(json
, "spfTimerDueInMsecs", time_store
);
3279 json_object_int_add(json
, "lsaMinIntervalMsecs", ospf
->min_ls_interval
);
3280 json_object_int_add(json
, "lsaMinArrivalMsecs", ospf
->min_ls_arrival
);
3281 /* Show write multiplier values */
3282 json_object_int_add(json
, "writeMultiplier", ospf
->write_oi_count
);
3283 /* Show refresh parameters. */
3284 json_object_int_add(json
, "refreshTimerMsecs", ospf
->lsa_refresh_interval
* 1000);
3288 vty_out (vty
, " SPF timer %s%s%s",
3289 (ospf
->t_spf_calc
? "due in " : "is "),
3290 ospf_timer_dump (ospf
->t_spf_calc
, timebuf
, sizeof (timebuf
)),
3293 vty_out (vty
, " LSA minimum interval %d msecs%s",
3294 ospf
->min_ls_interval
, VTY_NEWLINE
);
3295 vty_out (vty
, " LSA minimum arrival %d msecs%s",
3296 ospf
->min_ls_arrival
, VTY_NEWLINE
);
3298 /* Show write multiplier values */
3299 vty_out (vty
, " Write Multiplier set to %d %s",
3300 ospf
->write_oi_count
, VTY_NEWLINE
);
3302 /* Show refresh parameters. */
3303 vty_out (vty
, " Refresh timer %d secs%s",
3304 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
3307 /* Show ABR/ASBR flags. */
3308 if (CHECK_FLAG (ospf
->flags
, OSPF_FLAG_ABR
))
3311 json_object_string_add(json
, "abrType", ospf_abr_type_descr_str
[ospf
->abr_type
]);
3313 vty_out (vty
, " This router is an ABR, ABR type is: %s%s",
3314 ospf_abr_type_descr_str
[ospf
->abr_type
], VTY_NEWLINE
);
3316 if (CHECK_FLAG (ospf
->flags
, OSPF_FLAG_ASBR
))
3319 json_object_string_add(json
, "asbrRouter", "injectingExternalRoutingInformation");
3321 vty_out (vty
, " This router is an ASBR "
3322 "(injecting external routing information)%s", VTY_NEWLINE
);
3325 /* Show Number of AS-external-LSAs. */
3328 json_object_int_add(json
, "lsaExternalCounter",
3329 ospf_lsdb_count (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3330 json_object_int_add(json
, "lsaExternalChecksum",
3331 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3335 vty_out (vty
, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
3336 ospf_lsdb_count (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
),
3337 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
), VTY_NEWLINE
);
3342 json_object_int_add(json
, "lsaAsopaqueCounter",
3343 ospf_lsdb_count (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3344 json_object_int_add(json
, "lsaAsOpaqueChecksum",
3345 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3349 vty_out (vty
, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
3350 ospf_lsdb_count (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
),
3351 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
), VTY_NEWLINE
);
3354 /* Show number of areas attached. */
3356 json_object_int_add(json
, "attachedAreaCounter", listcount (ospf
->areas
));
3358 vty_out (vty
, " Number of areas attached to this router: %d%s",
3359 listcount (ospf
->areas
), VTY_NEWLINE
);
3361 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
))
3363 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
3366 json_object_boolean_true_add(json
, "adjacencyChangesLoggedAll");
3368 vty_out(vty
, " All adjacency changes are logged%s",VTY_NEWLINE
);
3373 json_object_boolean_true_add(json
, "adjacencyChangesLogged");
3375 vty_out(vty
, " Adjacency changes are logged%s",VTY_NEWLINE
);
3378 /* Show each area status. */
3379 for (ALL_LIST_ELEMENTS (ospf
->areas
, node
, nnode
, area
))
3380 show_ip_ospf_area (vty
, area
, json_areas
, use_json
);
3384 json_object_object_add(json
, "areas", json_areas
);
3385 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3386 json_object_free(json
);
3389 vty_out (vty
, "%s",VTY_NEWLINE
);
3394 DEFUN (show_ip_ospf
,
3396 "show ip ospf [json]",
3399 "OSPF information\n"
3400 "JavaScript Object Notation\n")
3403 u_char uj
= use_json(argc
, argv
);
3405 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3408 return (show_ip_ospf_common(vty
, ospf
, uj
));
3411 DEFUN (show_ip_ospf_instance
,
3412 show_ip_ospf_instance_cmd
,
3413 "show ip ospf (1-65535) [json]",
3416 "OSPF information\n"
3418 "JavaScript Object Notation\n")
3422 u_short instance
= 0;
3423 u_char uj
= use_json(argc
, argv
);
3425 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3426 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
3429 return (show_ip_ospf_common(vty
, ospf
, uj
));
3433 show_ip_ospf_interface_sub (struct vty
*vty
, struct ospf
*ospf
, struct interface
*ifp
,
3434 json_object
*json_interface_sub
, u_char use_json
)
3437 struct ospf_neighbor
*nbr
;
3438 struct route_node
*rn
;
3440 /* Is interface up? */
3443 is_up
= if_is_operative(ifp
);
3445 json_object_boolean_true_add(json_interface_sub
, "ifUp");
3447 json_object_boolean_false_add(json_interface_sub
, "ifDown");
3449 json_object_int_add(json_interface_sub
, "ifIndex", ifp
->ifindex
);
3450 json_object_int_add(json_interface_sub
, "mtuBytes", ifp
->mtu
);
3451 json_object_int_add(json_interface_sub
, "bandwidthMbit", ifp
->bandwidth
);
3452 json_object_string_add(json_interface_sub
, "ifFlags", if_flag_dump(ifp
->flags
));
3456 vty_out (vty
, "%s is %s%s", ifp
->name
,
3457 ((is_up
= if_is_operative(ifp
)) ? "up" : "down"), VTY_NEWLINE
);
3458 vty_out (vty
, " ifindex %u, MTU %u bytes, BW %u Mbit %s%s",
3459 ifp
->ifindex
, ifp
->mtu
, ifp
->bandwidth
, if_flag_dump(ifp
->flags
),
3463 /* Is interface OSPF enabled? */
3466 if (ospf_oi_count(ifp
) == 0)
3468 json_object_boolean_false_add(json_interface_sub
, "ospfEnabled");
3473 json_object_boolean_false_add(json_interface_sub
, "ospfRunning");
3477 json_object_boolean_true_add(json_interface_sub
, "ospfEnabled");
3481 if (ospf_oi_count(ifp
) == 0)
3483 vty_out (vty
, " OSPF not enabled on this interface%s", VTY_NEWLINE
);
3488 vty_out (vty
, " OSPF is enabled, but not running on this interface%s",
3494 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
3496 struct ospf_interface
*oi
= rn
->info
;
3501 if (CHECK_FLAG(oi
->connected
->flags
, ZEBRA_IFA_UNNUMBERED
))
3504 json_object_boolean_true_add(json_interface_sub
, "ifUnnumbered");
3506 vty_out (vty
, " This interface is UNNUMBERED,");
3510 /* Show OSPF interface information. */
3513 json_object_string_add(json_interface_sub
, "ipAddress", inet_ntoa (oi
->address
->u
.prefix4
));
3514 json_object_int_add(json_interface_sub
, "ipAddressPrefixlen", oi
->address
->prefixlen
);
3517 vty_out (vty
, " Internet Address %s/%d,",
3518 inet_ntoa (oi
->address
->u
.prefix4
), oi
->address
->prefixlen
);
3520 if (oi
->connected
->destination
|| oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3522 struct in_addr
*dest
;
3525 if (CONNECTED_PEER(oi
->connected
)
3526 || oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3531 /* For Vlinks, showing the peer address is probably more
3532 * * * * * informative than the local interface that is being used
3534 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3535 dest
= &oi
->vl_data
->peer_addr
;
3537 dest
= &oi
->connected
->destination
->u
.prefix4
;
3541 json_object_string_add(json_interface_sub
, "ospfIfType", dstr
);
3542 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3543 json_object_string_add(json_interface_sub
, "vlinkPeer", inet_ntoa (*dest
));
3545 json_object_string_add(json_interface_sub
, "localIfUsed", inet_ntoa (*dest
));
3548 vty_out (vty
, " %s %s,", dstr
, inet_ntoa (*dest
));
3553 json_object_string_add(json_interface_sub
, "area", ospf_area_desc_string (oi
->area
));
3554 if (OSPF_IF_PARAM(oi
, mtu_ignore
))
3555 json_object_boolean_true_add(json_interface_sub
, "mtuMismatchDetect");
3556 json_object_string_add(json_interface_sub
, "routerId", inet_ntoa (ospf
->router_id
));
3557 json_object_string_add(json_interface_sub
, "networkType", ospf_network_type_str
[oi
->type
]);
3558 json_object_int_add(json_interface_sub
, "cost", oi
->output_cost
);
3559 json_object_int_add(json_interface_sub
, "transmitDelayMsecs", 1000 / OSPF_IF_PARAM (oi
,transmit_delay
));
3560 json_object_string_add(json_interface_sub
, "state", LOOKUP (ospf_ism_state_msg
, oi
->state
));
3561 json_object_int_add(json_interface_sub
, "priority", PRIORITY (oi
));
3565 vty_out (vty
, " Area %s%s", ospf_area_desc_string (oi
->area
),
3568 vty_out (vty
, " MTU mismatch detection:%s%s",
3569 OSPF_IF_PARAM(oi
, mtu_ignore
) ? "disabled" : "enabled", VTY_NEWLINE
);
3571 vty_out (vty
, " Router ID %s, Network Type %s, Cost: %d%s",
3572 inet_ntoa (ospf
->router_id
), ospf_network_type_str
[oi
->type
],
3573 oi
->output_cost
, VTY_NEWLINE
);
3575 vty_out (vty
, " Transmit Delay is %d sec, State %s, Priority %d%s",
3576 OSPF_IF_PARAM (oi
,transmit_delay
), LOOKUP (ospf_ism_state_msg
, oi
->state
),
3577 PRIORITY (oi
), VTY_NEWLINE
);
3580 /* Show DR information. */
3581 if (DR (oi
).s_addr
== 0)
3584 vty_out (vty
, " No backup designated router on this network%s",
3589 nbr
= ospf_nbr_lookup_by_addr (oi
->nbrs
, &BDR (oi
));
3593 vty_out (vty
, " No backup designated router on this network%s",
3600 json_object_string_add(json_interface_sub
, "bdrId", inet_ntoa (nbr
->router_id
));
3601 json_object_string_add(json_interface_sub
, "bdrAddress", inet_ntoa (nbr
->address
.u
.prefix4
));
3605 vty_out (vty
, " Backup Designated Router (ID) %s,",
3606 inet_ntoa (nbr
->router_id
));
3607 vty_out (vty
, " Interface Address %s%s",
3608 inet_ntoa (nbr
->address
.u
.prefix4
), VTY_NEWLINE
);
3613 /* Next network-LSA sequence number we'll use, if we're elected DR */
3614 if (oi
->params
&& ntohl (oi
->params
->network_lsa_seqnum
) != OSPF_INITIAL_SEQUENCE_NUMBER
)
3617 json_object_int_add(json_interface_sub
, "networkLsaSequence", ntohl (oi
->params
->network_lsa_seqnum
));
3619 vty_out (vty
, " Saved Network-LSA sequence number 0x%x%s",
3620 ntohl (oi
->params
->network_lsa_seqnum
), VTY_NEWLINE
);
3625 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3626 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3628 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3629 json_object_boolean_true_add(json_interface_sub
, "mcastMemberOspfAllRouters");
3630 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3631 json_object_boolean_true_add(json_interface_sub
, "mcastMemberOspfDesignatedRouters");
3636 vty_out (vty
, " Multicast group memberships:");
3637 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3638 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3640 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3641 vty_out (vty
, " OSPFAllRouters");
3642 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3643 vty_out (vty
, " OSPFDesignatedRouters");
3646 vty_out (vty
, " <None>");
3647 vty_out (vty
, "%s", VTY_NEWLINE
);
3652 if (OSPF_IF_PARAM (oi
, fast_hello
) == 0)
3653 json_object_int_add(json_interface_sub
, "timerMsecs", 1000 /OSPF_IF_PARAM (oi
, v_hello
));
3655 json_object_int_add(json_interface_sub
, "timerMsecs", 1000 / OSPF_IF_PARAM (oi
, fast_hello
));
3656 json_object_int_add(json_interface_sub
, "timerDeadMsecs", 1000 / OSPF_IF_PARAM (oi
, v_wait
));
3657 json_object_int_add(json_interface_sub
, "timerWaitMsecs", 1000 / OSPF_IF_PARAM (oi
, v_wait
));
3658 json_object_int_add(json_interface_sub
, "timerRetransmit", 1000 / OSPF_IF_PARAM (oi
, retransmit_interval
));
3662 vty_out (vty
, " Timer intervals configured,");
3663 vty_out (vty
, " Hello ");
3664 if (OSPF_IF_PARAM (oi
, fast_hello
) == 0)
3665 vty_out (vty
, "%ds,", OSPF_IF_PARAM (oi
, v_hello
));
3667 vty_out (vty
, "%dms,", 1000 / OSPF_IF_PARAM (oi
, fast_hello
));
3668 vty_out (vty
, " Dead %ds, Wait %ds, Retransmit %d%s",
3669 OSPF_IF_PARAM (oi
, v_wait
),
3670 OSPF_IF_PARAM (oi
, v_wait
),
3671 OSPF_IF_PARAM (oi
, retransmit_interval
),
3675 if (OSPF_IF_PASSIVE_STATUS (oi
) == OSPF_IF_ACTIVE
)
3677 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3680 struct timeval result
;
3681 unsigned long time_store
= 0;
3683 result
= tv_sub (oi
->t_hello
->u
.sands
, recent_relative_time());
3689 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3690 json_object_int_add(json_interface_sub
, "timerHelloInMsecs", time_store
);
3693 vty_out (vty
, " Hello due in %s%s",
3694 ospf_timer_dump (oi
->t_hello
, timebuf
, sizeof(timebuf
)),
3697 else /* passive-interface is set */
3700 json_object_boolean_true_add(json_interface_sub
, "timerPassiveIface");
3702 vty_out (vty
, " No Hellos (Passive interface)%s", VTY_NEWLINE
);
3707 json_object_int_add(json_interface_sub
, "nbrCount", ospf_nbr_count (oi
, 0));
3708 json_object_int_add(json_interface_sub
, "nbrAdjacentCount", ospf_nbr_count (oi
, NSM_Full
));
3711 vty_out (vty
, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
3712 ospf_nbr_count (oi
, 0), ospf_nbr_count (oi
, NSM_Full
),
3714 ospf_bfd_interface_show(vty
, ifp
, json_interface_sub
, use_json
);
3719 show_ip_ospf_interface_common (struct vty
*vty
, struct ospf
*ospf
, int argc
,
3720 struct cmd_token
**argv
, int iface_argv
, u_char use_json
)
3722 struct interface
*ifp
;
3723 struct listnode
*node
;
3724 json_object
*json
= NULL
;
3725 json_object
*json_interface_sub
= NULL
;
3729 json
= json_object_new_object();
3730 json_interface_sub
= json_object_new_object();
3736 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3738 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3739 VTY_NEWLINE
, VTY_NEWLINE
);
3742 if (argc
== (iface_argv
+ 1))
3744 /* Show All Interfaces.*/
3745 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
3747 if (ospf_oi_count(ifp
))
3749 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3751 json_object_object_add (json
, ifp
->name
, json_interface_sub
);
3755 else if (argv
[iface_argv
] && strcmp(argv
[iface_argv
]->arg
, "json") == 0)
3759 json
= json_object_new_object();
3760 json_interface_sub
= json_object_new_object ();
3763 /* Show All Interfaces. */
3764 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
3766 if (ospf_oi_count(ifp
))
3768 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3770 json_object_object_add(json
, ifp
->name
, json_interface_sub
);
3776 /* Interface name is specified. */
3777 if ((ifp
= if_lookup_by_name (argv
[iface_argv
]->arg
)) == NULL
)
3780 json_object_boolean_true_add(json
, "noSuchIface");
3782 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
3786 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3788 json_object_object_add(json
, ifp
->name
, json_interface_sub
);
3794 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3795 json_object_free(json
);
3798 vty_out (vty
, "%s", VTY_NEWLINE
);
3803 DEFUN (show_ip_ospf_interface
,
3804 show_ip_ospf_interface_cmd
,
3805 "show ip ospf interface [INTERFACE] [json]",
3808 "OSPF information\n"
3809 "Interface information\n"
3811 "JavaScript Object Notation\n")
3814 u_char uj
= use_json(argc
, argv
);
3816 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3819 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 0, uj
);
3822 DEFUN (show_ip_ospf_instance_interface
,
3823 show_ip_ospf_instance_interface_cmd
,
3824 "show ip ospf (1-65535) interface [INTERFACE] [json]",
3827 "OSPF information\n"
3829 "Interface information\n"
3831 "JavaScript Object Notation\n")
3835 u_short instance
= 0;
3836 u_char uj
= use_json(argc
, argv
);
3838 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3839 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
3842 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 1, uj
);
3846 show_ip_ospf_neighbour_header (struct vty
*vty
)
3848 vty_out (vty
, "%s%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
3850 "Neighbor ID", "Pri", "State", "Dead Time",
3851 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
3856 show_ip_ospf_neighbor_sub (struct vty
*vty
, struct ospf_interface
*oi
, json_object
*json
, u_char use_json
)
3858 struct route_node
*rn
;
3859 struct ospf_neighbor
*nbr
;
3861 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3862 json_object
*json_neighbor
= NULL
;
3864 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
3866 if ((nbr
= rn
->info
))
3868 /* Do not show myself. */
3869 if (nbr
!= oi
->nbr_self
)
3871 /* Down state is not shown. */
3872 if (nbr
->state
!= NSM_Down
)
3876 json_neighbor
= json_object_new_object();
3877 ospf_nbr_state_message (nbr
, msgbuf
, 16);
3879 struct timeval result
;
3880 unsigned long time_store
= 0;
3882 result
= tv_sub (nbr
->t_inactivity
->u
.sands
, recent_relative_time());
3883 time_store
= (1000 * result
.tv_sec
) + (result
.tv_usec
/ 1000);
3885 json_object_int_add (json_neighbor
, "priority", nbr
->priority
);
3886 json_object_string_add (json_neighbor
, "state", msgbuf
);
3887 json_object_int_add (json_neighbor
, "deadTimeMsecs", time_store
);
3888 json_object_string_add (json_neighbor
, "address", inet_ntoa (nbr
->src
));
3889 json_object_string_add (json_neighbor
, "ifaceName", IF_NAME (oi
));
3890 json_object_int_add (json_neighbor
, "retransmitCounter", ospf_ls_retransmit_count (nbr
));
3891 json_object_int_add (json_neighbor
, "requestCounter", ospf_ls_request_count (nbr
));
3892 json_object_int_add (json_neighbor
, "dbSummaryCounter", ospf_db_summary_count (nbr
));
3893 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
3894 json_object_object_add(json
, "neighbor", json_neighbor
);
3896 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_neighbor
);
3900 ospf_nbr_state_message (nbr
, msgbuf
, 16);
3902 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
3903 vty_out (vty
, "%-15s %3d %-15s ",
3907 vty_out (vty
, "%-15s %3d %-15s ",
3908 inet_ntoa (nbr
->router_id
), nbr
->priority
,
3911 vty_out (vty
, "%9s ",
3912 ospf_timer_dump (nbr
->t_inactivity
, timebuf
,
3914 vty_out (vty
, "%-15s ", inet_ntoa (nbr
->src
));
3915 vty_out (vty
, "%-20s %5ld %5ld %5d%s",
3916 IF_NAME (oi
), ospf_ls_retransmit_count (nbr
),
3917 ospf_ls_request_count (nbr
), ospf_db_summary_count (nbr
),
3927 show_ip_ospf_neighbor_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
3929 struct ospf_interface
*oi
;
3930 struct listnode
*node
;
3931 json_object
*json
= NULL
;
3934 json
= json_object_new_object();
3936 show_ip_ospf_neighbour_header (vty
);
3941 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3943 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3944 VTY_NEWLINE
, VTY_NEWLINE
);
3947 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
3948 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
3952 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3953 json_object_free(json
);
3956 vty_out (vty
, "%s", VTY_NEWLINE
);
3961 DEFUN (show_ip_ospf_neighbor
,
3962 show_ip_ospf_neighbor_cmd
,
3963 "show ip ospf neighbor [json]",
3966 "OSPF information\n"
3968 "JavaScript Object Notation\n")
3971 u_char uj
= use_json(argc
, argv
);
3973 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3976 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
3980 DEFUN (show_ip_ospf_instance_neighbor
,
3981 show_ip_ospf_instance_neighbor_cmd
,
3982 "show ip ospf (1-65535) neighbor [json]",
3985 "OSPF information\n"
3988 "JavaScript Object Notation\n")
3992 u_short instance
= 0;
3993 u_char uj
= use_json(argc
, argv
);
3995 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3996 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
3999 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
4003 show_ip_ospf_neighbor_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4005 struct listnode
*node
;
4006 struct ospf_interface
*oi
;
4007 json_object
*json
= NULL
;
4008 json_object
*json_neighbor_sub
= NULL
;
4012 json
= json_object_new_object();
4013 json_neighbor_sub
= json_object_new_object();
4016 show_ip_ospf_neighbour_header (vty
);
4021 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4023 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4024 VTY_NEWLINE
, VTY_NEWLINE
);
4027 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4029 struct listnode
*nbr_node
;
4030 struct ospf_nbr_nbma
*nbr_nbma
;
4032 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
4034 /* print Down neighbor status */
4035 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nbr_node
, nbr_nbma
))
4037 if (nbr_nbma
->nbr
== NULL
4038 || nbr_nbma
->nbr
->state
== NSM_Down
)
4042 json_object_int_add (json_neighbor_sub
, "nbrNbmaPriority", nbr_nbma
->priority
);
4043 json_object_boolean_true_add (json_neighbor_sub
, "nbrNbmaDown");
4044 json_object_string_add (json_neighbor_sub
, "nbrNbmaIfaceName", IF_NAME (oi
));
4045 json_object_int_add (json_neighbor_sub
, "nbrNbmaRetransmitCounter", 0);
4046 json_object_int_add (json_neighbor_sub
, "nbrNbmaRequestCounter", 0);
4047 json_object_int_add (json_neighbor_sub
, "nbrNbmaDbSummaryCounter", 0);
4048 json_object_object_add(json
, inet_ntoa (nbr_nbma
->addr
), json_neighbor_sub
);
4052 vty_out (vty
, "%-15s %3d %-15s %9s ",
4053 "-", nbr_nbma
->priority
, "Down", "-");
4054 vty_out (vty
, "%-15s %-20s %5d %5d %5d%s",
4055 inet_ntoa (nbr_nbma
->addr
), IF_NAME (oi
),
4056 0, 0, 0, VTY_NEWLINE
);
4064 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4065 json_object_free(json
);
4068 vty_out (vty
, "%s", VTY_NEWLINE
);
4073 DEFUN (show_ip_ospf_neighbor_all
,
4074 show_ip_ospf_neighbor_all_cmd
,
4075 "show ip ospf neighbor all [json]",
4078 "OSPF information\n"
4080 "include down status neighbor\n"
4081 "JavaScript Object Notation\n")
4084 u_char uj
= use_json(argc
, argv
);
4086 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4089 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
4092 DEFUN (show_ip_ospf_instance_neighbor_all
,
4093 show_ip_ospf_instance_neighbor_all_cmd
,
4094 "show ip ospf (1-65535) neighbor all [json]",
4097 "OSPF information\n"
4100 "include down status neighbor\n"
4101 "JavaScript Object Notation\n")
4105 u_short instance
= 0;
4106 u_char uj
= use_json(argc
, argv
);
4108 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4109 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4112 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
4116 show_ip_ospf_neighbor_int_common (struct vty
*vty
, struct ospf
*ospf
, int arg_base
,
4117 struct cmd_token
**argv
, u_char use_json
)
4119 struct interface
*ifp
;
4120 struct route_node
*rn
;
4121 json_object
*json
= NULL
;
4124 json
= json_object_new_object();
4126 show_ip_ospf_neighbour_header (vty
);
4131 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4133 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4134 VTY_NEWLINE
, VTY_NEWLINE
);
4137 ifp
= if_lookup_by_name (argv
[arg_base
]->arg
);
4141 json_object_boolean_true_add(json
, "noSuchIface");
4143 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
4147 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
4149 struct ospf_interface
*oi
= rn
->info
;
4154 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
4159 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4160 json_object_free(json
);
4163 vty_out (vty
, "%s", VTY_NEWLINE
);
4168 DEFUN (show_ip_ospf_neighbor_int
,
4169 show_ip_ospf_neighbor_int_cmd
,
4170 "show ip ospf neighbor IFNAME [json]",
4173 "OSPF information\n"
4176 "JavaScript Object Notation\n")
4179 u_char uj
= use_json(argc
, argv
);
4181 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4184 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 0, argv
, uj
);
4187 DEFUN (show_ip_ospf_instance_neighbor_int
,
4188 show_ip_ospf_instance_neighbor_int_cmd
,
4189 "show ip ospf (1-65535) neighbor IFNAME [json]",
4192 "OSPF information\n"
4196 "JavaScript Object Notation\n")
4200 u_short instance
= 0;
4201 u_char uj
= use_json(argc
, argv
);
4203 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4204 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4207 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 1, argv
, uj
);
4211 show_ip_ospf_nbr_nbma_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
, struct ospf_nbr_nbma
*nbr_nbma
,
4212 u_char use_json
, json_object
*json
)
4214 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4215 json_object
*json_sub
= NULL
;
4218 json_sub
= json_object_new_object();
4219 else /* Show neighbor ID. */
4220 vty_out (vty
, " Neighbor %s,", "-");
4222 /* Show interface address. */
4224 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr_nbma
->addr
));
4226 vty_out (vty
, " interface address %s%s",
4227 inet_ntoa (nbr_nbma
->addr
), VTY_NEWLINE
);
4232 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4233 json_object_string_add(json_sub
, "iface", IF_NAME (oi
));
4236 vty_out (vty
, " In the area %s via interface %s%s",
4237 ospf_area_desc_string (oi
->area
), IF_NAME (oi
), VTY_NEWLINE
);
4239 /* Show neighbor priority and state. */
4242 json_object_int_add(json_sub
, "nbrPriority", nbr_nbma
->priority
);
4243 json_object_string_add(json_sub
, "nbrState", "down");
4246 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4247 nbr_nbma
->priority
, "Down");
4249 /* Show state changes. */
4251 json_object_int_add(json_sub
, "stateChangeCounter", nbr_nbma
->state_change
);
4253 vty_out (vty
, " %d state changes%s", nbr_nbma
->state_change
, VTY_NEWLINE
);
4255 /* Show PollInterval */
4257 json_object_int_add(json_sub
, "pollInterval", nbr_nbma
->v_poll
);
4259 vty_out (vty
, " Poll interval %d%s", nbr_nbma
->v_poll
, VTY_NEWLINE
);
4261 /* Show poll-interval timer. */
4264 struct timeval res
= tv_sub (nbr_nbma
->t_poll
->u
.sands
, recent_relative_time ());
4265 unsigned long time_store
= 0;
4266 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4267 json_object_int_add(json_sub
, "pollIntervalTimerDueMsec", time_store
);
4270 vty_out (vty
, " Poll timer due in %s%s",
4271 ospf_timer_dump (nbr_nbma
->t_poll
, timebuf
, sizeof(timebuf
)),
4274 /* Show poll-interval timer thread. */
4277 if (nbr_nbma
->t_poll
!= NULL
)
4278 json_object_string_add(json_sub
, "pollIntervalTimerThread", "on");
4281 vty_out (vty
, " Thread Poll Timer %s%s",
4282 nbr_nbma
->t_poll
!= NULL
? "on" : "off", VTY_NEWLINE
);
4285 json_object_object_add(json
, "noNbrId", json_sub
);
4289 show_ip_ospf_neighbor_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
,
4290 struct ospf_neighbor
*nbr
, u_char use_json
, json_object
*json
)
4292 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4293 json_object
*json_sub
= NULL
;
4296 json_sub
= json_object_new_object();
4299 /* Show neighbor ID. */
4300 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4301 vty_out (vty
, " Neighbor %s,", "-");
4303 vty_out (vty
, " Neighbor %s,", inet_ntoa (nbr
->router_id
));
4306 /* Show interface address. */
4308 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr
->address
.u
.prefix4
));
4310 vty_out (vty
, " interface address %s%s",
4311 inet_ntoa (nbr
->address
.u
.prefix4
), VTY_NEWLINE
);
4316 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4317 json_object_string_add(json_sub
, "ifaceName", oi
->ifp
->name
);
4320 vty_out (vty
, " In the area %s via interface %s%s",
4321 ospf_area_desc_string (oi
->area
), oi
->ifp
->name
, VTY_NEWLINE
);
4323 /* Show neighbor priority and state. */
4326 json_object_int_add(json_sub
, "nbrPriority", nbr
->priority
);
4327 json_object_string_add(json_sub
, "nbrState", LOOKUP (ospf_nsm_state_msg
, nbr
->state
));
4330 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4331 nbr
->priority
, LOOKUP (ospf_nsm_state_msg
, nbr
->state
));
4333 /* Show state changes. */
4335 json_object_int_add(json_sub
, "stateChangeCounter", nbr
->state_change
);
4337 vty_out (vty
, " %d state changes%s", nbr
->state_change
, VTY_NEWLINE
);
4339 if (nbr
->ts_last_progress
.tv_sec
|| nbr
->ts_last_progress
.tv_usec
)
4341 struct timeval res
= tv_sub (recent_relative_time (), nbr
->ts_last_progress
);
4344 unsigned long time_store
= 0;
4345 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4346 json_object_int_add(json_sub
, "lastPrgrsvChangeMsec", time_store
);
4350 vty_out (vty
, " Most recent state change statistics:%s",
4352 vty_out (vty
, " Progressive change %s ago%s",
4353 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4358 if (nbr
->ts_last_regress
.tv_sec
|| nbr
->ts_last_regress
.tv_usec
)
4360 struct timeval res
= tv_sub (recent_relative_time (), nbr
->ts_last_regress
);
4363 unsigned long time_store
= 0;
4364 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4365 json_object_int_add(json_sub
, "lastRegressiveChangeMsec", time_store
);
4366 if (nbr
->last_regress_str
)
4367 json_object_string_add(json_sub
, "lastRegressiveChangeReason", nbr
->last_regress_str
);
4371 vty_out (vty
, " Regressive change %s ago, due to %s%s",
4372 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4373 (nbr
->last_regress_str
? nbr
->last_regress_str
: "??"),
4378 /* Show Designated Rotuer ID. */
4380 json_object_string_add(json_sub
, "routerDesignatedId", inet_ntoa (nbr
->d_router
));
4382 vty_out (vty
, " DR is %s,", inet_ntoa (nbr
->d_router
));
4384 /* Show Backup Designated Rotuer ID. */
4386 json_object_string_add(json_sub
, "routerDesignatedBackupId", inet_ntoa (nbr
->bd_router
));
4388 vty_out (vty
, " BDR is %s%s", inet_ntoa (nbr
->bd_router
), VTY_NEWLINE
);
4393 json_object_int_add(json_sub
, "optionsCounter", nbr
->options
);
4394 json_object_string_add(json_sub
, "optionsList", ospf_options_dump (nbr
->options
));
4397 vty_out (vty
, " Options %d %s%s", nbr
->options
,
4398 ospf_options_dump (nbr
->options
), VTY_NEWLINE
);
4400 /* Show Router Dead interval timer. */
4403 struct timeval res
= tv_sub (nbr
->t_inactivity
->u
.sands
, recent_relative_time ());
4404 unsigned long time_store
= 0;
4405 time_store
= (1000 * res
.tv_sec
) + (res
.tv_usec
/ 1000);
4406 json_object_int_add(json_sub
, "routerDeadIntervalTimerDueMsec", time_store
);
4409 vty_out (vty
, " Dead timer due in %s%s",
4410 ospf_timer_dump (nbr
->t_inactivity
, timebuf
, sizeof (timebuf
)),
4413 /* Show Database Summary list. */
4415 json_object_int_add(json_sub
, "databaseSummaryListCounter", ospf_db_summary_count (nbr
));
4417 vty_out (vty
, " Database Summary List %d%s",
4418 ospf_db_summary_count (nbr
), VTY_NEWLINE
);
4420 /* Show Link State Request list. */
4422 json_object_int_add(json_sub
, "linkStateRequestListCounter", ospf_ls_request_count (nbr
));
4424 vty_out (vty
, " Link State Request List %ld%s",
4425 ospf_ls_request_count (nbr
), VTY_NEWLINE
);
4427 /* Show Link State Retransmission list. */
4429 json_object_int_add(json_sub
, "linkStateRetransmissionListCounter", ospf_ls_retransmit_count (nbr
));
4431 vty_out (vty
, " Link State Retransmission List %ld%s",
4432 ospf_ls_retransmit_count (nbr
), VTY_NEWLINE
);
4434 /* Show inactivity timer thread. */
4437 if (nbr
->t_inactivity
!= NULL
)
4438 json_object_string_add(json_sub
, "threadInactivityTimer", "on");
4441 vty_out (vty
, " Thread Inactivity Timer %s%s",
4442 nbr
->t_inactivity
!= NULL
? "on" : "off", VTY_NEWLINE
);
4444 /* Show Database Description retransmission thread. */
4447 if (nbr
->t_db_desc
!= NULL
)
4448 json_object_string_add(json_sub
, "threadDatabaseDescriptionRetransmission", "on");
4451 vty_out (vty
, " Thread Database Description Retransmision %s%s",
4452 nbr
->t_db_desc
!= NULL
? "on" : "off", VTY_NEWLINE
);
4454 /* Show Link State Request Retransmission thread. */
4457 if (nbr
->t_ls_req
!= NULL
)
4458 json_object_string_add(json_sub
, "threadLinkStateRequestRetransmission", "on");
4461 vty_out (vty
, " Thread Link State Request Retransmission %s%s",
4462 nbr
->t_ls_req
!= NULL
? "on" : "off", VTY_NEWLINE
);
4464 /* Show Link State Update Retransmission thread. */
4467 if (nbr
->t_ls_upd
!= NULL
)
4468 json_object_string_add(json_sub
, "threadLinkStateUpdateRetransmission", "on");
4471 vty_out (vty
, " Thread Link State Update Retransmission %s%s%s",
4472 nbr
->t_ls_upd
!= NULL
? "on" : "off", VTY_NEWLINE
, VTY_NEWLINE
);
4476 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4477 json_object_object_add(json
, "noNbrId", json_sub
);
4479 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_sub
);
4482 ospf_bfd_show_info(vty
, nbr
->bfd_info
, json
, use_json
, 0);
4486 show_ip_ospf_neighbor_id_common (struct vty
*vty
, struct ospf
*ospf
,
4487 int arg_base
, struct cmd_token
**argv
, u_char use_json
)
4489 struct listnode
*node
;
4490 struct ospf_neighbor
*nbr
;
4491 struct ospf_interface
*oi
;
4492 struct in_addr router_id
;
4494 json_object
*json
= NULL
;
4497 json
= json_object_new_object();
4502 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4504 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4505 VTY_NEWLINE
, VTY_NEWLINE
);
4508 ret
= inet_aton (argv
[arg_base
]->arg
, &router_id
);
4512 vty_out (vty
, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE
);
4516 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4518 if ((nbr
= ospf_nbr_lookup_by_routerid (oi
->nbrs
, &router_id
)))
4520 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4526 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4527 json_object_free(json
);
4530 vty_out (vty
, "%s", VTY_NEWLINE
);
4535 DEFUN (show_ip_ospf_neighbor_id
,
4536 show_ip_ospf_neighbor_id_cmd
,
4537 "show ip ospf neighbor A.B.C.D [json]",
4540 "OSPF information\n"
4543 "JavaScript Object Notation\n")
4546 u_char uj
= use_json(argc
, argv
);
4548 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4551 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 0, argv
, uj
);
4554 DEFUN (show_ip_ospf_instance_neighbor_id
,
4555 show_ip_ospf_instance_neighbor_id_cmd
,
4556 "show ip ospf (1-65535) neighbor A.B.C.D [json]",
4559 "OSPF information\n"
4563 "JavaScript Object Notation\n")
4567 u_short instance
= 0;
4568 u_char uj
= use_json(argc
, argv
);
4570 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4571 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4574 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 1, argv
, uj
);
4578 show_ip_ospf_neighbor_detail_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4580 struct ospf_interface
*oi
;
4581 struct listnode
*node
;
4582 json_object
*json
= NULL
;
4585 json
= json_object_new_object();
4590 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4592 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4593 VTY_NEWLINE
, VTY_NEWLINE
);
4596 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4598 struct route_node
*rn
;
4599 struct ospf_neighbor
*nbr
;
4601 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4603 if ((nbr
= rn
->info
))
4605 if (nbr
!= oi
->nbr_self
)
4607 if (nbr
->state
!= NSM_Down
)
4609 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4618 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4619 json_object_free(json
);
4622 vty_out (vty
, "%s", VTY_NEWLINE
);
4627 DEFUN (show_ip_ospf_neighbor_detail
,
4628 show_ip_ospf_neighbor_detail_cmd
,
4629 "show ip ospf neighbor detail [json]",
4632 "OSPF information\n"
4634 "detail of all neighbors\n"
4635 "JavaScript Object Notation\n")
4638 u_char uj
= use_json(argc
, argv
);
4640 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4643 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4646 DEFUN (show_ip_ospf_instance_neighbor_detail
,
4647 show_ip_ospf_instance_neighbor_detail_cmd
,
4648 "show ip ospf (1-65535) neighbor detail [json]",
4651 "OSPF information\n"
4654 "detail of all neighbors\n"
4655 "JavaScript Object Notation\n")
4659 u_short instance
= 0;
4660 u_char uj
= use_json(argc
, argv
);
4662 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4663 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
4666 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4670 show_ip_ospf_neighbor_detail_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4672 struct listnode
*node
;
4673 struct ospf_interface
*oi
;
4674 json_object
*json
= NULL
;
4677 json
= json_object_new_object();
4682 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4684 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4685 VTY_NEWLINE
, VTY_NEWLINE
);
4688 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4690 struct route_node
*rn
;
4691 struct ospf_neighbor
*nbr
;
4692 struct ospf_nbr_nbma
*nbr_nbma
;
4694 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4695 if ((nbr
= rn
->info
))
4696 if (nbr
!= oi
->nbr_self
)
4697 if (nbr
->state
!= NSM_Down
)
4698 show_ip_ospf_neighbor_detail_sub (vty
, oi
, rn
->info
, use_json
, json
);
4700 if (oi
->type
== OSPF_IFTYPE_NBMA
)
4702 struct listnode
*nd
;
4704 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nd
, nbr_nbma
))
4706 if (nbr_nbma
->nbr
== NULL
|| nbr_nbma
->nbr
->state
== NSM_Down
)
4707 show_ip_ospf_nbr_nbma_detail_sub (vty
, oi
, nbr_nbma
, use_json
, json
);
4714 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4715 json_object_free(json
);
4719 vty_out (vty
, "%s", VTY_NEWLINE
);
4725 DEFUN (show_ip_ospf_neighbor_detail_all
,
4726 show_ip_ospf_neighbor_detail_all_cmd
,
4727 "show ip ospf neighbor detail all [json]",
4730 "OSPF information\n"
4732 "detail of all neighbors\n"
4733 "include down status neighbor\n"
4734 "JavaScript Object Notation\n")
4737 u_char uj
= use_json(argc
, argv
);
4739 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4742 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4745 DEFUN (show_ip_ospf_instance_neighbor_detail_all
,
4746 show_ip_ospf_instance_neighbor_detail_all_cmd
,
4747 "show ip ospf (1-65535) neighbor detail all [json]",
4750 "OSPF information\n"
4753 "detail of all neighbors\n"
4754 "include down status neighbor\n"
4755 "JavaScript Object Notation\n")
4759 u_short instance
= 0;
4760 u_char uj
= use_json(argc
, argv
);
4762 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4763 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4766 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4770 show_ip_ospf_neighbor_int_detail_common (struct vty
*vty
, struct ospf
*ospf
,
4771 int arg_base
, struct cmd_token
**argv
, u_char use_json
)
4773 struct ospf_interface
*oi
;
4774 struct interface
*ifp
;
4775 struct route_node
*rn
, *nrn
;
4776 struct ospf_neighbor
*nbr
;
4777 json_object
*json
= NULL
;
4780 json
= json_object_new_object();
4785 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4787 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4788 VTY_NEWLINE
, VTY_NEWLINE
);
4791 ifp
= if_lookup_by_name (argv
[arg_base
]->arg
);
4795 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
4799 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
4801 if ((oi
= rn
->info
))
4803 for (nrn
= route_top (oi
->nbrs
); nrn
; nrn
= route_next (nrn
))
4805 if ((nbr
= nrn
->info
))
4807 if (nbr
!= oi
->nbr_self
)
4809 if (nbr
->state
!= NSM_Down
)
4810 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4819 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4820 json_object_free(json
);
4823 vty_out (vty
, "%s", VTY_NEWLINE
);
4828 DEFUN (show_ip_ospf_neighbor_int_detail
,
4829 show_ip_ospf_neighbor_int_detail_cmd
,
4830 "show ip ospf neighbor IFNAME detail [json]",
4833 "OSPF information\n"
4836 "detail of all neighbors\n"
4837 "JavaScript Object Notation\n")
4840 u_char uj
= use_json(argc
, argv
);
4842 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4845 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 0, argv
, uj
);
4848 DEFUN (show_ip_ospf_instance_neighbor_int_detail
,
4849 show_ip_ospf_instance_neighbor_int_detail_cmd
,
4850 "show ip ospf (1-65535) neighbor IFNAME detail [json]",
4853 "OSPF information\n"
4857 "detail of all neighbors\n"
4858 "JavaScript Object Notation\n")
4862 u_short instance
= 0;
4863 u_char uj
= use_json(argc
, argv
);
4865 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4866 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4869 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 1, argv
, uj
);
4872 /* Show functions */
4874 show_lsa_summary (struct vty
*vty
, struct ospf_lsa
*lsa
, int self
)
4876 struct router_lsa
*rl
;
4877 struct summary_lsa
*sl
;
4878 struct as_external_lsa
*asel
;
4879 struct prefix_ipv4 p
;
4882 /* If self option is set, check LSA self flag. */
4883 if (self
== 0 || IS_LSA_SELF (lsa
))
4885 /* LSA common part show. */
4886 vty_out (vty
, "%-15s ", inet_ntoa (lsa
->data
->id
));
4887 vty_out (vty
, "%-15s %4d 0x%08lx 0x%04x",
4888 inet_ntoa (lsa
->data
->adv_router
), LS_AGE (lsa
),
4889 (u_long
)ntohl (lsa
->data
->ls_seqnum
), ntohs (lsa
->data
->checksum
));
4890 /* LSA specific part show. */
4891 switch (lsa
->data
->type
)
4893 case OSPF_ROUTER_LSA
:
4894 rl
= (struct router_lsa
*) lsa
->data
;
4895 vty_out (vty
, " %-d", ntohs (rl
->links
));
4897 case OSPF_SUMMARY_LSA
:
4898 sl
= (struct summary_lsa
*) lsa
->data
;
4901 p
.prefix
= sl
->header
.id
;
4902 p
.prefixlen
= ip_masklen (sl
->mask
);
4903 apply_mask_ipv4 (&p
);
4905 vty_out (vty
, " %s/%d", inet_ntoa (p
.prefix
), p
.prefixlen
);
4907 case OSPF_AS_EXTERNAL_LSA
:
4908 case OSPF_AS_NSSA_LSA
:
4909 asel
= (struct as_external_lsa
*) lsa
->data
;
4912 p
.prefix
= asel
->header
.id
;
4913 p
.prefixlen
= ip_masklen (asel
->mask
);
4914 apply_mask_ipv4 (&p
);
4916 vty_out (vty
, " %s %s/%d [0x%lx]",
4917 IS_EXTERNAL_METRIC (asel
->e
[0].tos
) ? "E2" : "E1",
4918 inet_ntoa (p
.prefix
), p
.prefixlen
,
4919 (u_long
)ntohl (asel
->e
[0].route_tag
));
4921 case OSPF_NETWORK_LSA
:
4922 case OSPF_ASBR_SUMMARY_LSA
:
4923 case OSPF_OPAQUE_LINK_LSA
:
4924 case OSPF_OPAQUE_AREA_LSA
:
4925 case OSPF_OPAQUE_AS_LSA
:
4929 vty_out (vty
, VTY_NEWLINE
);
4935 static const char *show_database_desc
[] =
4938 "Router Link States",
4940 "Summary Link States",
4941 "ASBR-Summary Link States",
4942 "AS External Link States",
4943 "Group Membership LSA",
4944 "NSSA-external Link States",
4946 "Link-Local Opaque-LSA",
4947 "Area-Local Opaque-LSA",
4948 "AS-external Opaque-LSA",
4951 static const char *show_database_header
[] =
4954 "Link ID ADV Router Age Seq# CkSum Link count",
4955 "Link ID ADV Router Age Seq# CkSum",
4956 "Link ID ADV Router Age Seq# CkSum Route",
4957 "Link ID ADV Router Age Seq# CkSum",
4958 "Link ID ADV Router Age Seq# CkSum Route",
4959 " --- header for Group Member ----",
4960 "Link ID ADV Router Age Seq# CkSum Route",
4962 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4963 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4964 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4968 show_ip_ospf_database_header (struct vty
*vty
, struct ospf_lsa
*lsa
)
4970 struct router_lsa
*rlsa
= (struct router_lsa
*) lsa
->data
;
4972 vty_out (vty
, " LS age: %d%s", LS_AGE (lsa
), VTY_NEWLINE
);
4973 vty_out (vty
, " Options: 0x%-2x : %s%s",
4975 ospf_options_dump(lsa
->data
->options
),
4977 vty_out (vty
, " LS Flags: 0x%-2x %s%s",
4979 ((lsa
->flags
& OSPF_LSA_LOCAL_XLT
) ? "(Translated from Type-7)" : ""),
4982 if (lsa
->data
->type
== OSPF_ROUTER_LSA
)
4984 vty_out (vty
, " Flags: 0x%x" , rlsa
->flags
);
4987 vty_out (vty
, " :%s%s%s%s",
4988 IS_ROUTER_LSA_BORDER (rlsa
) ? " ABR" : "",
4989 IS_ROUTER_LSA_EXTERNAL (rlsa
) ? " ASBR" : "",
4990 IS_ROUTER_LSA_VIRTUAL (rlsa
) ? " VL-endpoint" : "",
4991 IS_ROUTER_LSA_SHORTCUT (rlsa
) ? " Shortcut" : "");
4993 vty_out (vty
, "%s", VTY_NEWLINE
);
4995 vty_out (vty
, " LS Type: %s%s",
4996 LOOKUP (ospf_lsa_type_msg
, lsa
->data
->type
), VTY_NEWLINE
);
4997 vty_out (vty
, " Link State ID: %s %s%s", inet_ntoa (lsa
->data
->id
),
4998 LOOKUP (ospf_link_state_id_type_msg
, lsa
->data
->type
), VTY_NEWLINE
);
4999 vty_out (vty
, " Advertising Router: %s%s",
5000 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
5001 vty_out (vty
, " LS Seq Number: %08lx%s", (u_long
)ntohl (lsa
->data
->ls_seqnum
),
5003 vty_out (vty
, " Checksum: 0x%04x%s", ntohs (lsa
->data
->checksum
),
5005 vty_out (vty
, " Length: %d%s", ntohs (lsa
->data
->length
), VTY_NEWLINE
);
5008 const char *link_type_desc
[] =
5011 "another Router (point-to-point)",
5012 "a Transit Network",
5017 const char *link_id_desc
[] =
5020 "Neighboring Router ID",
5021 "Designated Router address",
5023 "Neighboring Router ID",
5026 const char *link_data_desc
[] =
5029 "Router Interface address",
5030 "Router Interface address",
5032 "Router Interface address",
5035 /* Show router-LSA each Link information. */
5037 show_ip_ospf_database_router_links (struct vty
*vty
,
5038 struct router_lsa
*rl
)
5043 len
= ntohs (rl
->header
.length
) - 4;
5044 for (i
= 0; i
< ntohs (rl
->links
) && len
> 0; len
-= 12, i
++)
5046 type
= rl
->link
[i
].type
;
5048 vty_out (vty
, " Link connected to: %s%s",
5049 link_type_desc
[type
], VTY_NEWLINE
);
5050 vty_out (vty
, " (Link ID) %s: %s%s", link_id_desc
[type
],
5051 inet_ntoa (rl
->link
[i
].link_id
), VTY_NEWLINE
);
5052 vty_out (vty
, " (Link Data) %s: %s%s", link_data_desc
[type
],
5053 inet_ntoa (rl
->link
[i
].link_data
), VTY_NEWLINE
);
5054 vty_out (vty
, " Number of TOS metrics: 0%s", VTY_NEWLINE
);
5055 vty_out (vty
, " TOS 0 Metric: %d%s",
5056 ntohs (rl
->link
[i
].metric
), VTY_NEWLINE
);
5057 vty_out (vty
, "%s", VTY_NEWLINE
);
5061 /* Show router-LSA detail information. */
5063 show_router_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5067 struct router_lsa
*rl
= (struct router_lsa
*) lsa
->data
;
5069 show_ip_ospf_database_header (vty
, lsa
);
5071 vty_out (vty
, " Number of Links: %d%s%s", ntohs (rl
->links
),
5072 VTY_NEWLINE
, VTY_NEWLINE
);
5074 show_ip_ospf_database_router_links (vty
, rl
);
5075 vty_out (vty
, "%s", VTY_NEWLINE
);
5081 /* Show network-LSA detail information. */
5083 show_network_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5089 struct network_lsa
*nl
= (struct network_lsa
*) lsa
->data
;
5091 show_ip_ospf_database_header (vty
, lsa
);
5093 vty_out (vty
, " Network Mask: /%d%s",
5094 ip_masklen (nl
->mask
), VTY_NEWLINE
);
5096 length
= ntohs (lsa
->data
->length
) - OSPF_LSA_HEADER_SIZE
- 4;
5098 for (i
= 0; length
> 0; i
++, length
-= 4)
5099 vty_out (vty
, " Attached Router: %s%s",
5100 inet_ntoa (nl
->routers
[i
]), VTY_NEWLINE
);
5102 vty_out (vty
, "%s", VTY_NEWLINE
);
5108 /* Show summary-LSA detail information. */
5110 show_summary_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5114 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
5116 show_ip_ospf_database_header (vty
, lsa
);
5118 vty_out (vty
, " Network Mask: /%d%s", ip_masklen (sl
->mask
),
5120 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
5122 vty_out (vty
, "%s", VTY_NEWLINE
);
5128 /* Show summary-ASBR-LSA detail information. */
5130 show_summary_asbr_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5134 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
5136 show_ip_ospf_database_header (vty
, lsa
);
5138 vty_out (vty
, " Network Mask: /%d%s",
5139 ip_masklen (sl
->mask
), VTY_NEWLINE
);
5140 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
5142 vty_out (vty
, "%s", VTY_NEWLINE
);
5148 /* Show AS-external-LSA detail information. */
5150 show_as_external_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5154 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5156 show_ip_ospf_database_header (vty
, lsa
);
5158 vty_out (vty
, " Network Mask: /%d%s",
5159 ip_masklen (al
->mask
), VTY_NEWLINE
);
5160 vty_out (vty
, " Metric Type: %s%s",
5161 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5162 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
5163 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
5164 vty_out (vty
, " Metric: %d%s",
5165 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
5166 vty_out (vty
, " Forward Address: %s%s",
5167 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
5169 vty_out (vty
, " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5170 (route_tag_t
)ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
5177 show_as_external_lsa_stdvty (struct ospf_lsa
*lsa
)
5179 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5181 /* show_ip_ospf_database_header (vty, lsa); */
5183 zlog_debug( " Network Mask: /%d%s",
5184 ip_masklen (al
->mask
), "\n");
5185 zlog_debug( " Metric Type: %s%s",
5186 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5187 "2 (Larger than any link state path)" : "1", "\n");
5188 zlog_debug( " TOS: 0%s", "\n");
5189 zlog_debug( " Metric: %d%s",
5190 GET_METRIC (al
->e
[0].metric
), "\n");
5191 zlog_debug( " Forward Address: %s%s",
5192 inet_ntoa (al
->e
[0].fwd_addr
), "\n");
5194 zlog_debug( " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5195 (route_tag_t
)ntohl (al
->e
[0].route_tag
), "\n", "\n");
5200 /* Show AS-NSSA-LSA detail information. */
5202 show_as_nssa_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5206 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5208 show_ip_ospf_database_header (vty
, lsa
);
5210 vty_out (vty
, " Network Mask: /%d%s",
5211 ip_masklen (al
->mask
), VTY_NEWLINE
);
5212 vty_out (vty
, " Metric Type: %s%s",
5213 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5214 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
5215 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
5216 vty_out (vty
, " Metric: %d%s",
5217 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
5218 vty_out (vty
, " NSSA: Forward Address: %s%s",
5219 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
5221 vty_out (vty
, " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5222 (route_tag_t
)ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
5229 show_func_dummy (struct vty
*vty
, struct ospf_lsa
*lsa
)
5235 show_opaque_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5239 show_ip_ospf_database_header (vty
, lsa
);
5240 show_opaque_info_detail (vty
, lsa
);
5242 vty_out (vty
, "%s", VTY_NEWLINE
);
5247 int (*show_function
[])(struct vty
*, struct ospf_lsa
*) =
5250 show_router_lsa_detail
,
5251 show_network_lsa_detail
,
5252 show_summary_lsa_detail
,
5253 show_summary_asbr_lsa_detail
,
5254 show_as_external_lsa_detail
,
5256 show_as_nssa_lsa_detail
, /* almost same as external */
5258 show_opaque_lsa_detail
,
5259 show_opaque_lsa_detail
,
5260 show_opaque_lsa_detail
,
5264 show_lsa_prefix_set (struct vty
*vty
, struct prefix_ls
*lp
, struct in_addr
*id
,
5265 struct in_addr
*adv_router
)
5267 memset (lp
, 0, sizeof (struct prefix_ls
));
5271 else if (adv_router
== NULL
)
5280 lp
->adv_router
= *adv_router
;
5285 show_lsa_detail_proc (struct vty
*vty
, struct route_table
*rt
,
5286 struct in_addr
*id
, struct in_addr
*adv_router
)
5288 struct prefix_ls lp
;
5289 struct route_node
*rn
, *start
;
5290 struct ospf_lsa
*lsa
;
5292 show_lsa_prefix_set (vty
, &lp
, id
, adv_router
);
5293 start
= route_node_get (rt
, (struct prefix
*) &lp
);
5296 route_lock_node (start
);
5297 for (rn
= start
; rn
; rn
= route_next_until (rn
, start
))
5298 if ((lsa
= rn
->info
))
5300 if (show_function
[lsa
->data
->type
] != NULL
)
5301 show_function
[lsa
->data
->type
] (vty
, lsa
);
5303 route_unlock_node (start
);
5307 /* Show detail LSA information
5308 -- if id is NULL then show all LSAs. */
5310 show_lsa_detail (struct vty
*vty
, struct ospf
*ospf
, int type
,
5311 struct in_addr
*id
, struct in_addr
*adv_router
)
5313 struct listnode
*node
;
5314 struct ospf_area
*area
;
5318 case OSPF_AS_EXTERNAL_LSA
:
5319 case OSPF_OPAQUE_AS_LSA
:
5320 vty_out (vty
, " %s %s%s",
5321 show_database_desc
[type
],
5322 VTY_NEWLINE
, VTY_NEWLINE
);
5323 show_lsa_detail_proc (vty
, AS_LSDB (ospf
, type
), id
, adv_router
);
5326 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5328 vty_out (vty
, "%s %s (Area %s)%s%s",
5329 VTY_NEWLINE
, show_database_desc
[type
],
5330 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5331 show_lsa_detail_proc (vty
, AREA_LSDB (area
, type
), id
, adv_router
);
5338 show_lsa_detail_adv_router_proc (struct vty
*vty
, struct route_table
*rt
,
5339 struct in_addr
*adv_router
)
5341 struct route_node
*rn
;
5342 struct ospf_lsa
*lsa
;
5344 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
5345 if ((lsa
= rn
->info
))
5346 if (IPV4_ADDR_SAME (adv_router
, &lsa
->data
->adv_router
))
5348 if (CHECK_FLAG (lsa
->flags
, OSPF_LSA_LOCAL_XLT
))
5350 if (show_function
[lsa
->data
->type
] != NULL
)
5351 show_function
[lsa
->data
->type
] (vty
, lsa
);
5355 /* Show detail LSA information. */
5357 show_lsa_detail_adv_router (struct vty
*vty
, struct ospf
*ospf
, int type
,
5358 struct in_addr
*adv_router
)
5360 struct listnode
*node
;
5361 struct ospf_area
*area
;
5365 case OSPF_AS_EXTERNAL_LSA
:
5366 case OSPF_OPAQUE_AS_LSA
:
5367 vty_out (vty
, " %s %s%s",
5368 show_database_desc
[type
],
5369 VTY_NEWLINE
, VTY_NEWLINE
);
5370 show_lsa_detail_adv_router_proc (vty
, AS_LSDB (ospf
, type
),
5374 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5376 vty_out (vty
, "%s %s (Area %s)%s%s",
5377 VTY_NEWLINE
, show_database_desc
[type
],
5378 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5379 show_lsa_detail_adv_router_proc (vty
, AREA_LSDB (area
, type
),
5387 show_ip_ospf_database_summary (struct vty
*vty
, struct ospf
*ospf
, int self
)
5389 struct ospf_lsa
*lsa
;
5390 struct route_node
*rn
;
5391 struct ospf_area
*area
;
5392 struct listnode
*node
;
5395 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5397 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5401 case OSPF_AS_EXTERNAL_LSA
:
5402 case OSPF_OPAQUE_AS_LSA
:
5407 if (ospf_lsdb_count_self (area
->lsdb
, type
) > 0 ||
5408 (!self
&& ospf_lsdb_count (area
->lsdb
, type
) > 0))
5410 vty_out (vty
, " %s (Area %s)%s%s",
5411 show_database_desc
[type
],
5412 ospf_area_desc_string (area
),
5413 VTY_NEWLINE
, VTY_NEWLINE
);
5414 vty_out (vty
, "%s%s", show_database_header
[type
], VTY_NEWLINE
);
5416 LSDB_LOOP (AREA_LSDB (area
, type
), rn
, lsa
)
5417 show_lsa_summary (vty
, lsa
, self
);
5419 vty_out (vty
, "%s", VTY_NEWLINE
);
5424 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5428 case OSPF_AS_EXTERNAL_LSA
:
5429 case OSPF_OPAQUE_AS_LSA
:
5434 if (ospf_lsdb_count_self (ospf
->lsdb
, type
) ||
5435 (!self
&& ospf_lsdb_count (ospf
->lsdb
, type
)))
5437 vty_out (vty
, " %s%s%s",
5438 show_database_desc
[type
],
5439 VTY_NEWLINE
, VTY_NEWLINE
);
5440 vty_out (vty
, "%s%s", show_database_header
[type
],
5443 LSDB_LOOP (AS_LSDB (ospf
, type
), rn
, lsa
)
5444 show_lsa_summary (vty
, lsa
, self
);
5446 vty_out (vty
, "%s", VTY_NEWLINE
);
5450 vty_out (vty
, "%s", VTY_NEWLINE
);
5454 show_ip_ospf_database_maxage (struct vty
*vty
, struct ospf
*ospf
)
5456 struct route_node
*rn
;
5458 vty_out (vty
, "%s MaxAge Link States:%s%s",
5459 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
5461 for (rn
= route_top (ospf
->maxage_lsa
); rn
; rn
= route_next (rn
))
5463 struct ospf_lsa
*lsa
;
5465 if ((lsa
= rn
->info
) != NULL
)
5467 vty_out (vty
, "Link type: %d%s", lsa
->data
->type
, VTY_NEWLINE
);
5468 vty_out (vty
, "Link State ID: %s%s",
5469 inet_ntoa (lsa
->data
->id
), VTY_NEWLINE
);
5470 vty_out (vty
, "Advertising Router: %s%s",
5471 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
5472 vty_out (vty
, "LSA lock count: %d%s", lsa
->lock
, VTY_NEWLINE
);
5473 vty_out (vty
, "%s", VTY_NEWLINE
);
5478 #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
5479 #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
5481 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
5482 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
5483 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
5484 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
5486 #define OSPF_LSA_TYPES_DESC \
5487 "ASBR summary link states\n" \
5488 "External link states\n" \
5489 "Network link states\n" \
5490 "Router link states\n" \
5491 "Network summary link states\n" \
5492 OSPF_LSA_TYPE_NSSA_DESC \
5493 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
5494 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
5495 OSPF_LSA_TYPE_OPAQUE_AS_DESC
5498 show_ip_ospf_database_common (struct vty
*vty
, struct ospf
*ospf
,
5499 int arg_base
, int argc
, struct cmd_token
**argv
)
5503 struct in_addr id
, adv_router
;
5506 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5509 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5510 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5513 if (argc
== arg_base
+ 4)
5515 show_ip_ospf_database_summary (vty
, ospf
, 0);
5519 /* Set database type to show. */
5520 if (strncmp (argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5521 type
= OSPF_ROUTER_LSA
;
5522 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5523 type
= OSPF_NETWORK_LSA
;
5524 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5525 type
= OSPF_AS_NSSA_LSA
;
5526 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "su", 2) == 0)
5527 type
= OSPF_SUMMARY_LSA
;
5528 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5529 type
= OSPF_ASBR_SUMMARY_LSA
;
5530 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5531 type
= OSPF_AS_EXTERNAL_LSA
;
5532 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "se", 2) == 0)
5534 show_ip_ospf_database_summary (vty
, ospf
, 1);
5537 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "m", 1) == 0)
5539 show_ip_ospf_database_maxage (vty
, ospf
);
5542 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5543 type
= OSPF_OPAQUE_LINK_LSA
;
5544 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5545 type
= OSPF_OPAQUE_AREA_LSA
;
5546 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5547 type
= OSPF_OPAQUE_AS_LSA
;
5551 /* `show ip ospf database LSA'. */
5552 if (argc
== arg_base
+ 5)
5553 show_lsa_detail (vty
, ospf
, type
, NULL
, NULL
);
5554 else if (argc
>= arg_base
+ 6)
5556 ret
= inet_aton (argv
[arg_base
+ 5]->arg
, &id
);
5560 /* `show ip ospf database LSA ID'. */
5561 if (argc
== arg_base
+ 6)
5562 show_lsa_detail (vty
, ospf
, type
, &id
, NULL
);
5563 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
5564 else if (argc
== arg_base
+ 7)
5566 if (strncmp (argv
[arg_base
+ 6]->text
, "s", 1) == 0)
5567 adv_router
= ospf
->router_id
;
5570 ret
= inet_aton (argv
[arg_base
+ 7]->arg
, &adv_router
);
5574 show_lsa_detail (vty
, ospf
, type
, &id
, &adv_router
);
5581 DEFUN (show_ip_ospf_database_max
,
5582 show_ip_ospf_database_max_cmd
,
5583 "show ip ospf database <max-age|self-originate>",
5586 "OSPF information\n"
5587 "Database summary\n"
5588 "LSAs in MaxAge list\n"
5589 "Self-originated link states\n")
5593 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5596 return (show_ip_ospf_database_common(vty
, ospf
, 0, argc
, argv
));
5599 DEFUN (show_ip_ospf_instance_database
,
5600 show_ip_ospf_instance_database_cmd
,
5601 "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>]]]",
5604 "OSPF information\n"
5606 "Database summary\n"
5608 "Link State ID (as an IP address)\n"
5609 "Self-originated link states\n"
5610 "Advertising Router link states\n"
5611 "Advertising Router (as an IP address)\n")
5614 u_short instance
= 0;
5617 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
5619 VTY_GET_INTEGER ("Instance", instance
, argv
[idx
]->arg
);
5620 ospf
= ospf_lookup_instance (instance
);
5623 ospf
= ospf_lookup();
5626 if (!ospf
|| !ospf
->oi_running
)
5629 return (show_ip_ospf_database_common(vty
, ospf
, idx
? 1 : 0, argc
, argv
));
5632 DEFUN (show_ip_ospf_instance_database_max
,
5633 show_ip_ospf_instance_database_max_cmd
,
5634 "show ip ospf (1-65535) database <max-age|self-originate>",
5637 "OSPF information\n"
5639 "Database summary\n"
5640 "LSAs in MaxAge list\n"
5641 "Self-originated link states\n")
5645 u_short instance
= 0;
5647 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
5649 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5652 return (show_ip_ospf_database_common(vty
, ospf
, 1, argc
, argv
));
5657 show_ip_ospf_database_type_adv_router_common (struct vty
*vty
, struct ospf
*ospf
,
5658 int arg_base
, int argc
, struct cmd_token
**argv
)
5662 struct in_addr adv_router
;
5665 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5668 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5669 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5671 if (argc
!= arg_base
+ 7)
5674 /* Set database type to show. */
5675 if (strncmp (argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5676 type
= OSPF_ROUTER_LSA
;
5677 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5678 type
= OSPF_NETWORK_LSA
;
5679 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5680 type
= OSPF_AS_NSSA_LSA
;
5681 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "s", 1) == 0)
5682 type
= OSPF_SUMMARY_LSA
;
5683 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5684 type
= OSPF_ASBR_SUMMARY_LSA
;
5685 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5686 type
= OSPF_AS_EXTERNAL_LSA
;
5687 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5688 type
= OSPF_OPAQUE_LINK_LSA
;
5689 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5690 type
= OSPF_OPAQUE_AREA_LSA
;
5691 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5692 type
= OSPF_OPAQUE_AS_LSA
;
5696 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
5697 if (strncmp (argv
[arg_base
+ 5]->text
, "s", 1) == 0)
5698 adv_router
= ospf
->router_id
;
5701 ret
= inet_aton (argv
[arg_base
+ 6]->arg
, &adv_router
);
5706 show_lsa_detail_adv_router (vty
, ospf
, type
, &adv_router
);
5711 DEFUN (show_ip_ospf_database_type_adv_router
,
5712 show_ip_ospf_database_type_adv_router_cmd
,
5713 "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>",
5716 "OSPF information\n"
5717 "Database summary\n"
5719 "Advertising Router link states\n"
5720 "Advertising Router (as an IP address)\n"
5721 "Self-originated link states\n")
5725 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5728 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 0, argc
, argv
));
5731 DEFUN (show_ip_ospf_instance_database_type_adv_router
,
5732 show_ip_ospf_instance_database_type_adv_router_cmd
,
5733 "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>",
5736 "OSPF information\n"
5738 "Database summary\n"
5740 "Advertising Router link states\n"
5741 "Advertising Router (as an IP address)\n"
5742 "Self-originated link states\n")
5746 u_short instance
= 0;
5748 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
5750 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5753 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 1, argc
, argv
));
5756 DEFUN (ip_ospf_authentication_args
,
5757 ip_ospf_authentication_args_addr_cmd
,
5758 "ip ospf authentication <null|message-digest> [A.B.C.D]",
5760 "OSPF interface commands\n"
5761 "Enable authentication on this interface\n"
5762 "Use null authentication\n"
5763 "Use message-digest authentication\n"
5764 "Address of interface\n")
5766 int idx_encryption
= 3;
5768 struct interface
*ifp
;
5769 struct in_addr addr
;
5771 struct ospf_if_params
*params
;
5774 params
= IF_DEF_PARAMS (ifp
);
5778 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5781 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5786 params
= ospf_get_if_params (ifp
, addr
);
5787 ospf_if_update_params (ifp
, addr
);
5790 /* Handle null authentication */
5791 if ( argv
[idx_encryption
]->arg
[0] == 'n' )
5793 SET_IF_PARAM (params
, auth_type
);
5794 params
->auth_type
= OSPF_AUTH_NULL
;
5798 /* Handle message-digest authentication */
5799 if ( argv
[idx_encryption
]->arg
[0] == 'm' )
5801 SET_IF_PARAM (params
, auth_type
);
5802 params
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5806 vty_out (vty
, "You shouldn't get here!%s", VTY_NEWLINE
);
5810 DEFUN (ip_ospf_authentication
,
5811 ip_ospf_authentication_addr_cmd
,
5812 "ip ospf authentication [A.B.C.D]",
5814 "OSPF interface commands\n"
5815 "Enable authentication on this interface\n"
5816 "Address of interface")
5819 struct interface
*ifp
;
5820 struct in_addr addr
;
5822 struct ospf_if_params
*params
;
5825 params
= IF_DEF_PARAMS (ifp
);
5829 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5832 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5837 params
= ospf_get_if_params (ifp
, addr
);
5838 ospf_if_update_params (ifp
, addr
);
5841 SET_IF_PARAM (params
, auth_type
);
5842 params
->auth_type
= OSPF_AUTH_SIMPLE
;
5847 DEFUN (no_ip_ospf_authentication_args
,
5848 no_ip_ospf_authentication_args_addr_cmd
,
5849 "no ip ospf authentication <null|message-digest> [A.B.C.D]",
5852 "OSPF interface commands\n"
5853 "Enable authentication on this interface\n"
5854 "Use null authentication\n"
5855 "Use message-digest authentication\n"
5856 "Address of interface")
5858 int idx_encryption
= 4;
5860 struct interface
*ifp
;
5861 struct in_addr addr
;
5863 struct ospf_if_params
*params
;
5864 struct route_node
*rn
;
5868 params
= IF_DEF_PARAMS (ifp
);
5872 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5875 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5880 params
= ospf_lookup_if_params (ifp
, addr
);
5883 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
5886 params
->auth_type
= OSPF_AUTH_NOTSET
;
5887 UNSET_IF_PARAM (params
, auth_type
);
5888 if (params
!= IF_DEF_PARAMS (ifp
))
5890 ospf_free_if_params (ifp
, addr
);
5891 ospf_if_update_params (ifp
, addr
);
5896 if ( argv
[idx_encryption
]->arg
[0] == 'n' )
5898 auth_type
= OSPF_AUTH_NULL
;
5900 else if ( argv
[idx_encryption
]->arg
[0] == 'm' )
5902 auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5906 vty_out (vty
, "Unexpected input encountered%s", VTY_NEWLINE
);
5910 * Here we have a case where the user has entered
5911 * 'no ip ospf authentication (null | message_digest )'
5912 * we need to find if we have any ip addresses underneath it that
5913 * correspond to the associated type.
5915 if (params
->auth_type
== auth_type
)
5917 params
->auth_type
= OSPF_AUTH_NOTSET
;
5918 UNSET_IF_PARAM (params
, auth_type
);
5921 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
5923 if ((params
= rn
->info
))
5925 if (params
->auth_type
== auth_type
)
5927 params
->auth_type
= OSPF_AUTH_NOTSET
;
5928 UNSET_IF_PARAM (params
, auth_type
);
5929 if (params
!= IF_DEF_PARAMS (ifp
))
5931 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
5932 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
5942 DEFUN (no_ip_ospf_authentication
,
5943 no_ip_ospf_authentication_addr_cmd
,
5944 "no ip ospf authentication [A.B.C.D]",
5947 "OSPF interface commands\n"
5948 "Enable authentication on this interface\n"
5949 "Address of interface")
5952 struct interface
*ifp
;
5953 struct in_addr addr
;
5955 struct ospf_if_params
*params
;
5956 struct route_node
*rn
;
5959 params
= IF_DEF_PARAMS (ifp
);
5963 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5966 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5971 params
= ospf_lookup_if_params (ifp
, addr
);
5974 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
5978 params
->auth_type
= OSPF_AUTH_NOTSET
;
5979 UNSET_IF_PARAM (params
, auth_type
);
5980 if (params
!= IF_DEF_PARAMS (ifp
))
5982 ospf_free_if_params (ifp
, addr
);
5983 ospf_if_update_params (ifp
, addr
);
5989 * When a user enters 'no ip ospf authentication'
5990 * We should remove all authentication types from
5993 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
5994 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
5995 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
5997 params
->auth_type
= OSPF_AUTH_NOTSET
;
5998 UNSET_IF_PARAM (params
, auth_type
);
6001 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
6003 if ((params
= rn
->info
))
6006 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
6007 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
6008 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
6010 params
->auth_type
= OSPF_AUTH_NOTSET
;
6011 UNSET_IF_PARAM (params
, auth_type
);
6012 if (params
!= IF_DEF_PARAMS (ifp
))
6014 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
6015 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
6026 DEFUN (ip_ospf_authentication_key
,
6027 ip_ospf_authentication_key_addr_cmd
,
6028 "ip ospf authentication-key AUTH_KEY [A.B.C.D]",
6030 "OSPF interface commands\n"
6031 "Authentication password (key)\n"
6032 "The OSPF password (key)\n"
6033 "Address of interface")
6036 struct interface
*ifp
;
6037 struct in_addr addr
;
6038 struct ospf_if_params
*params
;
6041 params
= IF_DEF_PARAMS (ifp
);
6043 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6045 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6047 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6052 params
= ospf_get_if_params (ifp
, addr
);
6053 ospf_if_update_params (ifp
, addr
);
6056 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
6057 strncpy ((char *) params
->auth_simple
, argv
[3]->arg
, OSPF_AUTH_SIMPLE_SIZE
);
6058 SET_IF_PARAM (params
, auth_simple
);
6063 DEFUN_HIDDEN (ospf_authentication_key
,
6064 ospf_authentication_key_cmd
,
6065 "ospf authentication-key AUTH_KEY [A.B.C.D]",
6066 "OSPF interface commands\n"
6067 "Authentication password (key)\n"
6068 "The OSPF password (key)\n"
6069 "Address of interface\n")
6071 return ip_ospf_authentication_key (self
, vty
, argc
, argv
);
6074 DEFUN (no_ip_ospf_authentication_key
,
6075 no_ip_ospf_authentication_key_authkey_addr_cmd
,
6076 "no ip ospf authentication-key [AUTH_KEY [A.B.C.D]]",
6079 "OSPF interface commands\n"
6080 "Authentication password (key)\n"
6081 "The OSPF password (key)")
6084 struct interface
*ifp
;
6085 struct in_addr addr
;
6086 struct ospf_if_params
*params
;
6088 params
= IF_DEF_PARAMS (ifp
);
6090 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6092 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6094 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6099 params
= ospf_lookup_if_params (ifp
, addr
);
6104 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
);
6105 UNSET_IF_PARAM (params
, auth_simple
);
6107 if (params
!= IF_DEF_PARAMS (ifp
))
6109 ospf_free_if_params (ifp
, addr
);
6110 ospf_if_update_params (ifp
, addr
);
6116 DEFUN_HIDDEN (no_ospf_authentication_key
,
6117 no_ospf_authentication_key_authkey_addr_cmd
,
6118 "no ospf authentication-key [AUTH_KEY [A.B.C.D]]",
6120 "OSPF interface commands\n"
6121 "Authentication password (key)\n"
6122 "The OSPF password (key)")
6124 return no_ip_ospf_authentication_key (self
, vty
, argc
, argv
);
6127 DEFUN (ip_ospf_message_digest_key
,
6128 ip_ospf_message_digest_key_cmd
,
6129 "ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
6131 "OSPF interface commands\n"
6132 "Message digest authentication password (key)\n"
6134 "Use MD5 algorithm\n"
6135 "The OSPF password (key)\n"
6136 "Address of interface\n")
6138 struct interface
*ifp
;
6139 struct crypt_key
*ck
;
6141 struct in_addr addr
;
6142 struct ospf_if_params
*params
;
6145 params
= IF_DEF_PARAMS (ifp
);
6148 argv_find (argv
, argc
, "(1-255)", &idx
);
6149 char *keyid
= argv
[idx
]->arg
;
6150 argv_find (argv
, argc
, "KEY", &idx
);
6151 char *cryptkey
= argv
[idx
]->arg
;
6153 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6155 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6157 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6162 params
= ospf_get_if_params (ifp
, addr
);
6163 ospf_if_update_params (ifp
, addr
);
6166 key_id
= strtol (keyid
, NULL
, 10);
6167 if (ospf_crypt_key_lookup (params
->auth_crypt
, key_id
) != NULL
)
6169 vty_out (vty
, "OSPF: Key %d already exists%s", key_id
, VTY_NEWLINE
);
6173 ck
= ospf_crypt_key_new ();
6174 ck
->key_id
= (u_char
) key_id
;
6175 memset (ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
6176 strncpy ((char *) ck
->auth_key
, cryptkey
, OSPF_AUTH_MD5_SIZE
);
6178 ospf_crypt_key_add (params
->auth_crypt
, ck
);
6179 SET_IF_PARAM (params
, auth_crypt
);
6184 DEFUN_HIDDEN (ospf_message_digest_key
,
6185 ospf_message_digest_key_cmd
,
6186 "ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
6187 "OSPF interface commands\n"
6188 "Message digest authentication password (key)\n"
6190 "Use MD5 algorithm\n"
6191 "The OSPF password (key)\n"
6192 "Address of interface\n")
6194 return ip_ospf_message_digest_key (self
, vty
, argc
, argv
);
6197 DEFUN (no_ip_ospf_message_digest_key
,
6198 no_ip_ospf_message_digest_key_cmd
,
6199 "no ip ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
6202 "OSPF interface commands\n"
6203 "Message digest authentication password (key)\n"
6205 "Use MD5 algorithm\n"
6206 "The OSPF password (key)\n"
6207 "Address of interface\n")
6210 struct interface
*ifp
;
6211 struct crypt_key
*ck
;
6213 struct in_addr addr
;
6214 struct ospf_if_params
*params
;
6216 params
= IF_DEF_PARAMS (ifp
);
6218 argv_find (argv
, argc
, "(1-255)", &idx
);
6219 char *keyid
= argv
[idx
]->arg
;
6221 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6223 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6225 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6230 params
= ospf_lookup_if_params (ifp
, addr
);
6235 key_id
= strtol (keyid
, NULL
, 10);
6236 ck
= ospf_crypt_key_lookup (params
->auth_crypt
, key_id
);
6239 vty_out (vty
, "OSPF: Key %d does not exist%s", key_id
, VTY_NEWLINE
);
6243 ospf_crypt_key_delete (params
->auth_crypt
, key_id
);
6245 if (params
!= IF_DEF_PARAMS (ifp
))
6247 ospf_free_if_params (ifp
, addr
);
6248 ospf_if_update_params (ifp
, addr
);
6254 DEFUN_HIDDEN (no_ospf_message_digest_key
,
6255 no_ospf_message_digest_key_cmd
,
6256 "no ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
6258 "OSPF interface commands\n"
6259 "Message digest authentication password (key)\n"
6261 "Address of interface")
6263 return no_ip_ospf_message_digest_key (self
, vty
, argc
, argv
);
6266 DEFUN (ip_ospf_cost
,
6268 "ip ospf cost (1-65535) [A.B.C.D]",
6270 "OSPF interface commands\n"
6273 "Address of interface\n")
6276 struct interface
*ifp
= vty
->index
;
6278 struct in_addr addr
;
6279 struct ospf_if_params
*params
;
6280 params
= IF_DEF_PARAMS (ifp
);
6283 char *coststr
= NULL
, *ifaddr
= NULL
;
6284 coststr
= argv_find (argv
, argc
, "(1-65535)", &idx
) ? argv
[idx
]->arg
: NULL
;
6285 ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6287 cost
= strtol (coststr
, NULL
, 10);
6291 if(!inet_aton(ifaddr
, &addr
))
6293 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6298 params
= ospf_get_if_params (ifp
, addr
);
6299 ospf_if_update_params (ifp
, addr
);
6302 SET_IF_PARAM (params
, output_cost_cmd
);
6303 params
->output_cost_cmd
= cost
;
6305 ospf_if_recalculate_output_cost (ifp
);
6310 DEFUN_HIDDEN (ospf_cost
,
6312 "ospf cost (1-65535) [A.B.C.D]",
6313 "OSPF interface commands\n"
6316 "Address of interface\n")
6318 return ip_ospf_cost (self
, vty
, argc
, argv
);
6321 DEFUN (no_ip_ospf_cost
,
6322 no_ip_ospf_cost_cmd
,
6323 "no ip ospf cost [(1-65535)] [A.B.C.D]",
6325 "OSPF interface commands\n"
6327 "Address of interface")
6330 struct interface
*ifp
= vty
->index
;
6331 struct in_addr addr
;
6332 struct ospf_if_params
*params
;
6335 params
= IF_DEF_PARAMS (ifp
);
6338 char *ifaddr
= NULL
;
6339 ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6341 /* According to the semantics we are mimicking "no ip ospf cost N" is
6342 * always treated as "no ip ospf cost" regardless of the actual value
6343 * of N already configured for the interface. Thus ignore cost. */
6347 if (!inet_aton(ifaddr
, &addr
))
6349 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6354 params
= ospf_lookup_if_params (ifp
, addr
);
6359 UNSET_IF_PARAM (params
, output_cost_cmd
);
6361 if (params
!= IF_DEF_PARAMS (ifp
))
6363 ospf_free_if_params (ifp
, addr
);
6364 ospf_if_update_params (ifp
, addr
);
6367 ospf_if_recalculate_output_cost (ifp
);
6372 DEFUN_HIDDEN (no_ospf_cost
,
6374 "no ospf cost [(1-65535)] [A.B.C.D]",
6376 "OSPF interface commands\n"
6379 "Address of interface\n")
6381 return no_ip_ospf_cost (self
, vty
, argc
, argv
);
6385 ospf_nbr_timer_update (struct ospf_interface
*oi
)
6387 struct route_node
*rn
;
6388 struct ospf_neighbor
*nbr
;
6390 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
6391 if ((nbr
= rn
->info
))
6393 nbr
->v_inactivity
= OSPF_IF_PARAM (oi
, v_wait
);
6394 nbr
->v_db_desc
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6395 nbr
->v_ls_req
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6396 nbr
->v_ls_upd
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6401 ospf_vty_dead_interval_set (struct vty
*vty
, const char *interval_str
,
6402 const char *nbr_str
,
6403 const char *fast_hello_str
)
6405 struct interface
*ifp
= vty
->index
;
6408 struct in_addr addr
;
6410 struct ospf_if_params
*params
;
6411 struct ospf_interface
*oi
;
6412 struct route_node
*rn
;
6414 params
= IF_DEF_PARAMS (ifp
);
6418 ret
= inet_aton(nbr_str
, &addr
);
6421 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6426 params
= ospf_get_if_params (ifp
, addr
);
6427 ospf_if_update_params (ifp
, addr
);
6432 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds
, interval_str
,
6435 /* reset fast_hello too, just to be sure */
6436 UNSET_IF_PARAM (params
, fast_hello
);
6437 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6439 else if (fast_hello_str
)
6441 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult
, fast_hello_str
,
6443 /* 1s dead-interval with sub-second hellos desired */
6444 seconds
= OSPF_ROUTER_DEAD_INTERVAL_MINIMAL
;
6445 SET_IF_PARAM (params
, fast_hello
);
6446 params
->fast_hello
= hellomult
;
6450 vty_out (vty
, "Please specify dead-interval or hello-multiplier%s",
6455 SET_IF_PARAM (params
, v_wait
);
6456 params
->v_wait
= seconds
;
6458 /* Update timer values in neighbor structure. */
6462 if ((ospf
= ospf_lookup()))
6464 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
6466 ospf_nbr_timer_update (oi
);
6471 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6472 if ((oi
= rn
->info
))
6473 ospf_nbr_timer_update (oi
);
6479 DEFUN (ip_ospf_dead_interval
,
6480 ip_ospf_dead_interval_cmd
,
6481 "ip ospf dead-interval (1-65535) [A.B.C.D]",
6483 "OSPF interface commands\n"
6484 "Interval time after which a neighbor is declared down\n"
6486 "Address of interface\n")
6489 char *interval
= argv_find (argv
, argc
, "(1-65535)", &idx
) ? argv
[idx
]->arg
: NULL
;
6490 char *ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6491 return ospf_vty_dead_interval_set (vty
, interval
, ifaddr
, NULL
);
6495 DEFUN_HIDDEN (ospf_dead_interval
,
6496 ospf_dead_interval_cmd
,
6497 "ospf dead-interval (1-65535) [A.B.C.D]",
6498 "OSPF interface commands\n"
6499 "Interval time after which a neighbor is declared down\n"
6501 "Address of interface\n")
6503 return ip_ospf_dead_interval (self
, vty
, argc
, argv
);
6506 DEFUN (ip_ospf_dead_interval_minimal
,
6507 ip_ospf_dead_interval_minimal_addr_cmd
,
6508 "ip ospf dead-interval minimal hello-multiplier (1-10) [A.B.C.D]",
6510 "OSPF interface commands\n"
6511 "Interval time after which a neighbor is declared down\n"
6512 "Minimal 1s dead-interval with fast sub-second hellos\n"
6513 "Hello multiplier factor\n"
6514 "Number of Hellos to send each second\n"
6515 "Address of interface\n")
6520 return ospf_vty_dead_interval_set (vty
, NULL
, argv
[idx_ipv4
]->arg
, argv
[idx_number
]->arg
);
6522 return ospf_vty_dead_interval_set (vty
, NULL
, NULL
, argv
[idx_number
]->arg
);
6525 DEFUN (no_ip_ospf_dead_interval
,
6526 no_ip_ospf_dead_interval_cmd
,
6527 "no ip ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6530 "OSPF interface commands\n"
6531 "Interval time after which a neighbor is declared down\n"
6533 "Address of interface")
6535 int idx_ipv4
= argc
- 1;
6536 struct interface
*ifp
= vty
->index
;
6537 struct in_addr addr
;
6539 struct ospf_if_params
*params
;
6540 struct ospf_interface
*oi
;
6541 struct route_node
*rn
;
6544 params
= IF_DEF_PARAMS (ifp
);
6546 if (argv
[idx_ipv4
]->type
== IPV4_TKN
)
6548 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6551 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6556 params
= ospf_lookup_if_params (ifp
, addr
);
6561 UNSET_IF_PARAM (params
, v_wait
);
6562 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
6564 UNSET_IF_PARAM (params
, fast_hello
);
6565 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6567 if (params
!= IF_DEF_PARAMS (ifp
))
6569 ospf_free_if_params (ifp
, addr
);
6570 ospf_if_update_params (ifp
, addr
);
6573 /* Update timer values in neighbor structure. */
6578 if ((ospf
= ospf_lookup()))
6580 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
6582 ospf_nbr_timer_update (oi
);
6587 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6588 if ((oi
= rn
->info
))
6589 ospf_nbr_timer_update (oi
);
6595 DEFUN_HIDDEN (no_ospf_dead_interval
,
6596 no_ospf_dead_interval_cmd
,
6597 "no ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6599 "OSPF interface commands\n"
6600 "Interval time after which a neighbor is declared down\n"
6602 "Address of interface")
6604 return no_ip_ospf_dead_interval (self
, vty
, argc
, argv
);
6607 DEFUN (ip_ospf_hello_interval
,
6608 ip_ospf_hello_interval_cmd
,
6609 "ip ospf hello-interval (1-65535) [A.B.C.D]",
6611 "OSPF interface commands\n"
6612 "Time between HELLO packets\n"
6614 "Address of interface\n")
6617 struct interface
*ifp
= vty
->index
;
6618 struct in_addr addr
;
6619 struct ospf_if_params
*params
;
6620 params
= IF_DEF_PARAMS (ifp
);
6621 u_int32_t seconds
= 0;
6623 argv_find (argv
, argc
, "(1-65535)", &idx
);
6624 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
6626 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6628 if(!inet_aton(argv
[idx
]->arg
, &addr
))
6630 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6635 params
= ospf_get_if_params (ifp
, addr
);
6636 ospf_if_update_params (ifp
, addr
);
6639 SET_IF_PARAM (params
, v_hello
);
6640 params
->v_hello
= seconds
;
6645 DEFUN_HIDDEN (ospf_hello_interval
,
6646 ospf_hello_interval_cmd
,
6647 "ospf hello-interval (1-65535) [A.B.C.D]",
6648 "OSPF interface commands\n"
6649 "Time between HELLO packets\n"
6651 "Address of interface\n")
6653 return ip_ospf_hello_interval (self
, vty
, argc
, argv
);
6656 DEFUN (no_ip_ospf_hello_interval
,
6657 no_ip_ospf_hello_interval_cmd
,
6658 "no ip ospf hello-interval [(1-65535) [A.B.C.D]]",
6661 "OSPF interface commands\n"
6662 "Time between HELLO packets\n" // ignored
6664 "Address of interface\n")
6667 struct interface
*ifp
= vty
->index
;
6668 struct in_addr addr
;
6669 struct ospf_if_params
*params
;
6670 params
= IF_DEF_PARAMS (ifp
);
6672 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6674 if(!inet_aton(argv
[idx
]->arg
, &addr
))
6676 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6681 params
= ospf_lookup_if_params (ifp
, addr
);
6686 UNSET_IF_PARAM (params
, v_hello
);
6687 params
->v_hello
= OSPF_HELLO_INTERVAL_DEFAULT
;
6689 if (params
!= IF_DEF_PARAMS (ifp
))
6691 ospf_free_if_params (ifp
, addr
);
6692 ospf_if_update_params (ifp
, addr
);
6698 DEFUN_HIDDEN (no_ospf_hello_interval
,
6699 no_ospf_hello_interval_cmd
,
6700 "no ospf hello-interval [(1-65535) [A.B.C.D]]",
6702 "OSPF interface commands\n"
6703 "Time between HELLO packets\n" // ignored
6705 "Address of interface\n")
6707 return no_ospf_hello_interval (self
, vty
, argc
, argv
);
6710 DEFUN (ip_ospf_network
,
6711 ip_ospf_network_cmd
,
6712 "ip ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
6714 "OSPF interface commands\n"
6716 "Specify OSPF broadcast multi-access network\n"
6717 "Specify OSPF NBMA network\n"
6718 "Specify OSPF point-to-multipoint network\n"
6719 "Specify OSPF point-to-point network\n")
6722 struct interface
*ifp
= vty
->index
;
6723 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
6724 struct route_node
*rn
;
6726 if (old_type
== OSPF_IFTYPE_LOOPBACK
)
6728 vty_out (vty
, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE
);
6732 if (argv_find (argv
, argc
, "broadcast", &idx
))
6733 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_BROADCAST
;
6734 else if (argv_find (argv
, argc
, "non-broadcast", &idx
))
6735 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_NBMA
;
6736 else if (argv_find (argv
, argc
, "point-to-multipoint", &idx
))
6737 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOMULTIPOINT
;
6738 else if (argv_find (argv
, argc
, "point-to-point", &idx
))
6739 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOPOINT
;
6741 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
6744 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), type
);
6746 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6748 struct ospf_interface
*oi
= rn
->info
;
6753 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
6755 if (oi
->state
> ISM_Down
)
6757 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
6758 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
6765 DEFUN_HIDDEN (ospf_network
,
6767 "ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
6768 "OSPF interface commands\n"
6770 "Specify OSPF broadcast multi-access network\n"
6771 "Specify OSPF NBMA network\n"
6772 "Specify OSPF point-to-multipoint network\n"
6773 "Specify OSPF point-to-point network\n")
6775 return ip_ospf_network (self
, vty
, argc
, argv
);
6778 DEFUN (no_ip_ospf_network
,
6779 no_ip_ospf_network_cmd
,
6780 "no ip ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
6783 "OSPF interface commands\n"
6785 "Specify OSPF broadcast multi-access network\n"
6786 "Specify OSPF NBMA network\n"
6787 "Specify OSPF point-to-multipoint network\n"
6788 "Specify OSPF point-to-point network\n")
6790 struct interface
*ifp
= vty
->index
;
6791 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
6792 struct route_node
*rn
;
6794 IF_DEF_PARAMS (ifp
)->type
= ospf_default_iftype(ifp
);
6796 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
6799 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6801 struct ospf_interface
*oi
= rn
->info
;
6806 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
6808 if (oi
->state
> ISM_Down
)
6810 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
6811 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
6818 DEFUN_HIDDEN (no_ospf_network
,
6819 no_ospf_network_cmd
,
6820 "no ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
6822 "OSPF interface commands\n"
6824 "Specify OSPF broadcast multi-access network\n"
6825 "Specify OSPF NBMA network\n"
6826 "Specify OSPF point-to-multipoint network\n"
6827 "Specify OSPF point-to-point network\n")
6829 return no_ip_ospf_network (self
, vty
, argc
, argv
);
6832 DEFUN (ip_ospf_priority
,
6833 ip_ospf_priority_cmd
,
6834 "ip ospf priority (0-255) [A.B.C.D]",
6836 "OSPF interface commands\n"
6839 "Address of interface")
6842 struct interface
*ifp
= vty
->index
;
6844 struct route_node
*rn
;
6845 struct in_addr addr
;
6846 struct ospf_if_params
*params
;
6847 params
= IF_DEF_PARAMS (ifp
);
6849 argv_find (argv
, argc
, "(0-255)", &idx
);
6850 priority
= strtol (argv
[idx
]->arg
, NULL
, 10);
6852 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6854 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6856 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6861 params
= ospf_get_if_params (ifp
, addr
);
6862 ospf_if_update_params (ifp
, addr
);
6865 SET_IF_PARAM (params
, priority
);
6866 params
->priority
= priority
;
6868 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6870 struct ospf_interface
*oi
= rn
->info
;
6875 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
6877 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
6878 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
6885 DEFUN_HIDDEN (ospf_priority
,
6887 "ospf priority (0-255) [A.B.C.D]",
6888 "OSPF interface commands\n"
6891 "Address of interface")
6893 return ip_ospf_priority (self
, vty
, argc
, argv
);
6896 DEFUN (no_ip_ospf_priority
,
6897 no_ip_ospf_priority_cmd
,
6898 "no ip ospf priority [(0-255) [A.B.C.D]]",
6901 "OSPF interface commands\n"
6902 "Router priority\n" // ignored
6904 "Address of interface")
6907 struct interface
*ifp
= vty
->index
;
6908 struct route_node
*rn
;
6909 struct in_addr addr
;
6910 struct ospf_if_params
*params
;
6913 params
= IF_DEF_PARAMS (ifp
);
6915 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6917 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6919 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6924 params
= ospf_lookup_if_params (ifp
, addr
);
6929 UNSET_IF_PARAM (params
, priority
);
6930 params
->priority
= OSPF_ROUTER_PRIORITY_DEFAULT
;
6932 if (params
!= IF_DEF_PARAMS (ifp
))
6934 ospf_free_if_params (ifp
, addr
);
6935 ospf_if_update_params (ifp
, addr
);
6938 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6940 struct ospf_interface
*oi
= rn
->info
;
6945 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
6947 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
6948 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
6955 DEFUN_HIDDEN (no_ospf_priority
,
6956 no_ospf_priority_cmd
,
6957 "no ospf priority [(0-255) [A.B.C.D]]",
6959 "OSPF interface commands\n"
6962 "Address of interface")
6964 return no_ip_ospf_priority (self
, vty
, argc
, argv
);
6967 DEFUN (ip_ospf_retransmit_interval
,
6968 ip_ospf_retransmit_interval_addr_cmd
,
6969 "ip ospf retransmit-interval (3-65535) [A.B.C.D]",
6971 "OSPF interface commands\n"
6972 "Time between retransmitting lost link state advertisements\n"
6974 "Address of interface")
6977 struct interface
*ifp
= vty
->index
;
6979 struct in_addr addr
;
6980 struct ospf_if_params
*params
;
6981 params
= IF_DEF_PARAMS (ifp
);
6983 argv_find (argv
, argc
, "(3-65535)", &idx
);
6984 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
6986 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6988 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6990 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6995 params
= ospf_get_if_params (ifp
, addr
);
6996 ospf_if_update_params (ifp
, addr
);
6999 SET_IF_PARAM (params
, retransmit_interval
);
7000 params
->retransmit_interval
= seconds
;
7005 DEFUN_HIDDEN (ospf_retransmit_interval
,
7006 ospf_retransmit_interval_cmd
,
7007 "ospf retransmit-interval (3-65535) [A.B.C.D]",
7008 "OSPF interface commands\n"
7009 "Time between retransmitting lost link state advertisements\n"
7011 "Address of interface")
7013 return ip_ospf_retransmit_interval (self
, vty
, argc
, argv
);
7016 DEFUN (no_ip_ospf_retransmit_interval
,
7017 no_ip_ospf_retransmit_interval_addr_cmd
,
7018 "no ip ospf retransmit-interval [(3-65535)] [A.B.C.D]",
7021 "OSPF interface commands\n"
7022 "Time between retransmitting lost link state advertisements\n"
7024 "Address of interface\n")
7027 struct interface
*ifp
= vty
->index
;
7028 struct in_addr addr
;
7029 struct ospf_if_params
*params
;
7032 params
= IF_DEF_PARAMS (ifp
);
7034 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
7036 if (!inet_aton(argv
[idx
]->arg
, &addr
))
7038 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7043 params
= ospf_lookup_if_params (ifp
, addr
);
7048 UNSET_IF_PARAM (params
, retransmit_interval
);
7049 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
7051 if (params
!= IF_DEF_PARAMS (ifp
))
7053 ospf_free_if_params (ifp
, addr
);
7054 ospf_if_update_params (ifp
, addr
);
7060 DEFUN_HIDDEN (no_ospf_retransmit_interval
,
7061 no_ospf_retransmit_interval_cmd
,
7062 "no ospf retransmit-interval [(3-65535)] [A.B.C.D]",
7064 "OSPF interface commands\n"
7065 "Time between retransmitting lost link state advertisements\n"
7067 "Address of interface\n")
7069 return no_ip_ospf_retransmit_interval (self
, vty
, argc
, argv
);
7072 DEFUN (ip_ospf_transmit_delay
,
7073 ip_ospf_transmit_delay_addr_cmd
,
7074 "ip ospf transmit-delay (1-65535) [A.B.C.D]",
7076 "OSPF interface commands\n"
7077 "Link state transmit delay\n"
7079 "Address of interface")
7082 struct interface
*ifp
= vty
->index
;
7084 struct in_addr addr
;
7085 struct ospf_if_params
*params
;
7087 params
= IF_DEF_PARAMS (ifp
);
7088 argv_find (argv
, argc
, "(1-65535)", &idx
);
7089 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
7091 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
7093 if (!inet_aton(argv
[idx
]->arg
, &addr
))
7095 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7100 params
= ospf_get_if_params (ifp
, addr
);
7101 ospf_if_update_params (ifp
, addr
);
7104 SET_IF_PARAM (params
, transmit_delay
);
7105 params
->transmit_delay
= seconds
;
7110 DEFUN_HIDDEN (ospf_transmit_delay
,
7111 ospf_transmit_delay_cmd
,
7112 "ospf transmit-delay (1-65535) [A.B.C.D]",
7113 "OSPF interface commands\n"
7114 "Link state transmit delay\n"
7116 "Address of interface")
7118 return ip_ospf_transmit_delay (self
, vty
, argc
, argv
);
7121 DEFUN (no_ip_ospf_transmit_delay
,
7122 no_ip_ospf_transmit_delay_addr_cmd
,
7123 "no ip ospf transmit-delay [(1-65535)] [A.B.C.D]",
7126 "OSPF interface commands\n"
7127 "Link state transmit delay\n"
7128 "Address of interface")
7131 struct interface
*ifp
= vty
->index
;
7132 struct in_addr addr
;
7133 struct ospf_if_params
*params
;
7136 params
= IF_DEF_PARAMS (ifp
);
7138 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
7140 if (!inet_aton(argv
[idx
]->arg
, &addr
))
7142 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7147 params
= ospf_lookup_if_params (ifp
, addr
);
7152 UNSET_IF_PARAM (params
, transmit_delay
);
7153 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
7155 if (params
!= IF_DEF_PARAMS (ifp
))
7157 ospf_free_if_params (ifp
, addr
);
7158 ospf_if_update_params (ifp
, addr
);
7165 DEFUN_HIDDEN (no_ospf_transmit_delay
,
7166 no_ospf_transmit_delay_cmd
,
7167 "no ospf transmit-delay",
7169 "OSPF interface commands\n"
7170 "Link state transmit delay\n")
7172 return no_ip_ospf_transmit_delay (self
, vty
, argc
, argv
);
7175 DEFUN (ip_ospf_area
,
7177 "ip ospf [(1-65535)] area <A.B.C.D|(0-4294967295)>",
7179 "OSPF interface commands\n"
7181 "Enable OSPF on this interface\n"
7182 "OSPF area ID in IP address format\n"
7183 "OSPF area ID as a decimal value\n")
7186 struct interface
*ifp
= vty
->index
;
7188 struct in_addr area_id
;
7190 struct ospf_if_params
*params
;
7191 struct route_node
*rn
;
7192 u_short instance
= 0;
7194 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
7195 instance
= strtol (argv
[idx
]->arg
, NULL
, 10);
7196 char *areaid
= argv
[argc
- 1]->arg
;
7198 ospf
= ospf_lookup_instance (instance
);
7201 params
= IF_DEF_PARAMS (ifp
);
7202 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7204 ospf_interface_unset (ifp
);
7205 ospf
= ospf_lookup();
7206 ospf
->if_ospf_cli_count
--;
7211 ret
= ospf_str2area_id (areaid
, &area_id
, &format
);
7214 vty_out (vty
, "Please specify area by A.B.C.D|<0-4294967295>%s",
7218 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
7220 vty_out (vty
, "Cannot enable OSPF on a virtual link.%s", VTY_NEWLINE
);
7224 params
= IF_DEF_PARAMS (ifp
);
7225 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7228 "Must remove previous area config before changing ospf area %s",
7233 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
7235 if (rn
->info
!= NULL
)
7237 vty_out (vty
, "Please remove all network commands first.%s", VTY_NEWLINE
);
7242 /* enable ospf on this interface with area_id */
7243 ospf_interface_set (ifp
, area_id
);
7244 ospf
->if_ospf_cli_count
++;
7249 DEFUN (no_ip_ospf_area
,
7250 no_ip_ospf_area_cmd
,
7251 "no ip ospf [(1-65535)] area [<A.B.C.D|(0-4294967295)>]",
7254 "OSPF interface commands\n"
7256 "Disable OSPF on this interface\n"
7257 "OSPF area ID in IP address format\n"
7258 "OSPF area ID as a decimal value\n")
7261 struct interface
*ifp
= vty
->index
;
7263 struct ospf_if_params
*params
;
7264 u_short instance
= 0;
7266 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
7267 instance
= strtol (argv
[idx
]->arg
, NULL
, 10);
7269 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
7272 params
= IF_DEF_PARAMS (ifp
);
7273 if (!OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7275 vty_out (vty
, "Can't find specified interface area configuration.%s", VTY_NEWLINE
);
7279 ospf_interface_unset (ifp
);
7280 ospf
->if_ospf_cli_count
--;
7284 DEFUN (ospf_redistribute_source
,
7285 ospf_redistribute_source_cmd
,
7286 "redistribute <kernel|connected|static|rip|isis|bgp|pim|table> [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7288 QUAGGA_REDIST_HELP_STR_OSPFD
7289 "Metric for redistributed routes\n"
7290 "OSPF default metric\n"
7291 "OSPF exterior metric type for redistributed routes\n"
7292 "Set OSPF External Type 1 metrics\n"
7293 "Set OSPF External Type 2 metrics\n"
7294 "Route map reference\n"
7295 "Pointer to route-map entries\n")
7297 int idx_protocol
= 1;
7298 int idx_redist_param
= 2;
7299 struct ospf
*ospf
= vty
->index
;
7303 struct ospf_redist
*red
;
7309 return CMD_WARNING
; /* should not happen */
7314 /* Get distribute source. */
7315 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->arg
);
7316 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
7319 /* Get metric value. */
7320 if (strcmp (argv
[idx_redist_param
]->arg
, "metric") == 0)
7321 if (!str2metric (argv
[idx_redist_param
+1]->arg
, &metric
))
7324 /* Get metric type. */
7325 if (strcmp (argv
[idx_redist_param
]->arg
, "metric-type") == 0)
7326 if (!str2metric_type (argv
[idx_redist_param
+1]->arg
, &type
))
7329 red
= ospf_redist_add(ospf
, source
, 0);
7331 if (strcmp (argv
[idx_redist_param
]->arg
, "route-map") == 0)
7332 ospf_routemap_set (red
, argv
[idx_redist_param
+1]->arg
);
7334 ospf_routemap_unset (red
);
7336 return ospf_redistribute_set (ospf
, source
, 0, type
, metric
);
7339 DEFUN (no_ospf_redistribute_source
,
7340 no_ospf_redistribute_source_cmd
,
7341 "no redistribute <kernel|connected|static|rip|isis|bgp|pim|table> [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7344 QUAGGA_REDIST_HELP_STR_OSPFD
7345 "Metric for redistributed routes\n"
7346 "OSPF default metric\n"
7347 "OSPF exterior metric type for redistributed routes\n"
7348 "Set OSPF External Type 1 metrics\n"
7349 "Set OSPF External Type 2 metrics\n"
7350 "Route map reference\n"
7351 "Pointer to route-map entries\n")
7353 int idx_protocol
= 2;
7354 struct ospf
*ospf
= vty
->index
;
7356 struct ospf_redist
*red
;
7360 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->arg
);
7361 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
7364 red
= ospf_redist_lookup(ospf
, source
, 0);
7368 ospf_routemap_unset (red
);
7369 return ospf_redistribute_unset (ospf
, source
, 0);
7372 DEFUN (ospf_redistribute_instance_source
,
7373 ospf_redistribute_instance_source_cmd
,
7374 "redistribute <ospf|table> (1-65535) [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7376 "Open Shortest Path First\n"
7377 "Non-main Kernel Routing Table\n"
7378 "Instance ID/Table ID\n"
7379 "Metric for redistributed routes\n"
7380 "OSPF default metric\n"
7381 "OSPF exterior metric type for redistributed routes\n"
7382 "Set OSPF External Type 1 metrics\n"
7383 "Set OSPF External Type 2 metrics\n"
7384 "Route map reference\n"
7385 "Pointer to route-map entries\n")
7387 int idx_ospf_table
= 1;
7389 int idx_redist_param
= 3;
7390 struct ospf
*ospf
= vty
->index
;
7395 struct ospf_redist
*red
;
7400 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
7401 source
= ZEBRA_ROUTE_OSPF
;
7403 source
= ZEBRA_ROUTE_TABLE
;
7405 VTY_GET_INTEGER ("Instance ID", instance
, argv
[idx_number
]->arg
);
7410 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
7412 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
7417 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
7419 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
7424 /* Get metric value. */
7425 if (strcmp (argv
[idx_redist_param
]->arg
, "metric") == 0)
7426 if (!str2metric (argv
[idx_redist_param
+1]->arg
, &metric
))
7429 /* Get metric type. */
7430 if (strcmp (argv
[idx_redist_param
]->arg
, "metric-type") == 0)
7431 if (!str2metric_type (argv
[idx_redist_param
+1]->arg
, &type
))
7434 red
= ospf_redist_add(ospf
, source
, instance
);
7436 if (strcmp (argv
[idx_redist_param
]->arg
, "route-map") == 0)
7437 ospf_routemap_set (red
, argv
[idx_redist_param
+1]->arg
);
7439 ospf_routemap_unset (red
);
7441 return ospf_redistribute_set (ospf
, source
, instance
, type
, metric
);
7444 DEFUN (no_ospf_redistribute_instance_source
,
7445 no_ospf_redistribute_instance_source_cmd
,
7446 "no redistribute <ospf|table> (1-65535) [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7449 "Open Shortest Path First\n"
7450 "Non-main Kernel Routing Table\n"
7451 "Instance ID/Table Id\n"
7452 "Metric for redistributed routes\n"
7453 "OSPF default metric\n"
7454 "OSPF exterior metric type for redistributed routes\n"
7455 "Set OSPF External Type 1 metrics\n"
7456 "Set OSPF External Type 2 metrics\n"
7457 "Route map reference\n"
7458 "Pointer to route-map entries\n")
7460 int idx_ospf_table
= 2;
7462 struct ospf
*ospf
= vty
->index
;
7464 struct ospf_redist
*red
;
7470 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
7471 source
= ZEBRA_ROUTE_OSPF
;
7473 source
= ZEBRA_ROUTE_TABLE
;
7475 VTY_GET_INTEGER ("Instance ID", instance
, argv
[idx_number
]->arg
);
7477 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
7479 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
7484 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
7486 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
7491 red
= ospf_redist_lookup(ospf
, source
, instance
);
7495 ospf_routemap_unset (red
);
7496 return ospf_redistribute_unset (ospf
, source
, instance
);
7499 DEFUN (ospf_distribute_list_out
,
7500 ospf_distribute_list_out_cmd
,
7501 "distribute-list WORD out <kernel|connected|static|rip|isis|bgp|pim|table>",
7502 "Filter networks in routing updates\n"
7503 "Access-list name\n"
7505 QUAGGA_REDIST_HELP_STR_OSPFD
)
7508 struct ospf
*ospf
= vty
->index
;
7514 /* Get distribute source. */
7515 source
= proto_redistnum(AFI_IP
, argv
[4]->arg
);
7516 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
7519 return ospf_distribute_list_out_set (ospf
, source
, argv
[idx_word
]->arg
);
7522 DEFUN (no_ospf_distribute_list_out
,
7523 no_ospf_distribute_list_out_cmd
,
7524 "no distribute-list WORD out <kernel|connected|static|rip|isis|bgp|pim|table>",
7526 "Filter networks in routing updates\n"
7527 "Access-list name\n"
7529 QUAGGA_REDIST_HELP_STR_OSPFD
)
7532 struct ospf
*ospf
= vty
->index
;
7538 source
= proto_redistnum(AFI_IP
, argv
[5]->arg
);
7539 if (source
< 0 || source
== ZEBRA_ROUTE_OSPF
)
7542 return ospf_distribute_list_out_unset (ospf
, source
, argv
[idx_word
]->arg
);
7545 /* Default information originate. */
7546 DEFUN (ospf_default_information_originate
,
7547 ospf_default_information_originate_cmd
,
7548 "default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7549 "Control distribution of default information\n"
7550 "Distribute a default route\n"
7551 "Always advertise default route\n"
7552 "OSPF default metric\n"
7554 "OSPF metric type for default routes\n"
7555 "Set OSPF External Type 1 metrics\n"
7556 "Set OSPF External Type 2 metrics\n"
7557 "Route map reference\n"
7558 "Pointer to route-map entries\n")
7560 int idx_redist_param
= 2;
7561 struct ospf
*ospf
= vty
->index
;
7562 int default_originate
= DEFAULT_ORIGINATE_ZEBRA
;
7565 struct ospf_redist
*red
;
7571 return CMD_WARNING
; /* this should not happen */
7573 /* Check whether "always" was specified */
7574 if (argv
[idx_redist_param
]->arg
!= NULL
)
7575 default_originate
= DEFAULT_ORIGINATE_ALWAYS
;
7577 red
= ospf_redist_add(ospf
, DEFAULT_ROUTE
, 0);
7579 /* Get metric value. */
7580 if (strcmp (argv
[idx_redist_param
]->arg
, "metric") == 0)
7581 if (!str2metric (argv
[idx_redist_param
+1]->arg
, &metric
))
7584 /* Get metric type. */
7585 if (strcmp (argv
[idx_redist_param
]->arg
, "metric-type") == 0)
7586 if (!str2metric_type (argv
[idx_redist_param
+1]->arg
, &type
))
7589 if (strcmp (argv
[idx_redist_param
]->arg
, "route-map") == 0)
7590 ospf_routemap_set (red
, argv
[idx_redist_param
+1]->arg
);
7592 ospf_routemap_unset (red
);
7594 return ospf_redistribute_default_set (ospf
, default_originate
,
7598 DEFUN (no_ospf_default_information_originate
,
7599 no_ospf_default_information_originate_cmd
,
7600 "no default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7602 "Control distribution of default information\n"
7603 "Distribute a default route\n"
7604 "Always advertise default route\n"
7605 "OSPF default metric\n"
7607 "OSPF metric type for default routes\n"
7608 "Set OSPF External Type 1 metrics\n"
7609 "Set OSPF External Type 2 metrics\n"
7610 "Route map reference\n"
7611 "Pointer to route-map entries\n")
7613 struct ospf
*ospf
= vty
->index
;
7614 struct prefix_ipv4 p
;
7615 struct ospf_external
*ext
;
7616 struct ospf_redist
*red
;
7622 p
.prefix
.s_addr
= 0;
7625 ospf_external_lsa_flush (ospf
, DEFAULT_ROUTE
, &p
, 0);
7627 if ((ext
= ospf_external_lookup(DEFAULT_ROUTE
, 0)) &&
7628 EXTERNAL_INFO (ext
)) {
7629 ospf_external_info_delete (DEFAULT_ROUTE
, 0, p
);
7630 ospf_external_del (DEFAULT_ROUTE
, 0);
7633 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
7637 ospf_routemap_unset (red
);
7638 return ospf_redistribute_default_unset (ospf
);
7641 DEFUN (ospf_default_metric
,
7642 ospf_default_metric_cmd
,
7643 "default-metric (0-16777214)",
7644 "Set metric of redistributed routes\n"
7648 struct ospf
*ospf
= vty
->index
;
7654 if (!str2metric (argv
[idx_number
]->arg
, &metric
))
7657 ospf
->default_metric
= metric
;
7662 DEFUN (no_ospf_default_metric
,
7663 no_ospf_default_metric_cmd
,
7664 "no default-metric [(0-16777214)]",
7666 "Set metric of redistributed routes\n"
7669 struct ospf
*ospf
= vty
->index
;
7674 ospf
->default_metric
= -1;
7680 DEFUN (ospf_distance
,
7683 "Define an administrative distance\n"
7684 "OSPF Administrative distance\n")
7687 struct ospf
*ospf
= vty
->index
;
7692 ospf
->distance_all
= atoi (argv
[idx_number
]->arg
);
7697 DEFUN (no_ospf_distance
,
7698 no_ospf_distance_cmd
,
7699 "no distance (1-255)",
7701 "Define an administrative distance\n"
7702 "OSPF Administrative distance\n")
7704 struct ospf
*ospf
= vty
->index
;
7709 ospf
->distance_all
= 0;
7714 DEFUN (no_ospf_distance_ospf
,
7715 no_ospf_distance_ospf_cmd
,
7716 "no distance ospf [<intra-area (1-255)|inter-area (1-255)|external (1-255)>]",
7718 "Define an administrative distance\n"
7719 "OSPF Administrative distance\n"
7720 "Intra-area routes\n"
7721 "Distance for intra-area routes\n"
7722 "Inter-area routes\n"
7723 "Distance for inter-area routes\n"
7725 "Distance for external routes\n")
7727 int idx_area_distance
= 3;
7728 struct ospf
*ospf
= vty
->index
;
7739 if (argv
[idx_area_distance
]->arg
!= NULL
)
7740 ospf
->distance_intra
= 0;
7742 if (argv
[1] != NULL
)
7743 ospf
->distance_inter
= 0;
7745 if (argv
[2] != NULL
)
7746 ospf
->distance_external
= 0;
7748 if (argv
[idx_area_distance
]->arg
|| argv
[1] || argv
[2])
7751 /* If no arguments are given, clear all distance information */
7752 ospf
->distance_intra
= 0;
7753 ospf
->distance_inter
= 0;
7754 ospf
->distance_external
= 0;
7759 DEFUN (ospf_distance_ospf
,
7760 ospf_distance_ospf_cmd
,
7761 "distance ospf [<intra-area (1-255)|inter-area (1-255)|external (1-255)>]",
7762 "Define an administrative distance\n"
7763 "OSPF Administrative distance\n"
7764 "Intra-area routes\n"
7765 "Distance for intra-area routes\n"
7766 "Inter-area routes\n"
7767 "Distance for inter-area routes\n"
7769 "Distance for external routes\n")
7771 int idx_area_distance
= 2;
7772 struct ospf
*ospf
= vty
->index
;
7777 if (argc
< 3) /* should not happen */
7780 if (!argv
[idx_area_distance
]->arg
&& !argv
[1] && !argv
[2])
7782 vty_out(vty
, "%% Command incomplete. (Arguments required)%s",
7787 if (strcmp (argv
[idx_area_distance
]->text
, "intra") == 0)
7788 ospf
->distance_intra
= atoi(argv
[idx_area_distance
+1]->arg
);
7790 if (strcmp (argv
[idx_area_distance
]->text
, "inter") == 0)
7791 ospf
->distance_inter
= atoi(argv
[idx_area_distance
+1]->arg
);
7793 if (strcmp (argv
[idx_area_distance
]->text
, "external") == 0)
7794 ospf
->distance_external
= atoi(argv
[idx_area_distance
+1]->arg
);
7799 DEFUN (ospf_distance_source
,
7800 ospf_distance_source_cmd
,
7801 "distance (1-255) A.B.C.D/M",
7802 "Administrative distance\n"
7804 "IP source prefix\n")
7807 int idx_ipv4_prefixlen
= 2;
7808 struct ospf
*ospf
= vty
->index
;
7813 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
7818 DEFUN (no_ospf_distance_source
,
7819 no_ospf_distance_source_cmd
,
7820 "no distance (1-255) A.B.C.D/M",
7822 "Administrative distance\n"
7824 "IP source prefix\n")
7827 int idx_ipv4_prefixlen
= 3;
7828 struct ospf
*ospf
= vty
->index
;
7833 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
7838 DEFUN (ospf_distance_source_access_list
,
7839 ospf_distance_source_access_list_cmd
,
7840 "distance (1-255) A.B.C.D/M WORD",
7841 "Administrative distance\n"
7843 "IP source prefix\n"
7844 "Access list name\n")
7847 int idx_ipv4_prefixlen
= 2;
7849 struct ospf
*ospf
= vty
->index
;
7854 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
7859 DEFUN (no_ospf_distance_source_access_list
,
7860 no_ospf_distance_source_access_list_cmd
,
7861 "no distance (1-255) A.B.C.D/M WORD",
7863 "Administrative distance\n"
7865 "IP source prefix\n"
7866 "Access list name\n")
7869 int idx_ipv4_prefixlen
= 3;
7871 struct ospf
*ospf
= vty
->index
;
7876 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
7881 DEFUN (ip_ospf_mtu_ignore
,
7882 ip_ospf_mtu_ignore_addr_cmd
,
7883 "ip ospf mtu-ignore [A.B.C.D]",
7885 "OSPF interface commands\n"
7886 "Disable MTU mismatch detection on this interface\n"
7887 "Address of interface")
7890 struct interface
*ifp
= vty
->index
;
7891 struct in_addr addr
;
7894 struct ospf_if_params
*params
;
7895 params
= IF_DEF_PARAMS (ifp
);
7899 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7902 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7906 params
= ospf_get_if_params (ifp
, addr
);
7907 ospf_if_update_params (ifp
, addr
);
7909 params
->mtu_ignore
= 1;
7910 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
7911 SET_IF_PARAM (params
, mtu_ignore
);
7914 UNSET_IF_PARAM (params
, mtu_ignore
);
7915 if (params
!= IF_DEF_PARAMS (ifp
))
7917 ospf_free_if_params (ifp
, addr
);
7918 ospf_if_update_params (ifp
, addr
);
7924 DEFUN (no_ip_ospf_mtu_ignore
,
7925 no_ip_ospf_mtu_ignore_addr_cmd
,
7926 "no ip ospf mtu-ignore [A.B.C.D]",
7928 "OSPF interface commands\n"
7929 "Disable MTU mismatch detection on this interface\n"
7930 "Address of interface")
7933 struct interface
*ifp
= vty
->index
;
7934 struct in_addr addr
;
7937 struct ospf_if_params
*params
;
7938 params
= IF_DEF_PARAMS (ifp
);
7942 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7945 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7949 params
= ospf_get_if_params (ifp
, addr
);
7950 ospf_if_update_params (ifp
, addr
);
7952 params
->mtu_ignore
= 0;
7953 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
7954 SET_IF_PARAM (params
, mtu_ignore
);
7957 UNSET_IF_PARAM (params
, mtu_ignore
);
7958 if (params
!= IF_DEF_PARAMS (ifp
))
7960 ospf_free_if_params (ifp
, addr
);
7961 ospf_if_update_params (ifp
, addr
);
7968 DEFUN (ospf_max_metric_router_lsa_admin
,
7969 ospf_max_metric_router_lsa_admin_cmd
,
7970 "max-metric router-lsa administrative",
7971 "OSPF maximum / infinite-distance metric\n"
7972 "Advertise own Router-LSA with infinite distance (stub router)\n"
7973 "Administratively applied, for an indefinite period\n")
7975 struct listnode
*ln
;
7976 struct ospf_area
*area
;
7977 struct ospf
*ospf
= vty
->index
;
7982 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7984 SET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
7986 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
))
7987 ospf_router_lsa_update_area (area
);
7990 /* Allows for areas configured later to get the property */
7991 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_SET
;
7996 DEFUN (no_ospf_max_metric_router_lsa_admin
,
7997 no_ospf_max_metric_router_lsa_admin_cmd
,
7998 "no max-metric router-lsa administrative",
8000 "OSPF maximum / infinite-distance metric\n"
8001 "Advertise own Router-LSA with infinite distance (stub router)\n"
8002 "Administratively applied, for an indefinite period\n")
8004 struct listnode
*ln
;
8005 struct ospf_area
*area
;
8006 struct ospf
*ospf
= vty
->index
;
8011 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
8013 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
8015 /* Don't trample on the start-up stub timer */
8016 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
)
8017 && !area
->t_stub_router
)
8019 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
8020 ospf_router_lsa_update_area (area
);
8023 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET
;
8027 DEFUN (ospf_max_metric_router_lsa_startup
,
8028 ospf_max_metric_router_lsa_startup_cmd
,
8029 "max-metric router-lsa on-startup (5-86400)",
8030 "OSPF maximum / infinite-distance metric\n"
8031 "Advertise own Router-LSA with infinite distance (stub router)\n"
8032 "Automatically advertise stub Router-LSA on startup of OSPF\n"
8033 "Time (seconds) to advertise self as stub-router\n")
8036 unsigned int seconds
;
8037 struct ospf
*ospf
= vty
->index
;
8044 vty_out (vty
, "%% Must supply stub-router period");
8048 VTY_GET_INTEGER ("stub-router startup period", seconds
, argv
[idx_number
]->arg
);
8050 ospf
->stub_router_startup_time
= seconds
;
8055 DEFUN (no_ospf_max_metric_router_lsa_startup
,
8056 no_ospf_max_metric_router_lsa_startup_cmd
,
8057 "no max-metric router-lsa on-startup [(5-86400)]",
8059 "OSPF maximum / infinite-distance metric\n"
8060 "Advertise own Router-LSA with infinite distance (stub router)\n"
8061 "Automatically advertise stub Router-LSA on startup of OSPF\n"
8062 "Time (seconds) to advertise self as stub-router\n")
8064 struct listnode
*ln
;
8065 struct ospf_area
*area
;
8066 struct ospf
*ospf
= vty
->index
;
8071 ospf
->stub_router_startup_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
8073 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
8075 SET_FLAG (area
->stub_router_state
, OSPF_AREA_WAS_START_STUB_ROUTED
);
8076 OSPF_TIMER_OFF (area
->t_stub_router
);
8078 /* Don't trample on admin stub routed */
8079 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
8081 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
8082 ospf_router_lsa_update_area (area
);
8089 DEFUN (ospf_max_metric_router_lsa_shutdown
,
8090 ospf_max_metric_router_lsa_shutdown_cmd
,
8091 "max-metric router-lsa on-shutdown (5-100)",
8092 "OSPF maximum / infinite-distance metric\n"
8093 "Advertise own Router-LSA with infinite distance (stub router)\n"
8094 "Advertise stub-router prior to full shutdown of OSPF\n"
8095 "Time (seconds) to wait till full shutdown\n")
8098 unsigned int seconds
;
8099 struct ospf
*ospf
= vty
->index
;
8106 vty_out (vty
, "%% Must supply stub-router shutdown period");
8110 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds
, argv
[idx_number
]->arg
);
8112 ospf
->stub_router_shutdown_time
= seconds
;
8117 DEFUN (no_ospf_max_metric_router_lsa_shutdown
,
8118 no_ospf_max_metric_router_lsa_shutdown_cmd
,
8119 "no max-metric router-lsa on-shutdown [(5-100)]",
8121 "OSPF maximum / infinite-distance metric\n"
8122 "Advertise own Router-LSA with infinite distance (stub router)\n"
8123 "Advertise stub-router prior to full shutdown of OSPF\n"
8124 "Time (seconds) to wait till full shutdown\n")
8126 struct ospf
*ospf
= vty
->index
;
8131 ospf
->stub_router_shutdown_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
8137 config_write_stub_router (struct vty
*vty
, struct ospf
*ospf
)
8139 struct listnode
*ln
;
8140 struct ospf_area
*area
;
8142 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
8143 vty_out (vty
, " max-metric router-lsa on-startup %u%s",
8144 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
8145 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
8146 vty_out (vty
, " max-metric router-lsa on-shutdown %u%s",
8147 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
8148 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
8150 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
8152 vty_out (vty
, " max-metric router-lsa administrative%s",
8161 show_ip_ospf_route_network (struct vty
*vty
, struct route_table
*rt
)
8163 struct route_node
*rn
;
8164 struct ospf_route
*or;
8165 struct listnode
*pnode
, *pnnode
;
8166 struct ospf_path
*path
;
8168 vty_out (vty
, "============ OSPF network routing table ============%s",
8171 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
8172 if ((or = rn
->info
) != NULL
)
8175 snprintf (buf1
, 19, "%s/%d",
8176 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
8178 switch (or->path_type
)
8180 case OSPF_PATH_INTER_AREA
:
8181 if (or->type
== OSPF_DESTINATION_NETWORK
)
8182 vty_out (vty
, "N IA %-18s [%d] area: %s%s", buf1
, or->cost
,
8183 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
8184 else if (or->type
== OSPF_DESTINATION_DISCARD
)
8185 vty_out (vty
, "D IA %-18s Discard entry%s", buf1
, VTY_NEWLINE
);
8187 case OSPF_PATH_INTRA_AREA
:
8188 vty_out (vty
, "N %-18s [%d] area: %s%s", buf1
, or->cost
,
8189 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
8195 if (or->type
== OSPF_DESTINATION_NETWORK
)
8196 for (ALL_LIST_ELEMENTS (or->paths
, pnode
, pnnode
, path
))
8198 if (if_lookup_by_index(path
->ifindex
))
8200 if (path
->nexthop
.s_addr
== 0)
8201 vty_out (vty
, "%24s directly attached to %s%s",
8202 "", ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
8204 vty_out (vty
, "%24s via %s, %s%s", "",
8205 inet_ntoa (path
->nexthop
),
8206 ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
8210 vty_out (vty
, "%s", VTY_NEWLINE
);
8214 show_ip_ospf_route_router (struct vty
*vty
, struct route_table
*rtrs
)
8216 struct route_node
*rn
;
8217 struct ospf_route
*or;
8218 struct listnode
*pnode
;
8219 struct listnode
*node
;
8220 struct ospf_path
*path
;
8222 vty_out (vty
, "============ OSPF router routing table =============%s",
8224 for (rn
= route_top (rtrs
); rn
; rn
= route_next (rn
))
8229 vty_out (vty
, "R %-15s ", inet_ntoa (rn
->p
.u
.prefix4
));
8231 for (ALL_LIST_ELEMENTS_RO ((struct list
*)rn
->info
, node
, or))
8234 vty_out (vty
, "%24s", "");
8237 vty_out (vty
, "%s [%d] area: %s",
8238 (or->path_type
== OSPF_PATH_INTER_AREA
? "IA" : " "),
8239 or->cost
, inet_ntoa (or->u
.std
.area_id
));
8241 vty_out (vty
, "%s%s%s",
8242 (or->u
.std
.flags
& ROUTER_LSA_BORDER
? ", ABR" : ""),
8243 (or->u
.std
.flags
& ROUTER_LSA_EXTERNAL
? ", ASBR" : ""),
8246 for (ALL_LIST_ELEMENTS_RO (or->paths
, pnode
, path
))
8248 if (if_lookup_by_index(path
->ifindex
))
8250 if (path
->nexthop
.s_addr
== 0)
8251 vty_out (vty
, "%24s directly attached to %s%s",
8252 "", ifindex2ifname (path
->ifindex
),
8255 vty_out (vty
, "%24s via %s, %s%s", "",
8256 inet_ntoa (path
->nexthop
),
8257 ifindex2ifname (path
->ifindex
),
8263 vty_out (vty
, "%s", VTY_NEWLINE
);
8267 show_ip_ospf_route_external (struct vty
*vty
, struct route_table
*rt
)
8269 struct route_node
*rn
;
8270 struct ospf_route
*er
;
8271 struct listnode
*pnode
, *pnnode
;
8272 struct ospf_path
*path
;
8274 vty_out (vty
, "============ OSPF external routing table ===========%s",
8276 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
8277 if ((er
= rn
->info
) != NULL
)
8280 snprintf (buf1
, 19, "%s/%d",
8281 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
8283 switch (er
->path_type
)
8285 case OSPF_PATH_TYPE1_EXTERNAL
:
8286 vty_out (vty
, "N E1 %-18s [%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
,
8287 er
->cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
8289 case OSPF_PATH_TYPE2_EXTERNAL
:
8290 vty_out (vty
, "N E2 %-18s [%d/%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
, er
->cost
,
8291 er
->u
.ext
.type2_cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
8295 for (ALL_LIST_ELEMENTS (er
->paths
, pnode
, pnnode
, path
))
8297 if (if_lookup_by_index(path
->ifindex
))
8299 if (path
->nexthop
.s_addr
== 0)
8300 vty_out (vty
, "%24s directly attached to %s%s",
8301 "", ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
8303 vty_out (vty
, "%24s via %s, %s%s", "",
8304 inet_ntoa (path
->nexthop
),
8305 ifindex2ifname (path
->ifindex
),
8310 vty_out (vty
, "%s", VTY_NEWLINE
);
8314 show_ip_ospf_border_routers_common (struct vty
*vty
, struct ospf
*ospf
)
8317 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
8318 VTY_NEWLINE
, VTY_NEWLINE
);
8320 if (ospf
->new_table
== NULL
)
8322 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
8326 /* Show Network routes.
8327 show_ip_ospf_route_network (vty, ospf->new_table); */
8329 /* Show Router routes. */
8330 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
8332 vty_out (vty
, "%s", VTY_NEWLINE
);
8337 DEFUN (show_ip_ospf_border_routers
,
8338 show_ip_ospf_border_routers_cmd
,
8339 "show ip ospf border-routers",
8342 "OSPF information\n"
8343 "Show all the ABR's and ASBR's\n")
8347 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
8350 return show_ip_ospf_border_routers_common(vty
, ospf
);
8353 DEFUN (show_ip_ospf_instance_border_routers
,
8354 show_ip_ospf_instance_border_routers_cmd
,
8355 "show ip ospf (1-65535) border-routers",
8358 "OSPF information\n"
8360 "Show all the ABR's and ASBR's\n")
8364 u_short instance
= 0;
8366 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
8367 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
8370 return show_ip_ospf_border_routers_common(vty
, ospf
);
8374 show_ip_ospf_route_common (struct vty
*vty
, struct ospf
*ospf
)
8377 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
8378 VTY_NEWLINE
, VTY_NEWLINE
);
8380 if (ospf
->new_table
== NULL
)
8382 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
8386 /* Show Network routes. */
8387 show_ip_ospf_route_network (vty
, ospf
->new_table
);
8389 /* Show Router routes. */
8390 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
8392 /* Show AS External routes. */
8393 show_ip_ospf_route_external (vty
, ospf
->old_external_route
);
8395 vty_out (vty
, "%s", VTY_NEWLINE
);
8400 DEFUN (show_ip_ospf_route
,
8401 show_ip_ospf_route_cmd
,
8402 "show ip ospf route",
8405 "OSPF information\n"
8406 "OSPF routing table\n")
8410 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
8413 return show_ip_ospf_route_common(vty
, ospf
);
8416 DEFUN (show_ip_ospf_instance_route
,
8417 show_ip_ospf_instance_route_cmd
,
8418 "show ip ospf (1-65535) route",
8421 "OSPF information\n"
8423 "OSPF routing table\n")
8427 u_short instance
= 0;
8429 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
8430 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
8433 return show_ip_ospf_route_common(vty
, ospf
);
8436 const char *ospf_abr_type_str
[] =
8445 const char *ospf_shortcut_mode_str
[] =
8454 area_id2str (char *buf
, int length
, struct ospf_area
*area
)
8456 memset (buf
, 0, length
);
8458 if (area
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
8459 strncpy (buf
, inet_ntoa (area
->area_id
), length
);
8461 sprintf (buf
, "%lu", (unsigned long) ntohl (area
->area_id
.s_addr
));
8465 const char *ospf_int_type_str
[] =
8467 "unknown", /* should never be used. */
8471 "point-to-multipoint",
8472 "virtual-link", /* should never be used. */
8476 /* Configuration write function for ospfd. */
8478 config_write_interface (struct vty
*vty
)
8480 struct listnode
*n1
, *n2
;
8481 struct interface
*ifp
;
8482 struct crypt_key
*ck
;
8484 struct route_node
*rn
= NULL
;
8485 struct ospf_if_params
*params
;
8486 struct ospf
*ospf
= ospf_lookup();
8488 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), n1
, ifp
))
8490 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
8493 if (ifp
->ifindex
== IFINDEX_DELETED
)
8496 vty_out (vty
, "!%s", VTY_NEWLINE
);
8497 vty_out (vty
, "interface %s%s", ifp
->name
,
8500 vty_out (vty
, " description %s%s", ifp
->desc
,
8505 params
= IF_DEF_PARAMS (ifp
);
8508 /* Interface Network print. */
8509 if (OSPF_IF_PARAM_CONFIGURED (params
, type
) &&
8510 params
->type
!= OSPF_IFTYPE_LOOPBACK
)
8512 if (params
->type
!= ospf_default_iftype(ifp
))
8514 vty_out (vty
, " ip ospf network %s",
8515 ospf_int_type_str
[params
->type
]);
8516 if (params
!= IF_DEF_PARAMS (ifp
))
8517 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8518 vty_out (vty
, "%s", VTY_NEWLINE
);
8522 /* OSPF interface authentication print */
8523 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_type
) &&
8524 params
->auth_type
!= OSPF_AUTH_NOTSET
)
8526 const char *auth_str
;
8528 /* Translation tables are not that much help here due to syntax
8529 of the simple option */
8530 switch (params
->auth_type
)
8533 case OSPF_AUTH_NULL
:
8537 case OSPF_AUTH_SIMPLE
:
8541 case OSPF_AUTH_CRYPTOGRAPHIC
:
8542 auth_str
= " message-digest";
8550 vty_out (vty
, " ip ospf authentication%s", auth_str
);
8551 if (params
!= IF_DEF_PARAMS (ifp
))
8552 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8553 vty_out (vty
, "%s", VTY_NEWLINE
);
8556 /* Simple Authentication Password print. */
8557 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_simple
) &&
8558 params
->auth_simple
[0] != '\0')
8560 vty_out (vty
, " ip ospf authentication-key %s",
8561 params
->auth_simple
);
8562 if (params
!= IF_DEF_PARAMS (ifp
))
8563 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8564 vty_out (vty
, "%s", VTY_NEWLINE
);
8567 /* Cryptographic Authentication Key print. */
8568 for (ALL_LIST_ELEMENTS_RO (params
->auth_crypt
, n2
, ck
))
8570 vty_out (vty
, " ip ospf message-digest-key %d md5 %s",
8571 ck
->key_id
, ck
->auth_key
);
8572 if (params
!= IF_DEF_PARAMS (ifp
))
8573 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8574 vty_out (vty
, "%s", VTY_NEWLINE
);
8577 /* Interface Output Cost print. */
8578 if (OSPF_IF_PARAM_CONFIGURED (params
, output_cost_cmd
))
8580 vty_out (vty
, " ip ospf cost %u", params
->output_cost_cmd
);
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 /* Hello Interval print. */
8587 if (OSPF_IF_PARAM_CONFIGURED (params
, v_hello
) &&
8588 params
->v_hello
!= OSPF_HELLO_INTERVAL_DEFAULT
)
8590 vty_out (vty
, " ip ospf hello-interval %u", params
->v_hello
);
8591 if (params
!= IF_DEF_PARAMS (ifp
))
8592 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8593 vty_out (vty
, "%s", VTY_NEWLINE
);
8597 /* Router Dead Interval print. */
8598 if (OSPF_IF_PARAM_CONFIGURED (params
, v_wait
) &&
8599 params
->v_wait
!= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
)
8601 vty_out (vty
, " ip ospf dead-interval ");
8604 if (OSPF_IF_PARAM_CONFIGURED (params
, fast_hello
))
8605 vty_out (vty
, "minimal hello-multiplier %d",
8606 params
->fast_hello
);
8608 vty_out (vty
, "%u", params
->v_wait
);
8610 if (params
!= IF_DEF_PARAMS (ifp
))
8611 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8612 vty_out (vty
, "%s", VTY_NEWLINE
);
8615 /* Router Priority print. */
8616 if (OSPF_IF_PARAM_CONFIGURED (params
, priority
) &&
8617 params
->priority
!= OSPF_ROUTER_PRIORITY_DEFAULT
)
8619 vty_out (vty
, " ip ospf priority %u", params
->priority
);
8620 if (params
!= IF_DEF_PARAMS (ifp
))
8621 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8622 vty_out (vty
, "%s", VTY_NEWLINE
);
8625 /* Retransmit Interval print. */
8626 if (OSPF_IF_PARAM_CONFIGURED (params
, retransmit_interval
) &&
8627 params
->retransmit_interval
!= OSPF_RETRANSMIT_INTERVAL_DEFAULT
)
8629 vty_out (vty
, " ip ospf retransmit-interval %u",
8630 params
->retransmit_interval
);
8631 if (params
!= IF_DEF_PARAMS (ifp
))
8632 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8633 vty_out (vty
, "%s", VTY_NEWLINE
);
8636 /* Transmit Delay print. */
8637 if (OSPF_IF_PARAM_CONFIGURED (params
, transmit_delay
) &&
8638 params
->transmit_delay
!= OSPF_TRANSMIT_DELAY_DEFAULT
)
8640 vty_out (vty
, " ip ospf transmit-delay %u", params
->transmit_delay
);
8641 if (params
!= IF_DEF_PARAMS (ifp
))
8642 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8643 vty_out (vty
, "%s", VTY_NEWLINE
);
8647 if (OSPF_IF_PARAM_CONFIGURED (params
, if_area
))
8650 vty_out (vty
, " ip ospf %d area %s%s", ospf
->instance
,
8651 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
8653 vty_out (vty
, " ip ospf area %s%s",
8654 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
8659 ospf_bfd_write_config(vty
, params
);
8661 /* MTU ignore print. */
8662 if (OSPF_IF_PARAM_CONFIGURED (params
, mtu_ignore
) &&
8663 params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
8665 if (params
->mtu_ignore
== 0)
8666 vty_out (vty
, " no ip ospf mtu-ignore");
8668 vty_out (vty
, " ip ospf mtu-ignore");
8669 if (params
!= IF_DEF_PARAMS (ifp
))
8670 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8671 vty_out (vty
, "%s", VTY_NEWLINE
);
8678 rn
= route_top (IF_OIFS_PARAMS (ifp
));
8680 rn
= route_next (rn
);
8690 ospf_opaque_config_write_if (vty
, ifp
);
8697 config_write_network_area (struct vty
*vty
, struct ospf
*ospf
)
8699 struct route_node
*rn
;
8700 u_char buf
[INET_ADDRSTRLEN
];
8702 /* `network area' print. */
8703 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
8706 struct ospf_network
*n
= rn
->info
;
8708 memset (buf
, 0, INET_ADDRSTRLEN
);
8710 /* Create Area ID string by specified Area ID format. */
8711 if (n
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
8712 strncpy ((char *) buf
, inet_ntoa (n
->area_id
), INET_ADDRSTRLEN
);
8714 sprintf ((char *) buf
, "%lu",
8715 (unsigned long int) ntohl (n
->area_id
.s_addr
));
8717 /* Network print. */
8718 vty_out (vty
, " network %s/%d area %s%s",
8719 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
8727 config_write_ospf_area (struct vty
*vty
, struct ospf
*ospf
)
8729 struct listnode
*node
;
8730 struct ospf_area
*area
;
8731 u_char buf
[INET_ADDRSTRLEN
];
8733 /* Area configuration print. */
8734 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
8736 struct route_node
*rn1
;
8738 area_id2str ((char *) buf
, INET_ADDRSTRLEN
, area
);
8740 if (area
->auth_type
!= OSPF_AUTH_NULL
)
8742 if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
8743 vty_out (vty
, " area %s authentication%s", buf
, VTY_NEWLINE
);
8745 vty_out (vty
, " area %s authentication message-digest%s",
8749 if (area
->shortcut_configured
!= OSPF_SHORTCUT_DEFAULT
)
8750 vty_out (vty
, " area %s shortcut %s%s", buf
,
8751 ospf_shortcut_mode_str
[area
->shortcut_configured
],
8754 if ((area
->external_routing
== OSPF_AREA_STUB
)
8755 || (area
->external_routing
== OSPF_AREA_NSSA
)
8758 if (area
->external_routing
== OSPF_AREA_STUB
)
8759 vty_out (vty
, " area %s stub", buf
);
8760 else if (area
->external_routing
== OSPF_AREA_NSSA
)
8762 vty_out (vty
, " area %s nssa", buf
);
8763 switch (area
->NSSATranslatorRole
)
8765 case OSPF_NSSA_ROLE_NEVER
:
8766 vty_out (vty
, " translate-never");
8768 case OSPF_NSSA_ROLE_ALWAYS
:
8769 vty_out (vty
, " translate-always");
8771 case OSPF_NSSA_ROLE_CANDIDATE
:
8773 vty_out (vty
, " translate-candidate");
8777 if (area
->no_summary
)
8778 vty_out (vty
, " no-summary");
8780 vty_out (vty
, "%s", VTY_NEWLINE
);
8782 if (area
->default_cost
!= 1)
8783 vty_out (vty
, " area %s default-cost %d%s", buf
,
8784 area
->default_cost
, VTY_NEWLINE
);
8787 for (rn1
= route_top (area
->ranges
); rn1
; rn1
= route_next (rn1
))
8790 struct ospf_area_range
*range
= rn1
->info
;
8792 vty_out (vty
, " area %s range %s/%d", buf
,
8793 inet_ntoa (rn1
->p
.u
.prefix4
), rn1
->p
.prefixlen
);
8795 if (range
->cost_config
!= OSPF_AREA_RANGE_COST_UNSPEC
)
8796 vty_out (vty
, " cost %d", range
->cost_config
);
8798 if (!CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_ADVERTISE
))
8799 vty_out (vty
, " not-advertise");
8801 if (CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_SUBSTITUTE
))
8802 vty_out (vty
, " substitute %s/%d",
8803 inet_ntoa (range
->subst_addr
), range
->subst_masklen
);
8805 vty_out (vty
, "%s", VTY_NEWLINE
);
8808 if (EXPORT_NAME (area
))
8809 vty_out (vty
, " area %s export-list %s%s", buf
,
8810 EXPORT_NAME (area
), VTY_NEWLINE
);
8812 if (IMPORT_NAME (area
))
8813 vty_out (vty
, " area %s import-list %s%s", buf
,
8814 IMPORT_NAME (area
), VTY_NEWLINE
);
8816 if (PREFIX_NAME_IN (area
))
8817 vty_out (vty
, " area %s filter-list prefix %s in%s", buf
,
8818 PREFIX_NAME_IN (area
), VTY_NEWLINE
);
8820 if (PREFIX_NAME_OUT (area
))
8821 vty_out (vty
, " area %s filter-list prefix %s out%s", buf
,
8822 PREFIX_NAME_OUT (area
), VTY_NEWLINE
);
8829 config_write_ospf_nbr_nbma (struct vty
*vty
, struct ospf
*ospf
)
8831 struct ospf_nbr_nbma
*nbr_nbma
;
8832 struct route_node
*rn
;
8834 /* Static Neighbor configuration print. */
8835 for (rn
= route_top (ospf
->nbr_nbma
); rn
; rn
= route_next (rn
))
8836 if ((nbr_nbma
= rn
->info
))
8838 vty_out (vty
, " neighbor %s", inet_ntoa (nbr_nbma
->addr
));
8840 if (nbr_nbma
->priority
!= OSPF_NEIGHBOR_PRIORITY_DEFAULT
)
8841 vty_out (vty
, " priority %d", nbr_nbma
->priority
);
8843 if (nbr_nbma
->v_poll
!= OSPF_POLL_INTERVAL_DEFAULT
)
8844 vty_out (vty
, " poll-interval %d", nbr_nbma
->v_poll
);
8846 vty_out (vty
, "%s", VTY_NEWLINE
);
8853 config_write_virtual_link (struct vty
*vty
, struct ospf
*ospf
)
8855 struct listnode
*node
;
8856 struct ospf_vl_data
*vl_data
;
8857 u_char buf
[INET_ADDRSTRLEN
];
8859 /* Virtual-Link print */
8860 for (ALL_LIST_ELEMENTS_RO (ospf
->vlinks
, node
, vl_data
))
8862 struct listnode
*n2
;
8863 struct crypt_key
*ck
;
8864 struct ospf_interface
*oi
;
8866 if (vl_data
!= NULL
)
8868 memset (buf
, 0, INET_ADDRSTRLEN
);
8870 if (vl_data
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
8871 strncpy ((char *) buf
, inet_ntoa (vl_data
->vl_area_id
), INET_ADDRSTRLEN
);
8873 sprintf ((char *) buf
, "%lu",
8874 (unsigned long int) ntohl (vl_data
->vl_area_id
.s_addr
));
8875 oi
= vl_data
->vl_oi
;
8878 if (OSPF_IF_PARAM (oi
, v_hello
) != OSPF_HELLO_INTERVAL_DEFAULT
||
8879 OSPF_IF_PARAM (oi
, v_wait
) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
||
8880 OSPF_IF_PARAM (oi
, retransmit_interval
) != OSPF_RETRANSMIT_INTERVAL_DEFAULT
||
8881 OSPF_IF_PARAM (oi
, transmit_delay
) != OSPF_TRANSMIT_DELAY_DEFAULT
)
8882 vty_out (vty
, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
8884 inet_ntoa (vl_data
->vl_peer
),
8885 OSPF_IF_PARAM (oi
, v_hello
),
8886 OSPF_IF_PARAM (oi
, retransmit_interval
),
8887 OSPF_IF_PARAM (oi
, transmit_delay
),
8888 OSPF_IF_PARAM (oi
, v_wait
),
8891 vty_out (vty
, " area %s virtual-link %s%s", buf
,
8892 inet_ntoa (vl_data
->vl_peer
), VTY_NEWLINE
);
8894 if (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
[0] != '\0')
8895 vty_out (vty
, " area %s virtual-link %s authentication-key %s%s",
8897 inet_ntoa (vl_data
->vl_peer
),
8898 IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
,
8901 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_crypt
,
8903 vty_out (vty
, " area %s virtual-link %s"
8904 " message-digest-key %d md5 %s%s",
8906 inet_ntoa (vl_data
->vl_peer
),
8907 ck
->key_id
, ck
->auth_key
, VTY_NEWLINE
);
8917 config_write_ospf_redistribute (struct vty
*vty
, struct ospf
*ospf
)
8921 /* redistribute print. */
8922 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
8924 struct list
*red_list
;
8925 struct listnode
*node
;
8926 struct ospf_redist
*red
;
8928 red_list
= ospf
->redist
[type
];
8932 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
))
8934 vty_out (vty
, " redistribute %s", zebra_route_string(type
));
8936 vty_out (vty
, " %d", red
->instance
);
8938 if (red
->dmetric
.value
>= 0)
8939 vty_out (vty
, " metric %d", red
->dmetric
.value
);
8941 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
8942 vty_out (vty
, " metric-type 1");
8944 if (ROUTEMAP_NAME (red
))
8945 vty_out (vty
, " route-map %s", ROUTEMAP_NAME (red
));
8947 vty_out (vty
, "%s", VTY_NEWLINE
);
8955 config_write_ospf_default_metric (struct vty
*vty
, struct ospf
*ospf
)
8957 if (ospf
->default_metric
!= -1)
8958 vty_out (vty
, " default-metric %d%s", ospf
->default_metric
,
8964 config_write_ospf_distribute (struct vty
*vty
, struct ospf
*ospf
)
8967 struct ospf_redist
*red
;
8971 /* distribute-list print. */
8972 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
8973 if (DISTRIBUTE_NAME (ospf
, type
))
8974 vty_out (vty
, " distribute-list %s out %s%s",
8975 DISTRIBUTE_NAME (ospf
, type
),
8976 zebra_route_string(type
), VTY_NEWLINE
);
8978 /* default-information print. */
8979 if (ospf
->default_originate
!= DEFAULT_ORIGINATE_NONE
)
8981 vty_out (vty
, " default-information originate");
8982 if (ospf
->default_originate
== DEFAULT_ORIGINATE_ALWAYS
)
8983 vty_out (vty
, " always");
8985 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
8988 if (red
->dmetric
.value
>= 0)
8989 vty_out (vty
, " metric %d",
8990 red
->dmetric
.value
);
8991 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
8992 vty_out (vty
, " metric-type 1");
8994 if (ROUTEMAP_NAME (red
))
8995 vty_out (vty
, " route-map %s",
8996 ROUTEMAP_NAME (red
));
8999 vty_out (vty
, "%s", VTY_NEWLINE
);
9008 config_write_ospf_distance (struct vty
*vty
, struct ospf
*ospf
)
9010 struct route_node
*rn
;
9011 struct ospf_distance
*odistance
;
9013 if (ospf
->distance_all
)
9014 vty_out (vty
, " distance %d%s", ospf
->distance_all
, VTY_NEWLINE
);
9016 if (ospf
->distance_intra
9017 || ospf
->distance_inter
9018 || ospf
->distance_external
)
9020 vty_out (vty
, " distance ospf");
9022 if (ospf
->distance_intra
)
9023 vty_out (vty
, " intra-area %d", ospf
->distance_intra
);
9024 if (ospf
->distance_inter
)
9025 vty_out (vty
, " inter-area %d", ospf
->distance_inter
);
9026 if (ospf
->distance_external
)
9027 vty_out (vty
, " external %d", ospf
->distance_external
);
9029 vty_out (vty
, "%s", VTY_NEWLINE
);
9032 for (rn
= route_top (ospf
->distance_table
); rn
; rn
= route_next (rn
))
9033 if ((odistance
= rn
->info
) != NULL
)
9035 vty_out (vty
, " distance %d %s/%d %s%s", odistance
->distance
,
9036 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
9037 odistance
->access_list
? odistance
->access_list
: "",
9043 /* OSPF configuration write function. */
9045 ospf_config_write (struct vty
*vty
)
9048 struct interface
*ifp
;
9049 struct ospf_interface
*oi
;
9050 struct listnode
*node
;
9053 ospf
= ospf_lookup ();
9054 if (ospf
!= NULL
&& ospf
->oi_running
)
9056 /* `router ospf' print. */
9058 vty_out (vty
, "router ospf %d%s", ospf
->instance
, VTY_NEWLINE
);
9060 vty_out (vty
, "router ospf%s", VTY_NEWLINE
);
9064 if (!ospf
->networks
)
9067 /* Router ID print. */
9068 if (ospf
->router_id_static
.s_addr
!= 0)
9069 vty_out (vty
, " ospf router-id %s%s",
9070 inet_ntoa (ospf
->router_id_static
), VTY_NEWLINE
);
9072 /* ABR type print. */
9073 if (ospf
->abr_type
!= OSPF_ABR_DEFAULT
)
9074 vty_out (vty
, " ospf abr-type %s%s",
9075 ospf_abr_type_str
[ospf
->abr_type
], VTY_NEWLINE
);
9077 /* log-adjacency-changes flag print. */
9078 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
))
9080 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
9081 vty_out(vty
, " log-adjacency-changes detail%s", VTY_NEWLINE
);
9085 vty_out(vty
, " no log-adjacency-changes%s", VTY_NEWLINE
);
9088 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
9089 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
9090 vty_out (vty
, " compatible rfc1583%s", VTY_NEWLINE
);
9092 /* auto-cost reference-bandwidth configuration. */
9093 if (ospf
->ref_bandwidth
!= OSPF_DEFAULT_REF_BANDWIDTH
)
9095 vty_out (vty
, "! Important: ensure reference bandwidth "
9096 "is consistent across all routers%s", VTY_NEWLINE
);
9097 vty_out (vty
, " auto-cost reference-bandwidth %d%s",
9098 ospf
->ref_bandwidth
, VTY_NEWLINE
);
9101 /* SPF timers print. */
9102 if (ospf
->spf_delay
!= OSPF_SPF_DELAY_DEFAULT
||
9103 ospf
->spf_holdtime
!= OSPF_SPF_HOLDTIME_DEFAULT
||
9104 ospf
->spf_max_holdtime
!= OSPF_SPF_MAX_HOLDTIME_DEFAULT
)
9105 vty_out (vty
, " timers throttle spf %d %d %d%s",
9106 ospf
->spf_delay
, ospf
->spf_holdtime
,
9107 ospf
->spf_max_holdtime
, VTY_NEWLINE
);
9109 /* LSA timers print. */
9110 if (ospf
->min_ls_interval
!= OSPF_MIN_LS_INTERVAL
)
9111 vty_out (vty
, " timers throttle lsa all %d%s",
9112 ospf
->min_ls_interval
, VTY_NEWLINE
);
9113 if (ospf
->min_ls_arrival
!= OSPF_MIN_LS_ARRIVAL
)
9114 vty_out (vty
, " timers lsa min-arrival %d%s",
9115 ospf
->min_ls_arrival
, VTY_NEWLINE
);
9117 /* Write multiplier print. */
9118 if (ospf
->write_oi_count
!= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
)
9119 vty_out (vty
, " ospf write-multiplier %d%s",
9120 ospf
->write_oi_count
, VTY_NEWLINE
);
9122 /* Max-metric router-lsa print */
9123 config_write_stub_router (vty
, ospf
);
9125 /* SPF refresh parameters print. */
9126 if (ospf
->lsa_refresh_interval
!= OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
9127 vty_out (vty
, " refresh timer %d%s",
9128 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
9130 /* Redistribute information print. */
9131 config_write_ospf_redistribute (vty
, ospf
);
9133 /* passive-interface print. */
9134 if (ospf
->passive_interface_default
== OSPF_IF_PASSIVE
)
9135 vty_out (vty
, " passive-interface default%s", VTY_NEWLINE
);
9137 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, node
, ifp
))
9138 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
)
9139 && IF_DEF_PARAMS (ifp
)->passive_interface
!=
9140 ospf
->passive_interface_default
)
9142 vty_out (vty
, " %spassive-interface %s%s",
9143 IF_DEF_PARAMS (ifp
)->passive_interface
? "" : "no ",
9144 ifp
->name
, VTY_NEWLINE
);
9146 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
9148 if (!OSPF_IF_PARAM_CONFIGURED (oi
->params
, passive_interface
))
9150 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi
->ifp
),
9153 if (oi
->params
->passive_interface
== IF_DEF_PARAMS (oi
->ifp
)->passive_interface
)
9156 else if (oi
->params
->passive_interface
== ospf
->passive_interface_default
)
9159 vty_out (vty
, " %spassive-interface %s %s%s",
9160 oi
->params
->passive_interface
? "" : "no ",
9162 inet_ntoa (oi
->address
->u
.prefix4
), VTY_NEWLINE
);
9165 /* Network area print. */
9166 config_write_network_area (vty
, ospf
);
9168 /* Area config print. */
9169 config_write_ospf_area (vty
, ospf
);
9171 /* static neighbor print. */
9172 config_write_ospf_nbr_nbma (vty
, ospf
);
9174 /* Virtual-Link print. */
9175 config_write_virtual_link (vty
, ospf
);
9177 /* Default metric configuration. */
9178 config_write_ospf_default_metric (vty
, ospf
);
9180 /* Distribute-list and default-information print. */
9181 config_write_ospf_distribute (vty
, ospf
);
9183 /* Distance configuration. */
9184 config_write_ospf_distance (vty
, ospf
);
9186 ospf_opaque_config_write_router (vty
, ospf
);
9193 ospf_vty_show_init (void)
9195 /* "show ip ospf" commands. */
9196 install_element (VIEW_NODE
, &show_ip_ospf_cmd
);
9198 install_element (VIEW_NODE
, &show_ip_ospf_instance_cmd
);
9200 /* "show ip ospf database" commands. */
9201 install_element (VIEW_NODE
, &show_ip_ospf_database_type_adv_router_cmd
);
9202 install_element (VIEW_NODE
, &show_ip_ospf_database_max_cmd
);
9204 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_adv_router_cmd
);
9205 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_cmd
);
9206 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_max_cmd
);
9208 /* "show ip ospf interface" commands. */
9209 install_element (VIEW_NODE
, &show_ip_ospf_interface_cmd
);
9211 install_element (VIEW_NODE
, &show_ip_ospf_instance_interface_cmd
);
9213 /* "show ip ospf neighbor" commands. */
9214 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_detail_cmd
);
9215 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_cmd
);
9216 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_id_cmd
);
9217 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_all_cmd
);
9218 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_cmd
);
9219 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_cmd
);
9220 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_all_cmd
);
9222 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_detail_cmd
);
9223 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_cmd
);
9224 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_id_cmd
);
9225 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_all_cmd
);
9226 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_cmd
);
9227 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_cmd
);
9228 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_all_cmd
);
9230 /* "show ip ospf route" commands. */
9231 install_element (VIEW_NODE
, &show_ip_ospf_route_cmd
);
9232 install_element (VIEW_NODE
, &show_ip_ospf_border_routers_cmd
);
9234 install_element (VIEW_NODE
, &show_ip_ospf_instance_route_cmd
);
9235 install_element (VIEW_NODE
, &show_ip_ospf_instance_border_routers_cmd
);
9239 /* ospfd's interface node. */
9240 static struct cmd_node interface_node
=
9247 /* Initialization of OSPF interface. */
9249 ospf_vty_if_init (void)
9251 /* Install interface node. */
9252 install_node (&interface_node
, config_write_interface
);
9254 install_element (CONFIG_NODE
, &interface_cmd
);
9255 install_element (CONFIG_NODE
, &no_interface_cmd
);
9256 install_default (INTERFACE_NODE
);
9258 /* "description" commands. */
9259 install_element (INTERFACE_NODE
, &interface_desc_cmd
);
9260 install_element (INTERFACE_NODE
, &no_interface_desc_cmd
);
9262 /* "ip ospf authentication" commands. */
9263 install_element (INTERFACE_NODE
, &ip_ospf_authentication_args_addr_cmd
);
9264 install_element (INTERFACE_NODE
, &ip_ospf_authentication_addr_cmd
);
9265 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_args_addr_cmd
);
9266 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_addr_cmd
);
9267 install_element (INTERFACE_NODE
, &ip_ospf_authentication_key_addr_cmd
);
9268 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_key_authkey_addr_cmd
);
9269 install_element (INTERFACE_NODE
, &no_ospf_authentication_key_authkey_addr_cmd
);
9271 /* "ip ospf message-digest-key" commands. */
9272 install_element (INTERFACE_NODE
, &ip_ospf_message_digest_key_cmd
);
9273 install_element (INTERFACE_NODE
, &no_ip_ospf_message_digest_key_cmd
);
9275 /* "ip ospf cost" commands. */
9276 install_element (INTERFACE_NODE
, &ip_ospf_cost_cmd
);
9277 install_element (INTERFACE_NODE
, &no_ip_ospf_cost_cmd
);
9279 /* "ip ospf mtu-ignore" commands. */
9280 install_element (INTERFACE_NODE
, &ip_ospf_mtu_ignore_addr_cmd
);
9281 install_element (INTERFACE_NODE
, &no_ip_ospf_mtu_ignore_addr_cmd
);
9283 /* "ip ospf dead-interval" commands. */
9284 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_cmd
);
9285 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_minimal_addr_cmd
);
9286 install_element (INTERFACE_NODE
, &no_ip_ospf_dead_interval_cmd
);
9288 /* "ip ospf hello-interval" commands. */
9289 install_element (INTERFACE_NODE
, &ip_ospf_hello_interval_cmd
);
9290 install_element (INTERFACE_NODE
, &no_ip_ospf_hello_interval_cmd
);
9292 /* "ip ospf network" commands. */
9293 install_element (INTERFACE_NODE
, &ip_ospf_network_cmd
);
9294 install_element (INTERFACE_NODE
, &no_ip_ospf_network_cmd
);
9296 /* "ip ospf priority" commands. */
9297 install_element (INTERFACE_NODE
, &ip_ospf_priority_cmd
);
9298 install_element (INTERFACE_NODE
, &no_ip_ospf_priority_cmd
);
9300 /* "ip ospf retransmit-interval" commands. */
9301 install_element (INTERFACE_NODE
, &ip_ospf_retransmit_interval_addr_cmd
);
9302 install_element (INTERFACE_NODE
, &no_ip_ospf_retransmit_interval_addr_cmd
);
9304 /* "ip ospf transmit-delay" commands. */
9305 install_element (INTERFACE_NODE
, &ip_ospf_transmit_delay_addr_cmd
);
9306 install_element (INTERFACE_NODE
, &no_ip_ospf_transmit_delay_addr_cmd
);
9308 /* "ip ospf area" commands. */
9309 install_element (INTERFACE_NODE
, &ip_ospf_area_cmd
);
9310 install_element (INTERFACE_NODE
, &no_ip_ospf_area_cmd
);
9312 /* These commands are compatibitliy for previous version. */
9313 install_element (INTERFACE_NODE
, &ospf_authentication_key_cmd
);
9314 install_element (INTERFACE_NODE
, &ospf_message_digest_key_cmd
);
9315 install_element (INTERFACE_NODE
, &no_ospf_message_digest_key_cmd
);
9316 install_element (INTERFACE_NODE
, &ospf_dead_interval_cmd
);
9317 install_element (INTERFACE_NODE
, &no_ospf_dead_interval_cmd
);
9318 install_element (INTERFACE_NODE
, &ospf_hello_interval_cmd
);
9319 install_element (INTERFACE_NODE
, &no_ospf_hello_interval_cmd
);
9320 install_element (INTERFACE_NODE
, &ospf_cost_cmd
);
9321 install_element (INTERFACE_NODE
, &no_ospf_cost_cmd
);
9322 install_element (INTERFACE_NODE
, &ospf_network_cmd
);
9323 install_element (INTERFACE_NODE
, &no_ospf_network_cmd
);
9324 install_element (INTERFACE_NODE
, &ospf_priority_cmd
);
9325 install_element (INTERFACE_NODE
, &no_ospf_priority_cmd
);
9326 install_element (INTERFACE_NODE
, &ospf_retransmit_interval_cmd
);
9327 install_element (INTERFACE_NODE
, &no_ospf_retransmit_interval_cmd
);
9328 install_element (INTERFACE_NODE
, &ospf_transmit_delay_cmd
);
9329 install_element (INTERFACE_NODE
, &no_ospf_transmit_delay_cmd
);
9333 ospf_vty_zebra_init (void)
9335 install_element (OSPF_NODE
, &ospf_redistribute_source_cmd
);
9336 install_element (OSPF_NODE
, &no_ospf_redistribute_source_cmd
);
9337 install_element (OSPF_NODE
, &ospf_redistribute_instance_source_cmd
);
9338 install_element (OSPF_NODE
, &no_ospf_redistribute_instance_source_cmd
);
9340 install_element (OSPF_NODE
, &ospf_distribute_list_out_cmd
);
9341 install_element (OSPF_NODE
, &no_ospf_distribute_list_out_cmd
);
9343 install_element (OSPF_NODE
, &ospf_default_information_originate_cmd
);
9344 install_element (OSPF_NODE
, &no_ospf_default_information_originate_cmd
);
9346 install_element (OSPF_NODE
, &ospf_default_metric_cmd
);
9347 install_element (OSPF_NODE
, &no_ospf_default_metric_cmd
);
9349 install_element (OSPF_NODE
, &ospf_distance_cmd
);
9350 install_element (OSPF_NODE
, &no_ospf_distance_cmd
);
9351 install_element (OSPF_NODE
, &no_ospf_distance_ospf_cmd
);
9352 install_element (OSPF_NODE
, &ospf_distance_ospf_cmd
);
9354 install_element (OSPF_NODE
, &ospf_distance_source_cmd
);
9355 install_element (OSPF_NODE
, &no_ospf_distance_source_cmd
);
9356 install_element (OSPF_NODE
, &ospf_distance_source_access_list_cmd
);
9357 install_element (OSPF_NODE
, &no_ospf_distance_source_access_list_cmd
);
9361 static struct cmd_node ospf_node
=
9364 "%s(config-router)# ",
9369 ospf_interface_clear (struct interface
*ifp
)
9371 if (!if_is_operative (ifp
)) return;
9373 if (IS_DEBUG_OSPF (ism
, ISM_EVENTS
))
9374 zlog (NULL
, LOG_DEBUG
, "ISM[%s]: clear by reset", ifp
->name
);
9379 DEFUN (clear_ip_ospf_interface
,
9380 clear_ip_ospf_interface_cmd
,
9381 "clear ip ospf interface [IFNAME]",
9384 "OSPF information\n"
9385 "Interface information\n"
9389 struct interface
*ifp
;
9390 struct listnode
*node
;
9392 if (argc
== 4) /* Clear all the ospfv2 interfaces. */
9394 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
9395 ospf_interface_clear(ifp
);
9397 else /* Interface name is specified. */
9399 if ((ifp
= if_lookup_by_name (argv
[idx_ifname
]->text
)) == NULL
)
9400 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
9402 ospf_interface_clear(ifp
);
9409 ospf_vty_clear_init (void)
9411 install_element (ENABLE_NODE
, &clear_ip_ospf_interface_cmd
);
9415 /* Install OSPF related vty commands. */
9417 ospf_vty_init (void)
9419 /* Install ospf top node. */
9420 install_node (&ospf_node
, ospf_config_write
);
9422 /* "router ospf" commands. */
9423 install_element (CONFIG_NODE
, &router_ospf_cmd
);
9424 install_element (CONFIG_NODE
, &no_router_ospf_cmd
);
9427 install_default (OSPF_NODE
);
9429 /* "ospf router-id" commands. */
9430 install_element (OSPF_NODE
, &ospf_router_id_cmd
);
9431 install_element (OSPF_NODE
, &ospf_router_id_old_cmd
);
9432 install_element (OSPF_NODE
, &no_ospf_router_id_cmd
);
9434 /* "passive-interface" commands. */
9435 install_element (OSPF_NODE
, &ospf_passive_interface_addr_cmd
);
9436 install_element (OSPF_NODE
, &no_ospf_passive_interface_addr_cmd
);
9438 /* "ospf abr-type" commands. */
9439 install_element (OSPF_NODE
, &ospf_abr_type_cmd
);
9440 install_element (OSPF_NODE
, &no_ospf_abr_type_cmd
);
9442 /* "ospf log-adjacency-changes" commands. */
9443 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_cmd
);
9444 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_detail_cmd
);
9445 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_cmd
);
9446 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_detail_cmd
);
9448 /* "ospf rfc1583-compatible" commands. */
9449 install_element (OSPF_NODE
, &ospf_compatible_rfc1583_cmd
);
9450 install_element (OSPF_NODE
, &no_ospf_compatible_rfc1583_cmd
);
9451 install_element (OSPF_NODE
, &ospf_rfc1583_flag_cmd
);
9452 install_element (OSPF_NODE
, &no_ospf_rfc1583_flag_cmd
);
9454 /* "network area" commands. */
9455 install_element (OSPF_NODE
, &ospf_network_area_cmd
);
9456 install_element (OSPF_NODE
, &no_ospf_network_area_cmd
);
9458 /* "area authentication" commands. */
9459 install_element (OSPF_NODE
, &ospf_area_authentication_message_digest_cmd
);
9460 install_element (OSPF_NODE
, &ospf_area_authentication_cmd
);
9461 install_element (OSPF_NODE
, &no_ospf_area_authentication_cmd
);
9463 /* "area range" commands. */
9464 install_element (OSPF_NODE
, &ospf_area_range_cmd
);
9465 install_element (OSPF_NODE
, &ospf_area_range_cost_cmd
);
9466 install_element (OSPF_NODE
, &ospf_area_range_not_advertise_cmd
);
9467 install_element (OSPF_NODE
, &no_ospf_area_range_cmd
);
9468 install_element (OSPF_NODE
, &ospf_area_range_substitute_cmd
);
9469 install_element (OSPF_NODE
, &no_ospf_area_range_substitute_cmd
);
9471 /* "area virtual-link" commands. */
9472 install_element (OSPF_NODE
, &ospf_area_vlink_cmd
);
9473 install_element (OSPF_NODE
, &ospf_area_vlink_intervals_cmd
);
9474 install_element (OSPF_NODE
, &no_ospf_area_vlink_cmd
);
9475 install_element (OSPF_NODE
, &no_ospf_area_vlink_intervals_cmd
);
9486 /* "area stub" commands. */
9487 install_element (OSPF_NODE
, &ospf_area_stub_no_summary_cmd
);
9488 install_element (OSPF_NODE
, &ospf_area_stub_cmd
);
9489 install_element (OSPF_NODE
, &no_ospf_area_stub_no_summary_cmd
);
9490 install_element (OSPF_NODE
, &no_ospf_area_stub_cmd
);
9492 /* "area nssa" commands. */
9493 install_element (OSPF_NODE
, &ospf_area_nssa_cmd
);
9494 install_element (OSPF_NODE
, &ospf_area_nssa_translate_no_summary_cmd
);
9495 install_element (OSPF_NODE
, &ospf_area_nssa_translate_cmd
);
9496 install_element (OSPF_NODE
, &ospf_area_nssa_no_summary_cmd
);
9497 install_element (OSPF_NODE
, &no_ospf_area_nssa_cmd
);
9499 install_element (OSPF_NODE
, &ospf_area_default_cost_cmd
);
9500 install_element (OSPF_NODE
, &no_ospf_area_default_cost_cmd
);
9502 install_element (OSPF_NODE
, &ospf_area_shortcut_cmd
);
9503 install_element (OSPF_NODE
, &no_ospf_area_shortcut_cmd
);
9505 install_element (OSPF_NODE
, &ospf_area_export_list_cmd
);
9506 install_element (OSPF_NODE
, &no_ospf_area_export_list_cmd
);
9508 install_element (OSPF_NODE
, &ospf_area_filter_list_cmd
);
9509 install_element (OSPF_NODE
, &no_ospf_area_filter_list_cmd
);
9511 install_element (OSPF_NODE
, &ospf_area_import_list_cmd
);
9512 install_element (OSPF_NODE
, &no_ospf_area_import_list_cmd
);
9514 /* SPF timer commands */
9515 install_element (OSPF_NODE
, &ospf_timers_throttle_spf_cmd
);
9516 install_element (OSPF_NODE
, &no_ospf_timers_throttle_spf_cmd
);
9518 /* LSA timers commands */
9519 install_element (OSPF_NODE
, &ospf_timers_min_ls_interval_cmd
);
9520 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_interval_cmd
);
9521 install_element (OSPF_NODE
, &ospf_timers_min_ls_arrival_cmd
);
9522 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_arrival_cmd
);
9523 install_element (OSPF_NODE
, &ospf_timers_lsa_cmd
);
9524 install_element (OSPF_NODE
, &no_ospf_timers_lsa_cmd
);
9526 /* refresh timer commands */
9527 install_element (OSPF_NODE
, &ospf_refresh_timer_cmd
);
9528 install_element (OSPF_NODE
, &no_ospf_refresh_timer_val_cmd
);
9530 /* max-metric commands */
9531 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_admin_cmd
);
9532 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_admin_cmd
);
9533 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_startup_cmd
);
9534 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_startup_cmd
);
9535 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_shutdown_cmd
);
9536 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_shutdown_cmd
);
9538 /* reference bandwidth commands */
9539 install_element (OSPF_NODE
, &ospf_auto_cost_reference_bandwidth_cmd
);
9540 install_element (OSPF_NODE
, &no_ospf_auto_cost_reference_bandwidth_cmd
);
9542 /* "neighbor" commands. */
9543 install_element (OSPF_NODE
, &ospf_neighbor_cmd
);
9544 install_element (OSPF_NODE
, &ospf_neighbor_poll_interval_cmd
);
9545 install_element (OSPF_NODE
, &no_ospf_neighbor_cmd
);
9546 install_element (OSPF_NODE
, &no_ospf_neighbor_poll_cmd
);
9548 /* write multiplier commands */
9549 install_element (OSPF_NODE
, &ospf_write_multiplier_cmd
);
9550 install_element (OSPF_NODE
, &write_multiplier_cmd
);
9551 install_element (OSPF_NODE
, &no_ospf_write_multiplier_cmd
);
9552 install_element (OSPF_NODE
, &no_write_multiplier_cmd
);
9554 /* Init interface related vty commands. */
9555 ospf_vty_if_init ();
9557 /* Init zebra related vty commands. */
9558 ospf_vty_zebra_init ();