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 along
18 * with this program; see the file COPYING; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
38 #include "ospfd/ospfd.h"
39 #include "ospfd/ospf_asbr.h"
40 #include "ospfd/ospf_lsa.h"
41 #include "ospfd/ospf_lsdb.h"
42 #include "ospfd/ospf_ism.h"
43 #include "ospfd/ospf_interface.h"
44 #include "ospfd/ospf_nsm.h"
45 #include "ospfd/ospf_neighbor.h"
46 #include "ospfd/ospf_flood.h"
47 #include "ospfd/ospf_abr.h"
48 #include "ospfd/ospf_spf.h"
49 #include "ospfd/ospf_route.h"
50 #include "ospfd/ospf_zebra.h"
51 /*#include "ospfd/ospf_routemap.h" */
52 #include "ospfd/ospf_vty.h"
53 #include "ospfd/ospf_dump.h"
54 #include "ospfd/ospf_bfd.h"
56 static const char *ospf_network_type_str
[] =
67 /* Utility functions. */
69 str2area_id (const char *str
, struct in_addr
*area_id
, int *area_id_fmt
)
73 area_id
->s_addr
= htonl (strtoul (str
, &ep
, 10));
74 if (*ep
&& !inet_aton (str
, area_id
))
77 *area_id_fmt
= *ep
? OSPF_AREA_ID_FMT_DOTTEDQUAD
: OSPF_AREA_ID_FMT_DECIMAL
;
83 area_id2str (char *buf
, int length
, struct in_addr
*area_id
, int area_id_fmt
)
85 memset (buf
, 0, length
);
87 if (area_id_fmt
== OSPF_AREA_ID_FMT_DOTTEDQUAD
)
88 strncpy (buf
, inet_ntoa (*area_id
), length
);
90 sprintf (buf
, "%lu", (unsigned long) ntohl (area_id
->s_addr
));
94 str2metric (const char *str
, int *metric
)
100 *metric
= strtol (str
, NULL
, 10);
101 if (*metric
< 0 && *metric
> 16777214)
103 /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */
111 str2metric_type (const char *str
, int *metric_type
)
117 if (strncmp (str
, "1", 1) == 0)
118 *metric_type
= EXTERNAL_METRIC_TYPE_1
;
119 else if (strncmp (str
, "2", 1) == 0)
120 *metric_type
= EXTERNAL_METRIC_TYPE_2
;
128 ospf_oi_count (struct interface
*ifp
)
130 struct route_node
*rn
;
133 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
140 DEFUN_NOSH (router_ospf
,
142 "router ospf [(1-65535)]",
143 "Enable a routing process\n"
144 "Start OSPF configuration\n"
148 u_short instance
= 0;
150 ospf
= ospf_lookup();
153 vty_out (vty
, "There isn't active ospf instance %s", VTY_NEWLINE
);
158 VTY_GET_INTEGER ("Instance", instance
, argv
[2]->arg
);
160 /* The following logic to set the vty qobj index is in place to be able
161 to ignore the commands which dont belong to this instance. */
162 if (ospf
->instance
!= instance
)
163 VTY_PUSH_CONTEXT_NULL(OSPF_NODE
);
166 if (IS_DEBUG_OSPF_EVENT
)
167 zlog_debug ("Config command 'router ospf %d' received", instance
);
168 ospf
->oi_running
= 1;
169 VTY_PUSH_CONTEXT(OSPF_NODE
, ospf
);
170 ospf_router_id_update (ospf
);
176 DEFUN (no_router_ospf
,
178 "no router ospf [(1-65535)]",
180 "Enable a routing process\n"
181 "Start OSPF configuration\n"
185 u_short instance
= 0;
188 VTY_GET_INTEGER ("Instance", instance
, argv
[3]->arg
);
190 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
199 DEFUN (ospf_router_id
,
201 "ospf router-id A.B.C.D",
202 "OSPF specific commands\n"
203 "router-id for the OSPF process\n"
204 "OSPF router-id in IP address format\n")
206 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
208 struct listnode
*node
;
209 struct ospf_area
*area
;
210 struct in_addr router_id
;
213 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &router_id
);
216 vty_out (vty
, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE
);
220 ospf
->router_id_static
= router_id
;
222 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
225 vty_out (vty
, "For this router-id change to take effect,"
226 " save config and restart ospfd%s", VTY_NEWLINE
);
230 ospf_router_id_update (ospf
);
235 DEFUN_HIDDEN (ospf_router_id_old
,
236 ospf_router_id_old_cmd
,
238 "router-id for the OSPF process\n"
239 "OSPF router-id in IP address format\n")
241 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
243 struct listnode
*node
;
244 struct ospf_area
*area
;
245 struct in_addr router_id
;
248 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &router_id
);
251 vty_out (vty
, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE
);
255 ospf
->router_id_static
= router_id
;
257 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
260 vty_out (vty
, "For this router-id change to take effect,"
261 " save config and restart ospfd%s", VTY_NEWLINE
);
265 ospf_router_id_update (ospf
);
270 DEFUN (no_ospf_router_id
,
271 no_ospf_router_id_cmd
,
272 "no ospf router-id [A.B.C.D]",
274 "OSPF specific commands\n"
275 "router-id for the OSPF process\n"
276 "OSPF router-id in IP address format\n")
278 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
279 struct listnode
*node
;
280 struct ospf_area
*area
;
282 ospf
->router_id_static
.s_addr
= 0;
284 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
287 vty_out (vty
, "For this router-id change to take effect,"
288 " save config and restart ospfd%s", VTY_NEWLINE
);
292 ospf_router_id_update (ospf
);
299 ospf_passive_interface_default (struct ospf
*ospf
, u_char newval
)
302 struct interface
*ifp
;
303 struct ospf_interface
*oi
;
305 ospf
->passive_interface_default
= newval
;
307 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, ln
, ifp
))
310 OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
))
311 UNSET_IF_PARAM (IF_DEF_PARAMS (ifp
), passive_interface
);
313 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, ln
, oi
))
315 if (OSPF_IF_PARAM_CONFIGURED (oi
->params
, passive_interface
))
316 UNSET_IF_PARAM (oi
->params
, passive_interface
);
317 /* update multicast memberships */
318 ospf_if_set_multicast(oi
);
323 ospf_passive_interface_update_addr (struct ospf
*ospf
, struct interface
*ifp
,
324 struct ospf_if_params
*params
, u_char value
,
329 params
->passive_interface
= value
;
330 if (params
!= IF_DEF_PARAMS (ifp
))
332 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
))
333 dflt
= IF_DEF_PARAMS (ifp
)->passive_interface
;
335 dflt
= ospf
->passive_interface_default
;
338 SET_IF_PARAM (params
, passive_interface
);
340 UNSET_IF_PARAM (params
, passive_interface
);
342 ospf_free_if_params (ifp
, addr
);
343 ospf_if_update_params (ifp
, addr
);
348 ospf_passive_interface_update (struct ospf
*ospf
, struct interface
*ifp
,
349 struct ospf_if_params
*params
, u_char value
)
351 params
->passive_interface
= value
;
352 if (params
== IF_DEF_PARAMS (ifp
))
354 if (value
!= ospf
->passive_interface_default
)
355 SET_IF_PARAM (params
, passive_interface
);
357 UNSET_IF_PARAM (params
, passive_interface
);
361 DEFUN (ospf_passive_interface
,
362 ospf_passive_interface_addr_cmd
,
363 "passive-interface <IFNAME [A.B.C.D]|default>",
364 "Suppress routing updates on an interface\n"
367 "Suppress routing updates on interfaces by default\n")
369 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
371 struct interface
*ifp
;
372 struct in_addr addr
= { .s_addr
= INADDR_ANY
};
374 struct ospf_if_params
*params
;
375 struct route_node
*rn
;
377 if (strcmp (argv
[1]->text
, "default") == 0)
379 ospf_passive_interface_default (ospf
, OSPF_IF_PASSIVE
);
383 ifp
= if_get_by_name (argv
[1]->arg
, VRF_DEFAULT
);
385 params
= IF_DEF_PARAMS (ifp
);
389 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
392 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
397 params
= ospf_get_if_params (ifp
, addr
);
398 ospf_if_update_params (ifp
, addr
);
399 ospf_passive_interface_update_addr (ospf
, ifp
, params
,
400 OSPF_IF_PASSIVE
, addr
);
403 ospf_passive_interface_update (ospf
, ifp
, params
, OSPF_IF_PASSIVE
);
405 /* XXX We should call ospf_if_set_multicast on exactly those
406 * interfaces for which the passive property changed. It is too much
407 * work to determine this set, so we do this for every interface.
408 * This is safe and reasonable because ospf_if_set_multicast uses a
409 * record of joined groups to avoid systems calls if the desired
410 * memberships match the current memership.
413 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next (rn
))
415 struct ospf_interface
*oi
= rn
->info
;
417 if (oi
&& (OSPF_IF_PARAM(oi
, passive_interface
) == OSPF_IF_PASSIVE
))
418 ospf_if_set_multicast(oi
);
421 * XXX It is not clear what state transitions the interface needs to
422 * undergo when going from active to passive. Fixing this will
423 * require precise identification of interfaces having such a
430 DEFUN (no_ospf_passive_interface
,
431 no_ospf_passive_interface_addr_cmd
,
432 "no passive-interface <IFNAME [A.B.C.D]|default>",
434 "Allow routing updates on an interface\n"
437 "Allow routing updates on interfaces by default\n")
439 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
441 struct interface
*ifp
;
442 struct in_addr addr
= { .s_addr
= INADDR_ANY
};
443 struct ospf_if_params
*params
;
445 struct route_node
*rn
;
447 if (strcmp (argv
[2]->text
, "default") == 0)
449 ospf_passive_interface_default (ospf
, OSPF_IF_ACTIVE
);
453 ifp
= if_get_by_name (argv
[2]->arg
, VRF_DEFAULT
);
455 params
= IF_DEF_PARAMS (ifp
);
459 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
462 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
467 params
= ospf_lookup_if_params (ifp
, addr
);
470 ospf_passive_interface_update_addr (ospf
, ifp
, params
, OSPF_IF_ACTIVE
,
473 ospf_passive_interface_update (ospf
, ifp
, params
, OSPF_IF_ACTIVE
);
475 /* XXX We should call ospf_if_set_multicast on exactly those
476 * interfaces for which the passive property changed. It is too much
477 * work to determine this set, so we do this for every interface.
478 * This is safe and reasonable because ospf_if_set_multicast uses a
479 * record of joined groups to avoid systems calls if the desired
480 * memberships match the current memership.
482 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next (rn
))
484 struct ospf_interface
*oi
= rn
->info
;
486 if (oi
&& (OSPF_IF_PARAM(oi
, passive_interface
) == OSPF_IF_ACTIVE
))
487 ospf_if_set_multicast(oi
);
495 DEFUN (ospf_network_area
,
496 ospf_network_area_cmd
,
497 "network A.B.C.D/M area <A.B.C.D|(0-4294967295)>",
498 "Enable routing on an IP network\n"
499 "OSPF network prefix\n"
500 "Set the OSPF area ID\n"
501 "OSPF area ID in IP address format\n"
502 "OSPF area ID as a decimal value\n")
504 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
505 int idx_ipv4_prefixlen
= 1;
506 int idx_ipv4_number
= 3;
507 struct prefix_ipv4 p
;
508 struct in_addr area_id
;
513 vty_out (vty
, "The network command is not supported in multi-instance ospf%s",
518 if (ospf
->if_ospf_cli_count
> 0)
520 vty_out (vty
, "Please remove all ip ospf area x.x.x.x commands first.%s",
525 /* Get network prefix and Area ID. */
526 VTY_GET_IPV4_PREFIX ("network prefix", p
, argv
[idx_ipv4_prefixlen
]->arg
);
527 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
529 ret
= ospf_network_set (ospf
, &p
, area_id
, format
);
532 vty_out (vty
, "There is already same network statement.%s", VTY_NEWLINE
);
539 DEFUN (no_ospf_network_area
,
540 no_ospf_network_area_cmd
,
541 "no network A.B.C.D/M area <A.B.C.D|(0-4294967295)>",
543 "Enable routing on an IP network\n"
544 "OSPF network prefix\n"
545 "Set the OSPF area ID\n"
546 "OSPF area ID in IP address format\n"
547 "OSPF area ID as a decimal value\n")
549 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
550 int idx_ipv4_prefixlen
= 2;
551 int idx_ipv4_number
= 4;
552 struct prefix_ipv4 p
;
553 struct in_addr area_id
;
558 vty_out (vty
, "The network command is not supported in multi-instance ospf%s",
563 /* Get network prefix and Area ID. */
564 VTY_GET_IPV4_PREFIX ("network prefix", p
, argv
[idx_ipv4_prefixlen
]->arg
);
565 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
567 ret
= ospf_network_unset (ospf
, &p
, area_id
);
570 vty_out (vty
, "Can't find specified network area configuration.%s",
578 DEFUN (ospf_area_range
,
580 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [advertise [cost (0-16777215)]]",
581 "OSPF area parameters\n"
582 "OSPF area ID in IP address format\n"
583 "OSPF area ID as a decimal value\n"
584 "Summarize routes matching address/mask (border routers only)\n"
585 "Area range prefix\n"
586 "Advertise this range (default)\n"
587 "User specified metric for this range\n"
588 "Advertised metric for this range\n")
590 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
591 int idx_ipv4_number
= 1;
592 int idx_ipv4_prefixlen
= 3;
594 struct prefix_ipv4 p
;
595 struct in_addr area_id
;
599 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
600 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
602 ospf_area_range_set (ospf
, area_id
, &p
, OSPF_AREA_RANGE_ADVERTISE
);
605 VTY_GET_INTEGER ("range cost", cost
, argv
[idx_cost
]->arg
);
606 ospf_area_range_cost_set (ospf
, area_id
, &p
, cost
);
612 DEFUN (ospf_area_range_cost
,
613 ospf_area_range_cost_cmd
,
614 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M cost (0-16777215)",
615 "OSPF area parameters\n"
616 "OSPF area ID in IP address format\n"
617 "OSPF area ID as a decimal value\n"
618 "Summarize routes matching address/mask (border routers only)\n"
619 "Area range prefix\n"
620 "User specified metric for this range\n"
621 "Advertised metric for this range\n")
623 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
624 int idx_ipv4_number
= 1;
625 int idx_ipv4_prefixlen
= 3;
627 struct prefix_ipv4 p
;
628 struct in_addr area_id
;
632 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
633 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
635 ospf_area_range_set (ospf
, area_id
, &p
, OSPF_AREA_RANGE_ADVERTISE
);
636 ospf_area_display_format_set (ospf
, ospf_area_get (ospf
, area_id
), format
);
638 VTY_GET_INTEGER ("range cost", cost
, argv
[idx_cost
]->arg
);
639 ospf_area_range_cost_set (ospf
, area_id
, &p
, cost
);
644 DEFUN (ospf_area_range_not_advertise
,
645 ospf_area_range_not_advertise_cmd
,
646 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M not-advertise",
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 "DoNotAdvertise this range\n")
654 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
655 int idx_ipv4_number
= 1;
656 int idx_ipv4_prefixlen
= 3;
657 struct prefix_ipv4 p
;
658 struct in_addr area_id
;
661 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
662 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
664 ospf_area_range_set (ospf
, area_id
, &p
, 0);
665 ospf_area_display_format_set (ospf
, ospf_area_get (ospf
, area_id
), format
);
670 DEFUN (no_ospf_area_range
,
671 no_ospf_area_range_cmd
,
672 "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [<cost (0-16777215)|advertise [cost (0-16777215)]|not-advertise>]",
674 "OSPF area parameters\n"
675 "OSPF area ID in IP address format\n"
676 "OSPF area ID as a decimal value\n"
677 "Summarize routes matching address/mask (border routers only)\n"
678 "Area range prefix\n"
679 "User specified metric for this range\n"
680 "Advertised metric for this range\n"
681 "Advertise this range (default)\n"
682 "User specified metric for this range\n"
683 "Advertised metric for this range\n"
684 "DoNotAdvertise this range\n")
686 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
687 int idx_ipv4_number
= 2;
688 int idx_ipv4_prefixlen
= 4;
689 struct prefix_ipv4 p
;
690 struct in_addr area_id
;
693 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
694 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
696 ospf_area_range_unset (ospf
, area_id
, &p
);
701 DEFUN (ospf_area_range_substitute
,
702 ospf_area_range_substitute_cmd
,
703 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M",
704 "OSPF area parameters\n"
705 "OSPF area ID in IP address format\n"
706 "OSPF area ID as a decimal value\n"
707 "Summarize routes matching address/mask (border routers only)\n"
708 "Area range prefix\n"
709 "Announce area range as another prefix\n"
710 "Network prefix to be announced instead of range\n")
712 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
713 int idx_ipv4_number
= 1;
714 int idx_ipv4_prefixlen
= 3;
715 int idx_ipv4_prefixlen_2
= 5;
716 struct prefix_ipv4 p
, s
;
717 struct in_addr area_id
;
720 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
721 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
722 VTY_GET_IPV4_PREFIX ("substituted network prefix", s
, argv
[idx_ipv4_prefixlen_2
]->arg
);
724 ospf_area_range_substitute_set (ospf
, area_id
, &p
, &s
);
725 ospf_area_display_format_set (ospf
, ospf_area_get (ospf
, area_id
), format
);
730 DEFUN (no_ospf_area_range_substitute
,
731 no_ospf_area_range_substitute_cmd
,
732 "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M",
734 "OSPF area parameters\n"
735 "OSPF area ID in IP address format\n"
736 "OSPF area ID as a decimal value\n"
737 "Summarize routes matching address/mask (border routers only)\n"
738 "Area range prefix\n"
739 "Announce area range as another prefix\n"
740 "Network prefix to be announced instead of range\n")
742 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
743 int idx_ipv4_number
= 2;
744 int idx_ipv4_prefixlen
= 4;
745 int idx_ipv4_prefixlen_2
= 6;
746 struct prefix_ipv4 p
, s
;
747 struct in_addr area_id
;
750 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
751 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
752 VTY_GET_IPV4_PREFIX ("substituted network prefix", s
, argv
[idx_ipv4_prefixlen_2
]->arg
);
754 ospf_area_range_substitute_unset (ospf
, area_id
, &p
);
760 /* Command Handler Logic in VLink stuff is delicate!!
762 ALTER AT YOUR OWN RISK!!!!
764 Various dummy values are used to represent 'NoChange' state for
765 VLink configuration NOT being changed by a VLink command, and
766 special syntax is used within the command strings so that the
767 typed in command verbs can be seen in the configuration command
768 bacckend handler. This is to drastically reduce the verbeage
769 required to coe up with a reasonably compatible Cisco VLink command
771 - Matthew Grant <grantma@anathoth.gen.nz>
772 Wed, 21 Feb 2001 15:13:52 +1300
775 /* Configuration data for virtual links
777 struct ospf_vl_config_data
{
778 struct vty
*vty
; /* vty stuff */
779 struct in_addr area_id
; /* area ID from command line */
780 int area_id_fmt
; /* command line area ID format */
781 struct in_addr vl_peer
; /* command line vl_peer */
782 int auth_type
; /* Authehntication type, if given */
783 char *auth_key
; /* simple password if present */
784 int crypto_key_id
; /* Cryptographic key ID */
785 char *md5_key
; /* MD5 authentication key */
786 int hello_interval
; /* Obvious what these are... */
787 int retransmit_interval
;
793 ospf_vl_config_data_init (struct ospf_vl_config_data
*vl_config
,
796 memset (vl_config
, 0, sizeof (struct ospf_vl_config_data
));
797 vl_config
->auth_type
= OSPF_AUTH_CMD_NOTSEEN
;
798 vl_config
->vty
= vty
;
801 static struct ospf_vl_data
*
802 ospf_find_vl_data (struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
804 struct ospf_area
*area
;
805 struct ospf_vl_data
*vl_data
;
807 struct in_addr area_id
;
809 vty
= vl_config
->vty
;
810 area_id
= vl_config
->area_id
;
812 if (area_id
.s_addr
== OSPF_AREA_BACKBONE
)
815 "Configuring VLs over the backbone is not allowed%s",
819 area
= ospf_area_get (ospf
, area_id
);
820 ospf_area_display_format_set (ospf
, area
, vl_config
->area_id_fmt
);
822 if (area
->external_routing
!= OSPF_AREA_DEFAULT
)
824 if (vl_config
->area_id_fmt
== OSPF_AREA_ID_FMT_DOTTEDQUAD
)
825 vty_out (vty
, "Area %s is %s%s",
827 area
->external_routing
== OSPF_AREA_NSSA
?"nssa":"stub",
830 vty_out (vty
, "Area %ld is %s%s",
831 (u_long
)ntohl (area_id
.s_addr
),
832 area
->external_routing
== OSPF_AREA_NSSA
?"nssa":"stub",
837 if ((vl_data
= ospf_vl_lookup (ospf
, area
, vl_config
->vl_peer
)) == NULL
)
839 vl_data
= ospf_vl_data_new (area
, vl_config
->vl_peer
);
840 if (vl_data
->vl_oi
== NULL
)
842 vl_data
->vl_oi
= ospf_vl_new (ospf
, vl_data
);
843 ospf_vl_add (ospf
, vl_data
);
844 ospf_spf_calculate_schedule (ospf
, SPF_FLAG_CONFIG_CHANGE
);
852 ospf_vl_set_security (struct ospf_vl_data
*vl_data
,
853 struct ospf_vl_config_data
*vl_config
)
855 struct crypt_key
*ck
;
857 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
859 vty
= vl_config
->vty
;
861 if (vl_config
->auth_type
!= OSPF_AUTH_CMD_NOTSEEN
)
863 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), auth_type
);
864 IF_DEF_PARAMS (ifp
)->auth_type
= vl_config
->auth_type
;
867 if (vl_config
->auth_key
)
869 memset(IF_DEF_PARAMS (ifp
)->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+1);
870 strncpy ((char *) IF_DEF_PARAMS (ifp
)->auth_simple
, vl_config
->auth_key
,
871 OSPF_AUTH_SIMPLE_SIZE
);
873 else if (vl_config
->md5_key
)
875 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp
)->auth_crypt
, vl_config
->crypto_key_id
)
878 vty_out (vty
, "OSPF: Key %d already exists%s",
879 vl_config
->crypto_key_id
, VTY_NEWLINE
);
882 ck
= ospf_crypt_key_new ();
883 ck
->key_id
= vl_config
->crypto_key_id
;
884 memset(ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
885 strncpy ((char *) ck
->auth_key
, vl_config
->md5_key
, OSPF_AUTH_MD5_SIZE
);
887 ospf_crypt_key_add (IF_DEF_PARAMS (ifp
)->auth_crypt
, ck
);
889 else if (vl_config
->crypto_key_id
!= 0)
893 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp
)->auth_crypt
,
894 vl_config
->crypto_key_id
) == NULL
)
896 vty_out (vty
, "OSPF: Key %d does not exist%s",
897 vl_config
->crypto_key_id
, VTY_NEWLINE
);
901 ospf_crypt_key_delete (IF_DEF_PARAMS (ifp
)->auth_crypt
, vl_config
->crypto_key_id
);
909 ospf_vl_set_timers (struct ospf_vl_data
*vl_data
,
910 struct ospf_vl_config_data
*vl_config
)
912 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
913 /* Virtual Link data initialised to defaults, so only set
915 if (vl_config
->hello_interval
)
917 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), v_hello
);
918 IF_DEF_PARAMS (ifp
)->v_hello
= vl_config
->hello_interval
;
921 if (vl_config
->dead_interval
)
923 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), v_wait
);
924 IF_DEF_PARAMS (ifp
)->v_wait
= vl_config
->dead_interval
;
927 if (vl_config
->retransmit_interval
)
929 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), retransmit_interval
);
930 IF_DEF_PARAMS (ifp
)->retransmit_interval
= vl_config
->retransmit_interval
;
933 if (vl_config
->transmit_delay
)
935 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), transmit_delay
);
936 IF_DEF_PARAMS (ifp
)->transmit_delay
= vl_config
->transmit_delay
;
943 /* The business end of all of the above */
945 ospf_vl_set (struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
947 struct ospf_vl_data
*vl_data
;
950 vl_data
= ospf_find_vl_data (ospf
, vl_config
);
954 /* Process this one first as it can have a fatal result, which can
955 only logically occur if the virtual link exists already
956 Thus a command error does not result in a change to the
957 running configuration such as unexpectedly altered timer
959 ret
= ospf_vl_set_security (vl_data
, vl_config
);
960 if (ret
!= CMD_SUCCESS
)
963 /* Set any time based parameters, these area already range checked */
965 ret
= ospf_vl_set_timers (vl_data
, vl_config
);
966 if (ret
!= CMD_SUCCESS
)
973 /* This stuff exists to make specifying all the alias commands A LOT simpler
975 #define VLINK_HELPSTR_IPADDR \
976 "OSPF area parameters\n" \
977 "OSPF area ID in IP address format\n" \
978 "OSPF area ID as a decimal value\n" \
979 "Configure a virtual link\n" \
980 "Router ID of the remote ABR\n"
982 #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
983 "Enable authentication on this virtual link\n" \
986 #define VLINK_HELPSTR_AUTHTYPE_ALL \
987 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
988 "Use null authentication\n" \
989 "Use message-digest authentication\n"
991 #define VLINK_HELPSTR_TIME_PARAM \
992 "Time between HELLO packets\n" \
994 "Time between retransmitting lost link state advertisements\n" \
996 "Link state transmit delay\n" \
998 "Interval time after which a neighbor is declared down\n" \
1001 #define VLINK_HELPSTR_AUTH_SIMPLE \
1002 "Authentication password (key)\n" \
1003 "The OSPF password (key)"
1005 #define VLINK_HELPSTR_AUTH_MD5 \
1006 "Message digest authentication password (key)\n" \
1009 "Use MD5 algorithm\n" \
1010 "The OSPF password (key)"
1012 DEFUN (ospf_area_vlink
,
1013 ospf_area_vlink_cmd
,
1014 "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>]",
1015 VLINK_HELPSTR_IPADDR
1016 "Enable authentication on this virtual link\n" \
1017 "Use null authentication\n" \
1018 "Use message-digest authentication\n"
1019 "Message digest authentication password (key)\n" \
1021 "Use MD5 algorithm\n" \
1022 "The OSPF password (key)")
1024 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1025 int idx_ipv4_number
= 1;
1027 struct ospf_vl_config_data vl_config
;
1028 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+1];
1029 char md5_key
[OSPF_AUTH_MD5_SIZE
+1];
1033 ospf_vl_config_data_init(&vl_config
, vty
);
1035 /* Read off first 2 parameters and check them */
1036 ret
= str2area_id (argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
,
1037 &vl_config
.area_id_fmt
);
1040 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1044 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1047 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s",
1054 /* Thats all folks! - BUGS B. strikes again!!!*/
1056 return ospf_vl_set (ospf
, &vl_config
);
1059 /* Deal with other parameters */
1060 for (i
=5; i
< argc
; i
++)
1063 /* vty_out (vty, "argv[%d]->arg - %s%s", i, argv[i]->text, VTY_NEWLINE); */
1065 switch (argv
[i
]->arg
[0])
1069 if (i
>5 || strncmp (argv
[i
]->arg
, "authentication-", 15) == 0)
1071 /* authentication-key - this option can occur anywhere on
1072 command line. At start of command line
1073 must check for authentication option. */
1074 memset (auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1075 strncpy (auth_key
, argv
[i
+1]->text
, OSPF_AUTH_SIMPLE_SIZE
);
1076 vl_config
.auth_key
= auth_key
;
1079 else if (strncmp (argv
[i
]->arg
, "authentication", 14) == 0)
1081 /* authentication - this option can only occur at start
1083 vl_config
.auth_type
= OSPF_AUTH_SIMPLE
;
1086 if (strncmp (argv
[i
+1]->arg
, "n", 1) == 0)
1088 /* "authentication null" */
1089 vl_config
.auth_type
= OSPF_AUTH_NULL
;
1092 else if (strncmp (argv
[i
+1]->arg
, "m", 1) == 0
1093 && strcmp (argv
[i
+1]->arg
, "message-digest-") != 0)
1095 /* "authentication message-digest" */
1096 vl_config
.auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
1104 /* message-digest-key */
1108 vl_config
.crypto_key_id
= strtol (argv
[i
]->arg
, NULL
, 10);
1109 if (vl_config
.crypto_key_id
< 0)
1114 memset(md5_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
1115 strncpy (md5_key
, argv
[i
]->arg
, OSPF_AUTH_MD5_SIZE
);
1116 vl_config
.md5_key
= md5_key
;
1120 vl_config
.md5_key
= NULL
;
1126 /* Action configuration */
1128 return ospf_vl_set (ospf
, &vl_config
);
1132 DEFUN (ospf_area_vlink_intervals
,
1133 ospf_area_vlink_intervals_cmd
,
1134 "area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D {hello-interval (1-65535)|retransmit-interval (1-65535)|transmit-delay (1-65535)|dead-interval (1-65535)}",
1135 VLINK_HELPSTR_IPADDR
1136 VLINK_HELPSTR_TIME_PARAM
)
1138 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1139 struct ospf_vl_config_data vl_config
;
1142 ospf_vl_config_data_init(&vl_config
, vty
);
1144 char *area_id
= argv
[1]->arg
;
1145 char *router_id
= argv
[3]->arg
;
1147 ret
= str2area_id (area_id
, &vl_config
.area_id
, &vl_config
.area_id_fmt
);
1150 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1154 ret
= inet_aton (router_id
, &vl_config
.vl_peer
);
1157 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE
);
1161 for (int idx
= 4; idx
< argc
; idx
++)
1163 if (strmatch (argv
[idx
]->text
, "hello-interval"))
1164 vl_config
.hello_interval
= strtol(argv
[++idx
]->arg
, NULL
, 10);
1165 else if (strmatch (argv
[idx
]->text
, "retransmit-interval"))
1166 vl_config
.retransmit_interval
= strtol(argv
[++idx
]->arg
, NULL
, 10);
1167 else if (strmatch (argv
[idx
]->text
, "transmit-delay"))
1168 vl_config
.transmit_delay
= strtol(argv
[++idx
]->arg
, NULL
, 10);
1169 else if (strmatch (argv
[idx
]->text
, "dead-interval"))
1170 vl_config
.dead_interval
= strtol(argv
[++idx
]->arg
, NULL
, 10);
1173 /* Action configuration */
1174 return ospf_vl_set (ospf
, &vl_config
);
1177 DEFUN (no_ospf_area_vlink
,
1178 no_ospf_area_vlink_cmd
,
1179 "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>]",
1181 VLINK_HELPSTR_IPADDR
1182 "Enable authentication on this virtual link\n" \
1183 "Use null authentication\n" \
1184 "Use message-digest authentication\n"
1185 "Message digest authentication password (key)\n" \
1187 "Use MD5 algorithm\n" \
1188 "The OSPF password (key)")
1190 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1191 int idx_ipv4_number
= 2;
1193 struct ospf_area
*area
;
1194 struct ospf_vl_config_data vl_config
;
1195 struct ospf_vl_data
*vl_data
= NULL
;
1196 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+1];
1200 ospf_vl_config_data_init(&vl_config
, vty
);
1202 ret
= str2area_id (argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
, &format
);
1205 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1209 area
= ospf_area_lookup_by_area_id (ospf
, vl_config
.area_id
);
1212 vty_out (vty
, "Area does not exist%s", VTY_NEWLINE
);
1216 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1219 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s",
1226 /* Basic VLink no command */
1227 /* Thats all folks! - BUGS B. strikes again!!!*/
1228 if ((vl_data
= ospf_vl_lookup (ospf
, area
, vl_config
.vl_peer
)))
1229 ospf_vl_delete (ospf
, vl_data
);
1231 ospf_area_check_free (ospf
, vl_config
.area_id
);
1236 /* If we are down here, we are reseting parameters */
1238 /* Deal with other parameters */
1239 for (i
=6; i
< argc
; i
++)
1241 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1243 switch (argv
[i
]->arg
[0])
1247 if (i
> 2 || strncmp (argv
[i
]->text
, "authentication-", 15) == 0)
1249 /* authentication-key - this option can occur anywhere on
1250 command line. At start of command line
1251 must check for authentication option. */
1252 memset (auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1253 vl_config
.auth_key
= auth_key
;
1255 else if (strncmp (argv
[i
]->text
, "authentication", 14) == 0)
1257 /* authentication - this option can only occur at start
1259 vl_config
.auth_type
= OSPF_AUTH_NOTSET
;
1264 /* message-digest-key */
1265 /* Delete one key */
1269 vl_config
.crypto_key_id
= strtol (argv
[i
]->arg
, NULL
, 10);
1270 if (vl_config
.crypto_key_id
< 0)
1272 vl_config
.md5_key
= NULL
;
1282 /* Action configuration */
1284 return ospf_vl_set (ospf
, &vl_config
);
1287 DEFUN (no_ospf_area_vlink_intervals
,
1288 no_ospf_area_vlink_intervals_cmd
,
1289 "no area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D {hello-interval (1-65535)|retransmit-interval (1-65535)|transmit-delay (1-65535)|dead-interval (1-65535)}",
1291 VLINK_HELPSTR_IPADDR
1292 VLINK_HELPSTR_TIME_PARAM
)
1294 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1295 struct ospf_vl_config_data vl_config
;
1298 ospf_vl_config_data_init(&vl_config
, vty
);
1300 char *area_id
= argv
[2]->arg
;
1301 char *router_id
= argv
[4]->arg
;
1303 ret
= str2area_id (area_id
, &vl_config
.area_id
, &vl_config
.area_id_fmt
);
1306 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1310 ret
= inet_aton (router_id
, &vl_config
.vl_peer
);
1313 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE
);
1317 for (int idx
= 5; idx
< argc
; idx
++)
1319 if (strmatch (argv
[idx
]->text
, "hello-interval"))
1320 vl_config
.hello_interval
= OSPF_HELLO_INTERVAL_DEFAULT
;
1321 else if (strmatch (argv
[idx
]->text
, "retransmit-interval"))
1322 vl_config
.retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
1323 else if (strmatch (argv
[idx
]->text
, "transmit-delay"))
1324 vl_config
.transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
1325 else if (strmatch (argv
[idx
]->text
, "dead-interval"))
1326 vl_config
.dead_interval
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
1329 /* Action configuration */
1330 return ospf_vl_set (ospf
, &vl_config
);
1333 DEFUN (ospf_area_shortcut
,
1334 ospf_area_shortcut_cmd
,
1335 "area <A.B.C.D|(0-4294967295)> shortcut <default|enable|disable>",
1336 "OSPF area parameters\n"
1337 "OSPF area ID in IP address format\n"
1338 "OSPF area ID as a decimal value\n"
1339 "Configure the area's shortcutting mode\n"
1340 "Set default shortcutting behavior\n"
1341 "Enable shortcutting through the area\n"
1342 "Disable shortcutting through the area\n")
1344 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1345 int idx_ipv4_number
= 1;
1346 int idx_enable_disable
= 3;
1347 struct ospf_area
*area
;
1348 struct in_addr area_id
;
1352 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1354 area
= ospf_area_get (ospf
, area_id
);
1355 ospf_area_display_format_set (ospf
, area
, format
);
1357 if (strncmp (argv
[idx_enable_disable
]->arg
, "de", 2) == 0)
1358 mode
= OSPF_SHORTCUT_DEFAULT
;
1359 else if (strncmp (argv
[idx_enable_disable
]->arg
, "di", 2) == 0)
1360 mode
= OSPF_SHORTCUT_DISABLE
;
1361 else if (strncmp (argv
[idx_enable_disable
]->arg
, "e", 1) == 0)
1362 mode
= OSPF_SHORTCUT_ENABLE
;
1366 ospf_area_shortcut_set (ospf
, area
, mode
);
1368 if (ospf
->abr_type
!= OSPF_ABR_SHORTCUT
)
1369 vty_out (vty
, "Shortcut area setting will take effect "
1370 "only when the router is configured as Shortcut ABR%s",
1376 DEFUN (no_ospf_area_shortcut
,
1377 no_ospf_area_shortcut_cmd
,
1378 "no area <A.B.C.D|(0-4294967295)> shortcut <enable|disable>",
1380 "OSPF area parameters\n"
1381 "OSPF area ID in IP address format\n"
1382 "OSPF area ID as a decimal value\n"
1383 "Deconfigure the area's shortcutting mode\n"
1384 "Deconfigure enabled shortcutting through the area\n"
1385 "Deconfigure disabled shortcutting through the area\n")
1387 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1388 int idx_ipv4_number
= 2;
1389 struct ospf_area
*area
;
1390 struct in_addr area_id
;
1393 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1395 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1399 ospf_area_shortcut_unset (ospf
, area
);
1405 DEFUN (ospf_area_stub
,
1407 "area <A.B.C.D|(0-4294967295)> stub",
1408 "OSPF area parameters\n"
1409 "OSPF area ID in IP address format\n"
1410 "OSPF area ID as a decimal value\n"
1411 "Configure OSPF area as stub\n")
1413 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1414 int idx_ipv4_number
= 1;
1415 struct in_addr area_id
;
1418 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1420 ret
= ospf_area_stub_set (ospf
, area_id
);
1421 ospf_area_display_format_set (ospf
, ospf_area_get (ospf
, area_id
), format
);
1424 vty_out (vty
, "First deconfigure all virtual link through this area%s",
1429 ospf_area_no_summary_unset (ospf
, area_id
);
1434 DEFUN (ospf_area_stub_no_summary
,
1435 ospf_area_stub_no_summary_cmd
,
1436 "area <A.B.C.D|(0-4294967295)> stub no-summary",
1437 "OSPF stub parameters\n"
1438 "OSPF area ID in IP address format\n"
1439 "OSPF area ID as a decimal value\n"
1440 "Configure OSPF area as stub\n"
1441 "Do not inject inter-area routes into stub\n")
1443 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1444 int idx_ipv4_number
= 1;
1445 struct in_addr area_id
;
1448 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1450 ret
= ospf_area_stub_set (ospf
, area_id
);
1451 ospf_area_display_format_set (ospf
, ospf_area_get (ospf
, area_id
), format
);
1454 vty_out (vty
, "%% Area cannot be stub as it contains a virtual link%s",
1459 ospf_area_no_summary_set (ospf
, area_id
);
1464 DEFUN (no_ospf_area_stub
,
1465 no_ospf_area_stub_cmd
,
1466 "no area <A.B.C.D|(0-4294967295)> stub",
1468 "OSPF area parameters\n"
1469 "OSPF area ID in IP address format\n"
1470 "OSPF area ID as a decimal value\n"
1471 "Configure OSPF area as stub\n")
1473 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1474 int idx_ipv4_number
= 2;
1475 struct in_addr area_id
;
1478 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1480 ospf_area_stub_unset (ospf
, area_id
);
1481 ospf_area_no_summary_unset (ospf
, area_id
);
1486 DEFUN (no_ospf_area_stub_no_summary
,
1487 no_ospf_area_stub_no_summary_cmd
,
1488 "no area <A.B.C.D|(0-4294967295)> stub no-summary",
1490 "OSPF area parameters\n"
1491 "OSPF area ID in IP address format\n"
1492 "OSPF area ID as a decimal value\n"
1493 "Configure OSPF area as stub\n"
1494 "Do not inject inter-area routes into area\n")
1496 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1497 int idx_ipv4_number
= 2;
1498 struct in_addr area_id
;
1501 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1502 ospf_area_no_summary_unset (ospf
, area_id
);
1508 ospf_area_nssa_cmd_handler (struct vty
*vty
, int argc
, struct cmd_token
**argv
,
1511 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1512 struct in_addr area_id
;
1515 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id
, format
, argv
[1]->arg
);
1517 ret
= ospf_area_nssa_set (ospf
, area_id
);
1518 ospf_area_display_format_set (ospf
, ospf_area_get (ospf
, area_id
), format
);
1521 vty_out (vty
, "%% Area cannot be nssa as it contains a virtual link%s",
1528 if (strncmp (argv
[3]->text
, "translate-c", 11) == 0)
1529 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1530 OSPF_NSSA_ROLE_CANDIDATE
);
1531 else if (strncmp (argv
[3]->text
, "translate-n", 11) == 0)
1532 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1533 OSPF_NSSA_ROLE_NEVER
);
1534 else if (strncmp (argv
[3]->text
, "translate-a", 11) == 0)
1535 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1536 OSPF_NSSA_ROLE_ALWAYS
);
1540 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1541 OSPF_NSSA_ROLE_CANDIDATE
);
1545 ospf_area_no_summary_set (ospf
, area_id
);
1547 ospf_area_no_summary_unset (ospf
, area_id
);
1549 ospf_schedule_abr_task (ospf
);
1554 DEFUN (ospf_area_nssa_translate_no_summary
,
1555 ospf_area_nssa_translate_no_summary_cmd
,
1556 "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always> no-summary",
1557 "OSPF area parameters\n"
1558 "OSPF area ID in IP address format\n"
1559 "OSPF area ID as a decimal value\n"
1560 "Configure OSPF area as nssa\n"
1561 "Configure NSSA-ABR for translate election (default)\n"
1562 "Configure NSSA-ABR to never translate\n"
1563 "Configure NSSA-ABR to always translate\n"
1564 "Do not inject inter-area routes into nssa\n")
1566 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 1);
1569 DEFUN (ospf_area_nssa_translate
,
1570 ospf_area_nssa_translate_cmd
,
1571 "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always>",
1572 "OSPF area parameters\n"
1573 "OSPF area ID in IP address format\n"
1574 "OSPF area ID as a decimal value\n"
1575 "Configure OSPF area as nssa\n"
1576 "Configure NSSA-ABR for translate election (default)\n"
1577 "Configure NSSA-ABR to never translate\n"
1578 "Configure NSSA-ABR to always translate\n")
1580 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 0);
1583 DEFUN (ospf_area_nssa
,
1585 "area <A.B.C.D|(0-4294967295)> nssa",
1586 "OSPF area parameters\n"
1587 "OSPF area ID in IP address format\n"
1588 "OSPF area ID as a decimal value\n"
1589 "Configure OSPF area as nssa\n")
1591 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 0);
1594 DEFUN (ospf_area_nssa_no_summary
,
1595 ospf_area_nssa_no_summary_cmd
,
1596 "area <A.B.C.D|(0-4294967295)> nssa no-summary",
1597 "OSPF area parameters\n"
1598 "OSPF area ID in IP address format\n"
1599 "OSPF area ID as a decimal value\n"
1600 "Configure OSPF area as nssa\n"
1601 "Do not inject inter-area routes into nssa\n")
1603 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 1);
1606 DEFUN (no_ospf_area_nssa
,
1607 no_ospf_area_nssa_cmd
,
1608 "no area <A.B.C.D|(0-4294967295)> nssa [<translate-candidate|translate-never|translate-always> [no-summary]]",
1610 "OSPF area parameters\n"
1611 "OSPF area ID in IP address format\n"
1612 "OSPF area ID as a decimal value\n"
1613 "Configure OSPF area as nssa\n"
1614 "Configure NSSA-ABR for translate election (default)\n"
1615 "Configure NSSA-ABR to never translate\n"
1616 "Configure NSSA-ABR to always translate\n"
1617 "Do not inject inter-area routes into nssa\n")
1619 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1620 int idx_ipv4_number
= 2;
1621 struct in_addr area_id
;
1624 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1626 ospf_area_nssa_unset (ospf
, area_id
);
1627 ospf_area_no_summary_unset (ospf
, area_id
);
1629 ospf_schedule_abr_task (ospf
);
1635 DEFUN (ospf_area_default_cost
,
1636 ospf_area_default_cost_cmd
,
1637 "area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1638 "OSPF area parameters\n"
1639 "OSPF area ID in IP address format\n"
1640 "OSPF area ID as a decimal value\n"
1641 "Set the summary-default cost of a NSSA or stub area\n"
1642 "Stub's advertised default summary cost\n")
1644 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1645 int idx_ipv4_number
= 1;
1647 struct ospf_area
*area
;
1648 struct in_addr area_id
;
1651 struct prefix_ipv4 p
;
1653 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1654 VTY_GET_INTEGER_RANGE ("stub default cost", cost
, argv
[idx_number
]->arg
, 0, 16777215);
1656 area
= ospf_area_get (ospf
, area_id
);
1657 ospf_area_display_format_set (ospf
, area
, format
);
1659 if (area
->external_routing
== OSPF_AREA_DEFAULT
)
1661 vty_out (vty
, "The area is neither stub, nor NSSA%s", VTY_NEWLINE
);
1665 area
->default_cost
= cost
;
1668 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1670 if (IS_DEBUG_OSPF_EVENT
)
1671 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1672 "announcing 0.0.0.0/0 to area %s",
1673 inet_ntoa (area
->area_id
));
1674 ospf_abr_announce_network_to_area (&p
, area
->default_cost
, area
);
1679 DEFUN (no_ospf_area_default_cost
,
1680 no_ospf_area_default_cost_cmd
,
1681 "no area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1683 "OSPF area parameters\n"
1684 "OSPF area ID in IP address format\n"
1685 "OSPF area ID as a decimal value\n"
1686 "Set the summary-default cost of a NSSA or stub area\n"
1687 "Stub's advertised default summary cost\n")
1689 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1690 int idx_ipv4_number
= 2;
1692 struct ospf_area
*area
;
1693 struct in_addr area_id
;
1695 struct prefix_ipv4 p
;
1697 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1698 VTY_CHECK_INTEGER_RANGE ("stub default cost", argv
[idx_number
]->arg
, 0, OSPF_LS_INFINITY
);
1700 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1704 if (area
->external_routing
== OSPF_AREA_DEFAULT
)
1706 vty_out (vty
, "The area is neither stub, nor NSSA%s", VTY_NEWLINE
);
1710 area
->default_cost
= 1;
1713 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1715 if (IS_DEBUG_OSPF_EVENT
)
1716 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1717 "announcing 0.0.0.0/0 to area %s",
1718 inet_ntoa (area
->area_id
));
1719 ospf_abr_announce_network_to_area (&p
, area
->default_cost
, area
);
1722 ospf_area_check_free (ospf
, area_id
);
1727 DEFUN (ospf_area_export_list
,
1728 ospf_area_export_list_cmd
,
1729 "area <A.B.C.D|(0-4294967295)> export-list NAME",
1730 "OSPF area parameters\n"
1731 "OSPF area ID in IP address format\n"
1732 "OSPF area ID as a decimal value\n"
1733 "Set the filter for networks announced to other areas\n"
1734 "Name of the access-list\n")
1736 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1737 int idx_ipv4_number
= 1;
1738 struct ospf_area
*area
;
1739 struct in_addr area_id
;
1742 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1744 area
= ospf_area_get (ospf
, area_id
);
1745 ospf_area_display_format_set (ospf
, area
, format
);
1746 ospf_area_export_list_set (ospf
, area
, argv
[3]->arg
);
1751 DEFUN (no_ospf_area_export_list
,
1752 no_ospf_area_export_list_cmd
,
1753 "no area <A.B.C.D|(0-4294967295)> export-list NAME",
1755 "OSPF area parameters\n"
1756 "OSPF area ID in IP address format\n"
1757 "OSPF area ID as a decimal value\n"
1758 "Unset the filter for networks announced to other areas\n"
1759 "Name of the access-list\n")
1761 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1762 int idx_ipv4_number
= 2;
1763 struct ospf_area
*area
;
1764 struct in_addr area_id
;
1767 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1769 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1773 ospf_area_export_list_unset (ospf
, area
);
1779 DEFUN (ospf_area_import_list
,
1780 ospf_area_import_list_cmd
,
1781 "area <A.B.C.D|(0-4294967295)> import-list NAME",
1782 "OSPF area parameters\n"
1783 "OSPF area ID in IP address format\n"
1784 "OSPF area ID as a decimal value\n"
1785 "Set the filter for networks from other areas announced to the specified one\n"
1786 "Name of the access-list\n")
1788 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1789 int idx_ipv4_number
= 1;
1790 struct ospf_area
*area
;
1791 struct in_addr area_id
;
1794 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1796 area
= ospf_area_get (ospf
, area_id
);
1797 ospf_area_display_format_set (ospf
, area
, format
);
1798 ospf_area_import_list_set (ospf
, area
, argv
[3]->arg
);
1803 DEFUN (no_ospf_area_import_list
,
1804 no_ospf_area_import_list_cmd
,
1805 "no area <A.B.C.D|(0-4294967295)> import-list NAME",
1807 "OSPF area parameters\n"
1808 "OSPF area ID in IP address format\n"
1809 "OSPF area ID as a decimal value\n"
1810 "Unset the filter for networks announced to other areas\n"
1811 "Name of the access-list\n")
1813 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1814 int idx_ipv4_number
= 2;
1815 struct ospf_area
*area
;
1816 struct in_addr area_id
;
1819 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1821 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1825 ospf_area_import_list_unset (ospf
, area
);
1830 DEFUN (ospf_area_filter_list
,
1831 ospf_area_filter_list_cmd
,
1832 "area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>",
1833 "OSPF area parameters\n"
1834 "OSPF area ID in IP address format\n"
1835 "OSPF area ID as a decimal value\n"
1836 "Filter networks between OSPF areas\n"
1837 "Filter prefixes between OSPF areas\n"
1838 "Name of an IP prefix-list\n"
1839 "Filter networks sent to this area\n"
1840 "Filter networks sent from this area\n")
1842 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1843 int idx_ipv4_number
= 1;
1846 struct ospf_area
*area
;
1847 struct in_addr area_id
;
1848 struct prefix_list
*plist
;
1851 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1853 area
= ospf_area_get (ospf
, area_id
);
1854 ospf_area_display_format_set (ospf
, area
, format
);
1855 plist
= prefix_list_lookup (AFI_IP
, argv
[idx_word
]->arg
);
1856 if (strncmp (argv
[idx_in_out
]->arg
, "in", 2) == 0)
1858 PREFIX_LIST_IN (area
) = plist
;
1859 if (PREFIX_NAME_IN (area
))
1860 free (PREFIX_NAME_IN (area
));
1862 PREFIX_NAME_IN (area
) = strdup (argv
[idx_word
]->arg
);
1863 ospf_schedule_abr_task (ospf
);
1867 PREFIX_LIST_OUT (area
) = plist
;
1868 if (PREFIX_NAME_OUT (area
))
1869 free (PREFIX_NAME_OUT (area
));
1871 PREFIX_NAME_OUT (area
) = strdup (argv
[idx_word
]->arg
);
1872 ospf_schedule_abr_task (ospf
);
1878 DEFUN (no_ospf_area_filter_list
,
1879 no_ospf_area_filter_list_cmd
,
1880 "no area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>",
1882 "OSPF area parameters\n"
1883 "OSPF area ID in IP address format\n"
1884 "OSPF area ID as a decimal value\n"
1885 "Filter networks between OSPF areas\n"
1886 "Filter prefixes between OSPF areas\n"
1887 "Name of an IP prefix-list\n"
1888 "Filter networks sent to this area\n"
1889 "Filter networks sent from this area\n")
1891 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1892 int idx_ipv4_number
= 2;
1895 struct ospf_area
*area
;
1896 struct in_addr area_id
;
1899 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1901 if ((area
= ospf_area_lookup_by_area_id (ospf
, area_id
)) == NULL
)
1904 if (strncmp (argv
[idx_in_out
]->arg
, "in", 2) == 0)
1906 if (PREFIX_NAME_IN (area
))
1907 if (strcmp (PREFIX_NAME_IN (area
), argv
[idx_word
]->arg
) != 0)
1910 PREFIX_LIST_IN (area
) = NULL
;
1911 if (PREFIX_NAME_IN (area
))
1912 free (PREFIX_NAME_IN (area
));
1914 PREFIX_NAME_IN (area
) = NULL
;
1916 ospf_schedule_abr_task (ospf
);
1920 if (PREFIX_NAME_OUT (area
))
1921 if (strcmp (PREFIX_NAME_OUT (area
), argv
[idx_word
]->arg
) != 0)
1924 PREFIX_LIST_OUT (area
) = NULL
;
1925 if (PREFIX_NAME_OUT (area
))
1926 free (PREFIX_NAME_OUT (area
));
1928 PREFIX_NAME_OUT (area
) = NULL
;
1930 ospf_schedule_abr_task (ospf
);
1937 DEFUN (ospf_area_authentication_message_digest
,
1938 ospf_area_authentication_message_digest_cmd
,
1939 "area <A.B.C.D|(0-4294967295)> authentication message-digest",
1940 "OSPF area parameters\n"
1941 "OSPF area ID in IP address format\n"
1942 "OSPF area ID as a decimal value\n"
1943 "Enable authentication\n"
1944 "Use message-digest authentication\n")
1946 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1947 int idx_ipv4_number
= 1;
1948 struct ospf_area
*area
;
1949 struct in_addr area_id
;
1952 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1954 area
= ospf_area_get (ospf
, area_id
);
1955 ospf_area_display_format_set (ospf
, area
, format
);
1956 area
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
1961 DEFUN (ospf_area_authentication
,
1962 ospf_area_authentication_cmd
,
1963 "area <A.B.C.D|(0-4294967295)> authentication",
1964 "OSPF area parameters\n"
1965 "OSPF area ID in IP address format\n"
1966 "OSPF area ID as a decimal value\n"
1967 "Enable authentication\n")
1969 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1970 int idx_ipv4_number
= 1;
1971 struct ospf_area
*area
;
1972 struct in_addr area_id
;
1975 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1977 area
= ospf_area_get (ospf
, area_id
);
1978 ospf_area_display_format_set (ospf
, area
, format
);
1979 area
->auth_type
= OSPF_AUTH_SIMPLE
;
1984 DEFUN (no_ospf_area_authentication
,
1985 no_ospf_area_authentication_cmd
,
1986 "no area <A.B.C.D|(0-4294967295)> authentication",
1988 "OSPF area parameters\n"
1989 "OSPF area ID in IP address format\n"
1990 "OSPF area ID as a decimal value\n"
1991 "Enable authentication\n")
1993 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1994 int idx_ipv4_number
= 2;
1995 struct ospf_area
*area
;
1996 struct in_addr area_id
;
1999 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
2001 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
2005 area
->auth_type
= OSPF_AUTH_NULL
;
2007 ospf_area_check_free (ospf
, area_id
);
2013 DEFUN (ospf_abr_type
,
2015 "ospf abr-type <cisco|ibm|shortcut|standard>",
2016 "OSPF specific commands\n"
2017 "Set OSPF ABR type\n"
2018 "Alternative ABR, cisco implementation\n"
2019 "Alternative ABR, IBM implementation\n"
2021 "Standard behavior (RFC2328)\n")
2023 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2025 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2027 if (strncmp (argv
[idx_vendor
]->arg
, "c", 1) == 0)
2028 abr_type
= OSPF_ABR_CISCO
;
2029 else if (strncmp (argv
[idx_vendor
]->arg
, "i", 1) == 0)
2030 abr_type
= OSPF_ABR_IBM
;
2031 else if (strncmp (argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2032 abr_type
= OSPF_ABR_SHORTCUT
;
2033 else if (strncmp (argv
[idx_vendor
]->arg
, "st", 2) == 0)
2034 abr_type
= OSPF_ABR_STAND
;
2038 /* If ABR type value is changed, schedule ABR task. */
2039 if (ospf
->abr_type
!= abr_type
)
2041 ospf
->abr_type
= abr_type
;
2042 ospf_schedule_abr_task (ospf
);
2048 DEFUN (no_ospf_abr_type
,
2049 no_ospf_abr_type_cmd
,
2050 "no ospf abr-type <cisco|ibm|shortcut|standard>",
2052 "OSPF specific commands\n"
2053 "Set OSPF ABR type\n"
2054 "Alternative ABR, cisco implementation\n"
2055 "Alternative ABR, IBM implementation\n"
2059 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2061 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2063 if (strncmp (argv
[idx_vendor
]->arg
, "c", 1) == 0)
2064 abr_type
= OSPF_ABR_CISCO
;
2065 else if (strncmp (argv
[idx_vendor
]->arg
, "i", 1) == 0)
2066 abr_type
= OSPF_ABR_IBM
;
2067 else if (strncmp (argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2068 abr_type
= OSPF_ABR_SHORTCUT
;
2069 else if (strncmp (argv
[idx_vendor
]->arg
, "st", 2) == 0)
2070 abr_type
= OSPF_ABR_STAND
;
2074 /* If ABR type value is changed, schedule ABR task. */
2075 if (ospf
->abr_type
== abr_type
)
2077 ospf
->abr_type
= OSPF_ABR_DEFAULT
;
2078 ospf_schedule_abr_task (ospf
);
2084 DEFUN (ospf_log_adjacency_changes
,
2085 ospf_log_adjacency_changes_cmd
,
2086 "log-adjacency-changes",
2087 "Log changes in adjacency state\n")
2089 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2091 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2092 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2096 DEFUN (ospf_log_adjacency_changes_detail
,
2097 ospf_log_adjacency_changes_detail_cmd
,
2098 "log-adjacency-changes detail",
2099 "Log changes in adjacency state\n"
2100 "Log all state changes\n")
2102 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2104 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2105 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2109 DEFUN (no_ospf_log_adjacency_changes
,
2110 no_ospf_log_adjacency_changes_cmd
,
2111 "no log-adjacency-changes",
2113 "Log changes in adjacency state\n")
2115 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2117 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2118 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2122 DEFUN (no_ospf_log_adjacency_changes_detail
,
2123 no_ospf_log_adjacency_changes_detail_cmd
,
2124 "no log-adjacency-changes detail",
2126 "Log changes in adjacency state\n"
2127 "Log all state changes\n")
2129 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2131 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2135 DEFUN (ospf_compatible_rfc1583
,
2136 ospf_compatible_rfc1583_cmd
,
2137 "compatible rfc1583",
2138 "OSPF compatibility list\n"
2139 "compatible with RFC 1583\n")
2141 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2143 if (!CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
2145 SET_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2146 ospf_spf_calculate_schedule (ospf
, SPF_FLAG_CONFIG_CHANGE
);
2151 DEFUN (no_ospf_compatible_rfc1583
,
2152 no_ospf_compatible_rfc1583_cmd
,
2153 "no compatible rfc1583",
2155 "OSPF compatibility list\n"
2156 "compatible with RFC 1583\n")
2158 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2160 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
2162 UNSET_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2163 ospf_spf_calculate_schedule (ospf
, SPF_FLAG_CONFIG_CHANGE
);
2168 ALIAS (ospf_compatible_rfc1583
,
2169 ospf_rfc1583_flag_cmd
,
2170 "ospf rfc1583compatibility",
2171 "OSPF specific commands\n"
2172 "Enable the RFC1583Compatibility flag\n")
2174 ALIAS (no_ospf_compatible_rfc1583
,
2175 no_ospf_rfc1583_flag_cmd
,
2176 "no ospf rfc1583compatibility",
2178 "OSPF specific commands\n"
2179 "Disable the RFC1583Compatibility flag\n")
2182 ospf_timers_spf_set (struct vty
*vty
, unsigned int delay
,
2186 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2188 ospf
->spf_delay
= delay
;
2189 ospf
->spf_holdtime
= hold
;
2190 ospf
->spf_max_holdtime
= max
;
2195 DEFUN (ospf_timers_min_ls_interval
,
2196 ospf_timers_min_ls_interval_cmd
,
2197 "timers throttle lsa all (0-5000)",
2198 "Adjust routing timers\n"
2199 "Throttling adaptive timer\n"
2200 "LSA delay between transmissions\n"
2202 "Delay (msec) between sending LSAs\n")
2204 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2206 unsigned int interval
;
2210 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2214 VTY_GET_INTEGER ("LSA interval", interval
, argv
[idx_number
]->arg
);
2216 ospf
->min_ls_interval
= interval
;
2221 DEFUN (no_ospf_timers_min_ls_interval
,
2222 no_ospf_timers_min_ls_interval_cmd
,
2223 "no timers throttle lsa all [(0-5000)]",
2225 "Adjust routing timers\n"
2226 "Throttling adaptive timer\n"
2227 "LSA delay between transmissions\n"
2229 "Delay (msec) between sending LSAs\n")
2231 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2232 ospf
->min_ls_interval
= OSPF_MIN_LS_INTERVAL
;
2238 DEFUN (ospf_timers_min_ls_arrival
,
2239 ospf_timers_min_ls_arrival_cmd
,
2240 "timers lsa arrival (0-1000)",
2241 "Adjust routing timers\n"
2242 "Throttling link state advertisement delays\n"
2243 "OSPF minimum arrival interval delay\n"
2244 "Delay (msec) between accepted LSAs\n")
2246 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2248 unsigned int arrival
;
2252 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2256 VTY_GET_INTEGER_RANGE ("minimum LSA inter-arrival time", arrival
, argv
[idx_number
]->arg
, 0, 1000);
2258 ospf
->min_ls_arrival
= arrival
;
2263 DEFUN (no_ospf_timers_min_ls_arrival
,
2264 no_ospf_timers_min_ls_arrival_cmd
,
2265 "no timers lsa arrival [(0-1000)]",
2267 "Adjust routing timers\n"
2268 "Throttling link state advertisement delays\n"
2269 "OSPF minimum arrival interval delay\n"
2270 "Delay (msec) between accepted LSAs\n")
2272 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2274 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2280 DEFUN (ospf_timers_throttle_spf
,
2281 ospf_timers_throttle_spf_cmd
,
2282 "timers throttle spf (0-600000) (0-600000) (0-600000)",
2283 "Adjust routing timers\n"
2284 "Throttling adaptive timer\n"
2286 "Delay (msec) from first change received till SPF calculation\n"
2287 "Initial hold time (msec) between consecutive SPF calculations\n"
2288 "Maximum hold time (msec)\n")
2291 int idx_number_2
= 4;
2292 int idx_number_3
= 5;
2293 unsigned int delay
, hold
, max
;
2297 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2301 VTY_GET_INTEGER_RANGE ("SPF delay timer", delay
, argv
[idx_number
]->arg
, 0, 600000);
2302 VTY_GET_INTEGER_RANGE ("SPF hold timer", hold
, argv
[idx_number_2
]->arg
, 0, 600000);
2303 VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max
, argv
[idx_number_3
]->arg
, 0, 600000);
2305 return ospf_timers_spf_set (vty
, delay
, hold
, max
);
2308 DEFUN (no_ospf_timers_throttle_spf
,
2309 no_ospf_timers_throttle_spf_cmd
,
2310 "no timers throttle spf [(0-600000)(0-600000)(0-600000)]",
2312 "Adjust routing timers\n"
2313 "Throttling adaptive timer\n"
2315 "Delay (msec) from first change received till SPF calculation\n"
2316 "Initial hold time (msec) between consecutive SPF calculations\n"
2317 "Maximum hold time (msec)\n")
2319 return ospf_timers_spf_set (vty
,
2320 OSPF_SPF_DELAY_DEFAULT
,
2321 OSPF_SPF_HOLDTIME_DEFAULT
,
2322 OSPF_SPF_MAX_HOLDTIME_DEFAULT
);
2326 DEFUN (ospf_timers_lsa
,
2327 ospf_timers_lsa_cmd
,
2328 "timers lsa min-arrival (0-600000)",
2329 "Adjust routing timers\n"
2331 "Minimum delay in receiving new version of a LSA\n"
2332 "Delay in milliseconds\n")
2334 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2336 unsigned int minarrival
;
2340 vty_out (vty
, "Insufficient number of arguments%s", VTY_NEWLINE
);
2344 VTY_GET_INTEGER ("LSA min-arrival", minarrival
, argv
[idx_number
]->arg
);
2346 ospf
->min_ls_arrival
= minarrival
;
2351 DEFUN (no_ospf_timers_lsa
,
2352 no_ospf_timers_lsa_cmd
,
2353 "no timers lsa min-arrival [(0-600000)]",
2355 "Adjust routing timers\n"
2357 "Minimum delay in receiving new version of a LSA\n"
2358 "Delay in milliseconds\n")
2360 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2361 unsigned int minarrival
;
2365 VTY_GET_INTEGER ("LSA min-arrival", minarrival
, argv
[4]->arg
);
2367 if (ospf
->min_ls_arrival
!= minarrival
||
2368 minarrival
== OSPF_MIN_LS_ARRIVAL
)
2372 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2377 DEFUN (ospf_neighbor
,
2379 "neighbor A.B.C.D [priority (0-255) [poll-interval (1-65535)]]",
2381 "Neighbor IP address\n"
2382 "Neighbor Priority\n"
2384 "Dead Neighbor Polling interval\n"
2387 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2391 struct in_addr nbr_addr
;
2392 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2393 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2395 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2398 VTY_GET_INTEGER_RANGE ("neighbor priority", priority
, argv
[idx_pri
]->arg
, 0, 255);
2401 VTY_GET_INTEGER_RANGE ("poll interval", interval
, argv
[idx_poll
]->arg
, 1, 65535);
2403 ospf_nbr_nbma_set (ospf
, nbr_addr
);
2406 ospf_nbr_nbma_priority_set (ospf
, nbr_addr
, priority
);
2409 ospf_nbr_nbma_poll_interval_set (ospf
, nbr_addr
, interval
);
2414 DEFUN (ospf_neighbor_poll_interval
,
2415 ospf_neighbor_poll_interval_cmd
,
2416 "neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2418 "Neighbor IP address\n"
2419 "Dead Neighbor Polling interval\n"
2421 "OSPF priority of non-broadcast neighbor\n"
2424 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2428 struct in_addr nbr_addr
;
2429 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2430 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2432 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2434 VTY_GET_INTEGER_RANGE ("poll interval", interval
, argv
[idx_poll
]->arg
, 1, 65535);
2437 VTY_GET_INTEGER_RANGE ("neighbor priority", priority
, argv
[idx_pri
]->arg
, 0, 255);
2439 ospf_nbr_nbma_set (ospf
, nbr_addr
);
2440 ospf_nbr_nbma_poll_interval_set (ospf
, nbr_addr
, interval
);
2443 ospf_nbr_nbma_priority_set (ospf
, nbr_addr
, priority
);
2448 DEFUN (no_ospf_neighbor
,
2449 no_ospf_neighbor_cmd
,
2450 "no neighbor A.B.C.D [priority (0-255) [poll-interval (1-65525)]]",
2453 "Neighbor IP address\n"
2454 "Neighbor Priority\n"
2456 "Dead Neighbor Polling interval\n"
2459 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2461 struct in_addr nbr_addr
;
2463 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2465 (void)ospf_nbr_nbma_unset (ospf
, nbr_addr
);
2470 DEFUN (no_ospf_neighbor_poll
,
2471 no_ospf_neighbor_poll_cmd
,
2472 "no neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2475 "Neighbor IP address\n"
2476 "Dead Neighbor Polling interval\n"
2478 "Neighbor Priority\n"
2481 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2483 struct in_addr nbr_addr
;
2485 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2487 (void)ospf_nbr_nbma_unset (ospf
, nbr_addr
);
2492 DEFUN (ospf_refresh_timer
,
2493 ospf_refresh_timer_cmd
,
2494 "refresh timer (10-1800)",
2495 "Adjust refresh parameters\n"
2496 "Set refresh timer\n"
2497 "Timer value in seconds\n")
2499 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2501 unsigned int interval
;
2503 VTY_GET_INTEGER_RANGE ("refresh timer", interval
, argv
[idx_number
]->arg
, 10, 1800);
2504 interval
= (interval
/ OSPF_LSA_REFRESHER_GRANULARITY
) * OSPF_LSA_REFRESHER_GRANULARITY
;
2506 ospf_timers_refresh_set (ospf
, interval
);
2511 DEFUN (no_ospf_refresh_timer
,
2512 no_ospf_refresh_timer_val_cmd
,
2513 "no refresh timer [(10-1800)]",
2515 "Adjust refresh parameters\n"
2516 "Unset refresh timer\n"
2517 "Timer value in seconds\n")
2519 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2521 unsigned int interval
;
2525 VTY_GET_INTEGER_RANGE ("refresh timer", interval
, argv
[idx_number
]->arg
, 10, 1800);
2527 if (ospf
->lsa_refresh_interval
!= interval
||
2528 interval
== OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
2532 ospf_timers_refresh_unset (ospf
);
2538 DEFUN (ospf_auto_cost_reference_bandwidth
,
2539 ospf_auto_cost_reference_bandwidth_cmd
,
2540 "auto-cost reference-bandwidth (1-4294967)",
2541 "Calculate OSPF interface cost according to bandwidth\n"
2542 "Use reference bandwidth method to assign OSPF cost\n"
2543 "The reference bandwidth in terms of Mbits per second\n")
2545 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2548 struct listnode
*node
;
2549 struct interface
*ifp
;
2551 refbw
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
2552 if (refbw
< 1 || refbw
> 4294967)
2554 vty_out (vty
, "reference-bandwidth value is invalid%s", VTY_NEWLINE
);
2558 /* If reference bandwidth is changed. */
2559 if ((refbw
) == ospf
->ref_bandwidth
)
2562 ospf
->ref_bandwidth
= refbw
;
2563 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, node
, ifp
))
2564 ospf_if_recalculate_output_cost (ifp
);
2569 DEFUN (no_ospf_auto_cost_reference_bandwidth
,
2570 no_ospf_auto_cost_reference_bandwidth_cmd
,
2571 "no auto-cost reference-bandwidth [(1-4294967)]",
2573 "Calculate OSPF interface cost according to bandwidth\n"
2574 "Use reference bandwidth method to assign OSPF cost\n"
2575 "The reference bandwidth in terms of Mbits per second\n")
2577 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2578 struct listnode
*node
, *nnode
;
2579 struct interface
*ifp
;
2581 if (ospf
->ref_bandwidth
== OSPF_DEFAULT_REF_BANDWIDTH
)
2584 ospf
->ref_bandwidth
= OSPF_DEFAULT_REF_BANDWIDTH
;
2585 vty_out (vty
, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE
);
2586 vty_out (vty
, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE
);
2588 for (ALL_LIST_ELEMENTS (om
->iflist
, node
, nnode
, ifp
))
2589 ospf_if_recalculate_output_cost (ifp
);
2594 DEFUN (ospf_write_multiplier
,
2595 ospf_write_multiplier_cmd
,
2596 "ospf write-multiplier (1-100)",
2597 "OSPF specific commands\n"
2598 "Write multiplier\n"
2599 "Maximum number of interface serviced per write\n")
2601 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2603 u_int32_t write_oi_count
;
2610 write_oi_count
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
2611 if (write_oi_count
< 1 || write_oi_count
> 100)
2613 vty_out (vty
, "write-multiplier value is invalid%s", VTY_NEWLINE
);
2617 ospf
->write_oi_count
= write_oi_count
;
2621 ALIAS (ospf_write_multiplier
,
2622 write_multiplier_cmd
,
2623 "write-multiplier (1-100)",
2624 "Write multiplier\n"
2625 "Maximum number of interface serviced per write\n")
2627 DEFUN (no_ospf_write_multiplier
,
2628 no_ospf_write_multiplier_cmd
,
2629 "no ospf write-multiplier (1-100)",
2631 "OSPF specific commands\n"
2632 "Write multiplier\n"
2633 "Maximum number of interface serviced per write\n")
2635 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2637 ospf
->write_oi_count
= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
;
2641 ALIAS (no_ospf_write_multiplier
,
2642 no_write_multiplier_cmd
,
2643 "no write-multiplier (1-100)",
2645 "Write multiplier\n"
2646 "Maximum number of interface serviced per write\n")
2648 const char *ospf_abr_type_descr_str
[] =
2651 "Standard (RFC2328)",
2653 "Alternative Cisco",
2654 "Alternative Shortcut"
2657 const char *ospf_shortcut_mode_descr_str
[] =
2665 show_ip_ospf_area (struct vty
*vty
, struct ospf_area
*area
, json_object
*json_areas
, u_char use_json
)
2667 json_object
*json_area
= NULL
;
2670 json_area
= json_object_new_object();
2674 vty_out (vty
, " Area ID: %s", inet_ntoa (area
->area_id
));
2676 /* Show Area type/mode. */
2677 if (OSPF_IS_AREA_BACKBONE (area
))
2680 json_object_boolean_true_add(json_area
, "backbone");
2682 vty_out (vty
, " (Backbone)%s", VTY_NEWLINE
);
2688 if (area
->external_routing
== OSPF_AREA_STUB
)
2690 if (area
->no_summary
)
2691 json_object_boolean_true_add(json_area
, "stubNoSummary");
2692 if (area
->shortcut_configured
)
2693 json_object_boolean_true_add(json_area
, "stubShortcut");
2695 else if (area
->external_routing
== OSPF_AREA_NSSA
)
2697 if (area
->no_summary
)
2698 json_object_boolean_true_add(json_area
, "nssaNoSummary");
2699 if (area
->shortcut_configured
)
2700 json_object_boolean_true_add(json_area
, "nssaShortcut");
2703 json_object_string_add(json_area
,"shortcuttingMode",
2704 ospf_shortcut_mode_descr_str
[area
->shortcut_configured
]);
2705 if (area
->shortcut_capability
)
2706 json_object_boolean_true_add(json_area
,"sBitConcensus");
2710 if (area
->external_routing
== OSPF_AREA_STUB
)
2711 vty_out (vty
, " (Stub%s%s)",
2712 area
->no_summary
? ", no summary" : "",
2713 area
->shortcut_configured
? "; " : "");
2714 else if (area
->external_routing
== OSPF_AREA_NSSA
)
2715 vty_out (vty
, " (NSSA%s%s)",
2716 area
->no_summary
? ", no summary" : "",
2717 area
->shortcut_configured
? "; " : "");
2719 vty_out (vty
, "%s", VTY_NEWLINE
);
2720 vty_out (vty
, " Shortcutting mode: %s",
2721 ospf_shortcut_mode_descr_str
[area
->shortcut_configured
]);
2722 vty_out (vty
, ", S-bit consensus: %s%s",
2723 area
->shortcut_capability
? "ok" : "no", VTY_NEWLINE
);
2727 /* Show number of interfaces */
2730 json_object_int_add(json_area
, "areaIfTotalCounter", listcount (area
->oiflist
));
2731 json_object_int_add(json_area
, "areaIfActiveCounter", area
->act_ints
);
2734 vty_out (vty
, " Number of interfaces in this area: Total: %d, "
2735 "Active: %d%s", listcount (area
->oiflist
),
2736 area
->act_ints
, VTY_NEWLINE
);
2738 if (area
->external_routing
== OSPF_AREA_NSSA
)
2742 json_object_boolean_true_add(json_area
, "nssa");
2743 if (! IS_OSPF_ABR (area
->ospf
))
2744 json_object_boolean_false_add(json_area
, "abr");
2745 else if (area
->NSSATranslatorState
)
2747 json_object_boolean_true_add(json_area
, "abr");
2748 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
2749 json_object_boolean_true_add(json_area
, "nssaTranslatorElected");
2750 else if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_ALWAYS
)
2751 json_object_boolean_true_add(json_area
, "nssaTranslatorAlways");
2755 json_object_boolean_true_add(json_area
, "abr");
2756 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
2757 json_object_boolean_false_add(json_area
, "nssaTranslatorElected");
2759 json_object_boolean_true_add(json_area
, "nssaTranslatorNever");
2764 vty_out (vty
, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE
, VTY_NEWLINE
);
2765 if (! IS_OSPF_ABR (area
->ospf
))
2766 vty_out (vty
, " It is not ABR, therefore not Translator. %s",
2768 else if (area
->NSSATranslatorState
)
2770 vty_out (vty
, " We are an ABR and ");
2771 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
2772 vty_out (vty
, "the NSSA Elected Translator. %s",
2774 else if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_ALWAYS
)
2775 vty_out (vty
, "always an NSSA Translator. %s",
2780 vty_out (vty
, " We are an ABR, but ");
2781 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
2782 vty_out (vty
, "not the NSSA Elected Translator. %s",
2785 vty_out (vty
, "never an NSSA Translator. %s",
2791 /* Stub-router state for this area */
2792 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
))
2794 char timebuf
[OSPF_TIME_DUMP_SIZE
];
2798 json_object_boolean_true_add(json_area
, "originStubMaxDistRouterLsa");
2799 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
2800 json_object_boolean_true_add(json_area
, "indefiniteActiveAdmin");
2801 if (area
->t_stub_router
)
2804 time_store
= monotime_until(&area
->t_stub_router
->u
.sands
, NULL
) / 1000LL;
2805 json_object_int_add(json_area
, "activeStartupRemainderMsecs", time_store
);
2810 vty_out (vty
, " Originating stub / maximum-distance Router-LSA%s",
2812 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
2813 vty_out (vty
, " Administratively activated (indefinitely)%s",
2815 if (area
->t_stub_router
)
2816 vty_out (vty
, " Active from startup, %s remaining%s",
2817 ospf_timer_dump (area
->t_stub_router
, timebuf
,
2818 sizeof(timebuf
)), VTY_NEWLINE
);
2824 /* Show number of fully adjacent neighbors. */
2825 json_object_int_add(json_area
, "nbrFullAdjacentCounter", area
->full_nbrs
);
2827 /* Show authentication type. */
2828 if (area
->auth_type
== OSPF_AUTH_NULL
)
2829 json_object_string_add(json_area
, "authentication", "authenticationNone");
2830 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
2831 json_object_string_add(json_area
, "authentication", "authenticationSimplePassword");
2832 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
2833 json_object_string_add(json_area
, "authentication", "authenticationMessageDigest");
2835 if (!OSPF_IS_AREA_BACKBONE (area
))
2836 json_object_int_add(json_area
, "virtualAdjacenciesPassingCounter", area
->full_vls
);
2838 /* Show SPF calculation times. */
2839 json_object_int_add(json_area
, "spfExecutedCounter", area
->spf_calculation
);
2840 json_object_int_add(json_area
, "lsaNumber", area
->lsdb
->total
);
2841 json_object_int_add(json_area
, "lsaRouterNumber", ospf_lsdb_count (area
->lsdb
, OSPF_ROUTER_LSA
));
2842 json_object_int_add(json_area
, "lsaRouterChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_ROUTER_LSA
));
2843 json_object_int_add(json_area
, "lsaNetworkNumber", ospf_lsdb_count (area
->lsdb
, OSPF_NETWORK_LSA
));
2844 json_object_int_add(json_area
, "lsaNetworkChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_NETWORK_LSA
));
2845 json_object_int_add(json_area
, "lsaSummaryNumber", ospf_lsdb_count (area
->lsdb
, OSPF_SUMMARY_LSA
));
2846 json_object_int_add(json_area
, "lsaSummaryChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_SUMMARY_LSA
));
2847 json_object_int_add(json_area
, "lsaAsbrNumber", ospf_lsdb_count (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2848 json_object_int_add(json_area
, "lsaAsbrChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2849 json_object_int_add(json_area
, "lsaNssaNumber", ospf_lsdb_count (area
->lsdb
, OSPF_AS_NSSA_LSA
));
2850 json_object_int_add(json_area
, "lsaNssaChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_AS_NSSA_LSA
));
2854 /* Show number of fully adjacent neighbors. */
2855 vty_out (vty
, " Number of fully adjacent neighbors in this area:"
2856 " %d%s", area
->full_nbrs
, VTY_NEWLINE
);
2858 /* Show authentication type. */
2859 vty_out (vty
, " Area has ");
2860 if (area
->auth_type
== OSPF_AUTH_NULL
)
2861 vty_out (vty
, "no authentication%s", VTY_NEWLINE
);
2862 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
2863 vty_out (vty
, "simple password authentication%s", VTY_NEWLINE
);
2864 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
2865 vty_out (vty
, "message digest authentication%s", VTY_NEWLINE
);
2867 if (!OSPF_IS_AREA_BACKBONE (area
))
2868 vty_out (vty
, " Number of full virtual adjacencies going through"
2869 " this area: %d%s", area
->full_vls
, VTY_NEWLINE
);
2871 /* Show SPF calculation times. */
2872 vty_out (vty
, " SPF algorithm executed %d times%s",
2873 area
->spf_calculation
, VTY_NEWLINE
);
2875 /* Show number of LSA. */
2876 vty_out (vty
, " Number of LSA %ld%s", area
->lsdb
->total
, VTY_NEWLINE
);
2877 vty_out (vty
, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
2878 ospf_lsdb_count (area
->lsdb
, OSPF_ROUTER_LSA
),
2879 ospf_lsdb_checksum (area
->lsdb
, OSPF_ROUTER_LSA
), VTY_NEWLINE
);
2880 vty_out (vty
, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
2881 ospf_lsdb_count (area
->lsdb
, OSPF_NETWORK_LSA
),
2882 ospf_lsdb_checksum (area
->lsdb
, OSPF_NETWORK_LSA
), VTY_NEWLINE
);
2883 vty_out (vty
, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
2884 ospf_lsdb_count (area
->lsdb
, OSPF_SUMMARY_LSA
),
2885 ospf_lsdb_checksum (area
->lsdb
, OSPF_SUMMARY_LSA
), VTY_NEWLINE
);
2886 vty_out (vty
, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
2887 ospf_lsdb_count (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
),
2888 ospf_lsdb_checksum (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
), VTY_NEWLINE
);
2889 vty_out (vty
, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
2890 ospf_lsdb_count (area
->lsdb
, OSPF_AS_NSSA_LSA
),
2891 ospf_lsdb_checksum (area
->lsdb
, OSPF_AS_NSSA_LSA
), VTY_NEWLINE
);
2896 json_object_int_add(json_area
, "lsaOpaqueLinkNumber", ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
2897 json_object_int_add(json_area
, "lsaOpaqueLinkChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
2898 json_object_int_add(json_area
, "lsaOpaqueAreaNumber", ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
2899 json_object_int_add(json_area
, "lsaOpaqueAreaChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
2903 vty_out (vty
, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
2904 ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
),
2905 ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
), VTY_NEWLINE
);
2906 vty_out (vty
, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
2907 ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
),
2908 ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
), VTY_NEWLINE
);
2912 json_object_object_add(json_areas
, inet_ntoa (area
->area_id
), json_area
);
2914 vty_out (vty
, "%s", VTY_NEWLINE
);
2918 show_ip_ospf_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
2920 struct listnode
*node
, *nnode
;
2921 struct ospf_area
* area
;
2922 struct timeval result
;
2923 char timebuf
[OSPF_TIME_DUMP_SIZE
];
2924 json_object
*json
= NULL
;
2925 json_object
*json_areas
= NULL
;
2929 json
= json_object_new_object();
2930 json_areas
= json_object_new_object();
2937 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
2941 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
2942 VTY_NEWLINE
, VTY_NEWLINE
);
2946 /* Show Router ID. */
2949 json_object_string_add(json
, "routerId", inet_ntoa (ospf
->router_id
));
2953 vty_out (vty
, " OSPF Routing Process, Router ID: %s%s",
2954 inet_ntoa (ospf
->router_id
),
2958 /* Graceful shutdown */
2959 if (ospf
->t_deferred_shutdown
)
2964 time_store
= monotime_until(&ospf
->t_deferred_shutdown
->u
.sands
, NULL
) / 1000LL;
2965 json_object_int_add(json
, "deferredShutdownMsecs", time_store
);
2969 vty_out (vty
, " Deferred shutdown in progress, %s remaining%s",
2970 ospf_timer_dump (ospf
->t_deferred_shutdown
,
2971 timebuf
, sizeof (timebuf
)), VTY_NEWLINE
);
2975 /* Show capability. */
2978 json_object_boolean_true_add(json
, "tosRoutesOnly");
2979 json_object_boolean_true_add(json
, "rfc2328Conform");
2980 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
2982 json_object_boolean_true_add(json
, "rfc1583Compatibility");
2987 vty_out (vty
, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE
);
2988 vty_out (vty
, " This implementation conforms to RFC2328%s", VTY_NEWLINE
);
2989 vty_out (vty
, " RFC1583Compatibility flag is %s%s",
2990 CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
) ?
2991 "enabled" : "disabled", VTY_NEWLINE
);
2996 if (CHECK_FLAG (ospf
->config
, OSPF_OPAQUE_CAPABLE
))
2998 json_object_boolean_true_add(json
, "opaqueCapable");
3003 vty_out (vty
, " OpaqueCapability flag is %s%s",
3004 CHECK_FLAG (ospf
->config
, OSPF_OPAQUE_CAPABLE
) ? "enabled" : "disabled",
3008 /* Show stub-router configuration */
3009 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
3010 || ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3014 json_object_boolean_true_add(json
, "stubAdvertisement");
3015 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3016 json_object_int_add(json
,"postStartEnabledMsecs", ospf
->stub_router_startup_time
/ 1000);
3017 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3018 json_object_int_add(json
,"preShutdownEnabledMsecs", ospf
->stub_router_shutdown_time
/ 1000);
3022 vty_out (vty
, " Stub router advertisement is configured%s",
3024 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3025 vty_out (vty
, " Enabled for %us after start-up%s",
3026 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
3027 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3028 vty_out (vty
, " Enabled for %us prior to full shutdown%s",
3029 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
3033 /* Show SPF timers. */
3036 json_object_int_add(json
, "spfScheduleDelayMsecs", ospf
->spf_delay
);
3037 json_object_int_add(json
, "holdtimeMinMsecs", ospf
->spf_holdtime
);
3038 json_object_int_add(json
, "holdtimeMaxMsecs", ospf
->spf_max_holdtime
);
3039 json_object_int_add(json
, "holdtimeMultplier", ospf
->spf_hold_multiplier
);
3043 vty_out (vty
, " Initial SPF scheduling delay %d millisec(s)%s"
3044 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
3045 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
3046 " Hold time multiplier is currently %d%s",
3047 ospf
->spf_delay
, VTY_NEWLINE
,
3048 ospf
->spf_holdtime
, VTY_NEWLINE
,
3049 ospf
->spf_max_holdtime
, VTY_NEWLINE
,
3050 ospf
->spf_hold_multiplier
, VTY_NEWLINE
);
3055 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
)
3057 long time_store
= 0;
3059 time_store
= monotime_since(&ospf
->ts_spf
, NULL
) / 1000LL;
3060 json_object_int_add(json
, "spfLastExecutedMsecs", time_store
);
3062 time_store
= (1000 * ospf
->ts_spf_duration
.tv_sec
) + (ospf
->ts_spf_duration
.tv_usec
/ 1000);
3063 json_object_int_add(json
, "spfLastDurationMsecs", time_store
);
3066 json_object_boolean_true_add(json
, "spfHasNotRun");
3070 vty_out (vty
, " SPF algorithm ");
3071 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
)
3073 monotime_since(&ospf
->ts_spf
, &result
);
3074 vty_out (vty
, "last executed %s ago%s",
3075 ospf_timeval_dump (&result
, timebuf
, sizeof (timebuf
)),
3077 vty_out (vty
, " Last SPF duration %s%s",
3078 ospf_timeval_dump (&ospf
->ts_spf_duration
, timebuf
, sizeof (timebuf
)),
3082 vty_out (vty
, "has not been run%s", VTY_NEWLINE
);
3087 if (ospf
->t_spf_calc
)
3090 time_store
= monotime_until(&ospf
->t_spf_calc
->u
.sands
, NULL
) / 1000LL;
3091 json_object_int_add(json
, "spfTimerDueInMsecs", time_store
);
3094 json_object_int_add(json
, "lsaMinIntervalMsecs", ospf
->min_ls_interval
);
3095 json_object_int_add(json
, "lsaMinArrivalMsecs", ospf
->min_ls_arrival
);
3096 /* Show write multiplier values */
3097 json_object_int_add(json
, "writeMultiplier", ospf
->write_oi_count
);
3098 /* Show refresh parameters. */
3099 json_object_int_add(json
, "refreshTimerMsecs", ospf
->lsa_refresh_interval
* 1000);
3103 vty_out (vty
, " SPF timer %s%s%s",
3104 (ospf
->t_spf_calc
? "due in " : "is "),
3105 ospf_timer_dump (ospf
->t_spf_calc
, timebuf
, sizeof (timebuf
)),
3108 vty_out (vty
, " LSA minimum interval %d msecs%s",
3109 ospf
->min_ls_interval
, VTY_NEWLINE
);
3110 vty_out (vty
, " LSA minimum arrival %d msecs%s",
3111 ospf
->min_ls_arrival
, VTY_NEWLINE
);
3113 /* Show write multiplier values */
3114 vty_out (vty
, " Write Multiplier set to %d %s",
3115 ospf
->write_oi_count
, VTY_NEWLINE
);
3117 /* Show refresh parameters. */
3118 vty_out (vty
, " Refresh timer %d secs%s",
3119 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
3122 /* Show ABR/ASBR flags. */
3123 if (CHECK_FLAG (ospf
->flags
, OSPF_FLAG_ABR
))
3126 json_object_string_add(json
, "abrType", ospf_abr_type_descr_str
[ospf
->abr_type
]);
3128 vty_out (vty
, " This router is an ABR, ABR type is: %s%s",
3129 ospf_abr_type_descr_str
[ospf
->abr_type
], VTY_NEWLINE
);
3131 if (CHECK_FLAG (ospf
->flags
, OSPF_FLAG_ASBR
))
3134 json_object_string_add(json
, "asbrRouter", "injectingExternalRoutingInformation");
3136 vty_out (vty
, " This router is an ASBR "
3137 "(injecting external routing information)%s", VTY_NEWLINE
);
3140 /* Show Number of AS-external-LSAs. */
3143 json_object_int_add(json
, "lsaExternalCounter",
3144 ospf_lsdb_count (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3145 json_object_int_add(json
, "lsaExternalChecksum",
3146 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3150 vty_out (vty
, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
3151 ospf_lsdb_count (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
),
3152 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
), VTY_NEWLINE
);
3157 json_object_int_add(json
, "lsaAsopaqueCounter",
3158 ospf_lsdb_count (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3159 json_object_int_add(json
, "lsaAsOpaqueChecksum",
3160 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3164 vty_out (vty
, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
3165 ospf_lsdb_count (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
),
3166 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
), VTY_NEWLINE
);
3169 /* Show number of areas attached. */
3171 json_object_int_add(json
, "attachedAreaCounter", listcount (ospf
->areas
));
3173 vty_out (vty
, " Number of areas attached to this router: %d%s",
3174 listcount (ospf
->areas
), VTY_NEWLINE
);
3176 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
))
3178 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
3181 json_object_boolean_true_add(json
, "adjacencyChangesLoggedAll");
3183 vty_out(vty
, " All adjacency changes are logged%s",VTY_NEWLINE
);
3188 json_object_boolean_true_add(json
, "adjacencyChangesLogged");
3190 vty_out(vty
, " Adjacency changes are logged%s",VTY_NEWLINE
);
3193 /* Show each area status. */
3194 for (ALL_LIST_ELEMENTS (ospf
->areas
, node
, nnode
, area
))
3195 show_ip_ospf_area (vty
, area
, json_areas
, use_json
);
3199 json_object_object_add(json
, "areas", json_areas
);
3200 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3201 json_object_free(json
);
3204 vty_out (vty
, "%s",VTY_NEWLINE
);
3209 DEFUN (show_ip_ospf
,
3211 "show ip ospf [json]",
3214 "OSPF information\n"
3218 u_char uj
= use_json(argc
, argv
);
3220 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3223 return (show_ip_ospf_common(vty
, ospf
, uj
));
3226 DEFUN (show_ip_ospf_instance
,
3227 show_ip_ospf_instance_cmd
,
3228 "show ip ospf (1-65535) [json]",
3231 "OSPF information\n"
3237 u_short instance
= 0;
3238 u_char uj
= use_json(argc
, argv
);
3240 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3241 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
3244 return (show_ip_ospf_common(vty
, ospf
, uj
));
3248 show_ip_ospf_interface_sub (struct vty
*vty
, struct ospf
*ospf
, struct interface
*ifp
,
3249 json_object
*json_interface_sub
, u_char use_json
)
3252 struct ospf_neighbor
*nbr
;
3253 struct route_node
*rn
;
3255 /* Is interface up? */
3258 is_up
= if_is_operative(ifp
);
3260 json_object_boolean_true_add(json_interface_sub
, "ifUp");
3262 json_object_boolean_false_add(json_interface_sub
, "ifDown");
3264 json_object_int_add(json_interface_sub
, "ifIndex", ifp
->ifindex
);
3265 json_object_int_add(json_interface_sub
, "mtuBytes", ifp
->mtu
);
3266 json_object_int_add(json_interface_sub
, "bandwidthMbit", ifp
->bandwidth
);
3267 json_object_string_add(json_interface_sub
, "ifFlags", if_flag_dump(ifp
->flags
));
3271 vty_out (vty
, "%s is %s%s", ifp
->name
,
3272 ((is_up
= if_is_operative(ifp
)) ? "up" : "down"), VTY_NEWLINE
);
3273 vty_out (vty
, " ifindex %u, MTU %u bytes, BW %u Mbit %s%s",
3274 ifp
->ifindex
, ifp
->mtu
, ifp
->bandwidth
, if_flag_dump(ifp
->flags
),
3278 /* Is interface OSPF enabled? */
3281 if (ospf_oi_count(ifp
) == 0)
3283 json_object_boolean_false_add(json_interface_sub
, "ospfEnabled");
3288 json_object_boolean_false_add(json_interface_sub
, "ospfRunning");
3292 json_object_boolean_true_add(json_interface_sub
, "ospfEnabled");
3296 if (ospf_oi_count(ifp
) == 0)
3298 vty_out (vty
, " OSPF not enabled on this interface%s", VTY_NEWLINE
);
3303 vty_out (vty
, " OSPF is enabled, but not running on this interface%s",
3309 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
3311 struct ospf_interface
*oi
= rn
->info
;
3316 if (CHECK_FLAG(oi
->connected
->flags
, ZEBRA_IFA_UNNUMBERED
))
3319 json_object_boolean_true_add(json_interface_sub
, "ifUnnumbered");
3321 vty_out (vty
, " This interface is UNNUMBERED,");
3325 /* Show OSPF interface information. */
3328 json_object_string_add(json_interface_sub
, "ipAddress", inet_ntoa (oi
->address
->u
.prefix4
));
3329 json_object_int_add(json_interface_sub
, "ipAddressPrefixlen", oi
->address
->prefixlen
);
3332 vty_out (vty
, " Internet Address %s/%d,",
3333 inet_ntoa (oi
->address
->u
.prefix4
), oi
->address
->prefixlen
);
3335 if (oi
->connected
->destination
|| oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3337 struct in_addr
*dest
;
3340 if (CONNECTED_PEER(oi
->connected
)
3341 || oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3346 /* For Vlinks, showing the peer address is probably more
3347 * * * * * informative than the local interface that is being used
3349 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3350 dest
= &oi
->vl_data
->peer_addr
;
3352 dest
= &oi
->connected
->destination
->u
.prefix4
;
3356 json_object_string_add(json_interface_sub
, "ospfIfType", dstr
);
3357 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3358 json_object_string_add(json_interface_sub
, "vlinkPeer", inet_ntoa (*dest
));
3360 json_object_string_add(json_interface_sub
, "localIfUsed", inet_ntoa (*dest
));
3363 vty_out (vty
, " %s %s,", dstr
, inet_ntoa (*dest
));
3368 json_object_string_add(json_interface_sub
, "area", ospf_area_desc_string (oi
->area
));
3369 if (OSPF_IF_PARAM(oi
, mtu_ignore
))
3370 json_object_boolean_true_add(json_interface_sub
, "mtuMismatchDetect");
3371 json_object_string_add(json_interface_sub
, "routerId", inet_ntoa (ospf
->router_id
));
3372 json_object_string_add(json_interface_sub
, "networkType", ospf_network_type_str
[oi
->type
]);
3373 json_object_int_add(json_interface_sub
, "cost", oi
->output_cost
);
3374 json_object_int_add(json_interface_sub
, "transmitDelayMsecs", 1000 / OSPF_IF_PARAM (oi
,transmit_delay
));
3375 json_object_string_add(json_interface_sub
, "state", LOOKUP (ospf_ism_state_msg
, oi
->state
));
3376 json_object_int_add(json_interface_sub
, "priority", PRIORITY (oi
));
3380 vty_out (vty
, " Area %s%s", ospf_area_desc_string (oi
->area
),
3383 vty_out (vty
, " MTU mismatch detection:%s%s",
3384 OSPF_IF_PARAM(oi
, mtu_ignore
) ? "disabled" : "enabled", VTY_NEWLINE
);
3386 vty_out (vty
, " Router ID %s, Network Type %s, Cost: %d%s",
3387 inet_ntoa (ospf
->router_id
), ospf_network_type_str
[oi
->type
],
3388 oi
->output_cost
, VTY_NEWLINE
);
3390 vty_out (vty
, " Transmit Delay is %d sec, State %s, Priority %d%s",
3391 OSPF_IF_PARAM (oi
,transmit_delay
), LOOKUP (ospf_ism_state_msg
, oi
->state
),
3392 PRIORITY (oi
), VTY_NEWLINE
);
3395 /* Show DR information. */
3396 if (DR (oi
).s_addr
== 0)
3399 vty_out (vty
, " No backup designated router on this network%s",
3404 nbr
= ospf_nbr_lookup_by_addr (oi
->nbrs
, &BDR (oi
));
3408 vty_out (vty
, " No backup designated router on this network%s",
3415 json_object_string_add(json_interface_sub
, "bdrId", inet_ntoa (nbr
->router_id
));
3416 json_object_string_add(json_interface_sub
, "bdrAddress", inet_ntoa (nbr
->address
.u
.prefix4
));
3420 vty_out (vty
, " Backup Designated Router (ID) %s,",
3421 inet_ntoa (nbr
->router_id
));
3422 vty_out (vty
, " Interface Address %s%s",
3423 inet_ntoa (nbr
->address
.u
.prefix4
), VTY_NEWLINE
);
3428 /* Next network-LSA sequence number we'll use, if we're elected DR */
3429 if (oi
->params
&& ntohl (oi
->params
->network_lsa_seqnum
) != OSPF_INITIAL_SEQUENCE_NUMBER
)
3432 json_object_int_add(json_interface_sub
, "networkLsaSequence", ntohl (oi
->params
->network_lsa_seqnum
));
3434 vty_out (vty
, " Saved Network-LSA sequence number 0x%x%s",
3435 ntohl (oi
->params
->network_lsa_seqnum
), VTY_NEWLINE
);
3440 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3441 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3443 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3444 json_object_boolean_true_add(json_interface_sub
, "mcastMemberOspfAllRouters");
3445 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3446 json_object_boolean_true_add(json_interface_sub
, "mcastMemberOspfDesignatedRouters");
3451 vty_out (vty
, " Multicast group memberships:");
3452 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3453 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3455 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3456 vty_out (vty
, " OSPFAllRouters");
3457 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3458 vty_out (vty
, " OSPFDesignatedRouters");
3461 vty_out (vty
, " <None>");
3462 vty_out (vty
, "%s", VTY_NEWLINE
);
3467 if (OSPF_IF_PARAM (oi
, fast_hello
) == 0)
3468 json_object_int_add(json_interface_sub
, "timerMsecs", 1000 /OSPF_IF_PARAM (oi
, v_hello
));
3470 json_object_int_add(json_interface_sub
, "timerMsecs", 1000 / OSPF_IF_PARAM (oi
, fast_hello
));
3471 json_object_int_add(json_interface_sub
, "timerDeadMsecs", 1000 / OSPF_IF_PARAM (oi
, v_wait
));
3472 json_object_int_add(json_interface_sub
, "timerWaitMsecs", 1000 / OSPF_IF_PARAM (oi
, v_wait
));
3473 json_object_int_add(json_interface_sub
, "timerRetransmit", 1000 / OSPF_IF_PARAM (oi
, retransmit_interval
));
3477 vty_out (vty
, " Timer intervals configured,");
3478 vty_out (vty
, " Hello ");
3479 if (OSPF_IF_PARAM (oi
, fast_hello
) == 0)
3480 vty_out (vty
, "%ds,", OSPF_IF_PARAM (oi
, v_hello
));
3482 vty_out (vty
, "%dms,", 1000 / OSPF_IF_PARAM (oi
, fast_hello
));
3483 vty_out (vty
, " Dead %ds, Wait %ds, Retransmit %d%s",
3484 OSPF_IF_PARAM (oi
, v_wait
),
3485 OSPF_IF_PARAM (oi
, v_wait
),
3486 OSPF_IF_PARAM (oi
, retransmit_interval
),
3490 if (OSPF_IF_PASSIVE_STATUS (oi
) == OSPF_IF_ACTIVE
)
3492 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3495 long time_store
= 0;
3497 time_store
= monotime_until(&oi
->t_hello
->u
.sands
, NULL
) / 1000LL;
3498 json_object_int_add(json_interface_sub
, "timerHelloInMsecs", time_store
);
3501 vty_out (vty
, " Hello due in %s%s",
3502 ospf_timer_dump (oi
->t_hello
, timebuf
, sizeof(timebuf
)),
3505 else /* passive-interface is set */
3508 json_object_boolean_true_add(json_interface_sub
, "timerPassiveIface");
3510 vty_out (vty
, " No Hellos (Passive interface)%s", VTY_NEWLINE
);
3515 json_object_int_add(json_interface_sub
, "nbrCount", ospf_nbr_count (oi
, 0));
3516 json_object_int_add(json_interface_sub
, "nbrAdjacentCount", ospf_nbr_count (oi
, NSM_Full
));
3519 vty_out (vty
, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
3520 ospf_nbr_count (oi
, 0), ospf_nbr_count (oi
, NSM_Full
),
3522 ospf_bfd_interface_show(vty
, ifp
, json_interface_sub
, use_json
);
3527 show_ip_ospf_interface_common (struct vty
*vty
, struct ospf
*ospf
, int argc
,
3528 struct cmd_token
**argv
, int iface_argv
, u_char use_json
)
3530 struct interface
*ifp
;
3531 struct listnode
*node
;
3532 json_object
*json
= NULL
;
3533 json_object
*json_interface_sub
= NULL
;
3537 json
= json_object_new_object();
3538 json_interface_sub
= json_object_new_object();
3544 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3546 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3547 VTY_NEWLINE
, VTY_NEWLINE
);
3550 if (argc
== iface_argv
)
3552 /* Show All Interfaces.*/
3553 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
3555 if (ospf_oi_count(ifp
))
3557 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3559 json_object_object_add (json
, ifp
->name
, json_interface_sub
);
3565 /* Interface name is specified. */
3566 if ((ifp
= if_lookup_by_name (argv
[iface_argv
]->arg
, VRF_DEFAULT
)) == NULL
)
3569 json_object_boolean_true_add(json
, "noSuchIface");
3571 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
3575 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3577 json_object_object_add(json
, ifp
->name
, json_interface_sub
);
3583 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3584 json_object_free(json
);
3587 vty_out (vty
, "%s", VTY_NEWLINE
);
3592 DEFUN (show_ip_ospf_interface
,
3593 show_ip_ospf_interface_cmd
,
3594 "show ip ospf interface [INTERFACE] [json]",
3597 "OSPF information\n"
3598 "Interface information\n"
3603 u_char uj
= use_json(argc
, argv
);
3605 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3611 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 4, uj
);
3614 DEFUN (show_ip_ospf_instance_interface
,
3615 show_ip_ospf_instance_interface_cmd
,
3616 "show ip ospf (1-65535) interface [INTERFACE] [json]",
3619 "OSPF information\n"
3621 "Interface information\n"
3627 u_short instance
= 0;
3628 u_char uj
= use_json(argc
, argv
);
3630 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3631 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
3637 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 5, uj
);
3641 show_ip_ospf_neighbour_header (struct vty
*vty
)
3643 vty_out (vty
, "%s%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
3645 "Neighbor ID", "Pri", "State", "Dead Time",
3646 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
3651 show_ip_ospf_neighbor_sub (struct vty
*vty
, struct ospf_interface
*oi
, json_object
*json
, u_char use_json
)
3653 struct route_node
*rn
;
3654 struct ospf_neighbor
*nbr
;
3656 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3657 json_object
*json_neighbor
= NULL
;
3659 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
3661 if ((nbr
= rn
->info
))
3663 /* Do not show myself. */
3664 if (nbr
!= oi
->nbr_self
)
3666 /* Down state is not shown. */
3667 if (nbr
->state
!= NSM_Down
)
3671 json_neighbor
= json_object_new_object();
3672 ospf_nbr_state_message (nbr
, msgbuf
, 16);
3676 time_store
= monotime_until(&nbr
->t_inactivity
->u
.sands
, NULL
) / 1000LL;
3678 json_object_int_add (json_neighbor
, "priority", nbr
->priority
);
3679 json_object_string_add (json_neighbor
, "state", msgbuf
);
3680 json_object_int_add (json_neighbor
, "deadTimeMsecs", time_store
);
3681 json_object_string_add (json_neighbor
, "address", inet_ntoa (nbr
->src
));
3682 json_object_string_add (json_neighbor
, "ifaceName", IF_NAME (oi
));
3683 json_object_int_add (json_neighbor
, "retransmitCounter", ospf_ls_retransmit_count (nbr
));
3684 json_object_int_add (json_neighbor
, "requestCounter", ospf_ls_request_count (nbr
));
3685 json_object_int_add (json_neighbor
, "dbSummaryCounter", ospf_db_summary_count (nbr
));
3686 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
3687 json_object_object_add(json
, "neighbor", json_neighbor
);
3689 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_neighbor
);
3693 ospf_nbr_state_message (nbr
, msgbuf
, 16);
3695 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
3696 vty_out (vty
, "%-15s %3d %-15s ",
3700 vty_out (vty
, "%-15s %3d %-15s ",
3701 inet_ntoa (nbr
->router_id
), nbr
->priority
,
3704 vty_out (vty
, "%9s ",
3705 ospf_timer_dump (nbr
->t_inactivity
, timebuf
,
3707 vty_out (vty
, "%-15s ", inet_ntoa (nbr
->src
));
3708 vty_out (vty
, "%-20s %5ld %5ld %5d%s",
3709 IF_NAME (oi
), ospf_ls_retransmit_count (nbr
),
3710 ospf_ls_request_count (nbr
), ospf_db_summary_count (nbr
),
3720 show_ip_ospf_neighbor_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
3722 struct ospf_interface
*oi
;
3723 struct listnode
*node
;
3724 json_object
*json
= NULL
;
3727 json
= json_object_new_object();
3729 show_ip_ospf_neighbour_header (vty
);
3734 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3736 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3737 VTY_NEWLINE
, VTY_NEWLINE
);
3740 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
3741 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
3745 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3746 json_object_free(json
);
3749 vty_out (vty
, "%s", VTY_NEWLINE
);
3754 DEFUN (show_ip_ospf_neighbor
,
3755 show_ip_ospf_neighbor_cmd
,
3756 "show ip ospf neighbor [json]",
3759 "OSPF information\n"
3764 u_char uj
= use_json(argc
, argv
);
3766 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3769 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
3773 DEFUN (show_ip_ospf_instance_neighbor
,
3774 show_ip_ospf_instance_neighbor_cmd
,
3775 "show ip ospf (1-65535) neighbor [json]",
3778 "OSPF information\n"
3785 u_short instance
= 0;
3786 u_char uj
= use_json(argc
, argv
);
3788 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3789 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
3792 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
3796 show_ip_ospf_neighbor_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
3798 struct listnode
*node
;
3799 struct ospf_interface
*oi
;
3800 json_object
*json
= NULL
;
3801 json_object
*json_neighbor_sub
= NULL
;
3805 json
= json_object_new_object();
3806 json_neighbor_sub
= json_object_new_object();
3809 show_ip_ospf_neighbour_header (vty
);
3814 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3816 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3817 VTY_NEWLINE
, VTY_NEWLINE
);
3820 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
3822 struct listnode
*nbr_node
;
3823 struct ospf_nbr_nbma
*nbr_nbma
;
3825 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
3827 /* print Down neighbor status */
3828 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nbr_node
, nbr_nbma
))
3830 if (nbr_nbma
->nbr
== NULL
3831 || nbr_nbma
->nbr
->state
== NSM_Down
)
3835 json_object_int_add (json_neighbor_sub
, "nbrNbmaPriority", nbr_nbma
->priority
);
3836 json_object_boolean_true_add (json_neighbor_sub
, "nbrNbmaDown");
3837 json_object_string_add (json_neighbor_sub
, "nbrNbmaIfaceName", IF_NAME (oi
));
3838 json_object_int_add (json_neighbor_sub
, "nbrNbmaRetransmitCounter", 0);
3839 json_object_int_add (json_neighbor_sub
, "nbrNbmaRequestCounter", 0);
3840 json_object_int_add (json_neighbor_sub
, "nbrNbmaDbSummaryCounter", 0);
3841 json_object_object_add(json
, inet_ntoa (nbr_nbma
->addr
), json_neighbor_sub
);
3845 vty_out (vty
, "%-15s %3d %-15s %9s ",
3846 "-", nbr_nbma
->priority
, "Down", "-");
3847 vty_out (vty
, "%-15s %-20s %5d %5d %5d%s",
3848 inet_ntoa (nbr_nbma
->addr
), IF_NAME (oi
),
3849 0, 0, 0, VTY_NEWLINE
);
3857 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3858 json_object_free(json
);
3861 vty_out (vty
, "%s", VTY_NEWLINE
);
3866 DEFUN (show_ip_ospf_neighbor_all
,
3867 show_ip_ospf_neighbor_all_cmd
,
3868 "show ip ospf neighbor all [json]",
3871 "OSPF information\n"
3873 "include down status neighbor\n"
3877 u_char uj
= use_json(argc
, argv
);
3879 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3882 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
3885 DEFUN (show_ip_ospf_instance_neighbor_all
,
3886 show_ip_ospf_instance_neighbor_all_cmd
,
3887 "show ip ospf (1-65535) neighbor all [json]",
3890 "OSPF information\n"
3893 "include down status neighbor\n"
3898 u_short instance
= 0;
3899 u_char uj
= use_json(argc
, argv
);
3901 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3902 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
3905 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
3909 show_ip_ospf_neighbor_int_common (struct vty
*vty
, struct ospf
*ospf
, int arg_base
,
3910 struct cmd_token
**argv
, u_char use_json
)
3912 struct interface
*ifp
;
3913 struct route_node
*rn
;
3914 json_object
*json
= NULL
;
3917 json
= json_object_new_object();
3919 show_ip_ospf_neighbour_header (vty
);
3924 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3926 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3927 VTY_NEWLINE
, VTY_NEWLINE
);
3930 ifp
= if_lookup_by_name (argv
[arg_base
]->arg
, VRF_DEFAULT
);
3934 json_object_boolean_true_add(json
, "noSuchIface");
3936 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
3940 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
3942 struct ospf_interface
*oi
= rn
->info
;
3947 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_int
,
3962 show_ip_ospf_neighbor_int_cmd
,
3963 "show ip ospf neighbor IFNAME [json]",
3966 "OSPF information\n"
3972 u_char uj
= use_json(argc
, argv
);
3974 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3977 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 0, argv
, uj
);
3980 DEFUN (show_ip_ospf_instance_neighbor_int
,
3981 show_ip_ospf_instance_neighbor_int_cmd
,
3982 "show ip ospf (1-65535) neighbor IFNAME [json]",
3985 "OSPF information\n"
3993 u_short instance
= 0;
3994 u_char uj
= use_json(argc
, argv
);
3996 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3997 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4000 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 1, argv
, uj
);
4004 show_ip_ospf_nbr_nbma_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
, struct ospf_nbr_nbma
*nbr_nbma
,
4005 u_char use_json
, json_object
*json
)
4007 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4008 json_object
*json_sub
= NULL
;
4011 json_sub
= json_object_new_object();
4012 else /* Show neighbor ID. */
4013 vty_out (vty
, " Neighbor %s,", "-");
4015 /* Show interface address. */
4017 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr_nbma
->addr
));
4019 vty_out (vty
, " interface address %s%s",
4020 inet_ntoa (nbr_nbma
->addr
), VTY_NEWLINE
);
4025 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4026 json_object_string_add(json_sub
, "iface", IF_NAME (oi
));
4029 vty_out (vty
, " In the area %s via interface %s%s",
4030 ospf_area_desc_string (oi
->area
), IF_NAME (oi
), VTY_NEWLINE
);
4032 /* Show neighbor priority and state. */
4035 json_object_int_add(json_sub
, "nbrPriority", nbr_nbma
->priority
);
4036 json_object_string_add(json_sub
, "nbrState", "down");
4039 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4040 nbr_nbma
->priority
, "Down");
4042 /* Show state changes. */
4044 json_object_int_add(json_sub
, "stateChangeCounter", nbr_nbma
->state_change
);
4046 vty_out (vty
, " %d state changes%s", nbr_nbma
->state_change
, VTY_NEWLINE
);
4048 /* Show PollInterval */
4050 json_object_int_add(json_sub
, "pollInterval", nbr_nbma
->v_poll
);
4052 vty_out (vty
, " Poll interval %d%s", nbr_nbma
->v_poll
, VTY_NEWLINE
);
4054 /* Show poll-interval timer. */
4058 time_store
= monotime_until(&nbr_nbma
->t_poll
->u
.sands
, NULL
) / 1000LL;
4059 json_object_int_add(json_sub
, "pollIntervalTimerDueMsec", time_store
);
4062 vty_out (vty
, " Poll timer due in %s%s",
4063 ospf_timer_dump (nbr_nbma
->t_poll
, timebuf
, sizeof(timebuf
)),
4066 /* Show poll-interval timer thread. */
4069 if (nbr_nbma
->t_poll
!= NULL
)
4070 json_object_string_add(json_sub
, "pollIntervalTimerThread", "on");
4073 vty_out (vty
, " Thread Poll Timer %s%s",
4074 nbr_nbma
->t_poll
!= NULL
? "on" : "off", VTY_NEWLINE
);
4077 json_object_object_add(json
, "noNbrId", json_sub
);
4081 show_ip_ospf_neighbor_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
,
4082 struct ospf_neighbor
*nbr
, u_char use_json
, json_object
*json
)
4084 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4085 json_object
*json_sub
= NULL
;
4088 json_sub
= json_object_new_object();
4091 /* Show neighbor ID. */
4092 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4093 vty_out (vty
, " Neighbor %s,", "-");
4095 vty_out (vty
, " Neighbor %s,", inet_ntoa (nbr
->router_id
));
4098 /* Show interface address. */
4100 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr
->address
.u
.prefix4
));
4102 vty_out (vty
, " interface address %s%s",
4103 inet_ntoa (nbr
->address
.u
.prefix4
), VTY_NEWLINE
);
4108 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4109 json_object_string_add(json_sub
, "ifaceName", oi
->ifp
->name
);
4112 vty_out (vty
, " In the area %s via interface %s%s",
4113 ospf_area_desc_string (oi
->area
), oi
->ifp
->name
, VTY_NEWLINE
);
4115 /* Show neighbor priority and state. */
4118 json_object_int_add(json_sub
, "nbrPriority", nbr
->priority
);
4119 json_object_string_add(json_sub
, "nbrState", LOOKUP (ospf_nsm_state_msg
, nbr
->state
));
4122 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4123 nbr
->priority
, LOOKUP (ospf_nsm_state_msg
, nbr
->state
));
4125 /* Show state changes. */
4127 json_object_int_add(json_sub
, "stateChangeCounter", nbr
->state_change
);
4129 vty_out (vty
, " %d state changes%s", nbr
->state_change
, VTY_NEWLINE
);
4131 if (nbr
->ts_last_progress
.tv_sec
|| nbr
->ts_last_progress
.tv_usec
)
4136 time_store
= monotime_since(&nbr
->ts_last_progress
, &res
) / 1000LL;
4139 json_object_int_add(json_sub
, "lastPrgrsvChangeMsec", time_store
);
4143 vty_out (vty
, " Most recent state change statistics:%s",
4145 vty_out (vty
, " Progressive change %s ago%s",
4146 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4151 if (nbr
->ts_last_regress
.tv_sec
|| nbr
->ts_last_regress
.tv_usec
)
4156 time_store
= monotime_since(&nbr
->ts_last_regress
, &res
) / 1000LL;
4159 json_object_int_add(json_sub
, "lastRegressiveChangeMsec", time_store
);
4160 if (nbr
->last_regress_str
)
4161 json_object_string_add(json_sub
, "lastRegressiveChangeReason", nbr
->last_regress_str
);
4165 vty_out (vty
, " Regressive change %s ago, due to %s%s",
4166 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4167 (nbr
->last_regress_str
? nbr
->last_regress_str
: "??"),
4172 /* Show Designated Rotuer ID. */
4174 json_object_string_add(json_sub
, "routerDesignatedId", inet_ntoa (nbr
->d_router
));
4176 vty_out (vty
, " DR is %s,", inet_ntoa (nbr
->d_router
));
4178 /* Show Backup Designated Rotuer ID. */
4180 json_object_string_add(json_sub
, "routerDesignatedBackupId", inet_ntoa (nbr
->bd_router
));
4182 vty_out (vty
, " BDR is %s%s", inet_ntoa (nbr
->bd_router
), VTY_NEWLINE
);
4187 json_object_int_add(json_sub
, "optionsCounter", nbr
->options
);
4188 json_object_string_add(json_sub
, "optionsList", ospf_options_dump (nbr
->options
));
4191 vty_out (vty
, " Options %d %s%s", nbr
->options
,
4192 ospf_options_dump (nbr
->options
), VTY_NEWLINE
);
4194 /* Show Router Dead interval timer. */
4197 if (nbr
->t_inactivity
)
4200 time_store
= monotime_until(&nbr
->t_inactivity
->u
.sands
, NULL
) / 1000LL;
4201 json_object_int_add(json_sub
, "routerDeadIntervalTimerDueMsec", time_store
);
4204 json_object_int_add(json_sub
, "routerDeadIntervalTimerDueMsec", -1);
4207 vty_out (vty
, " Dead timer due in %s%s",
4208 ospf_timer_dump (nbr
->t_inactivity
, timebuf
, sizeof (timebuf
)),
4211 /* Show Database Summary list. */
4213 json_object_int_add(json_sub
, "databaseSummaryListCounter", ospf_db_summary_count (nbr
));
4215 vty_out (vty
, " Database Summary List %d%s",
4216 ospf_db_summary_count (nbr
), VTY_NEWLINE
);
4218 /* Show Link State Request list. */
4220 json_object_int_add(json_sub
, "linkStateRequestListCounter", ospf_ls_request_count (nbr
));
4222 vty_out (vty
, " Link State Request List %ld%s",
4223 ospf_ls_request_count (nbr
), VTY_NEWLINE
);
4225 /* Show Link State Retransmission list. */
4227 json_object_int_add(json_sub
, "linkStateRetransmissionListCounter", ospf_ls_retransmit_count (nbr
));
4229 vty_out (vty
, " Link State Retransmission List %ld%s",
4230 ospf_ls_retransmit_count (nbr
), VTY_NEWLINE
);
4232 /* Show inactivity timer thread. */
4235 if (nbr
->t_inactivity
!= NULL
)
4236 json_object_string_add(json_sub
, "threadInactivityTimer", "on");
4239 vty_out (vty
, " Thread Inactivity Timer %s%s",
4240 nbr
->t_inactivity
!= NULL
? "on" : "off", VTY_NEWLINE
);
4242 /* Show Database Description retransmission thread. */
4245 if (nbr
->t_db_desc
!= NULL
)
4246 json_object_string_add(json_sub
, "threadDatabaseDescriptionRetransmission", "on");
4249 vty_out (vty
, " Thread Database Description Retransmision %s%s",
4250 nbr
->t_db_desc
!= NULL
? "on" : "off", VTY_NEWLINE
);
4252 /* Show Link State Request Retransmission thread. */
4255 if (nbr
->t_ls_req
!= NULL
)
4256 json_object_string_add(json_sub
, "threadLinkStateRequestRetransmission", "on");
4259 vty_out (vty
, " Thread Link State Request Retransmission %s%s",
4260 nbr
->t_ls_req
!= NULL
? "on" : "off", VTY_NEWLINE
);
4262 /* Show Link State Update Retransmission thread. */
4265 if (nbr
->t_ls_upd
!= NULL
)
4266 json_object_string_add(json_sub
, "threadLinkStateUpdateRetransmission", "on");
4269 vty_out (vty
, " Thread Link State Update Retransmission %s%s%s",
4270 nbr
->t_ls_upd
!= NULL
? "on" : "off", VTY_NEWLINE
, VTY_NEWLINE
);
4274 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4275 json_object_object_add(json
, "noNbrId", json_sub
);
4277 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_sub
);
4280 ospf_bfd_show_info(vty
, nbr
->bfd_info
, json
, use_json
, 0);
4284 show_ip_ospf_neighbor_id_common (struct vty
*vty
, struct ospf
*ospf
,
4285 int arg_base
, struct cmd_token
**argv
, u_char use_json
)
4287 struct listnode
*node
;
4288 struct ospf_neighbor
*nbr
;
4289 struct ospf_interface
*oi
;
4290 struct in_addr router_id
;
4292 json_object
*json
= NULL
;
4295 json
= json_object_new_object();
4300 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4302 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4303 VTY_NEWLINE
, VTY_NEWLINE
);
4306 ret
= inet_aton (argv
[arg_base
]->arg
, &router_id
);
4310 vty_out (vty
, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE
);
4314 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4316 if ((nbr
= ospf_nbr_lookup_by_routerid (oi
->nbrs
, &router_id
)))
4318 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4324 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4325 json_object_free(json
);
4328 vty_out (vty
, "%s", VTY_NEWLINE
);
4333 DEFUN (show_ip_ospf_neighbor_id
,
4334 show_ip_ospf_neighbor_id_cmd
,
4335 "show ip ospf neighbor A.B.C.D [json]",
4338 "OSPF information\n"
4344 u_char uj
= use_json(argc
, argv
);
4346 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4349 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 0, argv
, uj
);
4352 DEFUN (show_ip_ospf_instance_neighbor_id
,
4353 show_ip_ospf_instance_neighbor_id_cmd
,
4354 "show ip ospf (1-65535) neighbor A.B.C.D [json]",
4357 "OSPF information\n"
4365 u_short instance
= 0;
4366 u_char uj
= use_json(argc
, argv
);
4368 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4369 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4372 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 1, argv
, uj
);
4376 show_ip_ospf_neighbor_detail_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4378 struct ospf_interface
*oi
;
4379 struct listnode
*node
;
4380 json_object
*json
= NULL
;
4383 json
= json_object_new_object();
4388 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4390 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4391 VTY_NEWLINE
, VTY_NEWLINE
);
4394 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4396 struct route_node
*rn
;
4397 struct ospf_neighbor
*nbr
;
4399 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4401 if ((nbr
= rn
->info
))
4403 if (nbr
!= oi
->nbr_self
)
4405 if (nbr
->state
!= NSM_Down
)
4407 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4416 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4417 json_object_free(json
);
4420 vty_out (vty
, "%s", VTY_NEWLINE
);
4425 DEFUN (show_ip_ospf_neighbor_detail
,
4426 show_ip_ospf_neighbor_detail_cmd
,
4427 "show ip ospf neighbor detail [json]",
4430 "OSPF information\n"
4432 "detail of all neighbors\n"
4436 u_char uj
= use_json(argc
, argv
);
4438 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4441 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4444 DEFUN (show_ip_ospf_instance_neighbor_detail
,
4445 show_ip_ospf_instance_neighbor_detail_cmd
,
4446 "show ip ospf (1-65535) neighbor detail [json]",
4449 "OSPF information\n"
4452 "detail of all neighbors\n"
4457 u_short instance
= 0;
4458 u_char uj
= use_json(argc
, argv
);
4460 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4461 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
4464 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4468 show_ip_ospf_neighbor_detail_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4470 struct listnode
*node
;
4471 struct ospf_interface
*oi
;
4472 json_object
*json
= NULL
;
4475 json
= json_object_new_object();
4480 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4482 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4483 VTY_NEWLINE
, VTY_NEWLINE
);
4486 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4488 struct route_node
*rn
;
4489 struct ospf_neighbor
*nbr
;
4490 struct ospf_nbr_nbma
*nbr_nbma
;
4492 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4493 if ((nbr
= rn
->info
))
4494 if (nbr
!= oi
->nbr_self
)
4495 if (nbr
->state
!= NSM_Down
)
4496 show_ip_ospf_neighbor_detail_sub (vty
, oi
, rn
->info
, use_json
, json
);
4498 if (oi
->type
== OSPF_IFTYPE_NBMA
)
4500 struct listnode
*nd
;
4502 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nd
, nbr_nbma
))
4504 if (nbr_nbma
->nbr
== NULL
|| nbr_nbma
->nbr
->state
== NSM_Down
)
4505 show_ip_ospf_nbr_nbma_detail_sub (vty
, oi
, nbr_nbma
, use_json
, json
);
4512 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4513 json_object_free(json
);
4517 vty_out (vty
, "%s", VTY_NEWLINE
);
4523 DEFUN (show_ip_ospf_neighbor_detail_all
,
4524 show_ip_ospf_neighbor_detail_all_cmd
,
4525 "show ip ospf neighbor detail all [json]",
4528 "OSPF information\n"
4530 "detail of all neighbors\n"
4531 "include down status neighbor\n"
4535 u_char uj
= use_json(argc
, argv
);
4537 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4540 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4543 DEFUN (show_ip_ospf_instance_neighbor_detail_all
,
4544 show_ip_ospf_instance_neighbor_detail_all_cmd
,
4545 "show ip ospf (1-65535) neighbor detail all [json]",
4548 "OSPF information\n"
4551 "detail of all neighbors\n"
4552 "include down status neighbor\n"
4557 u_short instance
= 0;
4558 u_char uj
= use_json(argc
, argv
);
4560 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4561 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4564 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4568 show_ip_ospf_neighbor_int_detail_common (struct vty
*vty
, struct ospf
*ospf
,
4569 int arg_base
, struct cmd_token
**argv
, u_char use_json
)
4571 struct ospf_interface
*oi
;
4572 struct interface
*ifp
;
4573 struct route_node
*rn
, *nrn
;
4574 struct ospf_neighbor
*nbr
;
4575 json_object
*json
= NULL
;
4578 json
= json_object_new_object();
4583 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4585 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4586 VTY_NEWLINE
, VTY_NEWLINE
);
4589 ifp
= if_lookup_by_name (argv
[arg_base
]->arg
, VRF_DEFAULT
);
4593 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
4597 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
4599 if ((oi
= rn
->info
))
4601 for (nrn
= route_top (oi
->nbrs
); nrn
; nrn
= route_next (nrn
))
4603 if ((nbr
= nrn
->info
))
4605 if (nbr
!= oi
->nbr_self
)
4607 if (nbr
->state
!= NSM_Down
)
4608 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4617 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4618 json_object_free(json
);
4621 vty_out (vty
, "%s", VTY_NEWLINE
);
4626 DEFUN (show_ip_ospf_neighbor_int_detail
,
4627 show_ip_ospf_neighbor_int_detail_cmd
,
4628 "show ip ospf neighbor IFNAME detail [json]",
4631 "OSPF information\n"
4634 "detail of all neighbors\n"
4638 u_char uj
= use_json(argc
, argv
);
4640 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4643 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 0, argv
, uj
);
4646 DEFUN (show_ip_ospf_instance_neighbor_int_detail
,
4647 show_ip_ospf_instance_neighbor_int_detail_cmd
,
4648 "show ip ospf (1-65535) neighbor IFNAME detail [json]",
4651 "OSPF information\n"
4655 "detail of all neighbors\n"
4660 u_short instance
= 0;
4661 u_char uj
= use_json(argc
, argv
);
4663 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4664 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4667 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 1, argv
, uj
);
4670 /* Show functions */
4672 show_lsa_summary (struct vty
*vty
, struct ospf_lsa
*lsa
, int self
)
4674 struct router_lsa
*rl
;
4675 struct summary_lsa
*sl
;
4676 struct as_external_lsa
*asel
;
4677 struct prefix_ipv4 p
;
4680 /* If self option is set, check LSA self flag. */
4681 if (self
== 0 || IS_LSA_SELF (lsa
))
4683 /* LSA common part show. */
4684 vty_out (vty
, "%-15s ", inet_ntoa (lsa
->data
->id
));
4685 vty_out (vty
, "%-15s %4d 0x%08lx 0x%04x",
4686 inet_ntoa (lsa
->data
->adv_router
), LS_AGE (lsa
),
4687 (u_long
)ntohl (lsa
->data
->ls_seqnum
), ntohs (lsa
->data
->checksum
));
4688 /* LSA specific part show. */
4689 switch (lsa
->data
->type
)
4691 case OSPF_ROUTER_LSA
:
4692 rl
= (struct router_lsa
*) lsa
->data
;
4693 vty_out (vty
, " %-d", ntohs (rl
->links
));
4695 case OSPF_SUMMARY_LSA
:
4696 sl
= (struct summary_lsa
*) lsa
->data
;
4699 p
.prefix
= sl
->header
.id
;
4700 p
.prefixlen
= ip_masklen (sl
->mask
);
4701 apply_mask_ipv4 (&p
);
4703 vty_out (vty
, " %s/%d", inet_ntoa (p
.prefix
), p
.prefixlen
);
4705 case OSPF_AS_EXTERNAL_LSA
:
4706 case OSPF_AS_NSSA_LSA
:
4707 asel
= (struct as_external_lsa
*) lsa
->data
;
4710 p
.prefix
= asel
->header
.id
;
4711 p
.prefixlen
= ip_masklen (asel
->mask
);
4712 apply_mask_ipv4 (&p
);
4714 vty_out (vty
, " %s %s/%d [0x%lx]",
4715 IS_EXTERNAL_METRIC (asel
->e
[0].tos
) ? "E2" : "E1",
4716 inet_ntoa (p
.prefix
), p
.prefixlen
,
4717 (u_long
)ntohl (asel
->e
[0].route_tag
));
4719 case OSPF_NETWORK_LSA
:
4720 case OSPF_ASBR_SUMMARY_LSA
:
4721 case OSPF_OPAQUE_LINK_LSA
:
4722 case OSPF_OPAQUE_AREA_LSA
:
4723 case OSPF_OPAQUE_AS_LSA
:
4727 vty_out (vty
, VTY_NEWLINE
);
4733 static const char *show_database_desc
[] =
4736 "Router Link States",
4738 "Summary Link States",
4739 "ASBR-Summary Link States",
4740 "AS External Link States",
4741 "Group Membership LSA",
4742 "NSSA-external Link States",
4744 "Link-Local Opaque-LSA",
4745 "Area-Local Opaque-LSA",
4746 "AS-external Opaque-LSA",
4749 static const char *show_database_header
[] =
4752 "Link ID ADV Router Age Seq# CkSum Link count",
4753 "Link ID ADV Router Age Seq# CkSum",
4754 "Link ID ADV Router Age Seq# CkSum Route",
4755 "Link ID ADV Router Age Seq# CkSum",
4756 "Link ID ADV Router Age Seq# CkSum Route",
4757 " --- header for Group Member ----",
4758 "Link ID ADV Router Age Seq# CkSum Route",
4760 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4761 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4762 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4766 show_ip_ospf_database_header (struct vty
*vty
, struct ospf_lsa
*lsa
)
4768 struct router_lsa
*rlsa
= (struct router_lsa
*) lsa
->data
;
4770 vty_out (vty
, " LS age: %d%s", LS_AGE (lsa
), VTY_NEWLINE
);
4771 vty_out (vty
, " Options: 0x%-2x : %s%s",
4773 ospf_options_dump(lsa
->data
->options
),
4775 vty_out (vty
, " LS Flags: 0x%-2x %s%s",
4777 ((lsa
->flags
& OSPF_LSA_LOCAL_XLT
) ? "(Translated from Type-7)" : ""),
4780 if (lsa
->data
->type
== OSPF_ROUTER_LSA
)
4782 vty_out (vty
, " Flags: 0x%x" , rlsa
->flags
);
4785 vty_out (vty
, " :%s%s%s%s",
4786 IS_ROUTER_LSA_BORDER (rlsa
) ? " ABR" : "",
4787 IS_ROUTER_LSA_EXTERNAL (rlsa
) ? " ASBR" : "",
4788 IS_ROUTER_LSA_VIRTUAL (rlsa
) ? " VL-endpoint" : "",
4789 IS_ROUTER_LSA_SHORTCUT (rlsa
) ? " Shortcut" : "");
4791 vty_out (vty
, "%s", VTY_NEWLINE
);
4793 vty_out (vty
, " LS Type: %s%s",
4794 LOOKUP (ospf_lsa_type_msg
, lsa
->data
->type
), VTY_NEWLINE
);
4795 vty_out (vty
, " Link State ID: %s %s%s", inet_ntoa (lsa
->data
->id
),
4796 LOOKUP (ospf_link_state_id_type_msg
, lsa
->data
->type
), VTY_NEWLINE
);
4797 vty_out (vty
, " Advertising Router: %s%s",
4798 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
4799 vty_out (vty
, " LS Seq Number: %08lx%s", (u_long
)ntohl (lsa
->data
->ls_seqnum
),
4801 vty_out (vty
, " Checksum: 0x%04x%s", ntohs (lsa
->data
->checksum
),
4803 vty_out (vty
, " Length: %d%s", ntohs (lsa
->data
->length
), VTY_NEWLINE
);
4806 const char *link_type_desc
[] =
4809 "another Router (point-to-point)",
4810 "a Transit Network",
4815 const char *link_id_desc
[] =
4818 "Neighboring Router ID",
4819 "Designated Router address",
4821 "Neighboring Router ID",
4824 const char *link_data_desc
[] =
4827 "Router Interface address",
4828 "Router Interface address",
4830 "Router Interface address",
4833 /* Show router-LSA each Link information. */
4835 show_ip_ospf_database_router_links (struct vty
*vty
,
4836 struct router_lsa
*rl
)
4841 len
= ntohs (rl
->header
.length
) - 4;
4842 for (i
= 0; i
< ntohs (rl
->links
) && len
> 0; len
-= 12, i
++)
4844 type
= rl
->link
[i
].type
;
4846 vty_out (vty
, " Link connected to: %s%s",
4847 link_type_desc
[type
], VTY_NEWLINE
);
4848 vty_out (vty
, " (Link ID) %s: %s%s", link_id_desc
[type
],
4849 inet_ntoa (rl
->link
[i
].link_id
), VTY_NEWLINE
);
4850 vty_out (vty
, " (Link Data) %s: %s%s", link_data_desc
[type
],
4851 inet_ntoa (rl
->link
[i
].link_data
), VTY_NEWLINE
);
4852 vty_out (vty
, " Number of TOS metrics: 0%s", VTY_NEWLINE
);
4853 vty_out (vty
, " TOS 0 Metric: %d%s",
4854 ntohs (rl
->link
[i
].metric
), VTY_NEWLINE
);
4855 vty_out (vty
, "%s", VTY_NEWLINE
);
4859 /* Show router-LSA detail information. */
4861 show_router_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4865 struct router_lsa
*rl
= (struct router_lsa
*) lsa
->data
;
4867 show_ip_ospf_database_header (vty
, lsa
);
4869 vty_out (vty
, " Number of Links: %d%s%s", ntohs (rl
->links
),
4870 VTY_NEWLINE
, VTY_NEWLINE
);
4872 show_ip_ospf_database_router_links (vty
, rl
);
4873 vty_out (vty
, "%s", VTY_NEWLINE
);
4879 /* Show network-LSA detail information. */
4881 show_network_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4887 struct network_lsa
*nl
= (struct network_lsa
*) lsa
->data
;
4889 show_ip_ospf_database_header (vty
, lsa
);
4891 vty_out (vty
, " Network Mask: /%d%s",
4892 ip_masklen (nl
->mask
), VTY_NEWLINE
);
4894 length
= ntohs (lsa
->data
->length
) - OSPF_LSA_HEADER_SIZE
- 4;
4896 for (i
= 0; length
> 0; i
++, length
-= 4)
4897 vty_out (vty
, " Attached Router: %s%s",
4898 inet_ntoa (nl
->routers
[i
]), VTY_NEWLINE
);
4900 vty_out (vty
, "%s", VTY_NEWLINE
);
4906 /* Show summary-LSA detail information. */
4908 show_summary_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4912 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
4914 show_ip_ospf_database_header (vty
, lsa
);
4916 vty_out (vty
, " Network Mask: /%d%s", ip_masklen (sl
->mask
),
4918 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
4920 vty_out (vty
, "%s", VTY_NEWLINE
);
4926 /* Show summary-ASBR-LSA detail information. */
4928 show_summary_asbr_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4932 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
4934 show_ip_ospf_database_header (vty
, lsa
);
4936 vty_out (vty
, " Network Mask: /%d%s",
4937 ip_masklen (sl
->mask
), VTY_NEWLINE
);
4938 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
4940 vty_out (vty
, "%s", VTY_NEWLINE
);
4946 /* Show AS-external-LSA detail information. */
4948 show_as_external_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4952 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
4954 show_ip_ospf_database_header (vty
, lsa
);
4956 vty_out (vty
, " Network Mask: /%d%s",
4957 ip_masklen (al
->mask
), VTY_NEWLINE
);
4958 vty_out (vty
, " Metric Type: %s%s",
4959 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
4960 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
4961 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
4962 vty_out (vty
, " Metric: %d%s",
4963 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
4964 vty_out (vty
, " Forward Address: %s%s",
4965 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
4967 vty_out (vty
, " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
4968 (route_tag_t
)ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
4975 show_as_external_lsa_stdvty (struct ospf_lsa
*lsa
)
4977 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
4979 /* show_ip_ospf_database_header (vty, lsa); */
4981 zlog_debug( " Network Mask: /%d%s",
4982 ip_masklen (al
->mask
), "\n");
4983 zlog_debug( " Metric Type: %s%s",
4984 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
4985 "2 (Larger than any link state path)" : "1", "\n");
4986 zlog_debug( " TOS: 0%s", "\n");
4987 zlog_debug( " Metric: %d%s",
4988 GET_METRIC (al
->e
[0].metric
), "\n");
4989 zlog_debug( " Forward Address: %s%s",
4990 inet_ntoa (al
->e
[0].fwd_addr
), "\n");
4992 zlog_debug( " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
4993 (route_tag_t
)ntohl (al
->e
[0].route_tag
), "\n", "\n");
4998 /* Show AS-NSSA-LSA detail information. */
5000 show_as_nssa_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5004 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5006 show_ip_ospf_database_header (vty
, lsa
);
5008 vty_out (vty
, " Network Mask: /%d%s",
5009 ip_masklen (al
->mask
), VTY_NEWLINE
);
5010 vty_out (vty
, " Metric Type: %s%s",
5011 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5012 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
5013 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
5014 vty_out (vty
, " Metric: %d%s",
5015 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
5016 vty_out (vty
, " NSSA: Forward Address: %s%s",
5017 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
5019 vty_out (vty
, " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5020 (route_tag_t
)ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
5027 show_func_dummy (struct vty
*vty
, struct ospf_lsa
*lsa
)
5033 show_opaque_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5037 show_ip_ospf_database_header (vty
, lsa
);
5038 show_opaque_info_detail (vty
, lsa
);
5040 vty_out (vty
, "%s", VTY_NEWLINE
);
5045 int (*show_function
[])(struct vty
*, struct ospf_lsa
*) =
5048 show_router_lsa_detail
,
5049 show_network_lsa_detail
,
5050 show_summary_lsa_detail
,
5051 show_summary_asbr_lsa_detail
,
5052 show_as_external_lsa_detail
,
5054 show_as_nssa_lsa_detail
, /* almost same as external */
5056 show_opaque_lsa_detail
,
5057 show_opaque_lsa_detail
,
5058 show_opaque_lsa_detail
,
5062 show_lsa_prefix_set (struct vty
*vty
, struct prefix_ls
*lp
, struct in_addr
*id
,
5063 struct in_addr
*adv_router
)
5065 memset (lp
, 0, sizeof (struct prefix_ls
));
5069 else if (adv_router
== NULL
)
5078 lp
->adv_router
= *adv_router
;
5083 show_lsa_detail_proc (struct vty
*vty
, struct route_table
*rt
,
5084 struct in_addr
*id
, struct in_addr
*adv_router
)
5086 struct prefix_ls lp
;
5087 struct route_node
*rn
, *start
;
5088 struct ospf_lsa
*lsa
;
5090 show_lsa_prefix_set (vty
, &lp
, id
, adv_router
);
5091 start
= route_node_get (rt
, (struct prefix
*) &lp
);
5094 route_lock_node (start
);
5095 for (rn
= start
; rn
; rn
= route_next_until (rn
, start
))
5096 if ((lsa
= rn
->info
))
5098 if (show_function
[lsa
->data
->type
] != NULL
)
5099 show_function
[lsa
->data
->type
] (vty
, lsa
);
5101 route_unlock_node (start
);
5105 /* Show detail LSA information
5106 -- if id is NULL then show all LSAs. */
5108 show_lsa_detail (struct vty
*vty
, struct ospf
*ospf
, int type
,
5109 struct in_addr
*id
, struct in_addr
*adv_router
)
5111 struct listnode
*node
;
5112 struct ospf_area
*area
;
5116 case OSPF_AS_EXTERNAL_LSA
:
5117 case OSPF_OPAQUE_AS_LSA
:
5118 vty_out (vty
, " %s %s%s",
5119 show_database_desc
[type
],
5120 VTY_NEWLINE
, VTY_NEWLINE
);
5121 show_lsa_detail_proc (vty
, AS_LSDB (ospf
, type
), id
, adv_router
);
5124 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5126 vty_out (vty
, "%s %s (Area %s)%s%s",
5127 VTY_NEWLINE
, show_database_desc
[type
],
5128 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5129 show_lsa_detail_proc (vty
, AREA_LSDB (area
, type
), id
, adv_router
);
5136 show_lsa_detail_adv_router_proc (struct vty
*vty
, struct route_table
*rt
,
5137 struct in_addr
*adv_router
)
5139 struct route_node
*rn
;
5140 struct ospf_lsa
*lsa
;
5142 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
5143 if ((lsa
= rn
->info
))
5144 if (IPV4_ADDR_SAME (adv_router
, &lsa
->data
->adv_router
))
5146 if (CHECK_FLAG (lsa
->flags
, OSPF_LSA_LOCAL_XLT
))
5148 if (show_function
[lsa
->data
->type
] != NULL
)
5149 show_function
[lsa
->data
->type
] (vty
, lsa
);
5153 /* Show detail LSA information. */
5155 show_lsa_detail_adv_router (struct vty
*vty
, struct ospf
*ospf
, int type
,
5156 struct in_addr
*adv_router
)
5158 struct listnode
*node
;
5159 struct ospf_area
*area
;
5163 case OSPF_AS_EXTERNAL_LSA
:
5164 case OSPF_OPAQUE_AS_LSA
:
5165 vty_out (vty
, " %s %s%s",
5166 show_database_desc
[type
],
5167 VTY_NEWLINE
, VTY_NEWLINE
);
5168 show_lsa_detail_adv_router_proc (vty
, AS_LSDB (ospf
, type
),
5172 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5174 vty_out (vty
, "%s %s (Area %s)%s%s",
5175 VTY_NEWLINE
, show_database_desc
[type
],
5176 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5177 show_lsa_detail_adv_router_proc (vty
, AREA_LSDB (area
, type
),
5185 show_ip_ospf_database_summary (struct vty
*vty
, struct ospf
*ospf
, int self
)
5187 struct ospf_lsa
*lsa
;
5188 struct route_node
*rn
;
5189 struct ospf_area
*area
;
5190 struct listnode
*node
;
5193 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5195 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5199 case OSPF_AS_EXTERNAL_LSA
:
5200 case OSPF_OPAQUE_AS_LSA
:
5205 if (ospf_lsdb_count_self (area
->lsdb
, type
) > 0 ||
5206 (!self
&& ospf_lsdb_count (area
->lsdb
, type
) > 0))
5208 vty_out (vty
, " %s (Area %s)%s%s",
5209 show_database_desc
[type
],
5210 ospf_area_desc_string (area
),
5211 VTY_NEWLINE
, VTY_NEWLINE
);
5212 vty_out (vty
, "%s%s", show_database_header
[type
], VTY_NEWLINE
);
5214 LSDB_LOOP (AREA_LSDB (area
, type
), rn
, lsa
)
5215 show_lsa_summary (vty
, lsa
, self
);
5217 vty_out (vty
, "%s", VTY_NEWLINE
);
5222 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5226 case OSPF_AS_EXTERNAL_LSA
:
5227 case OSPF_OPAQUE_AS_LSA
:
5232 if (ospf_lsdb_count_self (ospf
->lsdb
, type
) ||
5233 (!self
&& ospf_lsdb_count (ospf
->lsdb
, type
)))
5235 vty_out (vty
, " %s%s%s",
5236 show_database_desc
[type
],
5237 VTY_NEWLINE
, VTY_NEWLINE
);
5238 vty_out (vty
, "%s%s", show_database_header
[type
],
5241 LSDB_LOOP (AS_LSDB (ospf
, type
), rn
, lsa
)
5242 show_lsa_summary (vty
, lsa
, self
);
5244 vty_out (vty
, "%s", VTY_NEWLINE
);
5248 vty_out (vty
, "%s", VTY_NEWLINE
);
5252 show_ip_ospf_database_maxage (struct vty
*vty
, struct ospf
*ospf
)
5254 struct route_node
*rn
;
5256 vty_out (vty
, "%s MaxAge Link States:%s%s",
5257 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
5259 for (rn
= route_top (ospf
->maxage_lsa
); rn
; rn
= route_next (rn
))
5261 struct ospf_lsa
*lsa
;
5263 if ((lsa
= rn
->info
) != NULL
)
5265 vty_out (vty
, "Link type: %d%s", lsa
->data
->type
, VTY_NEWLINE
);
5266 vty_out (vty
, "Link State ID: %s%s",
5267 inet_ntoa (lsa
->data
->id
), VTY_NEWLINE
);
5268 vty_out (vty
, "Advertising Router: %s%s",
5269 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
5270 vty_out (vty
, "LSA lock count: %d%s", lsa
->lock
, VTY_NEWLINE
);
5271 vty_out (vty
, "%s", VTY_NEWLINE
);
5276 #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
5277 #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
5279 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
5280 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
5281 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
5282 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
5284 #define OSPF_LSA_TYPES_DESC \
5285 "ASBR summary link states\n" \
5286 "External link states\n" \
5287 "Network link states\n" \
5288 "Router link states\n" \
5289 "Network summary link states\n" \
5290 OSPF_LSA_TYPE_NSSA_DESC \
5291 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
5292 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
5293 OSPF_LSA_TYPE_OPAQUE_AS_DESC
5296 show_ip_ospf_database_common (struct vty
*vty
, struct ospf
*ospf
,
5297 int arg_base
, int argc
, struct cmd_token
**argv
)
5301 struct in_addr id
, adv_router
;
5304 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5307 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5308 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5311 if (argc
== arg_base
+ 4)
5313 show_ip_ospf_database_summary (vty
, ospf
, 0);
5317 /* Set database type to show. */
5318 if (strncmp (argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5319 type
= OSPF_ROUTER_LSA
;
5320 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5321 type
= OSPF_NETWORK_LSA
;
5322 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5323 type
= OSPF_AS_NSSA_LSA
;
5324 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "su", 2) == 0)
5325 type
= OSPF_SUMMARY_LSA
;
5326 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5327 type
= OSPF_ASBR_SUMMARY_LSA
;
5328 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5329 type
= OSPF_AS_EXTERNAL_LSA
;
5330 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "se", 2) == 0)
5332 show_ip_ospf_database_summary (vty
, ospf
, 1);
5335 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "m", 1) == 0)
5337 show_ip_ospf_database_maxage (vty
, ospf
);
5340 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5341 type
= OSPF_OPAQUE_LINK_LSA
;
5342 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5343 type
= OSPF_OPAQUE_AREA_LSA
;
5344 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5345 type
= OSPF_OPAQUE_AS_LSA
;
5349 /* `show ip ospf database LSA'. */
5350 if (argc
== arg_base
+ 5)
5351 show_lsa_detail (vty
, ospf
, type
, NULL
, NULL
);
5352 else if (argc
>= arg_base
+ 6)
5354 ret
= inet_aton (argv
[arg_base
+ 5]->arg
, &id
);
5358 /* `show ip ospf database LSA ID'. */
5359 if (argc
== arg_base
+ 6)
5360 show_lsa_detail (vty
, ospf
, type
, &id
, NULL
);
5361 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
5362 else if (argc
== arg_base
+ 7)
5364 if (strncmp (argv
[arg_base
+ 6]->text
, "s", 1) == 0)
5365 adv_router
= ospf
->router_id
;
5368 ret
= inet_aton (argv
[arg_base
+ 7]->arg
, &adv_router
);
5372 show_lsa_detail (vty
, ospf
, type
, &id
, &adv_router
);
5379 DEFUN (show_ip_ospf_database_max
,
5380 show_ip_ospf_database_max_cmd
,
5381 "show ip ospf database <max-age|self-originate>",
5384 "OSPF information\n"
5385 "Database summary\n"
5386 "LSAs in MaxAge list\n"
5387 "Self-originated link states\n")
5391 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5394 return (show_ip_ospf_database_common(vty
, ospf
, 0, argc
, argv
));
5397 DEFUN (show_ip_ospf_instance_database
,
5398 show_ip_ospf_instance_database_cmd
,
5399 "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>]]]",
5402 "OSPF information\n"
5404 "Database summary\n"
5406 "Link State ID (as an IP address)\n"
5407 "Self-originated link states\n"
5408 "Advertising Router link states\n"
5409 "Advertising Router (as an IP address)\n")
5412 u_short instance
= 0;
5415 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
5417 VTY_GET_INTEGER ("Instance", instance
, argv
[idx
]->arg
);
5418 ospf
= ospf_lookup_instance (instance
);
5421 ospf
= ospf_lookup();
5424 if (!ospf
|| !ospf
->oi_running
)
5427 return (show_ip_ospf_database_common(vty
, ospf
, idx
? 1 : 0, argc
, argv
));
5430 DEFUN (show_ip_ospf_instance_database_max
,
5431 show_ip_ospf_instance_database_max_cmd
,
5432 "show ip ospf (1-65535) database <max-age|self-originate>",
5435 "OSPF information\n"
5437 "Database summary\n"
5438 "LSAs in MaxAge list\n"
5439 "Self-originated link states\n")
5443 u_short instance
= 0;
5445 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
5447 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5450 return (show_ip_ospf_database_common(vty
, ospf
, 1, argc
, argv
));
5455 show_ip_ospf_database_type_adv_router_common (struct vty
*vty
, struct ospf
*ospf
,
5456 int arg_base
, int argc
, struct cmd_token
**argv
)
5460 struct in_addr adv_router
;
5463 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5466 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5467 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5469 if (argc
!= arg_base
+ 7)
5472 /* Set database type to show. */
5473 if (strncmp (argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5474 type
= OSPF_ROUTER_LSA
;
5475 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5476 type
= OSPF_NETWORK_LSA
;
5477 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5478 type
= OSPF_AS_NSSA_LSA
;
5479 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "s", 1) == 0)
5480 type
= OSPF_SUMMARY_LSA
;
5481 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5482 type
= OSPF_ASBR_SUMMARY_LSA
;
5483 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5484 type
= OSPF_AS_EXTERNAL_LSA
;
5485 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5486 type
= OSPF_OPAQUE_LINK_LSA
;
5487 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5488 type
= OSPF_OPAQUE_AREA_LSA
;
5489 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5490 type
= OSPF_OPAQUE_AS_LSA
;
5494 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
5495 if (strncmp (argv
[arg_base
+ 5]->text
, "s", 1) == 0)
5496 adv_router
= ospf
->router_id
;
5499 ret
= inet_aton (argv
[arg_base
+ 6]->arg
, &adv_router
);
5504 show_lsa_detail_adv_router (vty
, ospf
, type
, &adv_router
);
5509 DEFUN (show_ip_ospf_database_type_adv_router
,
5510 show_ip_ospf_database_type_adv_router_cmd
,
5511 "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>",
5514 "OSPF information\n"
5515 "Database summary\n"
5517 "Advertising Router link states\n"
5518 "Advertising Router (as an IP address)\n"
5519 "Self-originated link states\n")
5523 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5526 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 0, argc
, argv
));
5529 DEFUN (show_ip_ospf_instance_database_type_adv_router
,
5530 show_ip_ospf_instance_database_type_adv_router_cmd
,
5531 "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>",
5534 "OSPF information\n"
5536 "Database summary\n"
5538 "Advertising Router link states\n"
5539 "Advertising Router (as an IP address)\n"
5540 "Self-originated link states\n")
5544 u_short instance
= 0;
5546 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
5548 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5551 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 1, argc
, argv
));
5554 DEFUN (ip_ospf_authentication_args
,
5555 ip_ospf_authentication_args_addr_cmd
,
5556 "ip ospf authentication <null|message-digest> [A.B.C.D]",
5558 "OSPF interface commands\n"
5559 "Enable authentication on this interface\n"
5560 "Use null authentication\n"
5561 "Use message-digest authentication\n"
5562 "Address of interface\n")
5564 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5565 int idx_encryption
= 3;
5567 struct in_addr addr
;
5569 struct ospf_if_params
*params
;
5571 params
= IF_DEF_PARAMS (ifp
);
5575 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5578 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5583 params
= ospf_get_if_params (ifp
, addr
);
5584 ospf_if_update_params (ifp
, addr
);
5587 /* Handle null authentication */
5588 if ( argv
[idx_encryption
]->arg
[0] == 'n' )
5590 SET_IF_PARAM (params
, auth_type
);
5591 params
->auth_type
= OSPF_AUTH_NULL
;
5595 /* Handle message-digest authentication */
5596 if ( argv
[idx_encryption
]->arg
[0] == 'm' )
5598 SET_IF_PARAM (params
, auth_type
);
5599 params
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5603 vty_out (vty
, "You shouldn't get here!%s", VTY_NEWLINE
);
5607 DEFUN (ip_ospf_authentication
,
5608 ip_ospf_authentication_addr_cmd
,
5609 "ip ospf authentication [A.B.C.D]",
5611 "OSPF interface commands\n"
5612 "Enable authentication on this interface\n"
5613 "Address of interface")
5615 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5617 struct in_addr addr
;
5619 struct ospf_if_params
*params
;
5621 params
= IF_DEF_PARAMS (ifp
);
5625 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5628 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5633 params
= ospf_get_if_params (ifp
, addr
);
5634 ospf_if_update_params (ifp
, addr
);
5637 SET_IF_PARAM (params
, auth_type
);
5638 params
->auth_type
= OSPF_AUTH_SIMPLE
;
5643 DEFUN (no_ip_ospf_authentication_args
,
5644 no_ip_ospf_authentication_args_addr_cmd
,
5645 "no ip ospf authentication <null|message-digest> [A.B.C.D]",
5648 "OSPF interface commands\n"
5649 "Enable authentication on this interface\n"
5650 "Use null authentication\n"
5651 "Use message-digest authentication\n"
5652 "Address of interface")
5654 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5655 int idx_encryption
= 4;
5657 struct in_addr addr
;
5659 struct ospf_if_params
*params
;
5660 struct route_node
*rn
;
5663 params
= IF_DEF_PARAMS (ifp
);
5667 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5670 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5675 params
= ospf_lookup_if_params (ifp
, addr
);
5678 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
5681 params
->auth_type
= OSPF_AUTH_NOTSET
;
5682 UNSET_IF_PARAM (params
, auth_type
);
5683 if (params
!= IF_DEF_PARAMS (ifp
))
5685 ospf_free_if_params (ifp
, addr
);
5686 ospf_if_update_params (ifp
, addr
);
5691 if ( argv
[idx_encryption
]->arg
[0] == 'n' )
5693 auth_type
= OSPF_AUTH_NULL
;
5695 else if ( argv
[idx_encryption
]->arg
[0] == 'm' )
5697 auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5701 vty_out (vty
, "Unexpected input encountered%s", VTY_NEWLINE
);
5705 * Here we have a case where the user has entered
5706 * 'no ip ospf authentication (null | message_digest )'
5707 * we need to find if we have any ip addresses underneath it that
5708 * correspond to the associated type.
5710 if (params
->auth_type
== auth_type
)
5712 params
->auth_type
= OSPF_AUTH_NOTSET
;
5713 UNSET_IF_PARAM (params
, auth_type
);
5716 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
5718 if ((params
= rn
->info
))
5720 if (params
->auth_type
== auth_type
)
5722 params
->auth_type
= OSPF_AUTH_NOTSET
;
5723 UNSET_IF_PARAM (params
, auth_type
);
5724 if (params
!= IF_DEF_PARAMS (ifp
))
5726 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
5727 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
5737 DEFUN (no_ip_ospf_authentication
,
5738 no_ip_ospf_authentication_addr_cmd
,
5739 "no ip ospf authentication [A.B.C.D]",
5742 "OSPF interface commands\n"
5743 "Enable authentication on this interface\n"
5744 "Address of interface")
5746 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5748 struct in_addr addr
;
5750 struct ospf_if_params
*params
;
5751 struct route_node
*rn
;
5753 params
= IF_DEF_PARAMS (ifp
);
5757 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5760 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5765 params
= ospf_lookup_if_params (ifp
, addr
);
5768 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
5772 params
->auth_type
= OSPF_AUTH_NOTSET
;
5773 UNSET_IF_PARAM (params
, auth_type
);
5774 if (params
!= IF_DEF_PARAMS (ifp
))
5776 ospf_free_if_params (ifp
, addr
);
5777 ospf_if_update_params (ifp
, addr
);
5783 * When a user enters 'no ip ospf authentication'
5784 * We should remove all authentication types from
5787 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
5788 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
5789 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
5791 params
->auth_type
= OSPF_AUTH_NOTSET
;
5792 UNSET_IF_PARAM (params
, auth_type
);
5795 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
5797 if ((params
= rn
->info
))
5800 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
5801 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
5802 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
5804 params
->auth_type
= OSPF_AUTH_NOTSET
;
5805 UNSET_IF_PARAM (params
, auth_type
);
5806 if (params
!= IF_DEF_PARAMS (ifp
))
5808 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
5809 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
5820 DEFUN (ip_ospf_authentication_key
,
5821 ip_ospf_authentication_key_addr_cmd
,
5822 "ip ospf authentication-key AUTH_KEY [A.B.C.D]",
5824 "OSPF interface commands\n"
5825 "Authentication password (key)\n"
5826 "The OSPF password (key)\n"
5827 "Address of interface")
5829 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5831 struct in_addr addr
;
5832 struct ospf_if_params
*params
;
5834 params
= IF_DEF_PARAMS (ifp
);
5836 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
5838 if (!inet_aton(argv
[idx
]->arg
, &addr
))
5840 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5845 params
= ospf_get_if_params (ifp
, addr
);
5846 ospf_if_update_params (ifp
, addr
);
5849 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
5850 strncpy ((char *) params
->auth_simple
, argv
[3]->arg
, OSPF_AUTH_SIMPLE_SIZE
);
5851 SET_IF_PARAM (params
, auth_simple
);
5856 DEFUN_HIDDEN (ospf_authentication_key
,
5857 ospf_authentication_key_cmd
,
5858 "ospf authentication-key AUTH_KEY [A.B.C.D]",
5859 "OSPF interface commands\n"
5860 "Authentication password (key)\n"
5861 "The OSPF password (key)\n"
5862 "Address of interface\n")
5864 return ip_ospf_authentication_key (self
, vty
, argc
, argv
);
5867 DEFUN (no_ip_ospf_authentication_key
,
5868 no_ip_ospf_authentication_key_authkey_addr_cmd
,
5869 "no ip ospf authentication-key [AUTH_KEY [A.B.C.D]]",
5872 "OSPF interface commands\n"
5873 "Authentication password (key)\n"
5874 "The OSPF password (key)")
5876 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5878 struct in_addr addr
;
5879 struct ospf_if_params
*params
;
5880 params
= IF_DEF_PARAMS (ifp
);
5882 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
5884 if (!inet_aton(argv
[idx
]->arg
, &addr
))
5886 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5891 params
= ospf_lookup_if_params (ifp
, addr
);
5896 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
);
5897 UNSET_IF_PARAM (params
, auth_simple
);
5899 if (params
!= IF_DEF_PARAMS (ifp
))
5901 ospf_free_if_params (ifp
, addr
);
5902 ospf_if_update_params (ifp
, addr
);
5908 DEFUN_HIDDEN (no_ospf_authentication_key
,
5909 no_ospf_authentication_key_authkey_addr_cmd
,
5910 "no ospf authentication-key [AUTH_KEY [A.B.C.D]]",
5912 "OSPF interface commands\n"
5913 "Authentication password (key)\n"
5914 "The OSPF password (key)")
5916 return no_ip_ospf_authentication_key (self
, vty
, argc
, argv
);
5919 DEFUN (ip_ospf_message_digest_key
,
5920 ip_ospf_message_digest_key_cmd
,
5921 "ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
5923 "OSPF interface commands\n"
5924 "Message digest authentication password (key)\n"
5926 "Use MD5 algorithm\n"
5927 "The OSPF password (key)\n"
5928 "Address of interface\n")
5930 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5931 struct crypt_key
*ck
;
5933 struct in_addr addr
;
5934 struct ospf_if_params
*params
;
5936 params
= IF_DEF_PARAMS (ifp
);
5939 argv_find (argv
, argc
, "(1-255)", &idx
);
5940 char *keyid
= argv
[idx
]->arg
;
5941 argv_find (argv
, argc
, "KEY", &idx
);
5942 char *cryptkey
= argv
[idx
]->arg
;
5944 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
5946 if (!inet_aton(argv
[idx
]->arg
, &addr
))
5948 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5953 params
= ospf_get_if_params (ifp
, addr
);
5954 ospf_if_update_params (ifp
, addr
);
5957 key_id
= strtol (keyid
, NULL
, 10);
5958 if (ospf_crypt_key_lookup (params
->auth_crypt
, key_id
) != NULL
)
5960 vty_out (vty
, "OSPF: Key %d already exists%s", key_id
, VTY_NEWLINE
);
5964 ck
= ospf_crypt_key_new ();
5965 ck
->key_id
= (u_char
) key_id
;
5966 memset (ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
5967 strncpy ((char *) ck
->auth_key
, cryptkey
, OSPF_AUTH_MD5_SIZE
);
5969 ospf_crypt_key_add (params
->auth_crypt
, ck
);
5970 SET_IF_PARAM (params
, auth_crypt
);
5975 DEFUN_HIDDEN (ospf_message_digest_key
,
5976 ospf_message_digest_key_cmd
,
5977 "ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
5978 "OSPF interface commands\n"
5979 "Message digest authentication password (key)\n"
5981 "Use MD5 algorithm\n"
5982 "The OSPF password (key)\n"
5983 "Address of interface\n")
5985 return ip_ospf_message_digest_key (self
, vty
, argc
, argv
);
5988 DEFUN (no_ip_ospf_message_digest_key
,
5989 no_ip_ospf_message_digest_key_cmd
,
5990 "no ip ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
5993 "OSPF interface commands\n"
5994 "Message digest authentication password (key)\n"
5996 "Use MD5 algorithm\n"
5997 "The OSPF password (key)\n"
5998 "Address of interface\n")
6000 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6002 struct crypt_key
*ck
;
6004 struct in_addr addr
;
6005 struct ospf_if_params
*params
;
6006 params
= IF_DEF_PARAMS (ifp
);
6008 argv_find (argv
, argc
, "(1-255)", &idx
);
6009 char *keyid
= argv
[idx
]->arg
;
6011 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6013 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6015 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6020 params
= ospf_lookup_if_params (ifp
, addr
);
6025 key_id
= strtol (keyid
, NULL
, 10);
6026 ck
= ospf_crypt_key_lookup (params
->auth_crypt
, key_id
);
6029 vty_out (vty
, "OSPF: Key %d does not exist%s", key_id
, VTY_NEWLINE
);
6033 ospf_crypt_key_delete (params
->auth_crypt
, key_id
);
6035 if (params
!= IF_DEF_PARAMS (ifp
))
6037 ospf_free_if_params (ifp
, addr
);
6038 ospf_if_update_params (ifp
, addr
);
6044 DEFUN_HIDDEN (no_ospf_message_digest_key
,
6045 no_ospf_message_digest_key_cmd
,
6046 "no ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
6048 "OSPF interface commands\n"
6049 "Message digest authentication password (key)\n"
6051 "Address of interface")
6053 return no_ip_ospf_message_digest_key (self
, vty
, argc
, argv
);
6056 DEFUN (ip_ospf_cost
,
6058 "ip ospf cost (1-65535) [A.B.C.D]",
6060 "OSPF interface commands\n"
6063 "Address of interface\n")
6065 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6068 struct in_addr addr
;
6069 struct ospf_if_params
*params
;
6070 params
= IF_DEF_PARAMS (ifp
);
6073 char *coststr
= NULL
, *ifaddr
= NULL
;
6074 coststr
= argv_find (argv
, argc
, "(1-65535)", &idx
) ? argv
[idx
]->arg
: NULL
;
6075 ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6077 cost
= strtol (coststr
, NULL
, 10);
6081 if(!inet_aton(ifaddr
, &addr
))
6083 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6088 params
= ospf_get_if_params (ifp
, addr
);
6089 ospf_if_update_params (ifp
, addr
);
6092 SET_IF_PARAM (params
, output_cost_cmd
);
6093 params
->output_cost_cmd
= cost
;
6095 ospf_if_recalculate_output_cost (ifp
);
6100 DEFUN_HIDDEN (ospf_cost
,
6102 "ospf cost (1-65535) [A.B.C.D]",
6103 "OSPF interface commands\n"
6106 "Address of interface\n")
6108 return ip_ospf_cost (self
, vty
, argc
, argv
);
6111 DEFUN (no_ip_ospf_cost
,
6112 no_ip_ospf_cost_cmd
,
6113 "no ip ospf cost [(1-65535)] [A.B.C.D]",
6115 "OSPF interface commands\n"
6117 "Address of interface")
6119 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6121 struct in_addr addr
;
6122 struct ospf_if_params
*params
;
6124 params
= IF_DEF_PARAMS (ifp
);
6127 char *ifaddr
= NULL
;
6128 ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6130 /* According to the semantics we are mimicking "no ip ospf cost N" is
6131 * always treated as "no ip ospf cost" regardless of the actual value
6132 * of N already configured for the interface. Thus ignore cost. */
6136 if (!inet_aton(ifaddr
, &addr
))
6138 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6143 params
= ospf_lookup_if_params (ifp
, addr
);
6148 UNSET_IF_PARAM (params
, output_cost_cmd
);
6150 if (params
!= IF_DEF_PARAMS (ifp
))
6152 ospf_free_if_params (ifp
, addr
);
6153 ospf_if_update_params (ifp
, addr
);
6156 ospf_if_recalculate_output_cost (ifp
);
6161 DEFUN_HIDDEN (no_ospf_cost
,
6163 "no ospf cost [(1-65535)] [A.B.C.D]",
6165 "OSPF interface commands\n"
6168 "Address of interface\n")
6170 return no_ip_ospf_cost (self
, vty
, argc
, argv
);
6174 ospf_nbr_timer_update (struct ospf_interface
*oi
)
6176 struct route_node
*rn
;
6177 struct ospf_neighbor
*nbr
;
6179 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
6180 if ((nbr
= rn
->info
))
6182 nbr
->v_inactivity
= OSPF_IF_PARAM (oi
, v_wait
);
6183 nbr
->v_db_desc
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6184 nbr
->v_ls_req
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6185 nbr
->v_ls_upd
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6190 ospf_vty_dead_interval_set (struct vty
*vty
, const char *interval_str
,
6191 const char *nbr_str
,
6192 const char *fast_hello_str
)
6194 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6197 struct in_addr addr
;
6199 struct ospf_if_params
*params
;
6200 struct ospf_interface
*oi
;
6201 struct route_node
*rn
;
6203 params
= IF_DEF_PARAMS (ifp
);
6207 ret
= inet_aton(nbr_str
, &addr
);
6210 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6215 params
= ospf_get_if_params (ifp
, addr
);
6216 ospf_if_update_params (ifp
, addr
);
6221 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds
, interval_str
,
6224 /* reset fast_hello too, just to be sure */
6225 UNSET_IF_PARAM (params
, fast_hello
);
6226 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6228 else if (fast_hello_str
)
6230 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult
, fast_hello_str
,
6232 /* 1s dead-interval with sub-second hellos desired */
6233 seconds
= OSPF_ROUTER_DEAD_INTERVAL_MINIMAL
;
6234 SET_IF_PARAM (params
, fast_hello
);
6235 params
->fast_hello
= hellomult
;
6239 vty_out (vty
, "Please specify dead-interval or hello-multiplier%s",
6244 SET_IF_PARAM (params
, v_wait
);
6245 params
->v_wait
= seconds
;
6247 /* Update timer values in neighbor structure. */
6251 if ((ospf
= ospf_lookup()))
6253 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
6255 ospf_nbr_timer_update (oi
);
6260 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6261 if ((oi
= rn
->info
))
6262 ospf_nbr_timer_update (oi
);
6268 DEFUN (ip_ospf_dead_interval
,
6269 ip_ospf_dead_interval_cmd
,
6270 "ip ospf dead-interval (1-65535) [A.B.C.D]",
6272 "OSPF interface commands\n"
6273 "Interval time after which a neighbor is declared down\n"
6275 "Address of interface\n")
6278 char *interval
= argv_find (argv
, argc
, "(1-65535)", &idx
) ? argv
[idx
]->arg
: NULL
;
6279 char *ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6280 return ospf_vty_dead_interval_set (vty
, interval
, ifaddr
, NULL
);
6284 DEFUN_HIDDEN (ospf_dead_interval
,
6285 ospf_dead_interval_cmd
,
6286 "ospf dead-interval (1-65535) [A.B.C.D]",
6287 "OSPF interface commands\n"
6288 "Interval time after which a neighbor is declared down\n"
6290 "Address of interface\n")
6292 return ip_ospf_dead_interval (self
, vty
, argc
, argv
);
6295 DEFUN (ip_ospf_dead_interval_minimal
,
6296 ip_ospf_dead_interval_minimal_addr_cmd
,
6297 "ip ospf dead-interval minimal hello-multiplier (1-10) [A.B.C.D]",
6299 "OSPF interface commands\n"
6300 "Interval time after which a neighbor is declared down\n"
6301 "Minimal 1s dead-interval with fast sub-second hellos\n"
6302 "Hello multiplier factor\n"
6303 "Number of Hellos to send each second\n"
6304 "Address of interface\n")
6309 return ospf_vty_dead_interval_set (vty
, NULL
, argv
[idx_ipv4
]->arg
, argv
[idx_number
]->arg
);
6311 return ospf_vty_dead_interval_set (vty
, NULL
, NULL
, argv
[idx_number
]->arg
);
6314 DEFUN (no_ip_ospf_dead_interval
,
6315 no_ip_ospf_dead_interval_cmd
,
6316 "no ip ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6319 "OSPF interface commands\n"
6320 "Interval time after which a neighbor is declared down\n"
6322 "Address of interface")
6324 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6325 int idx_ipv4
= argc
- 1;
6326 struct in_addr addr
= { .s_addr
= 0L};
6328 struct ospf_if_params
*params
;
6329 struct ospf_interface
*oi
;
6330 struct route_node
*rn
;
6332 params
= IF_DEF_PARAMS (ifp
);
6334 if (argv
[idx_ipv4
]->type
== IPV4_TKN
)
6336 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6339 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6344 params
= ospf_lookup_if_params (ifp
, addr
);
6349 UNSET_IF_PARAM (params
, v_wait
);
6350 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
6352 UNSET_IF_PARAM (params
, fast_hello
);
6353 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6355 if (params
!= IF_DEF_PARAMS (ifp
))
6357 ospf_free_if_params (ifp
, addr
);
6358 ospf_if_update_params (ifp
, addr
);
6361 /* Update timer values in neighbor structure. */
6366 if ((ospf
= ospf_lookup()))
6368 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
6370 ospf_nbr_timer_update (oi
);
6375 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6376 if ((oi
= rn
->info
))
6377 ospf_nbr_timer_update (oi
);
6383 DEFUN_HIDDEN (no_ospf_dead_interval
,
6384 no_ospf_dead_interval_cmd
,
6385 "no ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6387 "OSPF interface commands\n"
6388 "Interval time after which a neighbor is declared down\n"
6390 "Address of interface")
6392 return no_ip_ospf_dead_interval (self
, vty
, argc
, argv
);
6395 DEFUN (ip_ospf_hello_interval
,
6396 ip_ospf_hello_interval_cmd
,
6397 "ip ospf hello-interval (1-65535) [A.B.C.D]",
6399 "OSPF interface commands\n"
6400 "Time between HELLO packets\n"
6402 "Address of interface\n")
6404 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6406 struct in_addr addr
;
6407 struct ospf_if_params
*params
;
6408 params
= IF_DEF_PARAMS (ifp
);
6409 u_int32_t seconds
= 0;
6411 argv_find (argv
, argc
, "(1-65535)", &idx
);
6412 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
6414 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6416 if(!inet_aton(argv
[idx
]->arg
, &addr
))
6418 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6423 params
= ospf_get_if_params (ifp
, addr
);
6424 ospf_if_update_params (ifp
, addr
);
6427 SET_IF_PARAM (params
, v_hello
);
6428 params
->v_hello
= seconds
;
6433 DEFUN_HIDDEN (ospf_hello_interval
,
6434 ospf_hello_interval_cmd
,
6435 "ospf hello-interval (1-65535) [A.B.C.D]",
6436 "OSPF interface commands\n"
6437 "Time between HELLO packets\n"
6439 "Address of interface\n")
6441 return ip_ospf_hello_interval (self
, vty
, argc
, argv
);
6444 DEFUN (no_ip_ospf_hello_interval
,
6445 no_ip_ospf_hello_interval_cmd
,
6446 "no ip ospf hello-interval [(1-65535) [A.B.C.D]]",
6449 "OSPF interface commands\n"
6450 "Time between HELLO packets\n" // ignored
6452 "Address of interface\n")
6454 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6456 struct in_addr addr
;
6457 struct ospf_if_params
*params
;
6459 params
= IF_DEF_PARAMS (ifp
);
6461 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6463 if(!inet_aton(argv
[idx
]->arg
, &addr
))
6465 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6470 params
= ospf_lookup_if_params (ifp
, addr
);
6475 UNSET_IF_PARAM (params
, v_hello
);
6476 params
->v_hello
= OSPF_HELLO_INTERVAL_DEFAULT
;
6478 if (params
!= IF_DEF_PARAMS (ifp
))
6480 ospf_free_if_params (ifp
, addr
);
6481 ospf_if_update_params (ifp
, addr
);
6487 DEFUN_HIDDEN (no_ospf_hello_interval
,
6488 no_ospf_hello_interval_cmd
,
6489 "no ospf hello-interval [(1-65535) [A.B.C.D]]",
6491 "OSPF interface commands\n"
6492 "Time between HELLO packets\n" // ignored
6494 "Address of interface\n")
6496 return no_ip_ospf_hello_interval (self
, vty
, argc
, argv
);
6499 DEFUN (ip_ospf_network
,
6500 ip_ospf_network_cmd
,
6501 "ip ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
6503 "OSPF interface commands\n"
6505 "Specify OSPF broadcast multi-access network\n"
6506 "Specify OSPF NBMA network\n"
6507 "Specify OSPF point-to-multipoint network\n"
6508 "Specify OSPF point-to-point network\n")
6510 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6512 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
6513 struct route_node
*rn
;
6515 if (old_type
== OSPF_IFTYPE_LOOPBACK
)
6517 vty_out (vty
, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE
);
6521 if (argv_find (argv
, argc
, "broadcast", &idx
))
6522 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_BROADCAST
;
6523 else if (argv_find (argv
, argc
, "non-broadcast", &idx
))
6524 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_NBMA
;
6525 else if (argv_find (argv
, argc
, "point-to-multipoint", &idx
))
6526 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOMULTIPOINT
;
6527 else if (argv_find (argv
, argc
, "point-to-point", &idx
))
6528 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOPOINT
;
6530 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
6533 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), type
);
6535 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6537 struct ospf_interface
*oi
= rn
->info
;
6542 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
6544 if (oi
->state
> ISM_Down
)
6546 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
6547 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
6554 DEFUN_HIDDEN (ospf_network
,
6556 "ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
6557 "OSPF interface commands\n"
6559 "Specify OSPF broadcast multi-access network\n"
6560 "Specify OSPF NBMA network\n"
6561 "Specify OSPF point-to-multipoint network\n"
6562 "Specify OSPF point-to-point network\n")
6564 return ip_ospf_network (self
, vty
, argc
, argv
);
6567 DEFUN (no_ip_ospf_network
,
6568 no_ip_ospf_network_cmd
,
6569 "no ip ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
6572 "OSPF interface commands\n"
6574 "Specify OSPF broadcast multi-access network\n"
6575 "Specify OSPF NBMA network\n"
6576 "Specify OSPF point-to-multipoint network\n"
6577 "Specify OSPF point-to-point network\n")
6579 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6580 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
6581 struct route_node
*rn
;
6583 IF_DEF_PARAMS (ifp
)->type
= ospf_default_iftype(ifp
);
6585 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
6588 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6590 struct ospf_interface
*oi
= rn
->info
;
6595 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
6597 if (oi
->state
> ISM_Down
)
6599 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
6600 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
6607 DEFUN_HIDDEN (no_ospf_network
,
6608 no_ospf_network_cmd
,
6609 "no ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
6611 "OSPF interface commands\n"
6613 "Specify OSPF broadcast multi-access network\n"
6614 "Specify OSPF NBMA network\n"
6615 "Specify OSPF point-to-multipoint network\n"
6616 "Specify OSPF point-to-point network\n")
6618 return no_ip_ospf_network (self
, vty
, argc
, argv
);
6621 DEFUN (ip_ospf_priority
,
6622 ip_ospf_priority_cmd
,
6623 "ip ospf priority (0-255) [A.B.C.D]",
6625 "OSPF interface commands\n"
6628 "Address of interface")
6630 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6633 struct route_node
*rn
;
6634 struct in_addr addr
;
6635 struct ospf_if_params
*params
;
6636 params
= IF_DEF_PARAMS (ifp
);
6638 argv_find (argv
, argc
, "(0-255)", &idx
);
6639 priority
= strtol (argv
[idx
]->arg
, NULL
, 10);
6641 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6643 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6645 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6650 params
= ospf_get_if_params (ifp
, addr
);
6651 ospf_if_update_params (ifp
, addr
);
6654 SET_IF_PARAM (params
, priority
);
6655 params
->priority
= priority
;
6657 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6659 struct ospf_interface
*oi
= rn
->info
;
6664 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
6666 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
6667 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
6674 DEFUN_HIDDEN (ospf_priority
,
6676 "ospf priority (0-255) [A.B.C.D]",
6677 "OSPF interface commands\n"
6680 "Address of interface")
6682 return ip_ospf_priority (self
, vty
, argc
, argv
);
6685 DEFUN (no_ip_ospf_priority
,
6686 no_ip_ospf_priority_cmd
,
6687 "no ip ospf priority [(0-255) [A.B.C.D]]",
6690 "OSPF interface commands\n"
6691 "Router priority\n" // ignored
6693 "Address of interface")
6695 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6697 struct route_node
*rn
;
6698 struct in_addr addr
;
6699 struct ospf_if_params
*params
;
6701 params
= IF_DEF_PARAMS (ifp
);
6703 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6705 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6707 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6712 params
= ospf_lookup_if_params (ifp
, addr
);
6717 UNSET_IF_PARAM (params
, priority
);
6718 params
->priority
= OSPF_ROUTER_PRIORITY_DEFAULT
;
6720 if (params
!= IF_DEF_PARAMS (ifp
))
6722 ospf_free_if_params (ifp
, addr
);
6723 ospf_if_update_params (ifp
, addr
);
6726 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6728 struct ospf_interface
*oi
= rn
->info
;
6733 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
6735 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
6736 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
6743 DEFUN_HIDDEN (no_ospf_priority
,
6744 no_ospf_priority_cmd
,
6745 "no ospf priority [(0-255) [A.B.C.D]]",
6747 "OSPF interface commands\n"
6750 "Address of interface")
6752 return no_ip_ospf_priority (self
, vty
, argc
, argv
);
6755 DEFUN (ip_ospf_retransmit_interval
,
6756 ip_ospf_retransmit_interval_addr_cmd
,
6757 "ip ospf retransmit-interval (3-65535) [A.B.C.D]",
6759 "OSPF interface commands\n"
6760 "Time between retransmitting lost link state advertisements\n"
6762 "Address of interface")
6764 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6767 struct in_addr addr
;
6768 struct ospf_if_params
*params
;
6769 params
= IF_DEF_PARAMS (ifp
);
6771 argv_find (argv
, argc
, "(3-65535)", &idx
);
6772 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
6774 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6776 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6778 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6783 params
= ospf_get_if_params (ifp
, addr
);
6784 ospf_if_update_params (ifp
, addr
);
6787 SET_IF_PARAM (params
, retransmit_interval
);
6788 params
->retransmit_interval
= seconds
;
6793 DEFUN_HIDDEN (ospf_retransmit_interval
,
6794 ospf_retransmit_interval_cmd
,
6795 "ospf retransmit-interval (3-65535) [A.B.C.D]",
6796 "OSPF interface commands\n"
6797 "Time between retransmitting lost link state advertisements\n"
6799 "Address of interface")
6801 return ip_ospf_retransmit_interval (self
, vty
, argc
, argv
);
6804 DEFUN (no_ip_ospf_retransmit_interval
,
6805 no_ip_ospf_retransmit_interval_addr_cmd
,
6806 "no ip ospf retransmit-interval [(3-65535)] [A.B.C.D]",
6809 "OSPF interface commands\n"
6810 "Time between retransmitting lost link state advertisements\n"
6812 "Address of interface\n")
6814 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6816 struct in_addr addr
;
6817 struct ospf_if_params
*params
;
6819 params
= IF_DEF_PARAMS (ifp
);
6821 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6823 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6825 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6830 params
= ospf_lookup_if_params (ifp
, addr
);
6835 UNSET_IF_PARAM (params
, retransmit_interval
);
6836 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
6838 if (params
!= IF_DEF_PARAMS (ifp
))
6840 ospf_free_if_params (ifp
, addr
);
6841 ospf_if_update_params (ifp
, addr
);
6847 DEFUN_HIDDEN (no_ospf_retransmit_interval
,
6848 no_ospf_retransmit_interval_cmd
,
6849 "no ospf retransmit-interval [(3-65535)] [A.B.C.D]",
6851 "OSPF interface commands\n"
6852 "Time between retransmitting lost link state advertisements\n"
6854 "Address of interface\n")
6856 return no_ip_ospf_retransmit_interval (self
, vty
, argc
, argv
);
6859 DEFUN (ip_ospf_transmit_delay
,
6860 ip_ospf_transmit_delay_addr_cmd
,
6861 "ip ospf transmit-delay (1-65535) [A.B.C.D]",
6863 "OSPF interface commands\n"
6864 "Link state transmit delay\n"
6866 "Address of interface")
6868 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6871 struct in_addr addr
;
6872 struct ospf_if_params
*params
;
6874 params
= IF_DEF_PARAMS (ifp
);
6875 argv_find (argv
, argc
, "(1-65535)", &idx
);
6876 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
6878 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6880 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6882 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6887 params
= ospf_get_if_params (ifp
, addr
);
6888 ospf_if_update_params (ifp
, addr
);
6891 SET_IF_PARAM (params
, transmit_delay
);
6892 params
->transmit_delay
= seconds
;
6897 DEFUN_HIDDEN (ospf_transmit_delay
,
6898 ospf_transmit_delay_cmd
,
6899 "ospf transmit-delay (1-65535) [A.B.C.D]",
6900 "OSPF interface commands\n"
6901 "Link state transmit delay\n"
6903 "Address of interface")
6905 return ip_ospf_transmit_delay (self
, vty
, argc
, argv
);
6908 DEFUN (no_ip_ospf_transmit_delay
,
6909 no_ip_ospf_transmit_delay_addr_cmd
,
6910 "no ip ospf transmit-delay [(1-65535)] [A.B.C.D]",
6913 "OSPF interface commands\n"
6914 "Link state transmit delay\n"
6915 "Address of interface")
6917 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6919 struct in_addr addr
;
6920 struct ospf_if_params
*params
;
6922 params
= IF_DEF_PARAMS (ifp
);
6924 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6926 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6928 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6933 params
= ospf_lookup_if_params (ifp
, addr
);
6938 UNSET_IF_PARAM (params
, transmit_delay
);
6939 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
6941 if (params
!= IF_DEF_PARAMS (ifp
))
6943 ospf_free_if_params (ifp
, addr
);
6944 ospf_if_update_params (ifp
, addr
);
6951 DEFUN_HIDDEN (no_ospf_transmit_delay
,
6952 no_ospf_transmit_delay_cmd
,
6953 "no ospf transmit-delay",
6955 "OSPF interface commands\n"
6956 "Link state transmit delay\n")
6958 return no_ip_ospf_transmit_delay (self
, vty
, argc
, argv
);
6961 DEFUN (ip_ospf_area
,
6963 "ip ospf [(1-65535)] area <A.B.C.D|(0-4294967295)>",
6965 "OSPF interface commands\n"
6967 "Enable OSPF on this interface\n"
6968 "OSPF area ID in IP address format\n"
6969 "OSPF area ID as a decimal value\n")
6971 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6974 struct in_addr area_id
;
6976 struct ospf_if_params
*params
;
6977 struct route_node
*rn
;
6978 u_short instance
= 0;
6980 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
6981 instance
= strtol (argv
[idx
]->arg
, NULL
, 10);
6982 char *areaid
= argv
[argc
- 1]->arg
;
6984 ospf
= ospf_lookup_instance (instance
);
6987 params
= IF_DEF_PARAMS (ifp
);
6988 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
6990 ospf_interface_unset (ifp
);
6991 ospf
= ospf_lookup();
6992 ospf
->if_ospf_cli_count
--;
6997 ret
= str2area_id (areaid
, &area_id
, &format
);
7000 vty_out (vty
, "Please specify area by A.B.C.D|<0-4294967295>%s",
7004 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
7006 vty_out (vty
, "Cannot enable OSPF on a virtual link.%s", VTY_NEWLINE
);
7010 params
= IF_DEF_PARAMS (ifp
);
7011 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7014 "Must remove previous area config before changing ospf area %s",
7019 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
7021 if (rn
->info
!= NULL
)
7023 vty_out (vty
, "Please remove all network commands first.%s", VTY_NEWLINE
);
7028 /* enable ospf on this interface with area_id */
7029 ospf_interface_set (ifp
, area_id
);
7030 ospf
->if_ospf_cli_count
++;
7035 DEFUN (no_ip_ospf_area
,
7036 no_ip_ospf_area_cmd
,
7037 "no ip ospf [(1-65535)] area [<A.B.C.D|(0-4294967295)>]",
7040 "OSPF interface commands\n"
7042 "Disable OSPF on this interface\n"
7043 "OSPF area ID in IP address format\n"
7044 "OSPF area ID as a decimal value\n")
7046 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7049 struct ospf_if_params
*params
;
7050 u_short instance
= 0;
7052 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
7053 instance
= strtol (argv
[idx
]->arg
, NULL
, 10);
7055 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
7058 params
= IF_DEF_PARAMS (ifp
);
7059 if (!OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7061 vty_out (vty
, "Can't find specified interface area configuration.%s", VTY_NEWLINE
);
7065 ospf_interface_unset (ifp
);
7066 ospf
->if_ospf_cli_count
--;
7070 DEFUN (ospf_redistribute_source
,
7071 ospf_redistribute_source_cmd
,
7072 "redistribute " FRR_REDIST_STR_OSPFD
" [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7074 FRR_REDIST_HELP_STR_OSPFD
7075 "Metric for redistributed routes\n"
7076 "OSPF default metric\n"
7077 "OSPF exterior metric type for redistributed routes\n"
7078 "Set OSPF External Type 1 metrics\n"
7079 "Set OSPF External Type 2 metrics\n"
7080 "Route map reference\n"
7081 "Pointer to route-map entries\n")
7083 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7084 int idx_protocol
= 1;
7088 struct ospf_redist
*red
;
7094 /* Get distribute source. */
7095 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
7099 red
= ospf_redist_add(ospf
, source
, 0);
7101 /* Get metric value. */
7102 if (argv_find (argv
, argc
, "(0-16777214)", &idx
)) {
7103 if (!str2metric (argv
[idx
]->arg
, &metric
))
7106 /* Get metric type. */
7107 else if (argv_find (argv
, argc
, "(1-2)", &idx
)) {
7108 if (!str2metric_type (argv
[idx
]->arg
, &type
))
7112 else if (argv_find (argv
, argc
, "WORD", &idx
)) {
7113 ospf_routemap_set (red
, argv
[idx
]->arg
);
7116 ospf_routemap_unset (red
);
7118 return ospf_redistribute_set (ospf
, source
, 0, type
, metric
);
7121 DEFUN (no_ospf_redistribute_source
,
7122 no_ospf_redistribute_source_cmd
,
7123 "no redistribute " FRR_REDIST_STR_OSPFD
" [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7126 FRR_REDIST_HELP_STR_OSPFD
7127 "Metric for redistributed routes\n"
7128 "OSPF default metric\n"
7129 "OSPF exterior metric type for redistributed routes\n"
7130 "Set OSPF External Type 1 metrics\n"
7131 "Set OSPF External Type 2 metrics\n"
7132 "Route map reference\n"
7133 "Pointer to route-map entries\n")
7135 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7136 int idx_protocol
= 2;
7138 struct ospf_redist
*red
;
7140 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
7144 red
= ospf_redist_lookup(ospf
, source
, 0);
7148 ospf_routemap_unset (red
);
7149 return ospf_redistribute_unset (ospf
, source
, 0);
7152 DEFUN (ospf_redistribute_instance_source
,
7153 ospf_redistribute_instance_source_cmd
,
7154 "redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
7156 "Open Shortest Path First\n"
7157 "Non-main Kernel Routing Table\n"
7158 "Instance ID/Table ID\n"
7159 "Metric for redistributed routes\n"
7160 "OSPF default metric\n"
7161 "OSPF exterior metric type for redistributed routes\n"
7162 "Set OSPF External Type 1 metrics\n"
7163 "Set OSPF External Type 2 metrics\n"
7164 "Route map reference\n"
7165 "Pointer to route-map entries\n")
7167 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7168 int idx_ospf_table
= 1;
7175 struct ospf_redist
*red
;
7180 source
= proto_redistnum (AFI_IP
, argv
[idx_ospf_table
]->text
);
7182 VTY_GET_INTEGER ("Instance ID", instance
, argv
[idx_number
]->arg
);
7187 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
7189 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
7194 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
7196 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
7201 /* Get metric value. */
7202 if (argv_find (argv
, argc
, "metric", &idx
))
7203 if (!str2metric (argv
[idx
+1]->arg
, &metric
))
7207 /* Get metric type. */
7208 if (argv_find (argv
, argc
, "metric-type", &idx
))
7209 if (!str2metric_type (argv
[idx
+1]->arg
, &type
))
7212 red
= ospf_redist_add(ospf
, source
, instance
);
7215 if (argv_find (argv
, argc
, "route-map", &idx
))
7216 ospf_routemap_set (red
, argv
[idx
+1]->arg
);
7218 ospf_routemap_unset (red
);
7220 return ospf_redistribute_set (ospf
, source
, instance
, type
, metric
);
7223 DEFUN (no_ospf_redistribute_instance_source
,
7224 no_ospf_redistribute_instance_source_cmd
,
7225 "no redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
7228 "Open Shortest Path First\n"
7229 "Non-main Kernel Routing Table\n"
7230 "Instance ID/Table Id\n"
7231 "Metric for redistributed routes\n"
7232 "OSPF default metric\n"
7233 "OSPF exterior metric type for redistributed routes\n"
7234 "Set OSPF External Type 1 metrics\n"
7235 "Set OSPF External Type 2 metrics\n"
7236 "Route map reference\n"
7237 "Pointer to route-map entries\n")
7239 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7240 int idx_ospf_table
= 2;
7243 struct ospf_redist
*red
;
7246 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
7247 source
= ZEBRA_ROUTE_OSPF
;
7249 source
= ZEBRA_ROUTE_TABLE
;
7251 VTY_GET_INTEGER ("Instance ID", instance
, argv
[idx_number
]->arg
);
7253 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
7255 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
7260 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
7262 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
7267 red
= ospf_redist_lookup(ospf
, source
, instance
);
7271 ospf_routemap_unset (red
);
7272 return ospf_redistribute_unset (ospf
, source
, instance
);
7275 DEFUN (ospf_distribute_list_out
,
7276 ospf_distribute_list_out_cmd
,
7277 "distribute-list WORD out " FRR_REDIST_STR_OSPFD
,
7278 "Filter networks in routing updates\n"
7279 "Access-list name\n"
7281 FRR_REDIST_HELP_STR_OSPFD
)
7283 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7287 char *proto
= argv
[argc
- 1]->text
;
7289 /* Get distribute source. */
7290 source
= proto_redistnum(AFI_IP
, proto
);
7294 return ospf_distribute_list_out_set (ospf
, source
, argv
[idx_word
]->arg
);
7297 DEFUN (no_ospf_distribute_list_out
,
7298 no_ospf_distribute_list_out_cmd
,
7299 "no distribute-list WORD out " FRR_REDIST_STR_OSPFD
,
7301 "Filter networks in routing updates\n"
7302 "Access-list name\n"
7304 FRR_REDIST_HELP_STR_OSPFD
)
7306 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7310 char *proto
= argv
[argc
- 1]->text
;
7311 source
= proto_redistnum(AFI_IP
, proto
);
7315 return ospf_distribute_list_out_unset (ospf
, source
, argv
[idx_word
]->arg
);
7318 /* Default information originate. */
7319 DEFUN (ospf_default_information_originate
,
7320 ospf_default_information_originate_cmd
,
7321 "default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7322 "Control distribution of default information\n"
7323 "Distribute a default route\n"
7324 "Always advertise default route\n"
7325 "OSPF default metric\n"
7327 "OSPF metric type for default routes\n"
7328 "Set OSPF External Type 1 metrics\n"
7329 "Set OSPF External Type 2 metrics\n"
7330 "Route map reference\n"
7331 "Pointer to route-map entries\n")
7333 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7334 int default_originate
= DEFAULT_ORIGINATE_ZEBRA
;
7337 struct ospf_redist
*red
;
7340 red
= ospf_redist_add(ospf
, DEFAULT_ROUTE
, 0);
7342 /* Check whether "always" was specified */
7343 if (argv_find (argv
, argc
, "always", &idx
))
7344 default_originate
= DEFAULT_ORIGINATE_ALWAYS
;
7345 /* Get metric value */
7346 else if (argv_find (argv
, argc
, "(0-16777214)", &idx
)) {
7347 if (!str2metric (argv
[idx
]->arg
, &metric
))
7350 /* Get metric type. */
7351 else if (argv_find (argv
, argc
, "(1-2)", &idx
)) {
7352 if (!str2metric_type (argv
[idx
]->arg
, &type
))
7356 else if (argv_find (argv
, argc
, "WORD", &idx
))
7357 ospf_routemap_set (red
, argv
[idx
]->arg
);
7359 ospf_routemap_unset (red
);
7361 return ospf_redistribute_default_set (ospf
, default_originate
,
7365 DEFUN (no_ospf_default_information_originate
,
7366 no_ospf_default_information_originate_cmd
,
7367 "no default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7369 "Control distribution of default information\n"
7370 "Distribute a default route\n"
7371 "Always advertise default route\n"
7372 "OSPF default metric\n"
7374 "OSPF metric type for default routes\n"
7375 "Set OSPF External Type 1 metrics\n"
7376 "Set OSPF External Type 2 metrics\n"
7377 "Route map reference\n"
7378 "Pointer to route-map entries\n")
7380 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7381 struct prefix_ipv4 p
;
7382 struct ospf_external
*ext
;
7383 struct ospf_redist
*red
;
7386 p
.prefix
.s_addr
= 0;
7389 ospf_external_lsa_flush (ospf
, DEFAULT_ROUTE
, &p
, 0);
7391 if ((ext
= ospf_external_lookup(DEFAULT_ROUTE
, 0)) &&
7392 EXTERNAL_INFO (ext
)) {
7393 ospf_external_info_delete (DEFAULT_ROUTE
, 0, p
);
7394 ospf_external_del (DEFAULT_ROUTE
, 0);
7397 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
7401 ospf_routemap_unset (red
);
7402 return ospf_redistribute_default_unset (ospf
);
7405 DEFUN (ospf_default_metric
,
7406 ospf_default_metric_cmd
,
7407 "default-metric (0-16777214)",
7408 "Set metric of redistributed routes\n"
7411 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7415 if (!str2metric (argv
[idx_number
]->arg
, &metric
))
7418 ospf
->default_metric
= metric
;
7423 DEFUN (no_ospf_default_metric
,
7424 no_ospf_default_metric_cmd
,
7425 "no default-metric [(0-16777214)]",
7427 "Set metric of redistributed routes\n"
7430 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7432 ospf
->default_metric
= -1;
7438 DEFUN (ospf_distance
,
7441 "Administrative distance\n"
7442 "OSPF Administrative distance\n")
7444 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7447 ospf
->distance_all
= atoi (argv
[idx_number
]->arg
);
7452 DEFUN (no_ospf_distance
,
7453 no_ospf_distance_cmd
,
7454 "no distance (1-255)",
7456 "Administrative distance\n"
7457 "OSPF Administrative distance\n")
7459 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7461 ospf
->distance_all
= 0;
7466 DEFUN (no_ospf_distance_ospf
,
7467 no_ospf_distance_ospf_cmd
,
7468 "no distance ospf [{intra-area [(1-255)]|inter-area [(1-255)]|external [(1-255)]}]",
7470 "Administrative distance\n"
7471 "OSPF administrative distance\n"
7472 "Intra-area routes\n"
7473 "Distance for intra-area routes\n"
7474 "Inter-area routes\n"
7475 "Distance for inter-area routes\n"
7477 "Distance for external routes\n")
7479 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7485 if (argv_find (argv
, argc
, "intra-area", &idx
) || argc
== 3)
7486 idx
= ospf
->distance_intra
= 0;
7487 if (argv_find (argv
, argc
, "inter-area", &idx
) || argc
== 3)
7488 idx
= ospf
->distance_inter
= 0;
7489 if (argv_find (argv
, argc
, "external", &idx
) || argc
== 3)
7490 ospf
->distance_external
= 0;
7495 DEFUN (ospf_distance_ospf
,
7496 ospf_distance_ospf_cmd
,
7497 "distance ospf {intra-area (1-255)|inter-area (1-255)|external (1-255)}",
7498 "Administrative distance\n"
7499 "OSPF administrative distance\n"
7500 "Intra-area routes\n"
7501 "Distance for intra-area routes\n"
7502 "Inter-area routes\n"
7503 "Distance for inter-area routes\n"
7505 "Distance for external routes\n")
7507 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7510 if (argv_find (argv
, argc
, "intra-area", &idx
))
7511 ospf
->distance_intra
= atoi(argv
[idx
+ 1]->arg
);
7513 if (argv_find (argv
, argc
, "inter-area", &idx
))
7514 ospf
->distance_inter
= atoi(argv
[idx
+ 1]->arg
);
7516 if (argv_find (argv
, argc
, "external", &idx
))
7517 ospf
->distance_external
= atoi(argv
[idx
+ 1]->arg
);
7523 DEFUN (ospf_distance_source
,
7524 ospf_distance_source_cmd
,
7525 "distance (1-255) A.B.C.D/M",
7526 "Administrative distance\n"
7528 "IP source prefix\n")
7530 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7532 int idx_ipv4_prefixlen
= 2;
7537 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
7542 DEFUN (no_ospf_distance_source
,
7543 no_ospf_distance_source_cmd
,
7544 "no distance (1-255) A.B.C.D/M",
7546 "Administrative distance\n"
7548 "IP source prefix\n")
7550 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7552 int idx_ipv4_prefixlen
= 3;
7557 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
7562 DEFUN (ospf_distance_source_access_list
,
7563 ospf_distance_source_access_list_cmd
,
7564 "distance (1-255) A.B.C.D/M WORD",
7565 "Administrative distance\n"
7567 "IP source prefix\n"
7568 "Access list name\n")
7570 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7572 int idx_ipv4_prefixlen
= 2;
7578 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
7583 DEFUN (no_ospf_distance_source_access_list
,
7584 no_ospf_distance_source_access_list_cmd
,
7585 "no distance (1-255) A.B.C.D/M WORD",
7587 "Administrative distance\n"
7589 "IP source prefix\n"
7590 "Access list name\n")
7592 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7594 int idx_ipv4_prefixlen
= 3;
7600 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
7606 DEFUN (ip_ospf_mtu_ignore
,
7607 ip_ospf_mtu_ignore_addr_cmd
,
7608 "ip ospf mtu-ignore [A.B.C.D]",
7610 "OSPF interface commands\n"
7611 "Disable MTU mismatch detection on this interface\n"
7612 "Address of interface")
7614 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7616 struct in_addr addr
;
7619 struct ospf_if_params
*params
;
7620 params
= IF_DEF_PARAMS (ifp
);
7624 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7627 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7631 params
= ospf_get_if_params (ifp
, addr
);
7632 ospf_if_update_params (ifp
, addr
);
7634 params
->mtu_ignore
= 1;
7635 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
7636 SET_IF_PARAM (params
, mtu_ignore
);
7639 UNSET_IF_PARAM (params
, mtu_ignore
);
7640 if (params
!= IF_DEF_PARAMS (ifp
))
7642 ospf_free_if_params (ifp
, addr
);
7643 ospf_if_update_params (ifp
, addr
);
7649 DEFUN (no_ip_ospf_mtu_ignore
,
7650 no_ip_ospf_mtu_ignore_addr_cmd
,
7651 "no ip ospf mtu-ignore [A.B.C.D]",
7653 "OSPF interface commands\n"
7654 "Disable MTU mismatch detection on this interface\n"
7655 "Address of interface")
7657 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7659 struct in_addr addr
;
7662 struct ospf_if_params
*params
;
7663 params
= IF_DEF_PARAMS (ifp
);
7667 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7670 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7674 params
= ospf_get_if_params (ifp
, addr
);
7675 ospf_if_update_params (ifp
, addr
);
7677 params
->mtu_ignore
= 0;
7678 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
7679 SET_IF_PARAM (params
, mtu_ignore
);
7682 UNSET_IF_PARAM (params
, mtu_ignore
);
7683 if (params
!= IF_DEF_PARAMS (ifp
))
7685 ospf_free_if_params (ifp
, addr
);
7686 ospf_if_update_params (ifp
, addr
);
7693 DEFUN (ospf_max_metric_router_lsa_admin
,
7694 ospf_max_metric_router_lsa_admin_cmd
,
7695 "max-metric router-lsa administrative",
7696 "OSPF maximum / infinite-distance metric\n"
7697 "Advertise own Router-LSA with infinite distance (stub router)\n"
7698 "Administratively applied, for an indefinite period\n")
7700 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7701 struct listnode
*ln
;
7702 struct ospf_area
*area
;
7704 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7706 SET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
7708 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
))
7709 ospf_router_lsa_update_area (area
);
7712 /* Allows for areas configured later to get the property */
7713 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_SET
;
7718 DEFUN (no_ospf_max_metric_router_lsa_admin
,
7719 no_ospf_max_metric_router_lsa_admin_cmd
,
7720 "no max-metric router-lsa administrative",
7722 "OSPF maximum / infinite-distance metric\n"
7723 "Advertise own Router-LSA with infinite distance (stub router)\n"
7724 "Administratively applied, for an indefinite period\n")
7726 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7727 struct listnode
*ln
;
7728 struct ospf_area
*area
;
7730 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7732 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
7734 /* Don't trample on the start-up stub timer */
7735 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
)
7736 && !area
->t_stub_router
)
7738 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
7739 ospf_router_lsa_update_area (area
);
7742 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET
;
7746 DEFUN (ospf_max_metric_router_lsa_startup
,
7747 ospf_max_metric_router_lsa_startup_cmd
,
7748 "max-metric router-lsa on-startup (5-86400)",
7749 "OSPF maximum / infinite-distance metric\n"
7750 "Advertise own Router-LSA with infinite distance (stub router)\n"
7751 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7752 "Time (seconds) to advertise self as stub-router\n")
7754 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7756 unsigned int seconds
;
7760 vty_out (vty
, "%% Must supply stub-router period");
7764 VTY_GET_INTEGER ("stub-router startup period", seconds
, argv
[idx_number
]->arg
);
7766 ospf
->stub_router_startup_time
= seconds
;
7771 DEFUN (no_ospf_max_metric_router_lsa_startup
,
7772 no_ospf_max_metric_router_lsa_startup_cmd
,
7773 "no max-metric router-lsa on-startup [(5-86400)]",
7775 "OSPF maximum / infinite-distance metric\n"
7776 "Advertise own Router-LSA with infinite distance (stub router)\n"
7777 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7778 "Time (seconds) to advertise self as stub-router\n")
7780 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7781 struct listnode
*ln
;
7782 struct ospf_area
*area
;
7784 ospf
->stub_router_startup_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
7786 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7788 SET_FLAG (area
->stub_router_state
, OSPF_AREA_WAS_START_STUB_ROUTED
);
7789 OSPF_TIMER_OFF (area
->t_stub_router
);
7791 /* Don't trample on admin stub routed */
7792 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
7794 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
7795 ospf_router_lsa_update_area (area
);
7802 DEFUN (ospf_max_metric_router_lsa_shutdown
,
7803 ospf_max_metric_router_lsa_shutdown_cmd
,
7804 "max-metric router-lsa on-shutdown (5-100)",
7805 "OSPF maximum / infinite-distance metric\n"
7806 "Advertise own Router-LSA with infinite distance (stub router)\n"
7807 "Advertise stub-router prior to full shutdown of OSPF\n"
7808 "Time (seconds) to wait till full shutdown\n")
7810 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7812 unsigned int seconds
;
7816 vty_out (vty
, "%% Must supply stub-router shutdown period");
7820 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds
, argv
[idx_number
]->arg
);
7822 ospf
->stub_router_shutdown_time
= seconds
;
7827 DEFUN (no_ospf_max_metric_router_lsa_shutdown
,
7828 no_ospf_max_metric_router_lsa_shutdown_cmd
,
7829 "no max-metric router-lsa on-shutdown [(5-100)]",
7831 "OSPF maximum / infinite-distance metric\n"
7832 "Advertise own Router-LSA with infinite distance (stub router)\n"
7833 "Advertise stub-router prior to full shutdown of OSPF\n"
7834 "Time (seconds) to wait till full shutdown\n")
7836 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7838 ospf
->stub_router_shutdown_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
7844 config_write_stub_router (struct vty
*vty
, struct ospf
*ospf
)
7846 struct listnode
*ln
;
7847 struct ospf_area
*area
;
7849 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
7850 vty_out (vty
, " max-metric router-lsa on-startup %u%s",
7851 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
7852 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
7853 vty_out (vty
, " max-metric router-lsa on-shutdown %u%s",
7854 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
7855 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7857 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
7859 vty_out (vty
, " max-metric router-lsa administrative%s",
7868 show_ip_ospf_route_network (struct vty
*vty
, struct route_table
*rt
)
7870 struct route_node
*rn
;
7871 struct ospf_route
*or;
7872 struct listnode
*pnode
, *pnnode
;
7873 struct ospf_path
*path
;
7875 vty_out (vty
, "============ OSPF network routing table ============%s",
7878 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
7879 if ((or = rn
->info
) != NULL
)
7882 snprintf (buf1
, 19, "%s/%d",
7883 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
7885 switch (or->path_type
)
7887 case OSPF_PATH_INTER_AREA
:
7888 if (or->type
== OSPF_DESTINATION_NETWORK
)
7889 vty_out (vty
, "N IA %-18s [%d] area: %s%s", buf1
, or->cost
,
7890 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
7891 else if (or->type
== OSPF_DESTINATION_DISCARD
)
7892 vty_out (vty
, "D IA %-18s Discard entry%s", buf1
, VTY_NEWLINE
);
7894 case OSPF_PATH_INTRA_AREA
:
7895 vty_out (vty
, "N %-18s [%d] area: %s%s", buf1
, or->cost
,
7896 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
7902 if (or->type
== OSPF_DESTINATION_NETWORK
)
7903 for (ALL_LIST_ELEMENTS (or->paths
, pnode
, pnnode
, path
))
7905 if (if_lookup_by_index(path
->ifindex
, VRF_DEFAULT
))
7907 if (path
->nexthop
.s_addr
== 0)
7908 vty_out (vty
, "%24s directly attached to %s%s",
7909 "", ifindex2ifname (path
->ifindex
, VRF_DEFAULT
), VTY_NEWLINE
);
7911 vty_out (vty
, "%24s via %s, %s%s", "",
7912 inet_ntoa (path
->nexthop
),
7913 ifindex2ifname (path
->ifindex
, VRF_DEFAULT
), VTY_NEWLINE
);
7917 vty_out (vty
, "%s", VTY_NEWLINE
);
7921 show_ip_ospf_route_router (struct vty
*vty
, struct route_table
*rtrs
)
7923 struct route_node
*rn
;
7924 struct ospf_route
*or;
7925 struct listnode
*pnode
;
7926 struct listnode
*node
;
7927 struct ospf_path
*path
;
7929 vty_out (vty
, "============ OSPF router routing table =============%s",
7931 for (rn
= route_top (rtrs
); rn
; rn
= route_next (rn
))
7936 vty_out (vty
, "R %-15s ", inet_ntoa (rn
->p
.u
.prefix4
));
7938 for (ALL_LIST_ELEMENTS_RO ((struct list
*)rn
->info
, node
, or))
7941 vty_out (vty
, "%24s", "");
7944 vty_out (vty
, "%s [%d] area: %s",
7945 (or->path_type
== OSPF_PATH_INTER_AREA
? "IA" : " "),
7946 or->cost
, inet_ntoa (or->u
.std
.area_id
));
7948 vty_out (vty
, "%s%s%s",
7949 (or->u
.std
.flags
& ROUTER_LSA_BORDER
? ", ABR" : ""),
7950 (or->u
.std
.flags
& ROUTER_LSA_EXTERNAL
? ", ASBR" : ""),
7953 for (ALL_LIST_ELEMENTS_RO (or->paths
, pnode
, path
))
7955 if (if_lookup_by_index(path
->ifindex
, VRF_DEFAULT
))
7957 if (path
->nexthop
.s_addr
== 0)
7958 vty_out (vty
, "%24s directly attached to %s%s",
7959 "", ifindex2ifname (path
->ifindex
, VRF_DEFAULT
),
7962 vty_out (vty
, "%24s via %s, %s%s", "",
7963 inet_ntoa (path
->nexthop
),
7964 ifindex2ifname (path
->ifindex
, VRF_DEFAULT
),
7970 vty_out (vty
, "%s", VTY_NEWLINE
);
7974 show_ip_ospf_route_external (struct vty
*vty
, struct route_table
*rt
)
7976 struct route_node
*rn
;
7977 struct ospf_route
*er
;
7978 struct listnode
*pnode
, *pnnode
;
7979 struct ospf_path
*path
;
7981 vty_out (vty
, "============ OSPF external routing table ===========%s",
7983 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
7984 if ((er
= rn
->info
) != NULL
)
7987 snprintf (buf1
, 19, "%s/%d",
7988 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
7990 switch (er
->path_type
)
7992 case OSPF_PATH_TYPE1_EXTERNAL
:
7993 vty_out (vty
, "N E1 %-18s [%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
,
7994 er
->cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
7996 case OSPF_PATH_TYPE2_EXTERNAL
:
7997 vty_out (vty
, "N E2 %-18s [%d/%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
, er
->cost
,
7998 er
->u
.ext
.type2_cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
8002 for (ALL_LIST_ELEMENTS (er
->paths
, pnode
, pnnode
, path
))
8004 if (if_lookup_by_index(path
->ifindex
, VRF_DEFAULT
))
8006 if (path
->nexthop
.s_addr
== 0)
8007 vty_out (vty
, "%24s directly attached to %s%s",
8008 "", ifindex2ifname (path
->ifindex
, VRF_DEFAULT
), VTY_NEWLINE
);
8010 vty_out (vty
, "%24s via %s, %s%s", "",
8011 inet_ntoa (path
->nexthop
),
8012 ifindex2ifname (path
->ifindex
, VRF_DEFAULT
),
8017 vty_out (vty
, "%s", VTY_NEWLINE
);
8021 show_ip_ospf_border_routers_common (struct vty
*vty
, struct ospf
*ospf
)
8024 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
8025 VTY_NEWLINE
, VTY_NEWLINE
);
8027 if (ospf
->new_table
== NULL
)
8029 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
8033 /* Show Network routes.
8034 show_ip_ospf_route_network (vty, ospf->new_table); */
8036 /* Show Router routes. */
8037 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
8039 vty_out (vty
, "%s", VTY_NEWLINE
);
8044 DEFUN (show_ip_ospf_border_routers
,
8045 show_ip_ospf_border_routers_cmd
,
8046 "show ip ospf border-routers",
8049 "OSPF information\n"
8050 "Show all the ABR's and ASBR's\n")
8054 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
8057 return show_ip_ospf_border_routers_common(vty
, ospf
);
8060 DEFUN (show_ip_ospf_instance_border_routers
,
8061 show_ip_ospf_instance_border_routers_cmd
,
8062 "show ip ospf (1-65535) border-routers",
8065 "OSPF information\n"
8067 "Show all the ABR's and ASBR's\n")
8071 u_short instance
= 0;
8073 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
8074 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
8077 return show_ip_ospf_border_routers_common(vty
, ospf
);
8081 show_ip_ospf_route_common (struct vty
*vty
, struct ospf
*ospf
)
8084 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
8085 VTY_NEWLINE
, VTY_NEWLINE
);
8087 if (ospf
->new_table
== NULL
)
8089 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
8093 /* Show Network routes. */
8094 show_ip_ospf_route_network (vty
, ospf
->new_table
);
8096 /* Show Router routes. */
8097 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
8099 /* Show AS External routes. */
8100 show_ip_ospf_route_external (vty
, ospf
->old_external_route
);
8102 vty_out (vty
, "%s", VTY_NEWLINE
);
8107 DEFUN (show_ip_ospf_route
,
8108 show_ip_ospf_route_cmd
,
8109 "show ip ospf route",
8112 "OSPF information\n"
8113 "OSPF routing table\n")
8117 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
8120 return show_ip_ospf_route_common(vty
, ospf
);
8123 DEFUN (show_ip_ospf_instance_route
,
8124 show_ip_ospf_instance_route_cmd
,
8125 "show ip ospf (1-65535) route",
8128 "OSPF information\n"
8130 "OSPF routing table\n")
8134 u_short instance
= 0;
8136 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
8137 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
8140 return show_ip_ospf_route_common(vty
, ospf
);
8143 const char *ospf_abr_type_str
[] =
8152 const char *ospf_shortcut_mode_str
[] =
8159 const char *ospf_int_type_str
[] =
8161 "unknown", /* should never be used. */
8165 "point-to-multipoint",
8166 "virtual-link", /* should never be used. */
8170 /* Configuration write function for ospfd. */
8172 config_write_interface (struct vty
*vty
)
8174 struct listnode
*n1
, *n2
;
8175 struct interface
*ifp
;
8176 struct crypt_key
*ck
;
8178 struct route_node
*rn
= NULL
;
8179 struct ospf_if_params
*params
;
8180 struct ospf
*ospf
= ospf_lookup();
8182 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), n1
, ifp
))
8184 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
8187 if (ifp
->ifindex
== IFINDEX_DELETED
)
8190 vty_out (vty
, "!%s", VTY_NEWLINE
);
8191 vty_out (vty
, "interface %s%s", ifp
->name
,
8194 vty_out (vty
, " description %s%s", ifp
->desc
,
8199 params
= IF_DEF_PARAMS (ifp
);
8202 /* Interface Network print. */
8203 if (OSPF_IF_PARAM_CONFIGURED (params
, type
) &&
8204 params
->type
!= OSPF_IFTYPE_LOOPBACK
)
8206 if (params
->type
!= ospf_default_iftype(ifp
))
8208 vty_out (vty
, " ip ospf network %s",
8209 ospf_int_type_str
[params
->type
]);
8210 if (params
!= IF_DEF_PARAMS (ifp
))
8211 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8212 vty_out (vty
, "%s", VTY_NEWLINE
);
8216 /* OSPF interface authentication print */
8217 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_type
) &&
8218 params
->auth_type
!= OSPF_AUTH_NOTSET
)
8220 const char *auth_str
;
8222 /* Translation tables are not that much help here due to syntax
8223 of the simple option */
8224 switch (params
->auth_type
)
8227 case OSPF_AUTH_NULL
:
8231 case OSPF_AUTH_SIMPLE
:
8235 case OSPF_AUTH_CRYPTOGRAPHIC
:
8236 auth_str
= " message-digest";
8244 vty_out (vty
, " ip ospf authentication%s", auth_str
);
8245 if (params
!= IF_DEF_PARAMS (ifp
))
8246 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8247 vty_out (vty
, "%s", VTY_NEWLINE
);
8250 /* Simple Authentication Password print. */
8251 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_simple
) &&
8252 params
->auth_simple
[0] != '\0')
8254 vty_out (vty
, " ip ospf authentication-key %s",
8255 params
->auth_simple
);
8256 if (params
!= IF_DEF_PARAMS (ifp
))
8257 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8258 vty_out (vty
, "%s", VTY_NEWLINE
);
8261 /* Cryptographic Authentication Key print. */
8262 for (ALL_LIST_ELEMENTS_RO (params
->auth_crypt
, n2
, ck
))
8264 vty_out (vty
, " ip ospf message-digest-key %d md5 %s",
8265 ck
->key_id
, ck
->auth_key
);
8266 if (params
!= IF_DEF_PARAMS (ifp
))
8267 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8268 vty_out (vty
, "%s", VTY_NEWLINE
);
8271 /* Interface Output Cost print. */
8272 if (OSPF_IF_PARAM_CONFIGURED (params
, output_cost_cmd
))
8274 vty_out (vty
, " ip ospf cost %u", params
->output_cost_cmd
);
8275 if (params
!= IF_DEF_PARAMS (ifp
))
8276 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8277 vty_out (vty
, "%s", VTY_NEWLINE
);
8280 /* Hello Interval print. */
8281 if (OSPF_IF_PARAM_CONFIGURED (params
, v_hello
) &&
8282 params
->v_hello
!= OSPF_HELLO_INTERVAL_DEFAULT
)
8284 vty_out (vty
, " ip ospf hello-interval %u", params
->v_hello
);
8285 if (params
!= IF_DEF_PARAMS (ifp
))
8286 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8287 vty_out (vty
, "%s", VTY_NEWLINE
);
8291 /* Router Dead Interval print. */
8292 if (OSPF_IF_PARAM_CONFIGURED (params
, v_wait
) &&
8293 params
->v_wait
!= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
)
8295 vty_out (vty
, " ip ospf dead-interval ");
8298 if (OSPF_IF_PARAM_CONFIGURED (params
, fast_hello
))
8299 vty_out (vty
, "minimal hello-multiplier %d",
8300 params
->fast_hello
);
8302 vty_out (vty
, "%u", params
->v_wait
);
8304 if (params
!= IF_DEF_PARAMS (ifp
))
8305 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8306 vty_out (vty
, "%s", VTY_NEWLINE
);
8309 /* Router Priority print. */
8310 if (OSPF_IF_PARAM_CONFIGURED (params
, priority
) &&
8311 params
->priority
!= OSPF_ROUTER_PRIORITY_DEFAULT
)
8313 vty_out (vty
, " ip ospf priority %u", params
->priority
);
8314 if (params
!= IF_DEF_PARAMS (ifp
))
8315 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8316 vty_out (vty
, "%s", VTY_NEWLINE
);
8319 /* Retransmit Interval print. */
8320 if (OSPF_IF_PARAM_CONFIGURED (params
, retransmit_interval
) &&
8321 params
->retransmit_interval
!= OSPF_RETRANSMIT_INTERVAL_DEFAULT
)
8323 vty_out (vty
, " ip ospf retransmit-interval %u",
8324 params
->retransmit_interval
);
8325 if (params
!= IF_DEF_PARAMS (ifp
))
8326 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8327 vty_out (vty
, "%s", VTY_NEWLINE
);
8330 /* Transmit Delay print. */
8331 if (OSPF_IF_PARAM_CONFIGURED (params
, transmit_delay
) &&
8332 params
->transmit_delay
!= OSPF_TRANSMIT_DELAY_DEFAULT
)
8334 vty_out (vty
, " ip ospf transmit-delay %u", params
->transmit_delay
);
8335 if (params
!= IF_DEF_PARAMS (ifp
))
8336 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8337 vty_out (vty
, "%s", VTY_NEWLINE
);
8341 if (OSPF_IF_PARAM_CONFIGURED (params
, if_area
))
8344 vty_out (vty
, " ip ospf %d area %s%s", ospf
->instance
,
8345 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
8347 vty_out (vty
, " ip ospf area %s%s",
8348 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
8353 ospf_bfd_write_config(vty
, params
);
8355 /* MTU ignore print. */
8356 if (OSPF_IF_PARAM_CONFIGURED (params
, mtu_ignore
) &&
8357 params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
8359 if (params
->mtu_ignore
== 0)
8360 vty_out (vty
, " no ip ospf mtu-ignore");
8362 vty_out (vty
, " ip ospf mtu-ignore");
8363 if (params
!= IF_DEF_PARAMS (ifp
))
8364 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8365 vty_out (vty
, "%s", VTY_NEWLINE
);
8372 rn
= route_top (IF_OIFS_PARAMS (ifp
));
8374 rn
= route_next (rn
);
8384 ospf_opaque_config_write_if (vty
, ifp
);
8391 config_write_network_area (struct vty
*vty
, struct ospf
*ospf
)
8393 struct route_node
*rn
;
8394 u_char buf
[INET_ADDRSTRLEN
];
8396 /* `network area' print. */
8397 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
8400 struct ospf_network
*n
= rn
->info
;
8402 memset (buf
, 0, INET_ADDRSTRLEN
);
8404 /* Create Area ID string by specified Area ID format. */
8405 if (n
->area_id_fmt
== OSPF_AREA_ID_FMT_DOTTEDQUAD
)
8406 strncpy ((char *) buf
, inet_ntoa (n
->area_id
), INET_ADDRSTRLEN
);
8408 sprintf ((char *) buf
, "%lu",
8409 (unsigned long int) ntohl (n
->area_id
.s_addr
));
8411 /* Network print. */
8412 vty_out (vty
, " network %s/%d area %s%s",
8413 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
8421 config_write_ospf_area (struct vty
*vty
, struct ospf
*ospf
)
8423 struct listnode
*node
;
8424 struct ospf_area
*area
;
8425 u_char buf
[INET_ADDRSTRLEN
];
8427 /* Area configuration print. */
8428 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
8430 struct route_node
*rn1
;
8432 area_id2str ((char *) buf
, INET_ADDRSTRLEN
, &area
->area_id
,
8435 if (area
->auth_type
!= OSPF_AUTH_NULL
)
8437 if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
8438 vty_out (vty
, " area %s authentication%s", buf
, VTY_NEWLINE
);
8440 vty_out (vty
, " area %s authentication message-digest%s",
8444 if (area
->shortcut_configured
!= OSPF_SHORTCUT_DEFAULT
)
8445 vty_out (vty
, " area %s shortcut %s%s", buf
,
8446 ospf_shortcut_mode_str
[area
->shortcut_configured
],
8449 if ((area
->external_routing
== OSPF_AREA_STUB
)
8450 || (area
->external_routing
== OSPF_AREA_NSSA
)
8453 if (area
->external_routing
== OSPF_AREA_STUB
)
8454 vty_out (vty
, " area %s stub", buf
);
8455 else if (area
->external_routing
== OSPF_AREA_NSSA
)
8457 vty_out (vty
, " area %s nssa", buf
);
8458 switch (area
->NSSATranslatorRole
)
8460 case OSPF_NSSA_ROLE_NEVER
:
8461 vty_out (vty
, " translate-never");
8463 case OSPF_NSSA_ROLE_ALWAYS
:
8464 vty_out (vty
, " translate-always");
8466 case OSPF_NSSA_ROLE_CANDIDATE
:
8468 vty_out (vty
, " translate-candidate");
8472 if (area
->no_summary
)
8473 vty_out (vty
, " no-summary");
8475 vty_out (vty
, "%s", VTY_NEWLINE
);
8477 if (area
->default_cost
!= 1)
8478 vty_out (vty
, " area %s default-cost %d%s", buf
,
8479 area
->default_cost
, VTY_NEWLINE
);
8482 for (rn1
= route_top (area
->ranges
); rn1
; rn1
= route_next (rn1
))
8485 struct ospf_area_range
*range
= rn1
->info
;
8487 vty_out (vty
, " area %s range %s/%d", buf
,
8488 inet_ntoa (rn1
->p
.u
.prefix4
), rn1
->p
.prefixlen
);
8490 if (range
->cost_config
!= OSPF_AREA_RANGE_COST_UNSPEC
)
8491 vty_out (vty
, " cost %d", range
->cost_config
);
8493 if (!CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_ADVERTISE
))
8494 vty_out (vty
, " not-advertise");
8496 if (CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_SUBSTITUTE
))
8497 vty_out (vty
, " substitute %s/%d",
8498 inet_ntoa (range
->subst_addr
), range
->subst_masklen
);
8500 vty_out (vty
, "%s", VTY_NEWLINE
);
8503 if (EXPORT_NAME (area
))
8504 vty_out (vty
, " area %s export-list %s%s", buf
,
8505 EXPORT_NAME (area
), VTY_NEWLINE
);
8507 if (IMPORT_NAME (area
))
8508 vty_out (vty
, " area %s import-list %s%s", buf
,
8509 IMPORT_NAME (area
), VTY_NEWLINE
);
8511 if (PREFIX_NAME_IN (area
))
8512 vty_out (vty
, " area %s filter-list prefix %s in%s", buf
,
8513 PREFIX_NAME_IN (area
), VTY_NEWLINE
);
8515 if (PREFIX_NAME_OUT (area
))
8516 vty_out (vty
, " area %s filter-list prefix %s out%s", buf
,
8517 PREFIX_NAME_OUT (area
), VTY_NEWLINE
);
8524 config_write_ospf_nbr_nbma (struct vty
*vty
, struct ospf
*ospf
)
8526 struct ospf_nbr_nbma
*nbr_nbma
;
8527 struct route_node
*rn
;
8529 /* Static Neighbor configuration print. */
8530 for (rn
= route_top (ospf
->nbr_nbma
); rn
; rn
= route_next (rn
))
8531 if ((nbr_nbma
= rn
->info
))
8533 vty_out (vty
, " neighbor %s", inet_ntoa (nbr_nbma
->addr
));
8535 if (nbr_nbma
->priority
!= OSPF_NEIGHBOR_PRIORITY_DEFAULT
)
8536 vty_out (vty
, " priority %d", nbr_nbma
->priority
);
8538 if (nbr_nbma
->v_poll
!= OSPF_POLL_INTERVAL_DEFAULT
)
8539 vty_out (vty
, " poll-interval %d", nbr_nbma
->v_poll
);
8541 vty_out (vty
, "%s", VTY_NEWLINE
);
8548 config_write_virtual_link (struct vty
*vty
, struct ospf
*ospf
)
8550 struct listnode
*node
;
8551 struct ospf_vl_data
*vl_data
;
8552 char buf
[INET_ADDRSTRLEN
];
8554 /* Virtual-Link print */
8555 for (ALL_LIST_ELEMENTS_RO (ospf
->vlinks
, node
, vl_data
))
8557 struct listnode
*n2
;
8558 struct crypt_key
*ck
;
8559 struct ospf_interface
*oi
;
8561 if (vl_data
!= NULL
)
8563 memset (buf
, 0, INET_ADDRSTRLEN
);
8565 area_id2str (buf
, sizeof(buf
), &vl_data
->vl_area_id
, vl_data
->vl_area_id_fmt
);
8566 oi
= vl_data
->vl_oi
;
8569 if (OSPF_IF_PARAM (oi
, v_hello
) != OSPF_HELLO_INTERVAL_DEFAULT
||
8570 OSPF_IF_PARAM (oi
, v_wait
) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
||
8571 OSPF_IF_PARAM (oi
, retransmit_interval
) != OSPF_RETRANSMIT_INTERVAL_DEFAULT
||
8572 OSPF_IF_PARAM (oi
, transmit_delay
) != OSPF_TRANSMIT_DELAY_DEFAULT
)
8573 vty_out (vty
, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
8575 inet_ntoa (vl_data
->vl_peer
),
8576 OSPF_IF_PARAM (oi
, v_hello
),
8577 OSPF_IF_PARAM (oi
, retransmit_interval
),
8578 OSPF_IF_PARAM (oi
, transmit_delay
),
8579 OSPF_IF_PARAM (oi
, v_wait
),
8582 vty_out (vty
, " area %s virtual-link %s%s", buf
,
8583 inet_ntoa (vl_data
->vl_peer
), VTY_NEWLINE
);
8585 if (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
[0] != '\0')
8586 vty_out (vty
, " area %s virtual-link %s authentication-key %s%s",
8588 inet_ntoa (vl_data
->vl_peer
),
8589 IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
,
8592 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_crypt
,
8594 vty_out (vty
, " area %s virtual-link %s"
8595 " message-digest-key %d md5 %s%s",
8597 inet_ntoa (vl_data
->vl_peer
),
8598 ck
->key_id
, ck
->auth_key
, VTY_NEWLINE
);
8608 config_write_ospf_redistribute (struct vty
*vty
, struct ospf
*ospf
)
8612 /* redistribute print. */
8613 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
8615 struct list
*red_list
;
8616 struct listnode
*node
;
8617 struct ospf_redist
*red
;
8619 red_list
= ospf
->redist
[type
];
8623 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
))
8625 vty_out (vty
, " redistribute %s", zebra_route_string(type
));
8627 vty_out (vty
, " %d", red
->instance
);
8629 if (red
->dmetric
.value
>= 0)
8630 vty_out (vty
, " metric %d", red
->dmetric
.value
);
8632 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
8633 vty_out (vty
, " metric-type 1");
8635 if (ROUTEMAP_NAME (red
))
8636 vty_out (vty
, " route-map %s", ROUTEMAP_NAME (red
));
8638 vty_out (vty
, "%s", VTY_NEWLINE
);
8646 config_write_ospf_default_metric (struct vty
*vty
, struct ospf
*ospf
)
8648 if (ospf
->default_metric
!= -1)
8649 vty_out (vty
, " default-metric %d%s", ospf
->default_metric
,
8655 config_write_ospf_distribute (struct vty
*vty
, struct ospf
*ospf
)
8658 struct ospf_redist
*red
;
8662 /* distribute-list print. */
8663 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
8664 if (DISTRIBUTE_NAME (ospf
, type
))
8665 vty_out (vty
, " distribute-list %s out %s%s",
8666 DISTRIBUTE_NAME (ospf
, type
),
8667 zebra_route_string(type
), VTY_NEWLINE
);
8669 /* default-information print. */
8670 if (ospf
->default_originate
!= DEFAULT_ORIGINATE_NONE
)
8672 vty_out (vty
, " default-information originate");
8673 if (ospf
->default_originate
== DEFAULT_ORIGINATE_ALWAYS
)
8674 vty_out (vty
, " always");
8676 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
8679 if (red
->dmetric
.value
>= 0)
8680 vty_out (vty
, " metric %d",
8681 red
->dmetric
.value
);
8682 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
8683 vty_out (vty
, " metric-type 1");
8685 if (ROUTEMAP_NAME (red
))
8686 vty_out (vty
, " route-map %s",
8687 ROUTEMAP_NAME (red
));
8690 vty_out (vty
, "%s", VTY_NEWLINE
);
8699 config_write_ospf_distance (struct vty
*vty
, struct ospf
*ospf
)
8701 struct route_node
*rn
;
8702 struct ospf_distance
*odistance
;
8704 if (ospf
->distance_all
)
8705 vty_out (vty
, " distance %d%s", ospf
->distance_all
, VTY_NEWLINE
);
8707 if (ospf
->distance_intra
8708 || ospf
->distance_inter
8709 || ospf
->distance_external
)
8711 vty_out (vty
, " distance ospf");
8713 if (ospf
->distance_intra
)
8714 vty_out (vty
, " intra-area %d", ospf
->distance_intra
);
8715 if (ospf
->distance_inter
)
8716 vty_out (vty
, " inter-area %d", ospf
->distance_inter
);
8717 if (ospf
->distance_external
)
8718 vty_out (vty
, " external %d", ospf
->distance_external
);
8720 vty_out (vty
, "%s", VTY_NEWLINE
);
8723 for (rn
= route_top (ospf
->distance_table
); rn
; rn
= route_next (rn
))
8724 if ((odistance
= rn
->info
) != NULL
)
8726 vty_out (vty
, " distance %d %s/%d %s%s", odistance
->distance
,
8727 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
8728 odistance
->access_list
? odistance
->access_list
: "",
8734 /* OSPF configuration write function. */
8736 ospf_config_write (struct vty
*vty
)
8739 struct interface
*ifp
;
8740 struct ospf_interface
*oi
;
8741 struct listnode
*node
;
8744 ospf
= ospf_lookup ();
8745 if (ospf
!= NULL
&& ospf
->oi_running
)
8747 /* `router ospf' print. */
8749 vty_out (vty
, "router ospf %d%s", ospf
->instance
, VTY_NEWLINE
);
8751 vty_out (vty
, "router ospf%s", VTY_NEWLINE
);
8755 if (!ospf
->networks
)
8758 /* Router ID print. */
8759 if (ospf
->router_id_static
.s_addr
!= 0)
8760 vty_out (vty
, " ospf router-id %s%s",
8761 inet_ntoa (ospf
->router_id_static
), VTY_NEWLINE
);
8763 /* ABR type print. */
8764 if (ospf
->abr_type
!= OSPF_ABR_DEFAULT
)
8765 vty_out (vty
, " ospf abr-type %s%s",
8766 ospf_abr_type_str
[ospf
->abr_type
], VTY_NEWLINE
);
8768 /* log-adjacency-changes flag print. */
8769 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
))
8771 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
8772 vty_out(vty
, " log-adjacency-changes detail%s", VTY_NEWLINE
);
8773 else if (!DFLT_OSPF_LOG_ADJACENCY_CHANGES
)
8774 vty_out(vty
, " log-adjacency-changes%s", VTY_NEWLINE
);
8776 else if (DFLT_OSPF_LOG_ADJACENCY_CHANGES
)
8778 vty_out(vty
, " no log-adjacency-changes%s", VTY_NEWLINE
);
8781 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
8782 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
8783 vty_out (vty
, " compatible rfc1583%s", VTY_NEWLINE
);
8785 /* auto-cost reference-bandwidth configuration. */
8786 if (ospf
->ref_bandwidth
!= OSPF_DEFAULT_REF_BANDWIDTH
)
8788 vty_out (vty
, "! Important: ensure reference bandwidth "
8789 "is consistent across all routers%s", VTY_NEWLINE
);
8790 vty_out (vty
, " auto-cost reference-bandwidth %d%s",
8791 ospf
->ref_bandwidth
, VTY_NEWLINE
);
8794 /* SPF timers print. */
8795 if (ospf
->spf_delay
!= OSPF_SPF_DELAY_DEFAULT
||
8796 ospf
->spf_holdtime
!= OSPF_SPF_HOLDTIME_DEFAULT
||
8797 ospf
->spf_max_holdtime
!= OSPF_SPF_MAX_HOLDTIME_DEFAULT
)
8798 vty_out (vty
, " timers throttle spf %d %d %d%s",
8799 ospf
->spf_delay
, ospf
->spf_holdtime
,
8800 ospf
->spf_max_holdtime
, VTY_NEWLINE
);
8802 /* LSA timers print. */
8803 if (ospf
->min_ls_interval
!= OSPF_MIN_LS_INTERVAL
)
8804 vty_out (vty
, " timers throttle lsa all %d%s",
8805 ospf
->min_ls_interval
, VTY_NEWLINE
);
8806 if (ospf
->min_ls_arrival
!= OSPF_MIN_LS_ARRIVAL
)
8807 vty_out (vty
, " timers lsa min-arrival %d%s",
8808 ospf
->min_ls_arrival
, VTY_NEWLINE
);
8810 /* Write multiplier print. */
8811 if (ospf
->write_oi_count
!= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
)
8812 vty_out (vty
, " ospf write-multiplier %d%s",
8813 ospf
->write_oi_count
, VTY_NEWLINE
);
8815 /* Max-metric router-lsa print */
8816 config_write_stub_router (vty
, ospf
);
8818 /* SPF refresh parameters print. */
8819 if (ospf
->lsa_refresh_interval
!= OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
8820 vty_out (vty
, " refresh timer %d%s",
8821 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
8823 /* Redistribute information print. */
8824 config_write_ospf_redistribute (vty
, ospf
);
8826 /* passive-interface print. */
8827 if (ospf
->passive_interface_default
== OSPF_IF_PASSIVE
)
8828 vty_out (vty
, " passive-interface default%s", VTY_NEWLINE
);
8830 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, node
, ifp
))
8831 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
)
8832 && IF_DEF_PARAMS (ifp
)->passive_interface
!=
8833 ospf
->passive_interface_default
)
8835 vty_out (vty
, " %spassive-interface %s%s",
8836 IF_DEF_PARAMS (ifp
)->passive_interface
? "" : "no ",
8837 ifp
->name
, VTY_NEWLINE
);
8839 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
8841 if (!OSPF_IF_PARAM_CONFIGURED (oi
->params
, passive_interface
))
8843 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi
->ifp
),
8846 if (oi
->params
->passive_interface
== IF_DEF_PARAMS (oi
->ifp
)->passive_interface
)
8849 else if (oi
->params
->passive_interface
== ospf
->passive_interface_default
)
8852 vty_out (vty
, " %spassive-interface %s %s%s",
8853 oi
->params
->passive_interface
? "" : "no ",
8855 inet_ntoa (oi
->address
->u
.prefix4
), VTY_NEWLINE
);
8858 /* Network area print. */
8859 config_write_network_area (vty
, ospf
);
8861 /* Area config print. */
8862 config_write_ospf_area (vty
, ospf
);
8864 /* static neighbor print. */
8865 config_write_ospf_nbr_nbma (vty
, ospf
);
8867 /* Virtual-Link print. */
8868 config_write_virtual_link (vty
, ospf
);
8870 /* Default metric configuration. */
8871 config_write_ospf_default_metric (vty
, ospf
);
8873 /* Distribute-list and default-information print. */
8874 config_write_ospf_distribute (vty
, ospf
);
8876 /* Distance configuration. */
8877 config_write_ospf_distance (vty
, ospf
);
8879 ospf_opaque_config_write_router (vty
, ospf
);
8886 ospf_vty_show_init (void)
8888 /* "show ip ospf" commands. */
8889 install_element (VIEW_NODE
, &show_ip_ospf_cmd
);
8891 install_element (VIEW_NODE
, &show_ip_ospf_instance_cmd
);
8893 /* "show ip ospf database" commands. */
8894 install_element (VIEW_NODE
, &show_ip_ospf_database_type_adv_router_cmd
);
8895 install_element (VIEW_NODE
, &show_ip_ospf_database_max_cmd
);
8897 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_adv_router_cmd
);
8898 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_cmd
);
8899 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_max_cmd
);
8901 /* "show ip ospf interface" commands. */
8902 install_element (VIEW_NODE
, &show_ip_ospf_interface_cmd
);
8904 install_element (VIEW_NODE
, &show_ip_ospf_instance_interface_cmd
);
8906 /* "show ip ospf neighbor" commands. */
8907 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_detail_cmd
);
8908 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_cmd
);
8909 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_id_cmd
);
8910 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_all_cmd
);
8911 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_cmd
);
8912 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_cmd
);
8913 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_all_cmd
);
8915 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_detail_cmd
);
8916 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_cmd
);
8917 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_id_cmd
);
8918 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_all_cmd
);
8919 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_cmd
);
8920 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_cmd
);
8921 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_all_cmd
);
8923 /* "show ip ospf route" commands. */
8924 install_element (VIEW_NODE
, &show_ip_ospf_route_cmd
);
8925 install_element (VIEW_NODE
, &show_ip_ospf_border_routers_cmd
);
8927 install_element (VIEW_NODE
, &show_ip_ospf_instance_route_cmd
);
8928 install_element (VIEW_NODE
, &show_ip_ospf_instance_border_routers_cmd
);
8932 /* ospfd's interface node. */
8933 static struct cmd_node interface_node
=
8940 /* Initialization of OSPF interface. */
8942 ospf_vty_if_init (void)
8944 /* Install interface node. */
8945 install_node (&interface_node
, config_write_interface
);
8948 /* "ip ospf authentication" commands. */
8949 install_element (INTERFACE_NODE
, &ip_ospf_authentication_args_addr_cmd
);
8950 install_element (INTERFACE_NODE
, &ip_ospf_authentication_addr_cmd
);
8951 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_args_addr_cmd
);
8952 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_addr_cmd
);
8953 install_element (INTERFACE_NODE
, &ip_ospf_authentication_key_addr_cmd
);
8954 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_key_authkey_addr_cmd
);
8955 install_element (INTERFACE_NODE
, &no_ospf_authentication_key_authkey_addr_cmd
);
8957 /* "ip ospf message-digest-key" commands. */
8958 install_element (INTERFACE_NODE
, &ip_ospf_message_digest_key_cmd
);
8959 install_element (INTERFACE_NODE
, &no_ip_ospf_message_digest_key_cmd
);
8961 /* "ip ospf cost" commands. */
8962 install_element (INTERFACE_NODE
, &ip_ospf_cost_cmd
);
8963 install_element (INTERFACE_NODE
, &no_ip_ospf_cost_cmd
);
8965 /* "ip ospf mtu-ignore" commands. */
8966 install_element (INTERFACE_NODE
, &ip_ospf_mtu_ignore_addr_cmd
);
8967 install_element (INTERFACE_NODE
, &no_ip_ospf_mtu_ignore_addr_cmd
);
8969 /* "ip ospf dead-interval" commands. */
8970 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_cmd
);
8971 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_minimal_addr_cmd
);
8972 install_element (INTERFACE_NODE
, &no_ip_ospf_dead_interval_cmd
);
8974 /* "ip ospf hello-interval" commands. */
8975 install_element (INTERFACE_NODE
, &ip_ospf_hello_interval_cmd
);
8976 install_element (INTERFACE_NODE
, &no_ip_ospf_hello_interval_cmd
);
8978 /* "ip ospf network" commands. */
8979 install_element (INTERFACE_NODE
, &ip_ospf_network_cmd
);
8980 install_element (INTERFACE_NODE
, &no_ip_ospf_network_cmd
);
8982 /* "ip ospf priority" commands. */
8983 install_element (INTERFACE_NODE
, &ip_ospf_priority_cmd
);
8984 install_element (INTERFACE_NODE
, &no_ip_ospf_priority_cmd
);
8986 /* "ip ospf retransmit-interval" commands. */
8987 install_element (INTERFACE_NODE
, &ip_ospf_retransmit_interval_addr_cmd
);
8988 install_element (INTERFACE_NODE
, &no_ip_ospf_retransmit_interval_addr_cmd
);
8990 /* "ip ospf transmit-delay" commands. */
8991 install_element (INTERFACE_NODE
, &ip_ospf_transmit_delay_addr_cmd
);
8992 install_element (INTERFACE_NODE
, &no_ip_ospf_transmit_delay_addr_cmd
);
8994 /* "ip ospf area" commands. */
8995 install_element (INTERFACE_NODE
, &ip_ospf_area_cmd
);
8996 install_element (INTERFACE_NODE
, &no_ip_ospf_area_cmd
);
8998 /* These commands are compatibitliy for previous version. */
8999 install_element (INTERFACE_NODE
, &ospf_authentication_key_cmd
);
9000 install_element (INTERFACE_NODE
, &ospf_message_digest_key_cmd
);
9001 install_element (INTERFACE_NODE
, &no_ospf_message_digest_key_cmd
);
9002 install_element (INTERFACE_NODE
, &ospf_dead_interval_cmd
);
9003 install_element (INTERFACE_NODE
, &no_ospf_dead_interval_cmd
);
9004 install_element (INTERFACE_NODE
, &ospf_hello_interval_cmd
);
9005 install_element (INTERFACE_NODE
, &no_ospf_hello_interval_cmd
);
9006 install_element (INTERFACE_NODE
, &ospf_cost_cmd
);
9007 install_element (INTERFACE_NODE
, &no_ospf_cost_cmd
);
9008 install_element (INTERFACE_NODE
, &ospf_network_cmd
);
9009 install_element (INTERFACE_NODE
, &no_ospf_network_cmd
);
9010 install_element (INTERFACE_NODE
, &ospf_priority_cmd
);
9011 install_element (INTERFACE_NODE
, &no_ospf_priority_cmd
);
9012 install_element (INTERFACE_NODE
, &ospf_retransmit_interval_cmd
);
9013 install_element (INTERFACE_NODE
, &no_ospf_retransmit_interval_cmd
);
9014 install_element (INTERFACE_NODE
, &ospf_transmit_delay_cmd
);
9015 install_element (INTERFACE_NODE
, &no_ospf_transmit_delay_cmd
);
9019 ospf_vty_zebra_init (void)
9021 install_element (OSPF_NODE
, &ospf_redistribute_source_cmd
);
9022 install_element (OSPF_NODE
, &no_ospf_redistribute_source_cmd
);
9023 install_element (OSPF_NODE
, &ospf_redistribute_instance_source_cmd
);
9024 install_element (OSPF_NODE
, &no_ospf_redistribute_instance_source_cmd
);
9026 install_element (OSPF_NODE
, &ospf_distribute_list_out_cmd
);
9027 install_element (OSPF_NODE
, &no_ospf_distribute_list_out_cmd
);
9029 install_element (OSPF_NODE
, &ospf_default_information_originate_cmd
);
9030 install_element (OSPF_NODE
, &no_ospf_default_information_originate_cmd
);
9032 install_element (OSPF_NODE
, &ospf_default_metric_cmd
);
9033 install_element (OSPF_NODE
, &no_ospf_default_metric_cmd
);
9035 install_element (OSPF_NODE
, &ospf_distance_cmd
);
9036 install_element (OSPF_NODE
, &no_ospf_distance_cmd
);
9037 install_element (OSPF_NODE
, &no_ospf_distance_ospf_cmd
);
9038 install_element (OSPF_NODE
, &ospf_distance_ospf_cmd
);
9040 install_element (OSPF_NODE
, &ospf_distance_source_cmd
);
9041 install_element (OSPF_NODE
, &no_ospf_distance_source_cmd
);
9042 install_element (OSPF_NODE
, &ospf_distance_source_access_list_cmd
);
9043 install_element (OSPF_NODE
, &no_ospf_distance_source_access_list_cmd
);
9047 static struct cmd_node ospf_node
=
9050 "%s(config-router)# ",
9055 ospf_interface_clear (struct interface
*ifp
)
9057 if (!if_is_operative (ifp
)) return;
9059 if (IS_DEBUG_OSPF (ism
, ISM_EVENTS
))
9060 zlog_debug("ISM[%s]: clear by reset", ifp
->name
);
9065 DEFUN (clear_ip_ospf_interface
,
9066 clear_ip_ospf_interface_cmd
,
9067 "clear ip ospf interface [IFNAME]",
9070 "OSPF information\n"
9071 "Interface information\n"
9075 struct interface
*ifp
;
9076 struct listnode
*node
;
9078 if (argc
== 4) /* Clear all the ospfv2 interfaces. */
9080 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
9081 ospf_interface_clear(ifp
);
9083 else /* Interface name is specified. */
9085 if ((ifp
= if_lookup_by_name (argv
[idx_ifname
]->text
, VRF_DEFAULT
)) == NULL
)
9086 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
9088 ospf_interface_clear(ifp
);
9095 ospf_vty_clear_init (void)
9097 install_element (ENABLE_NODE
, &clear_ip_ospf_interface_cmd
);
9101 /* Install OSPF related vty commands. */
9103 ospf_vty_init (void)
9105 /* Install ospf top node. */
9106 install_node (&ospf_node
, ospf_config_write
);
9108 /* "router ospf" commands. */
9109 install_element (CONFIG_NODE
, &router_ospf_cmd
);
9110 install_element (CONFIG_NODE
, &no_router_ospf_cmd
);
9113 install_default (OSPF_NODE
);
9115 /* "ospf router-id" commands. */
9116 install_element (OSPF_NODE
, &ospf_router_id_cmd
);
9117 install_element (OSPF_NODE
, &ospf_router_id_old_cmd
);
9118 install_element (OSPF_NODE
, &no_ospf_router_id_cmd
);
9120 /* "passive-interface" commands. */
9121 install_element (OSPF_NODE
, &ospf_passive_interface_addr_cmd
);
9122 install_element (OSPF_NODE
, &no_ospf_passive_interface_addr_cmd
);
9124 /* "ospf abr-type" commands. */
9125 install_element (OSPF_NODE
, &ospf_abr_type_cmd
);
9126 install_element (OSPF_NODE
, &no_ospf_abr_type_cmd
);
9128 /* "ospf log-adjacency-changes" commands. */
9129 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_cmd
);
9130 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_detail_cmd
);
9131 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_cmd
);
9132 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_detail_cmd
);
9134 /* "ospf rfc1583-compatible" commands. */
9135 install_element (OSPF_NODE
, &ospf_compatible_rfc1583_cmd
);
9136 install_element (OSPF_NODE
, &no_ospf_compatible_rfc1583_cmd
);
9137 install_element (OSPF_NODE
, &ospf_rfc1583_flag_cmd
);
9138 install_element (OSPF_NODE
, &no_ospf_rfc1583_flag_cmd
);
9140 /* "network area" commands. */
9141 install_element (OSPF_NODE
, &ospf_network_area_cmd
);
9142 install_element (OSPF_NODE
, &no_ospf_network_area_cmd
);
9144 /* "area authentication" commands. */
9145 install_element (OSPF_NODE
, &ospf_area_authentication_message_digest_cmd
);
9146 install_element (OSPF_NODE
, &ospf_area_authentication_cmd
);
9147 install_element (OSPF_NODE
, &no_ospf_area_authentication_cmd
);
9149 /* "area range" commands. */
9150 install_element (OSPF_NODE
, &ospf_area_range_cmd
);
9151 install_element (OSPF_NODE
, &ospf_area_range_cost_cmd
);
9152 install_element (OSPF_NODE
, &ospf_area_range_not_advertise_cmd
);
9153 install_element (OSPF_NODE
, &no_ospf_area_range_cmd
);
9154 install_element (OSPF_NODE
, &ospf_area_range_substitute_cmd
);
9155 install_element (OSPF_NODE
, &no_ospf_area_range_substitute_cmd
);
9157 /* "area virtual-link" commands. */
9158 install_element (OSPF_NODE
, &ospf_area_vlink_cmd
);
9159 install_element (OSPF_NODE
, &ospf_area_vlink_intervals_cmd
);
9160 install_element (OSPF_NODE
, &no_ospf_area_vlink_cmd
);
9161 install_element (OSPF_NODE
, &no_ospf_area_vlink_intervals_cmd
);
9172 /* "area stub" commands. */
9173 install_element (OSPF_NODE
, &ospf_area_stub_no_summary_cmd
);
9174 install_element (OSPF_NODE
, &ospf_area_stub_cmd
);
9175 install_element (OSPF_NODE
, &no_ospf_area_stub_no_summary_cmd
);
9176 install_element (OSPF_NODE
, &no_ospf_area_stub_cmd
);
9178 /* "area nssa" commands. */
9179 install_element (OSPF_NODE
, &ospf_area_nssa_cmd
);
9180 install_element (OSPF_NODE
, &ospf_area_nssa_translate_no_summary_cmd
);
9181 install_element (OSPF_NODE
, &ospf_area_nssa_translate_cmd
);
9182 install_element (OSPF_NODE
, &ospf_area_nssa_no_summary_cmd
);
9183 install_element (OSPF_NODE
, &no_ospf_area_nssa_cmd
);
9185 install_element (OSPF_NODE
, &ospf_area_default_cost_cmd
);
9186 install_element (OSPF_NODE
, &no_ospf_area_default_cost_cmd
);
9188 install_element (OSPF_NODE
, &ospf_area_shortcut_cmd
);
9189 install_element (OSPF_NODE
, &no_ospf_area_shortcut_cmd
);
9191 install_element (OSPF_NODE
, &ospf_area_export_list_cmd
);
9192 install_element (OSPF_NODE
, &no_ospf_area_export_list_cmd
);
9194 install_element (OSPF_NODE
, &ospf_area_filter_list_cmd
);
9195 install_element (OSPF_NODE
, &no_ospf_area_filter_list_cmd
);
9197 install_element (OSPF_NODE
, &ospf_area_import_list_cmd
);
9198 install_element (OSPF_NODE
, &no_ospf_area_import_list_cmd
);
9200 /* SPF timer commands */
9201 install_element (OSPF_NODE
, &ospf_timers_throttle_spf_cmd
);
9202 install_element (OSPF_NODE
, &no_ospf_timers_throttle_spf_cmd
);
9204 /* LSA timers commands */
9205 install_element (OSPF_NODE
, &ospf_timers_min_ls_interval_cmd
);
9206 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_interval_cmd
);
9207 install_element (OSPF_NODE
, &ospf_timers_min_ls_arrival_cmd
);
9208 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_arrival_cmd
);
9209 install_element (OSPF_NODE
, &ospf_timers_lsa_cmd
);
9210 install_element (OSPF_NODE
, &no_ospf_timers_lsa_cmd
);
9212 /* refresh timer commands */
9213 install_element (OSPF_NODE
, &ospf_refresh_timer_cmd
);
9214 install_element (OSPF_NODE
, &no_ospf_refresh_timer_val_cmd
);
9216 /* max-metric commands */
9217 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_admin_cmd
);
9218 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_admin_cmd
);
9219 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_startup_cmd
);
9220 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_startup_cmd
);
9221 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_shutdown_cmd
);
9222 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_shutdown_cmd
);
9224 /* reference bandwidth commands */
9225 install_element (OSPF_NODE
, &ospf_auto_cost_reference_bandwidth_cmd
);
9226 install_element (OSPF_NODE
, &no_ospf_auto_cost_reference_bandwidth_cmd
);
9228 /* "neighbor" commands. */
9229 install_element (OSPF_NODE
, &ospf_neighbor_cmd
);
9230 install_element (OSPF_NODE
, &ospf_neighbor_poll_interval_cmd
);
9231 install_element (OSPF_NODE
, &no_ospf_neighbor_cmd
);
9232 install_element (OSPF_NODE
, &no_ospf_neighbor_poll_cmd
);
9234 /* write multiplier commands */
9235 install_element (OSPF_NODE
, &ospf_write_multiplier_cmd
);
9236 install_element (OSPF_NODE
, &write_multiplier_cmd
);
9237 install_element (OSPF_NODE
, &no_ospf_write_multiplier_cmd
);
9238 install_element (OSPF_NODE
, &no_write_multiplier_cmd
);
9240 /* Init interface related vty commands. */
9241 ospf_vty_if_init ();
9243 /* Init zebra related vty commands. */
9244 ospf_vty_zebra_init ();