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 (strmatch(argv
[1]->text
, "default"))
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 (strmatch(argv
[2]->text
, "default"))
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 && !strmatch(argv
[i
+ 1]->text
, "message-digest-"))
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 (no_ospf_area_vlink
,
1133 no_ospf_area_vlink_cmd
,
1134 "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>]",
1136 VLINK_HELPSTR_IPADDR
1137 "Enable authentication on this virtual link\n" \
1138 "Use null authentication\n" \
1139 "Use message-digest authentication\n"
1140 "Message digest authentication password (key)\n" \
1142 "Use MD5 algorithm\n" \
1143 "The OSPF password (key)")
1145 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1146 int idx_ipv4_number
= 2;
1148 struct ospf_area
*area
;
1149 struct ospf_vl_config_data vl_config
;
1150 struct ospf_vl_data
*vl_data
= NULL
;
1151 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+1];
1155 ospf_vl_config_data_init(&vl_config
, vty
);
1157 ret
= str2area_id (argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
, &format
);
1160 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1164 area
= ospf_area_lookup_by_area_id (ospf
, vl_config
.area_id
);
1167 vty_out (vty
, "Area does not exist%s", VTY_NEWLINE
);
1171 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1174 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s",
1181 /* Basic VLink no command */
1182 /* Thats all folks! - BUGS B. strikes again!!!*/
1183 if ((vl_data
= ospf_vl_lookup (ospf
, area
, vl_config
.vl_peer
)))
1184 ospf_vl_delete (ospf
, vl_data
);
1186 ospf_area_check_free (ospf
, vl_config
.area_id
);
1191 /* If we are down here, we are reseting parameters */
1193 /* Deal with other parameters */
1194 for (i
=6; i
< argc
; i
++)
1196 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1198 switch (argv
[i
]->arg
[0])
1202 if (i
> 2 || strncmp (argv
[i
]->text
, "authentication-", 15) == 0)
1204 /* authentication-key - this option can occur anywhere on
1205 command line. At start of command line
1206 must check for authentication option. */
1207 memset (auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1208 vl_config
.auth_key
= auth_key
;
1210 else if (strncmp (argv
[i
]->text
, "authentication", 14) == 0)
1212 /* authentication - this option can only occur at start
1214 vl_config
.auth_type
= OSPF_AUTH_NOTSET
;
1219 /* message-digest-key */
1220 /* Delete one key */
1224 vl_config
.crypto_key_id
= strtol (argv
[i
]->arg
, NULL
, 10);
1225 if (vl_config
.crypto_key_id
< 0)
1227 vl_config
.md5_key
= NULL
;
1237 /* Action configuration */
1239 return ospf_vl_set (ospf
, &vl_config
);
1242 DEFUN (ospf_area_vlink_intervals
,
1243 ospf_area_vlink_intervals_cmd
,
1244 "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)}",
1245 VLINK_HELPSTR_IPADDR
1246 VLINK_HELPSTR_TIME_PARAM
)
1248 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1249 struct ospf_vl_config_data vl_config
;
1252 ospf_vl_config_data_init(&vl_config
, vty
);
1254 char *area_id
= argv
[1]->arg
;
1255 char *router_id
= argv
[3]->arg
;
1257 ret
= str2area_id (area_id
, &vl_config
.area_id
, &vl_config
.area_id_fmt
);
1260 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1264 ret
= inet_aton (router_id
, &vl_config
.vl_peer
);
1267 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE
);
1271 for (int idx
= 4; idx
< argc
; idx
++)
1273 if (strmatch (argv
[idx
]->text
, "hello-interval"))
1274 vl_config
.hello_interval
= strtol(argv
[++idx
]->arg
, NULL
, 10);
1275 else if (strmatch (argv
[idx
]->text
, "retransmit-interval"))
1276 vl_config
.retransmit_interval
= strtol(argv
[++idx
]->arg
, NULL
, 10);
1277 else if (strmatch (argv
[idx
]->text
, "transmit-delay"))
1278 vl_config
.transmit_delay
= strtol(argv
[++idx
]->arg
, NULL
, 10);
1279 else if (strmatch (argv
[idx
]->text
, "dead-interval"))
1280 vl_config
.dead_interval
= strtol(argv
[++idx
]->arg
, NULL
, 10);
1283 /* 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_msg(ospf_ism_state_msg
, oi
->state
, NULL
));
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_msg(ospf_ism_state_msg
, oi
->state
, NULL
),
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();
3543 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3545 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3546 VTY_NEWLINE
, VTY_NEWLINE
);
3549 if (argc
== iface_argv
)
3551 /* Show All Interfaces.*/
3552 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
3554 if (ospf_oi_count(ifp
))
3557 json_interface_sub
= json_object_new_object();
3559 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3562 json_object_object_add (json
, ifp
->name
, json_interface_sub
);
3568 /* Interface name is specified. */
3569 if ((ifp
= if_lookup_by_name (argv
[iface_argv
]->arg
, VRF_DEFAULT
)) == NULL
)
3572 json_object_boolean_true_add(json
, "noSuchIface");
3574 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
3579 json_interface_sub
= json_object_new_object();
3581 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3584 json_object_object_add(json
, ifp
->name
, json_interface_sub
);
3590 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3591 json_object_free(json
);
3594 vty_out (vty
, "%s", VTY_NEWLINE
);
3599 DEFUN (show_ip_ospf_interface
,
3600 show_ip_ospf_interface_cmd
,
3601 "show ip ospf interface [INTERFACE] [json]",
3604 "OSPF information\n"
3605 "Interface information\n"
3610 u_char uj
= use_json(argc
, argv
);
3612 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3618 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 4, uj
);
3621 DEFUN (show_ip_ospf_instance_interface
,
3622 show_ip_ospf_instance_interface_cmd
,
3623 "show ip ospf (1-65535) interface [INTERFACE] [json]",
3626 "OSPF information\n"
3628 "Interface information\n"
3634 u_short instance
= 0;
3635 u_char uj
= use_json(argc
, argv
);
3637 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3638 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
3644 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 5, uj
);
3648 show_ip_ospf_neighbour_header (struct vty
*vty
)
3650 vty_out (vty
, "%s%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
3652 "Neighbor ID", "Pri", "State", "Dead Time",
3653 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
3658 show_ip_ospf_neighbor_sub (struct vty
*vty
, struct ospf_interface
*oi
, json_object
*json
, u_char use_json
)
3660 struct route_node
*rn
;
3661 struct ospf_neighbor
*nbr
;
3663 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3664 json_object
*json_neighbor
= NULL
;
3666 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
3668 if ((nbr
= rn
->info
))
3670 /* Do not show myself. */
3671 if (nbr
!= oi
->nbr_self
)
3673 /* Down state is not shown. */
3674 if (nbr
->state
!= NSM_Down
)
3678 json_neighbor
= json_object_new_object();
3679 ospf_nbr_state_message (nbr
, msgbuf
, 16);
3683 time_store
= monotime_until(&nbr
->t_inactivity
->u
.sands
, NULL
) / 1000LL;
3685 json_object_int_add (json_neighbor
, "priority", nbr
->priority
);
3686 json_object_string_add (json_neighbor
, "state", msgbuf
);
3687 json_object_int_add (json_neighbor
, "deadTimeMsecs", time_store
);
3688 json_object_string_add (json_neighbor
, "address", inet_ntoa (nbr
->src
));
3689 json_object_string_add (json_neighbor
, "ifaceName", IF_NAME (oi
));
3690 json_object_int_add (json_neighbor
, "retransmitCounter", ospf_ls_retransmit_count (nbr
));
3691 json_object_int_add (json_neighbor
, "requestCounter", ospf_ls_request_count (nbr
));
3692 json_object_int_add (json_neighbor
, "dbSummaryCounter", ospf_db_summary_count (nbr
));
3693 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
3694 json_object_object_add(json
, "neighbor", json_neighbor
);
3696 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_neighbor
);
3700 ospf_nbr_state_message (nbr
, msgbuf
, 16);
3702 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
3703 vty_out (vty
, "%-15s %3d %-15s ",
3707 vty_out (vty
, "%-15s %3d %-15s ",
3708 inet_ntoa (nbr
->router_id
), nbr
->priority
,
3711 vty_out (vty
, "%9s ",
3712 ospf_timer_dump (nbr
->t_inactivity
, timebuf
,
3714 vty_out (vty
, "%-15s ", inet_ntoa (nbr
->src
));
3715 vty_out (vty
, "%-20s %5ld %5ld %5d%s",
3716 IF_NAME (oi
), ospf_ls_retransmit_count (nbr
),
3717 ospf_ls_request_count (nbr
), ospf_db_summary_count (nbr
),
3727 show_ip_ospf_neighbor_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
3729 struct ospf_interface
*oi
;
3730 struct listnode
*node
;
3731 json_object
*json
= NULL
;
3734 json
= json_object_new_object();
3736 show_ip_ospf_neighbour_header (vty
);
3741 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3743 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3744 VTY_NEWLINE
, VTY_NEWLINE
);
3747 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
3748 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
3752 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3753 json_object_free(json
);
3756 vty_out (vty
, "%s", VTY_NEWLINE
);
3761 DEFUN (show_ip_ospf_neighbor
,
3762 show_ip_ospf_neighbor_cmd
,
3763 "show ip ospf neighbor [json]",
3766 "OSPF information\n"
3771 u_char uj
= use_json(argc
, argv
);
3773 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3776 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
3780 DEFUN (show_ip_ospf_instance_neighbor
,
3781 show_ip_ospf_instance_neighbor_cmd
,
3782 "show ip ospf (1-65535) neighbor [json]",
3785 "OSPF information\n"
3792 u_short instance
= 0;
3793 u_char uj
= use_json(argc
, argv
);
3795 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3796 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
3799 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
3803 show_ip_ospf_neighbor_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
3805 struct listnode
*node
;
3806 struct ospf_interface
*oi
;
3807 json_object
*json
= NULL
;
3808 json_object
*json_neighbor_sub
= NULL
;
3812 json
= json_object_new_object();
3813 json_neighbor_sub
= json_object_new_object();
3816 show_ip_ospf_neighbour_header (vty
);
3821 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3823 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3824 VTY_NEWLINE
, VTY_NEWLINE
);
3827 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
3829 struct listnode
*nbr_node
;
3830 struct ospf_nbr_nbma
*nbr_nbma
;
3832 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
3834 /* print Down neighbor status */
3835 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nbr_node
, nbr_nbma
))
3837 if (nbr_nbma
->nbr
== NULL
3838 || nbr_nbma
->nbr
->state
== NSM_Down
)
3842 json_object_int_add (json_neighbor_sub
, "nbrNbmaPriority", nbr_nbma
->priority
);
3843 json_object_boolean_true_add (json_neighbor_sub
, "nbrNbmaDown");
3844 json_object_string_add (json_neighbor_sub
, "nbrNbmaIfaceName", IF_NAME (oi
));
3845 json_object_int_add (json_neighbor_sub
, "nbrNbmaRetransmitCounter", 0);
3846 json_object_int_add (json_neighbor_sub
, "nbrNbmaRequestCounter", 0);
3847 json_object_int_add (json_neighbor_sub
, "nbrNbmaDbSummaryCounter", 0);
3848 json_object_object_add(json
, inet_ntoa (nbr_nbma
->addr
), json_neighbor_sub
);
3852 vty_out (vty
, "%-15s %3d %-15s %9s ",
3853 "-", nbr_nbma
->priority
, "Down", "-");
3854 vty_out (vty
, "%-15s %-20s %5d %5d %5d%s",
3855 inet_ntoa (nbr_nbma
->addr
), IF_NAME (oi
),
3856 0, 0, 0, VTY_NEWLINE
);
3864 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3865 json_object_free(json
);
3868 vty_out (vty
, "%s", VTY_NEWLINE
);
3873 DEFUN (show_ip_ospf_neighbor_all
,
3874 show_ip_ospf_neighbor_all_cmd
,
3875 "show ip ospf neighbor all [json]",
3878 "OSPF information\n"
3880 "include down status neighbor\n"
3884 u_char uj
= use_json(argc
, argv
);
3886 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3889 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
3892 DEFUN (show_ip_ospf_instance_neighbor_all
,
3893 show_ip_ospf_instance_neighbor_all_cmd
,
3894 "show ip ospf (1-65535) neighbor all [json]",
3897 "OSPF information\n"
3900 "include down status neighbor\n"
3905 u_short instance
= 0;
3906 u_char uj
= use_json(argc
, argv
);
3908 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3909 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
3912 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
3916 show_ip_ospf_neighbor_int_common (struct vty
*vty
, struct ospf
*ospf
, int arg_base
,
3917 struct cmd_token
**argv
, u_char use_json
)
3919 struct interface
*ifp
;
3920 struct route_node
*rn
;
3921 json_object
*json
= NULL
;
3924 json
= json_object_new_object();
3926 show_ip_ospf_neighbour_header (vty
);
3931 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3933 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3934 VTY_NEWLINE
, VTY_NEWLINE
);
3937 ifp
= if_lookup_by_name (argv
[arg_base
]->arg
, VRF_DEFAULT
);
3941 json_object_boolean_true_add(json
, "noSuchIface");
3943 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
3947 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
3949 struct ospf_interface
*oi
= rn
->info
;
3954 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
3959 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3960 json_object_free(json
);
3963 vty_out (vty
, "%s", VTY_NEWLINE
);
3968 DEFUN (show_ip_ospf_neighbor_int
,
3969 show_ip_ospf_neighbor_int_cmd
,
3970 "show ip ospf neighbor IFNAME [json]",
3973 "OSPF information\n"
3979 u_char uj
= use_json(argc
, argv
);
3981 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3984 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 0, argv
, uj
);
3987 DEFUN (show_ip_ospf_instance_neighbor_int
,
3988 show_ip_ospf_instance_neighbor_int_cmd
,
3989 "show ip ospf (1-65535) neighbor IFNAME [json]",
3992 "OSPF information\n"
4000 u_short instance
= 0;
4001 u_char uj
= use_json(argc
, argv
);
4003 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4004 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4007 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 1, argv
, uj
);
4011 show_ip_ospf_nbr_nbma_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
, struct ospf_nbr_nbma
*nbr_nbma
,
4012 u_char use_json
, json_object
*json
)
4014 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4015 json_object
*json_sub
= NULL
;
4018 json_sub
= json_object_new_object();
4019 else /* Show neighbor ID. */
4020 vty_out (vty
, " Neighbor %s,", "-");
4022 /* Show interface address. */
4024 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr_nbma
->addr
));
4026 vty_out (vty
, " interface address %s%s",
4027 inet_ntoa (nbr_nbma
->addr
), VTY_NEWLINE
);
4032 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4033 json_object_string_add(json_sub
, "iface", IF_NAME (oi
));
4036 vty_out (vty
, " In the area %s via interface %s%s",
4037 ospf_area_desc_string (oi
->area
), IF_NAME (oi
), VTY_NEWLINE
);
4039 /* Show neighbor priority and state. */
4042 json_object_int_add(json_sub
, "nbrPriority", nbr_nbma
->priority
);
4043 json_object_string_add(json_sub
, "nbrState", "down");
4046 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4047 nbr_nbma
->priority
, "Down");
4049 /* Show state changes. */
4051 json_object_int_add(json_sub
, "stateChangeCounter", nbr_nbma
->state_change
);
4053 vty_out (vty
, " %d state changes%s", nbr_nbma
->state_change
, VTY_NEWLINE
);
4055 /* Show PollInterval */
4057 json_object_int_add(json_sub
, "pollInterval", nbr_nbma
->v_poll
);
4059 vty_out (vty
, " Poll interval %d%s", nbr_nbma
->v_poll
, VTY_NEWLINE
);
4061 /* Show poll-interval timer. */
4065 time_store
= monotime_until(&nbr_nbma
->t_poll
->u
.sands
, NULL
) / 1000LL;
4066 json_object_int_add(json_sub
, "pollIntervalTimerDueMsec", time_store
);
4069 vty_out (vty
, " Poll timer due in %s%s",
4070 ospf_timer_dump (nbr_nbma
->t_poll
, timebuf
, sizeof(timebuf
)),
4073 /* Show poll-interval timer thread. */
4076 if (nbr_nbma
->t_poll
!= NULL
)
4077 json_object_string_add(json_sub
, "pollIntervalTimerThread", "on");
4080 vty_out (vty
, " Thread Poll Timer %s%s",
4081 nbr_nbma
->t_poll
!= NULL
? "on" : "off", VTY_NEWLINE
);
4084 json_object_object_add(json
, "noNbrId", json_sub
);
4088 show_ip_ospf_neighbor_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
,
4089 struct ospf_neighbor
*nbr
, u_char use_json
, json_object
*json
)
4091 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4092 json_object
*json_sub
= NULL
;
4095 json_sub
= json_object_new_object();
4098 /* Show neighbor ID. */
4099 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4100 vty_out (vty
, " Neighbor %s,", "-");
4102 vty_out (vty
, " Neighbor %s,", inet_ntoa (nbr
->router_id
));
4105 /* Show interface address. */
4107 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr
->address
.u
.prefix4
));
4109 vty_out (vty
, " interface address %s%s",
4110 inet_ntoa (nbr
->address
.u
.prefix4
), VTY_NEWLINE
);
4115 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4116 json_object_string_add(json_sub
, "ifaceName", oi
->ifp
->name
);
4119 vty_out (vty
, " In the area %s via interface %s%s",
4120 ospf_area_desc_string (oi
->area
), oi
->ifp
->name
, VTY_NEWLINE
);
4122 /* Show neighbor priority and state. */
4125 json_object_int_add(json_sub
, "nbrPriority", nbr
->priority
);
4126 json_object_string_add(json_sub
, "nbrState", lookup_msg(ospf_nsm_state_msg
, nbr
->state
, NULL
));
4129 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4130 nbr
->priority
, lookup_msg(ospf_nsm_state_msg
, nbr
->state
, NULL
));
4132 /* Show state changes. */
4134 json_object_int_add(json_sub
, "stateChangeCounter", nbr
->state_change
);
4136 vty_out (vty
, " %d state changes%s", nbr
->state_change
, VTY_NEWLINE
);
4138 if (nbr
->ts_last_progress
.tv_sec
|| nbr
->ts_last_progress
.tv_usec
)
4143 time_store
= monotime_since(&nbr
->ts_last_progress
, &res
) / 1000LL;
4146 json_object_int_add(json_sub
, "lastPrgrsvChangeMsec", time_store
);
4150 vty_out (vty
, " Most recent state change statistics:%s",
4152 vty_out (vty
, " Progressive change %s ago%s",
4153 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4158 if (nbr
->ts_last_regress
.tv_sec
|| nbr
->ts_last_regress
.tv_usec
)
4163 time_store
= monotime_since(&nbr
->ts_last_regress
, &res
) / 1000LL;
4166 json_object_int_add(json_sub
, "lastRegressiveChangeMsec", time_store
);
4167 if (nbr
->last_regress_str
)
4168 json_object_string_add(json_sub
, "lastRegressiveChangeReason", nbr
->last_regress_str
);
4172 vty_out (vty
, " Regressive change %s ago, due to %s%s",
4173 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4174 (nbr
->last_regress_str
? nbr
->last_regress_str
: "??"),
4179 /* Show Designated Rotuer ID. */
4181 json_object_string_add(json_sub
, "routerDesignatedId", inet_ntoa (nbr
->d_router
));
4183 vty_out (vty
, " DR is %s,", inet_ntoa (nbr
->d_router
));
4185 /* Show Backup Designated Rotuer ID. */
4187 json_object_string_add(json_sub
, "routerDesignatedBackupId", inet_ntoa (nbr
->bd_router
));
4189 vty_out (vty
, " BDR is %s%s", inet_ntoa (nbr
->bd_router
), VTY_NEWLINE
);
4194 json_object_int_add(json_sub
, "optionsCounter", nbr
->options
);
4195 json_object_string_add(json_sub
, "optionsList", ospf_options_dump (nbr
->options
));
4198 vty_out (vty
, " Options %d %s%s", nbr
->options
,
4199 ospf_options_dump (nbr
->options
), VTY_NEWLINE
);
4201 /* Show Router Dead interval timer. */
4204 if (nbr
->t_inactivity
)
4207 time_store
= monotime_until(&nbr
->t_inactivity
->u
.sands
, NULL
) / 1000LL;
4208 json_object_int_add(json_sub
, "routerDeadIntervalTimerDueMsec", time_store
);
4211 json_object_int_add(json_sub
, "routerDeadIntervalTimerDueMsec", -1);
4214 vty_out (vty
, " Dead timer due in %s%s",
4215 ospf_timer_dump (nbr
->t_inactivity
, timebuf
, sizeof (timebuf
)),
4218 /* Show Database Summary list. */
4220 json_object_int_add(json_sub
, "databaseSummaryListCounter", ospf_db_summary_count (nbr
));
4222 vty_out (vty
, " Database Summary List %d%s",
4223 ospf_db_summary_count (nbr
), VTY_NEWLINE
);
4225 /* Show Link State Request list. */
4227 json_object_int_add(json_sub
, "linkStateRequestListCounter", ospf_ls_request_count (nbr
));
4229 vty_out (vty
, " Link State Request List %ld%s",
4230 ospf_ls_request_count (nbr
), VTY_NEWLINE
);
4232 /* Show Link State Retransmission list. */
4234 json_object_int_add(json_sub
, "linkStateRetransmissionListCounter", ospf_ls_retransmit_count (nbr
));
4236 vty_out (vty
, " Link State Retransmission List %ld%s",
4237 ospf_ls_retransmit_count (nbr
), VTY_NEWLINE
);
4239 /* Show inactivity timer thread. */
4242 if (nbr
->t_inactivity
!= NULL
)
4243 json_object_string_add(json_sub
, "threadInactivityTimer", "on");
4246 vty_out (vty
, " Thread Inactivity Timer %s%s",
4247 nbr
->t_inactivity
!= NULL
? "on" : "off", VTY_NEWLINE
);
4249 /* Show Database Description retransmission thread. */
4252 if (nbr
->t_db_desc
!= NULL
)
4253 json_object_string_add(json_sub
, "threadDatabaseDescriptionRetransmission", "on");
4256 vty_out (vty
, " Thread Database Description Retransmision %s%s",
4257 nbr
->t_db_desc
!= NULL
? "on" : "off", VTY_NEWLINE
);
4259 /* Show Link State Request Retransmission thread. */
4262 if (nbr
->t_ls_req
!= NULL
)
4263 json_object_string_add(json_sub
, "threadLinkStateRequestRetransmission", "on");
4266 vty_out (vty
, " Thread Link State Request Retransmission %s%s",
4267 nbr
->t_ls_req
!= NULL
? "on" : "off", VTY_NEWLINE
);
4269 /* Show Link State Update Retransmission thread. */
4272 if (nbr
->t_ls_upd
!= NULL
)
4273 json_object_string_add(json_sub
, "threadLinkStateUpdateRetransmission", "on");
4276 vty_out (vty
, " Thread Link State Update Retransmission %s%s%s",
4277 nbr
->t_ls_upd
!= NULL
? "on" : "off", VTY_NEWLINE
, VTY_NEWLINE
);
4281 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4282 json_object_object_add(json
, "noNbrId", json_sub
);
4284 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_sub
);
4287 ospf_bfd_show_info(vty
, nbr
->bfd_info
, json
, use_json
, 0);
4291 show_ip_ospf_neighbor_id_common (struct vty
*vty
, struct ospf
*ospf
,
4292 int arg_base
, struct cmd_token
**argv
, u_char use_json
)
4294 struct listnode
*node
;
4295 struct ospf_neighbor
*nbr
;
4296 struct ospf_interface
*oi
;
4297 struct in_addr router_id
;
4299 json_object
*json
= NULL
;
4302 json
= json_object_new_object();
4307 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4309 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4310 VTY_NEWLINE
, VTY_NEWLINE
);
4313 ret
= inet_aton (argv
[arg_base
]->arg
, &router_id
);
4317 vty_out (vty
, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE
);
4321 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4323 if ((nbr
= ospf_nbr_lookup_by_routerid (oi
->nbrs
, &router_id
)))
4325 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4331 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4332 json_object_free(json
);
4335 vty_out (vty
, "%s", VTY_NEWLINE
);
4340 DEFUN (show_ip_ospf_neighbor_id
,
4341 show_ip_ospf_neighbor_id_cmd
,
4342 "show ip ospf neighbor A.B.C.D [json]",
4345 "OSPF information\n"
4351 u_char uj
= use_json(argc
, argv
);
4353 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4356 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 0, argv
, uj
);
4359 DEFUN (show_ip_ospf_instance_neighbor_id
,
4360 show_ip_ospf_instance_neighbor_id_cmd
,
4361 "show ip ospf (1-65535) neighbor A.B.C.D [json]",
4364 "OSPF information\n"
4372 u_short instance
= 0;
4373 u_char uj
= use_json(argc
, argv
);
4375 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4376 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4379 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 1, argv
, uj
);
4383 show_ip_ospf_neighbor_detail_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4385 struct ospf_interface
*oi
;
4386 struct listnode
*node
;
4387 json_object
*json
= NULL
;
4390 json
= json_object_new_object();
4395 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4397 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4398 VTY_NEWLINE
, VTY_NEWLINE
);
4401 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4403 struct route_node
*rn
;
4404 struct ospf_neighbor
*nbr
;
4406 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4408 if ((nbr
= rn
->info
))
4410 if (nbr
!= oi
->nbr_self
)
4412 if (nbr
->state
!= NSM_Down
)
4414 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4423 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4424 json_object_free(json
);
4427 vty_out (vty
, "%s", VTY_NEWLINE
);
4432 DEFUN (show_ip_ospf_neighbor_detail
,
4433 show_ip_ospf_neighbor_detail_cmd
,
4434 "show ip ospf neighbor detail [json]",
4437 "OSPF information\n"
4439 "detail of all neighbors\n"
4443 u_char uj
= use_json(argc
, argv
);
4445 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4448 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4451 DEFUN (show_ip_ospf_instance_neighbor_detail
,
4452 show_ip_ospf_instance_neighbor_detail_cmd
,
4453 "show ip ospf (1-65535) neighbor detail [json]",
4456 "OSPF information\n"
4459 "detail of all neighbors\n"
4464 u_short instance
= 0;
4465 u_char uj
= use_json(argc
, argv
);
4467 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4468 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
4471 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4475 show_ip_ospf_neighbor_detail_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4477 struct listnode
*node
;
4478 struct ospf_interface
*oi
;
4479 json_object
*json
= NULL
;
4482 json
= json_object_new_object();
4487 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4489 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4490 VTY_NEWLINE
, VTY_NEWLINE
);
4493 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4495 struct route_node
*rn
;
4496 struct ospf_neighbor
*nbr
;
4497 struct ospf_nbr_nbma
*nbr_nbma
;
4499 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4500 if ((nbr
= rn
->info
))
4501 if (nbr
!= oi
->nbr_self
)
4502 if (nbr
->state
!= NSM_Down
)
4503 show_ip_ospf_neighbor_detail_sub (vty
, oi
, rn
->info
, use_json
, json
);
4505 if (oi
->type
== OSPF_IFTYPE_NBMA
)
4507 struct listnode
*nd
;
4509 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nd
, nbr_nbma
))
4511 if (nbr_nbma
->nbr
== NULL
|| nbr_nbma
->nbr
->state
== NSM_Down
)
4512 show_ip_ospf_nbr_nbma_detail_sub (vty
, oi
, nbr_nbma
, use_json
, json
);
4519 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4520 json_object_free(json
);
4524 vty_out (vty
, "%s", VTY_NEWLINE
);
4530 DEFUN (show_ip_ospf_neighbor_detail_all
,
4531 show_ip_ospf_neighbor_detail_all_cmd
,
4532 "show ip ospf neighbor detail all [json]",
4535 "OSPF information\n"
4537 "detail of all neighbors\n"
4538 "include down status neighbor\n"
4542 u_char uj
= use_json(argc
, argv
);
4544 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4547 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4550 DEFUN (show_ip_ospf_instance_neighbor_detail_all
,
4551 show_ip_ospf_instance_neighbor_detail_all_cmd
,
4552 "show ip ospf (1-65535) neighbor detail all [json]",
4555 "OSPF information\n"
4558 "detail of all neighbors\n"
4559 "include down status neighbor\n"
4564 u_short instance
= 0;
4565 u_char uj
= use_json(argc
, argv
);
4567 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4568 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4571 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4575 show_ip_ospf_neighbor_int_detail_common (struct vty
*vty
, struct ospf
*ospf
,
4576 int arg_base
, struct cmd_token
**argv
, u_char use_json
)
4578 struct ospf_interface
*oi
;
4579 struct interface
*ifp
;
4580 struct route_node
*rn
, *nrn
;
4581 struct ospf_neighbor
*nbr
;
4582 json_object
*json
= NULL
;
4585 json
= json_object_new_object();
4590 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4592 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4593 VTY_NEWLINE
, VTY_NEWLINE
);
4596 ifp
= if_lookup_by_name (argv
[arg_base
]->arg
, VRF_DEFAULT
);
4600 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
4604 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
4606 if ((oi
= rn
->info
))
4608 for (nrn
= route_top (oi
->nbrs
); nrn
; nrn
= route_next (nrn
))
4610 if ((nbr
= nrn
->info
))
4612 if (nbr
!= oi
->nbr_self
)
4614 if (nbr
->state
!= NSM_Down
)
4615 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4624 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4625 json_object_free(json
);
4628 vty_out (vty
, "%s", VTY_NEWLINE
);
4633 DEFUN (show_ip_ospf_neighbor_int_detail
,
4634 show_ip_ospf_neighbor_int_detail_cmd
,
4635 "show ip ospf neighbor IFNAME detail [json]",
4638 "OSPF information\n"
4641 "detail of all neighbors\n"
4645 u_char uj
= use_json(argc
, argv
);
4647 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4650 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 0, argv
, uj
);
4653 DEFUN (show_ip_ospf_instance_neighbor_int_detail
,
4654 show_ip_ospf_instance_neighbor_int_detail_cmd
,
4655 "show ip ospf (1-65535) neighbor IFNAME detail [json]",
4658 "OSPF information\n"
4662 "detail of all neighbors\n"
4667 u_short instance
= 0;
4668 u_char uj
= use_json(argc
, argv
);
4670 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4671 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4674 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 1, argv
, uj
);
4677 /* Show functions */
4679 show_lsa_summary (struct vty
*vty
, struct ospf_lsa
*lsa
, int self
)
4681 struct router_lsa
*rl
;
4682 struct summary_lsa
*sl
;
4683 struct as_external_lsa
*asel
;
4684 struct prefix_ipv4 p
;
4687 /* If self option is set, check LSA self flag. */
4688 if (self
== 0 || IS_LSA_SELF (lsa
))
4690 /* LSA common part show. */
4691 vty_out (vty
, "%-15s ", inet_ntoa (lsa
->data
->id
));
4692 vty_out (vty
, "%-15s %4d 0x%08lx 0x%04x",
4693 inet_ntoa (lsa
->data
->adv_router
), LS_AGE (lsa
),
4694 (u_long
)ntohl (lsa
->data
->ls_seqnum
), ntohs (lsa
->data
->checksum
));
4695 /* LSA specific part show. */
4696 switch (lsa
->data
->type
)
4698 case OSPF_ROUTER_LSA
:
4699 rl
= (struct router_lsa
*) lsa
->data
;
4700 vty_out (vty
, " %-d", ntohs (rl
->links
));
4702 case OSPF_SUMMARY_LSA
:
4703 sl
= (struct summary_lsa
*) lsa
->data
;
4706 p
.prefix
= sl
->header
.id
;
4707 p
.prefixlen
= ip_masklen (sl
->mask
);
4708 apply_mask_ipv4 (&p
);
4710 vty_out (vty
, " %s/%d", inet_ntoa (p
.prefix
), p
.prefixlen
);
4712 case OSPF_AS_EXTERNAL_LSA
:
4713 case OSPF_AS_NSSA_LSA
:
4714 asel
= (struct as_external_lsa
*) lsa
->data
;
4717 p
.prefix
= asel
->header
.id
;
4718 p
.prefixlen
= ip_masklen (asel
->mask
);
4719 apply_mask_ipv4 (&p
);
4721 vty_out (vty
, " %s %s/%d [0x%lx]",
4722 IS_EXTERNAL_METRIC (asel
->e
[0].tos
) ? "E2" : "E1",
4723 inet_ntoa (p
.prefix
), p
.prefixlen
,
4724 (u_long
)ntohl (asel
->e
[0].route_tag
));
4726 case OSPF_NETWORK_LSA
:
4727 case OSPF_ASBR_SUMMARY_LSA
:
4728 case OSPF_OPAQUE_LINK_LSA
:
4729 case OSPF_OPAQUE_AREA_LSA
:
4730 case OSPF_OPAQUE_AS_LSA
:
4734 vty_out (vty
, VTY_NEWLINE
);
4740 static const char *show_database_desc
[] =
4743 "Router Link States",
4745 "Summary Link States",
4746 "ASBR-Summary Link States",
4747 "AS External Link States",
4748 "Group Membership LSA",
4749 "NSSA-external Link States",
4751 "Link-Local Opaque-LSA",
4752 "Area-Local Opaque-LSA",
4753 "AS-external Opaque-LSA",
4756 static const char *show_database_header
[] =
4759 "Link ID ADV Router Age Seq# CkSum Link count",
4760 "Link ID ADV Router Age Seq# CkSum",
4761 "Link ID ADV Router Age Seq# CkSum Route",
4762 "Link ID ADV Router Age Seq# CkSum",
4763 "Link ID ADV Router Age Seq# CkSum Route",
4764 " --- header for Group Member ----",
4765 "Link ID ADV Router Age Seq# CkSum Route",
4767 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4768 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4769 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4773 show_ip_ospf_database_header (struct vty
*vty
, struct ospf_lsa
*lsa
)
4775 struct router_lsa
*rlsa
= (struct router_lsa
*) lsa
->data
;
4777 vty_out (vty
, " LS age: %d%s", LS_AGE (lsa
), VTY_NEWLINE
);
4778 vty_out (vty
, " Options: 0x%-2x : %s%s",
4780 ospf_options_dump(lsa
->data
->options
),
4782 vty_out (vty
, " LS Flags: 0x%-2x %s%s",
4784 ((lsa
->flags
& OSPF_LSA_LOCAL_XLT
) ? "(Translated from Type-7)" : ""),
4787 if (lsa
->data
->type
== OSPF_ROUTER_LSA
)
4789 vty_out (vty
, " Flags: 0x%x" , rlsa
->flags
);
4792 vty_out (vty
, " :%s%s%s%s",
4793 IS_ROUTER_LSA_BORDER (rlsa
) ? " ABR" : "",
4794 IS_ROUTER_LSA_EXTERNAL (rlsa
) ? " ASBR" : "",
4795 IS_ROUTER_LSA_VIRTUAL (rlsa
) ? " VL-endpoint" : "",
4796 IS_ROUTER_LSA_SHORTCUT (rlsa
) ? " Shortcut" : "");
4798 vty_out (vty
, "%s", VTY_NEWLINE
);
4800 vty_out (vty
, " LS Type: %s%s",
4801 lookup_msg(ospf_lsa_type_msg
, lsa
->data
->type
, NULL
), VTY_NEWLINE
);
4802 vty_out (vty
, " Link State ID: %s %s%s", inet_ntoa (lsa
->data
->id
),
4803 lookup_msg(ospf_link_state_id_type_msg
, lsa
->data
->type
, NULL
), VTY_NEWLINE
);
4804 vty_out (vty
, " Advertising Router: %s%s",
4805 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
4806 vty_out (vty
, " LS Seq Number: %08lx%s", (u_long
)ntohl (lsa
->data
->ls_seqnum
),
4808 vty_out (vty
, " Checksum: 0x%04x%s", ntohs (lsa
->data
->checksum
),
4810 vty_out (vty
, " Length: %d%s", ntohs (lsa
->data
->length
), VTY_NEWLINE
);
4813 const char *link_type_desc
[] =
4816 "another Router (point-to-point)",
4817 "a Transit Network",
4822 const char *link_id_desc
[] =
4825 "Neighboring Router ID",
4826 "Designated Router address",
4828 "Neighboring Router ID",
4831 const char *link_data_desc
[] =
4834 "Router Interface address",
4835 "Router Interface address",
4837 "Router Interface address",
4840 /* Show router-LSA each Link information. */
4842 show_ip_ospf_database_router_links (struct vty
*vty
,
4843 struct router_lsa
*rl
)
4848 len
= ntohs (rl
->header
.length
) - 4;
4849 for (i
= 0; i
< ntohs (rl
->links
) && len
> 0; len
-= 12, i
++)
4851 type
= rl
->link
[i
].type
;
4853 vty_out (vty
, " Link connected to: %s%s",
4854 link_type_desc
[type
], VTY_NEWLINE
);
4855 vty_out (vty
, " (Link ID) %s: %s%s", link_id_desc
[type
],
4856 inet_ntoa (rl
->link
[i
].link_id
), VTY_NEWLINE
);
4857 vty_out (vty
, " (Link Data) %s: %s%s", link_data_desc
[type
],
4858 inet_ntoa (rl
->link
[i
].link_data
), VTY_NEWLINE
);
4859 vty_out (vty
, " Number of TOS metrics: 0%s", VTY_NEWLINE
);
4860 vty_out (vty
, " TOS 0 Metric: %d%s",
4861 ntohs (rl
->link
[i
].metric
), VTY_NEWLINE
);
4862 vty_out (vty
, "%s", VTY_NEWLINE
);
4866 /* Show router-LSA detail information. */
4868 show_router_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4872 struct router_lsa
*rl
= (struct router_lsa
*) lsa
->data
;
4874 show_ip_ospf_database_header (vty
, lsa
);
4876 vty_out (vty
, " Number of Links: %d%s%s", ntohs (rl
->links
),
4877 VTY_NEWLINE
, VTY_NEWLINE
);
4879 show_ip_ospf_database_router_links (vty
, rl
);
4880 vty_out (vty
, "%s", VTY_NEWLINE
);
4886 /* Show network-LSA detail information. */
4888 show_network_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4894 struct network_lsa
*nl
= (struct network_lsa
*) lsa
->data
;
4896 show_ip_ospf_database_header (vty
, lsa
);
4898 vty_out (vty
, " Network Mask: /%d%s",
4899 ip_masklen (nl
->mask
), VTY_NEWLINE
);
4901 length
= ntohs (lsa
->data
->length
) - OSPF_LSA_HEADER_SIZE
- 4;
4903 for (i
= 0; length
> 0; i
++, length
-= 4)
4904 vty_out (vty
, " Attached Router: %s%s",
4905 inet_ntoa (nl
->routers
[i
]), VTY_NEWLINE
);
4907 vty_out (vty
, "%s", VTY_NEWLINE
);
4913 /* Show summary-LSA detail information. */
4915 show_summary_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4919 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
4921 show_ip_ospf_database_header (vty
, lsa
);
4923 vty_out (vty
, " Network Mask: /%d%s", ip_masklen (sl
->mask
),
4925 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
4927 vty_out (vty
, "%s", VTY_NEWLINE
);
4933 /* Show summary-ASBR-LSA detail information. */
4935 show_summary_asbr_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4939 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
4941 show_ip_ospf_database_header (vty
, lsa
);
4943 vty_out (vty
, " Network Mask: /%d%s",
4944 ip_masklen (sl
->mask
), VTY_NEWLINE
);
4945 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
4947 vty_out (vty
, "%s", VTY_NEWLINE
);
4953 /* Show AS-external-LSA detail information. */
4955 show_as_external_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4959 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
4961 show_ip_ospf_database_header (vty
, lsa
);
4963 vty_out (vty
, " Network Mask: /%d%s",
4964 ip_masklen (al
->mask
), VTY_NEWLINE
);
4965 vty_out (vty
, " Metric Type: %s%s",
4966 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
4967 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
4968 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
4969 vty_out (vty
, " Metric: %d%s",
4970 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
4971 vty_out (vty
, " Forward Address: %s%s",
4972 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
4974 vty_out (vty
, " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
4975 (route_tag_t
)ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
4982 show_as_external_lsa_stdvty (struct ospf_lsa
*lsa
)
4984 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
4986 /* show_ip_ospf_database_header (vty, lsa); */
4988 zlog_debug( " Network Mask: /%d%s",
4989 ip_masklen (al
->mask
), "\n");
4990 zlog_debug( " Metric Type: %s%s",
4991 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
4992 "2 (Larger than any link state path)" : "1", "\n");
4993 zlog_debug( " TOS: 0%s", "\n");
4994 zlog_debug( " Metric: %d%s",
4995 GET_METRIC (al
->e
[0].metric
), "\n");
4996 zlog_debug( " Forward Address: %s%s",
4997 inet_ntoa (al
->e
[0].fwd_addr
), "\n");
4999 zlog_debug( " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5000 (route_tag_t
)ntohl (al
->e
[0].route_tag
), "\n", "\n");
5005 /* Show AS-NSSA-LSA detail information. */
5007 show_as_nssa_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5011 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5013 show_ip_ospf_database_header (vty
, lsa
);
5015 vty_out (vty
, " Network Mask: /%d%s",
5016 ip_masklen (al
->mask
), VTY_NEWLINE
);
5017 vty_out (vty
, " Metric Type: %s%s",
5018 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5019 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
5020 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
5021 vty_out (vty
, " Metric: %d%s",
5022 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
5023 vty_out (vty
, " NSSA: Forward Address: %s%s",
5024 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
5026 vty_out (vty
, " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5027 (route_tag_t
)ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
5034 show_func_dummy (struct vty
*vty
, struct ospf_lsa
*lsa
)
5040 show_opaque_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5044 show_ip_ospf_database_header (vty
, lsa
);
5045 show_opaque_info_detail (vty
, lsa
);
5047 vty_out (vty
, "%s", VTY_NEWLINE
);
5052 int (*show_function
[])(struct vty
*, struct ospf_lsa
*) =
5055 show_router_lsa_detail
,
5056 show_network_lsa_detail
,
5057 show_summary_lsa_detail
,
5058 show_summary_asbr_lsa_detail
,
5059 show_as_external_lsa_detail
,
5061 show_as_nssa_lsa_detail
, /* almost same as external */
5063 show_opaque_lsa_detail
,
5064 show_opaque_lsa_detail
,
5065 show_opaque_lsa_detail
,
5069 show_lsa_prefix_set (struct vty
*vty
, struct prefix_ls
*lp
, struct in_addr
*id
,
5070 struct in_addr
*adv_router
)
5072 memset (lp
, 0, sizeof (struct prefix_ls
));
5076 else if (adv_router
== NULL
)
5085 lp
->adv_router
= *adv_router
;
5090 show_lsa_detail_proc (struct vty
*vty
, struct route_table
*rt
,
5091 struct in_addr
*id
, struct in_addr
*adv_router
)
5093 struct prefix_ls lp
;
5094 struct route_node
*rn
, *start
;
5095 struct ospf_lsa
*lsa
;
5097 show_lsa_prefix_set (vty
, &lp
, id
, adv_router
);
5098 start
= route_node_get (rt
, (struct prefix
*) &lp
);
5101 route_lock_node (start
);
5102 for (rn
= start
; rn
; rn
= route_next_until (rn
, start
))
5103 if ((lsa
= rn
->info
))
5105 if (show_function
[lsa
->data
->type
] != NULL
)
5106 show_function
[lsa
->data
->type
] (vty
, lsa
);
5108 route_unlock_node (start
);
5112 /* Show detail LSA information
5113 -- if id is NULL then show all LSAs. */
5115 show_lsa_detail (struct vty
*vty
, struct ospf
*ospf
, int type
,
5116 struct in_addr
*id
, struct in_addr
*adv_router
)
5118 struct listnode
*node
;
5119 struct ospf_area
*area
;
5123 case OSPF_AS_EXTERNAL_LSA
:
5124 case OSPF_OPAQUE_AS_LSA
:
5125 vty_out (vty
, " %s %s%s",
5126 show_database_desc
[type
],
5127 VTY_NEWLINE
, VTY_NEWLINE
);
5128 show_lsa_detail_proc (vty
, AS_LSDB (ospf
, type
), id
, adv_router
);
5131 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5133 vty_out (vty
, "%s %s (Area %s)%s%s",
5134 VTY_NEWLINE
, show_database_desc
[type
],
5135 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5136 show_lsa_detail_proc (vty
, AREA_LSDB (area
, type
), id
, adv_router
);
5143 show_lsa_detail_adv_router_proc (struct vty
*vty
, struct route_table
*rt
,
5144 struct in_addr
*adv_router
)
5146 struct route_node
*rn
;
5147 struct ospf_lsa
*lsa
;
5149 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
5150 if ((lsa
= rn
->info
))
5151 if (IPV4_ADDR_SAME (adv_router
, &lsa
->data
->adv_router
))
5153 if (CHECK_FLAG (lsa
->flags
, OSPF_LSA_LOCAL_XLT
))
5155 if (show_function
[lsa
->data
->type
] != NULL
)
5156 show_function
[lsa
->data
->type
] (vty
, lsa
);
5160 /* Show detail LSA information. */
5162 show_lsa_detail_adv_router (struct vty
*vty
, struct ospf
*ospf
, int type
,
5163 struct in_addr
*adv_router
)
5165 struct listnode
*node
;
5166 struct ospf_area
*area
;
5170 case OSPF_AS_EXTERNAL_LSA
:
5171 case OSPF_OPAQUE_AS_LSA
:
5172 vty_out (vty
, " %s %s%s",
5173 show_database_desc
[type
],
5174 VTY_NEWLINE
, VTY_NEWLINE
);
5175 show_lsa_detail_adv_router_proc (vty
, AS_LSDB (ospf
, type
),
5179 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5181 vty_out (vty
, "%s %s (Area %s)%s%s",
5182 VTY_NEWLINE
, show_database_desc
[type
],
5183 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5184 show_lsa_detail_adv_router_proc (vty
, AREA_LSDB (area
, type
),
5192 show_ip_ospf_database_summary (struct vty
*vty
, struct ospf
*ospf
, int self
)
5194 struct ospf_lsa
*lsa
;
5195 struct route_node
*rn
;
5196 struct ospf_area
*area
;
5197 struct listnode
*node
;
5200 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5202 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5206 case OSPF_AS_EXTERNAL_LSA
:
5207 case OSPF_OPAQUE_AS_LSA
:
5212 if (ospf_lsdb_count_self (area
->lsdb
, type
) > 0 ||
5213 (!self
&& ospf_lsdb_count (area
->lsdb
, type
) > 0))
5215 vty_out (vty
, " %s (Area %s)%s%s",
5216 show_database_desc
[type
],
5217 ospf_area_desc_string (area
),
5218 VTY_NEWLINE
, VTY_NEWLINE
);
5219 vty_out (vty
, "%s%s", show_database_header
[type
], VTY_NEWLINE
);
5221 LSDB_LOOP (AREA_LSDB (area
, type
), rn
, lsa
)
5222 show_lsa_summary (vty
, lsa
, self
);
5224 vty_out (vty
, "%s", VTY_NEWLINE
);
5229 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5233 case OSPF_AS_EXTERNAL_LSA
:
5234 case OSPF_OPAQUE_AS_LSA
:
5239 if (ospf_lsdb_count_self (ospf
->lsdb
, type
) ||
5240 (!self
&& ospf_lsdb_count (ospf
->lsdb
, type
)))
5242 vty_out (vty
, " %s%s%s",
5243 show_database_desc
[type
],
5244 VTY_NEWLINE
, VTY_NEWLINE
);
5245 vty_out (vty
, "%s%s", show_database_header
[type
],
5248 LSDB_LOOP (AS_LSDB (ospf
, type
), rn
, lsa
)
5249 show_lsa_summary (vty
, lsa
, self
);
5251 vty_out (vty
, "%s", VTY_NEWLINE
);
5255 vty_out (vty
, "%s", VTY_NEWLINE
);
5259 show_ip_ospf_database_maxage (struct vty
*vty
, struct ospf
*ospf
)
5261 struct route_node
*rn
;
5263 vty_out (vty
, "%s MaxAge Link States:%s%s",
5264 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
5266 for (rn
= route_top (ospf
->maxage_lsa
); rn
; rn
= route_next (rn
))
5268 struct ospf_lsa
*lsa
;
5270 if ((lsa
= rn
->info
) != NULL
)
5272 vty_out (vty
, "Link type: %d%s", lsa
->data
->type
, VTY_NEWLINE
);
5273 vty_out (vty
, "Link State ID: %s%s",
5274 inet_ntoa (lsa
->data
->id
), VTY_NEWLINE
);
5275 vty_out (vty
, "Advertising Router: %s%s",
5276 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
5277 vty_out (vty
, "LSA lock count: %d%s", lsa
->lock
, VTY_NEWLINE
);
5278 vty_out (vty
, "%s", VTY_NEWLINE
);
5283 #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
5284 #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
5286 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
5287 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
5288 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
5289 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
5291 #define OSPF_LSA_TYPES_DESC \
5292 "ASBR summary link states\n" \
5293 "External link states\n" \
5294 "Network link states\n" \
5295 "Router link states\n" \
5296 "Network summary link states\n" \
5297 OSPF_LSA_TYPE_NSSA_DESC \
5298 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
5299 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
5300 OSPF_LSA_TYPE_OPAQUE_AS_DESC
5303 show_ip_ospf_database_common (struct vty
*vty
, struct ospf
*ospf
,
5304 int arg_base
, int argc
, struct cmd_token
**argv
)
5308 struct in_addr id
, adv_router
;
5311 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5314 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5315 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5318 if (argc
== arg_base
+ 4)
5320 show_ip_ospf_database_summary (vty
, ospf
, 0);
5324 /* Set database type to show. */
5325 if (strncmp (argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5326 type
= OSPF_ROUTER_LSA
;
5327 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5328 type
= OSPF_NETWORK_LSA
;
5329 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5330 type
= OSPF_AS_NSSA_LSA
;
5331 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "su", 2) == 0)
5332 type
= OSPF_SUMMARY_LSA
;
5333 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5334 type
= OSPF_ASBR_SUMMARY_LSA
;
5335 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5336 type
= OSPF_AS_EXTERNAL_LSA
;
5337 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "se", 2) == 0)
5339 show_ip_ospf_database_summary (vty
, ospf
, 1);
5342 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "m", 1) == 0)
5344 show_ip_ospf_database_maxage (vty
, ospf
);
5347 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5348 type
= OSPF_OPAQUE_LINK_LSA
;
5349 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5350 type
= OSPF_OPAQUE_AREA_LSA
;
5351 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5352 type
= OSPF_OPAQUE_AS_LSA
;
5356 /* `show ip ospf database LSA'. */
5357 if (argc
== arg_base
+ 5)
5358 show_lsa_detail (vty
, ospf
, type
, NULL
, NULL
);
5359 else if (argc
>= arg_base
+ 6)
5361 ret
= inet_aton (argv
[arg_base
+ 5]->arg
, &id
);
5365 /* `show ip ospf database LSA ID'. */
5366 if (argc
== arg_base
+ 6)
5367 show_lsa_detail (vty
, ospf
, type
, &id
, NULL
);
5368 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
5369 else if (argc
== arg_base
+ 7)
5371 if (strncmp (argv
[arg_base
+ 6]->text
, "s", 1) == 0)
5372 adv_router
= ospf
->router_id
;
5375 ret
= inet_aton (argv
[arg_base
+ 7]->arg
, &adv_router
);
5379 show_lsa_detail (vty
, ospf
, type
, &id
, &adv_router
);
5386 DEFUN (show_ip_ospf_database_max
,
5387 show_ip_ospf_database_max_cmd
,
5388 "show ip ospf database <max-age|self-originate>",
5391 "OSPF information\n"
5392 "Database summary\n"
5393 "LSAs in MaxAge list\n"
5394 "Self-originated link states\n")
5398 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5401 return (show_ip_ospf_database_common(vty
, ospf
, 0, argc
, argv
));
5404 DEFUN (show_ip_ospf_instance_database
,
5405 show_ip_ospf_instance_database_cmd
,
5406 "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>]]]",
5409 "OSPF information\n"
5411 "Database summary\n"
5413 "Link State ID (as an IP address)\n"
5414 "Self-originated link states\n"
5415 "Advertising Router link states\n"
5416 "Advertising Router (as an IP address)\n")
5419 u_short instance
= 0;
5422 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
5424 VTY_GET_INTEGER ("Instance", instance
, argv
[idx
]->arg
);
5425 ospf
= ospf_lookup_instance (instance
);
5428 ospf
= ospf_lookup();
5431 if (!ospf
|| !ospf
->oi_running
)
5434 return (show_ip_ospf_database_common(vty
, ospf
, idx
? 1 : 0, argc
, argv
));
5437 DEFUN (show_ip_ospf_instance_database_max
,
5438 show_ip_ospf_instance_database_max_cmd
,
5439 "show ip ospf (1-65535) database <max-age|self-originate>",
5442 "OSPF information\n"
5444 "Database summary\n"
5445 "LSAs in MaxAge list\n"
5446 "Self-originated link states\n")
5450 u_short instance
= 0;
5452 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
5454 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5457 return (show_ip_ospf_database_common(vty
, ospf
, 1, argc
, argv
));
5462 show_ip_ospf_database_type_adv_router_common (struct vty
*vty
, struct ospf
*ospf
,
5463 int arg_base
, int argc
, struct cmd_token
**argv
)
5467 struct in_addr adv_router
;
5470 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5473 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5474 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5476 if (argc
!= arg_base
+ 7)
5479 /* Set database type to show. */
5480 if (strncmp (argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5481 type
= OSPF_ROUTER_LSA
;
5482 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5483 type
= OSPF_NETWORK_LSA
;
5484 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5485 type
= OSPF_AS_NSSA_LSA
;
5486 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "s", 1) == 0)
5487 type
= OSPF_SUMMARY_LSA
;
5488 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5489 type
= OSPF_ASBR_SUMMARY_LSA
;
5490 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5491 type
= OSPF_AS_EXTERNAL_LSA
;
5492 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5493 type
= OSPF_OPAQUE_LINK_LSA
;
5494 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5495 type
= OSPF_OPAQUE_AREA_LSA
;
5496 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5497 type
= OSPF_OPAQUE_AS_LSA
;
5501 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
5502 if (strncmp (argv
[arg_base
+ 5]->text
, "s", 1) == 0)
5503 adv_router
= ospf
->router_id
;
5506 ret
= inet_aton (argv
[arg_base
+ 6]->arg
, &adv_router
);
5511 show_lsa_detail_adv_router (vty
, ospf
, type
, &adv_router
);
5516 DEFUN (show_ip_ospf_database_type_adv_router
,
5517 show_ip_ospf_database_type_adv_router_cmd
,
5518 "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>",
5521 "OSPF information\n"
5522 "Database summary\n"
5524 "Advertising Router link states\n"
5525 "Advertising Router (as an IP address)\n"
5526 "Self-originated link states\n")
5530 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5533 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 0, argc
, argv
));
5536 DEFUN (show_ip_ospf_instance_database_type_adv_router
,
5537 show_ip_ospf_instance_database_type_adv_router_cmd
,
5538 "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>",
5541 "OSPF information\n"
5543 "Database summary\n"
5545 "Advertising Router link states\n"
5546 "Advertising Router (as an IP address)\n"
5547 "Self-originated link states\n")
5551 u_short instance
= 0;
5553 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
5555 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5558 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 1, argc
, argv
));
5561 DEFUN (ip_ospf_authentication_args
,
5562 ip_ospf_authentication_args_addr_cmd
,
5563 "ip ospf authentication <null|message-digest> [A.B.C.D]",
5565 "OSPF interface commands\n"
5566 "Enable authentication on this interface\n"
5567 "Use null authentication\n"
5568 "Use message-digest authentication\n"
5569 "Address of interface\n")
5571 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5572 int idx_encryption
= 3;
5574 struct in_addr addr
;
5576 struct ospf_if_params
*params
;
5578 params
= IF_DEF_PARAMS (ifp
);
5582 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5585 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5590 params
= ospf_get_if_params (ifp
, addr
);
5591 ospf_if_update_params (ifp
, addr
);
5594 /* Handle null authentication */
5595 if ( argv
[idx_encryption
]->arg
[0] == 'n' )
5597 SET_IF_PARAM (params
, auth_type
);
5598 params
->auth_type
= OSPF_AUTH_NULL
;
5602 /* Handle message-digest authentication */
5603 if ( argv
[idx_encryption
]->arg
[0] == 'm' )
5605 SET_IF_PARAM (params
, auth_type
);
5606 params
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5610 vty_out (vty
, "You shouldn't get here!%s", VTY_NEWLINE
);
5614 DEFUN (ip_ospf_authentication
,
5615 ip_ospf_authentication_addr_cmd
,
5616 "ip ospf authentication [A.B.C.D]",
5618 "OSPF interface commands\n"
5619 "Enable authentication on this interface\n"
5620 "Address of interface")
5622 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5624 struct in_addr addr
;
5626 struct ospf_if_params
*params
;
5628 params
= IF_DEF_PARAMS (ifp
);
5632 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5635 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5640 params
= ospf_get_if_params (ifp
, addr
);
5641 ospf_if_update_params (ifp
, addr
);
5644 SET_IF_PARAM (params
, auth_type
);
5645 params
->auth_type
= OSPF_AUTH_SIMPLE
;
5650 DEFUN (no_ip_ospf_authentication_args
,
5651 no_ip_ospf_authentication_args_addr_cmd
,
5652 "no ip ospf authentication <null|message-digest> [A.B.C.D]",
5655 "OSPF interface commands\n"
5656 "Enable authentication on this interface\n"
5657 "Use null authentication\n"
5658 "Use message-digest authentication\n"
5659 "Address of interface")
5661 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5662 int idx_encryption
= 4;
5664 struct in_addr addr
;
5666 struct ospf_if_params
*params
;
5667 struct route_node
*rn
;
5670 params
= IF_DEF_PARAMS (ifp
);
5674 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5677 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5682 params
= ospf_lookup_if_params (ifp
, addr
);
5685 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
5688 params
->auth_type
= OSPF_AUTH_NOTSET
;
5689 UNSET_IF_PARAM (params
, auth_type
);
5690 if (params
!= IF_DEF_PARAMS (ifp
))
5692 ospf_free_if_params (ifp
, addr
);
5693 ospf_if_update_params (ifp
, addr
);
5698 if ( argv
[idx_encryption
]->arg
[0] == 'n' )
5700 auth_type
= OSPF_AUTH_NULL
;
5702 else if ( argv
[idx_encryption
]->arg
[0] == 'm' )
5704 auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5708 vty_out (vty
, "Unexpected input encountered%s", VTY_NEWLINE
);
5712 * Here we have a case where the user has entered
5713 * 'no ip ospf authentication (null | message_digest )'
5714 * we need to find if we have any ip addresses underneath it that
5715 * correspond to the associated type.
5717 if (params
->auth_type
== auth_type
)
5719 params
->auth_type
= OSPF_AUTH_NOTSET
;
5720 UNSET_IF_PARAM (params
, auth_type
);
5723 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
5725 if ((params
= rn
->info
))
5727 if (params
->auth_type
== auth_type
)
5729 params
->auth_type
= OSPF_AUTH_NOTSET
;
5730 UNSET_IF_PARAM (params
, auth_type
);
5731 if (params
!= IF_DEF_PARAMS (ifp
))
5733 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
5734 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
5744 DEFUN (no_ip_ospf_authentication
,
5745 no_ip_ospf_authentication_addr_cmd
,
5746 "no ip ospf authentication [A.B.C.D]",
5749 "OSPF interface commands\n"
5750 "Enable authentication on this interface\n"
5751 "Address of interface")
5753 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5755 struct in_addr addr
;
5757 struct ospf_if_params
*params
;
5758 struct route_node
*rn
;
5760 params
= IF_DEF_PARAMS (ifp
);
5764 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5767 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5772 params
= ospf_lookup_if_params (ifp
, addr
);
5775 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
5779 params
->auth_type
= OSPF_AUTH_NOTSET
;
5780 UNSET_IF_PARAM (params
, auth_type
);
5781 if (params
!= IF_DEF_PARAMS (ifp
))
5783 ospf_free_if_params (ifp
, addr
);
5784 ospf_if_update_params (ifp
, addr
);
5790 * When a user enters 'no ip ospf authentication'
5791 * We should remove all authentication types from
5794 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
5795 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
5796 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
5798 params
->auth_type
= OSPF_AUTH_NOTSET
;
5799 UNSET_IF_PARAM (params
, auth_type
);
5802 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
5804 if ((params
= rn
->info
))
5807 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
5808 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
5809 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
5811 params
->auth_type
= OSPF_AUTH_NOTSET
;
5812 UNSET_IF_PARAM (params
, auth_type
);
5813 if (params
!= IF_DEF_PARAMS (ifp
))
5815 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
5816 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
5827 DEFUN (ip_ospf_authentication_key
,
5828 ip_ospf_authentication_key_addr_cmd
,
5829 "ip ospf authentication-key AUTH_KEY [A.B.C.D]",
5831 "OSPF interface commands\n"
5832 "Authentication password (key)\n"
5833 "The OSPF password (key)\n"
5834 "Address of interface")
5836 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5838 struct in_addr addr
;
5839 struct ospf_if_params
*params
;
5841 params
= IF_DEF_PARAMS (ifp
);
5843 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
5845 if (!inet_aton(argv
[idx
]->arg
, &addr
))
5847 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5852 params
= ospf_get_if_params (ifp
, addr
);
5853 ospf_if_update_params (ifp
, addr
);
5856 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
5857 strncpy ((char *) params
->auth_simple
, argv
[3]->arg
, OSPF_AUTH_SIMPLE_SIZE
);
5858 SET_IF_PARAM (params
, auth_simple
);
5863 DEFUN_HIDDEN (ospf_authentication_key
,
5864 ospf_authentication_key_cmd
,
5865 "ospf authentication-key AUTH_KEY [A.B.C.D]",
5866 "OSPF interface commands\n"
5867 "Authentication password (key)\n"
5868 "The OSPF password (key)\n"
5869 "Address of interface\n")
5871 return ip_ospf_authentication_key (self
, vty
, argc
, argv
);
5874 DEFUN (no_ip_ospf_authentication_key
,
5875 no_ip_ospf_authentication_key_authkey_addr_cmd
,
5876 "no ip ospf authentication-key [AUTH_KEY [A.B.C.D]]",
5879 "OSPF interface commands\n"
5880 "Authentication password (key)\n"
5881 "The OSPF password (key)")
5883 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5885 struct in_addr addr
;
5886 struct ospf_if_params
*params
;
5887 params
= IF_DEF_PARAMS (ifp
);
5889 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
5891 if (!inet_aton(argv
[idx
]->arg
, &addr
))
5893 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5898 params
= ospf_lookup_if_params (ifp
, addr
);
5903 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
);
5904 UNSET_IF_PARAM (params
, auth_simple
);
5906 if (params
!= IF_DEF_PARAMS (ifp
))
5908 ospf_free_if_params (ifp
, addr
);
5909 ospf_if_update_params (ifp
, addr
);
5915 DEFUN_HIDDEN (no_ospf_authentication_key
,
5916 no_ospf_authentication_key_authkey_addr_cmd
,
5917 "no ospf authentication-key [AUTH_KEY [A.B.C.D]]",
5919 "OSPF interface commands\n"
5920 "Authentication password (key)\n"
5921 "The OSPF password (key)")
5923 return no_ip_ospf_authentication_key (self
, vty
, argc
, argv
);
5926 DEFUN (ip_ospf_message_digest_key
,
5927 ip_ospf_message_digest_key_cmd
,
5928 "ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
5930 "OSPF interface commands\n"
5931 "Message digest authentication password (key)\n"
5933 "Use MD5 algorithm\n"
5934 "The OSPF password (key)\n"
5935 "Address of interface\n")
5937 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5938 struct crypt_key
*ck
;
5940 struct in_addr addr
;
5941 struct ospf_if_params
*params
;
5943 params
= IF_DEF_PARAMS (ifp
);
5946 argv_find (argv
, argc
, "(1-255)", &idx
);
5947 char *keyid
= argv
[idx
]->arg
;
5948 argv_find (argv
, argc
, "KEY", &idx
);
5949 char *cryptkey
= argv
[idx
]->arg
;
5951 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
5953 if (!inet_aton(argv
[idx
]->arg
, &addr
))
5955 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5960 params
= ospf_get_if_params (ifp
, addr
);
5961 ospf_if_update_params (ifp
, addr
);
5964 key_id
= strtol (keyid
, NULL
, 10);
5965 if (ospf_crypt_key_lookup (params
->auth_crypt
, key_id
) != NULL
)
5967 vty_out (vty
, "OSPF: Key %d already exists%s", key_id
, VTY_NEWLINE
);
5971 ck
= ospf_crypt_key_new ();
5972 ck
->key_id
= (u_char
) key_id
;
5973 memset (ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
5974 strncpy ((char *) ck
->auth_key
, cryptkey
, OSPF_AUTH_MD5_SIZE
);
5976 ospf_crypt_key_add (params
->auth_crypt
, ck
);
5977 SET_IF_PARAM (params
, auth_crypt
);
5982 DEFUN_HIDDEN (ospf_message_digest_key
,
5983 ospf_message_digest_key_cmd
,
5984 "ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
5985 "OSPF interface commands\n"
5986 "Message digest authentication password (key)\n"
5988 "Use MD5 algorithm\n"
5989 "The OSPF password (key)\n"
5990 "Address of interface\n")
5992 return ip_ospf_message_digest_key (self
, vty
, argc
, argv
);
5995 DEFUN (no_ip_ospf_message_digest_key
,
5996 no_ip_ospf_message_digest_key_cmd
,
5997 "no ip ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
6000 "OSPF interface commands\n"
6001 "Message digest authentication password (key)\n"
6003 "Use MD5 algorithm\n"
6004 "The OSPF password (key)\n"
6005 "Address of interface\n")
6007 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6009 struct crypt_key
*ck
;
6011 struct in_addr addr
;
6012 struct ospf_if_params
*params
;
6013 params
= IF_DEF_PARAMS (ifp
);
6015 argv_find (argv
, argc
, "(1-255)", &idx
);
6016 char *keyid
= argv
[idx
]->arg
;
6018 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6020 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6022 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6027 params
= ospf_lookup_if_params (ifp
, addr
);
6032 key_id
= strtol (keyid
, NULL
, 10);
6033 ck
= ospf_crypt_key_lookup (params
->auth_crypt
, key_id
);
6036 vty_out (vty
, "OSPF: Key %d does not exist%s", key_id
, VTY_NEWLINE
);
6040 ospf_crypt_key_delete (params
->auth_crypt
, key_id
);
6042 if (params
!= IF_DEF_PARAMS (ifp
))
6044 ospf_free_if_params (ifp
, addr
);
6045 ospf_if_update_params (ifp
, addr
);
6051 DEFUN_HIDDEN (no_ospf_message_digest_key
,
6052 no_ospf_message_digest_key_cmd
,
6053 "no ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
6055 "OSPF interface commands\n"
6056 "Message digest authentication password (key)\n"
6058 "Address of interface")
6060 return no_ip_ospf_message_digest_key (self
, vty
, argc
, argv
);
6063 DEFUN (ip_ospf_cost
,
6065 "ip ospf cost (1-65535) [A.B.C.D]",
6067 "OSPF interface commands\n"
6070 "Address of interface\n")
6072 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6075 struct in_addr addr
;
6076 struct ospf_if_params
*params
;
6077 params
= IF_DEF_PARAMS (ifp
);
6080 char *coststr
= NULL
, *ifaddr
= NULL
;
6081 coststr
= argv_find (argv
, argc
, "(1-65535)", &idx
) ? argv
[idx
]->arg
: NULL
;
6082 ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6084 cost
= strtol (coststr
, NULL
, 10);
6088 if(!inet_aton(ifaddr
, &addr
))
6090 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6095 params
= ospf_get_if_params (ifp
, addr
);
6096 ospf_if_update_params (ifp
, addr
);
6099 SET_IF_PARAM (params
, output_cost_cmd
);
6100 params
->output_cost_cmd
= cost
;
6102 ospf_if_recalculate_output_cost (ifp
);
6107 DEFUN_HIDDEN (ospf_cost
,
6109 "ospf cost (1-65535) [A.B.C.D]",
6110 "OSPF interface commands\n"
6113 "Address of interface\n")
6115 return ip_ospf_cost (self
, vty
, argc
, argv
);
6118 DEFUN (no_ip_ospf_cost
,
6119 no_ip_ospf_cost_cmd
,
6120 "no ip ospf cost [(1-65535)] [A.B.C.D]",
6122 "OSPF interface commands\n"
6124 "Address of interface")
6126 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6128 struct in_addr addr
;
6129 struct ospf_if_params
*params
;
6131 params
= IF_DEF_PARAMS (ifp
);
6134 char *ifaddr
= NULL
;
6135 ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6137 /* According to the semantics we are mimicking "no ip ospf cost N" is
6138 * always treated as "no ip ospf cost" regardless of the actual value
6139 * of N already configured for the interface. Thus ignore cost. */
6143 if (!inet_aton(ifaddr
, &addr
))
6145 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6150 params
= ospf_lookup_if_params (ifp
, addr
);
6155 UNSET_IF_PARAM (params
, output_cost_cmd
);
6157 if (params
!= IF_DEF_PARAMS (ifp
))
6159 ospf_free_if_params (ifp
, addr
);
6160 ospf_if_update_params (ifp
, addr
);
6163 ospf_if_recalculate_output_cost (ifp
);
6168 DEFUN_HIDDEN (no_ospf_cost
,
6170 "no ospf cost [(1-65535)] [A.B.C.D]",
6172 "OSPF interface commands\n"
6175 "Address of interface\n")
6177 return no_ip_ospf_cost (self
, vty
, argc
, argv
);
6181 ospf_nbr_timer_update (struct ospf_interface
*oi
)
6183 struct route_node
*rn
;
6184 struct ospf_neighbor
*nbr
;
6186 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
6187 if ((nbr
= rn
->info
))
6189 nbr
->v_inactivity
= OSPF_IF_PARAM (oi
, v_wait
);
6190 nbr
->v_db_desc
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6191 nbr
->v_ls_req
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6192 nbr
->v_ls_upd
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6197 ospf_vty_dead_interval_set (struct vty
*vty
, const char *interval_str
,
6198 const char *nbr_str
,
6199 const char *fast_hello_str
)
6201 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6204 struct in_addr addr
;
6206 struct ospf_if_params
*params
;
6207 struct ospf_interface
*oi
;
6208 struct route_node
*rn
;
6210 params
= IF_DEF_PARAMS (ifp
);
6214 ret
= inet_aton(nbr_str
, &addr
);
6217 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6222 params
= ospf_get_if_params (ifp
, addr
);
6223 ospf_if_update_params (ifp
, addr
);
6228 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds
, interval_str
,
6231 /* reset fast_hello too, just to be sure */
6232 UNSET_IF_PARAM (params
, fast_hello
);
6233 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6235 else if (fast_hello_str
)
6237 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult
, fast_hello_str
,
6239 /* 1s dead-interval with sub-second hellos desired */
6240 seconds
= OSPF_ROUTER_DEAD_INTERVAL_MINIMAL
;
6241 SET_IF_PARAM (params
, fast_hello
);
6242 params
->fast_hello
= hellomult
;
6246 vty_out (vty
, "Please specify dead-interval or hello-multiplier%s",
6251 SET_IF_PARAM (params
, v_wait
);
6252 params
->v_wait
= seconds
;
6254 /* Update timer values in neighbor structure. */
6258 if ((ospf
= ospf_lookup()))
6260 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
6262 ospf_nbr_timer_update (oi
);
6267 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6268 if ((oi
= rn
->info
))
6269 ospf_nbr_timer_update (oi
);
6275 DEFUN (ip_ospf_dead_interval
,
6276 ip_ospf_dead_interval_cmd
,
6277 "ip ospf dead-interval (1-65535) [A.B.C.D]",
6279 "OSPF interface commands\n"
6280 "Interval time after which a neighbor is declared down\n"
6282 "Address of interface\n")
6285 char *interval
= argv_find (argv
, argc
, "(1-65535)", &idx
) ? argv
[idx
]->arg
: NULL
;
6286 char *ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6287 return ospf_vty_dead_interval_set (vty
, interval
, ifaddr
, NULL
);
6291 DEFUN_HIDDEN (ospf_dead_interval
,
6292 ospf_dead_interval_cmd
,
6293 "ospf dead-interval (1-65535) [A.B.C.D]",
6294 "OSPF interface commands\n"
6295 "Interval time after which a neighbor is declared down\n"
6297 "Address of interface\n")
6299 return ip_ospf_dead_interval (self
, vty
, argc
, argv
);
6302 DEFUN (ip_ospf_dead_interval_minimal
,
6303 ip_ospf_dead_interval_minimal_addr_cmd
,
6304 "ip ospf dead-interval minimal hello-multiplier (1-10) [A.B.C.D]",
6306 "OSPF interface commands\n"
6307 "Interval time after which a neighbor is declared down\n"
6308 "Minimal 1s dead-interval with fast sub-second hellos\n"
6309 "Hello multiplier factor\n"
6310 "Number of Hellos to send each second\n"
6311 "Address of interface\n")
6316 return ospf_vty_dead_interval_set (vty
, NULL
, argv
[idx_ipv4
]->arg
, argv
[idx_number
]->arg
);
6318 return ospf_vty_dead_interval_set (vty
, NULL
, NULL
, argv
[idx_number
]->arg
);
6321 DEFUN (no_ip_ospf_dead_interval
,
6322 no_ip_ospf_dead_interval_cmd
,
6323 "no ip ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6326 "OSPF interface commands\n"
6327 "Interval time after which a neighbor is declared down\n"
6329 "Address of interface")
6331 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6332 int idx_ipv4
= argc
- 1;
6333 struct in_addr addr
= { .s_addr
= 0L};
6335 struct ospf_if_params
*params
;
6336 struct ospf_interface
*oi
;
6337 struct route_node
*rn
;
6339 params
= IF_DEF_PARAMS (ifp
);
6341 if (argv
[idx_ipv4
]->type
== IPV4_TKN
)
6343 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6346 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6351 params
= ospf_lookup_if_params (ifp
, addr
);
6356 UNSET_IF_PARAM (params
, v_wait
);
6357 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
6359 UNSET_IF_PARAM (params
, fast_hello
);
6360 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6362 if (params
!= IF_DEF_PARAMS (ifp
))
6364 ospf_free_if_params (ifp
, addr
);
6365 ospf_if_update_params (ifp
, addr
);
6368 /* Update timer values in neighbor structure. */
6373 if ((ospf
= ospf_lookup()))
6375 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
6377 ospf_nbr_timer_update (oi
);
6382 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6383 if ((oi
= rn
->info
))
6384 ospf_nbr_timer_update (oi
);
6390 DEFUN_HIDDEN (no_ospf_dead_interval
,
6391 no_ospf_dead_interval_cmd
,
6392 "no ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6394 "OSPF interface commands\n"
6395 "Interval time after which a neighbor is declared down\n"
6397 "Address of interface")
6399 return no_ip_ospf_dead_interval (self
, vty
, argc
, argv
);
6402 DEFUN (ip_ospf_hello_interval
,
6403 ip_ospf_hello_interval_cmd
,
6404 "ip ospf hello-interval (1-65535) [A.B.C.D]",
6406 "OSPF interface commands\n"
6407 "Time between HELLO packets\n"
6409 "Address of interface\n")
6411 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6413 struct in_addr addr
;
6414 struct ospf_if_params
*params
;
6415 params
= IF_DEF_PARAMS (ifp
);
6416 u_int32_t seconds
= 0;
6418 argv_find (argv
, argc
, "(1-65535)", &idx
);
6419 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
6421 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6423 if(!inet_aton(argv
[idx
]->arg
, &addr
))
6425 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6430 params
= ospf_get_if_params (ifp
, addr
);
6431 ospf_if_update_params (ifp
, addr
);
6434 SET_IF_PARAM (params
, v_hello
);
6435 params
->v_hello
= seconds
;
6440 DEFUN_HIDDEN (ospf_hello_interval
,
6441 ospf_hello_interval_cmd
,
6442 "ospf hello-interval (1-65535) [A.B.C.D]",
6443 "OSPF interface commands\n"
6444 "Time between HELLO packets\n"
6446 "Address of interface\n")
6448 return ip_ospf_hello_interval (self
, vty
, argc
, argv
);
6451 DEFUN (no_ip_ospf_hello_interval
,
6452 no_ip_ospf_hello_interval_cmd
,
6453 "no ip ospf hello-interval [(1-65535) [A.B.C.D]]",
6456 "OSPF interface commands\n"
6457 "Time between HELLO packets\n" // ignored
6459 "Address of interface\n")
6461 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6463 struct in_addr addr
;
6464 struct ospf_if_params
*params
;
6466 params
= IF_DEF_PARAMS (ifp
);
6468 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6470 if(!inet_aton(argv
[idx
]->arg
, &addr
))
6472 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6477 params
= ospf_lookup_if_params (ifp
, addr
);
6482 UNSET_IF_PARAM (params
, v_hello
);
6483 params
->v_hello
= OSPF_HELLO_INTERVAL_DEFAULT
;
6485 if (params
!= IF_DEF_PARAMS (ifp
))
6487 ospf_free_if_params (ifp
, addr
);
6488 ospf_if_update_params (ifp
, addr
);
6494 DEFUN_HIDDEN (no_ospf_hello_interval
,
6495 no_ospf_hello_interval_cmd
,
6496 "no ospf hello-interval [(1-65535) [A.B.C.D]]",
6498 "OSPF interface commands\n"
6499 "Time between HELLO packets\n" // ignored
6501 "Address of interface\n")
6503 return no_ip_ospf_hello_interval (self
, vty
, argc
, argv
);
6506 DEFUN (ip_ospf_network
,
6507 ip_ospf_network_cmd
,
6508 "ip ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
6510 "OSPF interface commands\n"
6512 "Specify OSPF broadcast multi-access network\n"
6513 "Specify OSPF NBMA network\n"
6514 "Specify OSPF point-to-multipoint network\n"
6515 "Specify OSPF point-to-point network\n")
6517 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6519 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
6520 struct route_node
*rn
;
6522 if (old_type
== OSPF_IFTYPE_LOOPBACK
)
6524 vty_out (vty
, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE
);
6528 if (argv_find (argv
, argc
, "broadcast", &idx
))
6529 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_BROADCAST
;
6530 else if (argv_find (argv
, argc
, "non-broadcast", &idx
))
6531 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_NBMA
;
6532 else if (argv_find (argv
, argc
, "point-to-multipoint", &idx
))
6533 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOMULTIPOINT
;
6534 else if (argv_find (argv
, argc
, "point-to-point", &idx
))
6535 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOPOINT
;
6537 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
6540 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), type
);
6542 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6544 struct ospf_interface
*oi
= rn
->info
;
6549 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
6551 if (oi
->state
> ISM_Down
)
6553 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
6554 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
6561 DEFUN_HIDDEN (ospf_network
,
6563 "ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
6564 "OSPF interface commands\n"
6566 "Specify OSPF broadcast multi-access network\n"
6567 "Specify OSPF NBMA network\n"
6568 "Specify OSPF point-to-multipoint network\n"
6569 "Specify OSPF point-to-point network\n")
6571 return ip_ospf_network (self
, vty
, argc
, argv
);
6574 DEFUN (no_ip_ospf_network
,
6575 no_ip_ospf_network_cmd
,
6576 "no ip ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
6579 "OSPF interface commands\n"
6581 "Specify OSPF broadcast multi-access network\n"
6582 "Specify OSPF NBMA network\n"
6583 "Specify OSPF point-to-multipoint network\n"
6584 "Specify OSPF point-to-point network\n")
6586 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6587 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
6588 struct route_node
*rn
;
6590 IF_DEF_PARAMS (ifp
)->type
= ospf_default_iftype(ifp
);
6592 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
6595 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6597 struct ospf_interface
*oi
= rn
->info
;
6602 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
6604 if (oi
->state
> ISM_Down
)
6606 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
6607 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
6614 DEFUN_HIDDEN (no_ospf_network
,
6615 no_ospf_network_cmd
,
6616 "no ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
6618 "OSPF interface commands\n"
6620 "Specify OSPF broadcast multi-access network\n"
6621 "Specify OSPF NBMA network\n"
6622 "Specify OSPF point-to-multipoint network\n"
6623 "Specify OSPF point-to-point network\n")
6625 return no_ip_ospf_network (self
, vty
, argc
, argv
);
6628 DEFUN (ip_ospf_priority
,
6629 ip_ospf_priority_cmd
,
6630 "ip ospf priority (0-255) [A.B.C.D]",
6632 "OSPF interface commands\n"
6635 "Address of interface")
6637 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6640 struct route_node
*rn
;
6641 struct in_addr addr
;
6642 struct ospf_if_params
*params
;
6643 params
= IF_DEF_PARAMS (ifp
);
6645 argv_find (argv
, argc
, "(0-255)", &idx
);
6646 priority
= strtol (argv
[idx
]->arg
, NULL
, 10);
6648 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6650 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6652 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6657 params
= ospf_get_if_params (ifp
, addr
);
6658 ospf_if_update_params (ifp
, addr
);
6661 SET_IF_PARAM (params
, priority
);
6662 params
->priority
= priority
;
6664 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6666 struct ospf_interface
*oi
= rn
->info
;
6671 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
6673 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
6674 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
6681 DEFUN_HIDDEN (ospf_priority
,
6683 "ospf priority (0-255) [A.B.C.D]",
6684 "OSPF interface commands\n"
6687 "Address of interface")
6689 return ip_ospf_priority (self
, vty
, argc
, argv
);
6692 DEFUN (no_ip_ospf_priority
,
6693 no_ip_ospf_priority_cmd
,
6694 "no ip ospf priority [(0-255) [A.B.C.D]]",
6697 "OSPF interface commands\n"
6698 "Router priority\n" // ignored
6700 "Address of interface")
6702 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6704 struct route_node
*rn
;
6705 struct in_addr addr
;
6706 struct ospf_if_params
*params
;
6708 params
= IF_DEF_PARAMS (ifp
);
6710 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6712 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6714 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6719 params
= ospf_lookup_if_params (ifp
, addr
);
6724 UNSET_IF_PARAM (params
, priority
);
6725 params
->priority
= OSPF_ROUTER_PRIORITY_DEFAULT
;
6727 if (params
!= IF_DEF_PARAMS (ifp
))
6729 ospf_free_if_params (ifp
, addr
);
6730 ospf_if_update_params (ifp
, addr
);
6733 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6735 struct ospf_interface
*oi
= rn
->info
;
6740 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
6742 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
6743 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
6750 DEFUN_HIDDEN (no_ospf_priority
,
6751 no_ospf_priority_cmd
,
6752 "no ospf priority [(0-255) [A.B.C.D]]",
6754 "OSPF interface commands\n"
6757 "Address of interface")
6759 return no_ip_ospf_priority (self
, vty
, argc
, argv
);
6762 DEFUN (ip_ospf_retransmit_interval
,
6763 ip_ospf_retransmit_interval_addr_cmd
,
6764 "ip ospf retransmit-interval (3-65535) [A.B.C.D]",
6766 "OSPF interface commands\n"
6767 "Time between retransmitting lost link state advertisements\n"
6769 "Address of interface")
6771 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6774 struct in_addr addr
;
6775 struct ospf_if_params
*params
;
6776 params
= IF_DEF_PARAMS (ifp
);
6778 argv_find (argv
, argc
, "(3-65535)", &idx
);
6779 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
6781 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6783 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6785 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6790 params
= ospf_get_if_params (ifp
, addr
);
6791 ospf_if_update_params (ifp
, addr
);
6794 SET_IF_PARAM (params
, retransmit_interval
);
6795 params
->retransmit_interval
= seconds
;
6800 DEFUN_HIDDEN (ospf_retransmit_interval
,
6801 ospf_retransmit_interval_cmd
,
6802 "ospf retransmit-interval (3-65535) [A.B.C.D]",
6803 "OSPF interface commands\n"
6804 "Time between retransmitting lost link state advertisements\n"
6806 "Address of interface")
6808 return ip_ospf_retransmit_interval (self
, vty
, argc
, argv
);
6811 DEFUN (no_ip_ospf_retransmit_interval
,
6812 no_ip_ospf_retransmit_interval_addr_cmd
,
6813 "no ip ospf retransmit-interval [(3-65535)] [A.B.C.D]",
6816 "OSPF interface commands\n"
6817 "Time between retransmitting lost link state advertisements\n"
6819 "Address of interface\n")
6821 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6823 struct in_addr addr
;
6824 struct ospf_if_params
*params
;
6826 params
= IF_DEF_PARAMS (ifp
);
6828 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6830 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6832 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6837 params
= ospf_lookup_if_params (ifp
, addr
);
6842 UNSET_IF_PARAM (params
, retransmit_interval
);
6843 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
6845 if (params
!= IF_DEF_PARAMS (ifp
))
6847 ospf_free_if_params (ifp
, addr
);
6848 ospf_if_update_params (ifp
, addr
);
6854 DEFUN_HIDDEN (no_ospf_retransmit_interval
,
6855 no_ospf_retransmit_interval_cmd
,
6856 "no ospf retransmit-interval [(3-65535)] [A.B.C.D]",
6858 "OSPF interface commands\n"
6859 "Time between retransmitting lost link state advertisements\n"
6861 "Address of interface\n")
6863 return no_ip_ospf_retransmit_interval (self
, vty
, argc
, argv
);
6866 DEFUN (ip_ospf_transmit_delay
,
6867 ip_ospf_transmit_delay_addr_cmd
,
6868 "ip ospf transmit-delay (1-65535) [A.B.C.D]",
6870 "OSPF interface commands\n"
6871 "Link state transmit delay\n"
6873 "Address of interface")
6875 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6878 struct in_addr addr
;
6879 struct ospf_if_params
*params
;
6881 params
= IF_DEF_PARAMS (ifp
);
6882 argv_find (argv
, argc
, "(1-65535)", &idx
);
6883 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
6885 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6887 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6889 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6894 params
= ospf_get_if_params (ifp
, addr
);
6895 ospf_if_update_params (ifp
, addr
);
6898 SET_IF_PARAM (params
, transmit_delay
);
6899 params
->transmit_delay
= seconds
;
6904 DEFUN_HIDDEN (ospf_transmit_delay
,
6905 ospf_transmit_delay_cmd
,
6906 "ospf transmit-delay (1-65535) [A.B.C.D]",
6907 "OSPF interface commands\n"
6908 "Link state transmit delay\n"
6910 "Address of interface")
6912 return ip_ospf_transmit_delay (self
, vty
, argc
, argv
);
6915 DEFUN (no_ip_ospf_transmit_delay
,
6916 no_ip_ospf_transmit_delay_addr_cmd
,
6917 "no ip ospf transmit-delay [(1-65535)] [A.B.C.D]",
6920 "OSPF interface commands\n"
6921 "Link state transmit delay\n"
6922 "Address of interface")
6924 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6926 struct in_addr addr
;
6927 struct ospf_if_params
*params
;
6929 params
= IF_DEF_PARAMS (ifp
);
6931 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6933 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6935 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6940 params
= ospf_lookup_if_params (ifp
, addr
);
6945 UNSET_IF_PARAM (params
, transmit_delay
);
6946 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
6948 if (params
!= IF_DEF_PARAMS (ifp
))
6950 ospf_free_if_params (ifp
, addr
);
6951 ospf_if_update_params (ifp
, addr
);
6958 DEFUN_HIDDEN (no_ospf_transmit_delay
,
6959 no_ospf_transmit_delay_cmd
,
6960 "no ospf transmit-delay",
6962 "OSPF interface commands\n"
6963 "Link state transmit delay\n")
6965 return no_ip_ospf_transmit_delay (self
, vty
, argc
, argv
);
6968 DEFUN (ip_ospf_area
,
6970 "ip ospf [(1-65535)] area <A.B.C.D|(0-4294967295)>",
6972 "OSPF interface commands\n"
6974 "Enable OSPF on this interface\n"
6975 "OSPF area ID in IP address format\n"
6976 "OSPF area ID as a decimal value\n")
6978 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6981 struct in_addr area_id
;
6983 struct ospf_if_params
*params
;
6984 struct route_node
*rn
;
6985 u_short instance
= 0;
6987 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
6988 instance
= strtol (argv
[idx
]->arg
, NULL
, 10);
6989 char *areaid
= argv
[argc
- 1]->arg
;
6991 ospf
= ospf_lookup_instance (instance
);
6994 params
= IF_DEF_PARAMS (ifp
);
6995 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
6997 ospf_interface_unset (ifp
);
6998 ospf
= ospf_lookup();
6999 ospf
->if_ospf_cli_count
--;
7004 ret
= str2area_id (areaid
, &area_id
, &format
);
7007 vty_out (vty
, "Please specify area by A.B.C.D|<0-4294967295>%s",
7011 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
7013 vty_out (vty
, "Cannot enable OSPF on a virtual link.%s", VTY_NEWLINE
);
7017 params
= IF_DEF_PARAMS (ifp
);
7018 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7021 "Must remove previous area config before changing ospf area %s",
7026 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
7028 if (rn
->info
!= NULL
)
7030 vty_out (vty
, "Please remove all network commands first.%s", VTY_NEWLINE
);
7035 /* enable ospf on this interface with area_id */
7036 ospf_interface_set (ifp
, area_id
);
7037 ospf
->if_ospf_cli_count
++;
7042 DEFUN (no_ip_ospf_area
,
7043 no_ip_ospf_area_cmd
,
7044 "no ip ospf [(1-65535)] area [<A.B.C.D|(0-4294967295)>]",
7047 "OSPF interface commands\n"
7049 "Disable OSPF on this interface\n"
7050 "OSPF area ID in IP address format\n"
7051 "OSPF area ID as a decimal value\n")
7053 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7056 struct ospf_if_params
*params
;
7057 u_short instance
= 0;
7059 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
7060 instance
= strtol (argv
[idx
]->arg
, NULL
, 10);
7062 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
7065 params
= IF_DEF_PARAMS (ifp
);
7066 if (!OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7068 vty_out (vty
, "Can't find specified interface area configuration.%s", VTY_NEWLINE
);
7072 ospf_interface_unset (ifp
);
7073 ospf
->if_ospf_cli_count
--;
7077 DEFUN (ospf_redistribute_source
,
7078 ospf_redistribute_source_cmd
,
7079 "redistribute " FRR_REDIST_STR_OSPFD
" [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7081 FRR_REDIST_HELP_STR_OSPFD
7082 "Metric for redistributed routes\n"
7083 "OSPF default metric\n"
7084 "OSPF exterior metric type for redistributed routes\n"
7085 "Set OSPF External Type 1 metrics\n"
7086 "Set OSPF External Type 2 metrics\n"
7087 "Route map reference\n"
7088 "Pointer to route-map entries\n")
7090 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7091 int idx_protocol
= 1;
7095 struct ospf_redist
*red
;
7101 /* Get distribute source. */
7102 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
7106 red
= ospf_redist_add(ospf
, source
, 0);
7108 /* Get metric value. */
7109 if (argv_find (argv
, argc
, "(0-16777214)", &idx
)) {
7110 if (!str2metric (argv
[idx
]->arg
, &metric
))
7113 /* Get metric type. */
7114 else if (argv_find (argv
, argc
, "(1-2)", &idx
)) {
7115 if (!str2metric_type (argv
[idx
]->arg
, &type
))
7119 else if (argv_find (argv
, argc
, "WORD", &idx
)) {
7120 ospf_routemap_set (red
, argv
[idx
]->arg
);
7123 ospf_routemap_unset (red
);
7125 return ospf_redistribute_set (ospf
, source
, 0, type
, metric
);
7128 DEFUN (no_ospf_redistribute_source
,
7129 no_ospf_redistribute_source_cmd
,
7130 "no redistribute " FRR_REDIST_STR_OSPFD
" [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7133 FRR_REDIST_HELP_STR_OSPFD
7134 "Metric for redistributed routes\n"
7135 "OSPF default metric\n"
7136 "OSPF exterior metric type for redistributed routes\n"
7137 "Set OSPF External Type 1 metrics\n"
7138 "Set OSPF External Type 2 metrics\n"
7139 "Route map reference\n"
7140 "Pointer to route-map entries\n")
7142 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7143 int idx_protocol
= 2;
7145 struct ospf_redist
*red
;
7147 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
7151 red
= ospf_redist_lookup(ospf
, source
, 0);
7155 ospf_routemap_unset (red
);
7156 return ospf_redistribute_unset (ospf
, source
, 0);
7159 DEFUN (ospf_redistribute_instance_source
,
7160 ospf_redistribute_instance_source_cmd
,
7161 "redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
7163 "Open Shortest Path First\n"
7164 "Non-main Kernel Routing Table\n"
7165 "Instance ID/Table ID\n"
7166 "Metric for redistributed routes\n"
7167 "OSPF default metric\n"
7168 "OSPF exterior metric type for redistributed routes\n"
7169 "Set OSPF External Type 1 metrics\n"
7170 "Set OSPF External Type 2 metrics\n"
7171 "Route map reference\n"
7172 "Pointer to route-map entries\n")
7174 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7175 int idx_ospf_table
= 1;
7182 struct ospf_redist
*red
;
7187 source
= proto_redistnum (AFI_IP
, argv
[idx_ospf_table
]->text
);
7189 VTY_GET_INTEGER ("Instance ID", instance
, argv
[idx_number
]->arg
);
7194 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
7196 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
7201 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
7203 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
7208 /* Get metric value. */
7209 if (argv_find (argv
, argc
, "metric", &idx
))
7210 if (!str2metric (argv
[idx
+1]->arg
, &metric
))
7214 /* Get metric type. */
7215 if (argv_find (argv
, argc
, "metric-type", &idx
))
7216 if (!str2metric_type (argv
[idx
+1]->arg
, &type
))
7219 red
= ospf_redist_add(ospf
, source
, instance
);
7222 if (argv_find (argv
, argc
, "route-map", &idx
))
7223 ospf_routemap_set (red
, argv
[idx
+1]->arg
);
7225 ospf_routemap_unset (red
);
7227 return ospf_redistribute_set (ospf
, source
, instance
, type
, metric
);
7230 DEFUN (no_ospf_redistribute_instance_source
,
7231 no_ospf_redistribute_instance_source_cmd
,
7232 "no redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
7235 "Open Shortest Path First\n"
7236 "Non-main Kernel Routing Table\n"
7237 "Instance ID/Table Id\n"
7238 "Metric for redistributed routes\n"
7239 "OSPF default metric\n"
7240 "OSPF exterior metric type for redistributed routes\n"
7241 "Set OSPF External Type 1 metrics\n"
7242 "Set OSPF External Type 2 metrics\n"
7243 "Route map reference\n"
7244 "Pointer to route-map entries\n")
7246 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7247 int idx_ospf_table
= 2;
7250 struct ospf_redist
*red
;
7253 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
7254 source
= ZEBRA_ROUTE_OSPF
;
7256 source
= ZEBRA_ROUTE_TABLE
;
7258 VTY_GET_INTEGER ("Instance ID", instance
, argv
[idx_number
]->arg
);
7260 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
7262 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
7267 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
7269 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
7274 red
= ospf_redist_lookup(ospf
, source
, instance
);
7278 ospf_routemap_unset (red
);
7279 return ospf_redistribute_unset (ospf
, source
, instance
);
7282 DEFUN (ospf_distribute_list_out
,
7283 ospf_distribute_list_out_cmd
,
7284 "distribute-list WORD out " FRR_REDIST_STR_OSPFD
,
7285 "Filter networks in routing updates\n"
7286 "Access-list name\n"
7288 FRR_REDIST_HELP_STR_OSPFD
)
7290 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7294 char *proto
= argv
[argc
- 1]->text
;
7296 /* Get distribute source. */
7297 source
= proto_redistnum(AFI_IP
, proto
);
7301 return ospf_distribute_list_out_set (ospf
, source
, argv
[idx_word
]->arg
);
7304 DEFUN (no_ospf_distribute_list_out
,
7305 no_ospf_distribute_list_out_cmd
,
7306 "no distribute-list WORD out " FRR_REDIST_STR_OSPFD
,
7308 "Filter networks in routing updates\n"
7309 "Access-list name\n"
7311 FRR_REDIST_HELP_STR_OSPFD
)
7313 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7317 char *proto
= argv
[argc
- 1]->text
;
7318 source
= proto_redistnum(AFI_IP
, proto
);
7322 return ospf_distribute_list_out_unset (ospf
, source
, argv
[idx_word
]->arg
);
7325 /* Default information originate. */
7326 DEFUN (ospf_default_information_originate
,
7327 ospf_default_information_originate_cmd
,
7328 "default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7329 "Control distribution of default information\n"
7330 "Distribute a default route\n"
7331 "Always advertise default route\n"
7332 "OSPF default metric\n"
7334 "OSPF metric type for default routes\n"
7335 "Set OSPF External Type 1 metrics\n"
7336 "Set OSPF External Type 2 metrics\n"
7337 "Route map reference\n"
7338 "Pointer to route-map entries\n")
7340 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7341 int default_originate
= DEFAULT_ORIGINATE_ZEBRA
;
7344 struct ospf_redist
*red
;
7347 red
= ospf_redist_add(ospf
, DEFAULT_ROUTE
, 0);
7349 /* Check whether "always" was specified */
7350 if (argv_find (argv
, argc
, "always", &idx
))
7351 default_originate
= DEFAULT_ORIGINATE_ALWAYS
;
7352 /* Get metric value */
7353 else if (argv_find (argv
, argc
, "(0-16777214)", &idx
)) {
7354 if (!str2metric (argv
[idx
]->arg
, &metric
))
7357 /* Get metric type. */
7358 else if (argv_find (argv
, argc
, "(1-2)", &idx
)) {
7359 if (!str2metric_type (argv
[idx
]->arg
, &type
))
7363 else if (argv_find (argv
, argc
, "WORD", &idx
))
7364 ospf_routemap_set (red
, argv
[idx
]->arg
);
7366 ospf_routemap_unset (red
);
7368 return ospf_redistribute_default_set (ospf
, default_originate
,
7372 DEFUN (no_ospf_default_information_originate
,
7373 no_ospf_default_information_originate_cmd
,
7374 "no default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7376 "Control distribution of default information\n"
7377 "Distribute a default route\n"
7378 "Always advertise default route\n"
7379 "OSPF default metric\n"
7381 "OSPF metric type for default routes\n"
7382 "Set OSPF External Type 1 metrics\n"
7383 "Set OSPF External Type 2 metrics\n"
7384 "Route map reference\n"
7385 "Pointer to route-map entries\n")
7387 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7388 struct prefix_ipv4 p
;
7389 struct ospf_external
*ext
;
7390 struct ospf_redist
*red
;
7393 p
.prefix
.s_addr
= 0;
7396 ospf_external_lsa_flush (ospf
, DEFAULT_ROUTE
, &p
, 0);
7398 if ((ext
= ospf_external_lookup(DEFAULT_ROUTE
, 0)) &&
7399 EXTERNAL_INFO (ext
)) {
7400 ospf_external_info_delete (DEFAULT_ROUTE
, 0, p
);
7401 ospf_external_del (DEFAULT_ROUTE
, 0);
7404 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
7408 ospf_routemap_unset (red
);
7409 return ospf_redistribute_default_unset (ospf
);
7412 DEFUN (ospf_default_metric
,
7413 ospf_default_metric_cmd
,
7414 "default-metric (0-16777214)",
7415 "Set metric of redistributed routes\n"
7418 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7422 if (!str2metric (argv
[idx_number
]->arg
, &metric
))
7425 ospf
->default_metric
= metric
;
7430 DEFUN (no_ospf_default_metric
,
7431 no_ospf_default_metric_cmd
,
7432 "no default-metric [(0-16777214)]",
7434 "Set metric of redistributed routes\n"
7437 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7439 ospf
->default_metric
= -1;
7445 DEFUN (ospf_distance
,
7448 "Administrative distance\n"
7449 "OSPF Administrative distance\n")
7451 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7454 ospf
->distance_all
= atoi (argv
[idx_number
]->arg
);
7459 DEFUN (no_ospf_distance
,
7460 no_ospf_distance_cmd
,
7461 "no distance (1-255)",
7463 "Administrative distance\n"
7464 "OSPF Administrative distance\n")
7466 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7468 ospf
->distance_all
= 0;
7473 DEFUN (no_ospf_distance_ospf
,
7474 no_ospf_distance_ospf_cmd
,
7475 "no distance ospf [{intra-area [(1-255)]|inter-area [(1-255)]|external [(1-255)]}]",
7477 "Administrative distance\n"
7478 "OSPF administrative distance\n"
7479 "Intra-area routes\n"
7480 "Distance for intra-area routes\n"
7481 "Inter-area routes\n"
7482 "Distance for inter-area routes\n"
7484 "Distance for external routes\n")
7486 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7492 if (argv_find (argv
, argc
, "intra-area", &idx
) || argc
== 3)
7493 idx
= ospf
->distance_intra
= 0;
7494 if (argv_find (argv
, argc
, "inter-area", &idx
) || argc
== 3)
7495 idx
= ospf
->distance_inter
= 0;
7496 if (argv_find (argv
, argc
, "external", &idx
) || argc
== 3)
7497 ospf
->distance_external
= 0;
7502 DEFUN (ospf_distance_ospf
,
7503 ospf_distance_ospf_cmd
,
7504 "distance ospf {intra-area (1-255)|inter-area (1-255)|external (1-255)}",
7505 "Administrative distance\n"
7506 "OSPF administrative distance\n"
7507 "Intra-area routes\n"
7508 "Distance for intra-area routes\n"
7509 "Inter-area routes\n"
7510 "Distance for inter-area routes\n"
7512 "Distance for external routes\n")
7514 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7517 if (argv_find (argv
, argc
, "intra-area", &idx
))
7518 ospf
->distance_intra
= atoi(argv
[idx
+ 1]->arg
);
7520 if (argv_find (argv
, argc
, "inter-area", &idx
))
7521 ospf
->distance_inter
= atoi(argv
[idx
+ 1]->arg
);
7523 if (argv_find (argv
, argc
, "external", &idx
))
7524 ospf
->distance_external
= atoi(argv
[idx
+ 1]->arg
);
7530 DEFUN (ospf_distance_source
,
7531 ospf_distance_source_cmd
,
7532 "distance (1-255) A.B.C.D/M",
7533 "Administrative distance\n"
7535 "IP source prefix\n")
7537 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7539 int idx_ipv4_prefixlen
= 2;
7544 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
7549 DEFUN (no_ospf_distance_source
,
7550 no_ospf_distance_source_cmd
,
7551 "no distance (1-255) A.B.C.D/M",
7553 "Administrative distance\n"
7555 "IP source prefix\n")
7557 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7559 int idx_ipv4_prefixlen
= 3;
7564 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
7569 DEFUN (ospf_distance_source_access_list
,
7570 ospf_distance_source_access_list_cmd
,
7571 "distance (1-255) A.B.C.D/M WORD",
7572 "Administrative distance\n"
7574 "IP source prefix\n"
7575 "Access list name\n")
7577 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7579 int idx_ipv4_prefixlen
= 2;
7585 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
7590 DEFUN (no_ospf_distance_source_access_list
,
7591 no_ospf_distance_source_access_list_cmd
,
7592 "no distance (1-255) A.B.C.D/M WORD",
7594 "Administrative distance\n"
7596 "IP source prefix\n"
7597 "Access list name\n")
7599 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7601 int idx_ipv4_prefixlen
= 3;
7607 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
7613 DEFUN (ip_ospf_mtu_ignore
,
7614 ip_ospf_mtu_ignore_addr_cmd
,
7615 "ip ospf mtu-ignore [A.B.C.D]",
7617 "OSPF interface commands\n"
7618 "Disable MTU mismatch detection on this interface\n"
7619 "Address of interface")
7621 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7623 struct in_addr addr
;
7626 struct ospf_if_params
*params
;
7627 params
= IF_DEF_PARAMS (ifp
);
7631 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7634 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7638 params
= ospf_get_if_params (ifp
, addr
);
7639 ospf_if_update_params (ifp
, addr
);
7641 params
->mtu_ignore
= 1;
7642 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
7643 SET_IF_PARAM (params
, mtu_ignore
);
7646 UNSET_IF_PARAM (params
, mtu_ignore
);
7647 if (params
!= IF_DEF_PARAMS (ifp
))
7649 ospf_free_if_params (ifp
, addr
);
7650 ospf_if_update_params (ifp
, addr
);
7656 DEFUN (no_ip_ospf_mtu_ignore
,
7657 no_ip_ospf_mtu_ignore_addr_cmd
,
7658 "no ip ospf mtu-ignore [A.B.C.D]",
7660 "OSPF interface commands\n"
7661 "Disable MTU mismatch detection on this interface\n"
7662 "Address of interface")
7664 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7666 struct in_addr addr
;
7669 struct ospf_if_params
*params
;
7670 params
= IF_DEF_PARAMS (ifp
);
7674 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7677 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7681 params
= ospf_get_if_params (ifp
, addr
);
7682 ospf_if_update_params (ifp
, addr
);
7684 params
->mtu_ignore
= 0;
7685 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
7686 SET_IF_PARAM (params
, mtu_ignore
);
7689 UNSET_IF_PARAM (params
, mtu_ignore
);
7690 if (params
!= IF_DEF_PARAMS (ifp
))
7692 ospf_free_if_params (ifp
, addr
);
7693 ospf_if_update_params (ifp
, addr
);
7700 DEFUN (ospf_max_metric_router_lsa_admin
,
7701 ospf_max_metric_router_lsa_admin_cmd
,
7702 "max-metric router-lsa administrative",
7703 "OSPF maximum / infinite-distance metric\n"
7704 "Advertise own Router-LSA with infinite distance (stub router)\n"
7705 "Administratively applied, for an indefinite period\n")
7707 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7708 struct listnode
*ln
;
7709 struct ospf_area
*area
;
7711 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7713 SET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
7715 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
))
7716 ospf_router_lsa_update_area (area
);
7719 /* Allows for areas configured later to get the property */
7720 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_SET
;
7725 DEFUN (no_ospf_max_metric_router_lsa_admin
,
7726 no_ospf_max_metric_router_lsa_admin_cmd
,
7727 "no max-metric router-lsa administrative",
7729 "OSPF maximum / infinite-distance metric\n"
7730 "Advertise own Router-LSA with infinite distance (stub router)\n"
7731 "Administratively applied, for an indefinite period\n")
7733 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7734 struct listnode
*ln
;
7735 struct ospf_area
*area
;
7737 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7739 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
7741 /* Don't trample on the start-up stub timer */
7742 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
)
7743 && !area
->t_stub_router
)
7745 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
7746 ospf_router_lsa_update_area (area
);
7749 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET
;
7753 DEFUN (ospf_max_metric_router_lsa_startup
,
7754 ospf_max_metric_router_lsa_startup_cmd
,
7755 "max-metric router-lsa on-startup (5-86400)",
7756 "OSPF maximum / infinite-distance metric\n"
7757 "Advertise own Router-LSA with infinite distance (stub router)\n"
7758 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7759 "Time (seconds) to advertise self as stub-router\n")
7761 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7763 unsigned int seconds
;
7767 vty_out (vty
, "%% Must supply stub-router period");
7771 VTY_GET_INTEGER ("stub-router startup period", seconds
, argv
[idx_number
]->arg
);
7773 ospf
->stub_router_startup_time
= seconds
;
7778 DEFUN (no_ospf_max_metric_router_lsa_startup
,
7779 no_ospf_max_metric_router_lsa_startup_cmd
,
7780 "no max-metric router-lsa on-startup [(5-86400)]",
7782 "OSPF maximum / infinite-distance metric\n"
7783 "Advertise own Router-LSA with infinite distance (stub router)\n"
7784 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7785 "Time (seconds) to advertise self as stub-router\n")
7787 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7788 struct listnode
*ln
;
7789 struct ospf_area
*area
;
7791 ospf
->stub_router_startup_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
7793 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7795 SET_FLAG (area
->stub_router_state
, OSPF_AREA_WAS_START_STUB_ROUTED
);
7796 OSPF_TIMER_OFF (area
->t_stub_router
);
7798 /* Don't trample on admin stub routed */
7799 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
7801 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
7802 ospf_router_lsa_update_area (area
);
7809 DEFUN (ospf_max_metric_router_lsa_shutdown
,
7810 ospf_max_metric_router_lsa_shutdown_cmd
,
7811 "max-metric router-lsa on-shutdown (5-100)",
7812 "OSPF maximum / infinite-distance metric\n"
7813 "Advertise own Router-LSA with infinite distance (stub router)\n"
7814 "Advertise stub-router prior to full shutdown of OSPF\n"
7815 "Time (seconds) to wait till full shutdown\n")
7817 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7819 unsigned int seconds
;
7823 vty_out (vty
, "%% Must supply stub-router shutdown period");
7827 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds
, argv
[idx_number
]->arg
);
7829 ospf
->stub_router_shutdown_time
= seconds
;
7834 DEFUN (no_ospf_max_metric_router_lsa_shutdown
,
7835 no_ospf_max_metric_router_lsa_shutdown_cmd
,
7836 "no max-metric router-lsa on-shutdown [(5-100)]",
7838 "OSPF maximum / infinite-distance metric\n"
7839 "Advertise own Router-LSA with infinite distance (stub router)\n"
7840 "Advertise stub-router prior to full shutdown of OSPF\n"
7841 "Time (seconds) to wait till full shutdown\n")
7843 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7845 ospf
->stub_router_shutdown_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
7851 config_write_stub_router (struct vty
*vty
, struct ospf
*ospf
)
7853 struct listnode
*ln
;
7854 struct ospf_area
*area
;
7856 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
7857 vty_out (vty
, " max-metric router-lsa on-startup %u%s",
7858 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
7859 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
7860 vty_out (vty
, " max-metric router-lsa on-shutdown %u%s",
7861 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
7862 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7864 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
7866 vty_out (vty
, " max-metric router-lsa administrative%s",
7875 show_ip_ospf_route_network (struct vty
*vty
, struct route_table
*rt
)
7877 struct route_node
*rn
;
7878 struct ospf_route
*or;
7879 struct listnode
*pnode
, *pnnode
;
7880 struct ospf_path
*path
;
7882 vty_out (vty
, "============ OSPF network routing table ============%s",
7885 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
7886 if ((or = rn
->info
) != NULL
)
7889 snprintf (buf1
, 19, "%s/%d",
7890 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
7892 switch (or->path_type
)
7894 case OSPF_PATH_INTER_AREA
:
7895 if (or->type
== OSPF_DESTINATION_NETWORK
)
7896 vty_out (vty
, "N IA %-18s [%d] area: %s%s", buf1
, or->cost
,
7897 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
7898 else if (or->type
== OSPF_DESTINATION_DISCARD
)
7899 vty_out (vty
, "D IA %-18s Discard entry%s", buf1
, VTY_NEWLINE
);
7901 case OSPF_PATH_INTRA_AREA
:
7902 vty_out (vty
, "N %-18s [%d] area: %s%s", buf1
, or->cost
,
7903 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
7909 if (or->type
== OSPF_DESTINATION_NETWORK
)
7910 for (ALL_LIST_ELEMENTS (or->paths
, pnode
, pnnode
, path
))
7912 if (if_lookup_by_index(path
->ifindex
, VRF_DEFAULT
))
7914 if (path
->nexthop
.s_addr
== 0)
7915 vty_out (vty
, "%24s directly attached to %s%s",
7916 "", ifindex2ifname (path
->ifindex
, VRF_DEFAULT
), VTY_NEWLINE
);
7918 vty_out (vty
, "%24s via %s, %s%s", "",
7919 inet_ntoa (path
->nexthop
),
7920 ifindex2ifname (path
->ifindex
, VRF_DEFAULT
), VTY_NEWLINE
);
7924 vty_out (vty
, "%s", VTY_NEWLINE
);
7928 show_ip_ospf_route_router (struct vty
*vty
, struct route_table
*rtrs
)
7930 struct route_node
*rn
;
7931 struct ospf_route
*or;
7932 struct listnode
*pnode
;
7933 struct listnode
*node
;
7934 struct ospf_path
*path
;
7936 vty_out (vty
, "============ OSPF router routing table =============%s",
7938 for (rn
= route_top (rtrs
); rn
; rn
= route_next (rn
))
7943 vty_out (vty
, "R %-15s ", inet_ntoa (rn
->p
.u
.prefix4
));
7945 for (ALL_LIST_ELEMENTS_RO ((struct list
*)rn
->info
, node
, or))
7948 vty_out (vty
, "%24s", "");
7951 vty_out (vty
, "%s [%d] area: %s",
7952 (or->path_type
== OSPF_PATH_INTER_AREA
? "IA" : " "),
7953 or->cost
, inet_ntoa (or->u
.std
.area_id
));
7955 vty_out (vty
, "%s%s%s",
7956 (or->u
.std
.flags
& ROUTER_LSA_BORDER
? ", ABR" : ""),
7957 (or->u
.std
.flags
& ROUTER_LSA_EXTERNAL
? ", ASBR" : ""),
7960 for (ALL_LIST_ELEMENTS_RO (or->paths
, pnode
, path
))
7962 if (if_lookup_by_index(path
->ifindex
, VRF_DEFAULT
))
7964 if (path
->nexthop
.s_addr
== 0)
7965 vty_out (vty
, "%24s directly attached to %s%s",
7966 "", ifindex2ifname (path
->ifindex
, VRF_DEFAULT
),
7969 vty_out (vty
, "%24s via %s, %s%s", "",
7970 inet_ntoa (path
->nexthop
),
7971 ifindex2ifname (path
->ifindex
, VRF_DEFAULT
),
7977 vty_out (vty
, "%s", VTY_NEWLINE
);
7981 show_ip_ospf_route_external (struct vty
*vty
, struct route_table
*rt
)
7983 struct route_node
*rn
;
7984 struct ospf_route
*er
;
7985 struct listnode
*pnode
, *pnnode
;
7986 struct ospf_path
*path
;
7988 vty_out (vty
, "============ OSPF external routing table ===========%s",
7990 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
7991 if ((er
= rn
->info
) != NULL
)
7994 snprintf (buf1
, 19, "%s/%d",
7995 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
7997 switch (er
->path_type
)
7999 case OSPF_PATH_TYPE1_EXTERNAL
:
8000 vty_out (vty
, "N E1 %-18s [%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
,
8001 er
->cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
8003 case OSPF_PATH_TYPE2_EXTERNAL
:
8004 vty_out (vty
, "N E2 %-18s [%d/%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
, er
->cost
,
8005 er
->u
.ext
.type2_cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
8009 for (ALL_LIST_ELEMENTS (er
->paths
, pnode
, pnnode
, path
))
8011 if (if_lookup_by_index(path
->ifindex
, VRF_DEFAULT
))
8013 if (path
->nexthop
.s_addr
== 0)
8014 vty_out (vty
, "%24s directly attached to %s%s",
8015 "", ifindex2ifname (path
->ifindex
, VRF_DEFAULT
), VTY_NEWLINE
);
8017 vty_out (vty
, "%24s via %s, %s%s", "",
8018 inet_ntoa (path
->nexthop
),
8019 ifindex2ifname (path
->ifindex
, VRF_DEFAULT
),
8024 vty_out (vty
, "%s", VTY_NEWLINE
);
8028 show_ip_ospf_border_routers_common (struct vty
*vty
, struct ospf
*ospf
)
8031 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
8032 VTY_NEWLINE
, VTY_NEWLINE
);
8034 if (ospf
->new_table
== NULL
)
8036 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
8040 /* Show Network routes.
8041 show_ip_ospf_route_network (vty, ospf->new_table); */
8043 /* Show Router routes. */
8044 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
8046 vty_out (vty
, "%s", VTY_NEWLINE
);
8051 DEFUN (show_ip_ospf_border_routers
,
8052 show_ip_ospf_border_routers_cmd
,
8053 "show ip ospf border-routers",
8056 "OSPF information\n"
8057 "Show all the ABR's and ASBR's\n")
8061 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
8064 return show_ip_ospf_border_routers_common(vty
, ospf
);
8067 DEFUN (show_ip_ospf_instance_border_routers
,
8068 show_ip_ospf_instance_border_routers_cmd
,
8069 "show ip ospf (1-65535) border-routers",
8072 "OSPF information\n"
8074 "Show all the ABR's and ASBR's\n")
8078 u_short instance
= 0;
8080 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
8081 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
8084 return show_ip_ospf_border_routers_common(vty
, ospf
);
8088 show_ip_ospf_route_common (struct vty
*vty
, struct ospf
*ospf
)
8091 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
8092 VTY_NEWLINE
, VTY_NEWLINE
);
8094 if (ospf
->new_table
== NULL
)
8096 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
8100 /* Show Network routes. */
8101 show_ip_ospf_route_network (vty
, ospf
->new_table
);
8103 /* Show Router routes. */
8104 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
8106 /* Show AS External routes. */
8107 show_ip_ospf_route_external (vty
, ospf
->old_external_route
);
8109 vty_out (vty
, "%s", VTY_NEWLINE
);
8114 DEFUN (show_ip_ospf_route
,
8115 show_ip_ospf_route_cmd
,
8116 "show ip ospf route",
8119 "OSPF information\n"
8120 "OSPF routing table\n")
8124 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
8127 return show_ip_ospf_route_common(vty
, ospf
);
8130 DEFUN (show_ip_ospf_instance_route
,
8131 show_ip_ospf_instance_route_cmd
,
8132 "show ip ospf (1-65535) route",
8135 "OSPF information\n"
8137 "OSPF routing table\n")
8141 u_short instance
= 0;
8143 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
8144 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
8147 return show_ip_ospf_route_common(vty
, ospf
);
8150 const char *ospf_abr_type_str
[] =
8159 const char *ospf_shortcut_mode_str
[] =
8166 const char *ospf_int_type_str
[] =
8168 "unknown", /* should never be used. */
8172 "point-to-multipoint",
8173 "virtual-link", /* should never be used. */
8177 /* Configuration write function for ospfd. */
8179 config_write_interface (struct vty
*vty
)
8181 struct listnode
*n1
, *n2
;
8182 struct interface
*ifp
;
8183 struct crypt_key
*ck
;
8185 struct route_node
*rn
= NULL
;
8186 struct ospf_if_params
*params
;
8187 struct ospf
*ospf
= ospf_lookup();
8189 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), n1
, ifp
))
8191 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
8194 if (ifp
->ifindex
== IFINDEX_DELETED
)
8197 vty_out (vty
, "!%s", VTY_NEWLINE
);
8198 vty_out (vty
, "interface %s%s", ifp
->name
,
8201 vty_out (vty
, " description %s%s", ifp
->desc
,
8206 params
= IF_DEF_PARAMS (ifp
);
8209 /* Interface Network print. */
8210 if (OSPF_IF_PARAM_CONFIGURED (params
, type
) &&
8211 params
->type
!= OSPF_IFTYPE_LOOPBACK
)
8213 if (params
->type
!= ospf_default_iftype(ifp
))
8215 vty_out (vty
, " ip ospf network %s",
8216 ospf_int_type_str
[params
->type
]);
8217 if (params
!= IF_DEF_PARAMS (ifp
))
8218 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8219 vty_out (vty
, "%s", VTY_NEWLINE
);
8223 /* OSPF interface authentication print */
8224 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_type
) &&
8225 params
->auth_type
!= OSPF_AUTH_NOTSET
)
8227 const char *auth_str
;
8229 /* Translation tables are not that much help here due to syntax
8230 of the simple option */
8231 switch (params
->auth_type
)
8234 case OSPF_AUTH_NULL
:
8238 case OSPF_AUTH_SIMPLE
:
8242 case OSPF_AUTH_CRYPTOGRAPHIC
:
8243 auth_str
= " message-digest";
8251 vty_out (vty
, " ip ospf authentication%s", auth_str
);
8252 if (params
!= IF_DEF_PARAMS (ifp
))
8253 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8254 vty_out (vty
, "%s", VTY_NEWLINE
);
8257 /* Simple Authentication Password print. */
8258 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_simple
) &&
8259 params
->auth_simple
[0] != '\0')
8261 vty_out (vty
, " ip ospf authentication-key %s",
8262 params
->auth_simple
);
8263 if (params
!= IF_DEF_PARAMS (ifp
))
8264 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8265 vty_out (vty
, "%s", VTY_NEWLINE
);
8268 /* Cryptographic Authentication Key print. */
8269 for (ALL_LIST_ELEMENTS_RO (params
->auth_crypt
, n2
, ck
))
8271 vty_out (vty
, " ip ospf message-digest-key %d md5 %s",
8272 ck
->key_id
, ck
->auth_key
);
8273 if (params
!= IF_DEF_PARAMS (ifp
))
8274 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8275 vty_out (vty
, "%s", VTY_NEWLINE
);
8278 /* Interface Output Cost print. */
8279 if (OSPF_IF_PARAM_CONFIGURED (params
, output_cost_cmd
))
8281 vty_out (vty
, " ip ospf cost %u", params
->output_cost_cmd
);
8282 if (params
!= IF_DEF_PARAMS (ifp
))
8283 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8284 vty_out (vty
, "%s", VTY_NEWLINE
);
8287 /* Hello Interval print. */
8288 if (OSPF_IF_PARAM_CONFIGURED (params
, v_hello
) &&
8289 params
->v_hello
!= OSPF_HELLO_INTERVAL_DEFAULT
)
8291 vty_out (vty
, " ip ospf hello-interval %u", params
->v_hello
);
8292 if (params
!= IF_DEF_PARAMS (ifp
))
8293 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8294 vty_out (vty
, "%s", VTY_NEWLINE
);
8298 /* Router Dead Interval print. */
8299 if (OSPF_IF_PARAM_CONFIGURED (params
, v_wait
) &&
8300 params
->v_wait
!= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
)
8302 vty_out (vty
, " ip ospf dead-interval ");
8305 if (OSPF_IF_PARAM_CONFIGURED (params
, fast_hello
))
8306 vty_out (vty
, "minimal hello-multiplier %d",
8307 params
->fast_hello
);
8309 vty_out (vty
, "%u", params
->v_wait
);
8311 if (params
!= IF_DEF_PARAMS (ifp
))
8312 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8313 vty_out (vty
, "%s", VTY_NEWLINE
);
8316 /* Router Priority print. */
8317 if (OSPF_IF_PARAM_CONFIGURED (params
, priority
) &&
8318 params
->priority
!= OSPF_ROUTER_PRIORITY_DEFAULT
)
8320 vty_out (vty
, " ip ospf priority %u", params
->priority
);
8321 if (params
!= IF_DEF_PARAMS (ifp
))
8322 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8323 vty_out (vty
, "%s", VTY_NEWLINE
);
8326 /* Retransmit Interval print. */
8327 if (OSPF_IF_PARAM_CONFIGURED (params
, retransmit_interval
) &&
8328 params
->retransmit_interval
!= OSPF_RETRANSMIT_INTERVAL_DEFAULT
)
8330 vty_out (vty
, " ip ospf retransmit-interval %u",
8331 params
->retransmit_interval
);
8332 if (params
!= IF_DEF_PARAMS (ifp
))
8333 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8334 vty_out (vty
, "%s", VTY_NEWLINE
);
8337 /* Transmit Delay print. */
8338 if (OSPF_IF_PARAM_CONFIGURED (params
, transmit_delay
) &&
8339 params
->transmit_delay
!= OSPF_TRANSMIT_DELAY_DEFAULT
)
8341 vty_out (vty
, " ip ospf transmit-delay %u", params
->transmit_delay
);
8342 if (params
!= IF_DEF_PARAMS (ifp
))
8343 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8344 vty_out (vty
, "%s", VTY_NEWLINE
);
8348 if (OSPF_IF_PARAM_CONFIGURED (params
, if_area
))
8351 vty_out (vty
, " ip ospf %d area %s%s", ospf
->instance
,
8352 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
8354 vty_out (vty
, " ip ospf area %s%s",
8355 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
8360 ospf_bfd_write_config(vty
, params
);
8362 /* MTU ignore print. */
8363 if (OSPF_IF_PARAM_CONFIGURED (params
, mtu_ignore
) &&
8364 params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
8366 if (params
->mtu_ignore
== 0)
8367 vty_out (vty
, " no ip ospf mtu-ignore");
8369 vty_out (vty
, " ip ospf mtu-ignore");
8370 if (params
!= IF_DEF_PARAMS (ifp
))
8371 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8372 vty_out (vty
, "%s", VTY_NEWLINE
);
8379 rn
= route_top (IF_OIFS_PARAMS (ifp
));
8381 rn
= route_next (rn
);
8391 ospf_opaque_config_write_if (vty
, ifp
);
8398 config_write_network_area (struct vty
*vty
, struct ospf
*ospf
)
8400 struct route_node
*rn
;
8401 u_char buf
[INET_ADDRSTRLEN
];
8403 /* `network area' print. */
8404 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
8407 struct ospf_network
*n
= rn
->info
;
8409 memset (buf
, 0, INET_ADDRSTRLEN
);
8411 /* Create Area ID string by specified Area ID format. */
8412 if (n
->area_id_fmt
== OSPF_AREA_ID_FMT_DOTTEDQUAD
)
8413 strncpy ((char *) buf
, inet_ntoa (n
->area_id
), INET_ADDRSTRLEN
);
8415 sprintf ((char *) buf
, "%lu",
8416 (unsigned long int) ntohl (n
->area_id
.s_addr
));
8418 /* Network print. */
8419 vty_out (vty
, " network %s/%d area %s%s",
8420 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
8428 config_write_ospf_area (struct vty
*vty
, struct ospf
*ospf
)
8430 struct listnode
*node
;
8431 struct ospf_area
*area
;
8432 u_char buf
[INET_ADDRSTRLEN
];
8434 /* Area configuration print. */
8435 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
8437 struct route_node
*rn1
;
8439 area_id2str ((char *) buf
, INET_ADDRSTRLEN
, &area
->area_id
,
8442 if (area
->auth_type
!= OSPF_AUTH_NULL
)
8444 if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
8445 vty_out (vty
, " area %s authentication%s", buf
, VTY_NEWLINE
);
8447 vty_out (vty
, " area %s authentication message-digest%s",
8451 if (area
->shortcut_configured
!= OSPF_SHORTCUT_DEFAULT
)
8452 vty_out (vty
, " area %s shortcut %s%s", buf
,
8453 ospf_shortcut_mode_str
[area
->shortcut_configured
],
8456 if ((area
->external_routing
== OSPF_AREA_STUB
)
8457 || (area
->external_routing
== OSPF_AREA_NSSA
)
8460 if (area
->external_routing
== OSPF_AREA_STUB
)
8461 vty_out (vty
, " area %s stub", buf
);
8462 else if (area
->external_routing
== OSPF_AREA_NSSA
)
8464 vty_out (vty
, " area %s nssa", buf
);
8465 switch (area
->NSSATranslatorRole
)
8467 case OSPF_NSSA_ROLE_NEVER
:
8468 vty_out (vty
, " translate-never");
8470 case OSPF_NSSA_ROLE_ALWAYS
:
8471 vty_out (vty
, " translate-always");
8473 case OSPF_NSSA_ROLE_CANDIDATE
:
8475 vty_out (vty
, " translate-candidate");
8479 if (area
->no_summary
)
8480 vty_out (vty
, " no-summary");
8482 vty_out (vty
, "%s", VTY_NEWLINE
);
8484 if (area
->default_cost
!= 1)
8485 vty_out (vty
, " area %s default-cost %d%s", buf
,
8486 area
->default_cost
, VTY_NEWLINE
);
8489 for (rn1
= route_top (area
->ranges
); rn1
; rn1
= route_next (rn1
))
8492 struct ospf_area_range
*range
= rn1
->info
;
8494 vty_out (vty
, " area %s range %s/%d", buf
,
8495 inet_ntoa (rn1
->p
.u
.prefix4
), rn1
->p
.prefixlen
);
8497 if (range
->cost_config
!= OSPF_AREA_RANGE_COST_UNSPEC
)
8498 vty_out (vty
, " cost %d", range
->cost_config
);
8500 if (!CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_ADVERTISE
))
8501 vty_out (vty
, " not-advertise");
8503 if (CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_SUBSTITUTE
))
8504 vty_out (vty
, " substitute %s/%d",
8505 inet_ntoa (range
->subst_addr
), range
->subst_masklen
);
8507 vty_out (vty
, "%s", VTY_NEWLINE
);
8510 if (EXPORT_NAME (area
))
8511 vty_out (vty
, " area %s export-list %s%s", buf
,
8512 EXPORT_NAME (area
), VTY_NEWLINE
);
8514 if (IMPORT_NAME (area
))
8515 vty_out (vty
, " area %s import-list %s%s", buf
,
8516 IMPORT_NAME (area
), VTY_NEWLINE
);
8518 if (PREFIX_NAME_IN (area
))
8519 vty_out (vty
, " area %s filter-list prefix %s in%s", buf
,
8520 PREFIX_NAME_IN (area
), VTY_NEWLINE
);
8522 if (PREFIX_NAME_OUT (area
))
8523 vty_out (vty
, " area %s filter-list prefix %s out%s", buf
,
8524 PREFIX_NAME_OUT (area
), VTY_NEWLINE
);
8531 config_write_ospf_nbr_nbma (struct vty
*vty
, struct ospf
*ospf
)
8533 struct ospf_nbr_nbma
*nbr_nbma
;
8534 struct route_node
*rn
;
8536 /* Static Neighbor configuration print. */
8537 for (rn
= route_top (ospf
->nbr_nbma
); rn
; rn
= route_next (rn
))
8538 if ((nbr_nbma
= rn
->info
))
8540 vty_out (vty
, " neighbor %s", inet_ntoa (nbr_nbma
->addr
));
8542 if (nbr_nbma
->priority
!= OSPF_NEIGHBOR_PRIORITY_DEFAULT
)
8543 vty_out (vty
, " priority %d", nbr_nbma
->priority
);
8545 if (nbr_nbma
->v_poll
!= OSPF_POLL_INTERVAL_DEFAULT
)
8546 vty_out (vty
, " poll-interval %d", nbr_nbma
->v_poll
);
8548 vty_out (vty
, "%s", VTY_NEWLINE
);
8555 config_write_virtual_link (struct vty
*vty
, struct ospf
*ospf
)
8557 struct listnode
*node
;
8558 struct ospf_vl_data
*vl_data
;
8559 char buf
[INET_ADDRSTRLEN
];
8561 /* Virtual-Link print */
8562 for (ALL_LIST_ELEMENTS_RO (ospf
->vlinks
, node
, vl_data
))
8564 struct listnode
*n2
;
8565 struct crypt_key
*ck
;
8566 struct ospf_interface
*oi
;
8568 if (vl_data
!= NULL
)
8570 memset (buf
, 0, INET_ADDRSTRLEN
);
8572 area_id2str (buf
, sizeof(buf
), &vl_data
->vl_area_id
, vl_data
->vl_area_id_fmt
);
8573 oi
= vl_data
->vl_oi
;
8576 if (OSPF_IF_PARAM (oi
, v_hello
) != OSPF_HELLO_INTERVAL_DEFAULT
||
8577 OSPF_IF_PARAM (oi
, v_wait
) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
||
8578 OSPF_IF_PARAM (oi
, retransmit_interval
) != OSPF_RETRANSMIT_INTERVAL_DEFAULT
||
8579 OSPF_IF_PARAM (oi
, transmit_delay
) != OSPF_TRANSMIT_DELAY_DEFAULT
)
8580 vty_out (vty
, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
8582 inet_ntoa (vl_data
->vl_peer
),
8583 OSPF_IF_PARAM (oi
, v_hello
),
8584 OSPF_IF_PARAM (oi
, retransmit_interval
),
8585 OSPF_IF_PARAM (oi
, transmit_delay
),
8586 OSPF_IF_PARAM (oi
, v_wait
),
8589 vty_out (vty
, " area %s virtual-link %s%s", buf
,
8590 inet_ntoa (vl_data
->vl_peer
), VTY_NEWLINE
);
8592 if (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
[0] != '\0')
8593 vty_out (vty
, " area %s virtual-link %s authentication-key %s%s",
8595 inet_ntoa (vl_data
->vl_peer
),
8596 IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
,
8599 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_crypt
,
8601 vty_out (vty
, " area %s virtual-link %s"
8602 " message-digest-key %d md5 %s%s",
8604 inet_ntoa (vl_data
->vl_peer
),
8605 ck
->key_id
, ck
->auth_key
, VTY_NEWLINE
);
8615 config_write_ospf_redistribute (struct vty
*vty
, struct ospf
*ospf
)
8619 /* redistribute print. */
8620 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
8622 struct list
*red_list
;
8623 struct listnode
*node
;
8624 struct ospf_redist
*red
;
8626 red_list
= ospf
->redist
[type
];
8630 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
))
8632 vty_out (vty
, " redistribute %s", zebra_route_string(type
));
8634 vty_out (vty
, " %d", red
->instance
);
8636 if (red
->dmetric
.value
>= 0)
8637 vty_out (vty
, " metric %d", red
->dmetric
.value
);
8639 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
8640 vty_out (vty
, " metric-type 1");
8642 if (ROUTEMAP_NAME (red
))
8643 vty_out (vty
, " route-map %s", ROUTEMAP_NAME (red
));
8645 vty_out (vty
, "%s", VTY_NEWLINE
);
8653 config_write_ospf_default_metric (struct vty
*vty
, struct ospf
*ospf
)
8655 if (ospf
->default_metric
!= -1)
8656 vty_out (vty
, " default-metric %d%s", ospf
->default_metric
,
8662 config_write_ospf_distribute (struct vty
*vty
, struct ospf
*ospf
)
8665 struct ospf_redist
*red
;
8669 /* distribute-list print. */
8670 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
8671 if (DISTRIBUTE_NAME (ospf
, type
))
8672 vty_out (vty
, " distribute-list %s out %s%s",
8673 DISTRIBUTE_NAME (ospf
, type
),
8674 zebra_route_string(type
), VTY_NEWLINE
);
8676 /* default-information print. */
8677 if (ospf
->default_originate
!= DEFAULT_ORIGINATE_NONE
)
8679 vty_out (vty
, " default-information originate");
8680 if (ospf
->default_originate
== DEFAULT_ORIGINATE_ALWAYS
)
8681 vty_out (vty
, " always");
8683 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
8686 if (red
->dmetric
.value
>= 0)
8687 vty_out (vty
, " metric %d",
8688 red
->dmetric
.value
);
8689 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
8690 vty_out (vty
, " metric-type 1");
8692 if (ROUTEMAP_NAME (red
))
8693 vty_out (vty
, " route-map %s",
8694 ROUTEMAP_NAME (red
));
8697 vty_out (vty
, "%s", VTY_NEWLINE
);
8706 config_write_ospf_distance (struct vty
*vty
, struct ospf
*ospf
)
8708 struct route_node
*rn
;
8709 struct ospf_distance
*odistance
;
8711 if (ospf
->distance_all
)
8712 vty_out (vty
, " distance %d%s", ospf
->distance_all
, VTY_NEWLINE
);
8714 if (ospf
->distance_intra
8715 || ospf
->distance_inter
8716 || ospf
->distance_external
)
8718 vty_out (vty
, " distance ospf");
8720 if (ospf
->distance_intra
)
8721 vty_out (vty
, " intra-area %d", ospf
->distance_intra
);
8722 if (ospf
->distance_inter
)
8723 vty_out (vty
, " inter-area %d", ospf
->distance_inter
);
8724 if (ospf
->distance_external
)
8725 vty_out (vty
, " external %d", ospf
->distance_external
);
8727 vty_out (vty
, "%s", VTY_NEWLINE
);
8730 for (rn
= route_top (ospf
->distance_table
); rn
; rn
= route_next (rn
))
8731 if ((odistance
= rn
->info
) != NULL
)
8733 vty_out (vty
, " distance %d %s/%d %s%s", odistance
->distance
,
8734 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
8735 odistance
->access_list
? odistance
->access_list
: "",
8741 /* OSPF configuration write function. */
8743 ospf_config_write (struct vty
*vty
)
8746 struct interface
*ifp
;
8747 struct ospf_interface
*oi
;
8748 struct listnode
*node
;
8751 ospf
= ospf_lookup ();
8752 if (ospf
!= NULL
&& ospf
->oi_running
)
8754 /* `router ospf' print. */
8756 vty_out (vty
, "router ospf %d%s", ospf
->instance
, VTY_NEWLINE
);
8758 vty_out (vty
, "router ospf%s", VTY_NEWLINE
);
8762 if (!ospf
->networks
)
8765 /* Router ID print. */
8766 if (ospf
->router_id_static
.s_addr
!= 0)
8767 vty_out (vty
, " ospf router-id %s%s",
8768 inet_ntoa (ospf
->router_id_static
), VTY_NEWLINE
);
8770 /* ABR type print. */
8771 if (ospf
->abr_type
!= OSPF_ABR_DEFAULT
)
8772 vty_out (vty
, " ospf abr-type %s%s",
8773 ospf_abr_type_str
[ospf
->abr_type
], VTY_NEWLINE
);
8775 /* log-adjacency-changes flag print. */
8776 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
))
8778 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
8779 vty_out(vty
, " log-adjacency-changes detail%s", VTY_NEWLINE
);
8780 else if (!DFLT_OSPF_LOG_ADJACENCY_CHANGES
)
8781 vty_out(vty
, " log-adjacency-changes%s", VTY_NEWLINE
);
8783 else if (DFLT_OSPF_LOG_ADJACENCY_CHANGES
)
8785 vty_out(vty
, " no log-adjacency-changes%s", VTY_NEWLINE
);
8788 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
8789 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
8790 vty_out (vty
, " compatible rfc1583%s", VTY_NEWLINE
);
8792 /* auto-cost reference-bandwidth configuration. */
8793 if (ospf
->ref_bandwidth
!= OSPF_DEFAULT_REF_BANDWIDTH
)
8795 vty_out (vty
, "! Important: ensure reference bandwidth "
8796 "is consistent across all routers%s", VTY_NEWLINE
);
8797 vty_out (vty
, " auto-cost reference-bandwidth %d%s",
8798 ospf
->ref_bandwidth
, VTY_NEWLINE
);
8801 /* SPF timers print. */
8802 if (ospf
->spf_delay
!= OSPF_SPF_DELAY_DEFAULT
||
8803 ospf
->spf_holdtime
!= OSPF_SPF_HOLDTIME_DEFAULT
||
8804 ospf
->spf_max_holdtime
!= OSPF_SPF_MAX_HOLDTIME_DEFAULT
)
8805 vty_out (vty
, " timers throttle spf %d %d %d%s",
8806 ospf
->spf_delay
, ospf
->spf_holdtime
,
8807 ospf
->spf_max_holdtime
, VTY_NEWLINE
);
8809 /* LSA timers print. */
8810 if (ospf
->min_ls_interval
!= OSPF_MIN_LS_INTERVAL
)
8811 vty_out (vty
, " timers throttle lsa all %d%s",
8812 ospf
->min_ls_interval
, VTY_NEWLINE
);
8813 if (ospf
->min_ls_arrival
!= OSPF_MIN_LS_ARRIVAL
)
8814 vty_out (vty
, " timers lsa min-arrival %d%s",
8815 ospf
->min_ls_arrival
, VTY_NEWLINE
);
8817 /* Write multiplier print. */
8818 if (ospf
->write_oi_count
!= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
)
8819 vty_out (vty
, " ospf write-multiplier %d%s",
8820 ospf
->write_oi_count
, VTY_NEWLINE
);
8822 /* Max-metric router-lsa print */
8823 config_write_stub_router (vty
, ospf
);
8825 /* SPF refresh parameters print. */
8826 if (ospf
->lsa_refresh_interval
!= OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
8827 vty_out (vty
, " refresh timer %d%s",
8828 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
8830 /* Redistribute information print. */
8831 config_write_ospf_redistribute (vty
, ospf
);
8833 /* passive-interface print. */
8834 if (ospf
->passive_interface_default
== OSPF_IF_PASSIVE
)
8835 vty_out (vty
, " passive-interface default%s", VTY_NEWLINE
);
8837 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, node
, ifp
))
8838 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
)
8839 && IF_DEF_PARAMS (ifp
)->passive_interface
!=
8840 ospf
->passive_interface_default
)
8842 vty_out (vty
, " %spassive-interface %s%s",
8843 IF_DEF_PARAMS (ifp
)->passive_interface
? "" : "no ",
8844 ifp
->name
, VTY_NEWLINE
);
8846 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
8848 if (!OSPF_IF_PARAM_CONFIGURED (oi
->params
, passive_interface
))
8850 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi
->ifp
),
8853 if (oi
->params
->passive_interface
== IF_DEF_PARAMS (oi
->ifp
)->passive_interface
)
8856 else if (oi
->params
->passive_interface
== ospf
->passive_interface_default
)
8859 vty_out (vty
, " %spassive-interface %s %s%s",
8860 oi
->params
->passive_interface
? "" : "no ",
8862 inet_ntoa (oi
->address
->u
.prefix4
), VTY_NEWLINE
);
8865 /* Network area print. */
8866 config_write_network_area (vty
, ospf
);
8868 /* Area config print. */
8869 config_write_ospf_area (vty
, ospf
);
8871 /* static neighbor print. */
8872 config_write_ospf_nbr_nbma (vty
, ospf
);
8874 /* Virtual-Link print. */
8875 config_write_virtual_link (vty
, ospf
);
8877 /* Default metric configuration. */
8878 config_write_ospf_default_metric (vty
, ospf
);
8880 /* Distribute-list and default-information print. */
8881 config_write_ospf_distribute (vty
, ospf
);
8883 /* Distance configuration. */
8884 config_write_ospf_distance (vty
, ospf
);
8886 ospf_opaque_config_write_router (vty
, ospf
);
8893 ospf_vty_show_init (void)
8895 /* "show ip ospf" commands. */
8896 install_element (VIEW_NODE
, &show_ip_ospf_cmd
);
8898 install_element (VIEW_NODE
, &show_ip_ospf_instance_cmd
);
8900 /* "show ip ospf database" commands. */
8901 install_element (VIEW_NODE
, &show_ip_ospf_database_type_adv_router_cmd
);
8902 install_element (VIEW_NODE
, &show_ip_ospf_database_max_cmd
);
8904 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_adv_router_cmd
);
8905 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_cmd
);
8906 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_max_cmd
);
8908 /* "show ip ospf interface" commands. */
8909 install_element (VIEW_NODE
, &show_ip_ospf_interface_cmd
);
8911 install_element (VIEW_NODE
, &show_ip_ospf_instance_interface_cmd
);
8913 /* "show ip ospf neighbor" commands. */
8914 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_detail_cmd
);
8915 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_cmd
);
8916 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_id_cmd
);
8917 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_all_cmd
);
8918 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_cmd
);
8919 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_cmd
);
8920 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_all_cmd
);
8922 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_detail_cmd
);
8923 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_cmd
);
8924 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_id_cmd
);
8925 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_all_cmd
);
8926 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_cmd
);
8927 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_cmd
);
8928 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_all_cmd
);
8930 /* "show ip ospf route" commands. */
8931 install_element (VIEW_NODE
, &show_ip_ospf_route_cmd
);
8932 install_element (VIEW_NODE
, &show_ip_ospf_border_routers_cmd
);
8934 install_element (VIEW_NODE
, &show_ip_ospf_instance_route_cmd
);
8935 install_element (VIEW_NODE
, &show_ip_ospf_instance_border_routers_cmd
);
8939 /* ospfd's interface node. */
8940 static struct cmd_node interface_node
=
8947 /* Initialization of OSPF interface. */
8949 ospf_vty_if_init (void)
8951 /* Install interface node. */
8952 install_node (&interface_node
, config_write_interface
);
8955 /* "ip ospf authentication" commands. */
8956 install_element (INTERFACE_NODE
, &ip_ospf_authentication_args_addr_cmd
);
8957 install_element (INTERFACE_NODE
, &ip_ospf_authentication_addr_cmd
);
8958 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_args_addr_cmd
);
8959 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_addr_cmd
);
8960 install_element (INTERFACE_NODE
, &ip_ospf_authentication_key_addr_cmd
);
8961 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_key_authkey_addr_cmd
);
8962 install_element (INTERFACE_NODE
, &no_ospf_authentication_key_authkey_addr_cmd
);
8964 /* "ip ospf message-digest-key" commands. */
8965 install_element (INTERFACE_NODE
, &ip_ospf_message_digest_key_cmd
);
8966 install_element (INTERFACE_NODE
, &no_ip_ospf_message_digest_key_cmd
);
8968 /* "ip ospf cost" commands. */
8969 install_element (INTERFACE_NODE
, &ip_ospf_cost_cmd
);
8970 install_element (INTERFACE_NODE
, &no_ip_ospf_cost_cmd
);
8972 /* "ip ospf mtu-ignore" commands. */
8973 install_element (INTERFACE_NODE
, &ip_ospf_mtu_ignore_addr_cmd
);
8974 install_element (INTERFACE_NODE
, &no_ip_ospf_mtu_ignore_addr_cmd
);
8976 /* "ip ospf dead-interval" commands. */
8977 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_cmd
);
8978 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_minimal_addr_cmd
);
8979 install_element (INTERFACE_NODE
, &no_ip_ospf_dead_interval_cmd
);
8981 /* "ip ospf hello-interval" commands. */
8982 install_element (INTERFACE_NODE
, &ip_ospf_hello_interval_cmd
);
8983 install_element (INTERFACE_NODE
, &no_ip_ospf_hello_interval_cmd
);
8985 /* "ip ospf network" commands. */
8986 install_element (INTERFACE_NODE
, &ip_ospf_network_cmd
);
8987 install_element (INTERFACE_NODE
, &no_ip_ospf_network_cmd
);
8989 /* "ip ospf priority" commands. */
8990 install_element (INTERFACE_NODE
, &ip_ospf_priority_cmd
);
8991 install_element (INTERFACE_NODE
, &no_ip_ospf_priority_cmd
);
8993 /* "ip ospf retransmit-interval" commands. */
8994 install_element (INTERFACE_NODE
, &ip_ospf_retransmit_interval_addr_cmd
);
8995 install_element (INTERFACE_NODE
, &no_ip_ospf_retransmit_interval_addr_cmd
);
8997 /* "ip ospf transmit-delay" commands. */
8998 install_element (INTERFACE_NODE
, &ip_ospf_transmit_delay_addr_cmd
);
8999 install_element (INTERFACE_NODE
, &no_ip_ospf_transmit_delay_addr_cmd
);
9001 /* "ip ospf area" commands. */
9002 install_element (INTERFACE_NODE
, &ip_ospf_area_cmd
);
9003 install_element (INTERFACE_NODE
, &no_ip_ospf_area_cmd
);
9005 /* These commands are compatibitliy for previous version. */
9006 install_element (INTERFACE_NODE
, &ospf_authentication_key_cmd
);
9007 install_element (INTERFACE_NODE
, &ospf_message_digest_key_cmd
);
9008 install_element (INTERFACE_NODE
, &no_ospf_message_digest_key_cmd
);
9009 install_element (INTERFACE_NODE
, &ospf_dead_interval_cmd
);
9010 install_element (INTERFACE_NODE
, &no_ospf_dead_interval_cmd
);
9011 install_element (INTERFACE_NODE
, &ospf_hello_interval_cmd
);
9012 install_element (INTERFACE_NODE
, &no_ospf_hello_interval_cmd
);
9013 install_element (INTERFACE_NODE
, &ospf_cost_cmd
);
9014 install_element (INTERFACE_NODE
, &no_ospf_cost_cmd
);
9015 install_element (INTERFACE_NODE
, &ospf_network_cmd
);
9016 install_element (INTERFACE_NODE
, &no_ospf_network_cmd
);
9017 install_element (INTERFACE_NODE
, &ospf_priority_cmd
);
9018 install_element (INTERFACE_NODE
, &no_ospf_priority_cmd
);
9019 install_element (INTERFACE_NODE
, &ospf_retransmit_interval_cmd
);
9020 install_element (INTERFACE_NODE
, &no_ospf_retransmit_interval_cmd
);
9021 install_element (INTERFACE_NODE
, &ospf_transmit_delay_cmd
);
9022 install_element (INTERFACE_NODE
, &no_ospf_transmit_delay_cmd
);
9026 ospf_vty_zebra_init (void)
9028 install_element (OSPF_NODE
, &ospf_redistribute_source_cmd
);
9029 install_element (OSPF_NODE
, &no_ospf_redistribute_source_cmd
);
9030 install_element (OSPF_NODE
, &ospf_redistribute_instance_source_cmd
);
9031 install_element (OSPF_NODE
, &no_ospf_redistribute_instance_source_cmd
);
9033 install_element (OSPF_NODE
, &ospf_distribute_list_out_cmd
);
9034 install_element (OSPF_NODE
, &no_ospf_distribute_list_out_cmd
);
9036 install_element (OSPF_NODE
, &ospf_default_information_originate_cmd
);
9037 install_element (OSPF_NODE
, &no_ospf_default_information_originate_cmd
);
9039 install_element (OSPF_NODE
, &ospf_default_metric_cmd
);
9040 install_element (OSPF_NODE
, &no_ospf_default_metric_cmd
);
9042 install_element (OSPF_NODE
, &ospf_distance_cmd
);
9043 install_element (OSPF_NODE
, &no_ospf_distance_cmd
);
9044 install_element (OSPF_NODE
, &no_ospf_distance_ospf_cmd
);
9045 install_element (OSPF_NODE
, &ospf_distance_ospf_cmd
);
9047 install_element (OSPF_NODE
, &ospf_distance_source_cmd
);
9048 install_element (OSPF_NODE
, &no_ospf_distance_source_cmd
);
9049 install_element (OSPF_NODE
, &ospf_distance_source_access_list_cmd
);
9050 install_element (OSPF_NODE
, &no_ospf_distance_source_access_list_cmd
);
9054 static struct cmd_node ospf_node
=
9057 "%s(config-router)# ",
9062 ospf_interface_clear (struct interface
*ifp
)
9064 if (!if_is_operative (ifp
)) return;
9066 if (IS_DEBUG_OSPF (ism
, ISM_EVENTS
))
9067 zlog_debug("ISM[%s]: clear by reset", ifp
->name
);
9072 DEFUN (clear_ip_ospf_interface
,
9073 clear_ip_ospf_interface_cmd
,
9074 "clear ip ospf interface [IFNAME]",
9077 "OSPF information\n"
9078 "Interface information\n"
9082 struct interface
*ifp
;
9083 struct listnode
*node
;
9085 if (argc
== 4) /* Clear all the ospfv2 interfaces. */
9087 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
9088 ospf_interface_clear(ifp
);
9090 else /* Interface name is specified. */
9092 if ((ifp
= if_lookup_by_name (argv
[idx_ifname
]->arg
, VRF_DEFAULT
)) == NULL
)
9093 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
9095 ospf_interface_clear(ifp
);
9102 ospf_vty_clear_init (void)
9104 install_element (ENABLE_NODE
, &clear_ip_ospf_interface_cmd
);
9108 /* Install OSPF related vty commands. */
9110 ospf_vty_init (void)
9112 /* Install ospf top node. */
9113 install_node (&ospf_node
, ospf_config_write
);
9115 /* "router ospf" commands. */
9116 install_element (CONFIG_NODE
, &router_ospf_cmd
);
9117 install_element (CONFIG_NODE
, &no_router_ospf_cmd
);
9120 install_default (OSPF_NODE
);
9122 /* "ospf router-id" commands. */
9123 install_element (OSPF_NODE
, &ospf_router_id_cmd
);
9124 install_element (OSPF_NODE
, &ospf_router_id_old_cmd
);
9125 install_element (OSPF_NODE
, &no_ospf_router_id_cmd
);
9127 /* "passive-interface" commands. */
9128 install_element (OSPF_NODE
, &ospf_passive_interface_addr_cmd
);
9129 install_element (OSPF_NODE
, &no_ospf_passive_interface_addr_cmd
);
9131 /* "ospf abr-type" commands. */
9132 install_element (OSPF_NODE
, &ospf_abr_type_cmd
);
9133 install_element (OSPF_NODE
, &no_ospf_abr_type_cmd
);
9135 /* "ospf log-adjacency-changes" commands. */
9136 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_cmd
);
9137 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_detail_cmd
);
9138 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_cmd
);
9139 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_detail_cmd
);
9141 /* "ospf rfc1583-compatible" commands. */
9142 install_element (OSPF_NODE
, &ospf_compatible_rfc1583_cmd
);
9143 install_element (OSPF_NODE
, &no_ospf_compatible_rfc1583_cmd
);
9144 install_element (OSPF_NODE
, &ospf_rfc1583_flag_cmd
);
9145 install_element (OSPF_NODE
, &no_ospf_rfc1583_flag_cmd
);
9147 /* "network area" commands. */
9148 install_element (OSPF_NODE
, &ospf_network_area_cmd
);
9149 install_element (OSPF_NODE
, &no_ospf_network_area_cmd
);
9151 /* "area authentication" commands. */
9152 install_element (OSPF_NODE
, &ospf_area_authentication_message_digest_cmd
);
9153 install_element (OSPF_NODE
, &ospf_area_authentication_cmd
);
9154 install_element (OSPF_NODE
, &no_ospf_area_authentication_cmd
);
9156 /* "area range" commands. */
9157 install_element (OSPF_NODE
, &ospf_area_range_cmd
);
9158 install_element (OSPF_NODE
, &ospf_area_range_cost_cmd
);
9159 install_element (OSPF_NODE
, &ospf_area_range_not_advertise_cmd
);
9160 install_element (OSPF_NODE
, &no_ospf_area_range_cmd
);
9161 install_element (OSPF_NODE
, &ospf_area_range_substitute_cmd
);
9162 install_element (OSPF_NODE
, &no_ospf_area_range_substitute_cmd
);
9164 /* "area virtual-link" commands. */
9165 install_element (OSPF_NODE
, &ospf_area_vlink_cmd
);
9166 install_element (OSPF_NODE
, &ospf_area_vlink_intervals_cmd
);
9167 install_element (OSPF_NODE
, &no_ospf_area_vlink_cmd
);
9168 install_element (OSPF_NODE
, &no_ospf_area_vlink_intervals_cmd
);
9179 /* "area stub" commands. */
9180 install_element (OSPF_NODE
, &ospf_area_stub_no_summary_cmd
);
9181 install_element (OSPF_NODE
, &ospf_area_stub_cmd
);
9182 install_element (OSPF_NODE
, &no_ospf_area_stub_no_summary_cmd
);
9183 install_element (OSPF_NODE
, &no_ospf_area_stub_cmd
);
9185 /* "area nssa" commands. */
9186 install_element (OSPF_NODE
, &ospf_area_nssa_cmd
);
9187 install_element (OSPF_NODE
, &ospf_area_nssa_translate_no_summary_cmd
);
9188 install_element (OSPF_NODE
, &ospf_area_nssa_translate_cmd
);
9189 install_element (OSPF_NODE
, &ospf_area_nssa_no_summary_cmd
);
9190 install_element (OSPF_NODE
, &no_ospf_area_nssa_cmd
);
9192 install_element (OSPF_NODE
, &ospf_area_default_cost_cmd
);
9193 install_element (OSPF_NODE
, &no_ospf_area_default_cost_cmd
);
9195 install_element (OSPF_NODE
, &ospf_area_shortcut_cmd
);
9196 install_element (OSPF_NODE
, &no_ospf_area_shortcut_cmd
);
9198 install_element (OSPF_NODE
, &ospf_area_export_list_cmd
);
9199 install_element (OSPF_NODE
, &no_ospf_area_export_list_cmd
);
9201 install_element (OSPF_NODE
, &ospf_area_filter_list_cmd
);
9202 install_element (OSPF_NODE
, &no_ospf_area_filter_list_cmd
);
9204 install_element (OSPF_NODE
, &ospf_area_import_list_cmd
);
9205 install_element (OSPF_NODE
, &no_ospf_area_import_list_cmd
);
9207 /* SPF timer commands */
9208 install_element (OSPF_NODE
, &ospf_timers_throttle_spf_cmd
);
9209 install_element (OSPF_NODE
, &no_ospf_timers_throttle_spf_cmd
);
9211 /* LSA timers commands */
9212 install_element (OSPF_NODE
, &ospf_timers_min_ls_interval_cmd
);
9213 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_interval_cmd
);
9214 install_element (OSPF_NODE
, &ospf_timers_min_ls_arrival_cmd
);
9215 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_arrival_cmd
);
9216 install_element (OSPF_NODE
, &ospf_timers_lsa_cmd
);
9217 install_element (OSPF_NODE
, &no_ospf_timers_lsa_cmd
);
9219 /* refresh timer commands */
9220 install_element (OSPF_NODE
, &ospf_refresh_timer_cmd
);
9221 install_element (OSPF_NODE
, &no_ospf_refresh_timer_val_cmd
);
9223 /* max-metric commands */
9224 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_admin_cmd
);
9225 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_admin_cmd
);
9226 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_startup_cmd
);
9227 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_startup_cmd
);
9228 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_shutdown_cmd
);
9229 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_shutdown_cmd
);
9231 /* reference bandwidth commands */
9232 install_element (OSPF_NODE
, &ospf_auto_cost_reference_bandwidth_cmd
);
9233 install_element (OSPF_NODE
, &no_ospf_auto_cost_reference_bandwidth_cmd
);
9235 /* "neighbor" commands. */
9236 install_element (OSPF_NODE
, &ospf_neighbor_cmd
);
9237 install_element (OSPF_NODE
, &ospf_neighbor_poll_interval_cmd
);
9238 install_element (OSPF_NODE
, &no_ospf_neighbor_cmd
);
9239 install_element (OSPF_NODE
, &no_ospf_neighbor_poll_cmd
);
9241 /* write multiplier commands */
9242 install_element (OSPF_NODE
, &ospf_write_multiplier_cmd
);
9243 install_element (OSPF_NODE
, &write_multiplier_cmd
);
9244 install_element (OSPF_NODE
, &no_ospf_write_multiplier_cmd
);
9245 install_element (OSPF_NODE
, &no_write_multiplier_cmd
);
9247 /* Init interface related vty commands. */
9248 ospf_vty_if_init ();
9250 /* Init zebra related vty commands. */
9251 ospf_vty_zebra_init ();