2 * Copyright (C) 2005 6WIND <alain.ritoux@6wind.com>
3 * Copyright (C) 2000 Toshiaki Takada
5 * This file is part of GNU Zebra.
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; see the file COPYING; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
38 #include "ospfd/ospfd.h"
39 #include "ospfd/ospf_asbr.h"
40 #include "ospfd/ospf_lsa.h"
41 #include "ospfd/ospf_lsdb.h"
42 #include "ospfd/ospf_ism.h"
43 #include "ospfd/ospf_interface.h"
44 #include "ospfd/ospf_nsm.h"
45 #include "ospfd/ospf_neighbor.h"
46 #include "ospfd/ospf_flood.h"
47 #include "ospfd/ospf_abr.h"
48 #include "ospfd/ospf_spf.h"
49 #include "ospfd/ospf_route.h"
50 #include "ospfd/ospf_zebra.h"
51 /*#include "ospfd/ospf_routemap.h" */
52 #include "ospfd/ospf_vty.h"
53 #include "ospfd/ospf_dump.h"
54 #include "ospfd/ospf_bfd.h"
56 static const char *ospf_network_type_str
[] =
67 /* Utility functions. */
69 str2area_id (const char *str
, struct in_addr
*area_id
, int *area_id_fmt
)
73 area_id
->s_addr
= htonl (strtoul (str
, &ep
, 10));
74 if (*ep
&& !inet_aton (str
, area_id
))
77 *area_id_fmt
= *ep
? OSPF_AREA_ID_FMT_DOTTEDQUAD
: OSPF_AREA_ID_FMT_DECIMAL
;
83 area_id2str (char *buf
, int length
, struct in_addr
*area_id
, int area_id_fmt
)
85 memset (buf
, 0, length
);
87 if (area_id_fmt
== OSPF_AREA_ID_FMT_DOTTEDQUAD
)
88 strncpy (buf
, inet_ntoa (*area_id
), length
);
90 sprintf (buf
, "%lu", (unsigned long) ntohl (area_id
->s_addr
));
94 str2metric (const char *str
, int *metric
)
100 *metric
= strtol (str
, NULL
, 10);
101 if (*metric
< 0 && *metric
> 16777214)
103 /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */
111 str2metric_type (const char *str
, int *metric_type
)
117 if (strncmp (str
, "1", 1) == 0)
118 *metric_type
= EXTERNAL_METRIC_TYPE_1
;
119 else if (strncmp (str
, "2", 1) == 0)
120 *metric_type
= EXTERNAL_METRIC_TYPE_2
;
128 ospf_oi_count (struct interface
*ifp
)
130 struct route_node
*rn
;
133 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
140 DEFUN_NOSH (router_ospf
,
142 "router ospf [(1-65535)]",
143 "Enable a routing process\n"
144 "Start OSPF configuration\n"
148 u_short instance
= 0;
150 ospf
= ospf_lookup();
153 vty_out (vty
, "There isn't active ospf instance %s", VTY_NEWLINE
);
158 VTY_GET_INTEGER ("Instance", instance
, argv
[2]->arg
);
160 /* The following logic to set the vty qobj index is in place to be able
161 to ignore the commands which dont belong to this instance. */
162 if (ospf
->instance
!= instance
)
163 VTY_PUSH_CONTEXT_NULL(OSPF_NODE
);
166 if (IS_DEBUG_OSPF_EVENT
)
167 zlog_debug ("Config command 'router ospf %d' received", instance
);
168 ospf
->oi_running
= 1;
169 VTY_PUSH_CONTEXT(OSPF_NODE
, ospf
);
170 ospf_router_id_update (ospf
);
176 DEFUN (no_router_ospf
,
178 "no router ospf [(1-65535)]",
180 "Enable a routing process\n"
181 "Start OSPF configuration\n"
185 u_short instance
= 0;
188 VTY_GET_INTEGER ("Instance", instance
, argv
[3]->arg
);
190 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
199 DEFUN (ospf_router_id
,
201 "ospf router-id A.B.C.D",
202 "OSPF specific commands\n"
203 "router-id for the OSPF process\n"
204 "OSPF router-id in IP address format\n")
206 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
208 struct listnode
*node
;
209 struct ospf_area
*area
;
210 struct in_addr router_id
;
213 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &router_id
);
216 vty_out (vty
, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE
);
220 ospf
->router_id_static
= router_id
;
222 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
225 vty_out (vty
, "For this router-id change to take effect,"
226 " save config and restart ospfd%s", VTY_NEWLINE
);
230 ospf_router_id_update (ospf
);
235 DEFUN_HIDDEN (ospf_router_id_old
,
236 ospf_router_id_old_cmd
,
238 "router-id for the OSPF process\n"
239 "OSPF router-id in IP address format\n")
241 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
243 struct listnode
*node
;
244 struct ospf_area
*area
;
245 struct in_addr router_id
;
248 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &router_id
);
251 vty_out (vty
, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE
);
255 ospf
->router_id_static
= router_id
;
257 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
260 vty_out (vty
, "For this router-id change to take effect,"
261 " save config and restart ospfd%s", VTY_NEWLINE
);
265 ospf_router_id_update (ospf
);
270 DEFUN (no_ospf_router_id
,
271 no_ospf_router_id_cmd
,
272 "no ospf router-id [A.B.C.D]",
274 "OSPF specific commands\n"
275 "router-id for the OSPF process\n"
276 "OSPF router-id in IP address format\n")
278 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
279 struct listnode
*node
;
280 struct ospf_area
*area
;
282 ospf
->router_id_static
.s_addr
= 0;
284 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
287 vty_out (vty
, "For this router-id change to take effect,"
288 " save config and restart ospfd%s", VTY_NEWLINE
);
292 ospf_router_id_update (ospf
);
299 ospf_passive_interface_default (struct ospf
*ospf
, u_char newval
)
302 struct interface
*ifp
;
303 struct ospf_interface
*oi
;
305 ospf
->passive_interface_default
= newval
;
307 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, ln
, ifp
))
310 OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
))
311 UNSET_IF_PARAM (IF_DEF_PARAMS (ifp
), passive_interface
);
313 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, ln
, oi
))
315 if (OSPF_IF_PARAM_CONFIGURED (oi
->params
, passive_interface
))
316 UNSET_IF_PARAM (oi
->params
, passive_interface
);
317 /* update multicast memberships */
318 ospf_if_set_multicast(oi
);
323 ospf_passive_interface_update_addr (struct ospf
*ospf
, struct interface
*ifp
,
324 struct ospf_if_params
*params
, u_char value
,
329 params
->passive_interface
= value
;
330 if (params
!= IF_DEF_PARAMS (ifp
))
332 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
))
333 dflt
= IF_DEF_PARAMS (ifp
)->passive_interface
;
335 dflt
= ospf
->passive_interface_default
;
338 SET_IF_PARAM (params
, passive_interface
);
340 UNSET_IF_PARAM (params
, passive_interface
);
342 ospf_free_if_params (ifp
, addr
);
343 ospf_if_update_params (ifp
, addr
);
348 ospf_passive_interface_update (struct ospf
*ospf
, struct interface
*ifp
,
349 struct ospf_if_params
*params
, u_char value
)
351 params
->passive_interface
= value
;
352 if (params
== IF_DEF_PARAMS (ifp
))
354 if (value
!= ospf
->passive_interface_default
)
355 SET_IF_PARAM (params
, passive_interface
);
357 UNSET_IF_PARAM (params
, passive_interface
);
361 DEFUN (ospf_passive_interface
,
362 ospf_passive_interface_addr_cmd
,
363 "passive-interface <IFNAME [A.B.C.D]|default>",
364 "Suppress routing updates on an interface\n"
367 "Suppress routing updates on interfaces by default\n")
369 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
371 struct interface
*ifp
;
372 struct in_addr addr
= { .s_addr
= INADDR_ANY
};
374 struct ospf_if_params
*params
;
375 struct route_node
*rn
;
377 if (strcmp (argv
[1]->text
, "default") == 0)
379 ospf_passive_interface_default (ospf
, OSPF_IF_PASSIVE
);
383 ifp
= if_get_by_name (argv
[1]->arg
, VRF_DEFAULT
);
385 params
= IF_DEF_PARAMS (ifp
);
389 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
392 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
397 params
= ospf_get_if_params (ifp
, addr
);
398 ospf_if_update_params (ifp
, addr
);
399 ospf_passive_interface_update_addr (ospf
, ifp
, params
,
400 OSPF_IF_PASSIVE
, addr
);
403 ospf_passive_interface_update (ospf
, ifp
, params
, OSPF_IF_PASSIVE
);
405 /* XXX We should call ospf_if_set_multicast on exactly those
406 * interfaces for which the passive property changed. It is too much
407 * work to determine this set, so we do this for every interface.
408 * This is safe and reasonable because ospf_if_set_multicast uses a
409 * record of joined groups to avoid systems calls if the desired
410 * memberships match the current memership.
413 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next (rn
))
415 struct ospf_interface
*oi
= rn
->info
;
417 if (oi
&& (OSPF_IF_PARAM(oi
, passive_interface
) == OSPF_IF_PASSIVE
))
418 ospf_if_set_multicast(oi
);
421 * XXX It is not clear what state transitions the interface needs to
422 * undergo when going from active to passive. Fixing this will
423 * require precise identification of interfaces having such a
430 DEFUN (no_ospf_passive_interface
,
431 no_ospf_passive_interface_addr_cmd
,
432 "no passive-interface <IFNAME [A.B.C.D]|default>",
434 "Allow routing updates on an interface\n"
437 "Allow routing updates on interfaces by default\n")
439 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
441 struct interface
*ifp
;
442 struct in_addr addr
= { .s_addr
= INADDR_ANY
};
443 struct ospf_if_params
*params
;
445 struct route_node
*rn
;
447 if (strcmp (argv
[2]->text
, "default") == 0)
449 ospf_passive_interface_default (ospf
, OSPF_IF_ACTIVE
);
453 ifp
= if_get_by_name (argv
[2]->arg
, VRF_DEFAULT
);
455 params
= IF_DEF_PARAMS (ifp
);
459 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
462 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
467 params
= ospf_lookup_if_params (ifp
, addr
);
470 ospf_passive_interface_update_addr (ospf
, ifp
, params
, OSPF_IF_ACTIVE
,
473 ospf_passive_interface_update (ospf
, ifp
, params
, OSPF_IF_ACTIVE
);
475 /* XXX We should call ospf_if_set_multicast on exactly those
476 * interfaces for which the passive property changed. It is too much
477 * work to determine this set, so we do this for every interface.
478 * This is safe and reasonable because ospf_if_set_multicast uses a
479 * record of joined groups to avoid systems calls if the desired
480 * memberships match the current memership.
482 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next (rn
))
484 struct ospf_interface
*oi
= rn
->info
;
486 if (oi
&& (OSPF_IF_PARAM(oi
, passive_interface
) == OSPF_IF_ACTIVE
))
487 ospf_if_set_multicast(oi
);
495 DEFUN (ospf_network_area
,
496 ospf_network_area_cmd
,
497 "network A.B.C.D/M area <A.B.C.D|(0-4294967295)>",
498 "Enable routing on an IP network\n"
499 "OSPF network prefix\n"
500 "Set the OSPF area ID\n"
501 "OSPF area ID in IP address format\n"
502 "OSPF area ID as a decimal value\n")
504 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
505 int idx_ipv4_prefixlen
= 1;
506 int idx_ipv4_number
= 3;
507 struct prefix_ipv4 p
;
508 struct in_addr area_id
;
513 vty_out (vty
, "The network command is not supported in multi-instance ospf%s",
518 if (ospf
->if_ospf_cli_count
> 0)
520 vty_out (vty
, "Please remove all ip ospf area x.x.x.x commands first.%s",
525 /* Get network prefix and Area ID. */
526 VTY_GET_IPV4_PREFIX ("network prefix", p
, argv
[idx_ipv4_prefixlen
]->arg
);
527 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
529 ret
= ospf_network_set (ospf
, &p
, area_id
, format
);
532 vty_out (vty
, "There is already same network statement.%s", VTY_NEWLINE
);
539 DEFUN (no_ospf_network_area
,
540 no_ospf_network_area_cmd
,
541 "no network A.B.C.D/M area <A.B.C.D|(0-4294967295)>",
543 "Enable routing on an IP network\n"
544 "OSPF network prefix\n"
545 "Set the OSPF area ID\n"
546 "OSPF area ID in IP address format\n"
547 "OSPF area ID as a decimal value\n")
549 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
550 int idx_ipv4_prefixlen
= 2;
551 int idx_ipv4_number
= 4;
552 struct prefix_ipv4 p
;
553 struct in_addr area_id
;
558 vty_out (vty
, "The network command is not supported in multi-instance ospf%s",
563 /* Get network prefix and Area ID. */
564 VTY_GET_IPV4_PREFIX ("network prefix", p
, argv
[idx_ipv4_prefixlen
]->arg
);
565 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
567 ret
= ospf_network_unset (ospf
, &p
, area_id
);
570 vty_out (vty
, "Can't find specified network area configuration.%s",
578 DEFUN (ospf_area_range
,
580 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [advertise [cost (0-16777215)]]",
581 "OSPF area parameters\n"
582 "OSPF area ID in IP address format\n"
583 "OSPF area ID as a decimal value\n"
584 "Summarize routes matching address/mask (border routers only)\n"
585 "Area range prefix\n"
586 "Advertise this range (default)\n"
587 "User specified metric for this range\n"
588 "Advertised metric for this range\n")
590 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
591 int idx_ipv4_number
= 1;
592 int idx_ipv4_prefixlen
= 3;
594 struct prefix_ipv4 p
;
595 struct in_addr area_id
;
599 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
600 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
602 ospf_area_range_set (ospf
, area_id
, &p
, OSPF_AREA_RANGE_ADVERTISE
);
605 VTY_GET_INTEGER ("range cost", cost
, argv
[idx_cost
]->arg
);
606 ospf_area_range_cost_set (ospf
, area_id
, &p
, cost
);
612 DEFUN (ospf_area_range_cost
,
613 ospf_area_range_cost_cmd
,
614 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M cost (0-16777215)",
615 "OSPF area parameters\n"
616 "OSPF area ID in IP address format\n"
617 "OSPF area ID as a decimal value\n"
618 "Summarize routes matching address/mask (border routers only)\n"
619 "Area range prefix\n"
620 "User specified metric for this range\n"
621 "Advertised metric for this range\n")
623 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
624 int idx_ipv4_number
= 1;
625 int idx_ipv4_prefixlen
= 3;
627 struct prefix_ipv4 p
;
628 struct in_addr area_id
;
632 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
633 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
635 ospf_area_range_set (ospf
, area_id
, &p
, OSPF_AREA_RANGE_ADVERTISE
);
636 ospf_area_display_format_set (ospf
, ospf_area_get (ospf
, area_id
), format
);
638 VTY_GET_INTEGER ("range cost", cost
, argv
[idx_cost
]->arg
);
639 ospf_area_range_cost_set (ospf
, area_id
, &p
, cost
);
644 DEFUN (ospf_area_range_not_advertise
,
645 ospf_area_range_not_advertise_cmd
,
646 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M not-advertise",
647 "OSPF area parameters\n"
648 "OSPF area ID in IP address format\n"
649 "OSPF area ID as a decimal value\n"
650 "Summarize routes matching address/mask (border routers only)\n"
651 "Area range prefix\n"
652 "DoNotAdvertise this range\n")
654 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
655 int idx_ipv4_number
= 1;
656 int idx_ipv4_prefixlen
= 3;
657 struct prefix_ipv4 p
;
658 struct in_addr area_id
;
661 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
662 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
664 ospf_area_range_set (ospf
, area_id
, &p
, 0);
665 ospf_area_display_format_set (ospf
, ospf_area_get (ospf
, area_id
), format
);
670 DEFUN (no_ospf_area_range
,
671 no_ospf_area_range_cmd
,
672 "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [<cost (0-16777215)|advertise [cost (0-16777215)]|not-advertise>]",
674 "OSPF area parameters\n"
675 "OSPF area ID in IP address format\n"
676 "OSPF area ID as a decimal value\n"
677 "Summarize routes matching address/mask (border routers only)\n"
678 "Area range prefix\n"
679 "User specified metric for this range\n"
680 "Advertised metric for this range\n"
681 "Advertise this range (default)\n"
682 "User specified metric for this range\n"
683 "Advertised metric for this range\n"
684 "DoNotAdvertise this range\n")
686 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
687 int idx_ipv4_number
= 2;
688 int idx_ipv4_prefixlen
= 4;
689 struct prefix_ipv4 p
;
690 struct in_addr area_id
;
693 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
694 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
696 ospf_area_range_unset (ospf
, area_id
, &p
);
701 DEFUN (ospf_area_range_substitute
,
702 ospf_area_range_substitute_cmd
,
703 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M",
704 "OSPF area parameters\n"
705 "OSPF area ID in IP address format\n"
706 "OSPF area ID as a decimal value\n"
707 "Summarize routes matching address/mask (border routers only)\n"
708 "Area range prefix\n"
709 "Announce area range as another prefix\n"
710 "Network prefix to be announced instead of range\n")
712 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
713 int idx_ipv4_number
= 1;
714 int idx_ipv4_prefixlen
= 3;
715 int idx_ipv4_prefixlen_2
= 5;
716 struct prefix_ipv4 p
, s
;
717 struct in_addr area_id
;
720 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
721 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
722 VTY_GET_IPV4_PREFIX ("substituted network prefix", s
, argv
[idx_ipv4_prefixlen_2
]->arg
);
724 ospf_area_range_substitute_set (ospf
, area_id
, &p
, &s
);
725 ospf_area_display_format_set (ospf
, ospf_area_get (ospf
, area_id
), format
);
730 DEFUN (no_ospf_area_range_substitute
,
731 no_ospf_area_range_substitute_cmd
,
732 "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M",
734 "OSPF area parameters\n"
735 "OSPF area ID in IP address format\n"
736 "OSPF area ID as a decimal value\n"
737 "Summarize routes matching address/mask (border routers only)\n"
738 "Area range prefix\n"
739 "Announce area range as another prefix\n"
740 "Network prefix to be announced instead of range\n")
742 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
743 int idx_ipv4_number
= 2;
744 int idx_ipv4_prefixlen
= 4;
745 int idx_ipv4_prefixlen_2
= 6;
746 struct prefix_ipv4 p
, s
;
747 struct in_addr area_id
;
750 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
751 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
752 VTY_GET_IPV4_PREFIX ("substituted network prefix", s
, argv
[idx_ipv4_prefixlen_2
]->arg
);
754 ospf_area_range_substitute_unset (ospf
, area_id
, &p
);
760 /* Command Handler Logic in VLink stuff is delicate!!
762 ALTER AT YOUR OWN RISK!!!!
764 Various dummy values are used to represent 'NoChange' state for
765 VLink configuration NOT being changed by a VLink command, and
766 special syntax is used within the command strings so that the
767 typed in command verbs can be seen in the configuration command
768 bacckend handler. This is to drastically reduce the verbeage
769 required to coe up with a reasonably compatible Cisco VLink command
771 - Matthew Grant <grantma@anathoth.gen.nz>
772 Wed, 21 Feb 2001 15:13:52 +1300
775 /* Configuration data for virtual links
777 struct ospf_vl_config_data
{
778 struct vty
*vty
; /* vty stuff */
779 struct in_addr area_id
; /* area ID from command line */
780 int area_id_fmt
; /* command line area ID format */
781 struct in_addr vl_peer
; /* command line vl_peer */
782 int auth_type
; /* Authehntication type, if given */
783 char *auth_key
; /* simple password if present */
784 int crypto_key_id
; /* Cryptographic key ID */
785 char *md5_key
; /* MD5 authentication key */
786 int hello_interval
; /* Obvious what these are... */
787 int retransmit_interval
;
793 ospf_vl_config_data_init (struct ospf_vl_config_data
*vl_config
,
796 memset (vl_config
, 0, sizeof (struct ospf_vl_config_data
));
797 vl_config
->auth_type
= OSPF_AUTH_CMD_NOTSEEN
;
798 vl_config
->vty
= vty
;
801 static struct ospf_vl_data
*
802 ospf_find_vl_data (struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
804 struct ospf_area
*area
;
805 struct ospf_vl_data
*vl_data
;
807 struct in_addr area_id
;
809 vty
= vl_config
->vty
;
810 area_id
= vl_config
->area_id
;
812 if (area_id
.s_addr
== OSPF_AREA_BACKBONE
)
815 "Configuring VLs over the backbone is not allowed%s",
819 area
= ospf_area_get (ospf
, area_id
);
820 ospf_area_display_format_set (ospf
, area
, vl_config
->area_id_fmt
);
822 if (area
->external_routing
!= OSPF_AREA_DEFAULT
)
824 if (vl_config
->area_id_fmt
== OSPF_AREA_ID_FMT_DOTTEDQUAD
)
825 vty_out (vty
, "Area %s is %s%s",
827 area
->external_routing
== OSPF_AREA_NSSA
?"nssa":"stub",
830 vty_out (vty
, "Area %ld is %s%s",
831 (u_long
)ntohl (area_id
.s_addr
),
832 area
->external_routing
== OSPF_AREA_NSSA
?"nssa":"stub",
837 if ((vl_data
= ospf_vl_lookup (ospf
, area
, vl_config
->vl_peer
)) == NULL
)
839 vl_data
= ospf_vl_data_new (area
, vl_config
->vl_peer
);
840 if (vl_data
->vl_oi
== NULL
)
842 vl_data
->vl_oi
= ospf_vl_new (ospf
, vl_data
);
843 ospf_vl_add (ospf
, vl_data
);
844 ospf_spf_calculate_schedule (ospf
, SPF_FLAG_CONFIG_CHANGE
);
852 ospf_vl_set_security (struct ospf_vl_data
*vl_data
,
853 struct ospf_vl_config_data
*vl_config
)
855 struct crypt_key
*ck
;
857 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
859 vty
= vl_config
->vty
;
861 if (vl_config
->auth_type
!= OSPF_AUTH_CMD_NOTSEEN
)
863 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), auth_type
);
864 IF_DEF_PARAMS (ifp
)->auth_type
= vl_config
->auth_type
;
867 if (vl_config
->auth_key
)
869 memset(IF_DEF_PARAMS (ifp
)->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+1);
870 strncpy ((char *) IF_DEF_PARAMS (ifp
)->auth_simple
, vl_config
->auth_key
,
871 OSPF_AUTH_SIMPLE_SIZE
);
873 else if (vl_config
->md5_key
)
875 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp
)->auth_crypt
, vl_config
->crypto_key_id
)
878 vty_out (vty
, "OSPF: Key %d already exists%s",
879 vl_config
->crypto_key_id
, VTY_NEWLINE
);
882 ck
= ospf_crypt_key_new ();
883 ck
->key_id
= vl_config
->crypto_key_id
;
884 memset(ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
885 strncpy ((char *) ck
->auth_key
, vl_config
->md5_key
, OSPF_AUTH_MD5_SIZE
);
887 ospf_crypt_key_add (IF_DEF_PARAMS (ifp
)->auth_crypt
, ck
);
889 else if (vl_config
->crypto_key_id
!= 0)
893 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp
)->auth_crypt
,
894 vl_config
->crypto_key_id
) == NULL
)
896 vty_out (vty
, "OSPF: Key %d does not exist%s",
897 vl_config
->crypto_key_id
, VTY_NEWLINE
);
901 ospf_crypt_key_delete (IF_DEF_PARAMS (ifp
)->auth_crypt
, vl_config
->crypto_key_id
);
909 ospf_vl_set_timers (struct ospf_vl_data
*vl_data
,
910 struct ospf_vl_config_data
*vl_config
)
912 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
913 /* Virtual Link data initialised to defaults, so only set
915 if (vl_config
->hello_interval
)
917 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), v_hello
);
918 IF_DEF_PARAMS (ifp
)->v_hello
= vl_config
->hello_interval
;
921 if (vl_config
->dead_interval
)
923 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), v_wait
);
924 IF_DEF_PARAMS (ifp
)->v_wait
= vl_config
->dead_interval
;
927 if (vl_config
->retransmit_interval
)
929 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), retransmit_interval
);
930 IF_DEF_PARAMS (ifp
)->retransmit_interval
= vl_config
->retransmit_interval
;
933 if (vl_config
->transmit_delay
)
935 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), transmit_delay
);
936 IF_DEF_PARAMS (ifp
)->transmit_delay
= vl_config
->transmit_delay
;
943 /* The business end of all of the above */
945 ospf_vl_set (struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
947 struct ospf_vl_data
*vl_data
;
950 vl_data
= ospf_find_vl_data (ospf
, vl_config
);
954 /* Process this one first as it can have a fatal result, which can
955 only logically occur if the virtual link exists already
956 Thus a command error does not result in a change to the
957 running configuration such as unexpectedly altered timer
959 ret
= ospf_vl_set_security (vl_data
, vl_config
);
960 if (ret
!= CMD_SUCCESS
)
963 /* Set any time based parameters, these area already range checked */
965 ret
= ospf_vl_set_timers (vl_data
, vl_config
);
966 if (ret
!= CMD_SUCCESS
)
973 /* This stuff exists to make specifying all the alias commands A LOT simpler
975 #define VLINK_HELPSTR_IPADDR \
976 "OSPF area parameters\n" \
977 "OSPF area ID in IP address format\n" \
978 "OSPF area ID as a decimal value\n" \
979 "Configure a virtual link\n" \
980 "Router ID of the remote ABR\n"
982 #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
983 "Enable authentication on this virtual link\n" \
986 #define VLINK_HELPSTR_AUTHTYPE_ALL \
987 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
988 "Use null authentication\n" \
989 "Use message-digest authentication\n"
991 #define VLINK_HELPSTR_TIME_PARAM_NOSECS \
992 "Time between HELLO packets\n" \
993 "Time between retransmitting lost link state advertisements\n" \
994 "Link state transmit delay\n" \
995 "Interval time after which a neighbor is declared down\n"
997 #define VLINK_HELPSTR_TIME_PARAM \
998 VLINK_HELPSTR_TIME_PARAM_NOSECS \
1001 #define VLINK_HELPSTR_AUTH_SIMPLE \
1002 "Authentication password (key)\n" \
1003 "The OSPF password (key)"
1005 #define VLINK_HELPSTR_AUTH_MD5 \
1006 "Message digest authentication password (key)\n" \
1009 "Use MD5 algorithm\n" \
1010 "The OSPF password (key)"
1012 DEFUN (ospf_area_vlink
,
1013 ospf_area_vlink_cmd
,
1014 "area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D [authentication] [<message-digest|null>] [<message-digest-key (1-255) md5 KEY|authentication-key AUTH_KEY>]",
1015 VLINK_HELPSTR_IPADDR
1016 "Enable authentication on this virtual link\n" \
1017 "Use null authentication\n" \
1018 "Use message-digest authentication\n"
1019 "Message digest authentication password (key)\n" \
1021 "Use MD5 algorithm\n" \
1022 "The OSPF password (key)")
1024 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1025 int idx_ipv4_number
= 1;
1027 struct ospf_vl_config_data vl_config
;
1028 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+1];
1029 char md5_key
[OSPF_AUTH_MD5_SIZE
+1];
1033 ospf_vl_config_data_init(&vl_config
, vty
);
1035 /* Read off first 2 parameters and check them */
1036 ret
= str2area_id (argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
,
1037 &vl_config
.area_id_fmt
);
1040 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1044 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1047 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s",
1054 /* Thats all folks! - BUGS B. strikes again!!!*/
1056 return ospf_vl_set (ospf
, &vl_config
);
1059 /* Deal with other parameters */
1060 for (i
=5; i
< argc
; i
++)
1063 /* vty_out (vty, "argv[%d]->arg - %s%s", i, argv[i]->text, VTY_NEWLINE); */
1065 switch (argv
[i
]->arg
[0])
1069 if (i
>5 || strncmp (argv
[i
]->arg
, "authentication-", 15) == 0)
1071 /* authentication-key - this option can occur anywhere on
1072 command line. At start of command line
1073 must check for authentication option. */
1074 memset (auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1075 strncpy (auth_key
, argv
[i
+1]->text
, OSPF_AUTH_SIMPLE_SIZE
);
1076 vl_config
.auth_key
= auth_key
;
1079 else if (strncmp (argv
[i
]->arg
, "authentication", 14) == 0)
1081 /* authentication - this option can only occur at start
1083 vl_config
.auth_type
= OSPF_AUTH_SIMPLE
;
1086 if (strncmp (argv
[i
+1]->arg
, "n", 1) == 0)
1088 /* "authentication null" */
1089 vl_config
.auth_type
= OSPF_AUTH_NULL
;
1092 else if (strncmp (argv
[i
+1]->arg
, "m", 1) == 0
1093 && strcmp (argv
[i
+1]->arg
, "message-digest-") != 0)
1095 /* "authentication message-digest" */
1096 vl_config
.auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
1104 /* message-digest-key */
1108 vl_config
.crypto_key_id
= strtol (argv
[i
]->arg
, NULL
, 10);
1109 if (vl_config
.crypto_key_id
< 0)
1114 memset(md5_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
1115 strncpy (md5_key
, argv
[i
]->arg
, OSPF_AUTH_MD5_SIZE
);
1116 vl_config
.md5_key
= md5_key
;
1120 vl_config
.md5_key
= NULL
;
1126 /* Action configuration */
1128 return ospf_vl_set (ospf
, &vl_config
);
1132 DEFUN (ospf_area_vlink_intervals
,
1133 ospf_area_vlink_intervals_cmd
,
1134 "area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D"
1135 "<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1136 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1137 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1138 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1140 VLINK_HELPSTR_IPADDR
1141 VLINK_HELPSTR_TIME_PARAM
1142 VLINK_HELPSTR_TIME_PARAM
1143 VLINK_HELPSTR_TIME_PARAM
1144 VLINK_HELPSTR_TIME_PARAM
)
1146 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1147 struct ospf_vl_config_data vl_config
;
1150 ospf_vl_config_data_init(&vl_config
, vty
);
1152 char *area_id
= argv
[1]->arg
;
1153 char *router_id
= argv
[3]->arg
;
1155 ret
= str2area_id (area_id
, &vl_config
.area_id
, &vl_config
.area_id_fmt
);
1158 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1162 ret
= inet_aton (router_id
, &vl_config
.vl_peer
);
1165 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE
);
1168 for (unsigned int i
= 0; i
< 4; i
++)
1171 if (argv_find (argv
, argc
, "hello-interval", &idx
))
1172 vl_config
.hello_interval
= strtol(argv
[idx
+1]->arg
, NULL
, 10);
1173 else if (argv_find (argv
, argc
, "retransmit-interval", &idx
))
1174 vl_config
.retransmit_interval
= strtol(argv
[idx
+1]->arg
, NULL
, 10);
1175 else if (argv_find (argv
, argc
, "transmit-delay", &idx
))
1176 vl_config
.transmit_delay
= strtol(argv
[idx
+1]->arg
, NULL
, 10);
1177 else if (argv_find (argv
, argc
, "dead-interval", &idx
))
1178 vl_config
.dead_interval
= strtol(argv
[idx
+1]->arg
, NULL
, 10);
1181 /* Action configuration */
1182 return ospf_vl_set (ospf
, &vl_config
);
1185 DEFUN (no_ospf_area_vlink
,
1186 no_ospf_area_vlink_cmd
,
1187 "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>]",
1189 VLINK_HELPSTR_IPADDR
1190 "Enable authentication on this virtual link\n" \
1191 "Use null authentication\n" \
1192 "Use message-digest authentication\n"
1193 "Message digest authentication password (key)\n" \
1195 "Use MD5 algorithm\n" \
1196 "The OSPF password (key)")
1198 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1199 int idx_ipv4_number
= 2;
1201 struct ospf_area
*area
;
1202 struct ospf_vl_config_data vl_config
;
1203 struct ospf_vl_data
*vl_data
= NULL
;
1204 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+1];
1208 ospf_vl_config_data_init(&vl_config
, vty
);
1210 ret
= str2area_id (argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
, &format
);
1213 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1217 area
= ospf_area_lookup_by_area_id (ospf
, vl_config
.area_id
);
1220 vty_out (vty
, "Area does not exist%s", VTY_NEWLINE
);
1224 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1227 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s",
1234 /* Basic VLink no command */
1235 /* Thats all folks! - BUGS B. strikes again!!!*/
1236 if ((vl_data
= ospf_vl_lookup (ospf
, area
, vl_config
.vl_peer
)))
1237 ospf_vl_delete (ospf
, vl_data
);
1239 ospf_area_check_free (ospf
, vl_config
.area_id
);
1244 /* If we are down here, we are reseting parameters */
1246 /* Deal with other parameters */
1247 for (i
=6; i
< argc
; i
++)
1249 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1251 switch (argv
[i
]->arg
[0])
1255 if (i
> 2 || strncmp (argv
[i
]->text
, "authentication-", 15) == 0)
1257 /* authentication-key - this option can occur anywhere on
1258 command line. At start of command line
1259 must check for authentication option. */
1260 memset (auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1261 vl_config
.auth_key
= auth_key
;
1263 else if (strncmp (argv
[i
]->text
, "authentication", 14) == 0)
1265 /* authentication - this option can only occur at start
1267 vl_config
.auth_type
= OSPF_AUTH_NOTSET
;
1272 /* message-digest-key */
1273 /* Delete one key */
1277 vl_config
.crypto_key_id
= strtol (argv
[i
]->arg
, NULL
, 10);
1278 if (vl_config
.crypto_key_id
< 0)
1280 vl_config
.md5_key
= NULL
;
1290 /* Action configuration */
1292 return ospf_vl_set (ospf
, &vl_config
);
1295 DEFUN (no_ospf_area_vlink_intervals
,
1296 no_ospf_area_vlink_intervals_cmd
,
1297 "no area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D"
1298 "<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1299 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1300 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1301 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1304 VLINK_HELPSTR_IPADDR
1305 VLINK_HELPSTR_TIME_PARAM
1306 VLINK_HELPSTR_TIME_PARAM
1307 VLINK_HELPSTR_TIME_PARAM
1308 VLINK_HELPSTR_TIME_PARAM
)
1310 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1311 struct ospf_vl_config_data vl_config
;
1314 ospf_vl_config_data_init(&vl_config
, vty
);
1316 char *area_id
= argv
[2]->arg
;
1317 char *router_id
= argv
[4]->arg
;
1319 ret
= str2area_id (area_id
, &vl_config
.area_id
, &vl_config
.area_id_fmt
);
1322 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1326 ret
= inet_aton (router_id
, &vl_config
.vl_peer
);
1329 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE
);
1333 for (unsigned int i
= 0; i
< 4; i
++)
1336 if (argv_find (argv
, argc
, "hello-interval", &idx
))
1337 vl_config
.hello_interval
= OSPF_HELLO_INTERVAL_DEFAULT
;
1338 else if (argv_find (argv
, argc
, "retransmit-interval", &idx
))
1339 vl_config
.retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
1340 else if (argv_find (argv
, argc
, "transmit-delay", &idx
))
1341 vl_config
.transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
1342 else if (argv_find (argv
, argc
, "dead-interval", &idx
))
1343 vl_config
.dead_interval
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
1346 /* Action configuration */
1347 return ospf_vl_set (ospf
, &vl_config
);
1350 DEFUN (ospf_area_shortcut
,
1351 ospf_area_shortcut_cmd
,
1352 "area <A.B.C.D|(0-4294967295)> shortcut <default|enable|disable>",
1353 "OSPF area parameters\n"
1354 "OSPF area ID in IP address format\n"
1355 "OSPF area ID as a decimal value\n"
1356 "Configure the area's shortcutting mode\n"
1357 "Set default shortcutting behavior\n"
1358 "Enable shortcutting through the area\n"
1359 "Disable shortcutting through the area\n")
1361 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1362 int idx_ipv4_number
= 1;
1363 int idx_enable_disable
= 3;
1364 struct ospf_area
*area
;
1365 struct in_addr area_id
;
1369 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1371 area
= ospf_area_get (ospf
, area_id
);
1372 ospf_area_display_format_set (ospf
, area
, format
);
1374 if (strncmp (argv
[idx_enable_disable
]->arg
, "de", 2) == 0)
1375 mode
= OSPF_SHORTCUT_DEFAULT
;
1376 else if (strncmp (argv
[idx_enable_disable
]->arg
, "di", 2) == 0)
1377 mode
= OSPF_SHORTCUT_DISABLE
;
1378 else if (strncmp (argv
[idx_enable_disable
]->arg
, "e", 1) == 0)
1379 mode
= OSPF_SHORTCUT_ENABLE
;
1383 ospf_area_shortcut_set (ospf
, area
, mode
);
1385 if (ospf
->abr_type
!= OSPF_ABR_SHORTCUT
)
1386 vty_out (vty
, "Shortcut area setting will take effect "
1387 "only when the router is configured as Shortcut ABR%s",
1393 DEFUN (no_ospf_area_shortcut
,
1394 no_ospf_area_shortcut_cmd
,
1395 "no area <A.B.C.D|(0-4294967295)> shortcut <enable|disable>",
1397 "OSPF area parameters\n"
1398 "OSPF area ID in IP address format\n"
1399 "OSPF area ID as a decimal value\n"
1400 "Deconfigure the area's shortcutting mode\n"
1401 "Deconfigure enabled shortcutting through the area\n"
1402 "Deconfigure disabled shortcutting through the area\n")
1404 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1405 int idx_ipv4_number
= 2;
1406 struct ospf_area
*area
;
1407 struct in_addr area_id
;
1410 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1412 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1416 ospf_area_shortcut_unset (ospf
, area
);
1422 DEFUN (ospf_area_stub
,
1424 "area <A.B.C.D|(0-4294967295)> stub",
1425 "OSPF area parameters\n"
1426 "OSPF area ID in IP address format\n"
1427 "OSPF area ID as a decimal value\n"
1428 "Configure OSPF area as stub\n")
1430 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1431 int idx_ipv4_number
= 1;
1432 struct in_addr area_id
;
1435 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1437 ret
= ospf_area_stub_set (ospf
, area_id
);
1438 ospf_area_display_format_set (ospf
, ospf_area_get (ospf
, area_id
), format
);
1441 vty_out (vty
, "First deconfigure all virtual link through this area%s",
1446 ospf_area_no_summary_unset (ospf
, area_id
);
1451 DEFUN (ospf_area_stub_no_summary
,
1452 ospf_area_stub_no_summary_cmd
,
1453 "area <A.B.C.D|(0-4294967295)> stub no-summary",
1454 "OSPF stub parameters\n"
1455 "OSPF area ID in IP address format\n"
1456 "OSPF area ID as a decimal value\n"
1457 "Configure OSPF area as stub\n"
1458 "Do not inject inter-area routes into stub\n")
1460 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1461 int idx_ipv4_number
= 1;
1462 struct in_addr area_id
;
1465 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1467 ret
= ospf_area_stub_set (ospf
, area_id
);
1468 ospf_area_display_format_set (ospf
, ospf_area_get (ospf
, area_id
), format
);
1471 vty_out (vty
, "%% Area cannot be stub as it contains a virtual link%s",
1476 ospf_area_no_summary_set (ospf
, area_id
);
1481 DEFUN (no_ospf_area_stub
,
1482 no_ospf_area_stub_cmd
,
1483 "no area <A.B.C.D|(0-4294967295)> stub",
1485 "OSPF area parameters\n"
1486 "OSPF area ID in IP address format\n"
1487 "OSPF area ID as a decimal value\n"
1488 "Configure OSPF area as stub\n")
1490 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1491 int idx_ipv4_number
= 2;
1492 struct in_addr area_id
;
1495 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1497 ospf_area_stub_unset (ospf
, area_id
);
1498 ospf_area_no_summary_unset (ospf
, area_id
);
1503 DEFUN (no_ospf_area_stub_no_summary
,
1504 no_ospf_area_stub_no_summary_cmd
,
1505 "no area <A.B.C.D|(0-4294967295)> stub no-summary",
1507 "OSPF area parameters\n"
1508 "OSPF area ID in IP address format\n"
1509 "OSPF area ID as a decimal value\n"
1510 "Configure OSPF area as stub\n"
1511 "Do not inject inter-area routes into area\n")
1513 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1514 int idx_ipv4_number
= 2;
1515 struct in_addr area_id
;
1518 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1519 ospf_area_no_summary_unset (ospf
, area_id
);
1525 ospf_area_nssa_cmd_handler (struct vty
*vty
, int argc
, struct cmd_token
**argv
,
1528 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1529 struct in_addr area_id
;
1532 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id
, format
, argv
[1]->arg
);
1534 ret
= ospf_area_nssa_set (ospf
, area_id
);
1535 ospf_area_display_format_set (ospf
, ospf_area_get (ospf
, area_id
), format
);
1538 vty_out (vty
, "%% Area cannot be nssa as it contains a virtual link%s",
1545 if (strncmp (argv
[3]->text
, "translate-c", 11) == 0)
1546 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1547 OSPF_NSSA_ROLE_CANDIDATE
);
1548 else if (strncmp (argv
[3]->text
, "translate-n", 11) == 0)
1549 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1550 OSPF_NSSA_ROLE_NEVER
);
1551 else if (strncmp (argv
[3]->text
, "translate-a", 11) == 0)
1552 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1553 OSPF_NSSA_ROLE_ALWAYS
);
1557 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1558 OSPF_NSSA_ROLE_CANDIDATE
);
1562 ospf_area_no_summary_set (ospf
, area_id
);
1564 ospf_area_no_summary_unset (ospf
, area_id
);
1566 ospf_schedule_abr_task (ospf
);
1571 DEFUN (ospf_area_nssa_translate_no_summary
,
1572 ospf_area_nssa_translate_no_summary_cmd
,
1573 "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always> no-summary",
1574 "OSPF area parameters\n"
1575 "OSPF area ID in IP address format\n"
1576 "OSPF area ID as a decimal value\n"
1577 "Configure OSPF area as nssa\n"
1578 "Configure NSSA-ABR for translate election (default)\n"
1579 "Configure NSSA-ABR to never translate\n"
1580 "Configure NSSA-ABR to always translate\n"
1581 "Do not inject inter-area routes into nssa\n")
1583 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 1);
1586 DEFUN (ospf_area_nssa_translate
,
1587 ospf_area_nssa_translate_cmd
,
1588 "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always>",
1589 "OSPF area parameters\n"
1590 "OSPF area ID in IP address format\n"
1591 "OSPF area ID as a decimal value\n"
1592 "Configure OSPF area as nssa\n"
1593 "Configure NSSA-ABR for translate election (default)\n"
1594 "Configure NSSA-ABR to never translate\n"
1595 "Configure NSSA-ABR to always translate\n")
1597 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 0);
1600 DEFUN (ospf_area_nssa
,
1602 "area <A.B.C.D|(0-4294967295)> nssa",
1603 "OSPF area parameters\n"
1604 "OSPF area ID in IP address format\n"
1605 "OSPF area ID as a decimal value\n"
1606 "Configure OSPF area as nssa\n")
1608 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 0);
1611 DEFUN (ospf_area_nssa_no_summary
,
1612 ospf_area_nssa_no_summary_cmd
,
1613 "area <A.B.C.D|(0-4294967295)> nssa no-summary",
1614 "OSPF area parameters\n"
1615 "OSPF area ID in IP address format\n"
1616 "OSPF area ID as a decimal value\n"
1617 "Configure OSPF area as nssa\n"
1618 "Do not inject inter-area routes into nssa\n")
1620 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 1);
1623 DEFUN (no_ospf_area_nssa
,
1624 no_ospf_area_nssa_cmd
,
1625 "no area <A.B.C.D|(0-4294967295)> nssa [<translate-candidate|translate-never|translate-always> [no-summary]]",
1627 "OSPF area parameters\n"
1628 "OSPF area ID in IP address format\n"
1629 "OSPF area ID as a decimal value\n"
1630 "Configure OSPF area as nssa\n"
1631 "Configure NSSA-ABR for translate election (default)\n"
1632 "Configure NSSA-ABR to never translate\n"
1633 "Configure NSSA-ABR to always translate\n"
1634 "Do not inject inter-area routes into nssa\n")
1636 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1637 int idx_ipv4_number
= 2;
1638 struct in_addr area_id
;
1641 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1643 ospf_area_nssa_unset (ospf
, area_id
);
1644 ospf_area_no_summary_unset (ospf
, area_id
);
1646 ospf_schedule_abr_task (ospf
);
1652 DEFUN (ospf_area_default_cost
,
1653 ospf_area_default_cost_cmd
,
1654 "area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1655 "OSPF area parameters\n"
1656 "OSPF area ID in IP address format\n"
1657 "OSPF area ID as a decimal value\n"
1658 "Set the summary-default cost of a NSSA or stub area\n"
1659 "Stub's advertised default summary cost\n")
1661 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1662 int idx_ipv4_number
= 1;
1664 struct ospf_area
*area
;
1665 struct in_addr area_id
;
1668 struct prefix_ipv4 p
;
1670 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1671 VTY_GET_INTEGER_RANGE ("stub default cost", cost
, argv
[idx_number
]->arg
, 0, 16777215);
1673 area
= ospf_area_get (ospf
, area_id
);
1674 ospf_area_display_format_set (ospf
, area
, format
);
1676 if (area
->external_routing
== OSPF_AREA_DEFAULT
)
1678 vty_out (vty
, "The area is neither stub, nor NSSA%s", VTY_NEWLINE
);
1682 area
->default_cost
= cost
;
1685 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1687 if (IS_DEBUG_OSPF_EVENT
)
1688 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1689 "announcing 0.0.0.0/0 to area %s",
1690 inet_ntoa (area
->area_id
));
1691 ospf_abr_announce_network_to_area (&p
, area
->default_cost
, area
);
1696 DEFUN (no_ospf_area_default_cost
,
1697 no_ospf_area_default_cost_cmd
,
1698 "no area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1700 "OSPF area parameters\n"
1701 "OSPF area ID in IP address format\n"
1702 "OSPF area ID as a decimal value\n"
1703 "Set the summary-default cost of a NSSA or stub area\n"
1704 "Stub's advertised default summary cost\n")
1706 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1707 int idx_ipv4_number
= 2;
1709 struct ospf_area
*area
;
1710 struct in_addr area_id
;
1712 struct prefix_ipv4 p
;
1714 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1715 VTY_CHECK_INTEGER_RANGE ("stub default cost", argv
[idx_number
]->arg
, 0, OSPF_LS_INFINITY
);
1717 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1721 if (area
->external_routing
== OSPF_AREA_DEFAULT
)
1723 vty_out (vty
, "The area is neither stub, nor NSSA%s", VTY_NEWLINE
);
1727 area
->default_cost
= 1;
1730 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1732 if (IS_DEBUG_OSPF_EVENT
)
1733 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1734 "announcing 0.0.0.0/0 to area %s",
1735 inet_ntoa (area
->area_id
));
1736 ospf_abr_announce_network_to_area (&p
, area
->default_cost
, area
);
1739 ospf_area_check_free (ospf
, area_id
);
1744 DEFUN (ospf_area_export_list
,
1745 ospf_area_export_list_cmd
,
1746 "area <A.B.C.D|(0-4294967295)> export-list NAME",
1747 "OSPF area parameters\n"
1748 "OSPF area ID in IP address format\n"
1749 "OSPF area ID as a decimal value\n"
1750 "Set the filter for networks announced to other areas\n"
1751 "Name of the access-list\n")
1753 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1754 int idx_ipv4_number
= 1;
1755 struct ospf_area
*area
;
1756 struct in_addr area_id
;
1759 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1761 area
= ospf_area_get (ospf
, area_id
);
1762 ospf_area_display_format_set (ospf
, area
, format
);
1763 ospf_area_export_list_set (ospf
, area
, argv
[3]->arg
);
1768 DEFUN (no_ospf_area_export_list
,
1769 no_ospf_area_export_list_cmd
,
1770 "no area <A.B.C.D|(0-4294967295)> export-list NAME",
1772 "OSPF area parameters\n"
1773 "OSPF area ID in IP address format\n"
1774 "OSPF area ID as a decimal value\n"
1775 "Unset the filter for networks announced to other areas\n"
1776 "Name of the access-list\n")
1778 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1779 int idx_ipv4_number
= 2;
1780 struct ospf_area
*area
;
1781 struct in_addr area_id
;
1784 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1786 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1790 ospf_area_export_list_unset (ospf
, area
);
1796 DEFUN (ospf_area_import_list
,
1797 ospf_area_import_list_cmd
,
1798 "area <A.B.C.D|(0-4294967295)> import-list NAME",
1799 "OSPF area parameters\n"
1800 "OSPF area ID in IP address format\n"
1801 "OSPF area ID as a decimal value\n"
1802 "Set the filter for networks from other areas announced to the specified one\n"
1803 "Name of the access-list\n")
1805 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1806 int idx_ipv4_number
= 1;
1807 struct ospf_area
*area
;
1808 struct in_addr area_id
;
1811 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1813 area
= ospf_area_get (ospf
, area_id
);
1814 ospf_area_display_format_set (ospf
, area
, format
);
1815 ospf_area_import_list_set (ospf
, area
, argv
[3]->arg
);
1820 DEFUN (no_ospf_area_import_list
,
1821 no_ospf_area_import_list_cmd
,
1822 "no area <A.B.C.D|(0-4294967295)> import-list NAME",
1824 "OSPF area parameters\n"
1825 "OSPF area ID in IP address format\n"
1826 "OSPF area ID as a decimal value\n"
1827 "Unset the filter for networks announced to other areas\n"
1828 "Name of the access-list\n")
1830 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1831 int idx_ipv4_number
= 2;
1832 struct ospf_area
*area
;
1833 struct in_addr area_id
;
1836 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1838 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1842 ospf_area_import_list_unset (ospf
, area
);
1847 DEFUN (ospf_area_filter_list
,
1848 ospf_area_filter_list_cmd
,
1849 "area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>",
1850 "OSPF area parameters\n"
1851 "OSPF area ID in IP address format\n"
1852 "OSPF area ID as a decimal value\n"
1853 "Filter networks between OSPF areas\n"
1854 "Filter prefixes between OSPF areas\n"
1855 "Name of an IP prefix-list\n"
1856 "Filter networks sent to this area\n"
1857 "Filter networks sent from this area\n")
1859 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1860 int idx_ipv4_number
= 1;
1863 struct ospf_area
*area
;
1864 struct in_addr area_id
;
1865 struct prefix_list
*plist
;
1868 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1870 area
= ospf_area_get (ospf
, area_id
);
1871 ospf_area_display_format_set (ospf
, area
, format
);
1872 plist
= prefix_list_lookup (AFI_IP
, argv
[idx_word
]->arg
);
1873 if (strncmp (argv
[idx_in_out
]->arg
, "in", 2) == 0)
1875 PREFIX_LIST_IN (area
) = plist
;
1876 if (PREFIX_NAME_IN (area
))
1877 free (PREFIX_NAME_IN (area
));
1879 PREFIX_NAME_IN (area
) = strdup (argv
[idx_word
]->arg
);
1880 ospf_schedule_abr_task (ospf
);
1884 PREFIX_LIST_OUT (area
) = plist
;
1885 if (PREFIX_NAME_OUT (area
))
1886 free (PREFIX_NAME_OUT (area
));
1888 PREFIX_NAME_OUT (area
) = strdup (argv
[idx_word
]->arg
);
1889 ospf_schedule_abr_task (ospf
);
1895 DEFUN (no_ospf_area_filter_list
,
1896 no_ospf_area_filter_list_cmd
,
1897 "no area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>",
1899 "OSPF area parameters\n"
1900 "OSPF area ID in IP address format\n"
1901 "OSPF area ID as a decimal value\n"
1902 "Filter networks between OSPF areas\n"
1903 "Filter prefixes between OSPF areas\n"
1904 "Name of an IP prefix-list\n"
1905 "Filter networks sent to this area\n"
1906 "Filter networks sent from this area\n")
1908 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1909 int idx_ipv4_number
= 2;
1912 struct ospf_area
*area
;
1913 struct in_addr area_id
;
1916 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1918 if ((area
= ospf_area_lookup_by_area_id (ospf
, area_id
)) == NULL
)
1921 if (strncmp (argv
[idx_in_out
]->arg
, "in", 2) == 0)
1923 if (PREFIX_NAME_IN (area
))
1924 if (strcmp (PREFIX_NAME_IN (area
), argv
[idx_word
]->arg
) != 0)
1927 PREFIX_LIST_IN (area
) = NULL
;
1928 if (PREFIX_NAME_IN (area
))
1929 free (PREFIX_NAME_IN (area
));
1931 PREFIX_NAME_IN (area
) = NULL
;
1933 ospf_schedule_abr_task (ospf
);
1937 if (PREFIX_NAME_OUT (area
))
1938 if (strcmp (PREFIX_NAME_OUT (area
), argv
[idx_word
]->arg
) != 0)
1941 PREFIX_LIST_OUT (area
) = NULL
;
1942 if (PREFIX_NAME_OUT (area
))
1943 free (PREFIX_NAME_OUT (area
));
1945 PREFIX_NAME_OUT (area
) = NULL
;
1947 ospf_schedule_abr_task (ospf
);
1954 DEFUN (ospf_area_authentication_message_digest
,
1955 ospf_area_authentication_message_digest_cmd
,
1956 "area <A.B.C.D|(0-4294967295)> authentication message-digest",
1957 "OSPF area parameters\n"
1958 "OSPF area ID in IP address format\n"
1959 "OSPF area ID as a decimal value\n"
1960 "Enable authentication\n"
1961 "Use message-digest authentication\n")
1963 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1964 int idx_ipv4_number
= 1;
1965 struct ospf_area
*area
;
1966 struct in_addr area_id
;
1969 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1971 area
= ospf_area_get (ospf
, area_id
);
1972 ospf_area_display_format_set (ospf
, area
, format
);
1973 area
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
1978 DEFUN (ospf_area_authentication
,
1979 ospf_area_authentication_cmd
,
1980 "area <A.B.C.D|(0-4294967295)> authentication",
1981 "OSPF area parameters\n"
1982 "OSPF area ID in IP address format\n"
1983 "OSPF area ID as a decimal value\n"
1984 "Enable authentication\n")
1986 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1987 int idx_ipv4_number
= 1;
1988 struct ospf_area
*area
;
1989 struct in_addr area_id
;
1992 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1994 area
= ospf_area_get (ospf
, area_id
);
1995 ospf_area_display_format_set (ospf
, area
, format
);
1996 area
->auth_type
= OSPF_AUTH_SIMPLE
;
2001 DEFUN (no_ospf_area_authentication
,
2002 no_ospf_area_authentication_cmd
,
2003 "no area <A.B.C.D|(0-4294967295)> authentication",
2005 "OSPF area parameters\n"
2006 "OSPF area ID in IP address format\n"
2007 "OSPF area ID as a decimal value\n"
2008 "Enable authentication\n")
2010 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2011 int idx_ipv4_number
= 2;
2012 struct ospf_area
*area
;
2013 struct in_addr area_id
;
2016 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
2018 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
2022 area
->auth_type
= OSPF_AUTH_NULL
;
2024 ospf_area_check_free (ospf
, area_id
);
2030 DEFUN (ospf_abr_type
,
2032 "ospf abr-type <cisco|ibm|shortcut|standard>",
2033 "OSPF specific commands\n"
2034 "Set OSPF ABR type\n"
2035 "Alternative ABR, cisco implementation\n"
2036 "Alternative ABR, IBM implementation\n"
2038 "Standard behavior (RFC2328)\n")
2040 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2042 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2044 if (strncmp (argv
[idx_vendor
]->arg
, "c", 1) == 0)
2045 abr_type
= OSPF_ABR_CISCO
;
2046 else if (strncmp (argv
[idx_vendor
]->arg
, "i", 1) == 0)
2047 abr_type
= OSPF_ABR_IBM
;
2048 else if (strncmp (argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2049 abr_type
= OSPF_ABR_SHORTCUT
;
2050 else if (strncmp (argv
[idx_vendor
]->arg
, "st", 2) == 0)
2051 abr_type
= OSPF_ABR_STAND
;
2055 /* If ABR type value is changed, schedule ABR task. */
2056 if (ospf
->abr_type
!= abr_type
)
2058 ospf
->abr_type
= abr_type
;
2059 ospf_schedule_abr_task (ospf
);
2065 DEFUN (no_ospf_abr_type
,
2066 no_ospf_abr_type_cmd
,
2067 "no ospf abr-type <cisco|ibm|shortcut|standard>",
2069 "OSPF specific commands\n"
2070 "Set OSPF ABR type\n"
2071 "Alternative ABR, cisco implementation\n"
2072 "Alternative ABR, IBM implementation\n"
2076 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2078 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2080 if (strncmp (argv
[idx_vendor
]->arg
, "c", 1) == 0)
2081 abr_type
= OSPF_ABR_CISCO
;
2082 else if (strncmp (argv
[idx_vendor
]->arg
, "i", 1) == 0)
2083 abr_type
= OSPF_ABR_IBM
;
2084 else if (strncmp (argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2085 abr_type
= OSPF_ABR_SHORTCUT
;
2086 else if (strncmp (argv
[idx_vendor
]->arg
, "st", 2) == 0)
2087 abr_type
= OSPF_ABR_STAND
;
2091 /* If ABR type value is changed, schedule ABR task. */
2092 if (ospf
->abr_type
== abr_type
)
2094 ospf
->abr_type
= OSPF_ABR_DEFAULT
;
2095 ospf_schedule_abr_task (ospf
);
2101 DEFUN (ospf_log_adjacency_changes
,
2102 ospf_log_adjacency_changes_cmd
,
2103 "log-adjacency-changes",
2104 "Log changes in adjacency state\n")
2106 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2108 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2109 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2113 DEFUN (ospf_log_adjacency_changes_detail
,
2114 ospf_log_adjacency_changes_detail_cmd
,
2115 "log-adjacency-changes detail",
2116 "Log changes in adjacency state\n"
2117 "Log all state changes\n")
2119 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2121 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2122 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2126 DEFUN (no_ospf_log_adjacency_changes
,
2127 no_ospf_log_adjacency_changes_cmd
,
2128 "no log-adjacency-changes",
2130 "Log changes in adjacency state\n")
2132 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2134 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2135 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2139 DEFUN (no_ospf_log_adjacency_changes_detail
,
2140 no_ospf_log_adjacency_changes_detail_cmd
,
2141 "no log-adjacency-changes detail",
2143 "Log changes in adjacency state\n"
2144 "Log all state changes\n")
2146 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2148 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2152 DEFUN (ospf_compatible_rfc1583
,
2153 ospf_compatible_rfc1583_cmd
,
2154 "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 SET_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2163 ospf_spf_calculate_schedule (ospf
, SPF_FLAG_CONFIG_CHANGE
);
2168 DEFUN (no_ospf_compatible_rfc1583
,
2169 no_ospf_compatible_rfc1583_cmd
,
2170 "no compatible rfc1583",
2172 "OSPF compatibility list\n"
2173 "compatible with RFC 1583\n")
2175 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2177 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
2179 UNSET_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2180 ospf_spf_calculate_schedule (ospf
, SPF_FLAG_CONFIG_CHANGE
);
2185 ALIAS (ospf_compatible_rfc1583
,
2186 ospf_rfc1583_flag_cmd
,
2187 "ospf rfc1583compatibility",
2188 "OSPF specific commands\n"
2189 "Enable the RFC1583Compatibility flag\n")
2191 ALIAS (no_ospf_compatible_rfc1583
,
2192 no_ospf_rfc1583_flag_cmd
,
2193 "no ospf rfc1583compatibility",
2195 "OSPF specific commands\n"
2196 "Disable the RFC1583Compatibility flag\n")
2199 ospf_timers_spf_set (struct vty
*vty
, unsigned int delay
,
2203 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2205 ospf
->spf_delay
= delay
;
2206 ospf
->spf_holdtime
= hold
;
2207 ospf
->spf_max_holdtime
= max
;
2212 DEFUN (ospf_timers_min_ls_interval
,
2213 ospf_timers_min_ls_interval_cmd
,
2214 "timers throttle lsa all (0-5000)",
2215 "Adjust routing timers\n"
2216 "Throttling adaptive timer\n"
2217 "LSA delay between transmissions\n"
2219 "Delay (msec) between sending LSAs\n")
2221 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2223 unsigned int interval
;
2227 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2231 VTY_GET_INTEGER ("LSA interval", interval
, argv
[idx_number
]->arg
);
2233 ospf
->min_ls_interval
= interval
;
2238 DEFUN (no_ospf_timers_min_ls_interval
,
2239 no_ospf_timers_min_ls_interval_cmd
,
2240 "no timers throttle lsa all [(0-5000)]",
2242 "Adjust routing timers\n"
2243 "Throttling adaptive timer\n"
2244 "LSA delay between transmissions\n"
2246 "Delay (msec) between sending LSAs\n")
2248 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2249 ospf
->min_ls_interval
= OSPF_MIN_LS_INTERVAL
;
2255 DEFUN (ospf_timers_min_ls_arrival
,
2256 ospf_timers_min_ls_arrival_cmd
,
2257 "timers lsa arrival (0-1000)",
2258 "Adjust routing timers\n"
2259 "Throttling link state advertisement delays\n"
2260 "OSPF minimum arrival interval delay\n"
2261 "Delay (msec) between accepted LSAs\n")
2263 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2265 unsigned int arrival
;
2269 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2273 VTY_GET_INTEGER_RANGE ("minimum LSA inter-arrival time", arrival
, argv
[idx_number
]->arg
, 0, 1000);
2275 ospf
->min_ls_arrival
= arrival
;
2280 DEFUN (no_ospf_timers_min_ls_arrival
,
2281 no_ospf_timers_min_ls_arrival_cmd
,
2282 "no timers lsa arrival [(0-1000)]",
2284 "Adjust routing timers\n"
2285 "Throttling link state advertisement delays\n"
2286 "OSPF minimum arrival interval delay\n"
2287 "Delay (msec) between accepted LSAs\n")
2289 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2291 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2297 DEFUN (ospf_timers_throttle_spf
,
2298 ospf_timers_throttle_spf_cmd
,
2299 "timers throttle spf (0-600000) (0-600000) (0-600000)",
2300 "Adjust routing timers\n"
2301 "Throttling adaptive timer\n"
2303 "Delay (msec) from first change received till SPF calculation\n"
2304 "Initial hold time (msec) between consecutive SPF calculations\n"
2305 "Maximum hold time (msec)\n")
2308 int idx_number_2
= 4;
2309 int idx_number_3
= 5;
2310 unsigned int delay
, hold
, max
;
2314 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2318 VTY_GET_INTEGER_RANGE ("SPF delay timer", delay
, argv
[idx_number
]->arg
, 0, 600000);
2319 VTY_GET_INTEGER_RANGE ("SPF hold timer", hold
, argv
[idx_number_2
]->arg
, 0, 600000);
2320 VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max
, argv
[idx_number_3
]->arg
, 0, 600000);
2322 return ospf_timers_spf_set (vty
, delay
, hold
, max
);
2325 DEFUN (no_ospf_timers_throttle_spf
,
2326 no_ospf_timers_throttle_spf_cmd
,
2327 "no timers throttle spf [(0-600000)(0-600000)(0-600000)]",
2329 "Adjust routing timers\n"
2330 "Throttling adaptive timer\n"
2332 "Delay (msec) from first change received till SPF calculation\n"
2333 "Initial hold time (msec) between consecutive SPF calculations\n"
2334 "Maximum hold time (msec)\n")
2336 return ospf_timers_spf_set (vty
,
2337 OSPF_SPF_DELAY_DEFAULT
,
2338 OSPF_SPF_HOLDTIME_DEFAULT
,
2339 OSPF_SPF_MAX_HOLDTIME_DEFAULT
);
2343 DEFUN (ospf_timers_lsa
,
2344 ospf_timers_lsa_cmd
,
2345 "timers lsa min-arrival (0-600000)",
2346 "Adjust routing timers\n"
2348 "Minimum delay in receiving new version of a LSA\n"
2349 "Delay in milliseconds\n")
2351 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2353 unsigned int minarrival
;
2357 vty_out (vty
, "Insufficient number of arguments%s", VTY_NEWLINE
);
2361 VTY_GET_INTEGER ("LSA min-arrival", minarrival
, argv
[idx_number
]->arg
);
2363 ospf
->min_ls_arrival
= minarrival
;
2368 DEFUN (no_ospf_timers_lsa
,
2369 no_ospf_timers_lsa_cmd
,
2370 "no timers lsa min-arrival [(0-600000)]",
2372 "Adjust routing timers\n"
2374 "Minimum delay in receiving new version of a LSA\n"
2375 "Delay in milliseconds\n")
2377 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2378 unsigned int minarrival
;
2382 VTY_GET_INTEGER ("LSA min-arrival", minarrival
, argv
[4]->arg
);
2384 if (ospf
->min_ls_arrival
!= minarrival
||
2385 minarrival
== OSPF_MIN_LS_ARRIVAL
)
2389 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2394 DEFUN (ospf_neighbor
,
2396 "neighbor A.B.C.D [priority (0-255) [poll-interval (1-65535)]]",
2398 "Neighbor IP address\n"
2399 "Neighbor Priority\n"
2401 "Dead Neighbor Polling interval\n"
2404 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2408 struct in_addr nbr_addr
;
2409 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2410 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2412 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2415 VTY_GET_INTEGER_RANGE ("neighbor priority", priority
, argv
[idx_pri
]->arg
, 0, 255);
2418 VTY_GET_INTEGER_RANGE ("poll interval", interval
, argv
[idx_poll
]->arg
, 1, 65535);
2420 ospf_nbr_nbma_set (ospf
, nbr_addr
);
2423 ospf_nbr_nbma_priority_set (ospf
, nbr_addr
, priority
);
2426 ospf_nbr_nbma_poll_interval_set (ospf
, nbr_addr
, interval
);
2431 DEFUN (ospf_neighbor_poll_interval
,
2432 ospf_neighbor_poll_interval_cmd
,
2433 "neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2435 "Neighbor IP address\n"
2436 "Dead Neighbor Polling interval\n"
2438 "OSPF priority of non-broadcast neighbor\n"
2441 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2445 struct in_addr nbr_addr
;
2446 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2447 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2449 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2451 VTY_GET_INTEGER_RANGE ("poll interval", interval
, argv
[idx_poll
]->arg
, 1, 65535);
2454 VTY_GET_INTEGER_RANGE ("neighbor priority", priority
, argv
[idx_pri
]->arg
, 0, 255);
2456 ospf_nbr_nbma_set (ospf
, nbr_addr
);
2457 ospf_nbr_nbma_poll_interval_set (ospf
, nbr_addr
, interval
);
2460 ospf_nbr_nbma_priority_set (ospf
, nbr_addr
, priority
);
2465 DEFUN (no_ospf_neighbor
,
2466 no_ospf_neighbor_cmd
,
2467 "no neighbor A.B.C.D [priority (0-255) [poll-interval (1-65525)]]",
2470 "Neighbor IP address\n"
2471 "Neighbor Priority\n"
2473 "Dead Neighbor Polling interval\n"
2476 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2478 struct in_addr nbr_addr
;
2480 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2482 (void)ospf_nbr_nbma_unset (ospf
, nbr_addr
);
2487 DEFUN (no_ospf_neighbor_poll
,
2488 no_ospf_neighbor_poll_cmd
,
2489 "no neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2492 "Neighbor IP address\n"
2493 "Dead Neighbor Polling interval\n"
2495 "Neighbor Priority\n"
2498 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2500 struct in_addr nbr_addr
;
2502 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2504 (void)ospf_nbr_nbma_unset (ospf
, nbr_addr
);
2509 DEFUN (ospf_refresh_timer
,
2510 ospf_refresh_timer_cmd
,
2511 "refresh timer (10-1800)",
2512 "Adjust refresh parameters\n"
2513 "Set refresh timer\n"
2514 "Timer value in seconds\n")
2516 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2518 unsigned int interval
;
2520 VTY_GET_INTEGER_RANGE ("refresh timer", interval
, argv
[idx_number
]->arg
, 10, 1800);
2521 interval
= (interval
/ OSPF_LSA_REFRESHER_GRANULARITY
) * OSPF_LSA_REFRESHER_GRANULARITY
;
2523 ospf_timers_refresh_set (ospf
, interval
);
2528 DEFUN (no_ospf_refresh_timer
,
2529 no_ospf_refresh_timer_val_cmd
,
2530 "no refresh timer [(10-1800)]",
2532 "Adjust refresh parameters\n"
2533 "Unset refresh timer\n"
2534 "Timer value in seconds\n")
2536 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2538 unsigned int interval
;
2542 VTY_GET_INTEGER_RANGE ("refresh timer", interval
, argv
[idx_number
]->arg
, 10, 1800);
2544 if (ospf
->lsa_refresh_interval
!= interval
||
2545 interval
== OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
2549 ospf_timers_refresh_unset (ospf
);
2555 DEFUN (ospf_auto_cost_reference_bandwidth
,
2556 ospf_auto_cost_reference_bandwidth_cmd
,
2557 "auto-cost reference-bandwidth (1-4294967)",
2558 "Calculate OSPF interface cost according to bandwidth\n"
2559 "Use reference bandwidth method to assign OSPF cost\n"
2560 "The reference bandwidth in terms of Mbits per second\n")
2562 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2565 struct listnode
*node
;
2566 struct interface
*ifp
;
2568 refbw
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
2569 if (refbw
< 1 || refbw
> 4294967)
2571 vty_out (vty
, "reference-bandwidth value is invalid%s", VTY_NEWLINE
);
2575 /* If reference bandwidth is changed. */
2576 if ((refbw
) == ospf
->ref_bandwidth
)
2579 ospf
->ref_bandwidth
= refbw
;
2580 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, node
, ifp
))
2581 ospf_if_recalculate_output_cost (ifp
);
2586 DEFUN (no_ospf_auto_cost_reference_bandwidth
,
2587 no_ospf_auto_cost_reference_bandwidth_cmd
,
2588 "no auto-cost reference-bandwidth [(1-4294967)]",
2590 "Calculate OSPF interface cost according to bandwidth\n"
2591 "Use reference bandwidth method to assign OSPF cost\n"
2592 "The reference bandwidth in terms of Mbits per second\n")
2594 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2595 struct listnode
*node
, *nnode
;
2596 struct interface
*ifp
;
2598 if (ospf
->ref_bandwidth
== OSPF_DEFAULT_REF_BANDWIDTH
)
2601 ospf
->ref_bandwidth
= OSPF_DEFAULT_REF_BANDWIDTH
;
2602 vty_out (vty
, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE
);
2603 vty_out (vty
, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE
);
2605 for (ALL_LIST_ELEMENTS (om
->iflist
, node
, nnode
, ifp
))
2606 ospf_if_recalculate_output_cost (ifp
);
2611 DEFUN (ospf_write_multiplier
,
2612 ospf_write_multiplier_cmd
,
2613 "ospf write-multiplier (1-100)",
2614 "OSPF specific commands\n"
2615 "Write multiplier\n"
2616 "Maximum number of interface serviced per write\n")
2618 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2620 u_int32_t write_oi_count
;
2627 write_oi_count
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
2628 if (write_oi_count
< 1 || write_oi_count
> 100)
2630 vty_out (vty
, "write-multiplier value is invalid%s", VTY_NEWLINE
);
2634 ospf
->write_oi_count
= write_oi_count
;
2638 ALIAS (ospf_write_multiplier
,
2639 write_multiplier_cmd
,
2640 "write-multiplier (1-100)",
2641 "Write multiplier\n"
2642 "Maximum number of interface serviced per write\n")
2644 DEFUN (no_ospf_write_multiplier
,
2645 no_ospf_write_multiplier_cmd
,
2646 "no ospf write-multiplier (1-100)",
2648 "OSPF specific commands\n"
2649 "Write multiplier\n"
2650 "Maximum number of interface serviced per write\n")
2652 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2654 ospf
->write_oi_count
= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
;
2658 ALIAS (no_ospf_write_multiplier
,
2659 no_write_multiplier_cmd
,
2660 "no write-multiplier (1-100)",
2662 "Write multiplier\n"
2663 "Maximum number of interface serviced per write\n")
2665 const char *ospf_abr_type_descr_str
[] =
2668 "Standard (RFC2328)",
2670 "Alternative Cisco",
2671 "Alternative Shortcut"
2674 const char *ospf_shortcut_mode_descr_str
[] =
2682 show_ip_ospf_area (struct vty
*vty
, struct ospf_area
*area
, json_object
*json_areas
, u_char use_json
)
2684 json_object
*json_area
= NULL
;
2687 json_area
= json_object_new_object();
2691 vty_out (vty
, " Area ID: %s", inet_ntoa (area
->area_id
));
2693 /* Show Area type/mode. */
2694 if (OSPF_IS_AREA_BACKBONE (area
))
2697 json_object_boolean_true_add(json_area
, "backbone");
2699 vty_out (vty
, " (Backbone)%s", VTY_NEWLINE
);
2705 if (area
->external_routing
== OSPF_AREA_STUB
)
2707 if (area
->no_summary
)
2708 json_object_boolean_true_add(json_area
, "stubNoSummary");
2709 if (area
->shortcut_configured
)
2710 json_object_boolean_true_add(json_area
, "stubShortcut");
2712 else if (area
->external_routing
== OSPF_AREA_NSSA
)
2714 if (area
->no_summary
)
2715 json_object_boolean_true_add(json_area
, "nssaNoSummary");
2716 if (area
->shortcut_configured
)
2717 json_object_boolean_true_add(json_area
, "nssaShortcut");
2720 json_object_string_add(json_area
,"shortcuttingMode",
2721 ospf_shortcut_mode_descr_str
[area
->shortcut_configured
]);
2722 if (area
->shortcut_capability
)
2723 json_object_boolean_true_add(json_area
,"sBitConcensus");
2727 if (area
->external_routing
== OSPF_AREA_STUB
)
2728 vty_out (vty
, " (Stub%s%s)",
2729 area
->no_summary
? ", no summary" : "",
2730 area
->shortcut_configured
? "; " : "");
2731 else if (area
->external_routing
== OSPF_AREA_NSSA
)
2732 vty_out (vty
, " (NSSA%s%s)",
2733 area
->no_summary
? ", no summary" : "",
2734 area
->shortcut_configured
? "; " : "");
2736 vty_out (vty
, "%s", VTY_NEWLINE
);
2737 vty_out (vty
, " Shortcutting mode: %s",
2738 ospf_shortcut_mode_descr_str
[area
->shortcut_configured
]);
2739 vty_out (vty
, ", S-bit consensus: %s%s",
2740 area
->shortcut_capability
? "ok" : "no", VTY_NEWLINE
);
2744 /* Show number of interfaces */
2747 json_object_int_add(json_area
, "areaIfTotalCounter", listcount (area
->oiflist
));
2748 json_object_int_add(json_area
, "areaIfActiveCounter", area
->act_ints
);
2751 vty_out (vty
, " Number of interfaces in this area: Total: %d, "
2752 "Active: %d%s", listcount (area
->oiflist
),
2753 area
->act_ints
, VTY_NEWLINE
);
2755 if (area
->external_routing
== OSPF_AREA_NSSA
)
2759 json_object_boolean_true_add(json_area
, "nssa");
2760 if (! IS_OSPF_ABR (area
->ospf
))
2761 json_object_boolean_false_add(json_area
, "abr");
2762 else if (area
->NSSATranslatorState
)
2764 json_object_boolean_true_add(json_area
, "abr");
2765 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
2766 json_object_boolean_true_add(json_area
, "nssaTranslatorElected");
2767 else if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_ALWAYS
)
2768 json_object_boolean_true_add(json_area
, "nssaTranslatorAlways");
2772 json_object_boolean_true_add(json_area
, "abr");
2773 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
2774 json_object_boolean_false_add(json_area
, "nssaTranslatorElected");
2776 json_object_boolean_true_add(json_area
, "nssaTranslatorNever");
2781 vty_out (vty
, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE
, VTY_NEWLINE
);
2782 if (! IS_OSPF_ABR (area
->ospf
))
2783 vty_out (vty
, " It is not ABR, therefore not Translator. %s",
2785 else if (area
->NSSATranslatorState
)
2787 vty_out (vty
, " We are an ABR and ");
2788 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
2789 vty_out (vty
, "the NSSA Elected Translator. %s",
2791 else if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_ALWAYS
)
2792 vty_out (vty
, "always an NSSA Translator. %s",
2797 vty_out (vty
, " We are an ABR, but ");
2798 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
2799 vty_out (vty
, "not the NSSA Elected Translator. %s",
2802 vty_out (vty
, "never an NSSA Translator. %s",
2808 /* Stub-router state for this area */
2809 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
))
2811 char timebuf
[OSPF_TIME_DUMP_SIZE
];
2815 json_object_boolean_true_add(json_area
, "originStubMaxDistRouterLsa");
2816 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
2817 json_object_boolean_true_add(json_area
, "indefiniteActiveAdmin");
2818 if (area
->t_stub_router
)
2821 time_store
= monotime_until(&area
->t_stub_router
->u
.sands
, NULL
) / 1000LL;
2822 json_object_int_add(json_area
, "activeStartupRemainderMsecs", time_store
);
2827 vty_out (vty
, " Originating stub / maximum-distance Router-LSA%s",
2829 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
2830 vty_out (vty
, " Administratively activated (indefinitely)%s",
2832 if (area
->t_stub_router
)
2833 vty_out (vty
, " Active from startup, %s remaining%s",
2834 ospf_timer_dump (area
->t_stub_router
, timebuf
,
2835 sizeof(timebuf
)), VTY_NEWLINE
);
2841 /* Show number of fully adjacent neighbors. */
2842 json_object_int_add(json_area
, "nbrFullAdjacentCounter", area
->full_nbrs
);
2844 /* Show authentication type. */
2845 if (area
->auth_type
== OSPF_AUTH_NULL
)
2846 json_object_string_add(json_area
, "authentication", "authenticationNone");
2847 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
2848 json_object_string_add(json_area
, "authentication", "authenticationSimplePassword");
2849 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
2850 json_object_string_add(json_area
, "authentication", "authenticationMessageDigest");
2852 if (!OSPF_IS_AREA_BACKBONE (area
))
2853 json_object_int_add(json_area
, "virtualAdjacenciesPassingCounter", area
->full_vls
);
2855 /* Show SPF calculation times. */
2856 json_object_int_add(json_area
, "spfExecutedCounter", area
->spf_calculation
);
2857 json_object_int_add(json_area
, "lsaNumber", area
->lsdb
->total
);
2858 json_object_int_add(json_area
, "lsaRouterNumber", ospf_lsdb_count (area
->lsdb
, OSPF_ROUTER_LSA
));
2859 json_object_int_add(json_area
, "lsaRouterChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_ROUTER_LSA
));
2860 json_object_int_add(json_area
, "lsaNetworkNumber", ospf_lsdb_count (area
->lsdb
, OSPF_NETWORK_LSA
));
2861 json_object_int_add(json_area
, "lsaNetworkChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_NETWORK_LSA
));
2862 json_object_int_add(json_area
, "lsaSummaryNumber", ospf_lsdb_count (area
->lsdb
, OSPF_SUMMARY_LSA
));
2863 json_object_int_add(json_area
, "lsaSummaryChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_SUMMARY_LSA
));
2864 json_object_int_add(json_area
, "lsaAsbrNumber", ospf_lsdb_count (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2865 json_object_int_add(json_area
, "lsaAsbrChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2866 json_object_int_add(json_area
, "lsaNssaNumber", ospf_lsdb_count (area
->lsdb
, OSPF_AS_NSSA_LSA
));
2867 json_object_int_add(json_area
, "lsaNssaChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_AS_NSSA_LSA
));
2871 /* Show number of fully adjacent neighbors. */
2872 vty_out (vty
, " Number of fully adjacent neighbors in this area:"
2873 " %d%s", area
->full_nbrs
, VTY_NEWLINE
);
2875 /* Show authentication type. */
2876 vty_out (vty
, " Area has ");
2877 if (area
->auth_type
== OSPF_AUTH_NULL
)
2878 vty_out (vty
, "no authentication%s", VTY_NEWLINE
);
2879 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
2880 vty_out (vty
, "simple password authentication%s", VTY_NEWLINE
);
2881 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
2882 vty_out (vty
, "message digest authentication%s", VTY_NEWLINE
);
2884 if (!OSPF_IS_AREA_BACKBONE (area
))
2885 vty_out (vty
, " Number of full virtual adjacencies going through"
2886 " this area: %d%s", area
->full_vls
, VTY_NEWLINE
);
2888 /* Show SPF calculation times. */
2889 vty_out (vty
, " SPF algorithm executed %d times%s",
2890 area
->spf_calculation
, VTY_NEWLINE
);
2892 /* Show number of LSA. */
2893 vty_out (vty
, " Number of LSA %ld%s", area
->lsdb
->total
, VTY_NEWLINE
);
2894 vty_out (vty
, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
2895 ospf_lsdb_count (area
->lsdb
, OSPF_ROUTER_LSA
),
2896 ospf_lsdb_checksum (area
->lsdb
, OSPF_ROUTER_LSA
), VTY_NEWLINE
);
2897 vty_out (vty
, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
2898 ospf_lsdb_count (area
->lsdb
, OSPF_NETWORK_LSA
),
2899 ospf_lsdb_checksum (area
->lsdb
, OSPF_NETWORK_LSA
), VTY_NEWLINE
);
2900 vty_out (vty
, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
2901 ospf_lsdb_count (area
->lsdb
, OSPF_SUMMARY_LSA
),
2902 ospf_lsdb_checksum (area
->lsdb
, OSPF_SUMMARY_LSA
), VTY_NEWLINE
);
2903 vty_out (vty
, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
2904 ospf_lsdb_count (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
),
2905 ospf_lsdb_checksum (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
), VTY_NEWLINE
);
2906 vty_out (vty
, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
2907 ospf_lsdb_count (area
->lsdb
, OSPF_AS_NSSA_LSA
),
2908 ospf_lsdb_checksum (area
->lsdb
, OSPF_AS_NSSA_LSA
), VTY_NEWLINE
);
2913 json_object_int_add(json_area
, "lsaOpaqueLinkNumber", ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
2914 json_object_int_add(json_area
, "lsaOpaqueLinkChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
2915 json_object_int_add(json_area
, "lsaOpaqueAreaNumber", ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
2916 json_object_int_add(json_area
, "lsaOpaqueAreaChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
2920 vty_out (vty
, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
2921 ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
),
2922 ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
), VTY_NEWLINE
);
2923 vty_out (vty
, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
2924 ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
),
2925 ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
), VTY_NEWLINE
);
2929 json_object_object_add(json_areas
, inet_ntoa (area
->area_id
), json_area
);
2931 vty_out (vty
, "%s", VTY_NEWLINE
);
2935 show_ip_ospf_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
2937 struct listnode
*node
, *nnode
;
2938 struct ospf_area
* area
;
2939 struct timeval result
;
2940 char timebuf
[OSPF_TIME_DUMP_SIZE
];
2941 json_object
*json
= NULL
;
2942 json_object
*json_areas
= NULL
;
2946 json
= json_object_new_object();
2947 json_areas
= json_object_new_object();
2954 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
2958 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
2959 VTY_NEWLINE
, VTY_NEWLINE
);
2963 /* Show Router ID. */
2966 json_object_string_add(json
, "routerId", inet_ntoa (ospf
->router_id
));
2970 vty_out (vty
, " OSPF Routing Process, Router ID: %s%s",
2971 inet_ntoa (ospf
->router_id
),
2975 /* Graceful shutdown */
2976 if (ospf
->t_deferred_shutdown
)
2981 time_store
= monotime_until(&ospf
->t_deferred_shutdown
->u
.sands
, NULL
) / 1000LL;
2982 json_object_int_add(json
, "deferredShutdownMsecs", time_store
);
2986 vty_out (vty
, " Deferred shutdown in progress, %s remaining%s",
2987 ospf_timer_dump (ospf
->t_deferred_shutdown
,
2988 timebuf
, sizeof (timebuf
)), VTY_NEWLINE
);
2992 /* Show capability. */
2995 json_object_boolean_true_add(json
, "tosRoutesOnly");
2996 json_object_boolean_true_add(json
, "rfc2328Conform");
2997 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
2999 json_object_boolean_true_add(json
, "rfc1583Compatibility");
3004 vty_out (vty
, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE
);
3005 vty_out (vty
, " This implementation conforms to RFC2328%s", VTY_NEWLINE
);
3006 vty_out (vty
, " RFC1583Compatibility flag is %s%s",
3007 CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
) ?
3008 "enabled" : "disabled", VTY_NEWLINE
);
3013 if (CHECK_FLAG (ospf
->config
, OSPF_OPAQUE_CAPABLE
))
3015 json_object_boolean_true_add(json
, "opaqueCapable");
3020 vty_out (vty
, " OpaqueCapability flag is %s%s",
3021 CHECK_FLAG (ospf
->config
, OSPF_OPAQUE_CAPABLE
) ? "enabled" : "disabled",
3025 /* Show stub-router configuration */
3026 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
3027 || ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3031 json_object_boolean_true_add(json
, "stubAdvertisement");
3032 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3033 json_object_int_add(json
,"postStartEnabledMsecs", ospf
->stub_router_startup_time
/ 1000);
3034 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3035 json_object_int_add(json
,"preShutdownEnabledMsecs", ospf
->stub_router_shutdown_time
/ 1000);
3039 vty_out (vty
, " Stub router advertisement is configured%s",
3041 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3042 vty_out (vty
, " Enabled for %us after start-up%s",
3043 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
3044 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3045 vty_out (vty
, " Enabled for %us prior to full shutdown%s",
3046 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
3050 /* Show SPF timers. */
3053 json_object_int_add(json
, "spfScheduleDelayMsecs", ospf
->spf_delay
);
3054 json_object_int_add(json
, "holdtimeMinMsecs", ospf
->spf_holdtime
);
3055 json_object_int_add(json
, "holdtimeMaxMsecs", ospf
->spf_max_holdtime
);
3056 json_object_int_add(json
, "holdtimeMultplier", ospf
->spf_hold_multiplier
);
3060 vty_out (vty
, " Initial SPF scheduling delay %d millisec(s)%s"
3061 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
3062 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
3063 " Hold time multiplier is currently %d%s",
3064 ospf
->spf_delay
, VTY_NEWLINE
,
3065 ospf
->spf_holdtime
, VTY_NEWLINE
,
3066 ospf
->spf_max_holdtime
, VTY_NEWLINE
,
3067 ospf
->spf_hold_multiplier
, VTY_NEWLINE
);
3072 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
)
3074 long time_store
= 0;
3076 time_store
= monotime_since(&ospf
->ts_spf
, NULL
) / 1000LL;
3077 json_object_int_add(json
, "spfLastExecutedMsecs", time_store
);
3079 time_store
= (1000 * ospf
->ts_spf_duration
.tv_sec
) + (ospf
->ts_spf_duration
.tv_usec
/ 1000);
3080 json_object_int_add(json
, "spfLastDurationMsecs", time_store
);
3083 json_object_boolean_true_add(json
, "spfHasNotRun");
3087 vty_out (vty
, " SPF algorithm ");
3088 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
)
3090 monotime_since(&ospf
->ts_spf
, &result
);
3091 vty_out (vty
, "last executed %s ago%s",
3092 ospf_timeval_dump (&result
, timebuf
, sizeof (timebuf
)),
3094 vty_out (vty
, " Last SPF duration %s%s",
3095 ospf_timeval_dump (&ospf
->ts_spf_duration
, timebuf
, sizeof (timebuf
)),
3099 vty_out (vty
, "has not been run%s", VTY_NEWLINE
);
3104 if (ospf
->t_spf_calc
)
3107 time_store
= monotime_until(&ospf
->t_spf_calc
->u
.sands
, NULL
) / 1000LL;
3108 json_object_int_add(json
, "spfTimerDueInMsecs", time_store
);
3111 json_object_int_add(json
, "lsaMinIntervalMsecs", ospf
->min_ls_interval
);
3112 json_object_int_add(json
, "lsaMinArrivalMsecs", ospf
->min_ls_arrival
);
3113 /* Show write multiplier values */
3114 json_object_int_add(json
, "writeMultiplier", ospf
->write_oi_count
);
3115 /* Show refresh parameters. */
3116 json_object_int_add(json
, "refreshTimerMsecs", ospf
->lsa_refresh_interval
* 1000);
3120 vty_out (vty
, " SPF timer %s%s%s",
3121 (ospf
->t_spf_calc
? "due in " : "is "),
3122 ospf_timer_dump (ospf
->t_spf_calc
, timebuf
, sizeof (timebuf
)),
3125 vty_out (vty
, " LSA minimum interval %d msecs%s",
3126 ospf
->min_ls_interval
, VTY_NEWLINE
);
3127 vty_out (vty
, " LSA minimum arrival %d msecs%s",
3128 ospf
->min_ls_arrival
, VTY_NEWLINE
);
3130 /* Show write multiplier values */
3131 vty_out (vty
, " Write Multiplier set to %d %s",
3132 ospf
->write_oi_count
, VTY_NEWLINE
);
3134 /* Show refresh parameters. */
3135 vty_out (vty
, " Refresh timer %d secs%s",
3136 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
3139 /* Show ABR/ASBR flags. */
3140 if (CHECK_FLAG (ospf
->flags
, OSPF_FLAG_ABR
))
3143 json_object_string_add(json
, "abrType", ospf_abr_type_descr_str
[ospf
->abr_type
]);
3145 vty_out (vty
, " This router is an ABR, ABR type is: %s%s",
3146 ospf_abr_type_descr_str
[ospf
->abr_type
], VTY_NEWLINE
);
3148 if (CHECK_FLAG (ospf
->flags
, OSPF_FLAG_ASBR
))
3151 json_object_string_add(json
, "asbrRouter", "injectingExternalRoutingInformation");
3153 vty_out (vty
, " This router is an ASBR "
3154 "(injecting external routing information)%s", VTY_NEWLINE
);
3157 /* Show Number of AS-external-LSAs. */
3160 json_object_int_add(json
, "lsaExternalCounter",
3161 ospf_lsdb_count (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3162 json_object_int_add(json
, "lsaExternalChecksum",
3163 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3167 vty_out (vty
, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
3168 ospf_lsdb_count (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
),
3169 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
), VTY_NEWLINE
);
3174 json_object_int_add(json
, "lsaAsopaqueCounter",
3175 ospf_lsdb_count (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3176 json_object_int_add(json
, "lsaAsOpaqueChecksum",
3177 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3181 vty_out (vty
, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
3182 ospf_lsdb_count (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
),
3183 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
), VTY_NEWLINE
);
3186 /* Show number of areas attached. */
3188 json_object_int_add(json
, "attachedAreaCounter", listcount (ospf
->areas
));
3190 vty_out (vty
, " Number of areas attached to this router: %d%s",
3191 listcount (ospf
->areas
), VTY_NEWLINE
);
3193 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
))
3195 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
3198 json_object_boolean_true_add(json
, "adjacencyChangesLoggedAll");
3200 vty_out(vty
, " All adjacency changes are logged%s",VTY_NEWLINE
);
3205 json_object_boolean_true_add(json
, "adjacencyChangesLogged");
3207 vty_out(vty
, " Adjacency changes are logged%s",VTY_NEWLINE
);
3210 /* Show each area status. */
3211 for (ALL_LIST_ELEMENTS (ospf
->areas
, node
, nnode
, area
))
3212 show_ip_ospf_area (vty
, area
, json_areas
, use_json
);
3216 json_object_object_add(json
, "areas", json_areas
);
3217 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3218 json_object_free(json
);
3221 vty_out (vty
, "%s",VTY_NEWLINE
);
3226 DEFUN (show_ip_ospf
,
3228 "show ip ospf [json]",
3231 "OSPF information\n"
3235 u_char uj
= use_json(argc
, argv
);
3237 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3240 return (show_ip_ospf_common(vty
, ospf
, uj
));
3243 DEFUN (show_ip_ospf_instance
,
3244 show_ip_ospf_instance_cmd
,
3245 "show ip ospf (1-65535) [json]",
3248 "OSPF information\n"
3254 u_short instance
= 0;
3255 u_char uj
= use_json(argc
, argv
);
3257 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3258 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
3261 return (show_ip_ospf_common(vty
, ospf
, uj
));
3265 show_ip_ospf_interface_sub (struct vty
*vty
, struct ospf
*ospf
, struct interface
*ifp
,
3266 json_object
*json_interface_sub
, u_char use_json
)
3269 struct ospf_neighbor
*nbr
;
3270 struct route_node
*rn
;
3272 /* Is interface up? */
3275 is_up
= if_is_operative(ifp
);
3277 json_object_boolean_true_add(json_interface_sub
, "ifUp");
3279 json_object_boolean_false_add(json_interface_sub
, "ifDown");
3281 json_object_int_add(json_interface_sub
, "ifIndex", ifp
->ifindex
);
3282 json_object_int_add(json_interface_sub
, "mtuBytes", ifp
->mtu
);
3283 json_object_int_add(json_interface_sub
, "bandwidthMbit", ifp
->bandwidth
);
3284 json_object_string_add(json_interface_sub
, "ifFlags", if_flag_dump(ifp
->flags
));
3288 vty_out (vty
, "%s is %s%s", ifp
->name
,
3289 ((is_up
= if_is_operative(ifp
)) ? "up" : "down"), VTY_NEWLINE
);
3290 vty_out (vty
, " ifindex %u, MTU %u bytes, BW %u Mbit %s%s",
3291 ifp
->ifindex
, ifp
->mtu
, ifp
->bandwidth
, if_flag_dump(ifp
->flags
),
3295 /* Is interface OSPF enabled? */
3298 if (ospf_oi_count(ifp
) == 0)
3300 json_object_boolean_false_add(json_interface_sub
, "ospfEnabled");
3305 json_object_boolean_false_add(json_interface_sub
, "ospfRunning");
3309 json_object_boolean_true_add(json_interface_sub
, "ospfEnabled");
3313 if (ospf_oi_count(ifp
) == 0)
3315 vty_out (vty
, " OSPF not enabled on this interface%s", VTY_NEWLINE
);
3320 vty_out (vty
, " OSPF is enabled, but not running on this interface%s",
3326 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
3328 struct ospf_interface
*oi
= rn
->info
;
3333 if (CHECK_FLAG(oi
->connected
->flags
, ZEBRA_IFA_UNNUMBERED
))
3336 json_object_boolean_true_add(json_interface_sub
, "ifUnnumbered");
3338 vty_out (vty
, " This interface is UNNUMBERED,");
3342 /* Show OSPF interface information. */
3345 json_object_string_add(json_interface_sub
, "ipAddress", inet_ntoa (oi
->address
->u
.prefix4
));
3346 json_object_int_add(json_interface_sub
, "ipAddressPrefixlen", oi
->address
->prefixlen
);
3349 vty_out (vty
, " Internet Address %s/%d,",
3350 inet_ntoa (oi
->address
->u
.prefix4
), oi
->address
->prefixlen
);
3352 if (oi
->connected
->destination
|| oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3354 struct in_addr
*dest
;
3357 if (CONNECTED_PEER(oi
->connected
)
3358 || oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3363 /* For Vlinks, showing the peer address is probably more
3364 * * * * * informative than the local interface that is being used
3366 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3367 dest
= &oi
->vl_data
->peer_addr
;
3369 dest
= &oi
->connected
->destination
->u
.prefix4
;
3373 json_object_string_add(json_interface_sub
, "ospfIfType", dstr
);
3374 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3375 json_object_string_add(json_interface_sub
, "vlinkPeer", inet_ntoa (*dest
));
3377 json_object_string_add(json_interface_sub
, "localIfUsed", inet_ntoa (*dest
));
3380 vty_out (vty
, " %s %s,", dstr
, inet_ntoa (*dest
));
3385 json_object_string_add(json_interface_sub
, "area", ospf_area_desc_string (oi
->area
));
3386 if (OSPF_IF_PARAM(oi
, mtu_ignore
))
3387 json_object_boolean_true_add(json_interface_sub
, "mtuMismatchDetect");
3388 json_object_string_add(json_interface_sub
, "routerId", inet_ntoa (ospf
->router_id
));
3389 json_object_string_add(json_interface_sub
, "networkType", ospf_network_type_str
[oi
->type
]);
3390 json_object_int_add(json_interface_sub
, "cost", oi
->output_cost
);
3391 json_object_int_add(json_interface_sub
, "transmitDelayMsecs", 1000 / OSPF_IF_PARAM (oi
,transmit_delay
));
3392 json_object_string_add(json_interface_sub
, "state", LOOKUP (ospf_ism_state_msg
, oi
->state
));
3393 json_object_int_add(json_interface_sub
, "priority", PRIORITY (oi
));
3397 vty_out (vty
, " Area %s%s", ospf_area_desc_string (oi
->area
),
3400 vty_out (vty
, " MTU mismatch detection:%s%s",
3401 OSPF_IF_PARAM(oi
, mtu_ignore
) ? "disabled" : "enabled", VTY_NEWLINE
);
3403 vty_out (vty
, " Router ID %s, Network Type %s, Cost: %d%s",
3404 inet_ntoa (ospf
->router_id
), ospf_network_type_str
[oi
->type
],
3405 oi
->output_cost
, VTY_NEWLINE
);
3407 vty_out (vty
, " Transmit Delay is %d sec, State %s, Priority %d%s",
3408 OSPF_IF_PARAM (oi
,transmit_delay
), LOOKUP (ospf_ism_state_msg
, oi
->state
),
3409 PRIORITY (oi
), VTY_NEWLINE
);
3412 /* Show DR information. */
3413 if (DR (oi
).s_addr
== 0)
3416 vty_out (vty
, " No backup designated router on this network%s",
3421 nbr
= ospf_nbr_lookup_by_addr (oi
->nbrs
, &BDR (oi
));
3425 vty_out (vty
, " No backup designated router on this network%s",
3432 json_object_string_add(json_interface_sub
, "bdrId", inet_ntoa (nbr
->router_id
));
3433 json_object_string_add(json_interface_sub
, "bdrAddress", inet_ntoa (nbr
->address
.u
.prefix4
));
3437 vty_out (vty
, " Backup Designated Router (ID) %s,",
3438 inet_ntoa (nbr
->router_id
));
3439 vty_out (vty
, " Interface Address %s%s",
3440 inet_ntoa (nbr
->address
.u
.prefix4
), VTY_NEWLINE
);
3445 /* Next network-LSA sequence number we'll use, if we're elected DR */
3446 if (oi
->params
&& ntohl (oi
->params
->network_lsa_seqnum
) != OSPF_INITIAL_SEQUENCE_NUMBER
)
3449 json_object_int_add(json_interface_sub
, "networkLsaSequence", ntohl (oi
->params
->network_lsa_seqnum
));
3451 vty_out (vty
, " Saved Network-LSA sequence number 0x%x%s",
3452 ntohl (oi
->params
->network_lsa_seqnum
), VTY_NEWLINE
);
3457 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3458 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3460 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3461 json_object_boolean_true_add(json_interface_sub
, "mcastMemberOspfAllRouters");
3462 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3463 json_object_boolean_true_add(json_interface_sub
, "mcastMemberOspfDesignatedRouters");
3468 vty_out (vty
, " Multicast group memberships:");
3469 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3470 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3472 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3473 vty_out (vty
, " OSPFAllRouters");
3474 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3475 vty_out (vty
, " OSPFDesignatedRouters");
3478 vty_out (vty
, " <None>");
3479 vty_out (vty
, "%s", VTY_NEWLINE
);
3484 if (OSPF_IF_PARAM (oi
, fast_hello
) == 0)
3485 json_object_int_add(json_interface_sub
, "timerMsecs", 1000 /OSPF_IF_PARAM (oi
, v_hello
));
3487 json_object_int_add(json_interface_sub
, "timerMsecs", 1000 / OSPF_IF_PARAM (oi
, fast_hello
));
3488 json_object_int_add(json_interface_sub
, "timerDeadMsecs", 1000 / OSPF_IF_PARAM (oi
, v_wait
));
3489 json_object_int_add(json_interface_sub
, "timerWaitMsecs", 1000 / OSPF_IF_PARAM (oi
, v_wait
));
3490 json_object_int_add(json_interface_sub
, "timerRetransmit", 1000 / OSPF_IF_PARAM (oi
, retransmit_interval
));
3494 vty_out (vty
, " Timer intervals configured,");
3495 vty_out (vty
, " Hello ");
3496 if (OSPF_IF_PARAM (oi
, fast_hello
) == 0)
3497 vty_out (vty
, "%ds,", OSPF_IF_PARAM (oi
, v_hello
));
3499 vty_out (vty
, "%dms,", 1000 / OSPF_IF_PARAM (oi
, fast_hello
));
3500 vty_out (vty
, " Dead %ds, Wait %ds, Retransmit %d%s",
3501 OSPF_IF_PARAM (oi
, v_wait
),
3502 OSPF_IF_PARAM (oi
, v_wait
),
3503 OSPF_IF_PARAM (oi
, retransmit_interval
),
3507 if (OSPF_IF_PASSIVE_STATUS (oi
) == OSPF_IF_ACTIVE
)
3509 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3512 long time_store
= 0;
3514 time_store
= monotime_until(&oi
->t_hello
->u
.sands
, NULL
) / 1000LL;
3515 json_object_int_add(json_interface_sub
, "timerHelloInMsecs", time_store
);
3518 vty_out (vty
, " Hello due in %s%s",
3519 ospf_timer_dump (oi
->t_hello
, timebuf
, sizeof(timebuf
)),
3522 else /* passive-interface is set */
3525 json_object_boolean_true_add(json_interface_sub
, "timerPassiveIface");
3527 vty_out (vty
, " No Hellos (Passive interface)%s", VTY_NEWLINE
);
3532 json_object_int_add(json_interface_sub
, "nbrCount", ospf_nbr_count (oi
, 0));
3533 json_object_int_add(json_interface_sub
, "nbrAdjacentCount", ospf_nbr_count (oi
, NSM_Full
));
3536 vty_out (vty
, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
3537 ospf_nbr_count (oi
, 0), ospf_nbr_count (oi
, NSM_Full
),
3539 ospf_bfd_interface_show(vty
, ifp
, json_interface_sub
, use_json
);
3544 show_ip_ospf_interface_common (struct vty
*vty
, struct ospf
*ospf
, int argc
,
3545 struct cmd_token
**argv
, int iface_argv
, u_char use_json
)
3547 struct interface
*ifp
;
3548 struct listnode
*node
;
3549 json_object
*json
= NULL
;
3550 json_object
*json_interface_sub
= NULL
;
3554 json
= json_object_new_object();
3555 json_interface_sub
= json_object_new_object();
3561 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3563 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3564 VTY_NEWLINE
, VTY_NEWLINE
);
3567 if (argc
== iface_argv
)
3569 /* Show All Interfaces.*/
3570 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
3572 if (ospf_oi_count(ifp
))
3574 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3576 json_object_object_add (json
, ifp
->name
, json_interface_sub
);
3582 /* Interface name is specified. */
3583 if ((ifp
= if_lookup_by_name (argv
[iface_argv
]->arg
, VRF_DEFAULT
)) == NULL
)
3586 json_object_boolean_true_add(json
, "noSuchIface");
3588 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
3592 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3594 json_object_object_add(json
, ifp
->name
, json_interface_sub
);
3600 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3601 json_object_free(json
);
3604 vty_out (vty
, "%s", VTY_NEWLINE
);
3609 DEFUN (show_ip_ospf_interface
,
3610 show_ip_ospf_interface_cmd
,
3611 "show ip ospf interface [INTERFACE] [json]",
3614 "OSPF information\n"
3615 "Interface information\n"
3620 u_char uj
= use_json(argc
, argv
);
3622 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3628 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 4, uj
);
3631 DEFUN (show_ip_ospf_instance_interface
,
3632 show_ip_ospf_instance_interface_cmd
,
3633 "show ip ospf (1-65535) interface [INTERFACE] [json]",
3636 "OSPF information\n"
3638 "Interface information\n"
3644 u_short instance
= 0;
3645 u_char uj
= use_json(argc
, argv
);
3647 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3648 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
3654 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 5, uj
);
3658 show_ip_ospf_neighbour_header (struct vty
*vty
)
3660 vty_out (vty
, "%s%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
3662 "Neighbor ID", "Pri", "State", "Dead Time",
3663 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
3668 show_ip_ospf_neighbor_sub (struct vty
*vty
, struct ospf_interface
*oi
, json_object
*json
, u_char use_json
)
3670 struct route_node
*rn
;
3671 struct ospf_neighbor
*nbr
;
3673 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3674 json_object
*json_neighbor
= NULL
;
3676 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
3678 if ((nbr
= rn
->info
))
3680 /* Do not show myself. */
3681 if (nbr
!= oi
->nbr_self
)
3683 /* Down state is not shown. */
3684 if (nbr
->state
!= NSM_Down
)
3688 json_neighbor
= json_object_new_object();
3689 ospf_nbr_state_message (nbr
, msgbuf
, 16);
3693 time_store
= monotime_until(&nbr
->t_inactivity
->u
.sands
, NULL
) / 1000LL;
3695 json_object_int_add (json_neighbor
, "priority", nbr
->priority
);
3696 json_object_string_add (json_neighbor
, "state", msgbuf
);
3697 json_object_int_add (json_neighbor
, "deadTimeMsecs", time_store
);
3698 json_object_string_add (json_neighbor
, "address", inet_ntoa (nbr
->src
));
3699 json_object_string_add (json_neighbor
, "ifaceName", IF_NAME (oi
));
3700 json_object_int_add (json_neighbor
, "retransmitCounter", ospf_ls_retransmit_count (nbr
));
3701 json_object_int_add (json_neighbor
, "requestCounter", ospf_ls_request_count (nbr
));
3702 json_object_int_add (json_neighbor
, "dbSummaryCounter", ospf_db_summary_count (nbr
));
3703 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
3704 json_object_object_add(json
, "neighbor", json_neighbor
);
3706 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_neighbor
);
3710 ospf_nbr_state_message (nbr
, msgbuf
, 16);
3712 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
3713 vty_out (vty
, "%-15s %3d %-15s ",
3717 vty_out (vty
, "%-15s %3d %-15s ",
3718 inet_ntoa (nbr
->router_id
), nbr
->priority
,
3721 vty_out (vty
, "%9s ",
3722 ospf_timer_dump (nbr
->t_inactivity
, timebuf
,
3724 vty_out (vty
, "%-15s ", inet_ntoa (nbr
->src
));
3725 vty_out (vty
, "%-20s %5ld %5ld %5d%s",
3726 IF_NAME (oi
), ospf_ls_retransmit_count (nbr
),
3727 ospf_ls_request_count (nbr
), ospf_db_summary_count (nbr
),
3737 show_ip_ospf_neighbor_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
3739 struct ospf_interface
*oi
;
3740 struct listnode
*node
;
3741 json_object
*json
= NULL
;
3744 json
= json_object_new_object();
3746 show_ip_ospf_neighbour_header (vty
);
3751 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3753 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3754 VTY_NEWLINE
, VTY_NEWLINE
);
3757 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
3758 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
3762 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3763 json_object_free(json
);
3766 vty_out (vty
, "%s", VTY_NEWLINE
);
3771 DEFUN (show_ip_ospf_neighbor
,
3772 show_ip_ospf_neighbor_cmd
,
3773 "show ip ospf neighbor [json]",
3776 "OSPF information\n"
3781 u_char uj
= use_json(argc
, argv
);
3783 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3786 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
3790 DEFUN (show_ip_ospf_instance_neighbor
,
3791 show_ip_ospf_instance_neighbor_cmd
,
3792 "show ip ospf (1-65535) neighbor [json]",
3795 "OSPF information\n"
3802 u_short instance
= 0;
3803 u_char uj
= use_json(argc
, argv
);
3805 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3806 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
3809 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
3813 show_ip_ospf_neighbor_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
3815 struct listnode
*node
;
3816 struct ospf_interface
*oi
;
3817 json_object
*json
= NULL
;
3818 json_object
*json_neighbor_sub
= NULL
;
3822 json
= json_object_new_object();
3823 json_neighbor_sub
= json_object_new_object();
3826 show_ip_ospf_neighbour_header (vty
);
3831 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3833 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3834 VTY_NEWLINE
, VTY_NEWLINE
);
3837 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
3839 struct listnode
*nbr_node
;
3840 struct ospf_nbr_nbma
*nbr_nbma
;
3842 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
3844 /* print Down neighbor status */
3845 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nbr_node
, nbr_nbma
))
3847 if (nbr_nbma
->nbr
== NULL
3848 || nbr_nbma
->nbr
->state
== NSM_Down
)
3852 json_object_int_add (json_neighbor_sub
, "nbrNbmaPriority", nbr_nbma
->priority
);
3853 json_object_boolean_true_add (json_neighbor_sub
, "nbrNbmaDown");
3854 json_object_string_add (json_neighbor_sub
, "nbrNbmaIfaceName", IF_NAME (oi
));
3855 json_object_int_add (json_neighbor_sub
, "nbrNbmaRetransmitCounter", 0);
3856 json_object_int_add (json_neighbor_sub
, "nbrNbmaRequestCounter", 0);
3857 json_object_int_add (json_neighbor_sub
, "nbrNbmaDbSummaryCounter", 0);
3858 json_object_object_add(json
, inet_ntoa (nbr_nbma
->addr
), json_neighbor_sub
);
3862 vty_out (vty
, "%-15s %3d %-15s %9s ",
3863 "-", nbr_nbma
->priority
, "Down", "-");
3864 vty_out (vty
, "%-15s %-20s %5d %5d %5d%s",
3865 inet_ntoa (nbr_nbma
->addr
), IF_NAME (oi
),
3866 0, 0, 0, VTY_NEWLINE
);
3874 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3875 json_object_free(json
);
3878 vty_out (vty
, "%s", VTY_NEWLINE
);
3883 DEFUN (show_ip_ospf_neighbor_all
,
3884 show_ip_ospf_neighbor_all_cmd
,
3885 "show ip ospf neighbor all [json]",
3888 "OSPF information\n"
3890 "include down status neighbor\n"
3894 u_char uj
= use_json(argc
, argv
);
3896 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3899 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
3902 DEFUN (show_ip_ospf_instance_neighbor_all
,
3903 show_ip_ospf_instance_neighbor_all_cmd
,
3904 "show ip ospf (1-65535) neighbor all [json]",
3907 "OSPF information\n"
3910 "include down status neighbor\n"
3915 u_short instance
= 0;
3916 u_char uj
= use_json(argc
, argv
);
3918 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3919 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
3922 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
3926 show_ip_ospf_neighbor_int_common (struct vty
*vty
, struct ospf
*ospf
, int arg_base
,
3927 struct cmd_token
**argv
, u_char use_json
)
3929 struct interface
*ifp
;
3930 struct route_node
*rn
;
3931 json_object
*json
= NULL
;
3934 json
= json_object_new_object();
3936 show_ip_ospf_neighbour_header (vty
);
3941 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3943 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3944 VTY_NEWLINE
, VTY_NEWLINE
);
3947 ifp
= if_lookup_by_name (argv
[arg_base
]->arg
, VRF_DEFAULT
);
3951 json_object_boolean_true_add(json
, "noSuchIface");
3953 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
3957 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
3959 struct ospf_interface
*oi
= rn
->info
;
3964 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
3969 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3970 json_object_free(json
);
3973 vty_out (vty
, "%s", VTY_NEWLINE
);
3978 DEFUN (show_ip_ospf_neighbor_int
,
3979 show_ip_ospf_neighbor_int_cmd
,
3980 "show ip ospf neighbor IFNAME [json]",
3983 "OSPF information\n"
3989 u_char uj
= use_json(argc
, argv
);
3991 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3994 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 0, argv
, uj
);
3997 DEFUN (show_ip_ospf_instance_neighbor_int
,
3998 show_ip_ospf_instance_neighbor_int_cmd
,
3999 "show ip ospf (1-65535) neighbor IFNAME [json]",
4002 "OSPF information\n"
4010 u_short instance
= 0;
4011 u_char uj
= use_json(argc
, argv
);
4013 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4014 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4017 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 1, argv
, uj
);
4021 show_ip_ospf_nbr_nbma_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
, struct ospf_nbr_nbma
*nbr_nbma
,
4022 u_char use_json
, json_object
*json
)
4024 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4025 json_object
*json_sub
= NULL
;
4028 json_sub
= json_object_new_object();
4029 else /* Show neighbor ID. */
4030 vty_out (vty
, " Neighbor %s,", "-");
4032 /* Show interface address. */
4034 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr_nbma
->addr
));
4036 vty_out (vty
, " interface address %s%s",
4037 inet_ntoa (nbr_nbma
->addr
), VTY_NEWLINE
);
4042 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4043 json_object_string_add(json_sub
, "iface", IF_NAME (oi
));
4046 vty_out (vty
, " In the area %s via interface %s%s",
4047 ospf_area_desc_string (oi
->area
), IF_NAME (oi
), VTY_NEWLINE
);
4049 /* Show neighbor priority and state. */
4052 json_object_int_add(json_sub
, "nbrPriority", nbr_nbma
->priority
);
4053 json_object_string_add(json_sub
, "nbrState", "down");
4056 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4057 nbr_nbma
->priority
, "Down");
4059 /* Show state changes. */
4061 json_object_int_add(json_sub
, "stateChangeCounter", nbr_nbma
->state_change
);
4063 vty_out (vty
, " %d state changes%s", nbr_nbma
->state_change
, VTY_NEWLINE
);
4065 /* Show PollInterval */
4067 json_object_int_add(json_sub
, "pollInterval", nbr_nbma
->v_poll
);
4069 vty_out (vty
, " Poll interval %d%s", nbr_nbma
->v_poll
, VTY_NEWLINE
);
4071 /* Show poll-interval timer. */
4075 time_store
= monotime_until(&nbr_nbma
->t_poll
->u
.sands
, NULL
) / 1000LL;
4076 json_object_int_add(json_sub
, "pollIntervalTimerDueMsec", time_store
);
4079 vty_out (vty
, " Poll timer due in %s%s",
4080 ospf_timer_dump (nbr_nbma
->t_poll
, timebuf
, sizeof(timebuf
)),
4083 /* Show poll-interval timer thread. */
4086 if (nbr_nbma
->t_poll
!= NULL
)
4087 json_object_string_add(json_sub
, "pollIntervalTimerThread", "on");
4090 vty_out (vty
, " Thread Poll Timer %s%s",
4091 nbr_nbma
->t_poll
!= NULL
? "on" : "off", VTY_NEWLINE
);
4094 json_object_object_add(json
, "noNbrId", json_sub
);
4098 show_ip_ospf_neighbor_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
,
4099 struct ospf_neighbor
*nbr
, u_char use_json
, json_object
*json
)
4101 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4102 json_object
*json_sub
= NULL
;
4105 json_sub
= json_object_new_object();
4108 /* Show neighbor ID. */
4109 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4110 vty_out (vty
, " Neighbor %s,", "-");
4112 vty_out (vty
, " Neighbor %s,", inet_ntoa (nbr
->router_id
));
4115 /* Show interface address. */
4117 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr
->address
.u
.prefix4
));
4119 vty_out (vty
, " interface address %s%s",
4120 inet_ntoa (nbr
->address
.u
.prefix4
), VTY_NEWLINE
);
4125 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4126 json_object_string_add(json_sub
, "ifaceName", oi
->ifp
->name
);
4129 vty_out (vty
, " In the area %s via interface %s%s",
4130 ospf_area_desc_string (oi
->area
), oi
->ifp
->name
, VTY_NEWLINE
);
4132 /* Show neighbor priority and state. */
4135 json_object_int_add(json_sub
, "nbrPriority", nbr
->priority
);
4136 json_object_string_add(json_sub
, "nbrState", LOOKUP (ospf_nsm_state_msg
, nbr
->state
));
4139 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4140 nbr
->priority
, LOOKUP (ospf_nsm_state_msg
, nbr
->state
));
4142 /* Show state changes. */
4144 json_object_int_add(json_sub
, "stateChangeCounter", nbr
->state_change
);
4146 vty_out (vty
, " %d state changes%s", nbr
->state_change
, VTY_NEWLINE
);
4148 if (nbr
->ts_last_progress
.tv_sec
|| nbr
->ts_last_progress
.tv_usec
)
4153 time_store
= monotime_since(&nbr
->ts_last_progress
, &res
) / 1000LL;
4156 json_object_int_add(json_sub
, "lastPrgrsvChangeMsec", time_store
);
4160 vty_out (vty
, " Most recent state change statistics:%s",
4162 vty_out (vty
, " Progressive change %s ago%s",
4163 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4168 if (nbr
->ts_last_regress
.tv_sec
|| nbr
->ts_last_regress
.tv_usec
)
4173 time_store
= monotime_since(&nbr
->ts_last_regress
, &res
) / 1000LL;
4176 json_object_int_add(json_sub
, "lastRegressiveChangeMsec", time_store
);
4177 if (nbr
->last_regress_str
)
4178 json_object_string_add(json_sub
, "lastRegressiveChangeReason", nbr
->last_regress_str
);
4182 vty_out (vty
, " Regressive change %s ago, due to %s%s",
4183 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4184 (nbr
->last_regress_str
? nbr
->last_regress_str
: "??"),
4189 /* Show Designated Rotuer ID. */
4191 json_object_string_add(json_sub
, "routerDesignatedId", inet_ntoa (nbr
->d_router
));
4193 vty_out (vty
, " DR is %s,", inet_ntoa (nbr
->d_router
));
4195 /* Show Backup Designated Rotuer ID. */
4197 json_object_string_add(json_sub
, "routerDesignatedBackupId", inet_ntoa (nbr
->bd_router
));
4199 vty_out (vty
, " BDR is %s%s", inet_ntoa (nbr
->bd_router
), VTY_NEWLINE
);
4204 json_object_int_add(json_sub
, "optionsCounter", nbr
->options
);
4205 json_object_string_add(json_sub
, "optionsList", ospf_options_dump (nbr
->options
));
4208 vty_out (vty
, " Options %d %s%s", nbr
->options
,
4209 ospf_options_dump (nbr
->options
), VTY_NEWLINE
);
4211 /* Show Router Dead interval timer. */
4214 if (nbr
->t_inactivity
)
4217 time_store
= monotime_until(&nbr
->t_inactivity
->u
.sands
, NULL
) / 1000LL;
4218 json_object_int_add(json_sub
, "routerDeadIntervalTimerDueMsec", time_store
);
4221 json_object_int_add(json_sub
, "routerDeadIntervalTimerDueMsec", -1);
4224 vty_out (vty
, " Dead timer due in %s%s",
4225 ospf_timer_dump (nbr
->t_inactivity
, timebuf
, sizeof (timebuf
)),
4228 /* Show Database Summary list. */
4230 json_object_int_add(json_sub
, "databaseSummaryListCounter", ospf_db_summary_count (nbr
));
4232 vty_out (vty
, " Database Summary List %d%s",
4233 ospf_db_summary_count (nbr
), VTY_NEWLINE
);
4235 /* Show Link State Request list. */
4237 json_object_int_add(json_sub
, "linkStateRequestListCounter", ospf_ls_request_count (nbr
));
4239 vty_out (vty
, " Link State Request List %ld%s",
4240 ospf_ls_request_count (nbr
), VTY_NEWLINE
);
4242 /* Show Link State Retransmission list. */
4244 json_object_int_add(json_sub
, "linkStateRetransmissionListCounter", ospf_ls_retransmit_count (nbr
));
4246 vty_out (vty
, " Link State Retransmission List %ld%s",
4247 ospf_ls_retransmit_count (nbr
), VTY_NEWLINE
);
4249 /* Show inactivity timer thread. */
4252 if (nbr
->t_inactivity
!= NULL
)
4253 json_object_string_add(json_sub
, "threadInactivityTimer", "on");
4256 vty_out (vty
, " Thread Inactivity Timer %s%s",
4257 nbr
->t_inactivity
!= NULL
? "on" : "off", VTY_NEWLINE
);
4259 /* Show Database Description retransmission thread. */
4262 if (nbr
->t_db_desc
!= NULL
)
4263 json_object_string_add(json_sub
, "threadDatabaseDescriptionRetransmission", "on");
4266 vty_out (vty
, " Thread Database Description Retransmision %s%s",
4267 nbr
->t_db_desc
!= NULL
? "on" : "off", VTY_NEWLINE
);
4269 /* Show Link State Request Retransmission thread. */
4272 if (nbr
->t_ls_req
!= NULL
)
4273 json_object_string_add(json_sub
, "threadLinkStateRequestRetransmission", "on");
4276 vty_out (vty
, " Thread Link State Request Retransmission %s%s",
4277 nbr
->t_ls_req
!= NULL
? "on" : "off", VTY_NEWLINE
);
4279 /* Show Link State Update Retransmission thread. */
4282 if (nbr
->t_ls_upd
!= NULL
)
4283 json_object_string_add(json_sub
, "threadLinkStateUpdateRetransmission", "on");
4286 vty_out (vty
, " Thread Link State Update Retransmission %s%s%s",
4287 nbr
->t_ls_upd
!= NULL
? "on" : "off", VTY_NEWLINE
, VTY_NEWLINE
);
4291 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4292 json_object_object_add(json
, "noNbrId", json_sub
);
4294 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_sub
);
4297 ospf_bfd_show_info(vty
, nbr
->bfd_info
, json
, use_json
, 0);
4301 show_ip_ospf_neighbor_id_common (struct vty
*vty
, struct ospf
*ospf
,
4302 int arg_base
, struct cmd_token
**argv
, u_char use_json
)
4304 struct listnode
*node
;
4305 struct ospf_neighbor
*nbr
;
4306 struct ospf_interface
*oi
;
4307 struct in_addr router_id
;
4309 json_object
*json
= NULL
;
4312 json
= json_object_new_object();
4317 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4319 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4320 VTY_NEWLINE
, VTY_NEWLINE
);
4323 ret
= inet_aton (argv
[arg_base
]->arg
, &router_id
);
4327 vty_out (vty
, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE
);
4331 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4333 if ((nbr
= ospf_nbr_lookup_by_routerid (oi
->nbrs
, &router_id
)))
4335 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4341 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4342 json_object_free(json
);
4345 vty_out (vty
, "%s", VTY_NEWLINE
);
4350 DEFUN (show_ip_ospf_neighbor_id
,
4351 show_ip_ospf_neighbor_id_cmd
,
4352 "show ip ospf neighbor A.B.C.D [json]",
4355 "OSPF information\n"
4361 u_char uj
= use_json(argc
, argv
);
4363 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4366 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 0, argv
, uj
);
4369 DEFUN (show_ip_ospf_instance_neighbor_id
,
4370 show_ip_ospf_instance_neighbor_id_cmd
,
4371 "show ip ospf (1-65535) neighbor A.B.C.D [json]",
4374 "OSPF information\n"
4382 u_short instance
= 0;
4383 u_char uj
= use_json(argc
, argv
);
4385 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4386 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4389 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 1, argv
, uj
);
4393 show_ip_ospf_neighbor_detail_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4395 struct ospf_interface
*oi
;
4396 struct listnode
*node
;
4397 json_object
*json
= NULL
;
4400 json
= json_object_new_object();
4405 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4407 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4408 VTY_NEWLINE
, VTY_NEWLINE
);
4411 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4413 struct route_node
*rn
;
4414 struct ospf_neighbor
*nbr
;
4416 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4418 if ((nbr
= rn
->info
))
4420 if (nbr
!= oi
->nbr_self
)
4422 if (nbr
->state
!= NSM_Down
)
4424 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4433 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4434 json_object_free(json
);
4437 vty_out (vty
, "%s", VTY_NEWLINE
);
4442 DEFUN (show_ip_ospf_neighbor_detail
,
4443 show_ip_ospf_neighbor_detail_cmd
,
4444 "show ip ospf neighbor detail [json]",
4447 "OSPF information\n"
4449 "detail of all neighbors\n"
4453 u_char uj
= use_json(argc
, argv
);
4455 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4458 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4461 DEFUN (show_ip_ospf_instance_neighbor_detail
,
4462 show_ip_ospf_instance_neighbor_detail_cmd
,
4463 "show ip ospf (1-65535) neighbor detail [json]",
4466 "OSPF information\n"
4469 "detail of all neighbors\n"
4474 u_short instance
= 0;
4475 u_char uj
= use_json(argc
, argv
);
4477 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4478 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
4481 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4485 show_ip_ospf_neighbor_detail_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4487 struct listnode
*node
;
4488 struct ospf_interface
*oi
;
4489 json_object
*json
= NULL
;
4492 json
= json_object_new_object();
4497 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4499 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4500 VTY_NEWLINE
, VTY_NEWLINE
);
4503 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4505 struct route_node
*rn
;
4506 struct ospf_neighbor
*nbr
;
4507 struct ospf_nbr_nbma
*nbr_nbma
;
4509 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4510 if ((nbr
= rn
->info
))
4511 if (nbr
!= oi
->nbr_self
)
4512 if (nbr
->state
!= NSM_Down
)
4513 show_ip_ospf_neighbor_detail_sub (vty
, oi
, rn
->info
, use_json
, json
);
4515 if (oi
->type
== OSPF_IFTYPE_NBMA
)
4517 struct listnode
*nd
;
4519 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nd
, nbr_nbma
))
4521 if (nbr_nbma
->nbr
== NULL
|| nbr_nbma
->nbr
->state
== NSM_Down
)
4522 show_ip_ospf_nbr_nbma_detail_sub (vty
, oi
, nbr_nbma
, use_json
, json
);
4529 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4530 json_object_free(json
);
4534 vty_out (vty
, "%s", VTY_NEWLINE
);
4540 DEFUN (show_ip_ospf_neighbor_detail_all
,
4541 show_ip_ospf_neighbor_detail_all_cmd
,
4542 "show ip ospf neighbor detail all [json]",
4545 "OSPF information\n"
4547 "detail of all neighbors\n"
4548 "include down status neighbor\n"
4552 u_char uj
= use_json(argc
, argv
);
4554 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4557 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4560 DEFUN (show_ip_ospf_instance_neighbor_detail_all
,
4561 show_ip_ospf_instance_neighbor_detail_all_cmd
,
4562 "show ip ospf (1-65535) neighbor detail all [json]",
4565 "OSPF information\n"
4568 "detail of all neighbors\n"
4569 "include down status neighbor\n"
4574 u_short instance
= 0;
4575 u_char uj
= use_json(argc
, argv
);
4577 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4578 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4581 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4585 show_ip_ospf_neighbor_int_detail_common (struct vty
*vty
, struct ospf
*ospf
,
4586 int arg_base
, struct cmd_token
**argv
, u_char use_json
)
4588 struct ospf_interface
*oi
;
4589 struct interface
*ifp
;
4590 struct route_node
*rn
, *nrn
;
4591 struct ospf_neighbor
*nbr
;
4592 json_object
*json
= NULL
;
4595 json
= json_object_new_object();
4600 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4602 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4603 VTY_NEWLINE
, VTY_NEWLINE
);
4606 ifp
= if_lookup_by_name (argv
[arg_base
]->arg
, VRF_DEFAULT
);
4610 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
4614 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
4616 if ((oi
= rn
->info
))
4618 for (nrn
= route_top (oi
->nbrs
); nrn
; nrn
= route_next (nrn
))
4620 if ((nbr
= nrn
->info
))
4622 if (nbr
!= oi
->nbr_self
)
4624 if (nbr
->state
!= NSM_Down
)
4625 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4634 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4635 json_object_free(json
);
4638 vty_out (vty
, "%s", VTY_NEWLINE
);
4643 DEFUN (show_ip_ospf_neighbor_int_detail
,
4644 show_ip_ospf_neighbor_int_detail_cmd
,
4645 "show ip ospf neighbor IFNAME detail [json]",
4648 "OSPF information\n"
4651 "detail of all neighbors\n"
4655 u_char uj
= use_json(argc
, argv
);
4657 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4660 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 0, argv
, uj
);
4663 DEFUN (show_ip_ospf_instance_neighbor_int_detail
,
4664 show_ip_ospf_instance_neighbor_int_detail_cmd
,
4665 "show ip ospf (1-65535) neighbor IFNAME detail [json]",
4668 "OSPF information\n"
4672 "detail of all neighbors\n"
4677 u_short instance
= 0;
4678 u_char uj
= use_json(argc
, argv
);
4680 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4681 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4684 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 1, argv
, uj
);
4687 /* Show functions */
4689 show_lsa_summary (struct vty
*vty
, struct ospf_lsa
*lsa
, int self
)
4691 struct router_lsa
*rl
;
4692 struct summary_lsa
*sl
;
4693 struct as_external_lsa
*asel
;
4694 struct prefix_ipv4 p
;
4697 /* If self option is set, check LSA self flag. */
4698 if (self
== 0 || IS_LSA_SELF (lsa
))
4700 /* LSA common part show. */
4701 vty_out (vty
, "%-15s ", inet_ntoa (lsa
->data
->id
));
4702 vty_out (vty
, "%-15s %4d 0x%08lx 0x%04x",
4703 inet_ntoa (lsa
->data
->adv_router
), LS_AGE (lsa
),
4704 (u_long
)ntohl (lsa
->data
->ls_seqnum
), ntohs (lsa
->data
->checksum
));
4705 /* LSA specific part show. */
4706 switch (lsa
->data
->type
)
4708 case OSPF_ROUTER_LSA
:
4709 rl
= (struct router_lsa
*) lsa
->data
;
4710 vty_out (vty
, " %-d", ntohs (rl
->links
));
4712 case OSPF_SUMMARY_LSA
:
4713 sl
= (struct summary_lsa
*) lsa
->data
;
4716 p
.prefix
= sl
->header
.id
;
4717 p
.prefixlen
= ip_masklen (sl
->mask
);
4718 apply_mask_ipv4 (&p
);
4720 vty_out (vty
, " %s/%d", inet_ntoa (p
.prefix
), p
.prefixlen
);
4722 case OSPF_AS_EXTERNAL_LSA
:
4723 case OSPF_AS_NSSA_LSA
:
4724 asel
= (struct as_external_lsa
*) lsa
->data
;
4727 p
.prefix
= asel
->header
.id
;
4728 p
.prefixlen
= ip_masklen (asel
->mask
);
4729 apply_mask_ipv4 (&p
);
4731 vty_out (vty
, " %s %s/%d [0x%lx]",
4732 IS_EXTERNAL_METRIC (asel
->e
[0].tos
) ? "E2" : "E1",
4733 inet_ntoa (p
.prefix
), p
.prefixlen
,
4734 (u_long
)ntohl (asel
->e
[0].route_tag
));
4736 case OSPF_NETWORK_LSA
:
4737 case OSPF_ASBR_SUMMARY_LSA
:
4738 case OSPF_OPAQUE_LINK_LSA
:
4739 case OSPF_OPAQUE_AREA_LSA
:
4740 case OSPF_OPAQUE_AS_LSA
:
4744 vty_out (vty
, VTY_NEWLINE
);
4750 static const char *show_database_desc
[] =
4753 "Router Link States",
4755 "Summary Link States",
4756 "ASBR-Summary Link States",
4757 "AS External Link States",
4758 "Group Membership LSA",
4759 "NSSA-external Link States",
4761 "Link-Local Opaque-LSA",
4762 "Area-Local Opaque-LSA",
4763 "AS-external Opaque-LSA",
4766 static const char *show_database_header
[] =
4769 "Link ID ADV Router Age Seq# CkSum Link count",
4770 "Link ID ADV Router Age Seq# CkSum",
4771 "Link ID ADV Router Age Seq# CkSum Route",
4772 "Link ID ADV Router Age Seq# CkSum",
4773 "Link ID ADV Router Age Seq# CkSum Route",
4774 " --- header for Group Member ----",
4775 "Link ID ADV Router Age Seq# CkSum Route",
4777 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4778 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4779 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4783 show_ip_ospf_database_header (struct vty
*vty
, struct ospf_lsa
*lsa
)
4785 struct router_lsa
*rlsa
= (struct router_lsa
*) lsa
->data
;
4787 vty_out (vty
, " LS age: %d%s", LS_AGE (lsa
), VTY_NEWLINE
);
4788 vty_out (vty
, " Options: 0x%-2x : %s%s",
4790 ospf_options_dump(lsa
->data
->options
),
4792 vty_out (vty
, " LS Flags: 0x%-2x %s%s",
4794 ((lsa
->flags
& OSPF_LSA_LOCAL_XLT
) ? "(Translated from Type-7)" : ""),
4797 if (lsa
->data
->type
== OSPF_ROUTER_LSA
)
4799 vty_out (vty
, " Flags: 0x%x" , rlsa
->flags
);
4802 vty_out (vty
, " :%s%s%s%s",
4803 IS_ROUTER_LSA_BORDER (rlsa
) ? " ABR" : "",
4804 IS_ROUTER_LSA_EXTERNAL (rlsa
) ? " ASBR" : "",
4805 IS_ROUTER_LSA_VIRTUAL (rlsa
) ? " VL-endpoint" : "",
4806 IS_ROUTER_LSA_SHORTCUT (rlsa
) ? " Shortcut" : "");
4808 vty_out (vty
, "%s", VTY_NEWLINE
);
4810 vty_out (vty
, " LS Type: %s%s",
4811 LOOKUP (ospf_lsa_type_msg
, lsa
->data
->type
), VTY_NEWLINE
);
4812 vty_out (vty
, " Link State ID: %s %s%s", inet_ntoa (lsa
->data
->id
),
4813 LOOKUP (ospf_link_state_id_type_msg
, lsa
->data
->type
), VTY_NEWLINE
);
4814 vty_out (vty
, " Advertising Router: %s%s",
4815 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
4816 vty_out (vty
, " LS Seq Number: %08lx%s", (u_long
)ntohl (lsa
->data
->ls_seqnum
),
4818 vty_out (vty
, " Checksum: 0x%04x%s", ntohs (lsa
->data
->checksum
),
4820 vty_out (vty
, " Length: %d%s", ntohs (lsa
->data
->length
), VTY_NEWLINE
);
4823 const char *link_type_desc
[] =
4826 "another Router (point-to-point)",
4827 "a Transit Network",
4832 const char *link_id_desc
[] =
4835 "Neighboring Router ID",
4836 "Designated Router address",
4838 "Neighboring Router ID",
4841 const char *link_data_desc
[] =
4844 "Router Interface address",
4845 "Router Interface address",
4847 "Router Interface address",
4850 /* Show router-LSA each Link information. */
4852 show_ip_ospf_database_router_links (struct vty
*vty
,
4853 struct router_lsa
*rl
)
4858 len
= ntohs (rl
->header
.length
) - 4;
4859 for (i
= 0; i
< ntohs (rl
->links
) && len
> 0; len
-= 12, i
++)
4861 type
= rl
->link
[i
].type
;
4863 vty_out (vty
, " Link connected to: %s%s",
4864 link_type_desc
[type
], VTY_NEWLINE
);
4865 vty_out (vty
, " (Link ID) %s: %s%s", link_id_desc
[type
],
4866 inet_ntoa (rl
->link
[i
].link_id
), VTY_NEWLINE
);
4867 vty_out (vty
, " (Link Data) %s: %s%s", link_data_desc
[type
],
4868 inet_ntoa (rl
->link
[i
].link_data
), VTY_NEWLINE
);
4869 vty_out (vty
, " Number of TOS metrics: 0%s", VTY_NEWLINE
);
4870 vty_out (vty
, " TOS 0 Metric: %d%s",
4871 ntohs (rl
->link
[i
].metric
), VTY_NEWLINE
);
4872 vty_out (vty
, "%s", VTY_NEWLINE
);
4876 /* Show router-LSA detail information. */
4878 show_router_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4882 struct router_lsa
*rl
= (struct router_lsa
*) lsa
->data
;
4884 show_ip_ospf_database_header (vty
, lsa
);
4886 vty_out (vty
, " Number of Links: %d%s%s", ntohs (rl
->links
),
4887 VTY_NEWLINE
, VTY_NEWLINE
);
4889 show_ip_ospf_database_router_links (vty
, rl
);
4890 vty_out (vty
, "%s", VTY_NEWLINE
);
4896 /* Show network-LSA detail information. */
4898 show_network_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4904 struct network_lsa
*nl
= (struct network_lsa
*) lsa
->data
;
4906 show_ip_ospf_database_header (vty
, lsa
);
4908 vty_out (vty
, " Network Mask: /%d%s",
4909 ip_masklen (nl
->mask
), VTY_NEWLINE
);
4911 length
= ntohs (lsa
->data
->length
) - OSPF_LSA_HEADER_SIZE
- 4;
4913 for (i
= 0; length
> 0; i
++, length
-= 4)
4914 vty_out (vty
, " Attached Router: %s%s",
4915 inet_ntoa (nl
->routers
[i
]), VTY_NEWLINE
);
4917 vty_out (vty
, "%s", VTY_NEWLINE
);
4923 /* Show summary-LSA detail information. */
4925 show_summary_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4929 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
4931 show_ip_ospf_database_header (vty
, lsa
);
4933 vty_out (vty
, " Network Mask: /%d%s", ip_masklen (sl
->mask
),
4935 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
4937 vty_out (vty
, "%s", VTY_NEWLINE
);
4943 /* Show summary-ASBR-LSA detail information. */
4945 show_summary_asbr_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4949 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
4951 show_ip_ospf_database_header (vty
, lsa
);
4953 vty_out (vty
, " Network Mask: /%d%s",
4954 ip_masklen (sl
->mask
), VTY_NEWLINE
);
4955 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
4957 vty_out (vty
, "%s", VTY_NEWLINE
);
4963 /* Show AS-external-LSA detail information. */
4965 show_as_external_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4969 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
4971 show_ip_ospf_database_header (vty
, lsa
);
4973 vty_out (vty
, " Network Mask: /%d%s",
4974 ip_masklen (al
->mask
), VTY_NEWLINE
);
4975 vty_out (vty
, " Metric Type: %s%s",
4976 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
4977 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
4978 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
4979 vty_out (vty
, " Metric: %d%s",
4980 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
4981 vty_out (vty
, " Forward Address: %s%s",
4982 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
4984 vty_out (vty
, " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
4985 (route_tag_t
)ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
4992 show_as_external_lsa_stdvty (struct ospf_lsa
*lsa
)
4994 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
4996 /* show_ip_ospf_database_header (vty, lsa); */
4998 zlog_debug( " Network Mask: /%d%s",
4999 ip_masklen (al
->mask
), "\n");
5000 zlog_debug( " Metric Type: %s%s",
5001 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5002 "2 (Larger than any link state path)" : "1", "\n");
5003 zlog_debug( " TOS: 0%s", "\n");
5004 zlog_debug( " Metric: %d%s",
5005 GET_METRIC (al
->e
[0].metric
), "\n");
5006 zlog_debug( " Forward Address: %s%s",
5007 inet_ntoa (al
->e
[0].fwd_addr
), "\n");
5009 zlog_debug( " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5010 (route_tag_t
)ntohl (al
->e
[0].route_tag
), "\n", "\n");
5015 /* Show AS-NSSA-LSA detail information. */
5017 show_as_nssa_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5021 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5023 show_ip_ospf_database_header (vty
, lsa
);
5025 vty_out (vty
, " Network Mask: /%d%s",
5026 ip_masklen (al
->mask
), VTY_NEWLINE
);
5027 vty_out (vty
, " Metric Type: %s%s",
5028 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5029 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
5030 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
5031 vty_out (vty
, " Metric: %d%s",
5032 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
5033 vty_out (vty
, " NSSA: Forward Address: %s%s",
5034 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
5036 vty_out (vty
, " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5037 (route_tag_t
)ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
5044 show_func_dummy (struct vty
*vty
, struct ospf_lsa
*lsa
)
5050 show_opaque_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5054 show_ip_ospf_database_header (vty
, lsa
);
5055 show_opaque_info_detail (vty
, lsa
);
5057 vty_out (vty
, "%s", VTY_NEWLINE
);
5062 int (*show_function
[])(struct vty
*, struct ospf_lsa
*) =
5065 show_router_lsa_detail
,
5066 show_network_lsa_detail
,
5067 show_summary_lsa_detail
,
5068 show_summary_asbr_lsa_detail
,
5069 show_as_external_lsa_detail
,
5071 show_as_nssa_lsa_detail
, /* almost same as external */
5073 show_opaque_lsa_detail
,
5074 show_opaque_lsa_detail
,
5075 show_opaque_lsa_detail
,
5079 show_lsa_prefix_set (struct vty
*vty
, struct prefix_ls
*lp
, struct in_addr
*id
,
5080 struct in_addr
*adv_router
)
5082 memset (lp
, 0, sizeof (struct prefix_ls
));
5086 else if (adv_router
== NULL
)
5095 lp
->adv_router
= *adv_router
;
5100 show_lsa_detail_proc (struct vty
*vty
, struct route_table
*rt
,
5101 struct in_addr
*id
, struct in_addr
*adv_router
)
5103 struct prefix_ls lp
;
5104 struct route_node
*rn
, *start
;
5105 struct ospf_lsa
*lsa
;
5107 show_lsa_prefix_set (vty
, &lp
, id
, adv_router
);
5108 start
= route_node_get (rt
, (struct prefix
*) &lp
);
5111 route_lock_node (start
);
5112 for (rn
= start
; rn
; rn
= route_next_until (rn
, start
))
5113 if ((lsa
= rn
->info
))
5115 if (show_function
[lsa
->data
->type
] != NULL
)
5116 show_function
[lsa
->data
->type
] (vty
, lsa
);
5118 route_unlock_node (start
);
5122 /* Show detail LSA information
5123 -- if id is NULL then show all LSAs. */
5125 show_lsa_detail (struct vty
*vty
, struct ospf
*ospf
, int type
,
5126 struct in_addr
*id
, struct in_addr
*adv_router
)
5128 struct listnode
*node
;
5129 struct ospf_area
*area
;
5133 case OSPF_AS_EXTERNAL_LSA
:
5134 case OSPF_OPAQUE_AS_LSA
:
5135 vty_out (vty
, " %s %s%s",
5136 show_database_desc
[type
],
5137 VTY_NEWLINE
, VTY_NEWLINE
);
5138 show_lsa_detail_proc (vty
, AS_LSDB (ospf
, type
), id
, adv_router
);
5141 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5143 vty_out (vty
, "%s %s (Area %s)%s%s",
5144 VTY_NEWLINE
, show_database_desc
[type
],
5145 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5146 show_lsa_detail_proc (vty
, AREA_LSDB (area
, type
), id
, adv_router
);
5153 show_lsa_detail_adv_router_proc (struct vty
*vty
, struct route_table
*rt
,
5154 struct in_addr
*adv_router
)
5156 struct route_node
*rn
;
5157 struct ospf_lsa
*lsa
;
5159 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
5160 if ((lsa
= rn
->info
))
5161 if (IPV4_ADDR_SAME (adv_router
, &lsa
->data
->adv_router
))
5163 if (CHECK_FLAG (lsa
->flags
, OSPF_LSA_LOCAL_XLT
))
5165 if (show_function
[lsa
->data
->type
] != NULL
)
5166 show_function
[lsa
->data
->type
] (vty
, lsa
);
5170 /* Show detail LSA information. */
5172 show_lsa_detail_adv_router (struct vty
*vty
, struct ospf
*ospf
, int type
,
5173 struct in_addr
*adv_router
)
5175 struct listnode
*node
;
5176 struct ospf_area
*area
;
5180 case OSPF_AS_EXTERNAL_LSA
:
5181 case OSPF_OPAQUE_AS_LSA
:
5182 vty_out (vty
, " %s %s%s",
5183 show_database_desc
[type
],
5184 VTY_NEWLINE
, VTY_NEWLINE
);
5185 show_lsa_detail_adv_router_proc (vty
, AS_LSDB (ospf
, type
),
5189 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5191 vty_out (vty
, "%s %s (Area %s)%s%s",
5192 VTY_NEWLINE
, show_database_desc
[type
],
5193 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5194 show_lsa_detail_adv_router_proc (vty
, AREA_LSDB (area
, type
),
5202 show_ip_ospf_database_summary (struct vty
*vty
, struct ospf
*ospf
, int self
)
5204 struct ospf_lsa
*lsa
;
5205 struct route_node
*rn
;
5206 struct ospf_area
*area
;
5207 struct listnode
*node
;
5210 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5212 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5216 case OSPF_AS_EXTERNAL_LSA
:
5217 case OSPF_OPAQUE_AS_LSA
:
5222 if (ospf_lsdb_count_self (area
->lsdb
, type
) > 0 ||
5223 (!self
&& ospf_lsdb_count (area
->lsdb
, type
) > 0))
5225 vty_out (vty
, " %s (Area %s)%s%s",
5226 show_database_desc
[type
],
5227 ospf_area_desc_string (area
),
5228 VTY_NEWLINE
, VTY_NEWLINE
);
5229 vty_out (vty
, "%s%s", show_database_header
[type
], VTY_NEWLINE
);
5231 LSDB_LOOP (AREA_LSDB (area
, type
), rn
, lsa
)
5232 show_lsa_summary (vty
, lsa
, self
);
5234 vty_out (vty
, "%s", VTY_NEWLINE
);
5239 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5243 case OSPF_AS_EXTERNAL_LSA
:
5244 case OSPF_OPAQUE_AS_LSA
:
5249 if (ospf_lsdb_count_self (ospf
->lsdb
, type
) ||
5250 (!self
&& ospf_lsdb_count (ospf
->lsdb
, type
)))
5252 vty_out (vty
, " %s%s%s",
5253 show_database_desc
[type
],
5254 VTY_NEWLINE
, VTY_NEWLINE
);
5255 vty_out (vty
, "%s%s", show_database_header
[type
],
5258 LSDB_LOOP (AS_LSDB (ospf
, type
), rn
, lsa
)
5259 show_lsa_summary (vty
, lsa
, self
);
5261 vty_out (vty
, "%s", VTY_NEWLINE
);
5265 vty_out (vty
, "%s", VTY_NEWLINE
);
5269 show_ip_ospf_database_maxage (struct vty
*vty
, struct ospf
*ospf
)
5271 struct route_node
*rn
;
5273 vty_out (vty
, "%s MaxAge Link States:%s%s",
5274 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
5276 for (rn
= route_top (ospf
->maxage_lsa
); rn
; rn
= route_next (rn
))
5278 struct ospf_lsa
*lsa
;
5280 if ((lsa
= rn
->info
) != NULL
)
5282 vty_out (vty
, "Link type: %d%s", lsa
->data
->type
, VTY_NEWLINE
);
5283 vty_out (vty
, "Link State ID: %s%s",
5284 inet_ntoa (lsa
->data
->id
), VTY_NEWLINE
);
5285 vty_out (vty
, "Advertising Router: %s%s",
5286 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
5287 vty_out (vty
, "LSA lock count: %d%s", lsa
->lock
, VTY_NEWLINE
);
5288 vty_out (vty
, "%s", VTY_NEWLINE
);
5293 #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
5294 #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
5296 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
5297 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
5298 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
5299 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
5301 #define OSPF_LSA_TYPES_DESC \
5302 "ASBR summary link states\n" \
5303 "External link states\n" \
5304 "Network link states\n" \
5305 "Router link states\n" \
5306 "Network summary link states\n" \
5307 OSPF_LSA_TYPE_NSSA_DESC \
5308 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
5309 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
5310 OSPF_LSA_TYPE_OPAQUE_AS_DESC
5313 show_ip_ospf_database_common (struct vty
*vty
, struct ospf
*ospf
,
5314 int arg_base
, int argc
, struct cmd_token
**argv
)
5318 struct in_addr id
, adv_router
;
5321 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5324 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5325 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5328 if (argc
== arg_base
+ 4)
5330 show_ip_ospf_database_summary (vty
, ospf
, 0);
5334 /* Set database type to show. */
5335 if (strncmp (argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5336 type
= OSPF_ROUTER_LSA
;
5337 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5338 type
= OSPF_NETWORK_LSA
;
5339 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5340 type
= OSPF_AS_NSSA_LSA
;
5341 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "su", 2) == 0)
5342 type
= OSPF_SUMMARY_LSA
;
5343 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5344 type
= OSPF_ASBR_SUMMARY_LSA
;
5345 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5346 type
= OSPF_AS_EXTERNAL_LSA
;
5347 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "se", 2) == 0)
5349 show_ip_ospf_database_summary (vty
, ospf
, 1);
5352 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "m", 1) == 0)
5354 show_ip_ospf_database_maxage (vty
, ospf
);
5357 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5358 type
= OSPF_OPAQUE_LINK_LSA
;
5359 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5360 type
= OSPF_OPAQUE_AREA_LSA
;
5361 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5362 type
= OSPF_OPAQUE_AS_LSA
;
5366 /* `show ip ospf database LSA'. */
5367 if (argc
== arg_base
+ 5)
5368 show_lsa_detail (vty
, ospf
, type
, NULL
, NULL
);
5369 else if (argc
>= arg_base
+ 6)
5371 ret
= inet_aton (argv
[arg_base
+ 5]->arg
, &id
);
5375 /* `show ip ospf database LSA ID'. */
5376 if (argc
== arg_base
+ 6)
5377 show_lsa_detail (vty
, ospf
, type
, &id
, NULL
);
5378 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
5379 else if (argc
== arg_base
+ 7)
5381 if (strncmp (argv
[arg_base
+ 6]->text
, "s", 1) == 0)
5382 adv_router
= ospf
->router_id
;
5385 ret
= inet_aton (argv
[arg_base
+ 7]->arg
, &adv_router
);
5389 show_lsa_detail (vty
, ospf
, type
, &id
, &adv_router
);
5396 DEFUN (show_ip_ospf_database_max
,
5397 show_ip_ospf_database_max_cmd
,
5398 "show ip ospf database <max-age|self-originate>",
5401 "OSPF information\n"
5402 "Database summary\n"
5403 "LSAs in MaxAge list\n"
5404 "Self-originated link states\n")
5408 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5411 return (show_ip_ospf_database_common(vty
, ospf
, 0, argc
, argv
));
5414 DEFUN (show_ip_ospf_instance_database
,
5415 show_ip_ospf_instance_database_cmd
,
5416 "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>]]]",
5419 "OSPF information\n"
5421 "Database summary\n"
5423 "Link State ID (as an IP address)\n"
5424 "Self-originated link states\n"
5425 "Advertising Router link states\n"
5426 "Advertising Router (as an IP address)\n")
5429 u_short instance
= 0;
5432 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
5434 VTY_GET_INTEGER ("Instance", instance
, argv
[idx
]->arg
);
5435 ospf
= ospf_lookup_instance (instance
);
5438 ospf
= ospf_lookup();
5441 if (!ospf
|| !ospf
->oi_running
)
5444 return (show_ip_ospf_database_common(vty
, ospf
, idx
? 1 : 0, argc
, argv
));
5447 DEFUN (show_ip_ospf_instance_database_max
,
5448 show_ip_ospf_instance_database_max_cmd
,
5449 "show ip ospf (1-65535) database <max-age|self-originate>",
5452 "OSPF information\n"
5454 "Database summary\n"
5455 "LSAs in MaxAge list\n"
5456 "Self-originated link states\n")
5460 u_short instance
= 0;
5462 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
5464 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5467 return (show_ip_ospf_database_common(vty
, ospf
, 1, argc
, argv
));
5472 show_ip_ospf_database_type_adv_router_common (struct vty
*vty
, struct ospf
*ospf
,
5473 int arg_base
, int argc
, struct cmd_token
**argv
)
5477 struct in_addr adv_router
;
5480 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5483 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5484 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5486 if (argc
!= arg_base
+ 7)
5489 /* Set database type to show. */
5490 if (strncmp (argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5491 type
= OSPF_ROUTER_LSA
;
5492 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5493 type
= OSPF_NETWORK_LSA
;
5494 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5495 type
= OSPF_AS_NSSA_LSA
;
5496 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "s", 1) == 0)
5497 type
= OSPF_SUMMARY_LSA
;
5498 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5499 type
= OSPF_ASBR_SUMMARY_LSA
;
5500 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5501 type
= OSPF_AS_EXTERNAL_LSA
;
5502 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5503 type
= OSPF_OPAQUE_LINK_LSA
;
5504 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5505 type
= OSPF_OPAQUE_AREA_LSA
;
5506 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5507 type
= OSPF_OPAQUE_AS_LSA
;
5511 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
5512 if (strncmp (argv
[arg_base
+ 5]->text
, "s", 1) == 0)
5513 adv_router
= ospf
->router_id
;
5516 ret
= inet_aton (argv
[arg_base
+ 6]->arg
, &adv_router
);
5521 show_lsa_detail_adv_router (vty
, ospf
, type
, &adv_router
);
5526 DEFUN (show_ip_ospf_database_type_adv_router
,
5527 show_ip_ospf_database_type_adv_router_cmd
,
5528 "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>",
5531 "OSPF information\n"
5532 "Database summary\n"
5534 "Advertising Router link states\n"
5535 "Advertising Router (as an IP address)\n"
5536 "Self-originated link states\n")
5540 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5543 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 0, argc
, argv
));
5546 DEFUN (show_ip_ospf_instance_database_type_adv_router
,
5547 show_ip_ospf_instance_database_type_adv_router_cmd
,
5548 "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>",
5551 "OSPF information\n"
5553 "Database summary\n"
5555 "Advertising Router link states\n"
5556 "Advertising Router (as an IP address)\n"
5557 "Self-originated link states\n")
5561 u_short instance
= 0;
5563 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
5565 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5568 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 1, argc
, argv
));
5571 DEFUN (ip_ospf_authentication_args
,
5572 ip_ospf_authentication_args_addr_cmd
,
5573 "ip ospf authentication <null|message-digest> [A.B.C.D]",
5575 "OSPF interface commands\n"
5576 "Enable authentication on this interface\n"
5577 "Use null authentication\n"
5578 "Use message-digest authentication\n"
5579 "Address of interface\n")
5581 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5582 int idx_encryption
= 3;
5584 struct in_addr addr
;
5586 struct ospf_if_params
*params
;
5588 params
= IF_DEF_PARAMS (ifp
);
5592 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5595 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5600 params
= ospf_get_if_params (ifp
, addr
);
5601 ospf_if_update_params (ifp
, addr
);
5604 /* Handle null authentication */
5605 if ( argv
[idx_encryption
]->arg
[0] == 'n' )
5607 SET_IF_PARAM (params
, auth_type
);
5608 params
->auth_type
= OSPF_AUTH_NULL
;
5612 /* Handle message-digest authentication */
5613 if ( argv
[idx_encryption
]->arg
[0] == 'm' )
5615 SET_IF_PARAM (params
, auth_type
);
5616 params
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5620 vty_out (vty
, "You shouldn't get here!%s", VTY_NEWLINE
);
5624 DEFUN (ip_ospf_authentication
,
5625 ip_ospf_authentication_addr_cmd
,
5626 "ip ospf authentication [A.B.C.D]",
5628 "OSPF interface commands\n"
5629 "Enable authentication on this interface\n"
5630 "Address of interface")
5632 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5634 struct in_addr addr
;
5636 struct ospf_if_params
*params
;
5638 params
= IF_DEF_PARAMS (ifp
);
5642 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5645 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5650 params
= ospf_get_if_params (ifp
, addr
);
5651 ospf_if_update_params (ifp
, addr
);
5654 SET_IF_PARAM (params
, auth_type
);
5655 params
->auth_type
= OSPF_AUTH_SIMPLE
;
5660 DEFUN (no_ip_ospf_authentication_args
,
5661 no_ip_ospf_authentication_args_addr_cmd
,
5662 "no ip ospf authentication <null|message-digest> [A.B.C.D]",
5665 "OSPF interface commands\n"
5666 "Enable authentication on this interface\n"
5667 "Use null authentication\n"
5668 "Use message-digest authentication\n"
5669 "Address of interface")
5671 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5672 int idx_encryption
= 4;
5674 struct in_addr addr
;
5676 struct ospf_if_params
*params
;
5677 struct route_node
*rn
;
5680 params
= IF_DEF_PARAMS (ifp
);
5684 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5687 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5692 params
= ospf_lookup_if_params (ifp
, addr
);
5695 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
5698 params
->auth_type
= OSPF_AUTH_NOTSET
;
5699 UNSET_IF_PARAM (params
, auth_type
);
5700 if (params
!= IF_DEF_PARAMS (ifp
))
5702 ospf_free_if_params (ifp
, addr
);
5703 ospf_if_update_params (ifp
, addr
);
5708 if ( argv
[idx_encryption
]->arg
[0] == 'n' )
5710 auth_type
= OSPF_AUTH_NULL
;
5712 else if ( argv
[idx_encryption
]->arg
[0] == 'm' )
5714 auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5718 vty_out (vty
, "Unexpected input encountered%s", VTY_NEWLINE
);
5722 * Here we have a case where the user has entered
5723 * 'no ip ospf authentication (null | message_digest )'
5724 * we need to find if we have any ip addresses underneath it that
5725 * correspond to the associated type.
5727 if (params
->auth_type
== auth_type
)
5729 params
->auth_type
= OSPF_AUTH_NOTSET
;
5730 UNSET_IF_PARAM (params
, auth_type
);
5733 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
5735 if ((params
= rn
->info
))
5737 if (params
->auth_type
== auth_type
)
5739 params
->auth_type
= OSPF_AUTH_NOTSET
;
5740 UNSET_IF_PARAM (params
, auth_type
);
5741 if (params
!= IF_DEF_PARAMS (ifp
))
5743 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
5744 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
5754 DEFUN (no_ip_ospf_authentication
,
5755 no_ip_ospf_authentication_addr_cmd
,
5756 "no ip ospf authentication [A.B.C.D]",
5759 "OSPF interface commands\n"
5760 "Enable authentication on this interface\n"
5761 "Address of interface")
5763 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5765 struct in_addr addr
;
5767 struct ospf_if_params
*params
;
5768 struct route_node
*rn
;
5770 params
= IF_DEF_PARAMS (ifp
);
5774 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5777 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5782 params
= ospf_lookup_if_params (ifp
, addr
);
5785 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
5789 params
->auth_type
= OSPF_AUTH_NOTSET
;
5790 UNSET_IF_PARAM (params
, auth_type
);
5791 if (params
!= IF_DEF_PARAMS (ifp
))
5793 ospf_free_if_params (ifp
, addr
);
5794 ospf_if_update_params (ifp
, addr
);
5800 * When a user enters 'no ip ospf authentication'
5801 * We should remove all authentication types from
5804 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
5805 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
5806 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
5808 params
->auth_type
= OSPF_AUTH_NOTSET
;
5809 UNSET_IF_PARAM (params
, auth_type
);
5812 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
5814 if ((params
= rn
->info
))
5817 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
5818 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
5819 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
5821 params
->auth_type
= OSPF_AUTH_NOTSET
;
5822 UNSET_IF_PARAM (params
, auth_type
);
5823 if (params
!= IF_DEF_PARAMS (ifp
))
5825 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
5826 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
5837 DEFUN (ip_ospf_authentication_key
,
5838 ip_ospf_authentication_key_addr_cmd
,
5839 "ip ospf authentication-key AUTH_KEY [A.B.C.D]",
5841 "OSPF interface commands\n"
5842 "Authentication password (key)\n"
5843 "The OSPF password (key)\n"
5844 "Address of interface")
5846 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5848 struct in_addr addr
;
5849 struct ospf_if_params
*params
;
5851 params
= IF_DEF_PARAMS (ifp
);
5853 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
5855 if (!inet_aton(argv
[idx
]->arg
, &addr
))
5857 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5862 params
= ospf_get_if_params (ifp
, addr
);
5863 ospf_if_update_params (ifp
, addr
);
5866 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
5867 strncpy ((char *) params
->auth_simple
, argv
[3]->arg
, OSPF_AUTH_SIMPLE_SIZE
);
5868 SET_IF_PARAM (params
, auth_simple
);
5873 DEFUN_HIDDEN (ospf_authentication_key
,
5874 ospf_authentication_key_cmd
,
5875 "ospf authentication-key AUTH_KEY [A.B.C.D]",
5876 "OSPF interface commands\n"
5877 "Authentication password (key)\n"
5878 "The OSPF password (key)\n"
5879 "Address of interface\n")
5881 return ip_ospf_authentication_key (self
, vty
, argc
, argv
);
5884 DEFUN (no_ip_ospf_authentication_key
,
5885 no_ip_ospf_authentication_key_authkey_addr_cmd
,
5886 "no ip ospf authentication-key [AUTH_KEY [A.B.C.D]]",
5889 "OSPF interface commands\n"
5890 "Authentication password (key)\n"
5891 "The OSPF password (key)")
5893 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5895 struct in_addr addr
;
5896 struct ospf_if_params
*params
;
5897 params
= IF_DEF_PARAMS (ifp
);
5899 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
5901 if (!inet_aton(argv
[idx
]->arg
, &addr
))
5903 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5908 params
= ospf_lookup_if_params (ifp
, addr
);
5913 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
);
5914 UNSET_IF_PARAM (params
, auth_simple
);
5916 if (params
!= IF_DEF_PARAMS (ifp
))
5918 ospf_free_if_params (ifp
, addr
);
5919 ospf_if_update_params (ifp
, addr
);
5925 DEFUN_HIDDEN (no_ospf_authentication_key
,
5926 no_ospf_authentication_key_authkey_addr_cmd
,
5927 "no ospf authentication-key [AUTH_KEY [A.B.C.D]]",
5929 "OSPF interface commands\n"
5930 "Authentication password (key)\n"
5931 "The OSPF password (key)")
5933 return no_ip_ospf_authentication_key (self
, vty
, argc
, argv
);
5936 DEFUN (ip_ospf_message_digest_key
,
5937 ip_ospf_message_digest_key_cmd
,
5938 "ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
5940 "OSPF interface commands\n"
5941 "Message digest authentication password (key)\n"
5943 "Use MD5 algorithm\n"
5944 "The OSPF password (key)\n"
5945 "Address of interface\n")
5947 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5948 struct crypt_key
*ck
;
5950 struct in_addr addr
;
5951 struct ospf_if_params
*params
;
5953 params
= IF_DEF_PARAMS (ifp
);
5956 argv_find (argv
, argc
, "(1-255)", &idx
);
5957 char *keyid
= argv
[idx
]->arg
;
5958 argv_find (argv
, argc
, "KEY", &idx
);
5959 char *cryptkey
= argv
[idx
]->arg
;
5961 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
5963 if (!inet_aton(argv
[idx
]->arg
, &addr
))
5965 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5970 params
= ospf_get_if_params (ifp
, addr
);
5971 ospf_if_update_params (ifp
, addr
);
5974 key_id
= strtol (keyid
, NULL
, 10);
5975 if (ospf_crypt_key_lookup (params
->auth_crypt
, key_id
) != NULL
)
5977 vty_out (vty
, "OSPF: Key %d already exists%s", key_id
, VTY_NEWLINE
);
5981 ck
= ospf_crypt_key_new ();
5982 ck
->key_id
= (u_char
) key_id
;
5983 memset (ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
5984 strncpy ((char *) ck
->auth_key
, cryptkey
, OSPF_AUTH_MD5_SIZE
);
5986 ospf_crypt_key_add (params
->auth_crypt
, ck
);
5987 SET_IF_PARAM (params
, auth_crypt
);
5992 DEFUN_HIDDEN (ospf_message_digest_key
,
5993 ospf_message_digest_key_cmd
,
5994 "ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
5995 "OSPF interface commands\n"
5996 "Message digest authentication password (key)\n"
5998 "Use MD5 algorithm\n"
5999 "The OSPF password (key)\n"
6000 "Address of interface\n")
6002 return ip_ospf_message_digest_key (self
, vty
, argc
, argv
);
6005 DEFUN (no_ip_ospf_message_digest_key
,
6006 no_ip_ospf_message_digest_key_cmd
,
6007 "no ip ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
6010 "OSPF interface commands\n"
6011 "Message digest authentication password (key)\n"
6013 "Use MD5 algorithm\n"
6014 "The OSPF password (key)\n"
6015 "Address of interface\n")
6017 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6019 struct crypt_key
*ck
;
6021 struct in_addr addr
;
6022 struct ospf_if_params
*params
;
6023 params
= IF_DEF_PARAMS (ifp
);
6025 argv_find (argv
, argc
, "(1-255)", &idx
);
6026 char *keyid
= argv
[idx
]->arg
;
6028 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6030 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6032 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6037 params
= ospf_lookup_if_params (ifp
, addr
);
6042 key_id
= strtol (keyid
, NULL
, 10);
6043 ck
= ospf_crypt_key_lookup (params
->auth_crypt
, key_id
);
6046 vty_out (vty
, "OSPF: Key %d does not exist%s", key_id
, VTY_NEWLINE
);
6050 ospf_crypt_key_delete (params
->auth_crypt
, key_id
);
6052 if (params
!= IF_DEF_PARAMS (ifp
))
6054 ospf_free_if_params (ifp
, addr
);
6055 ospf_if_update_params (ifp
, addr
);
6061 DEFUN_HIDDEN (no_ospf_message_digest_key
,
6062 no_ospf_message_digest_key_cmd
,
6063 "no ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
6065 "OSPF interface commands\n"
6066 "Message digest authentication password (key)\n"
6068 "Address of interface")
6070 return no_ip_ospf_message_digest_key (self
, vty
, argc
, argv
);
6073 DEFUN (ip_ospf_cost
,
6075 "ip ospf cost (1-65535) [A.B.C.D]",
6077 "OSPF interface commands\n"
6080 "Address of interface\n")
6082 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6085 struct in_addr addr
;
6086 struct ospf_if_params
*params
;
6087 params
= IF_DEF_PARAMS (ifp
);
6090 char *coststr
= NULL
, *ifaddr
= NULL
;
6091 coststr
= argv_find (argv
, argc
, "(1-65535)", &idx
) ? argv
[idx
]->arg
: NULL
;
6092 ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6094 cost
= strtol (coststr
, NULL
, 10);
6098 if(!inet_aton(ifaddr
, &addr
))
6100 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6105 params
= ospf_get_if_params (ifp
, addr
);
6106 ospf_if_update_params (ifp
, addr
);
6109 SET_IF_PARAM (params
, output_cost_cmd
);
6110 params
->output_cost_cmd
= cost
;
6112 ospf_if_recalculate_output_cost (ifp
);
6117 DEFUN_HIDDEN (ospf_cost
,
6119 "ospf cost (1-65535) [A.B.C.D]",
6120 "OSPF interface commands\n"
6123 "Address of interface\n")
6125 return ip_ospf_cost (self
, vty
, argc
, argv
);
6128 DEFUN (no_ip_ospf_cost
,
6129 no_ip_ospf_cost_cmd
,
6130 "no ip ospf cost [(1-65535)] [A.B.C.D]",
6132 "OSPF interface commands\n"
6134 "Address of interface")
6136 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6138 struct in_addr addr
;
6139 struct ospf_if_params
*params
;
6141 params
= IF_DEF_PARAMS (ifp
);
6144 char *ifaddr
= NULL
;
6145 ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6147 /* According to the semantics we are mimicking "no ip ospf cost N" is
6148 * always treated as "no ip ospf cost" regardless of the actual value
6149 * of N already configured for the interface. Thus ignore cost. */
6153 if (!inet_aton(ifaddr
, &addr
))
6155 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6160 params
= ospf_lookup_if_params (ifp
, addr
);
6165 UNSET_IF_PARAM (params
, output_cost_cmd
);
6167 if (params
!= IF_DEF_PARAMS (ifp
))
6169 ospf_free_if_params (ifp
, addr
);
6170 ospf_if_update_params (ifp
, addr
);
6173 ospf_if_recalculate_output_cost (ifp
);
6178 DEFUN_HIDDEN (no_ospf_cost
,
6180 "no ospf cost [(1-65535)] [A.B.C.D]",
6182 "OSPF interface commands\n"
6185 "Address of interface\n")
6187 return no_ip_ospf_cost (self
, vty
, argc
, argv
);
6191 ospf_nbr_timer_update (struct ospf_interface
*oi
)
6193 struct route_node
*rn
;
6194 struct ospf_neighbor
*nbr
;
6196 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
6197 if ((nbr
= rn
->info
))
6199 nbr
->v_inactivity
= OSPF_IF_PARAM (oi
, v_wait
);
6200 nbr
->v_db_desc
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6201 nbr
->v_ls_req
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6202 nbr
->v_ls_upd
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6207 ospf_vty_dead_interval_set (struct vty
*vty
, const char *interval_str
,
6208 const char *nbr_str
,
6209 const char *fast_hello_str
)
6211 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6214 struct in_addr addr
;
6216 struct ospf_if_params
*params
;
6217 struct ospf_interface
*oi
;
6218 struct route_node
*rn
;
6220 params
= IF_DEF_PARAMS (ifp
);
6224 ret
= inet_aton(nbr_str
, &addr
);
6227 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6232 params
= ospf_get_if_params (ifp
, addr
);
6233 ospf_if_update_params (ifp
, addr
);
6238 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds
, interval_str
,
6241 /* reset fast_hello too, just to be sure */
6242 UNSET_IF_PARAM (params
, fast_hello
);
6243 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6245 else if (fast_hello_str
)
6247 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult
, fast_hello_str
,
6249 /* 1s dead-interval with sub-second hellos desired */
6250 seconds
= OSPF_ROUTER_DEAD_INTERVAL_MINIMAL
;
6251 SET_IF_PARAM (params
, fast_hello
);
6252 params
->fast_hello
= hellomult
;
6256 vty_out (vty
, "Please specify dead-interval or hello-multiplier%s",
6261 SET_IF_PARAM (params
, v_wait
);
6262 params
->v_wait
= seconds
;
6264 /* Update timer values in neighbor structure. */
6268 if ((ospf
= ospf_lookup()))
6270 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
6272 ospf_nbr_timer_update (oi
);
6277 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6278 if ((oi
= rn
->info
))
6279 ospf_nbr_timer_update (oi
);
6285 DEFUN (ip_ospf_dead_interval
,
6286 ip_ospf_dead_interval_cmd
,
6287 "ip ospf dead-interval (1-65535) [A.B.C.D]",
6289 "OSPF interface commands\n"
6290 "Interval time after which a neighbor is declared down\n"
6292 "Address of interface\n")
6295 char *interval
= argv_find (argv
, argc
, "(1-65535)", &idx
) ? argv
[idx
]->arg
: NULL
;
6296 char *ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6297 return ospf_vty_dead_interval_set (vty
, interval
, ifaddr
, NULL
);
6301 DEFUN_HIDDEN (ospf_dead_interval
,
6302 ospf_dead_interval_cmd
,
6303 "ospf dead-interval (1-65535) [A.B.C.D]",
6304 "OSPF interface commands\n"
6305 "Interval time after which a neighbor is declared down\n"
6307 "Address of interface\n")
6309 return ip_ospf_dead_interval (self
, vty
, argc
, argv
);
6312 DEFUN (ip_ospf_dead_interval_minimal
,
6313 ip_ospf_dead_interval_minimal_addr_cmd
,
6314 "ip ospf dead-interval minimal hello-multiplier (1-10) [A.B.C.D]",
6316 "OSPF interface commands\n"
6317 "Interval time after which a neighbor is declared down\n"
6318 "Minimal 1s dead-interval with fast sub-second hellos\n"
6319 "Hello multiplier factor\n"
6320 "Number of Hellos to send each second\n"
6321 "Address of interface\n")
6326 return ospf_vty_dead_interval_set (vty
, NULL
, argv
[idx_ipv4
]->arg
, argv
[idx_number
]->arg
);
6328 return ospf_vty_dead_interval_set (vty
, NULL
, NULL
, argv
[idx_number
]->arg
);
6331 DEFUN (no_ip_ospf_dead_interval
,
6332 no_ip_ospf_dead_interval_cmd
,
6333 "no ip ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6336 "OSPF interface commands\n"
6337 "Interval time after which a neighbor is declared down\n"
6339 "Address of interface")
6341 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6342 int idx_ipv4
= argc
- 1;
6343 struct in_addr addr
= { .s_addr
= 0L};
6345 struct ospf_if_params
*params
;
6346 struct ospf_interface
*oi
;
6347 struct route_node
*rn
;
6349 params
= IF_DEF_PARAMS (ifp
);
6351 if (argv
[idx_ipv4
]->type
== IPV4_TKN
)
6353 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6356 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6361 params
= ospf_lookup_if_params (ifp
, addr
);
6366 UNSET_IF_PARAM (params
, v_wait
);
6367 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
6369 UNSET_IF_PARAM (params
, fast_hello
);
6370 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6372 if (params
!= IF_DEF_PARAMS (ifp
))
6374 ospf_free_if_params (ifp
, addr
);
6375 ospf_if_update_params (ifp
, addr
);
6378 /* Update timer values in neighbor structure. */
6383 if ((ospf
= ospf_lookup()))
6385 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
6387 ospf_nbr_timer_update (oi
);
6392 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6393 if ((oi
= rn
->info
))
6394 ospf_nbr_timer_update (oi
);
6400 DEFUN_HIDDEN (no_ospf_dead_interval
,
6401 no_ospf_dead_interval_cmd
,
6402 "no ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6404 "OSPF interface commands\n"
6405 "Interval time after which a neighbor is declared down\n"
6407 "Address of interface")
6409 return no_ip_ospf_dead_interval (self
, vty
, argc
, argv
);
6412 DEFUN (ip_ospf_hello_interval
,
6413 ip_ospf_hello_interval_cmd
,
6414 "ip ospf hello-interval (1-65535) [A.B.C.D]",
6416 "OSPF interface commands\n"
6417 "Time between HELLO packets\n"
6419 "Address of interface\n")
6421 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6423 struct in_addr addr
;
6424 struct ospf_if_params
*params
;
6425 params
= IF_DEF_PARAMS (ifp
);
6426 u_int32_t seconds
= 0;
6428 argv_find (argv
, argc
, "(1-65535)", &idx
);
6429 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
6431 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6433 if(!inet_aton(argv
[idx
]->arg
, &addr
))
6435 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6440 params
= ospf_get_if_params (ifp
, addr
);
6441 ospf_if_update_params (ifp
, addr
);
6444 SET_IF_PARAM (params
, v_hello
);
6445 params
->v_hello
= seconds
;
6450 DEFUN_HIDDEN (ospf_hello_interval
,
6451 ospf_hello_interval_cmd
,
6452 "ospf hello-interval (1-65535) [A.B.C.D]",
6453 "OSPF interface commands\n"
6454 "Time between HELLO packets\n"
6456 "Address of interface\n")
6458 return ip_ospf_hello_interval (self
, vty
, argc
, argv
);
6461 DEFUN (no_ip_ospf_hello_interval
,
6462 no_ip_ospf_hello_interval_cmd
,
6463 "no ip ospf hello-interval [(1-65535) [A.B.C.D]]",
6466 "OSPF interface commands\n"
6467 "Time between HELLO packets\n" // ignored
6469 "Address of interface\n")
6471 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6473 struct in_addr addr
;
6474 struct ospf_if_params
*params
;
6476 params
= IF_DEF_PARAMS (ifp
);
6478 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6480 if(!inet_aton(argv
[idx
]->arg
, &addr
))
6482 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6487 params
= ospf_lookup_if_params (ifp
, addr
);
6492 UNSET_IF_PARAM (params
, v_hello
);
6493 params
->v_hello
= OSPF_HELLO_INTERVAL_DEFAULT
;
6495 if (params
!= IF_DEF_PARAMS (ifp
))
6497 ospf_free_if_params (ifp
, addr
);
6498 ospf_if_update_params (ifp
, addr
);
6504 DEFUN_HIDDEN (no_ospf_hello_interval
,
6505 no_ospf_hello_interval_cmd
,
6506 "no ospf hello-interval [(1-65535) [A.B.C.D]]",
6508 "OSPF interface commands\n"
6509 "Time between HELLO packets\n" // ignored
6511 "Address of interface\n")
6513 return no_ip_ospf_hello_interval (self
, vty
, argc
, argv
);
6516 DEFUN (ip_ospf_network
,
6517 ip_ospf_network_cmd
,
6518 "ip ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
6520 "OSPF interface commands\n"
6522 "Specify OSPF broadcast multi-access network\n"
6523 "Specify OSPF NBMA network\n"
6524 "Specify OSPF point-to-multipoint network\n"
6525 "Specify OSPF point-to-point network\n")
6527 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6529 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
6530 struct route_node
*rn
;
6532 if (old_type
== OSPF_IFTYPE_LOOPBACK
)
6534 vty_out (vty
, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE
);
6538 if (argv_find (argv
, argc
, "broadcast", &idx
))
6539 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_BROADCAST
;
6540 else if (argv_find (argv
, argc
, "non-broadcast", &idx
))
6541 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_NBMA
;
6542 else if (argv_find (argv
, argc
, "point-to-multipoint", &idx
))
6543 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOMULTIPOINT
;
6544 else if (argv_find (argv
, argc
, "point-to-point", &idx
))
6545 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOPOINT
;
6547 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
6550 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), type
);
6552 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6554 struct ospf_interface
*oi
= rn
->info
;
6559 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
6561 if (oi
->state
> ISM_Down
)
6563 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
6564 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
6571 DEFUN_HIDDEN (ospf_network
,
6573 "ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
6574 "OSPF interface commands\n"
6576 "Specify OSPF broadcast multi-access network\n"
6577 "Specify OSPF NBMA network\n"
6578 "Specify OSPF point-to-multipoint network\n"
6579 "Specify OSPF point-to-point network\n")
6581 return ip_ospf_network (self
, vty
, argc
, argv
);
6584 DEFUN (no_ip_ospf_network
,
6585 no_ip_ospf_network_cmd
,
6586 "no ip ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
6589 "OSPF interface commands\n"
6591 "Specify OSPF broadcast multi-access network\n"
6592 "Specify OSPF NBMA network\n"
6593 "Specify OSPF point-to-multipoint network\n"
6594 "Specify OSPF point-to-point network\n")
6596 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6597 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
6598 struct route_node
*rn
;
6600 IF_DEF_PARAMS (ifp
)->type
= ospf_default_iftype(ifp
);
6602 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
6605 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6607 struct ospf_interface
*oi
= rn
->info
;
6612 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
6614 if (oi
->state
> ISM_Down
)
6616 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
6617 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
6624 DEFUN_HIDDEN (no_ospf_network
,
6625 no_ospf_network_cmd
,
6626 "no ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
6628 "OSPF interface commands\n"
6630 "Specify OSPF broadcast multi-access network\n"
6631 "Specify OSPF NBMA network\n"
6632 "Specify OSPF point-to-multipoint network\n"
6633 "Specify OSPF point-to-point network\n")
6635 return no_ip_ospf_network (self
, vty
, argc
, argv
);
6638 DEFUN (ip_ospf_priority
,
6639 ip_ospf_priority_cmd
,
6640 "ip ospf priority (0-255) [A.B.C.D]",
6642 "OSPF interface commands\n"
6645 "Address of interface")
6647 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6650 struct route_node
*rn
;
6651 struct in_addr addr
;
6652 struct ospf_if_params
*params
;
6653 params
= IF_DEF_PARAMS (ifp
);
6655 argv_find (argv
, argc
, "(0-255)", &idx
);
6656 priority
= strtol (argv
[idx
]->arg
, NULL
, 10);
6658 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6660 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6662 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6667 params
= ospf_get_if_params (ifp
, addr
);
6668 ospf_if_update_params (ifp
, addr
);
6671 SET_IF_PARAM (params
, priority
);
6672 params
->priority
= priority
;
6674 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6676 struct ospf_interface
*oi
= rn
->info
;
6681 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
6683 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
6684 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
6691 DEFUN_HIDDEN (ospf_priority
,
6693 "ospf priority (0-255) [A.B.C.D]",
6694 "OSPF interface commands\n"
6697 "Address of interface")
6699 return ip_ospf_priority (self
, vty
, argc
, argv
);
6702 DEFUN (no_ip_ospf_priority
,
6703 no_ip_ospf_priority_cmd
,
6704 "no ip ospf priority [(0-255) [A.B.C.D]]",
6707 "OSPF interface commands\n"
6708 "Router priority\n" // ignored
6710 "Address of interface")
6712 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6714 struct route_node
*rn
;
6715 struct in_addr addr
;
6716 struct ospf_if_params
*params
;
6718 params
= IF_DEF_PARAMS (ifp
);
6720 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6722 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6724 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6729 params
= ospf_lookup_if_params (ifp
, addr
);
6734 UNSET_IF_PARAM (params
, priority
);
6735 params
->priority
= OSPF_ROUTER_PRIORITY_DEFAULT
;
6737 if (params
!= IF_DEF_PARAMS (ifp
))
6739 ospf_free_if_params (ifp
, addr
);
6740 ospf_if_update_params (ifp
, addr
);
6743 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6745 struct ospf_interface
*oi
= rn
->info
;
6750 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
6752 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
6753 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
6760 DEFUN_HIDDEN (no_ospf_priority
,
6761 no_ospf_priority_cmd
,
6762 "no ospf priority [(0-255) [A.B.C.D]]",
6764 "OSPF interface commands\n"
6767 "Address of interface")
6769 return no_ip_ospf_priority (self
, vty
, argc
, argv
);
6772 DEFUN (ip_ospf_retransmit_interval
,
6773 ip_ospf_retransmit_interval_addr_cmd
,
6774 "ip ospf retransmit-interval (3-65535) [A.B.C.D]",
6776 "OSPF interface commands\n"
6777 "Time between retransmitting lost link state advertisements\n"
6779 "Address of interface")
6781 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6784 struct in_addr addr
;
6785 struct ospf_if_params
*params
;
6786 params
= IF_DEF_PARAMS (ifp
);
6788 argv_find (argv
, argc
, "(3-65535)", &idx
);
6789 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
6791 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6793 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6795 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6800 params
= ospf_get_if_params (ifp
, addr
);
6801 ospf_if_update_params (ifp
, addr
);
6804 SET_IF_PARAM (params
, retransmit_interval
);
6805 params
->retransmit_interval
= seconds
;
6810 DEFUN_HIDDEN (ospf_retransmit_interval
,
6811 ospf_retransmit_interval_cmd
,
6812 "ospf retransmit-interval (3-65535) [A.B.C.D]",
6813 "OSPF interface commands\n"
6814 "Time between retransmitting lost link state advertisements\n"
6816 "Address of interface")
6818 return ip_ospf_retransmit_interval (self
, vty
, argc
, argv
);
6821 DEFUN (no_ip_ospf_retransmit_interval
,
6822 no_ip_ospf_retransmit_interval_addr_cmd
,
6823 "no ip ospf retransmit-interval [(3-65535)] [A.B.C.D]",
6826 "OSPF interface commands\n"
6827 "Time between retransmitting lost link state advertisements\n"
6829 "Address of interface\n")
6831 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6833 struct in_addr addr
;
6834 struct ospf_if_params
*params
;
6836 params
= IF_DEF_PARAMS (ifp
);
6838 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6840 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6842 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6847 params
= ospf_lookup_if_params (ifp
, addr
);
6852 UNSET_IF_PARAM (params
, retransmit_interval
);
6853 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
6855 if (params
!= IF_DEF_PARAMS (ifp
))
6857 ospf_free_if_params (ifp
, addr
);
6858 ospf_if_update_params (ifp
, addr
);
6864 DEFUN_HIDDEN (no_ospf_retransmit_interval
,
6865 no_ospf_retransmit_interval_cmd
,
6866 "no ospf retransmit-interval [(3-65535)] [A.B.C.D]",
6868 "OSPF interface commands\n"
6869 "Time between retransmitting lost link state advertisements\n"
6871 "Address of interface\n")
6873 return no_ip_ospf_retransmit_interval (self
, vty
, argc
, argv
);
6876 DEFUN (ip_ospf_transmit_delay
,
6877 ip_ospf_transmit_delay_addr_cmd
,
6878 "ip ospf transmit-delay (1-65535) [A.B.C.D]",
6880 "OSPF interface commands\n"
6881 "Link state transmit delay\n"
6883 "Address of interface")
6885 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6888 struct in_addr addr
;
6889 struct ospf_if_params
*params
;
6891 params
= IF_DEF_PARAMS (ifp
);
6892 argv_find (argv
, argc
, "(1-65535)", &idx
);
6893 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
6895 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6897 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6899 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6904 params
= ospf_get_if_params (ifp
, addr
);
6905 ospf_if_update_params (ifp
, addr
);
6908 SET_IF_PARAM (params
, transmit_delay
);
6909 params
->transmit_delay
= seconds
;
6914 DEFUN_HIDDEN (ospf_transmit_delay
,
6915 ospf_transmit_delay_cmd
,
6916 "ospf transmit-delay (1-65535) [A.B.C.D]",
6917 "OSPF interface commands\n"
6918 "Link state transmit delay\n"
6920 "Address of interface")
6922 return ip_ospf_transmit_delay (self
, vty
, argc
, argv
);
6925 DEFUN (no_ip_ospf_transmit_delay
,
6926 no_ip_ospf_transmit_delay_addr_cmd
,
6927 "no ip ospf transmit-delay [(1-65535)] [A.B.C.D]",
6930 "OSPF interface commands\n"
6931 "Link state transmit delay\n"
6932 "Address of interface")
6934 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6936 struct in_addr addr
;
6937 struct ospf_if_params
*params
;
6939 params
= IF_DEF_PARAMS (ifp
);
6941 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6943 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6945 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6950 params
= ospf_lookup_if_params (ifp
, addr
);
6955 UNSET_IF_PARAM (params
, transmit_delay
);
6956 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
6958 if (params
!= IF_DEF_PARAMS (ifp
))
6960 ospf_free_if_params (ifp
, addr
);
6961 ospf_if_update_params (ifp
, addr
);
6968 DEFUN_HIDDEN (no_ospf_transmit_delay
,
6969 no_ospf_transmit_delay_cmd
,
6970 "no ospf transmit-delay",
6972 "OSPF interface commands\n"
6973 "Link state transmit delay\n")
6975 return no_ip_ospf_transmit_delay (self
, vty
, argc
, argv
);
6978 DEFUN (ip_ospf_area
,
6980 "ip ospf [(1-65535)] area <A.B.C.D|(0-4294967295)>",
6982 "OSPF interface commands\n"
6984 "Enable OSPF on this interface\n"
6985 "OSPF area ID in IP address format\n"
6986 "OSPF area ID as a decimal value\n")
6988 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6991 struct in_addr area_id
;
6993 struct ospf_if_params
*params
;
6994 struct route_node
*rn
;
6995 u_short instance
= 0;
6997 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
6998 instance
= strtol (argv
[idx
]->arg
, NULL
, 10);
6999 char *areaid
= argv
[argc
- 1]->arg
;
7001 ospf
= ospf_lookup_instance (instance
);
7004 params
= IF_DEF_PARAMS (ifp
);
7005 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7007 ospf_interface_unset (ifp
);
7008 ospf
= ospf_lookup();
7009 ospf
->if_ospf_cli_count
--;
7014 ret
= str2area_id (areaid
, &area_id
, &format
);
7017 vty_out (vty
, "Please specify area by A.B.C.D|<0-4294967295>%s",
7021 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
7023 vty_out (vty
, "Cannot enable OSPF on a virtual link.%s", VTY_NEWLINE
);
7027 params
= IF_DEF_PARAMS (ifp
);
7028 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7031 "Must remove previous area config before changing ospf area %s",
7036 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
7038 if (rn
->info
!= NULL
)
7040 vty_out (vty
, "Please remove all network commands first.%s", VTY_NEWLINE
);
7045 /* enable ospf on this interface with area_id */
7046 ospf_interface_set (ifp
, area_id
);
7047 ospf
->if_ospf_cli_count
++;
7052 DEFUN (no_ip_ospf_area
,
7053 no_ip_ospf_area_cmd
,
7054 "no ip ospf [(1-65535)] area [<A.B.C.D|(0-4294967295)>]",
7057 "OSPF interface commands\n"
7059 "Disable OSPF on this interface\n"
7060 "OSPF area ID in IP address format\n"
7061 "OSPF area ID as a decimal value\n")
7063 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7066 struct ospf_if_params
*params
;
7067 u_short instance
= 0;
7069 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
7070 instance
= strtol (argv
[idx
]->arg
, NULL
, 10);
7072 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
7075 params
= IF_DEF_PARAMS (ifp
);
7076 if (!OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7078 vty_out (vty
, "Can't find specified interface area configuration.%s", VTY_NEWLINE
);
7082 ospf_interface_unset (ifp
);
7083 ospf
->if_ospf_cli_count
--;
7087 DEFUN (ospf_redistribute_source
,
7088 ospf_redistribute_source_cmd
,
7089 "redistribute " FRR_REDIST_STR_OSPFD
" [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7091 FRR_REDIST_HELP_STR_OSPFD
7092 "Metric for redistributed routes\n"
7093 "OSPF default metric\n"
7094 "OSPF exterior metric type for redistributed routes\n"
7095 "Set OSPF External Type 1 metrics\n"
7096 "Set OSPF External Type 2 metrics\n"
7097 "Route map reference\n"
7098 "Pointer to route-map entries\n")
7100 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7101 int idx_protocol
= 1;
7105 struct ospf_redist
*red
;
7111 /* Get distribute source. */
7112 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
7116 red
= ospf_redist_add(ospf
, source
, 0);
7118 /* Get metric value. */
7119 if (argv_find (argv
, argc
, "(0-16777214)", &idx
)) {
7120 if (!str2metric (argv
[idx
]->arg
, &metric
))
7123 /* Get metric type. */
7124 else if (argv_find (argv
, argc
, "(1-2)", &idx
)) {
7125 if (!str2metric_type (argv
[idx
]->arg
, &type
))
7129 else if (argv_find (argv
, argc
, "WORD", &idx
)) {
7130 ospf_routemap_set (red
, argv
[idx
]->arg
);
7133 ospf_routemap_unset (red
);
7135 return ospf_redistribute_set (ospf
, source
, 0, type
, metric
);
7138 DEFUN (no_ospf_redistribute_source
,
7139 no_ospf_redistribute_source_cmd
,
7140 "no redistribute " FRR_REDIST_STR_OSPFD
" [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7143 FRR_REDIST_HELP_STR_OSPFD
7144 "Metric for redistributed routes\n"
7145 "OSPF default metric\n"
7146 "OSPF exterior metric type for redistributed routes\n"
7147 "Set OSPF External Type 1 metrics\n"
7148 "Set OSPF External Type 2 metrics\n"
7149 "Route map reference\n"
7150 "Pointer to route-map entries\n")
7152 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7153 int idx_protocol
= 2;
7155 struct ospf_redist
*red
;
7157 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
7161 red
= ospf_redist_lookup(ospf
, source
, 0);
7165 ospf_routemap_unset (red
);
7166 return ospf_redistribute_unset (ospf
, source
, 0);
7169 DEFUN (ospf_redistribute_instance_source
,
7170 ospf_redistribute_instance_source_cmd
,
7171 "redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
7173 "Open Shortest Path First\n"
7174 "Non-main Kernel Routing Table\n"
7175 "Instance ID/Table ID\n"
7176 "Metric for redistributed routes\n"
7177 "OSPF default metric\n"
7178 "OSPF exterior metric type for redistributed routes\n"
7179 "Set OSPF External Type 1 metrics\n"
7180 "Set OSPF External Type 2 metrics\n"
7181 "Route map reference\n"
7182 "Pointer to route-map entries\n")
7184 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7185 int idx_ospf_table
= 1;
7192 struct ospf_redist
*red
;
7197 source
= proto_redistnum (AFI_IP
, argv
[idx_ospf_table
]->text
);
7199 VTY_GET_INTEGER ("Instance ID", instance
, argv
[idx_number
]->arg
);
7204 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
7206 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
7211 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
7213 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
7218 /* Get metric value. */
7219 if (argv_find (argv
, argc
, "metric", &idx
))
7220 if (!str2metric (argv
[idx
+1]->arg
, &metric
))
7224 /* Get metric type. */
7225 if (argv_find (argv
, argc
, "metric-type", &idx
))
7226 if (!str2metric_type (argv
[idx
+1]->arg
, &type
))
7229 red
= ospf_redist_add(ospf
, source
, instance
);
7232 if (argv_find (argv
, argc
, "route-map", &idx
))
7233 ospf_routemap_set (red
, argv
[idx
+1]->arg
);
7235 ospf_routemap_unset (red
);
7237 return ospf_redistribute_set (ospf
, source
, instance
, type
, metric
);
7240 DEFUN (no_ospf_redistribute_instance_source
,
7241 no_ospf_redistribute_instance_source_cmd
,
7242 "no redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
7245 "Open Shortest Path First\n"
7246 "Non-main Kernel Routing Table\n"
7247 "Instance ID/Table Id\n"
7248 "Metric for redistributed routes\n"
7249 "OSPF default metric\n"
7250 "OSPF exterior metric type for redistributed routes\n"
7251 "Set OSPF External Type 1 metrics\n"
7252 "Set OSPF External Type 2 metrics\n"
7253 "Route map reference\n"
7254 "Pointer to route-map entries\n")
7256 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7257 int idx_ospf_table
= 2;
7260 struct ospf_redist
*red
;
7263 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
7264 source
= ZEBRA_ROUTE_OSPF
;
7266 source
= ZEBRA_ROUTE_TABLE
;
7268 VTY_GET_INTEGER ("Instance ID", instance
, argv
[idx_number
]->arg
);
7270 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
7272 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
7277 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
7279 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
7284 red
= ospf_redist_lookup(ospf
, source
, instance
);
7288 ospf_routemap_unset (red
);
7289 return ospf_redistribute_unset (ospf
, source
, instance
);
7292 DEFUN (ospf_distribute_list_out
,
7293 ospf_distribute_list_out_cmd
,
7294 "distribute-list WORD out " FRR_REDIST_STR_OSPFD
,
7295 "Filter networks in routing updates\n"
7296 "Access-list name\n"
7298 FRR_REDIST_HELP_STR_OSPFD
)
7300 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7304 char *proto
= argv
[argc
- 1]->text
;
7306 /* Get distribute source. */
7307 source
= proto_redistnum(AFI_IP
, proto
);
7311 return ospf_distribute_list_out_set (ospf
, source
, argv
[idx_word
]->arg
);
7314 DEFUN (no_ospf_distribute_list_out
,
7315 no_ospf_distribute_list_out_cmd
,
7316 "no distribute-list WORD out " FRR_REDIST_STR_OSPFD
,
7318 "Filter networks in routing updates\n"
7319 "Access-list name\n"
7321 FRR_REDIST_HELP_STR_OSPFD
)
7323 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7327 char *proto
= argv
[argc
- 1]->text
;
7328 source
= proto_redistnum(AFI_IP
, proto
);
7332 return ospf_distribute_list_out_unset (ospf
, source
, argv
[idx_word
]->arg
);
7335 /* Default information originate. */
7336 DEFUN (ospf_default_information_originate
,
7337 ospf_default_information_originate_cmd
,
7338 "default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7339 "Control distribution of default information\n"
7340 "Distribute a default route\n"
7341 "Always advertise default route\n"
7342 "OSPF default metric\n"
7344 "OSPF metric type for default routes\n"
7345 "Set OSPF External Type 1 metrics\n"
7346 "Set OSPF External Type 2 metrics\n"
7347 "Route map reference\n"
7348 "Pointer to route-map entries\n")
7350 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7351 int default_originate
= DEFAULT_ORIGINATE_ZEBRA
;
7354 struct ospf_redist
*red
;
7357 red
= ospf_redist_add(ospf
, DEFAULT_ROUTE
, 0);
7359 /* Check whether "always" was specified */
7360 if (argv_find (argv
, argc
, "always", &idx
))
7361 default_originate
= DEFAULT_ORIGINATE_ALWAYS
;
7362 /* Get metric value */
7363 else if (argv_find (argv
, argc
, "(0-16777214)", &idx
)) {
7364 if (!str2metric (argv
[idx
]->arg
, &metric
))
7367 /* Get metric type. */
7368 else if (argv_find (argv
, argc
, "(1-2)", &idx
)) {
7369 if (!str2metric_type (argv
[idx
]->arg
, &type
))
7373 else if (argv_find (argv
, argc
, "WORD", &idx
))
7374 ospf_routemap_set (red
, argv
[idx
]->arg
);
7376 ospf_routemap_unset (red
);
7378 return ospf_redistribute_default_set (ospf
, default_originate
,
7382 DEFUN (no_ospf_default_information_originate
,
7383 no_ospf_default_information_originate_cmd
,
7384 "no default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7386 "Control distribution of default information\n"
7387 "Distribute a default route\n"
7388 "Always advertise default route\n"
7389 "OSPF default metric\n"
7391 "OSPF metric type for default routes\n"
7392 "Set OSPF External Type 1 metrics\n"
7393 "Set OSPF External Type 2 metrics\n"
7394 "Route map reference\n"
7395 "Pointer to route-map entries\n")
7397 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7398 struct prefix_ipv4 p
;
7399 struct ospf_external
*ext
;
7400 struct ospf_redist
*red
;
7403 p
.prefix
.s_addr
= 0;
7406 ospf_external_lsa_flush (ospf
, DEFAULT_ROUTE
, &p
, 0);
7408 if ((ext
= ospf_external_lookup(DEFAULT_ROUTE
, 0)) &&
7409 EXTERNAL_INFO (ext
)) {
7410 ospf_external_info_delete (DEFAULT_ROUTE
, 0, p
);
7411 ospf_external_del (DEFAULT_ROUTE
, 0);
7414 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
7418 ospf_routemap_unset (red
);
7419 return ospf_redistribute_default_unset (ospf
);
7422 DEFUN (ospf_default_metric
,
7423 ospf_default_metric_cmd
,
7424 "default-metric (0-16777214)",
7425 "Set metric of redistributed routes\n"
7428 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7432 if (!str2metric (argv
[idx_number
]->arg
, &metric
))
7435 ospf
->default_metric
= metric
;
7440 DEFUN (no_ospf_default_metric
,
7441 no_ospf_default_metric_cmd
,
7442 "no default-metric [(0-16777214)]",
7444 "Set metric of redistributed routes\n"
7447 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7449 ospf
->default_metric
= -1;
7455 DEFUN (ospf_distance
,
7458 "Administrative distance\n"
7459 "OSPF Administrative distance\n")
7461 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7464 ospf
->distance_all
= atoi (argv
[idx_number
]->arg
);
7469 DEFUN (no_ospf_distance
,
7470 no_ospf_distance_cmd
,
7471 "no distance (1-255)",
7473 "Administrative distance\n"
7474 "OSPF Administrative distance\n")
7476 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7478 ospf
->distance_all
= 0;
7483 DEFUN (no_ospf_distance_ospf
,
7484 no_ospf_distance_ospf_cmd
,
7485 "no distance ospf [{intra-area [(1-255)]|inter-area [(1-255)]|external [(1-255)]}]",
7487 "Administrative distance\n"
7488 "OSPF administrative distance\n"
7489 "Intra-area routes\n"
7490 "Distance for intra-area routes\n"
7491 "Inter-area routes\n"
7492 "Distance for inter-area routes\n"
7494 "Distance for external routes\n")
7496 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7502 if (argv_find (argv
, argc
, "intra-area", &idx
) || argc
== 3)
7503 idx
= ospf
->distance_intra
= 0;
7504 if (argv_find (argv
, argc
, "inter-area", &idx
) || argc
== 3)
7505 idx
= ospf
->distance_inter
= 0;
7506 if (argv_find (argv
, argc
, "external", &idx
) || argc
== 3)
7507 ospf
->distance_external
= 0;
7512 DEFUN (ospf_distance_ospf
,
7513 ospf_distance_ospf_cmd
,
7514 "distance ospf {intra-area (1-255)|inter-area (1-255)|external (1-255)}",
7515 "Administrative distance\n"
7516 "OSPF administrative distance\n"
7517 "Intra-area routes\n"
7518 "Distance for intra-area routes\n"
7519 "Inter-area routes\n"
7520 "Distance for inter-area routes\n"
7522 "Distance for external routes\n")
7524 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7527 if (argv_find (argv
, argc
, "intra-area", &idx
))
7528 ospf
->distance_intra
= atoi(argv
[idx
+ 1]->arg
);
7530 if (argv_find (argv
, argc
, "inter-area", &idx
))
7531 ospf
->distance_inter
= atoi(argv
[idx
+ 1]->arg
);
7533 if (argv_find (argv
, argc
, "external", &idx
))
7534 ospf
->distance_external
= atoi(argv
[idx
+ 1]->arg
);
7540 DEFUN (ospf_distance_source
,
7541 ospf_distance_source_cmd
,
7542 "distance (1-255) A.B.C.D/M",
7543 "Administrative distance\n"
7545 "IP source prefix\n")
7547 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7549 int idx_ipv4_prefixlen
= 2;
7554 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
7559 DEFUN (no_ospf_distance_source
,
7560 no_ospf_distance_source_cmd
,
7561 "no distance (1-255) A.B.C.D/M",
7563 "Administrative distance\n"
7565 "IP source prefix\n")
7567 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7569 int idx_ipv4_prefixlen
= 3;
7574 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
7579 DEFUN (ospf_distance_source_access_list
,
7580 ospf_distance_source_access_list_cmd
,
7581 "distance (1-255) A.B.C.D/M WORD",
7582 "Administrative distance\n"
7584 "IP source prefix\n"
7585 "Access list name\n")
7587 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7589 int idx_ipv4_prefixlen
= 2;
7595 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
7600 DEFUN (no_ospf_distance_source_access_list
,
7601 no_ospf_distance_source_access_list_cmd
,
7602 "no distance (1-255) A.B.C.D/M WORD",
7604 "Administrative distance\n"
7606 "IP source prefix\n"
7607 "Access list name\n")
7609 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7611 int idx_ipv4_prefixlen
= 3;
7617 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
7623 DEFUN (ip_ospf_mtu_ignore
,
7624 ip_ospf_mtu_ignore_addr_cmd
,
7625 "ip ospf mtu-ignore [A.B.C.D]",
7627 "OSPF interface commands\n"
7628 "Disable MTU mismatch detection on this interface\n"
7629 "Address of interface")
7631 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7633 struct in_addr addr
;
7636 struct ospf_if_params
*params
;
7637 params
= IF_DEF_PARAMS (ifp
);
7641 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7644 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7648 params
= ospf_get_if_params (ifp
, addr
);
7649 ospf_if_update_params (ifp
, addr
);
7651 params
->mtu_ignore
= 1;
7652 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
7653 SET_IF_PARAM (params
, mtu_ignore
);
7656 UNSET_IF_PARAM (params
, mtu_ignore
);
7657 if (params
!= IF_DEF_PARAMS (ifp
))
7659 ospf_free_if_params (ifp
, addr
);
7660 ospf_if_update_params (ifp
, addr
);
7666 DEFUN (no_ip_ospf_mtu_ignore
,
7667 no_ip_ospf_mtu_ignore_addr_cmd
,
7668 "no ip ospf mtu-ignore [A.B.C.D]",
7670 "OSPF interface commands\n"
7671 "Disable MTU mismatch detection on this interface\n"
7672 "Address of interface")
7674 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7676 struct in_addr addr
;
7679 struct ospf_if_params
*params
;
7680 params
= IF_DEF_PARAMS (ifp
);
7684 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7687 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7691 params
= ospf_get_if_params (ifp
, addr
);
7692 ospf_if_update_params (ifp
, addr
);
7694 params
->mtu_ignore
= 0;
7695 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
7696 SET_IF_PARAM (params
, mtu_ignore
);
7699 UNSET_IF_PARAM (params
, mtu_ignore
);
7700 if (params
!= IF_DEF_PARAMS (ifp
))
7702 ospf_free_if_params (ifp
, addr
);
7703 ospf_if_update_params (ifp
, addr
);
7710 DEFUN (ospf_max_metric_router_lsa_admin
,
7711 ospf_max_metric_router_lsa_admin_cmd
,
7712 "max-metric router-lsa administrative",
7713 "OSPF maximum / infinite-distance metric\n"
7714 "Advertise own Router-LSA with infinite distance (stub router)\n"
7715 "Administratively applied, for an indefinite period\n")
7717 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7718 struct listnode
*ln
;
7719 struct ospf_area
*area
;
7721 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7723 SET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
7725 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
))
7726 ospf_router_lsa_update_area (area
);
7729 /* Allows for areas configured later to get the property */
7730 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_SET
;
7735 DEFUN (no_ospf_max_metric_router_lsa_admin
,
7736 no_ospf_max_metric_router_lsa_admin_cmd
,
7737 "no max-metric router-lsa administrative",
7739 "OSPF maximum / infinite-distance metric\n"
7740 "Advertise own Router-LSA with infinite distance (stub router)\n"
7741 "Administratively applied, for an indefinite period\n")
7743 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7744 struct listnode
*ln
;
7745 struct ospf_area
*area
;
7747 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7749 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
7751 /* Don't trample on the start-up stub timer */
7752 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
)
7753 && !area
->t_stub_router
)
7755 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
7756 ospf_router_lsa_update_area (area
);
7759 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET
;
7763 DEFUN (ospf_max_metric_router_lsa_startup
,
7764 ospf_max_metric_router_lsa_startup_cmd
,
7765 "max-metric router-lsa on-startup (5-86400)",
7766 "OSPF maximum / infinite-distance metric\n"
7767 "Advertise own Router-LSA with infinite distance (stub router)\n"
7768 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7769 "Time (seconds) to advertise self as stub-router\n")
7771 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7773 unsigned int seconds
;
7777 vty_out (vty
, "%% Must supply stub-router period");
7781 VTY_GET_INTEGER ("stub-router startup period", seconds
, argv
[idx_number
]->arg
);
7783 ospf
->stub_router_startup_time
= seconds
;
7788 DEFUN (no_ospf_max_metric_router_lsa_startup
,
7789 no_ospf_max_metric_router_lsa_startup_cmd
,
7790 "no max-metric router-lsa on-startup [(5-86400)]",
7792 "OSPF maximum / infinite-distance metric\n"
7793 "Advertise own Router-LSA with infinite distance (stub router)\n"
7794 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7795 "Time (seconds) to advertise self as stub-router\n")
7797 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7798 struct listnode
*ln
;
7799 struct ospf_area
*area
;
7801 ospf
->stub_router_startup_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
7803 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7805 SET_FLAG (area
->stub_router_state
, OSPF_AREA_WAS_START_STUB_ROUTED
);
7806 OSPF_TIMER_OFF (area
->t_stub_router
);
7808 /* Don't trample on admin stub routed */
7809 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
7811 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
7812 ospf_router_lsa_update_area (area
);
7819 DEFUN (ospf_max_metric_router_lsa_shutdown
,
7820 ospf_max_metric_router_lsa_shutdown_cmd
,
7821 "max-metric router-lsa on-shutdown (5-100)",
7822 "OSPF maximum / infinite-distance metric\n"
7823 "Advertise own Router-LSA with infinite distance (stub router)\n"
7824 "Advertise stub-router prior to full shutdown of OSPF\n"
7825 "Time (seconds) to wait till full shutdown\n")
7827 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7829 unsigned int seconds
;
7833 vty_out (vty
, "%% Must supply stub-router shutdown period");
7837 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds
, argv
[idx_number
]->arg
);
7839 ospf
->stub_router_shutdown_time
= seconds
;
7844 DEFUN (no_ospf_max_metric_router_lsa_shutdown
,
7845 no_ospf_max_metric_router_lsa_shutdown_cmd
,
7846 "no max-metric router-lsa on-shutdown [(5-100)]",
7848 "OSPF maximum / infinite-distance metric\n"
7849 "Advertise own Router-LSA with infinite distance (stub router)\n"
7850 "Advertise stub-router prior to full shutdown of OSPF\n"
7851 "Time (seconds) to wait till full shutdown\n")
7853 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7855 ospf
->stub_router_shutdown_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
7861 config_write_stub_router (struct vty
*vty
, struct ospf
*ospf
)
7863 struct listnode
*ln
;
7864 struct ospf_area
*area
;
7866 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
7867 vty_out (vty
, " max-metric router-lsa on-startup %u%s",
7868 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
7869 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
7870 vty_out (vty
, " max-metric router-lsa on-shutdown %u%s",
7871 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
7872 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7874 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
7876 vty_out (vty
, " max-metric router-lsa administrative%s",
7885 show_ip_ospf_route_network (struct vty
*vty
, struct route_table
*rt
)
7887 struct route_node
*rn
;
7888 struct ospf_route
*or;
7889 struct listnode
*pnode
, *pnnode
;
7890 struct ospf_path
*path
;
7892 vty_out (vty
, "============ OSPF network routing table ============%s",
7895 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
7896 if ((or = rn
->info
) != NULL
)
7899 snprintf (buf1
, 19, "%s/%d",
7900 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
7902 switch (or->path_type
)
7904 case OSPF_PATH_INTER_AREA
:
7905 if (or->type
== OSPF_DESTINATION_NETWORK
)
7906 vty_out (vty
, "N IA %-18s [%d] area: %s%s", buf1
, or->cost
,
7907 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
7908 else if (or->type
== OSPF_DESTINATION_DISCARD
)
7909 vty_out (vty
, "D IA %-18s Discard entry%s", buf1
, VTY_NEWLINE
);
7911 case OSPF_PATH_INTRA_AREA
:
7912 vty_out (vty
, "N %-18s [%d] area: %s%s", buf1
, or->cost
,
7913 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
7919 if (or->type
== OSPF_DESTINATION_NETWORK
)
7920 for (ALL_LIST_ELEMENTS (or->paths
, pnode
, pnnode
, path
))
7922 if (if_lookup_by_index(path
->ifindex
, VRF_DEFAULT
))
7924 if (path
->nexthop
.s_addr
== 0)
7925 vty_out (vty
, "%24s directly attached to %s%s",
7926 "", ifindex2ifname (path
->ifindex
, VRF_DEFAULT
), VTY_NEWLINE
);
7928 vty_out (vty
, "%24s via %s, %s%s", "",
7929 inet_ntoa (path
->nexthop
),
7930 ifindex2ifname (path
->ifindex
, VRF_DEFAULT
), VTY_NEWLINE
);
7934 vty_out (vty
, "%s", VTY_NEWLINE
);
7938 show_ip_ospf_route_router (struct vty
*vty
, struct route_table
*rtrs
)
7940 struct route_node
*rn
;
7941 struct ospf_route
*or;
7942 struct listnode
*pnode
;
7943 struct listnode
*node
;
7944 struct ospf_path
*path
;
7946 vty_out (vty
, "============ OSPF router routing table =============%s",
7948 for (rn
= route_top (rtrs
); rn
; rn
= route_next (rn
))
7953 vty_out (vty
, "R %-15s ", inet_ntoa (rn
->p
.u
.prefix4
));
7955 for (ALL_LIST_ELEMENTS_RO ((struct list
*)rn
->info
, node
, or))
7958 vty_out (vty
, "%24s", "");
7961 vty_out (vty
, "%s [%d] area: %s",
7962 (or->path_type
== OSPF_PATH_INTER_AREA
? "IA" : " "),
7963 or->cost
, inet_ntoa (or->u
.std
.area_id
));
7965 vty_out (vty
, "%s%s%s",
7966 (or->u
.std
.flags
& ROUTER_LSA_BORDER
? ", ABR" : ""),
7967 (or->u
.std
.flags
& ROUTER_LSA_EXTERNAL
? ", ASBR" : ""),
7970 for (ALL_LIST_ELEMENTS_RO (or->paths
, pnode
, path
))
7972 if (if_lookup_by_index(path
->ifindex
, VRF_DEFAULT
))
7974 if (path
->nexthop
.s_addr
== 0)
7975 vty_out (vty
, "%24s directly attached to %s%s",
7976 "", ifindex2ifname (path
->ifindex
, VRF_DEFAULT
),
7979 vty_out (vty
, "%24s via %s, %s%s", "",
7980 inet_ntoa (path
->nexthop
),
7981 ifindex2ifname (path
->ifindex
, VRF_DEFAULT
),
7987 vty_out (vty
, "%s", VTY_NEWLINE
);
7991 show_ip_ospf_route_external (struct vty
*vty
, struct route_table
*rt
)
7993 struct route_node
*rn
;
7994 struct ospf_route
*er
;
7995 struct listnode
*pnode
, *pnnode
;
7996 struct ospf_path
*path
;
7998 vty_out (vty
, "============ OSPF external routing table ===========%s",
8000 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
8001 if ((er
= rn
->info
) != NULL
)
8004 snprintf (buf1
, 19, "%s/%d",
8005 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
8007 switch (er
->path_type
)
8009 case OSPF_PATH_TYPE1_EXTERNAL
:
8010 vty_out (vty
, "N E1 %-18s [%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
,
8011 er
->cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
8013 case OSPF_PATH_TYPE2_EXTERNAL
:
8014 vty_out (vty
, "N E2 %-18s [%d/%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
, er
->cost
,
8015 er
->u
.ext
.type2_cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
8019 for (ALL_LIST_ELEMENTS (er
->paths
, pnode
, pnnode
, path
))
8021 if (if_lookup_by_index(path
->ifindex
, VRF_DEFAULT
))
8023 if (path
->nexthop
.s_addr
== 0)
8024 vty_out (vty
, "%24s directly attached to %s%s",
8025 "", ifindex2ifname (path
->ifindex
, VRF_DEFAULT
), VTY_NEWLINE
);
8027 vty_out (vty
, "%24s via %s, %s%s", "",
8028 inet_ntoa (path
->nexthop
),
8029 ifindex2ifname (path
->ifindex
, VRF_DEFAULT
),
8034 vty_out (vty
, "%s", VTY_NEWLINE
);
8038 show_ip_ospf_border_routers_common (struct vty
*vty
, struct ospf
*ospf
)
8041 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
8042 VTY_NEWLINE
, VTY_NEWLINE
);
8044 if (ospf
->new_table
== NULL
)
8046 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
8050 /* Show Network routes.
8051 show_ip_ospf_route_network (vty, ospf->new_table); */
8053 /* Show Router routes. */
8054 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
8056 vty_out (vty
, "%s", VTY_NEWLINE
);
8061 DEFUN (show_ip_ospf_border_routers
,
8062 show_ip_ospf_border_routers_cmd
,
8063 "show ip ospf border-routers",
8066 "OSPF information\n"
8067 "Show all the ABR's and ASBR's\n")
8071 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
8074 return show_ip_ospf_border_routers_common(vty
, ospf
);
8077 DEFUN (show_ip_ospf_instance_border_routers
,
8078 show_ip_ospf_instance_border_routers_cmd
,
8079 "show ip ospf (1-65535) border-routers",
8082 "OSPF information\n"
8084 "Show all the ABR's and ASBR's\n")
8088 u_short instance
= 0;
8090 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
8091 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
8094 return show_ip_ospf_border_routers_common(vty
, ospf
);
8098 show_ip_ospf_route_common (struct vty
*vty
, struct ospf
*ospf
)
8101 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
8102 VTY_NEWLINE
, VTY_NEWLINE
);
8104 if (ospf
->new_table
== NULL
)
8106 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
8110 /* Show Network routes. */
8111 show_ip_ospf_route_network (vty
, ospf
->new_table
);
8113 /* Show Router routes. */
8114 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
8116 /* Show AS External routes. */
8117 show_ip_ospf_route_external (vty
, ospf
->old_external_route
);
8119 vty_out (vty
, "%s", VTY_NEWLINE
);
8124 DEFUN (show_ip_ospf_route
,
8125 show_ip_ospf_route_cmd
,
8126 "show ip ospf route",
8129 "OSPF information\n"
8130 "OSPF routing table\n")
8134 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
8137 return show_ip_ospf_route_common(vty
, ospf
);
8140 DEFUN (show_ip_ospf_instance_route
,
8141 show_ip_ospf_instance_route_cmd
,
8142 "show ip ospf (1-65535) route",
8145 "OSPF information\n"
8147 "OSPF routing table\n")
8151 u_short instance
= 0;
8153 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
8154 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
8157 return show_ip_ospf_route_common(vty
, ospf
);
8160 const char *ospf_abr_type_str
[] =
8169 const char *ospf_shortcut_mode_str
[] =
8176 const char *ospf_int_type_str
[] =
8178 "unknown", /* should never be used. */
8182 "point-to-multipoint",
8183 "virtual-link", /* should never be used. */
8187 /* Configuration write function for ospfd. */
8189 config_write_interface (struct vty
*vty
)
8191 struct listnode
*n1
, *n2
;
8192 struct interface
*ifp
;
8193 struct crypt_key
*ck
;
8195 struct route_node
*rn
= NULL
;
8196 struct ospf_if_params
*params
;
8197 struct ospf
*ospf
= ospf_lookup();
8199 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), n1
, ifp
))
8201 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
8204 if (ifp
->ifindex
== IFINDEX_DELETED
)
8207 vty_out (vty
, "!%s", VTY_NEWLINE
);
8208 vty_out (vty
, "interface %s%s", ifp
->name
,
8211 vty_out (vty
, " description %s%s", ifp
->desc
,
8216 params
= IF_DEF_PARAMS (ifp
);
8219 /* Interface Network print. */
8220 if (OSPF_IF_PARAM_CONFIGURED (params
, type
) &&
8221 params
->type
!= OSPF_IFTYPE_LOOPBACK
)
8223 if (params
->type
!= ospf_default_iftype(ifp
))
8225 vty_out (vty
, " ip ospf network %s",
8226 ospf_int_type_str
[params
->type
]);
8227 if (params
!= IF_DEF_PARAMS (ifp
))
8228 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8229 vty_out (vty
, "%s", VTY_NEWLINE
);
8233 /* OSPF interface authentication print */
8234 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_type
) &&
8235 params
->auth_type
!= OSPF_AUTH_NOTSET
)
8237 const char *auth_str
;
8239 /* Translation tables are not that much help here due to syntax
8240 of the simple option */
8241 switch (params
->auth_type
)
8244 case OSPF_AUTH_NULL
:
8248 case OSPF_AUTH_SIMPLE
:
8252 case OSPF_AUTH_CRYPTOGRAPHIC
:
8253 auth_str
= " message-digest";
8261 vty_out (vty
, " ip ospf authentication%s", auth_str
);
8262 if (params
!= IF_DEF_PARAMS (ifp
))
8263 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8264 vty_out (vty
, "%s", VTY_NEWLINE
);
8267 /* Simple Authentication Password print. */
8268 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_simple
) &&
8269 params
->auth_simple
[0] != '\0')
8271 vty_out (vty
, " ip ospf authentication-key %s",
8272 params
->auth_simple
);
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 /* Cryptographic Authentication Key print. */
8279 for (ALL_LIST_ELEMENTS_RO (params
->auth_crypt
, n2
, ck
))
8281 vty_out (vty
, " ip ospf message-digest-key %d md5 %s",
8282 ck
->key_id
, ck
->auth_key
);
8283 if (params
!= IF_DEF_PARAMS (ifp
))
8284 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8285 vty_out (vty
, "%s", VTY_NEWLINE
);
8288 /* Interface Output Cost print. */
8289 if (OSPF_IF_PARAM_CONFIGURED (params
, output_cost_cmd
))
8291 vty_out (vty
, " ip ospf cost %u", params
->output_cost_cmd
);
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
);
8297 /* Hello Interval print. */
8298 if (OSPF_IF_PARAM_CONFIGURED (params
, v_hello
) &&
8299 params
->v_hello
!= OSPF_HELLO_INTERVAL_DEFAULT
)
8301 vty_out (vty
, " ip ospf hello-interval %u", params
->v_hello
);
8302 if (params
!= IF_DEF_PARAMS (ifp
))
8303 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8304 vty_out (vty
, "%s", VTY_NEWLINE
);
8308 /* Router Dead Interval print. */
8309 if (OSPF_IF_PARAM_CONFIGURED (params
, v_wait
) &&
8310 params
->v_wait
!= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
)
8312 vty_out (vty
, " ip ospf dead-interval ");
8315 if (OSPF_IF_PARAM_CONFIGURED (params
, fast_hello
))
8316 vty_out (vty
, "minimal hello-multiplier %d",
8317 params
->fast_hello
);
8319 vty_out (vty
, "%u", params
->v_wait
);
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 /* Router Priority print. */
8327 if (OSPF_IF_PARAM_CONFIGURED (params
, priority
) &&
8328 params
->priority
!= OSPF_ROUTER_PRIORITY_DEFAULT
)
8330 vty_out (vty
, " ip ospf priority %u", params
->priority
);
8331 if (params
!= IF_DEF_PARAMS (ifp
))
8332 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8333 vty_out (vty
, "%s", VTY_NEWLINE
);
8336 /* Retransmit Interval print. */
8337 if (OSPF_IF_PARAM_CONFIGURED (params
, retransmit_interval
) &&
8338 params
->retransmit_interval
!= OSPF_RETRANSMIT_INTERVAL_DEFAULT
)
8340 vty_out (vty
, " ip ospf retransmit-interval %u",
8341 params
->retransmit_interval
);
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
);
8347 /* Transmit Delay print. */
8348 if (OSPF_IF_PARAM_CONFIGURED (params
, transmit_delay
) &&
8349 params
->transmit_delay
!= OSPF_TRANSMIT_DELAY_DEFAULT
)
8351 vty_out (vty
, " ip ospf transmit-delay %u", params
->transmit_delay
);
8352 if (params
!= IF_DEF_PARAMS (ifp
))
8353 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8354 vty_out (vty
, "%s", VTY_NEWLINE
);
8358 if (OSPF_IF_PARAM_CONFIGURED (params
, if_area
))
8361 vty_out (vty
, " ip ospf %d area %s%s", ospf
->instance
,
8362 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
8364 vty_out (vty
, " ip ospf area %s%s",
8365 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
8370 ospf_bfd_write_config(vty
, params
);
8372 /* MTU ignore print. */
8373 if (OSPF_IF_PARAM_CONFIGURED (params
, mtu_ignore
) &&
8374 params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
8376 if (params
->mtu_ignore
== 0)
8377 vty_out (vty
, " no ip ospf mtu-ignore");
8379 vty_out (vty
, " ip ospf mtu-ignore");
8380 if (params
!= IF_DEF_PARAMS (ifp
))
8381 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8382 vty_out (vty
, "%s", VTY_NEWLINE
);
8389 rn
= route_top (IF_OIFS_PARAMS (ifp
));
8391 rn
= route_next (rn
);
8401 ospf_opaque_config_write_if (vty
, ifp
);
8408 config_write_network_area (struct vty
*vty
, struct ospf
*ospf
)
8410 struct route_node
*rn
;
8411 u_char buf
[INET_ADDRSTRLEN
];
8413 /* `network area' print. */
8414 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
8417 struct ospf_network
*n
= rn
->info
;
8419 memset (buf
, 0, INET_ADDRSTRLEN
);
8421 /* Create Area ID string by specified Area ID format. */
8422 if (n
->area_id_fmt
== OSPF_AREA_ID_FMT_DOTTEDQUAD
)
8423 strncpy ((char *) buf
, inet_ntoa (n
->area_id
), INET_ADDRSTRLEN
);
8425 sprintf ((char *) buf
, "%lu",
8426 (unsigned long int) ntohl (n
->area_id
.s_addr
));
8428 /* Network print. */
8429 vty_out (vty
, " network %s/%d area %s%s",
8430 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
8438 config_write_ospf_area (struct vty
*vty
, struct ospf
*ospf
)
8440 struct listnode
*node
;
8441 struct ospf_area
*area
;
8442 u_char buf
[INET_ADDRSTRLEN
];
8444 /* Area configuration print. */
8445 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
8447 struct route_node
*rn1
;
8449 area_id2str ((char *) buf
, INET_ADDRSTRLEN
, &area
->area_id
,
8452 if (area
->auth_type
!= OSPF_AUTH_NULL
)
8454 if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
8455 vty_out (vty
, " area %s authentication%s", buf
, VTY_NEWLINE
);
8457 vty_out (vty
, " area %s authentication message-digest%s",
8461 if (area
->shortcut_configured
!= OSPF_SHORTCUT_DEFAULT
)
8462 vty_out (vty
, " area %s shortcut %s%s", buf
,
8463 ospf_shortcut_mode_str
[area
->shortcut_configured
],
8466 if ((area
->external_routing
== OSPF_AREA_STUB
)
8467 || (area
->external_routing
== OSPF_AREA_NSSA
)
8470 if (area
->external_routing
== OSPF_AREA_STUB
)
8471 vty_out (vty
, " area %s stub", buf
);
8472 else if (area
->external_routing
== OSPF_AREA_NSSA
)
8474 vty_out (vty
, " area %s nssa", buf
);
8475 switch (area
->NSSATranslatorRole
)
8477 case OSPF_NSSA_ROLE_NEVER
:
8478 vty_out (vty
, " translate-never");
8480 case OSPF_NSSA_ROLE_ALWAYS
:
8481 vty_out (vty
, " translate-always");
8483 case OSPF_NSSA_ROLE_CANDIDATE
:
8485 vty_out (vty
, " translate-candidate");
8489 if (area
->no_summary
)
8490 vty_out (vty
, " no-summary");
8492 vty_out (vty
, "%s", VTY_NEWLINE
);
8494 if (area
->default_cost
!= 1)
8495 vty_out (vty
, " area %s default-cost %d%s", buf
,
8496 area
->default_cost
, VTY_NEWLINE
);
8499 for (rn1
= route_top (area
->ranges
); rn1
; rn1
= route_next (rn1
))
8502 struct ospf_area_range
*range
= rn1
->info
;
8504 vty_out (vty
, " area %s range %s/%d", buf
,
8505 inet_ntoa (rn1
->p
.u
.prefix4
), rn1
->p
.prefixlen
);
8507 if (range
->cost_config
!= OSPF_AREA_RANGE_COST_UNSPEC
)
8508 vty_out (vty
, " cost %d", range
->cost_config
);
8510 if (!CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_ADVERTISE
))
8511 vty_out (vty
, " not-advertise");
8513 if (CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_SUBSTITUTE
))
8514 vty_out (vty
, " substitute %s/%d",
8515 inet_ntoa (range
->subst_addr
), range
->subst_masklen
);
8517 vty_out (vty
, "%s", VTY_NEWLINE
);
8520 if (EXPORT_NAME (area
))
8521 vty_out (vty
, " area %s export-list %s%s", buf
,
8522 EXPORT_NAME (area
), VTY_NEWLINE
);
8524 if (IMPORT_NAME (area
))
8525 vty_out (vty
, " area %s import-list %s%s", buf
,
8526 IMPORT_NAME (area
), VTY_NEWLINE
);
8528 if (PREFIX_NAME_IN (area
))
8529 vty_out (vty
, " area %s filter-list prefix %s in%s", buf
,
8530 PREFIX_NAME_IN (area
), VTY_NEWLINE
);
8532 if (PREFIX_NAME_OUT (area
))
8533 vty_out (vty
, " area %s filter-list prefix %s out%s", buf
,
8534 PREFIX_NAME_OUT (area
), VTY_NEWLINE
);
8541 config_write_ospf_nbr_nbma (struct vty
*vty
, struct ospf
*ospf
)
8543 struct ospf_nbr_nbma
*nbr_nbma
;
8544 struct route_node
*rn
;
8546 /* Static Neighbor configuration print. */
8547 for (rn
= route_top (ospf
->nbr_nbma
); rn
; rn
= route_next (rn
))
8548 if ((nbr_nbma
= rn
->info
))
8550 vty_out (vty
, " neighbor %s", inet_ntoa (nbr_nbma
->addr
));
8552 if (nbr_nbma
->priority
!= OSPF_NEIGHBOR_PRIORITY_DEFAULT
)
8553 vty_out (vty
, " priority %d", nbr_nbma
->priority
);
8555 if (nbr_nbma
->v_poll
!= OSPF_POLL_INTERVAL_DEFAULT
)
8556 vty_out (vty
, " poll-interval %d", nbr_nbma
->v_poll
);
8558 vty_out (vty
, "%s", VTY_NEWLINE
);
8565 config_write_virtual_link (struct vty
*vty
, struct ospf
*ospf
)
8567 struct listnode
*node
;
8568 struct ospf_vl_data
*vl_data
;
8569 char buf
[INET_ADDRSTRLEN
];
8571 /* Virtual-Link print */
8572 for (ALL_LIST_ELEMENTS_RO (ospf
->vlinks
, node
, vl_data
))
8574 struct listnode
*n2
;
8575 struct crypt_key
*ck
;
8576 struct ospf_interface
*oi
;
8578 if (vl_data
!= NULL
)
8580 memset (buf
, 0, INET_ADDRSTRLEN
);
8582 area_id2str (buf
, sizeof(buf
), &vl_data
->vl_area_id
, vl_data
->vl_area_id_fmt
);
8583 oi
= vl_data
->vl_oi
;
8586 if (OSPF_IF_PARAM (oi
, v_hello
) != OSPF_HELLO_INTERVAL_DEFAULT
||
8587 OSPF_IF_PARAM (oi
, v_wait
) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
||
8588 OSPF_IF_PARAM (oi
, retransmit_interval
) != OSPF_RETRANSMIT_INTERVAL_DEFAULT
||
8589 OSPF_IF_PARAM (oi
, transmit_delay
) != OSPF_TRANSMIT_DELAY_DEFAULT
)
8590 vty_out (vty
, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
8592 inet_ntoa (vl_data
->vl_peer
),
8593 OSPF_IF_PARAM (oi
, v_hello
),
8594 OSPF_IF_PARAM (oi
, retransmit_interval
),
8595 OSPF_IF_PARAM (oi
, transmit_delay
),
8596 OSPF_IF_PARAM (oi
, v_wait
),
8599 vty_out (vty
, " area %s virtual-link %s%s", buf
,
8600 inet_ntoa (vl_data
->vl_peer
), VTY_NEWLINE
);
8602 if (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
[0] != '\0')
8603 vty_out (vty
, " area %s virtual-link %s authentication-key %s%s",
8605 inet_ntoa (vl_data
->vl_peer
),
8606 IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
,
8609 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_crypt
,
8611 vty_out (vty
, " area %s virtual-link %s"
8612 " message-digest-key %d md5 %s%s",
8614 inet_ntoa (vl_data
->vl_peer
),
8615 ck
->key_id
, ck
->auth_key
, VTY_NEWLINE
);
8625 config_write_ospf_redistribute (struct vty
*vty
, struct ospf
*ospf
)
8629 /* redistribute print. */
8630 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
8632 struct list
*red_list
;
8633 struct listnode
*node
;
8634 struct ospf_redist
*red
;
8636 red_list
= ospf
->redist
[type
];
8640 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
))
8642 vty_out (vty
, " redistribute %s", zebra_route_string(type
));
8644 vty_out (vty
, " %d", red
->instance
);
8646 if (red
->dmetric
.value
>= 0)
8647 vty_out (vty
, " metric %d", red
->dmetric
.value
);
8649 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
8650 vty_out (vty
, " metric-type 1");
8652 if (ROUTEMAP_NAME (red
))
8653 vty_out (vty
, " route-map %s", ROUTEMAP_NAME (red
));
8655 vty_out (vty
, "%s", VTY_NEWLINE
);
8663 config_write_ospf_default_metric (struct vty
*vty
, struct ospf
*ospf
)
8665 if (ospf
->default_metric
!= -1)
8666 vty_out (vty
, " default-metric %d%s", ospf
->default_metric
,
8672 config_write_ospf_distribute (struct vty
*vty
, struct ospf
*ospf
)
8675 struct ospf_redist
*red
;
8679 /* distribute-list print. */
8680 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
8681 if (DISTRIBUTE_NAME (ospf
, type
))
8682 vty_out (vty
, " distribute-list %s out %s%s",
8683 DISTRIBUTE_NAME (ospf
, type
),
8684 zebra_route_string(type
), VTY_NEWLINE
);
8686 /* default-information print. */
8687 if (ospf
->default_originate
!= DEFAULT_ORIGINATE_NONE
)
8689 vty_out (vty
, " default-information originate");
8690 if (ospf
->default_originate
== DEFAULT_ORIGINATE_ALWAYS
)
8691 vty_out (vty
, " always");
8693 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
8696 if (red
->dmetric
.value
>= 0)
8697 vty_out (vty
, " metric %d",
8698 red
->dmetric
.value
);
8699 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
8700 vty_out (vty
, " metric-type 1");
8702 if (ROUTEMAP_NAME (red
))
8703 vty_out (vty
, " route-map %s",
8704 ROUTEMAP_NAME (red
));
8707 vty_out (vty
, "%s", VTY_NEWLINE
);
8716 config_write_ospf_distance (struct vty
*vty
, struct ospf
*ospf
)
8718 struct route_node
*rn
;
8719 struct ospf_distance
*odistance
;
8721 if (ospf
->distance_all
)
8722 vty_out (vty
, " distance %d%s", ospf
->distance_all
, VTY_NEWLINE
);
8724 if (ospf
->distance_intra
8725 || ospf
->distance_inter
8726 || ospf
->distance_external
)
8728 vty_out (vty
, " distance ospf");
8730 if (ospf
->distance_intra
)
8731 vty_out (vty
, " intra-area %d", ospf
->distance_intra
);
8732 if (ospf
->distance_inter
)
8733 vty_out (vty
, " inter-area %d", ospf
->distance_inter
);
8734 if (ospf
->distance_external
)
8735 vty_out (vty
, " external %d", ospf
->distance_external
);
8737 vty_out (vty
, "%s", VTY_NEWLINE
);
8740 for (rn
= route_top (ospf
->distance_table
); rn
; rn
= route_next (rn
))
8741 if ((odistance
= rn
->info
) != NULL
)
8743 vty_out (vty
, " distance %d %s/%d %s%s", odistance
->distance
,
8744 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
8745 odistance
->access_list
? odistance
->access_list
: "",
8751 /* OSPF configuration write function. */
8753 ospf_config_write (struct vty
*vty
)
8756 struct interface
*ifp
;
8757 struct ospf_interface
*oi
;
8758 struct listnode
*node
;
8761 ospf
= ospf_lookup ();
8762 if (ospf
!= NULL
&& ospf
->oi_running
)
8764 /* `router ospf' print. */
8766 vty_out (vty
, "router ospf %d%s", ospf
->instance
, VTY_NEWLINE
);
8768 vty_out (vty
, "router ospf%s", VTY_NEWLINE
);
8772 if (!ospf
->networks
)
8775 /* Router ID print. */
8776 if (ospf
->router_id_static
.s_addr
!= 0)
8777 vty_out (vty
, " ospf router-id %s%s",
8778 inet_ntoa (ospf
->router_id_static
), VTY_NEWLINE
);
8780 /* ABR type print. */
8781 if (ospf
->abr_type
!= OSPF_ABR_DEFAULT
)
8782 vty_out (vty
, " ospf abr-type %s%s",
8783 ospf_abr_type_str
[ospf
->abr_type
], VTY_NEWLINE
);
8785 /* log-adjacency-changes flag print. */
8786 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
))
8788 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
8789 vty_out(vty
, " log-adjacency-changes detail%s", VTY_NEWLINE
);
8790 else if (!DFLT_OSPF_LOG_ADJACENCY_CHANGES
)
8791 vty_out(vty
, " log-adjacency-changes%s", VTY_NEWLINE
);
8793 else if (DFLT_OSPF_LOG_ADJACENCY_CHANGES
)
8795 vty_out(vty
, " no log-adjacency-changes%s", VTY_NEWLINE
);
8798 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
8799 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
8800 vty_out (vty
, " compatible rfc1583%s", VTY_NEWLINE
);
8802 /* auto-cost reference-bandwidth configuration. */
8803 if (ospf
->ref_bandwidth
!= OSPF_DEFAULT_REF_BANDWIDTH
)
8805 vty_out (vty
, "! Important: ensure reference bandwidth "
8806 "is consistent across all routers%s", VTY_NEWLINE
);
8807 vty_out (vty
, " auto-cost reference-bandwidth %d%s",
8808 ospf
->ref_bandwidth
, VTY_NEWLINE
);
8811 /* SPF timers print. */
8812 if (ospf
->spf_delay
!= OSPF_SPF_DELAY_DEFAULT
||
8813 ospf
->spf_holdtime
!= OSPF_SPF_HOLDTIME_DEFAULT
||
8814 ospf
->spf_max_holdtime
!= OSPF_SPF_MAX_HOLDTIME_DEFAULT
)
8815 vty_out (vty
, " timers throttle spf %d %d %d%s",
8816 ospf
->spf_delay
, ospf
->spf_holdtime
,
8817 ospf
->spf_max_holdtime
, VTY_NEWLINE
);
8819 /* LSA timers print. */
8820 if (ospf
->min_ls_interval
!= OSPF_MIN_LS_INTERVAL
)
8821 vty_out (vty
, " timers throttle lsa all %d%s",
8822 ospf
->min_ls_interval
, VTY_NEWLINE
);
8823 if (ospf
->min_ls_arrival
!= OSPF_MIN_LS_ARRIVAL
)
8824 vty_out (vty
, " timers lsa min-arrival %d%s",
8825 ospf
->min_ls_arrival
, VTY_NEWLINE
);
8827 /* Write multiplier print. */
8828 if (ospf
->write_oi_count
!= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
)
8829 vty_out (vty
, " ospf write-multiplier %d%s",
8830 ospf
->write_oi_count
, VTY_NEWLINE
);
8832 /* Max-metric router-lsa print */
8833 config_write_stub_router (vty
, ospf
);
8835 /* SPF refresh parameters print. */
8836 if (ospf
->lsa_refresh_interval
!= OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
8837 vty_out (vty
, " refresh timer %d%s",
8838 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
8840 /* Redistribute information print. */
8841 config_write_ospf_redistribute (vty
, ospf
);
8843 /* passive-interface print. */
8844 if (ospf
->passive_interface_default
== OSPF_IF_PASSIVE
)
8845 vty_out (vty
, " passive-interface default%s", VTY_NEWLINE
);
8847 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, node
, ifp
))
8848 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
)
8849 && IF_DEF_PARAMS (ifp
)->passive_interface
!=
8850 ospf
->passive_interface_default
)
8852 vty_out (vty
, " %spassive-interface %s%s",
8853 IF_DEF_PARAMS (ifp
)->passive_interface
? "" : "no ",
8854 ifp
->name
, VTY_NEWLINE
);
8856 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
8858 if (!OSPF_IF_PARAM_CONFIGURED (oi
->params
, passive_interface
))
8860 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi
->ifp
),
8863 if (oi
->params
->passive_interface
== IF_DEF_PARAMS (oi
->ifp
)->passive_interface
)
8866 else if (oi
->params
->passive_interface
== ospf
->passive_interface_default
)
8869 vty_out (vty
, " %spassive-interface %s %s%s",
8870 oi
->params
->passive_interface
? "" : "no ",
8872 inet_ntoa (oi
->address
->u
.prefix4
), VTY_NEWLINE
);
8875 /* Network area print. */
8876 config_write_network_area (vty
, ospf
);
8878 /* Area config print. */
8879 config_write_ospf_area (vty
, ospf
);
8881 /* static neighbor print. */
8882 config_write_ospf_nbr_nbma (vty
, ospf
);
8884 /* Virtual-Link print. */
8885 config_write_virtual_link (vty
, ospf
);
8887 /* Default metric configuration. */
8888 config_write_ospf_default_metric (vty
, ospf
);
8890 /* Distribute-list and default-information print. */
8891 config_write_ospf_distribute (vty
, ospf
);
8893 /* Distance configuration. */
8894 config_write_ospf_distance (vty
, ospf
);
8896 ospf_opaque_config_write_router (vty
, ospf
);
8903 ospf_vty_show_init (void)
8905 /* "show ip ospf" commands. */
8906 install_element (VIEW_NODE
, &show_ip_ospf_cmd
);
8908 install_element (VIEW_NODE
, &show_ip_ospf_instance_cmd
);
8910 /* "show ip ospf database" commands. */
8911 install_element (VIEW_NODE
, &show_ip_ospf_database_type_adv_router_cmd
);
8912 install_element (VIEW_NODE
, &show_ip_ospf_database_max_cmd
);
8914 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_adv_router_cmd
);
8915 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_cmd
);
8916 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_max_cmd
);
8918 /* "show ip ospf interface" commands. */
8919 install_element (VIEW_NODE
, &show_ip_ospf_interface_cmd
);
8921 install_element (VIEW_NODE
, &show_ip_ospf_instance_interface_cmd
);
8923 /* "show ip ospf neighbor" commands. */
8924 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_detail_cmd
);
8925 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_cmd
);
8926 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_id_cmd
);
8927 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_all_cmd
);
8928 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_cmd
);
8929 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_cmd
);
8930 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_all_cmd
);
8932 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_detail_cmd
);
8933 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_cmd
);
8934 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_id_cmd
);
8935 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_all_cmd
);
8936 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_cmd
);
8937 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_cmd
);
8938 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_all_cmd
);
8940 /* "show ip ospf route" commands. */
8941 install_element (VIEW_NODE
, &show_ip_ospf_route_cmd
);
8942 install_element (VIEW_NODE
, &show_ip_ospf_border_routers_cmd
);
8944 install_element (VIEW_NODE
, &show_ip_ospf_instance_route_cmd
);
8945 install_element (VIEW_NODE
, &show_ip_ospf_instance_border_routers_cmd
);
8949 /* ospfd's interface node. */
8950 static struct cmd_node interface_node
=
8957 /* Initialization of OSPF interface. */
8959 ospf_vty_if_init (void)
8961 /* Install interface node. */
8962 install_node (&interface_node
, config_write_interface
);
8965 /* "ip ospf authentication" commands. */
8966 install_element (INTERFACE_NODE
, &ip_ospf_authentication_args_addr_cmd
);
8967 install_element (INTERFACE_NODE
, &ip_ospf_authentication_addr_cmd
);
8968 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_args_addr_cmd
);
8969 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_addr_cmd
);
8970 install_element (INTERFACE_NODE
, &ip_ospf_authentication_key_addr_cmd
);
8971 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_key_authkey_addr_cmd
);
8972 install_element (INTERFACE_NODE
, &no_ospf_authentication_key_authkey_addr_cmd
);
8974 /* "ip ospf message-digest-key" commands. */
8975 install_element (INTERFACE_NODE
, &ip_ospf_message_digest_key_cmd
);
8976 install_element (INTERFACE_NODE
, &no_ip_ospf_message_digest_key_cmd
);
8978 /* "ip ospf cost" commands. */
8979 install_element (INTERFACE_NODE
, &ip_ospf_cost_cmd
);
8980 install_element (INTERFACE_NODE
, &no_ip_ospf_cost_cmd
);
8982 /* "ip ospf mtu-ignore" commands. */
8983 install_element (INTERFACE_NODE
, &ip_ospf_mtu_ignore_addr_cmd
);
8984 install_element (INTERFACE_NODE
, &no_ip_ospf_mtu_ignore_addr_cmd
);
8986 /* "ip ospf dead-interval" commands. */
8987 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_cmd
);
8988 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_minimal_addr_cmd
);
8989 install_element (INTERFACE_NODE
, &no_ip_ospf_dead_interval_cmd
);
8991 /* "ip ospf hello-interval" commands. */
8992 install_element (INTERFACE_NODE
, &ip_ospf_hello_interval_cmd
);
8993 install_element (INTERFACE_NODE
, &no_ip_ospf_hello_interval_cmd
);
8995 /* "ip ospf network" commands. */
8996 install_element (INTERFACE_NODE
, &ip_ospf_network_cmd
);
8997 install_element (INTERFACE_NODE
, &no_ip_ospf_network_cmd
);
8999 /* "ip ospf priority" commands. */
9000 install_element (INTERFACE_NODE
, &ip_ospf_priority_cmd
);
9001 install_element (INTERFACE_NODE
, &no_ip_ospf_priority_cmd
);
9003 /* "ip ospf retransmit-interval" commands. */
9004 install_element (INTERFACE_NODE
, &ip_ospf_retransmit_interval_addr_cmd
);
9005 install_element (INTERFACE_NODE
, &no_ip_ospf_retransmit_interval_addr_cmd
);
9007 /* "ip ospf transmit-delay" commands. */
9008 install_element (INTERFACE_NODE
, &ip_ospf_transmit_delay_addr_cmd
);
9009 install_element (INTERFACE_NODE
, &no_ip_ospf_transmit_delay_addr_cmd
);
9011 /* "ip ospf area" commands. */
9012 install_element (INTERFACE_NODE
, &ip_ospf_area_cmd
);
9013 install_element (INTERFACE_NODE
, &no_ip_ospf_area_cmd
);
9015 /* These commands are compatibitliy for previous version. */
9016 install_element (INTERFACE_NODE
, &ospf_authentication_key_cmd
);
9017 install_element (INTERFACE_NODE
, &ospf_message_digest_key_cmd
);
9018 install_element (INTERFACE_NODE
, &no_ospf_message_digest_key_cmd
);
9019 install_element (INTERFACE_NODE
, &ospf_dead_interval_cmd
);
9020 install_element (INTERFACE_NODE
, &no_ospf_dead_interval_cmd
);
9021 install_element (INTERFACE_NODE
, &ospf_hello_interval_cmd
);
9022 install_element (INTERFACE_NODE
, &no_ospf_hello_interval_cmd
);
9023 install_element (INTERFACE_NODE
, &ospf_cost_cmd
);
9024 install_element (INTERFACE_NODE
, &no_ospf_cost_cmd
);
9025 install_element (INTERFACE_NODE
, &ospf_network_cmd
);
9026 install_element (INTERFACE_NODE
, &no_ospf_network_cmd
);
9027 install_element (INTERFACE_NODE
, &ospf_priority_cmd
);
9028 install_element (INTERFACE_NODE
, &no_ospf_priority_cmd
);
9029 install_element (INTERFACE_NODE
, &ospf_retransmit_interval_cmd
);
9030 install_element (INTERFACE_NODE
, &no_ospf_retransmit_interval_cmd
);
9031 install_element (INTERFACE_NODE
, &ospf_transmit_delay_cmd
);
9032 install_element (INTERFACE_NODE
, &no_ospf_transmit_delay_cmd
);
9036 ospf_vty_zebra_init (void)
9038 install_element (OSPF_NODE
, &ospf_redistribute_source_cmd
);
9039 install_element (OSPF_NODE
, &no_ospf_redistribute_source_cmd
);
9040 install_element (OSPF_NODE
, &ospf_redistribute_instance_source_cmd
);
9041 install_element (OSPF_NODE
, &no_ospf_redistribute_instance_source_cmd
);
9043 install_element (OSPF_NODE
, &ospf_distribute_list_out_cmd
);
9044 install_element (OSPF_NODE
, &no_ospf_distribute_list_out_cmd
);
9046 install_element (OSPF_NODE
, &ospf_default_information_originate_cmd
);
9047 install_element (OSPF_NODE
, &no_ospf_default_information_originate_cmd
);
9049 install_element (OSPF_NODE
, &ospf_default_metric_cmd
);
9050 install_element (OSPF_NODE
, &no_ospf_default_metric_cmd
);
9052 install_element (OSPF_NODE
, &ospf_distance_cmd
);
9053 install_element (OSPF_NODE
, &no_ospf_distance_cmd
);
9054 install_element (OSPF_NODE
, &no_ospf_distance_ospf_cmd
);
9055 install_element (OSPF_NODE
, &ospf_distance_ospf_cmd
);
9057 install_element (OSPF_NODE
, &ospf_distance_source_cmd
);
9058 install_element (OSPF_NODE
, &no_ospf_distance_source_cmd
);
9059 install_element (OSPF_NODE
, &ospf_distance_source_access_list_cmd
);
9060 install_element (OSPF_NODE
, &no_ospf_distance_source_access_list_cmd
);
9064 static struct cmd_node ospf_node
=
9067 "%s(config-router)# ",
9072 ospf_interface_clear (struct interface
*ifp
)
9074 if (!if_is_operative (ifp
)) return;
9076 if (IS_DEBUG_OSPF (ism
, ISM_EVENTS
))
9077 zlog_debug("ISM[%s]: clear by reset", ifp
->name
);
9082 DEFUN (clear_ip_ospf_interface
,
9083 clear_ip_ospf_interface_cmd
,
9084 "clear ip ospf interface [IFNAME]",
9087 "OSPF information\n"
9088 "Interface information\n"
9092 struct interface
*ifp
;
9093 struct listnode
*node
;
9095 if (argc
== 4) /* Clear all the ospfv2 interfaces. */
9097 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
9098 ospf_interface_clear(ifp
);
9100 else /* Interface name is specified. */
9102 if ((ifp
= if_lookup_by_name (argv
[idx_ifname
]->text
, VRF_DEFAULT
)) == NULL
)
9103 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
9105 ospf_interface_clear(ifp
);
9112 ospf_vty_clear_init (void)
9114 install_element (ENABLE_NODE
, &clear_ip_ospf_interface_cmd
);
9118 /* Install OSPF related vty commands. */
9120 ospf_vty_init (void)
9122 /* Install ospf top node. */
9123 install_node (&ospf_node
, ospf_config_write
);
9125 /* "router ospf" commands. */
9126 install_element (CONFIG_NODE
, &router_ospf_cmd
);
9127 install_element (CONFIG_NODE
, &no_router_ospf_cmd
);
9130 install_default (OSPF_NODE
);
9132 /* "ospf router-id" commands. */
9133 install_element (OSPF_NODE
, &ospf_router_id_cmd
);
9134 install_element (OSPF_NODE
, &ospf_router_id_old_cmd
);
9135 install_element (OSPF_NODE
, &no_ospf_router_id_cmd
);
9137 /* "passive-interface" commands. */
9138 install_element (OSPF_NODE
, &ospf_passive_interface_addr_cmd
);
9139 install_element (OSPF_NODE
, &no_ospf_passive_interface_addr_cmd
);
9141 /* "ospf abr-type" commands. */
9142 install_element (OSPF_NODE
, &ospf_abr_type_cmd
);
9143 install_element (OSPF_NODE
, &no_ospf_abr_type_cmd
);
9145 /* "ospf log-adjacency-changes" commands. */
9146 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_cmd
);
9147 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_detail_cmd
);
9148 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_cmd
);
9149 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_detail_cmd
);
9151 /* "ospf rfc1583-compatible" commands. */
9152 install_element (OSPF_NODE
, &ospf_compatible_rfc1583_cmd
);
9153 install_element (OSPF_NODE
, &no_ospf_compatible_rfc1583_cmd
);
9154 install_element (OSPF_NODE
, &ospf_rfc1583_flag_cmd
);
9155 install_element (OSPF_NODE
, &no_ospf_rfc1583_flag_cmd
);
9157 /* "network area" commands. */
9158 install_element (OSPF_NODE
, &ospf_network_area_cmd
);
9159 install_element (OSPF_NODE
, &no_ospf_network_area_cmd
);
9161 /* "area authentication" commands. */
9162 install_element (OSPF_NODE
, &ospf_area_authentication_message_digest_cmd
);
9163 install_element (OSPF_NODE
, &ospf_area_authentication_cmd
);
9164 install_element (OSPF_NODE
, &no_ospf_area_authentication_cmd
);
9166 /* "area range" commands. */
9167 install_element (OSPF_NODE
, &ospf_area_range_cmd
);
9168 install_element (OSPF_NODE
, &ospf_area_range_cost_cmd
);
9169 install_element (OSPF_NODE
, &ospf_area_range_not_advertise_cmd
);
9170 install_element (OSPF_NODE
, &no_ospf_area_range_cmd
);
9171 install_element (OSPF_NODE
, &ospf_area_range_substitute_cmd
);
9172 install_element (OSPF_NODE
, &no_ospf_area_range_substitute_cmd
);
9174 /* "area virtual-link" commands. */
9175 install_element (OSPF_NODE
, &ospf_area_vlink_cmd
);
9176 install_element (OSPF_NODE
, &ospf_area_vlink_intervals_cmd
);
9177 install_element (OSPF_NODE
, &no_ospf_area_vlink_cmd
);
9178 install_element (OSPF_NODE
, &no_ospf_area_vlink_intervals_cmd
);
9189 /* "area stub" commands. */
9190 install_element (OSPF_NODE
, &ospf_area_stub_no_summary_cmd
);
9191 install_element (OSPF_NODE
, &ospf_area_stub_cmd
);
9192 install_element (OSPF_NODE
, &no_ospf_area_stub_no_summary_cmd
);
9193 install_element (OSPF_NODE
, &no_ospf_area_stub_cmd
);
9195 /* "area nssa" commands. */
9196 install_element (OSPF_NODE
, &ospf_area_nssa_cmd
);
9197 install_element (OSPF_NODE
, &ospf_area_nssa_translate_no_summary_cmd
);
9198 install_element (OSPF_NODE
, &ospf_area_nssa_translate_cmd
);
9199 install_element (OSPF_NODE
, &ospf_area_nssa_no_summary_cmd
);
9200 install_element (OSPF_NODE
, &no_ospf_area_nssa_cmd
);
9202 install_element (OSPF_NODE
, &ospf_area_default_cost_cmd
);
9203 install_element (OSPF_NODE
, &no_ospf_area_default_cost_cmd
);
9205 install_element (OSPF_NODE
, &ospf_area_shortcut_cmd
);
9206 install_element (OSPF_NODE
, &no_ospf_area_shortcut_cmd
);
9208 install_element (OSPF_NODE
, &ospf_area_export_list_cmd
);
9209 install_element (OSPF_NODE
, &no_ospf_area_export_list_cmd
);
9211 install_element (OSPF_NODE
, &ospf_area_filter_list_cmd
);
9212 install_element (OSPF_NODE
, &no_ospf_area_filter_list_cmd
);
9214 install_element (OSPF_NODE
, &ospf_area_import_list_cmd
);
9215 install_element (OSPF_NODE
, &no_ospf_area_import_list_cmd
);
9217 /* SPF timer commands */
9218 install_element (OSPF_NODE
, &ospf_timers_throttle_spf_cmd
);
9219 install_element (OSPF_NODE
, &no_ospf_timers_throttle_spf_cmd
);
9221 /* LSA timers commands */
9222 install_element (OSPF_NODE
, &ospf_timers_min_ls_interval_cmd
);
9223 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_interval_cmd
);
9224 install_element (OSPF_NODE
, &ospf_timers_min_ls_arrival_cmd
);
9225 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_arrival_cmd
);
9226 install_element (OSPF_NODE
, &ospf_timers_lsa_cmd
);
9227 install_element (OSPF_NODE
, &no_ospf_timers_lsa_cmd
);
9229 /* refresh timer commands */
9230 install_element (OSPF_NODE
, &ospf_refresh_timer_cmd
);
9231 install_element (OSPF_NODE
, &no_ospf_refresh_timer_val_cmd
);
9233 /* max-metric commands */
9234 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_admin_cmd
);
9235 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_admin_cmd
);
9236 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_startup_cmd
);
9237 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_startup_cmd
);
9238 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_shutdown_cmd
);
9239 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_shutdown_cmd
);
9241 /* reference bandwidth commands */
9242 install_element (OSPF_NODE
, &ospf_auto_cost_reference_bandwidth_cmd
);
9243 install_element (OSPF_NODE
, &no_ospf_auto_cost_reference_bandwidth_cmd
);
9245 /* "neighbor" commands. */
9246 install_element (OSPF_NODE
, &ospf_neighbor_cmd
);
9247 install_element (OSPF_NODE
, &ospf_neighbor_poll_interval_cmd
);
9248 install_element (OSPF_NODE
, &no_ospf_neighbor_cmd
);
9249 install_element (OSPF_NODE
, &no_ospf_neighbor_poll_cmd
);
9251 /* write multiplier commands */
9252 install_element (OSPF_NODE
, &ospf_write_multiplier_cmd
);
9253 install_element (OSPF_NODE
, &write_multiplier_cmd
);
9254 install_element (OSPF_NODE
, &no_ospf_write_multiplier_cmd
);
9255 install_element (OSPF_NODE
, &no_write_multiplier_cmd
);
9257 /* Init interface related vty commands. */
9258 ospf_vty_if_init ();
9260 /* Init zebra related vty commands. */
9261 ospf_vty_zebra_init ();