2 * Copyright (C) 2005 6WIND <alain.ritoux@6wind.com>
3 * Copyright (C) 2000 Toshiaki Takada
5 * This file is part of GNU Zebra.
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Zebra; see the file COPYING. If not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
39 #include "ospfd/ospfd.h"
40 #include "ospfd/ospf_asbr.h"
41 #include "ospfd/ospf_lsa.h"
42 #include "ospfd/ospf_lsdb.h"
43 #include "ospfd/ospf_ism.h"
44 #include "ospfd/ospf_interface.h"
45 #include "ospfd/ospf_nsm.h"
46 #include "ospfd/ospf_neighbor.h"
47 #include "ospfd/ospf_flood.h"
48 #include "ospfd/ospf_abr.h"
49 #include "ospfd/ospf_spf.h"
50 #include "ospfd/ospf_route.h"
51 #include "ospfd/ospf_zebra.h"
52 /*#include "ospfd/ospf_routemap.h" */
53 #include "ospfd/ospf_vty.h"
54 #include "ospfd/ospf_dump.h"
55 #include "ospfd/ospf_bfd.h"
57 static const char *ospf_network_type_str
[] = {
58 "Null", "POINTOPOINT", "BROADCAST", "NBMA", "POINTOMULTIPOINT",
59 "VIRTUALLINK", "LOOPBACK"};
61 /* Utility functions. */
62 int str2area_id(const char *str
, struct in_addr
*area_id
, int *area_id_fmt
)
66 area_id
->s_addr
= htonl(strtoul(str
, &ep
, 10));
67 if (*ep
&& !inet_aton(str
, area_id
))
71 *ep
? OSPF_AREA_ID_FMT_DOTTEDQUAD
: OSPF_AREA_ID_FMT_DECIMAL
;
76 void area_id2str(char *buf
, int length
, struct in_addr
*area_id
,
79 memset(buf
, 0, length
);
81 if (area_id_fmt
== OSPF_AREA_ID_FMT_DOTTEDQUAD
)
82 strncpy(buf
, inet_ntoa(*area_id
), length
);
84 sprintf(buf
, "%lu", (unsigned long)ntohl(area_id
->s_addr
));
87 static int str2metric(const char *str
, int *metric
)
93 *metric
= strtol(str
, NULL
, 10);
94 if (*metric
< 0 && *metric
> 16777214) {
95 /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE);
103 static int str2metric_type(const char *str
, int *metric_type
)
109 if (strncmp(str
, "1", 1) == 0)
110 *metric_type
= EXTERNAL_METRIC_TYPE_1
;
111 else if (strncmp(str
, "2", 1) == 0)
112 *metric_type
= EXTERNAL_METRIC_TYPE_2
;
119 int ospf_oi_count(struct interface
*ifp
)
121 struct route_node
*rn
;
124 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
))
131 DEFUN_NOSH (router_ospf
,
133 "router ospf [(1-65535)]",
134 "Enable a routing process\n"
135 "Start OSPF configuration\n"
139 u_short instance
= 0;
141 ospf
= ospf_lookup();
143 vty_out(vty
, "There isn't active ospf instance %s",
149 VTY_GET_INTEGER("Instance", instance
, argv
[2]->arg
);
151 /* The following logic to set the vty qobj index is in place to be able
152 to ignore the commands which dont belong to this instance. */
153 if (ospf
->instance
!= instance
)
154 VTY_PUSH_CONTEXT_NULL(OSPF_NODE
);
156 if (IS_DEBUG_OSPF_EVENT
)
157 zlog_debug("Config command 'router ospf %d' received",
159 ospf
->oi_running
= 1;
160 VTY_PUSH_CONTEXT(OSPF_NODE
, ospf
);
161 ospf_router_id_update(ospf
);
167 DEFUN (no_router_ospf
,
169 "no router ospf [(1-65535)]",
171 "Enable a routing process\n"
172 "Start OSPF configuration\n"
176 u_short instance
= 0;
179 VTY_GET_INTEGER("Instance", instance
, argv
[3]->arg
);
181 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
)
190 DEFUN (ospf_router_id
,
192 "ospf router-id A.B.C.D",
193 "OSPF specific commands\n"
194 "router-id for the OSPF process\n"
195 "OSPF router-id in IP address format\n")
197 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
199 struct listnode
*node
;
200 struct ospf_area
*area
;
201 struct in_addr router_id
;
204 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &router_id
);
206 vty_out(vty
, "Please specify Router ID by A.B.C.D%s",
211 ospf
->router_id_static
= router_id
;
213 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
))
214 if (area
->full_nbrs
) {
216 "For this router-id change to take effect,"
217 " save config and restart ospfd%s",
222 ospf_router_id_update(ospf
);
227 DEFUN_HIDDEN (ospf_router_id_old
,
228 ospf_router_id_old_cmd
,
230 "router-id for the OSPF process\n"
231 "OSPF router-id in IP address format\n")
233 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
235 struct listnode
*node
;
236 struct ospf_area
*area
;
237 struct in_addr router_id
;
240 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &router_id
);
242 vty_out(vty
, "Please specify Router ID by A.B.C.D%s",
247 ospf
->router_id_static
= router_id
;
249 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
))
250 if (area
->full_nbrs
) {
252 "For this router-id change to take effect,"
253 " save config and restart ospfd%s",
258 ospf_router_id_update(ospf
);
263 DEFUN (no_ospf_router_id
,
264 no_ospf_router_id_cmd
,
265 "no ospf router-id [A.B.C.D]",
267 "OSPF specific commands\n"
268 "router-id for the OSPF process\n"
269 "OSPF router-id in IP address format\n")
271 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
272 struct listnode
*node
;
273 struct ospf_area
*area
;
275 ospf
->router_id_static
.s_addr
= 0;
277 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
))
278 if (area
->full_nbrs
) {
280 "For this router-id change to take effect,"
281 " save config and restart ospfd%s",
286 ospf_router_id_update(ospf
);
292 static void ospf_passive_interface_default(struct ospf
*ospf
, u_char newval
)
295 struct interface
*ifp
;
296 struct ospf_interface
*oi
;
298 ospf
->passive_interface_default
= newval
;
300 for (ALL_LIST_ELEMENTS_RO(om
->iflist
, ln
, ifp
)) {
301 if (ifp
&& OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp
),
303 UNSET_IF_PARAM(IF_DEF_PARAMS(ifp
), passive_interface
);
305 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, ln
, oi
)) {
306 if (OSPF_IF_PARAM_CONFIGURED(oi
->params
, passive_interface
))
307 UNSET_IF_PARAM(oi
->params
, passive_interface
);
308 /* update multicast memberships */
309 ospf_if_set_multicast(oi
);
313 static void ospf_passive_interface_update_addr(struct ospf
*ospf
,
314 struct interface
*ifp
,
315 struct ospf_if_params
*params
,
321 params
->passive_interface
= value
;
322 if (params
!= IF_DEF_PARAMS(ifp
)) {
323 if (OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp
),
325 dflt
= IF_DEF_PARAMS(ifp
)->passive_interface
;
327 dflt
= ospf
->passive_interface_default
;
330 SET_IF_PARAM(params
, passive_interface
);
332 UNSET_IF_PARAM(params
, passive_interface
);
334 ospf_free_if_params(ifp
, addr
);
335 ospf_if_update_params(ifp
, addr
);
339 static void ospf_passive_interface_update(struct ospf
*ospf
,
340 struct interface
*ifp
,
341 struct ospf_if_params
*params
,
344 params
->passive_interface
= value
;
345 if (params
== IF_DEF_PARAMS(ifp
)) {
346 if (value
!= ospf
->passive_interface_default
)
347 SET_IF_PARAM(params
, passive_interface
);
349 UNSET_IF_PARAM(params
, passive_interface
);
353 DEFUN (ospf_passive_interface
,
354 ospf_passive_interface_addr_cmd
,
355 "passive-interface <IFNAME [A.B.C.D]|default>",
356 "Suppress routing updates on an interface\n"
359 "Suppress routing updates on interfaces by default\n")
361 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
363 struct interface
*ifp
;
364 struct in_addr addr
= {.s_addr
= INADDR_ANY
};
366 struct ospf_if_params
*params
;
367 struct route_node
*rn
;
369 if (strcmp(argv
[1]->text
, "default") == 0) {
370 ospf_passive_interface_default(ospf
, OSPF_IF_PASSIVE
);
374 ifp
= if_get_by_name(argv
[1]->arg
, VRF_DEFAULT
);
376 params
= IF_DEF_PARAMS(ifp
);
379 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
382 "Please specify interface address by A.B.C.D%s",
387 params
= ospf_get_if_params(ifp
, addr
);
388 ospf_if_update_params(ifp
, addr
);
389 ospf_passive_interface_update_addr(ospf
, ifp
, params
,
390 OSPF_IF_PASSIVE
, addr
);
393 ospf_passive_interface_update(ospf
, ifp
, params
, OSPF_IF_PASSIVE
);
395 /* XXX We should call ospf_if_set_multicast on exactly those
396 * interfaces for which the passive property changed. It is too much
397 * work to determine this set, so we do this for every interface.
398 * This is safe and reasonable because ospf_if_set_multicast uses a
399 * record of joined groups to avoid systems calls if the desired
400 * memberships match the current memership.
403 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
404 struct ospf_interface
*oi
= rn
->info
;
406 if (oi
&& (OSPF_IF_PARAM(oi
, passive_interface
)
408 ospf_if_set_multicast(oi
);
411 * XXX It is not clear what state transitions the interface needs to
412 * undergo when going from active to passive. Fixing this will
413 * require precise identification of interfaces having such a
420 DEFUN (no_ospf_passive_interface
,
421 no_ospf_passive_interface_addr_cmd
,
422 "no passive-interface <IFNAME [A.B.C.D]|default>",
424 "Allow routing updates on an interface\n"
427 "Allow routing updates on interfaces by default\n")
429 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
431 struct interface
*ifp
;
432 struct in_addr addr
= {.s_addr
= INADDR_ANY
};
433 struct ospf_if_params
*params
;
435 struct route_node
*rn
;
437 if (strcmp(argv
[2]->text
, "default") == 0) {
438 ospf_passive_interface_default(ospf
, OSPF_IF_ACTIVE
);
442 ifp
= if_get_by_name(argv
[2]->arg
, VRF_DEFAULT
);
444 params
= IF_DEF_PARAMS(ifp
);
447 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
450 "Please specify interface address by A.B.C.D%s",
455 params
= ospf_lookup_if_params(ifp
, addr
);
458 ospf_passive_interface_update_addr(ospf
, ifp
, params
,
459 OSPF_IF_ACTIVE
, addr
);
461 ospf_passive_interface_update(ospf
, ifp
, params
, OSPF_IF_ACTIVE
);
463 /* XXX We should call ospf_if_set_multicast on exactly those
464 * interfaces for which the passive property changed. It is too much
465 * work to determine this set, so we do this for every interface.
466 * This is safe and reasonable because ospf_if_set_multicast uses a
467 * record of joined groups to avoid systems calls if the desired
468 * memberships match the current memership.
470 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
471 struct ospf_interface
*oi
= rn
->info
;
474 && (OSPF_IF_PARAM(oi
, passive_interface
) == OSPF_IF_ACTIVE
))
475 ospf_if_set_multicast(oi
);
482 DEFUN (ospf_network_area
,
483 ospf_network_area_cmd
,
484 "network A.B.C.D/M area <A.B.C.D|(0-4294967295)>",
485 "Enable routing on an IP network\n"
486 "OSPF network prefix\n"
487 "Set the OSPF area ID\n"
488 "OSPF area ID in IP address format\n"
489 "OSPF area ID as a decimal value\n")
491 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
492 int idx_ipv4_prefixlen
= 1;
493 int idx_ipv4_number
= 3;
494 struct prefix_ipv4 p
;
495 struct in_addr area_id
;
498 if (ospf
->instance
) {
500 "The network command is not supported in multi-instance ospf%s",
505 if (ospf
->if_ospf_cli_count
> 0) {
507 "Please remove all ip ospf area x.x.x.x commands first.%s",
512 /* Get network prefix and Area ID. */
513 VTY_GET_IPV4_PREFIX("network prefix", p
, argv
[idx_ipv4_prefixlen
]->arg
);
514 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
516 ret
= ospf_network_set(ospf
, &p
, area_id
, format
);
518 vty_out(vty
, "There is already same network statement.%s",
526 DEFUN (no_ospf_network_area
,
527 no_ospf_network_area_cmd
,
528 "no network A.B.C.D/M area <A.B.C.D|(0-4294967295)>",
530 "Enable routing on an IP network\n"
531 "OSPF network prefix\n"
532 "Set the OSPF area ID\n"
533 "OSPF area ID in IP address format\n"
534 "OSPF area ID as a decimal value\n")
536 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
537 int idx_ipv4_prefixlen
= 2;
538 int idx_ipv4_number
= 4;
539 struct prefix_ipv4 p
;
540 struct in_addr area_id
;
543 if (ospf
->instance
) {
545 "The network command is not supported in multi-instance ospf%s",
550 /* Get network prefix and Area ID. */
551 VTY_GET_IPV4_PREFIX("network prefix", p
, argv
[idx_ipv4_prefixlen
]->arg
);
552 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
554 ret
= ospf_network_unset(ospf
, &p
, area_id
);
557 "Can't find specified network area configuration.%s",
565 DEFUN (ospf_area_range
,
567 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [advertise [cost (0-16777215)]]",
568 "OSPF area parameters\n"
569 "OSPF area ID in IP address format\n"
570 "OSPF area ID as a decimal value\n"
571 "Summarize routes matching address/mask (border routers only)\n"
572 "Area range prefix\n"
573 "Advertise this range (default)\n"
574 "User specified metric for this range\n"
575 "Advertised metric for this range\n")
577 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
578 int idx_ipv4_number
= 1;
579 int idx_ipv4_prefixlen
= 3;
581 struct prefix_ipv4 p
;
582 struct in_addr area_id
;
586 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
587 VTY_GET_IPV4_PREFIX("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
589 ospf_area_range_set(ospf
, area_id
, &p
, OSPF_AREA_RANGE_ADVERTISE
);
591 VTY_GET_INTEGER("range cost", cost
, argv
[idx_cost
]->arg
);
592 ospf_area_range_cost_set(ospf
, area_id
, &p
, cost
);
598 DEFUN (ospf_area_range_cost
,
599 ospf_area_range_cost_cmd
,
600 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M cost (0-16777215)",
601 "OSPF area parameters\n"
602 "OSPF area ID in IP address format\n"
603 "OSPF area ID as a decimal value\n"
604 "Summarize routes matching address/mask (border routers only)\n"
605 "Area range prefix\n"
606 "User specified metric for this range\n"
607 "Advertised metric for this range\n")
609 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
610 int idx_ipv4_number
= 1;
611 int idx_ipv4_prefixlen
= 3;
613 struct prefix_ipv4 p
;
614 struct in_addr area_id
;
618 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
619 VTY_GET_IPV4_PREFIX("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
621 ospf_area_range_set(ospf
, area_id
, &p
, OSPF_AREA_RANGE_ADVERTISE
);
622 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
625 VTY_GET_INTEGER("range cost", cost
, argv
[idx_cost
]->arg
);
626 ospf_area_range_cost_set(ospf
, area_id
, &p
, cost
);
631 DEFUN (ospf_area_range_not_advertise
,
632 ospf_area_range_not_advertise_cmd
,
633 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M not-advertise",
634 "OSPF area parameters\n"
635 "OSPF area ID in IP address format\n"
636 "OSPF area ID as a decimal value\n"
637 "Summarize routes matching address/mask (border routers only)\n"
638 "Area range prefix\n"
639 "DoNotAdvertise this range\n")
641 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
642 int idx_ipv4_number
= 1;
643 int idx_ipv4_prefixlen
= 3;
644 struct prefix_ipv4 p
;
645 struct in_addr area_id
;
648 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
649 VTY_GET_IPV4_PREFIX("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
651 ospf_area_range_set(ospf
, area_id
, &p
, 0);
652 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
658 DEFUN (no_ospf_area_range
,
659 no_ospf_area_range_cmd
,
660 "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [<cost (0-16777215)|advertise [cost (0-16777215)]|not-advertise>]",
662 "OSPF area parameters\n"
663 "OSPF area ID in IP address format\n"
664 "OSPF area ID as a decimal value\n"
665 "Summarize routes matching address/mask (border routers only)\n"
666 "Area range prefix\n"
667 "User specified metric for this range\n"
668 "Advertised metric for this range\n"
669 "Advertise this range (default)\n"
670 "User specified metric for this range\n"
671 "Advertised metric for this range\n"
672 "DoNotAdvertise this range\n")
674 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
675 int idx_ipv4_number
= 2;
676 int idx_ipv4_prefixlen
= 4;
677 struct prefix_ipv4 p
;
678 struct in_addr area_id
;
681 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
682 VTY_GET_IPV4_PREFIX("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
684 ospf_area_range_unset(ospf
, area_id
, &p
);
689 DEFUN (ospf_area_range_substitute
,
690 ospf_area_range_substitute_cmd
,
691 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M",
692 "OSPF area parameters\n"
693 "OSPF area ID in IP address format\n"
694 "OSPF area ID as a decimal value\n"
695 "Summarize routes matching address/mask (border routers only)\n"
696 "Area range prefix\n"
697 "Announce area range as another prefix\n"
698 "Network prefix to be announced instead of range\n")
700 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
701 int idx_ipv4_number
= 1;
702 int idx_ipv4_prefixlen
= 3;
703 int idx_ipv4_prefixlen_2
= 5;
704 struct prefix_ipv4 p
, s
;
705 struct in_addr area_id
;
708 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
709 VTY_GET_IPV4_PREFIX("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
710 VTY_GET_IPV4_PREFIX("substituted network prefix", s
,
711 argv
[idx_ipv4_prefixlen_2
]->arg
);
713 ospf_area_range_substitute_set(ospf
, area_id
, &p
, &s
);
714 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
720 DEFUN (no_ospf_area_range_substitute
,
721 no_ospf_area_range_substitute_cmd
,
722 "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M",
724 "OSPF area parameters\n"
725 "OSPF area ID in IP address format\n"
726 "OSPF area ID as a decimal value\n"
727 "Summarize routes matching address/mask (border routers only)\n"
728 "Area range prefix\n"
729 "Announce area range as another prefix\n"
730 "Network prefix to be announced instead of range\n")
732 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
733 int idx_ipv4_number
= 2;
734 int idx_ipv4_prefixlen
= 4;
735 int idx_ipv4_prefixlen_2
= 6;
736 struct prefix_ipv4 p
, s
;
737 struct in_addr area_id
;
740 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
741 VTY_GET_IPV4_PREFIX("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
742 VTY_GET_IPV4_PREFIX("substituted network prefix", s
,
743 argv
[idx_ipv4_prefixlen_2
]->arg
);
745 ospf_area_range_substitute_unset(ospf
, area_id
, &p
);
751 /* Command Handler Logic in VLink stuff is delicate!!
753 ALTER AT YOUR OWN RISK!!!!
755 Various dummy values are used to represent 'NoChange' state for
756 VLink configuration NOT being changed by a VLink command, and
757 special syntax is used within the command strings so that the
758 typed in command verbs can be seen in the configuration command
759 bacckend handler. This is to drastically reduce the verbeage
760 required to coe up with a reasonably compatible Cisco VLink command
762 - Matthew Grant <grantma@anathoth.gen.nz>
763 Wed, 21 Feb 2001 15:13:52 +1300
766 /* Configuration data for virtual links
768 struct ospf_vl_config_data
{
769 struct vty
*vty
; /* vty stuff */
770 struct in_addr area_id
; /* area ID from command line */
771 int area_id_fmt
; /* command line area ID format */
772 struct in_addr vl_peer
; /* command line vl_peer */
773 int auth_type
; /* Authehntication type, if given */
774 char *auth_key
; /* simple password if present */
775 int crypto_key_id
; /* Cryptographic key ID */
776 char *md5_key
; /* MD5 authentication key */
777 int hello_interval
; /* Obvious what these are... */
778 int retransmit_interval
;
783 static void ospf_vl_config_data_init(struct ospf_vl_config_data
*vl_config
,
786 memset(vl_config
, 0, sizeof(struct ospf_vl_config_data
));
787 vl_config
->auth_type
= OSPF_AUTH_CMD_NOTSEEN
;
788 vl_config
->vty
= vty
;
791 static struct ospf_vl_data
*
792 ospf_find_vl_data(struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
794 struct ospf_area
*area
;
795 struct ospf_vl_data
*vl_data
;
797 struct in_addr area_id
;
799 vty
= vl_config
->vty
;
800 area_id
= vl_config
->area_id
;
802 if (area_id
.s_addr
== OSPF_AREA_BACKBONE
) {
804 "Configuring VLs over the backbone is not allowed%s",
808 area
= ospf_area_get(ospf
, area_id
);
809 ospf_area_display_format_set(ospf
, area
, vl_config
->area_id_fmt
);
811 if (area
->external_routing
!= OSPF_AREA_DEFAULT
) {
812 if (vl_config
->area_id_fmt
== OSPF_AREA_ID_FMT_DOTTEDQUAD
)
813 vty_out(vty
, "Area %s is %s%s", inet_ntoa(area_id
),
814 area
->external_routing
== OSPF_AREA_NSSA
819 vty_out(vty
, "Area %ld is %s%s",
820 (u_long
)ntohl(area_id
.s_addr
),
821 area
->external_routing
== OSPF_AREA_NSSA
828 if ((vl_data
= ospf_vl_lookup(ospf
, area
, vl_config
->vl_peer
))
830 vl_data
= ospf_vl_data_new(area
, vl_config
->vl_peer
);
831 if (vl_data
->vl_oi
== NULL
) {
832 vl_data
->vl_oi
= ospf_vl_new(ospf
, vl_data
);
833 ospf_vl_add(ospf
, vl_data
);
834 ospf_spf_calculate_schedule(ospf
,
835 SPF_FLAG_CONFIG_CHANGE
);
842 static int ospf_vl_set_security(struct ospf_vl_data
*vl_data
,
843 struct ospf_vl_config_data
*vl_config
)
845 struct crypt_key
*ck
;
847 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
849 vty
= vl_config
->vty
;
851 if (vl_config
->auth_type
!= OSPF_AUTH_CMD_NOTSEEN
) {
852 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), auth_type
);
853 IF_DEF_PARAMS(ifp
)->auth_type
= vl_config
->auth_type
;
856 if (vl_config
->auth_key
) {
857 memset(IF_DEF_PARAMS(ifp
)->auth_simple
, 0,
858 OSPF_AUTH_SIMPLE_SIZE
+ 1);
859 strncpy((char *)IF_DEF_PARAMS(ifp
)->auth_simple
,
860 vl_config
->auth_key
, OSPF_AUTH_SIMPLE_SIZE
);
861 } else if (vl_config
->md5_key
) {
862 if (ospf_crypt_key_lookup(IF_DEF_PARAMS(ifp
)->auth_crypt
,
863 vl_config
->crypto_key_id
)
865 vty_out(vty
, "OSPF: Key %d already exists%s",
866 vl_config
->crypto_key_id
, VTY_NEWLINE
);
869 ck
= ospf_crypt_key_new();
870 ck
->key_id
= vl_config
->crypto_key_id
;
871 memset(ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+ 1);
872 strncpy((char *)ck
->auth_key
, vl_config
->md5_key
,
875 ospf_crypt_key_add(IF_DEF_PARAMS(ifp
)->auth_crypt
, ck
);
876 } else if (vl_config
->crypto_key_id
!= 0) {
879 if (ospf_crypt_key_lookup(IF_DEF_PARAMS(ifp
)->auth_crypt
,
880 vl_config
->crypto_key_id
)
882 vty_out(vty
, "OSPF: Key %d does not exist%s",
883 vl_config
->crypto_key_id
, VTY_NEWLINE
);
887 ospf_crypt_key_delete(IF_DEF_PARAMS(ifp
)->auth_crypt
,
888 vl_config
->crypto_key_id
);
894 static int ospf_vl_set_timers(struct ospf_vl_data
*vl_data
,
895 struct ospf_vl_config_data
*vl_config
)
897 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
898 /* Virtual Link data initialised to defaults, so only set
900 if (vl_config
->hello_interval
) {
901 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), v_hello
);
902 IF_DEF_PARAMS(ifp
)->v_hello
= vl_config
->hello_interval
;
905 if (vl_config
->dead_interval
) {
906 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), v_wait
);
907 IF_DEF_PARAMS(ifp
)->v_wait
= vl_config
->dead_interval
;
910 if (vl_config
->retransmit_interval
) {
911 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), retransmit_interval
);
912 IF_DEF_PARAMS(ifp
)->retransmit_interval
=
913 vl_config
->retransmit_interval
;
916 if (vl_config
->transmit_delay
) {
917 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), transmit_delay
);
918 IF_DEF_PARAMS(ifp
)->transmit_delay
= vl_config
->transmit_delay
;
925 /* The business end of all of the above */
926 static int ospf_vl_set(struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
928 struct ospf_vl_data
*vl_data
;
931 vl_data
= ospf_find_vl_data(ospf
, vl_config
);
935 /* Process this one first as it can have a fatal result, which can
936 only logically occur if the virtual link exists already
937 Thus a command error does not result in a change to the
938 running configuration such as unexpectedly altered timer
940 ret
= ospf_vl_set_security(vl_data
, vl_config
);
941 if (ret
!= CMD_SUCCESS
)
944 /* Set any time based parameters, these area already range checked */
946 ret
= ospf_vl_set_timers(vl_data
, vl_config
);
947 if (ret
!= CMD_SUCCESS
)
953 /* This stuff exists to make specifying all the alias commands A LOT simpler
955 #define VLINK_HELPSTR_IPADDR \
956 "OSPF area parameters\n" \
957 "OSPF area ID in IP address format\n" \
958 "OSPF area ID as a decimal value\n" \
959 "Configure a virtual link\n" \
960 "Router ID of the remote ABR\n"
962 #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
963 "Enable authentication on this virtual link\n" \
966 #define VLINK_HELPSTR_AUTHTYPE_ALL \
967 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
968 "Use null authentication\n" \
969 "Use message-digest authentication\n"
971 #define VLINK_HELPSTR_TIME_PARAM \
972 "Time between HELLO packets\n" \
974 "Time between retransmitting lost link state advertisements\n" \
976 "Link state transmit delay\n" \
978 "Interval time after which a neighbor is declared down\n" \
981 #define VLINK_HELPSTR_AUTH_SIMPLE \
982 "Authentication password (key)\n" \
983 "The OSPF password (key)"
985 #define VLINK_HELPSTR_AUTH_MD5 \
986 "Message digest authentication password (key)\n" \
989 "Use MD5 algorithm\n" \
990 "The OSPF password (key)"
992 DEFUN (ospf_area_vlink
,
994 "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>]",
996 "Enable authentication on this virtual link\n" \
997 "Use null authentication\n" \
998 "Use message-digest authentication\n"
999 "Message digest authentication password (key)\n" \
1001 "Use MD5 algorithm\n" \
1002 "The OSPF password (key)")
1004 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1005 int idx_ipv4_number
= 1;
1007 struct ospf_vl_config_data vl_config
;
1008 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+ 1];
1009 char md5_key
[OSPF_AUTH_MD5_SIZE
+ 1];
1013 ospf_vl_config_data_init(&vl_config
, vty
);
1015 /* Read off first 2 parameters and check them */
1016 ret
= str2area_id(argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
,
1017 &vl_config
.area_id_fmt
);
1019 vty_out(vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1023 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1025 vty_out(vty
, "Please specify valid Router ID as a.b.c.d%s",
1031 /* Thats all folks! - BUGS B. strikes again!!!*/
1033 return ospf_vl_set(ospf
, &vl_config
);
1036 /* Deal with other parameters */
1037 for (i
= 5; i
< argc
; i
++) {
1039 /* vty_out (vty, "argv[%d]->arg - %s%s", i, argv[i]->text,
1042 switch (argv
[i
]->arg
[0]) {
1046 || strncmp(argv
[i
]->arg
, "authentication-", 15)
1048 /* authentication-key - this option can occur
1050 command line. At start
1053 authentication option. */
1054 memset(auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1055 strncpy(auth_key
, argv
[i
+ 1]->text
,
1056 OSPF_AUTH_SIMPLE_SIZE
);
1057 vl_config
.auth_key
= auth_key
;
1059 } else if (strncmp(argv
[i
]->arg
, "authentication", 14)
1061 /* authentication - this option can only occur
1064 vl_config
.auth_type
= OSPF_AUTH_SIMPLE
;
1065 if ((i
+ 1) < argc
) {
1066 if (strncmp(argv
[i
+ 1]->arg
, "n", 1)
1068 /* "authentication null" */
1069 vl_config
.auth_type
=
1072 } else if (strncmp(argv
[i
+ 1]->arg
,
1075 && strcmp(argv
[i
+ 1]->arg
,
1079 * message-digest" */
1080 vl_config
.auth_type
=
1081 OSPF_AUTH_CRYPTOGRAPHIC
;
1089 /* message-digest-key */
1092 vl_config
.crypto_key_id
=
1093 strtol(argv
[i
]->arg
, NULL
, 10);
1094 if (vl_config
.crypto_key_id
< 0)
1099 OSPF_AUTH_MD5_SIZE
+ 1);
1100 strncpy(md5_key
, argv
[i
]->arg
,
1101 OSPF_AUTH_MD5_SIZE
);
1102 vl_config
.md5_key
= md5_key
;
1105 vl_config
.md5_key
= NULL
;
1111 /* Action configuration */
1113 return ospf_vl_set(ospf
, &vl_config
);
1116 DEFUN (no_ospf_area_vlink
,
1117 no_ospf_area_vlink_cmd
,
1118 "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>]",
1120 VLINK_HELPSTR_IPADDR
1121 "Enable authentication on this virtual link\n" \
1122 "Use null authentication\n" \
1123 "Use message-digest authentication\n"
1124 "Message digest authentication password (key)\n" \
1126 "Use MD5 algorithm\n" \
1127 "The OSPF password (key)")
1129 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1130 int idx_ipv4_number
= 2;
1132 struct ospf_area
*area
;
1133 struct ospf_vl_config_data vl_config
;
1134 struct ospf_vl_data
*vl_data
= NULL
;
1135 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+ 1];
1139 ospf_vl_config_data_init(&vl_config
, vty
);
1141 ret
= str2area_id(argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
,
1144 vty_out(vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1148 area
= ospf_area_lookup_by_area_id(ospf
, vl_config
.area_id
);
1150 vty_out(vty
, "Area does not exist%s", VTY_NEWLINE
);
1154 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1156 vty_out(vty
, "Please specify valid Router ID as a.b.c.d%s",
1162 /* Basic VLink no command */
1163 /* Thats all folks! - BUGS B. strikes again!!!*/
1164 if ((vl_data
= ospf_vl_lookup(ospf
, area
, vl_config
.vl_peer
)))
1165 ospf_vl_delete(ospf
, vl_data
);
1167 ospf_area_check_free(ospf
, vl_config
.area_id
);
1172 /* If we are down here, we are reseting parameters */
1174 /* Deal with other parameters */
1175 for (i
= 6; i
< argc
; i
++) {
1176 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1178 switch (argv
[i
]->arg
[0]) {
1182 || strncmp(argv
[i
]->text
, "authentication-", 15)
1184 /* authentication-key - this option can occur
1186 command line. At start
1189 authentication option. */
1190 memset(auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1191 vl_config
.auth_key
= auth_key
;
1192 } else if (strncmp(argv
[i
]->text
, "authentication", 14)
1194 /* authentication - this option can only occur
1197 vl_config
.auth_type
= OSPF_AUTH_NOTSET
;
1202 /* message-digest-key */
1203 /* Delete one key */
1206 vl_config
.crypto_key_id
=
1207 strtol(argv
[i
]->arg
, NULL
, 10);
1208 if (vl_config
.crypto_key_id
< 0)
1210 vl_config
.md5_key
= NULL
;
1218 /* Action configuration */
1220 return ospf_vl_set(ospf
, &vl_config
);
1223 DEFUN (ospf_area_vlink_intervals
,
1224 ospf_area_vlink_intervals_cmd
,
1225 "area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D {hello-interval (1-65535)|retransmit-interval (1-65535)|transmit-delay (1-65535)|dead-interval (1-65535)}",
1226 VLINK_HELPSTR_IPADDR
1227 VLINK_HELPSTR_TIME_PARAM
)
1229 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1230 struct ospf_vl_config_data vl_config
;
1233 ospf_vl_config_data_init(&vl_config
, vty
);
1235 char *area_id
= argv
[1]->arg
;
1236 char *router_id
= argv
[3]->arg
;
1238 ret
= str2area_id(area_id
, &vl_config
.area_id
, &vl_config
.area_id_fmt
);
1240 vty_out(vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1244 ret
= inet_aton(router_id
, &vl_config
.vl_peer
);
1246 vty_out(vty
, "Please specify valid Router ID as a.b.c.d%s",
1251 for (int idx
= 4; idx
< argc
; idx
++) {
1252 if (strmatch(argv
[idx
]->text
, "hello-interval"))
1253 vl_config
.hello_interval
=
1254 strtol(argv
[++idx
]->arg
, NULL
, 10);
1255 else if (strmatch(argv
[idx
]->text
, "retransmit-interval"))
1256 vl_config
.retransmit_interval
=
1257 strtol(argv
[++idx
]->arg
, NULL
, 10);
1258 else if (strmatch(argv
[idx
]->text
, "transmit-delay"))
1259 vl_config
.transmit_delay
=
1260 strtol(argv
[++idx
]->arg
, NULL
, 10);
1261 else if (strmatch(argv
[idx
]->text
, "dead-interval"))
1262 vl_config
.dead_interval
=
1263 strtol(argv
[++idx
]->arg
, NULL
, 10);
1266 /* Action configuration */
1267 return ospf_vl_set(ospf
, &vl_config
);
1270 DEFUN (no_ospf_area_vlink_intervals
,
1271 no_ospf_area_vlink_intervals_cmd
,
1272 "no area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D {hello-interval (1-65535)|retransmit-interval (1-65535)|transmit-delay (1-65535)|dead-interval (1-65535)}",
1274 VLINK_HELPSTR_IPADDR
1275 VLINK_HELPSTR_TIME_PARAM
)
1277 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1278 struct ospf_vl_config_data vl_config
;
1281 ospf_vl_config_data_init(&vl_config
, vty
);
1283 char *area_id
= argv
[2]->arg
;
1284 char *router_id
= argv
[4]->arg
;
1286 ret
= str2area_id(area_id
, &vl_config
.area_id
, &vl_config
.area_id_fmt
);
1288 vty_out(vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1292 ret
= inet_aton(router_id
, &vl_config
.vl_peer
);
1294 vty_out(vty
, "Please specify valid Router ID as a.b.c.d%s",
1299 for (int idx
= 5; idx
< argc
; idx
++) {
1300 if (strmatch(argv
[idx
]->text
, "hello-interval"))
1301 vl_config
.hello_interval
= OSPF_HELLO_INTERVAL_DEFAULT
;
1302 else if (strmatch(argv
[idx
]->text
, "retransmit-interval"))
1303 vl_config
.retransmit_interval
=
1304 OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
1305 else if (strmatch(argv
[idx
]->text
, "transmit-delay"))
1306 vl_config
.transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
1307 else if (strmatch(argv
[idx
]->text
, "dead-interval"))
1308 vl_config
.dead_interval
=
1309 OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
1312 /* Action configuration */
1313 return ospf_vl_set(ospf
, &vl_config
);
1316 DEFUN (ospf_area_shortcut
,
1317 ospf_area_shortcut_cmd
,
1318 "area <A.B.C.D|(0-4294967295)> shortcut <default|enable|disable>",
1319 "OSPF area parameters\n"
1320 "OSPF area ID in IP address format\n"
1321 "OSPF area ID as a decimal value\n"
1322 "Configure the area's shortcutting mode\n"
1323 "Set default shortcutting behavior\n"
1324 "Enable shortcutting through the area\n"
1325 "Disable shortcutting through the area\n")
1327 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1328 int idx_ipv4_number
= 1;
1329 int idx_enable_disable
= 3;
1330 struct ospf_area
*area
;
1331 struct in_addr area_id
;
1335 VTY_GET_OSPF_AREA_ID_NO_BB("shortcut", area_id
, format
,
1336 argv
[idx_ipv4_number
]->arg
);
1338 area
= ospf_area_get(ospf
, area_id
);
1339 ospf_area_display_format_set(ospf
, area
, format
);
1341 if (strncmp(argv
[idx_enable_disable
]->arg
, "de", 2) == 0)
1342 mode
= OSPF_SHORTCUT_DEFAULT
;
1343 else if (strncmp(argv
[idx_enable_disable
]->arg
, "di", 2) == 0)
1344 mode
= OSPF_SHORTCUT_DISABLE
;
1345 else if (strncmp(argv
[idx_enable_disable
]->arg
, "e", 1) == 0)
1346 mode
= OSPF_SHORTCUT_ENABLE
;
1350 ospf_area_shortcut_set(ospf
, area
, mode
);
1352 if (ospf
->abr_type
!= OSPF_ABR_SHORTCUT
)
1354 "Shortcut area setting will take effect "
1355 "only when the router is configured as Shortcut ABR%s",
1361 DEFUN (no_ospf_area_shortcut
,
1362 no_ospf_area_shortcut_cmd
,
1363 "no area <A.B.C.D|(0-4294967295)> shortcut <enable|disable>",
1365 "OSPF area parameters\n"
1366 "OSPF area ID in IP address format\n"
1367 "OSPF area ID as a decimal value\n"
1368 "Deconfigure the area's shortcutting mode\n"
1369 "Deconfigure enabled shortcutting through the area\n"
1370 "Deconfigure disabled shortcutting through the area\n")
1372 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1373 int idx_ipv4_number
= 2;
1374 struct ospf_area
*area
;
1375 struct in_addr area_id
;
1378 VTY_GET_OSPF_AREA_ID_NO_BB("shortcut", area_id
, format
,
1379 argv
[idx_ipv4_number
]->arg
);
1381 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1385 ospf_area_shortcut_unset(ospf
, area
);
1391 DEFUN (ospf_area_stub
,
1393 "area <A.B.C.D|(0-4294967295)> stub",
1394 "OSPF area parameters\n"
1395 "OSPF area ID in IP address format\n"
1396 "OSPF area ID as a decimal value\n"
1397 "Configure OSPF area as stub\n")
1399 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1400 int idx_ipv4_number
= 1;
1401 struct in_addr area_id
;
1404 VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id
, format
,
1405 argv
[idx_ipv4_number
]->arg
);
1407 ret
= ospf_area_stub_set(ospf
, area_id
);
1408 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1412 "First deconfigure all virtual link through this area%s",
1417 ospf_area_no_summary_unset(ospf
, area_id
);
1422 DEFUN (ospf_area_stub_no_summary
,
1423 ospf_area_stub_no_summary_cmd
,
1424 "area <A.B.C.D|(0-4294967295)> stub no-summary",
1425 "OSPF stub 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"
1429 "Do not inject inter-area routes into stub\n")
1431 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1432 int idx_ipv4_number
= 1;
1433 struct in_addr area_id
;
1436 VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id
, format
,
1437 argv
[idx_ipv4_number
]->arg
);
1439 ret
= ospf_area_stub_set(ospf
, area_id
);
1440 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1444 "%% Area cannot be stub as it contains a virtual link%s",
1449 ospf_area_no_summary_set(ospf
, area_id
);
1454 DEFUN (no_ospf_area_stub
,
1455 no_ospf_area_stub_cmd
,
1456 "no area <A.B.C.D|(0-4294967295)> stub",
1458 "OSPF area parameters\n"
1459 "OSPF area ID in IP address format\n"
1460 "OSPF area ID as a decimal value\n"
1461 "Configure OSPF area as stub\n")
1463 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1464 int idx_ipv4_number
= 2;
1465 struct in_addr area_id
;
1468 VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id
, format
,
1469 argv
[idx_ipv4_number
]->arg
);
1471 ospf_area_stub_unset(ospf
, area_id
);
1472 ospf_area_no_summary_unset(ospf
, area_id
);
1477 DEFUN (no_ospf_area_stub_no_summary
,
1478 no_ospf_area_stub_no_summary_cmd
,
1479 "no area <A.B.C.D|(0-4294967295)> stub no-summary",
1481 "OSPF area parameters\n"
1482 "OSPF area ID in IP address format\n"
1483 "OSPF area ID as a decimal value\n"
1484 "Configure OSPF area as stub\n"
1485 "Do not inject inter-area routes into area\n")
1487 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1488 int idx_ipv4_number
= 2;
1489 struct in_addr area_id
;
1492 VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id
, format
,
1493 argv
[idx_ipv4_number
]->arg
);
1494 ospf_area_no_summary_unset(ospf
, area_id
);
1499 static int ospf_area_nssa_cmd_handler(struct vty
*vty
, int argc
,
1500 struct cmd_token
**argv
, int nosum
)
1502 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1503 struct in_addr area_id
;
1506 VTY_GET_OSPF_AREA_ID_NO_BB("NSSA", area_id
, format
, argv
[1]->arg
);
1508 ret
= ospf_area_nssa_set(ospf
, area_id
);
1509 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1513 "%% Area cannot be nssa as it contains a virtual link%s",
1519 if (strncmp(argv
[3]->text
, "translate-c", 11) == 0)
1520 ospf_area_nssa_translator_role_set(
1521 ospf
, area_id
, OSPF_NSSA_ROLE_CANDIDATE
);
1522 else if (strncmp(argv
[3]->text
, "translate-n", 11) == 0)
1523 ospf_area_nssa_translator_role_set(
1524 ospf
, area_id
, OSPF_NSSA_ROLE_NEVER
);
1525 else if (strncmp(argv
[3]->text
, "translate-a", 11) == 0)
1526 ospf_area_nssa_translator_role_set(
1527 ospf
, area_id
, OSPF_NSSA_ROLE_ALWAYS
);
1529 ospf_area_nssa_translator_role_set(ospf
, area_id
,
1530 OSPF_NSSA_ROLE_CANDIDATE
);
1534 ospf_area_no_summary_set(ospf
, area_id
);
1536 ospf_area_no_summary_unset(ospf
, area_id
);
1538 ospf_schedule_abr_task(ospf
);
1543 DEFUN (ospf_area_nssa_translate_no_summary
,
1544 ospf_area_nssa_translate_no_summary_cmd
,
1545 "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always> no-summary",
1546 "OSPF area parameters\n"
1547 "OSPF area ID in IP address format\n"
1548 "OSPF area ID as a decimal value\n"
1549 "Configure OSPF area as nssa\n"
1550 "Configure NSSA-ABR for translate election (default)\n"
1551 "Configure NSSA-ABR to never translate\n"
1552 "Configure NSSA-ABR to always translate\n"
1553 "Do not inject inter-area routes into nssa\n")
1555 return ospf_area_nssa_cmd_handler(vty
, argc
, argv
, 1);
1558 DEFUN (ospf_area_nssa_translate
,
1559 ospf_area_nssa_translate_cmd
,
1560 "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always>",
1561 "OSPF area parameters\n"
1562 "OSPF area ID in IP address format\n"
1563 "OSPF area ID as a decimal value\n"
1564 "Configure OSPF area as nssa\n"
1565 "Configure NSSA-ABR for translate election (default)\n"
1566 "Configure NSSA-ABR to never translate\n"
1567 "Configure NSSA-ABR to always translate\n")
1569 return ospf_area_nssa_cmd_handler(vty
, argc
, argv
, 0);
1572 DEFUN (ospf_area_nssa
,
1574 "area <A.B.C.D|(0-4294967295)> nssa",
1575 "OSPF area parameters\n"
1576 "OSPF area ID in IP address format\n"
1577 "OSPF area ID as a decimal value\n"
1578 "Configure OSPF area as nssa\n")
1580 return ospf_area_nssa_cmd_handler(vty
, argc
, argv
, 0);
1583 DEFUN (ospf_area_nssa_no_summary
,
1584 ospf_area_nssa_no_summary_cmd
,
1585 "area <A.B.C.D|(0-4294967295)> nssa no-summary",
1586 "OSPF area parameters\n"
1587 "OSPF area ID in IP address format\n"
1588 "OSPF area ID as a decimal value\n"
1589 "Configure OSPF area as nssa\n"
1590 "Do not inject inter-area routes into nssa\n")
1592 return ospf_area_nssa_cmd_handler(vty
, argc
, argv
, 1);
1595 DEFUN (no_ospf_area_nssa
,
1596 no_ospf_area_nssa_cmd
,
1597 "no area <A.B.C.D|(0-4294967295)> nssa [<translate-candidate|translate-never|translate-always> [no-summary]]",
1599 "OSPF area parameters\n"
1600 "OSPF area ID in IP address format\n"
1601 "OSPF area ID as a decimal value\n"
1602 "Configure OSPF area as nssa\n"
1603 "Configure NSSA-ABR for translate election (default)\n"
1604 "Configure NSSA-ABR to never translate\n"
1605 "Configure NSSA-ABR to always translate\n"
1606 "Do not inject inter-area routes into nssa\n")
1608 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1609 int idx_ipv4_number
= 2;
1610 struct in_addr area_id
;
1613 VTY_GET_OSPF_AREA_ID_NO_BB("NSSA", area_id
, format
,
1614 argv
[idx_ipv4_number
]->arg
);
1616 ospf_area_nssa_unset(ospf
, area_id
);
1617 ospf_area_no_summary_unset(ospf
, area_id
);
1619 ospf_schedule_abr_task(ospf
);
1625 DEFUN (ospf_area_default_cost
,
1626 ospf_area_default_cost_cmd
,
1627 "area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1628 "OSPF area parameters\n"
1629 "OSPF area ID in IP address format\n"
1630 "OSPF area ID as a decimal value\n"
1631 "Set the summary-default cost of a NSSA or stub area\n"
1632 "Stub's advertised default summary cost\n")
1634 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1635 int idx_ipv4_number
= 1;
1637 struct ospf_area
*area
;
1638 struct in_addr area_id
;
1641 struct prefix_ipv4 p
;
1643 VTY_GET_OSPF_AREA_ID_NO_BB("default-cost", area_id
, format
,
1644 argv
[idx_ipv4_number
]->arg
);
1645 VTY_GET_INTEGER_RANGE("stub default cost", cost
, argv
[idx_number
]->arg
,
1648 area
= ospf_area_get(ospf
, area_id
);
1649 ospf_area_display_format_set(ospf
, area
, format
);
1651 if (area
->external_routing
== OSPF_AREA_DEFAULT
) {
1652 vty_out(vty
, "The area is neither stub, nor NSSA%s",
1657 area
->default_cost
= cost
;
1660 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1662 if (IS_DEBUG_OSPF_EVENT
)
1664 "ospf_abr_announce_stub_defaults(): "
1665 "announcing 0.0.0.0/0 to area %s",
1666 inet_ntoa(area
->area_id
));
1667 ospf_abr_announce_network_to_area(&p
, area
->default_cost
, area
);
1672 DEFUN (no_ospf_area_default_cost
,
1673 no_ospf_area_default_cost_cmd
,
1674 "no area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1676 "OSPF area parameters\n"
1677 "OSPF area ID in IP address format\n"
1678 "OSPF area ID as a decimal value\n"
1679 "Set the summary-default cost of a NSSA or stub area\n"
1680 "Stub's advertised default summary cost\n")
1682 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1683 int idx_ipv4_number
= 2;
1685 struct ospf_area
*area
;
1686 struct in_addr area_id
;
1688 struct prefix_ipv4 p
;
1690 VTY_GET_OSPF_AREA_ID_NO_BB("default-cost", area_id
, format
,
1691 argv
[idx_ipv4_number
]->arg
);
1692 VTY_CHECK_INTEGER_RANGE("stub default cost", argv
[idx_number
]->arg
, 0,
1695 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1699 if (area
->external_routing
== OSPF_AREA_DEFAULT
) {
1700 vty_out(vty
, "The area is neither stub, nor NSSA%s",
1705 area
->default_cost
= 1;
1708 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1710 if (IS_DEBUG_OSPF_EVENT
)
1712 "ospf_abr_announce_stub_defaults(): "
1713 "announcing 0.0.0.0/0 to area %s",
1714 inet_ntoa(area
->area_id
));
1715 ospf_abr_announce_network_to_area(&p
, area
->default_cost
, area
);
1718 ospf_area_check_free(ospf
, area_id
);
1723 DEFUN (ospf_area_export_list
,
1724 ospf_area_export_list_cmd
,
1725 "area <A.B.C.D|(0-4294967295)> export-list NAME",
1726 "OSPF area parameters\n"
1727 "OSPF area ID in IP address format\n"
1728 "OSPF area ID as a decimal value\n"
1729 "Set the filter for networks announced to other areas\n"
1730 "Name of the access-list\n")
1732 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1733 int idx_ipv4_number
= 1;
1734 struct ospf_area
*area
;
1735 struct in_addr area_id
;
1738 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1740 area
= ospf_area_get(ospf
, area_id
);
1741 ospf_area_display_format_set(ospf
, area
, format
);
1742 ospf_area_export_list_set(ospf
, area
, argv
[3]->arg
);
1747 DEFUN (no_ospf_area_export_list
,
1748 no_ospf_area_export_list_cmd
,
1749 "no area <A.B.C.D|(0-4294967295)> export-list NAME",
1751 "OSPF area parameters\n"
1752 "OSPF area ID in IP address format\n"
1753 "OSPF area ID as a decimal value\n"
1754 "Unset the filter for networks announced to other areas\n"
1755 "Name of the access-list\n")
1757 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1758 int idx_ipv4_number
= 2;
1759 struct ospf_area
*area
;
1760 struct in_addr area_id
;
1763 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1765 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1769 ospf_area_export_list_unset(ospf
, area
);
1775 DEFUN (ospf_area_import_list
,
1776 ospf_area_import_list_cmd
,
1777 "area <A.B.C.D|(0-4294967295)> import-list NAME",
1778 "OSPF area parameters\n"
1779 "OSPF area ID in IP address format\n"
1780 "OSPF area ID as a decimal value\n"
1781 "Set the filter for networks from other areas announced to the specified one\n"
1782 "Name of the access-list\n")
1784 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1785 int idx_ipv4_number
= 1;
1786 struct ospf_area
*area
;
1787 struct in_addr area_id
;
1790 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1792 area
= ospf_area_get(ospf
, area_id
);
1793 ospf_area_display_format_set(ospf
, area
, format
);
1794 ospf_area_import_list_set(ospf
, area
, argv
[3]->arg
);
1799 DEFUN (no_ospf_area_import_list
,
1800 no_ospf_area_import_list_cmd
,
1801 "no area <A.B.C.D|(0-4294967295)> import-list NAME",
1803 "OSPF area parameters\n"
1804 "OSPF area ID in IP address format\n"
1805 "OSPF area ID as a decimal value\n"
1806 "Unset the filter for networks announced to other areas\n"
1807 "Name of the access-list\n")
1809 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1810 int idx_ipv4_number
= 2;
1811 struct ospf_area
*area
;
1812 struct in_addr area_id
;
1815 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1817 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1821 ospf_area_import_list_unset(ospf
, area
);
1826 DEFUN (ospf_area_filter_list
,
1827 ospf_area_filter_list_cmd
,
1828 "area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>",
1829 "OSPF area parameters\n"
1830 "OSPF area ID in IP address format\n"
1831 "OSPF area ID as a decimal value\n"
1832 "Filter networks between OSPF areas\n"
1833 "Filter prefixes between OSPF areas\n"
1834 "Name of an IP prefix-list\n"
1835 "Filter networks sent to this area\n"
1836 "Filter networks sent from this area\n")
1838 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1839 int idx_ipv4_number
= 1;
1842 struct ospf_area
*area
;
1843 struct in_addr area_id
;
1844 struct prefix_list
*plist
;
1847 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1849 area
= ospf_area_get(ospf
, area_id
);
1850 ospf_area_display_format_set(ospf
, area
, format
);
1851 plist
= prefix_list_lookup(AFI_IP
, argv
[idx_word
]->arg
);
1852 if (strncmp(argv
[idx_in_out
]->arg
, "in", 2) == 0) {
1853 PREFIX_LIST_IN(area
) = plist
;
1854 if (PREFIX_NAME_IN(area
))
1855 free(PREFIX_NAME_IN(area
));
1857 PREFIX_NAME_IN(area
) = strdup(argv
[idx_word
]->arg
);
1858 ospf_schedule_abr_task(ospf
);
1860 PREFIX_LIST_OUT(area
) = plist
;
1861 if (PREFIX_NAME_OUT(area
))
1862 free(PREFIX_NAME_OUT(area
));
1864 PREFIX_NAME_OUT(area
) = strdup(argv
[idx_word
]->arg
);
1865 ospf_schedule_abr_task(ospf
);
1871 DEFUN (no_ospf_area_filter_list
,
1872 no_ospf_area_filter_list_cmd
,
1873 "no area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>",
1875 "OSPF area parameters\n"
1876 "OSPF area ID in IP address format\n"
1877 "OSPF area ID as a decimal value\n"
1878 "Filter networks between OSPF areas\n"
1879 "Filter prefixes between OSPF areas\n"
1880 "Name of an IP prefix-list\n"
1881 "Filter networks sent to this area\n"
1882 "Filter networks sent from this area\n")
1884 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1885 int idx_ipv4_number
= 2;
1888 struct ospf_area
*area
;
1889 struct in_addr area_id
;
1892 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1894 if ((area
= ospf_area_lookup_by_area_id(ospf
, area_id
)) == NULL
)
1897 if (strncmp(argv
[idx_in_out
]->arg
, "in", 2) == 0) {
1898 if (PREFIX_NAME_IN(area
))
1899 if (strcmp(PREFIX_NAME_IN(area
), argv
[idx_word
]->arg
)
1903 PREFIX_LIST_IN(area
) = NULL
;
1904 if (PREFIX_NAME_IN(area
))
1905 free(PREFIX_NAME_IN(area
));
1907 PREFIX_NAME_IN(area
) = NULL
;
1909 ospf_schedule_abr_task(ospf
);
1911 if (PREFIX_NAME_OUT(area
))
1912 if (strcmp(PREFIX_NAME_OUT(area
), argv
[idx_word
]->arg
)
1916 PREFIX_LIST_OUT(area
) = NULL
;
1917 if (PREFIX_NAME_OUT(area
))
1918 free(PREFIX_NAME_OUT(area
));
1920 PREFIX_NAME_OUT(area
) = NULL
;
1922 ospf_schedule_abr_task(ospf
);
1929 DEFUN (ospf_area_authentication_message_digest
,
1930 ospf_area_authentication_message_digest_cmd
,
1931 "area <A.B.C.D|(0-4294967295)> authentication message-digest",
1932 "OSPF area parameters\n"
1933 "OSPF area ID in IP address format\n"
1934 "OSPF area ID as a decimal value\n"
1935 "Enable authentication\n"
1936 "Use message-digest authentication\n")
1938 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1939 int idx_ipv4_number
= 1;
1940 struct ospf_area
*area
;
1941 struct in_addr area_id
;
1944 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1946 area
= ospf_area_get(ospf
, area_id
);
1947 ospf_area_display_format_set(ospf
, area
, format
);
1948 area
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
1953 DEFUN (ospf_area_authentication
,
1954 ospf_area_authentication_cmd
,
1955 "area <A.B.C.D|(0-4294967295)> authentication",
1956 "OSPF area parameters\n"
1957 "OSPF area ID in IP address format\n"
1958 "OSPF area ID as a decimal value\n"
1959 "Enable authentication\n")
1961 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1962 int idx_ipv4_number
= 1;
1963 struct ospf_area
*area
;
1964 struct in_addr area_id
;
1967 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1969 area
= ospf_area_get(ospf
, area_id
);
1970 ospf_area_display_format_set(ospf
, area
, format
);
1971 area
->auth_type
= OSPF_AUTH_SIMPLE
;
1976 DEFUN (no_ospf_area_authentication
,
1977 no_ospf_area_authentication_cmd
,
1978 "no area <A.B.C.D|(0-4294967295)> authentication",
1980 "OSPF area parameters\n"
1981 "OSPF area ID in IP address format\n"
1982 "OSPF area ID as a decimal value\n"
1983 "Enable authentication\n")
1985 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1986 int idx_ipv4_number
= 2;
1987 struct ospf_area
*area
;
1988 struct in_addr area_id
;
1991 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1993 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1997 area
->auth_type
= OSPF_AUTH_NULL
;
1999 ospf_area_check_free(ospf
, area_id
);
2005 DEFUN (ospf_abr_type
,
2007 "ospf abr-type <cisco|ibm|shortcut|standard>",
2008 "OSPF specific commands\n"
2009 "Set OSPF ABR type\n"
2010 "Alternative ABR, cisco implementation\n"
2011 "Alternative ABR, IBM implementation\n"
2013 "Standard behavior (RFC2328)\n")
2015 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2017 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2019 if (strncmp(argv
[idx_vendor
]->arg
, "c", 1) == 0)
2020 abr_type
= OSPF_ABR_CISCO
;
2021 else if (strncmp(argv
[idx_vendor
]->arg
, "i", 1) == 0)
2022 abr_type
= OSPF_ABR_IBM
;
2023 else if (strncmp(argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2024 abr_type
= OSPF_ABR_SHORTCUT
;
2025 else if (strncmp(argv
[idx_vendor
]->arg
, "st", 2) == 0)
2026 abr_type
= OSPF_ABR_STAND
;
2030 /* If ABR type value is changed, schedule ABR task. */
2031 if (ospf
->abr_type
!= abr_type
) {
2032 ospf
->abr_type
= abr_type
;
2033 ospf_schedule_abr_task(ospf
);
2039 DEFUN (no_ospf_abr_type
,
2040 no_ospf_abr_type_cmd
,
2041 "no ospf abr-type <cisco|ibm|shortcut|standard>",
2043 "OSPF specific commands\n"
2044 "Set OSPF ABR type\n"
2045 "Alternative ABR, cisco implementation\n"
2046 "Alternative ABR, IBM implementation\n"
2050 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2052 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2054 if (strncmp(argv
[idx_vendor
]->arg
, "c", 1) == 0)
2055 abr_type
= OSPF_ABR_CISCO
;
2056 else if (strncmp(argv
[idx_vendor
]->arg
, "i", 1) == 0)
2057 abr_type
= OSPF_ABR_IBM
;
2058 else if (strncmp(argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2059 abr_type
= OSPF_ABR_SHORTCUT
;
2060 else if (strncmp(argv
[idx_vendor
]->arg
, "st", 2) == 0)
2061 abr_type
= OSPF_ABR_STAND
;
2065 /* If ABR type value is changed, schedule ABR task. */
2066 if (ospf
->abr_type
== abr_type
) {
2067 ospf
->abr_type
= OSPF_ABR_DEFAULT
;
2068 ospf_schedule_abr_task(ospf
);
2074 DEFUN (ospf_log_adjacency_changes
,
2075 ospf_log_adjacency_changes_cmd
,
2076 "log-adjacency-changes",
2077 "Log changes in adjacency state\n")
2079 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2081 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2082 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2086 DEFUN (ospf_log_adjacency_changes_detail
,
2087 ospf_log_adjacency_changes_detail_cmd
,
2088 "log-adjacency-changes detail",
2089 "Log changes in adjacency state\n"
2090 "Log all state changes\n")
2092 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2094 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2095 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2099 DEFUN (no_ospf_log_adjacency_changes
,
2100 no_ospf_log_adjacency_changes_cmd
,
2101 "no log-adjacency-changes",
2103 "Log changes in adjacency state\n")
2105 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2107 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2108 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2112 DEFUN (no_ospf_log_adjacency_changes_detail
,
2113 no_ospf_log_adjacency_changes_detail_cmd
,
2114 "no log-adjacency-changes detail",
2116 "Log changes in adjacency state\n"
2117 "Log all state changes\n")
2119 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2121 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2125 DEFUN (ospf_compatible_rfc1583
,
2126 ospf_compatible_rfc1583_cmd
,
2127 "compatible rfc1583",
2128 "OSPF compatibility list\n"
2129 "compatible with RFC 1583\n")
2131 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2133 if (!CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)) {
2134 SET_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2135 ospf_spf_calculate_schedule(ospf
, SPF_FLAG_CONFIG_CHANGE
);
2140 DEFUN (no_ospf_compatible_rfc1583
,
2141 no_ospf_compatible_rfc1583_cmd
,
2142 "no compatible rfc1583",
2144 "OSPF compatibility list\n"
2145 "compatible with RFC 1583\n")
2147 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2149 if (CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)) {
2150 UNSET_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2151 ospf_spf_calculate_schedule(ospf
, SPF_FLAG_CONFIG_CHANGE
);
2156 ALIAS(ospf_compatible_rfc1583
, ospf_rfc1583_flag_cmd
,
2157 "ospf rfc1583compatibility",
2158 "OSPF specific commands\n"
2159 "Enable the RFC1583Compatibility flag\n")
2161 ALIAS(no_ospf_compatible_rfc1583
, no_ospf_rfc1583_flag_cmd
,
2162 "no ospf rfc1583compatibility", NO_STR
2163 "OSPF specific commands\n"
2164 "Disable the RFC1583Compatibility flag\n")
2166 static int ospf_timers_spf_set(struct vty
*vty
, unsigned int delay
,
2167 unsigned int hold
, unsigned int max
)
2169 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2171 ospf
->spf_delay
= delay
;
2172 ospf
->spf_holdtime
= hold
;
2173 ospf
->spf_max_holdtime
= max
;
2178 DEFUN (ospf_timers_min_ls_interval
,
2179 ospf_timers_min_ls_interval_cmd
,
2180 "timers throttle lsa all (0-5000)",
2181 "Adjust routing timers\n"
2182 "Throttling adaptive timer\n"
2183 "LSA delay between transmissions\n"
2185 "Delay (msec) between sending LSAs\n")
2187 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2189 unsigned int interval
;
2192 vty_out(vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2196 VTY_GET_INTEGER("LSA interval", interval
, argv
[idx_number
]->arg
);
2198 ospf
->min_ls_interval
= interval
;
2203 DEFUN (no_ospf_timers_min_ls_interval
,
2204 no_ospf_timers_min_ls_interval_cmd
,
2205 "no timers throttle lsa all [(0-5000)]",
2207 "Adjust routing timers\n"
2208 "Throttling adaptive timer\n"
2209 "LSA delay between transmissions\n"
2211 "Delay (msec) between sending LSAs\n")
2213 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2214 ospf
->min_ls_interval
= OSPF_MIN_LS_INTERVAL
;
2220 DEFUN (ospf_timers_min_ls_arrival
,
2221 ospf_timers_min_ls_arrival_cmd
,
2222 "timers lsa arrival (0-1000)",
2223 "Adjust routing timers\n"
2224 "Throttling link state advertisement delays\n"
2225 "OSPF minimum arrival interval delay\n"
2226 "Delay (msec) between accepted LSAs\n")
2228 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2230 unsigned int arrival
;
2233 vty_out(vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2237 VTY_GET_INTEGER_RANGE("minimum LSA inter-arrival time", arrival
,
2238 argv
[idx_number
]->arg
, 0, 1000);
2240 ospf
->min_ls_arrival
= arrival
;
2245 DEFUN (no_ospf_timers_min_ls_arrival
,
2246 no_ospf_timers_min_ls_arrival_cmd
,
2247 "no timers lsa arrival [(0-1000)]",
2249 "Adjust routing timers\n"
2250 "Throttling link state advertisement delays\n"
2251 "OSPF minimum arrival interval delay\n"
2252 "Delay (msec) between accepted LSAs\n")
2254 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2256 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2262 DEFUN (ospf_timers_throttle_spf
,
2263 ospf_timers_throttle_spf_cmd
,
2264 "timers throttle spf (0-600000) (0-600000) (0-600000)",
2265 "Adjust routing timers\n"
2266 "Throttling adaptive timer\n"
2268 "Delay (msec) from first change received till SPF calculation\n"
2269 "Initial hold time (msec) between consecutive SPF calculations\n"
2270 "Maximum hold time (msec)\n")
2273 int idx_number_2
= 4;
2274 int idx_number_3
= 5;
2275 unsigned int delay
, hold
, max
;
2278 vty_out(vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2282 VTY_GET_INTEGER_RANGE("SPF delay timer", delay
, argv
[idx_number
]->arg
,
2284 VTY_GET_INTEGER_RANGE("SPF hold timer", hold
, argv
[idx_number_2
]->arg
,
2286 VTY_GET_INTEGER_RANGE("SPF max-hold timer", max
,
2287 argv
[idx_number_3
]->arg
, 0, 600000);
2289 return ospf_timers_spf_set(vty
, delay
, hold
, max
);
2292 DEFUN (no_ospf_timers_throttle_spf
,
2293 no_ospf_timers_throttle_spf_cmd
,
2294 "no timers throttle spf [(0-600000)(0-600000)(0-600000)]",
2296 "Adjust routing timers\n"
2297 "Throttling adaptive timer\n"
2299 "Delay (msec) from first change received till SPF calculation\n"
2300 "Initial hold time (msec) between consecutive SPF calculations\n"
2301 "Maximum hold time (msec)\n")
2303 return ospf_timers_spf_set(vty
, OSPF_SPF_DELAY_DEFAULT
,
2304 OSPF_SPF_HOLDTIME_DEFAULT
,
2305 OSPF_SPF_MAX_HOLDTIME_DEFAULT
);
2309 DEFUN (ospf_timers_lsa
,
2310 ospf_timers_lsa_cmd
,
2311 "timers lsa min-arrival (0-600000)",
2312 "Adjust routing timers\n"
2314 "Minimum delay in receiving new version of a LSA\n"
2315 "Delay in milliseconds\n")
2317 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2319 unsigned int minarrival
;
2322 vty_out(vty
, "Insufficient number of arguments%s", VTY_NEWLINE
);
2326 VTY_GET_INTEGER("LSA min-arrival", minarrival
, argv
[idx_number
]->arg
);
2328 ospf
->min_ls_arrival
= minarrival
;
2333 DEFUN (no_ospf_timers_lsa
,
2334 no_ospf_timers_lsa_cmd
,
2335 "no timers lsa min-arrival [(0-600000)]",
2337 "Adjust routing timers\n"
2339 "Minimum delay in receiving new version of a LSA\n"
2340 "Delay in milliseconds\n")
2342 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2343 unsigned int minarrival
;
2346 VTY_GET_INTEGER("LSA min-arrival", minarrival
, argv
[4]->arg
);
2348 if (ospf
->min_ls_arrival
!= minarrival
2349 || minarrival
== OSPF_MIN_LS_ARRIVAL
)
2353 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2358 DEFUN (ospf_neighbor
,
2360 "neighbor A.B.C.D [priority (0-255) [poll-interval (1-65535)]]",
2362 "Neighbor IP address\n"
2363 "Neighbor Priority\n"
2365 "Dead Neighbor Polling interval\n"
2368 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2372 struct in_addr nbr_addr
;
2373 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2374 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2376 VTY_GET_IPV4_ADDRESS("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2379 VTY_GET_INTEGER_RANGE("neighbor priority", priority
,
2380 argv
[idx_pri
]->arg
, 0, 255);
2383 VTY_GET_INTEGER_RANGE("poll interval", interval
,
2384 argv
[idx_poll
]->arg
, 1, 65535);
2386 ospf_nbr_nbma_set(ospf
, nbr_addr
);
2389 ospf_nbr_nbma_priority_set(ospf
, nbr_addr
, priority
);
2392 ospf_nbr_nbma_poll_interval_set(ospf
, nbr_addr
, interval
);
2397 DEFUN (ospf_neighbor_poll_interval
,
2398 ospf_neighbor_poll_interval_cmd
,
2399 "neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2401 "Neighbor IP address\n"
2402 "Dead Neighbor Polling interval\n"
2404 "OSPF priority of non-broadcast neighbor\n"
2407 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2411 struct in_addr nbr_addr
;
2412 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2413 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2415 VTY_GET_IPV4_ADDRESS("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2417 VTY_GET_INTEGER_RANGE("poll interval", interval
, argv
[idx_poll
]->arg
, 1,
2421 VTY_GET_INTEGER_RANGE("neighbor priority", priority
,
2422 argv
[idx_pri
]->arg
, 0, 255);
2424 ospf_nbr_nbma_set(ospf
, nbr_addr
);
2425 ospf_nbr_nbma_poll_interval_set(ospf
, nbr_addr
, interval
);
2428 ospf_nbr_nbma_priority_set(ospf
, nbr_addr
, priority
);
2433 DEFUN (no_ospf_neighbor
,
2434 no_ospf_neighbor_cmd
,
2435 "no neighbor A.B.C.D [priority (0-255) [poll-interval (1-65525)]]",
2438 "Neighbor IP address\n"
2439 "Neighbor Priority\n"
2441 "Dead Neighbor Polling interval\n"
2444 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2446 struct in_addr nbr_addr
;
2448 VTY_GET_IPV4_ADDRESS("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2450 (void)ospf_nbr_nbma_unset(ospf
, nbr_addr
);
2455 DEFUN (no_ospf_neighbor_poll
,
2456 no_ospf_neighbor_poll_cmd
,
2457 "no neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2460 "Neighbor IP address\n"
2461 "Dead Neighbor Polling interval\n"
2463 "Neighbor Priority\n"
2466 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2468 struct in_addr nbr_addr
;
2470 VTY_GET_IPV4_ADDRESS("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2472 (void)ospf_nbr_nbma_unset(ospf
, nbr_addr
);
2477 DEFUN (ospf_refresh_timer
,
2478 ospf_refresh_timer_cmd
,
2479 "refresh timer (10-1800)",
2480 "Adjust refresh parameters\n"
2481 "Set refresh timer\n"
2482 "Timer value in seconds\n")
2484 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2486 unsigned int interval
;
2488 VTY_GET_INTEGER_RANGE("refresh timer", interval
, argv
[idx_number
]->arg
,
2490 interval
= (interval
/ OSPF_LSA_REFRESHER_GRANULARITY
)
2491 * OSPF_LSA_REFRESHER_GRANULARITY
;
2493 ospf_timers_refresh_set(ospf
, interval
);
2498 DEFUN (no_ospf_refresh_timer
,
2499 no_ospf_refresh_timer_val_cmd
,
2500 "no refresh timer [(10-1800)]",
2502 "Adjust refresh parameters\n"
2503 "Unset refresh timer\n"
2504 "Timer value in seconds\n")
2506 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2508 unsigned int interval
;
2511 VTY_GET_INTEGER_RANGE("refresh timer", interval
,
2512 argv
[idx_number
]->arg
, 10, 1800);
2514 if (ospf
->lsa_refresh_interval
!= interval
2515 || interval
== OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
2519 ospf_timers_refresh_unset(ospf
);
2525 DEFUN (ospf_auto_cost_reference_bandwidth
,
2526 ospf_auto_cost_reference_bandwidth_cmd
,
2527 "auto-cost reference-bandwidth (1-4294967)",
2528 "Calculate OSPF interface cost according to bandwidth\n"
2529 "Use reference bandwidth method to assign OSPF cost\n"
2530 "The reference bandwidth in terms of Mbits per second\n")
2532 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2535 struct listnode
*node
;
2536 struct interface
*ifp
;
2538 refbw
= strtol(argv
[idx_number
]->arg
, NULL
, 10);
2539 if (refbw
< 1 || refbw
> 4294967) {
2540 vty_out(vty
, "reference-bandwidth value is invalid%s",
2545 /* If reference bandwidth is changed. */
2546 if ((refbw
) == ospf
->ref_bandwidth
)
2549 ospf
->ref_bandwidth
= refbw
;
2550 for (ALL_LIST_ELEMENTS_RO(om
->iflist
, node
, ifp
))
2551 ospf_if_recalculate_output_cost(ifp
);
2556 DEFUN (no_ospf_auto_cost_reference_bandwidth
,
2557 no_ospf_auto_cost_reference_bandwidth_cmd
,
2558 "no auto-cost reference-bandwidth [(1-4294967)]",
2560 "Calculate OSPF interface cost according to bandwidth\n"
2561 "Use reference bandwidth method to assign OSPF cost\n"
2562 "The reference bandwidth in terms of Mbits per second\n")
2564 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2565 struct listnode
*node
, *nnode
;
2566 struct interface
*ifp
;
2568 if (ospf
->ref_bandwidth
== OSPF_DEFAULT_REF_BANDWIDTH
)
2571 ospf
->ref_bandwidth
= OSPF_DEFAULT_REF_BANDWIDTH
;
2572 vty_out(vty
, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE
);
2574 " Please ensure reference bandwidth is consistent across all routers%s",
2577 for (ALL_LIST_ELEMENTS(om
->iflist
, node
, nnode
, ifp
))
2578 ospf_if_recalculate_output_cost(ifp
);
2583 DEFUN (ospf_write_multiplier
,
2584 ospf_write_multiplier_cmd
,
2585 "ospf write-multiplier (1-100)",
2586 "OSPF specific commands\n"
2587 "Write multiplier\n"
2588 "Maximum number of interface serviced per write\n")
2590 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2592 u_int32_t write_oi_count
;
2599 write_oi_count
= strtol(argv
[idx_number
]->arg
, NULL
, 10);
2600 if (write_oi_count
< 1 || write_oi_count
> 100) {
2601 vty_out(vty
, "write-multiplier value is invalid%s",
2606 ospf
->write_oi_count
= write_oi_count
;
2610 ALIAS(ospf_write_multiplier
, write_multiplier_cmd
, "write-multiplier (1-100)",
2611 "Write multiplier\n"
2612 "Maximum number of interface serviced per write\n")
2614 DEFUN (no_ospf_write_multiplier
,
2615 no_ospf_write_multiplier_cmd
,
2616 "no ospf write-multiplier (1-100)",
2618 "OSPF specific commands\n"
2619 "Write multiplier\n"
2620 "Maximum number of interface serviced per write\n")
2622 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2624 ospf
->write_oi_count
= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
;
2628 ALIAS(no_ospf_write_multiplier
, no_write_multiplier_cmd
,
2629 "no write-multiplier (1-100)", NO_STR
2630 "Write multiplier\n"
2631 "Maximum number of interface serviced per write\n")
2633 const char *ospf_abr_type_descr_str
[] = {"Unknown", "Standard (RFC2328)",
2634 "Alternative IBM", "Alternative Cisco",
2635 "Alternative Shortcut"};
2637 const char *ospf_shortcut_mode_descr_str
[] = {"Default", "Enabled", "Disabled"};
2639 static void show_ip_ospf_area(struct vty
*vty
, struct ospf_area
*area
,
2640 json_object
*json_areas
, u_char use_json
)
2642 json_object
*json_area
= NULL
;
2645 json_area
= json_object_new_object();
2649 vty_out(vty
, " Area ID: %s", inet_ntoa(area
->area_id
));
2651 /* Show Area type/mode. */
2652 if (OSPF_IS_AREA_BACKBONE(area
)) {
2654 json_object_boolean_true_add(json_area
, "backbone");
2656 vty_out(vty
, " (Backbone)%s", VTY_NEWLINE
);
2659 if (area
->external_routing
== OSPF_AREA_STUB
) {
2660 if (area
->no_summary
)
2661 json_object_boolean_true_add(
2662 json_area
, "stubNoSummary");
2663 if (area
->shortcut_configured
)
2664 json_object_boolean_true_add(
2665 json_area
, "stubShortcut");
2666 } else if (area
->external_routing
== OSPF_AREA_NSSA
) {
2667 if (area
->no_summary
)
2668 json_object_boolean_true_add(
2669 json_area
, "nssaNoSummary");
2670 if (area
->shortcut_configured
)
2671 json_object_boolean_true_add(
2672 json_area
, "nssaShortcut");
2675 json_object_string_add(
2676 json_area
, "shortcuttingMode",
2677 ospf_shortcut_mode_descr_str
2678 [area
->shortcut_configured
]);
2679 if (area
->shortcut_capability
)
2680 json_object_boolean_true_add(json_area
,
2683 if (area
->external_routing
== OSPF_AREA_STUB
)
2684 vty_out(vty
, " (Stub%s%s)",
2685 area
->no_summary
? ", no summary" : "",
2686 area
->shortcut_configured
? "; " : "");
2687 else if (area
->external_routing
== OSPF_AREA_NSSA
)
2688 vty_out(vty
, " (NSSA%s%s)",
2689 area
->no_summary
? ", no summary" : "",
2690 area
->shortcut_configured
? "; " : "");
2692 vty_out(vty
, "%s", VTY_NEWLINE
);
2693 vty_out(vty
, " Shortcutting mode: %s",
2694 ospf_shortcut_mode_descr_str
2695 [area
->shortcut_configured
]);
2696 vty_out(vty
, ", S-bit consensus: %s%s",
2697 area
->shortcut_capability
? "ok" : "no",
2702 /* Show number of interfaces */
2704 json_object_int_add(json_area
, "areaIfTotalCounter",
2705 listcount(area
->oiflist
));
2706 json_object_int_add(json_area
, "areaIfActiveCounter",
2710 " Number of interfaces in this area: Total: %d, "
2712 listcount(area
->oiflist
), area
->act_ints
, VTY_NEWLINE
);
2714 if (area
->external_routing
== OSPF_AREA_NSSA
) {
2716 json_object_boolean_true_add(json_area
, "nssa");
2717 if (!IS_OSPF_ABR(area
->ospf
))
2718 json_object_boolean_false_add(json_area
, "abr");
2719 else if (area
->NSSATranslatorState
) {
2720 json_object_boolean_true_add(json_area
, "abr");
2721 if (area
->NSSATranslatorRole
2722 == OSPF_NSSA_ROLE_CANDIDATE
)
2723 json_object_boolean_true_add(
2725 "nssaTranslatorElected");
2726 else if (area
->NSSATranslatorRole
2727 == OSPF_NSSA_ROLE_ALWAYS
)
2728 json_object_boolean_true_add(
2730 "nssaTranslatorAlways");
2732 json_object_boolean_true_add(json_area
, "abr");
2733 if (area
->NSSATranslatorRole
2734 == OSPF_NSSA_ROLE_CANDIDATE
)
2735 json_object_boolean_false_add(
2737 "nssaTranslatorElected");
2739 json_object_boolean_true_add(
2741 "nssaTranslatorNever");
2745 " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s",
2746 VTY_NEWLINE
, VTY_NEWLINE
);
2747 if (!IS_OSPF_ABR(area
->ospf
))
2749 " It is not ABR, therefore not Translator. %s",
2751 else if (area
->NSSATranslatorState
) {
2752 vty_out(vty
, " We are an ABR and ");
2753 if (area
->NSSATranslatorRole
2754 == OSPF_NSSA_ROLE_CANDIDATE
)
2756 "the NSSA Elected Translator. %s",
2758 else if (area
->NSSATranslatorRole
2759 == OSPF_NSSA_ROLE_ALWAYS
)
2761 "always an NSSA Translator. %s",
2764 vty_out(vty
, " We are an ABR, but ");
2765 if (area
->NSSATranslatorRole
2766 == OSPF_NSSA_ROLE_CANDIDATE
)
2768 "not the NSSA Elected Translator. %s",
2772 "never an NSSA Translator. %s",
2778 /* Stub-router state for this area */
2779 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
)) {
2780 char timebuf
[OSPF_TIME_DUMP_SIZE
];
2783 json_object_boolean_true_add(
2784 json_area
, "originStubMaxDistRouterLsa");
2785 if (CHECK_FLAG(area
->stub_router_state
,
2786 OSPF_AREA_ADMIN_STUB_ROUTED
))
2787 json_object_boolean_true_add(
2788 json_area
, "indefiniteActiveAdmin");
2789 if (area
->t_stub_router
) {
2793 &area
->t_stub_router
->u
.sands
,
2796 json_object_int_add(
2798 "activeStartupRemainderMsecs",
2803 " Originating stub / maximum-distance Router-LSA%s",
2805 if (CHECK_FLAG(area
->stub_router_state
,
2806 OSPF_AREA_ADMIN_STUB_ROUTED
))
2808 " Administratively activated (indefinitely)%s",
2810 if (area
->t_stub_router
)
2812 " Active from startup, %s remaining%s",
2813 ospf_timer_dump(area
->t_stub_router
,
2821 /* Show number of fully adjacent neighbors. */
2822 json_object_int_add(json_area
, "nbrFullAdjacentCounter",
2825 /* Show authentication type. */
2826 if (area
->auth_type
== OSPF_AUTH_NULL
)
2827 json_object_string_add(json_area
, "authentication",
2828 "authenticationNone");
2829 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
2830 json_object_string_add(json_area
, "authentication",
2831 "authenticationSimplePassword");
2832 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
2833 json_object_string_add(json_area
, "authentication",
2834 "authenticationMessageDigest");
2836 if (!OSPF_IS_AREA_BACKBONE(area
))
2837 json_object_int_add(json_area
,
2838 "virtualAdjacenciesPassingCounter",
2841 /* Show SPF calculation times. */
2842 json_object_int_add(json_area
, "spfExecutedCounter",
2843 area
->spf_calculation
);
2844 json_object_int_add(json_area
, "lsaNumber", area
->lsdb
->total
);
2845 json_object_int_add(
2846 json_area
, "lsaRouterNumber",
2847 ospf_lsdb_count(area
->lsdb
, OSPF_ROUTER_LSA
));
2848 json_object_int_add(
2849 json_area
, "lsaRouterChecksum",
2850 ospf_lsdb_checksum(area
->lsdb
, OSPF_ROUTER_LSA
));
2851 json_object_int_add(
2852 json_area
, "lsaNetworkNumber",
2853 ospf_lsdb_count(area
->lsdb
, OSPF_NETWORK_LSA
));
2854 json_object_int_add(
2855 json_area
, "lsaNetworkChecksum",
2856 ospf_lsdb_checksum(area
->lsdb
, OSPF_NETWORK_LSA
));
2857 json_object_int_add(
2858 json_area
, "lsaSummaryNumber",
2859 ospf_lsdb_count(area
->lsdb
, OSPF_SUMMARY_LSA
));
2860 json_object_int_add(
2861 json_area
, "lsaSummaryChecksum",
2862 ospf_lsdb_checksum(area
->lsdb
, OSPF_SUMMARY_LSA
));
2863 json_object_int_add(
2864 json_area
, "lsaAsbrNumber",
2865 ospf_lsdb_count(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2866 json_object_int_add(
2867 json_area
, "lsaAsbrChecksum",
2868 ospf_lsdb_checksum(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2869 json_object_int_add(
2870 json_area
, "lsaNssaNumber",
2871 ospf_lsdb_count(area
->lsdb
, OSPF_AS_NSSA_LSA
));
2872 json_object_int_add(
2873 json_area
, "lsaNssaChecksum",
2874 ospf_lsdb_checksum(area
->lsdb
, OSPF_AS_NSSA_LSA
));
2876 /* Show number of fully adjacent neighbors. */
2878 " Number of fully adjacent neighbors in this area:"
2880 area
->full_nbrs
, VTY_NEWLINE
);
2882 /* Show authentication type. */
2883 vty_out(vty
, " Area has ");
2884 if (area
->auth_type
== OSPF_AUTH_NULL
)
2885 vty_out(vty
, "no authentication%s", VTY_NEWLINE
);
2886 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
2887 vty_out(vty
, "simple password authentication%s",
2889 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
2890 vty_out(vty
, "message digest authentication%s",
2893 if (!OSPF_IS_AREA_BACKBONE(area
))
2895 " Number of full virtual adjacencies going through"
2897 area
->full_vls
, VTY_NEWLINE
);
2899 /* Show SPF calculation times. */
2900 vty_out(vty
, " SPF algorithm executed %d times%s",
2901 area
->spf_calculation
, VTY_NEWLINE
);
2903 /* Show number of LSA. */
2904 vty_out(vty
, " Number of LSA %ld%s", area
->lsdb
->total
,
2907 " Number of router LSA %ld. Checksum Sum 0x%08x%s",
2908 ospf_lsdb_count(area
->lsdb
, OSPF_ROUTER_LSA
),
2909 ospf_lsdb_checksum(area
->lsdb
, OSPF_ROUTER_LSA
),
2912 " Number of network LSA %ld. Checksum Sum 0x%08x%s",
2913 ospf_lsdb_count(area
->lsdb
, OSPF_NETWORK_LSA
),
2914 ospf_lsdb_checksum(area
->lsdb
, OSPF_NETWORK_LSA
),
2917 " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
2918 ospf_lsdb_count(area
->lsdb
, OSPF_SUMMARY_LSA
),
2919 ospf_lsdb_checksum(area
->lsdb
, OSPF_SUMMARY_LSA
),
2922 " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
2923 ospf_lsdb_count(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
),
2924 ospf_lsdb_checksum(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
),
2926 vty_out(vty
, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
2927 ospf_lsdb_count(area
->lsdb
, OSPF_AS_NSSA_LSA
),
2928 ospf_lsdb_checksum(area
->lsdb
, OSPF_AS_NSSA_LSA
),
2933 json_object_int_add(
2934 json_area
, "lsaOpaqueLinkNumber",
2935 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
2936 json_object_int_add(
2937 json_area
, "lsaOpaqueLinkChecksum",
2938 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
2939 json_object_int_add(
2940 json_area
, "lsaOpaqueAreaNumber",
2941 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
2942 json_object_int_add(
2943 json_area
, "lsaOpaqueAreaChecksum",
2944 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
2947 " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
2948 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
),
2949 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
),
2952 " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
2953 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
),
2954 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
),
2959 json_object_object_add(json_areas
, inet_ntoa(area
->area_id
),
2962 vty_out(vty
, "%s", VTY_NEWLINE
);
2965 static int show_ip_ospf_common(struct vty
*vty
, struct ospf
*ospf
,
2968 struct listnode
*node
, *nnode
;
2969 struct ospf_area
*area
;
2970 struct timeval result
;
2971 char timebuf
[OSPF_TIME_DUMP_SIZE
];
2972 json_object
*json
= NULL
;
2973 json_object
*json_areas
= NULL
;
2976 json
= json_object_new_object();
2977 json_areas
= json_object_new_object();
2980 if (ospf
->instance
) {
2982 json_object_int_add(json
, "ospfInstance",
2985 vty_out(vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
,
2986 ospf
->instance
, VTY_NEWLINE
, VTY_NEWLINE
);
2990 /* Show Router ID. */
2992 json_object_string_add(json
, "routerId",
2993 inet_ntoa(ospf
->router_id
));
2995 vty_out(vty
, " OSPF Routing Process, Router ID: %s%s",
2996 inet_ntoa(ospf
->router_id
), VTY_NEWLINE
);
2999 /* Graceful shutdown */
3000 if (ospf
->t_deferred_shutdown
) {
3005 &ospf
->t_deferred_shutdown
->u
.sands
,
3008 json_object_int_add(json
, "deferredShutdownMsecs",
3012 " Deferred shutdown in progress, %s remaining%s",
3013 ospf_timer_dump(ospf
->t_deferred_shutdown
,
3014 timebuf
, sizeof(timebuf
)),
3019 /* Show capability. */
3021 json_object_boolean_true_add(json
, "tosRoutesOnly");
3022 json_object_boolean_true_add(json
, "rfc2328Conform");
3023 if (CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)) {
3024 json_object_boolean_true_add(json
,
3025 "rfc1583Compatibility");
3028 vty_out(vty
, " Supports only single TOS (TOS0) routes%s",
3030 vty_out(vty
, " This implementation conforms to RFC2328%s",
3032 vty_out(vty
, " RFC1583Compatibility flag is %s%s",
3033 CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)
3040 if (CHECK_FLAG(ospf
->config
, OSPF_OPAQUE_CAPABLE
)) {
3041 json_object_boolean_true_add(json
, "opaqueCapable");
3044 vty_out(vty
, " OpaqueCapability flag is %s%s",
3045 CHECK_FLAG(ospf
->config
, OSPF_OPAQUE_CAPABLE
)
3051 /* Show stub-router configuration */
3052 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
3053 || ospf
->stub_router_shutdown_time
3054 != OSPF_STUB_ROUTER_UNCONFIGURED
) {
3056 json_object_boolean_true_add(json
, "stubAdvertisement");
3057 if (ospf
->stub_router_startup_time
3058 != OSPF_STUB_ROUTER_UNCONFIGURED
)
3059 json_object_int_add(
3060 json
, "postStartEnabledMsecs",
3061 ospf
->stub_router_startup_time
/ 1000);
3062 if (ospf
->stub_router_shutdown_time
3063 != OSPF_STUB_ROUTER_UNCONFIGURED
)
3064 json_object_int_add(
3065 json
, "preShutdownEnabledMsecs",
3066 ospf
->stub_router_shutdown_time
/ 1000);
3069 " Stub router advertisement is configured%s",
3071 if (ospf
->stub_router_startup_time
3072 != OSPF_STUB_ROUTER_UNCONFIGURED
)
3074 " Enabled for %us after start-up%s",
3075 ospf
->stub_router_startup_time
,
3077 if (ospf
->stub_router_shutdown_time
3078 != OSPF_STUB_ROUTER_UNCONFIGURED
)
3080 " Enabled for %us prior to full shutdown%s",
3081 ospf
->stub_router_shutdown_time
,
3086 /* Show SPF timers. */
3088 json_object_int_add(json
, "spfScheduleDelayMsecs",
3090 json_object_int_add(json
, "holdtimeMinMsecs",
3091 ospf
->spf_holdtime
);
3092 json_object_int_add(json
, "holdtimeMaxMsecs",
3093 ospf
->spf_max_holdtime
);
3094 json_object_int_add(json
, "holdtimeMultplier",
3095 ospf
->spf_hold_multiplier
);
3098 " Initial SPF scheduling delay %d millisec(s)%s"
3099 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
3100 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
3101 " Hold time multiplier is currently %d%s",
3102 ospf
->spf_delay
, VTY_NEWLINE
, ospf
->spf_holdtime
,
3103 VTY_NEWLINE
, ospf
->spf_max_holdtime
, VTY_NEWLINE
,
3104 ospf
->spf_hold_multiplier
, VTY_NEWLINE
);
3108 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
) {
3109 long time_store
= 0;
3112 monotime_since(&ospf
->ts_spf
, NULL
) / 1000LL;
3113 json_object_int_add(json
, "spfLastExecutedMsecs",
3116 time_store
= (1000 * ospf
->ts_spf_duration
.tv_sec
)
3117 + (ospf
->ts_spf_duration
.tv_usec
/ 1000);
3118 json_object_int_add(json
, "spfLastDurationMsecs",
3121 json_object_boolean_true_add(json
, "spfHasNotRun");
3123 vty_out(vty
, " SPF algorithm ");
3124 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
) {
3125 monotime_since(&ospf
->ts_spf
, &result
);
3126 vty_out(vty
, "last executed %s ago%s",
3127 ospf_timeval_dump(&result
, timebuf
,
3130 vty_out(vty
, " Last SPF duration %s%s",
3131 ospf_timeval_dump(&ospf
->ts_spf_duration
,
3132 timebuf
, sizeof(timebuf
)),
3135 vty_out(vty
, "has not been run%s", VTY_NEWLINE
);
3139 if (ospf
->t_spf_calc
) {
3142 monotime_until(&ospf
->t_spf_calc
->u
.sands
, NULL
)
3144 json_object_int_add(json
, "spfTimerDueInMsecs",
3148 json_object_int_add(json
, "lsaMinIntervalMsecs",
3149 ospf
->min_ls_interval
);
3150 json_object_int_add(json
, "lsaMinArrivalMsecs",
3151 ospf
->min_ls_arrival
);
3152 /* Show write multiplier values */
3153 json_object_int_add(json
, "writeMultiplier",
3154 ospf
->write_oi_count
);
3155 /* Show refresh parameters. */
3156 json_object_int_add(json
, "refreshTimerMsecs",
3157 ospf
->lsa_refresh_interval
* 1000);
3159 vty_out(vty
, " SPF timer %s%s%s",
3160 (ospf
->t_spf_calc
? "due in " : "is "),
3161 ospf_timer_dump(ospf
->t_spf_calc
, timebuf
,
3165 vty_out(vty
, " LSA minimum interval %d msecs%s",
3166 ospf
->min_ls_interval
, VTY_NEWLINE
);
3167 vty_out(vty
, " LSA minimum arrival %d msecs%s",
3168 ospf
->min_ls_arrival
, VTY_NEWLINE
);
3170 /* Show write multiplier values */
3171 vty_out(vty
, " Write Multiplier set to %d %s",
3172 ospf
->write_oi_count
, VTY_NEWLINE
);
3174 /* Show refresh parameters. */
3175 vty_out(vty
, " Refresh timer %d secs%s",
3176 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
3179 /* Show ABR/ASBR flags. */
3180 if (CHECK_FLAG(ospf
->flags
, OSPF_FLAG_ABR
)) {
3182 json_object_string_add(
3184 ospf_abr_type_descr_str
[ospf
->abr_type
]);
3187 " This router is an ABR, ABR type is: %s%s",
3188 ospf_abr_type_descr_str
[ospf
->abr_type
],
3191 if (CHECK_FLAG(ospf
->flags
, OSPF_FLAG_ASBR
)) {
3193 json_object_string_add(
3195 "injectingExternalRoutingInformation");
3198 " This router is an ASBR "
3199 "(injecting external routing information)%s",
3203 /* Show Number of AS-external-LSAs. */
3205 json_object_int_add(
3206 json
, "lsaExternalCounter",
3207 ospf_lsdb_count(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3208 json_object_int_add(
3209 json
, "lsaExternalChecksum",
3210 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3213 " Number of external LSA %ld. Checksum Sum 0x%08x%s",
3214 ospf_lsdb_count(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
),
3215 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
),
3220 json_object_int_add(
3221 json
, "lsaAsopaqueCounter",
3222 ospf_lsdb_count(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3223 json_object_int_add(
3224 json
, "lsaAsOpaqueChecksum",
3225 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3228 " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
3229 ospf_lsdb_count(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
),
3230 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
),
3234 /* Show number of areas attached. */
3236 json_object_int_add(json
, "attachedAreaCounter",
3237 listcount(ospf
->areas
));
3239 vty_out(vty
, " Number of areas attached to this router: %d%s",
3240 listcount(ospf
->areas
), VTY_NEWLINE
);
3242 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
)) {
3243 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
)) {
3245 json_object_boolean_true_add(
3246 json
, "adjacencyChangesLoggedAll");
3249 " All adjacency changes are logged%s",
3253 json_object_boolean_true_add(
3254 json
, "adjacencyChangesLogged");
3256 vty_out(vty
, " Adjacency changes are logged%s",
3260 /* Show each area status. */
3261 for (ALL_LIST_ELEMENTS(ospf
->areas
, node
, nnode
, area
))
3262 show_ip_ospf_area(vty
, area
, json_areas
, use_json
);
3265 json_object_object_add(json
, "areas", json_areas
);
3266 vty_out(vty
, "%s%s", json_object_to_json_string_ext(
3267 json
, JSON_C_TO_STRING_PRETTY
),
3269 json_object_free(json
);
3271 vty_out(vty
, "%s", VTY_NEWLINE
);
3276 DEFUN (show_ip_ospf
,
3278 "show ip ospf [json]",
3281 "OSPF information\n"
3285 u_char uj
= use_json(argc
, argv
);
3287 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3290 return (show_ip_ospf_common(vty
, ospf
, uj
));
3293 DEFUN (show_ip_ospf_instance
,
3294 show_ip_ospf_instance_cmd
,
3295 "show ip ospf (1-65535) [json]",
3298 "OSPF information\n"
3304 u_short instance
= 0;
3305 u_char uj
= use_json(argc
, argv
);
3307 VTY_GET_INTEGER("Instance", instance
, argv
[idx_number
]->arg
);
3308 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
3309 || !ospf
->oi_running
)
3312 return (show_ip_ospf_common(vty
, ospf
, uj
));
3315 static void show_ip_ospf_interface_sub(struct vty
*vty
, struct ospf
*ospf
,
3316 struct interface
*ifp
,
3317 json_object
*json_interface_sub
,
3321 struct ospf_neighbor
*nbr
;
3322 struct route_node
*rn
;
3323 uint32_t bandwidth
= ifp
->bandwidth
? ifp
->bandwidth
: ifp
->speed
;
3325 /* Is interface up? */
3327 is_up
= if_is_operative(ifp
);
3329 json_object_boolean_true_add(json_interface_sub
,
3332 json_object_boolean_false_add(json_interface_sub
,
3335 json_object_int_add(json_interface_sub
, "ifIndex",
3337 json_object_int_add(json_interface_sub
, "mtuBytes", ifp
->mtu
);
3338 json_object_int_add(json_interface_sub
, "bandwidthMbit",
3340 json_object_string_add(json_interface_sub
, "ifFlags",
3341 if_flag_dump(ifp
->flags
));
3343 vty_out(vty
, "%s is %s%s", ifp
->name
,
3344 ((is_up
= if_is_operative(ifp
)) ? "up" : "down"),
3346 vty_out(vty
, " ifindex %u, MTU %u bytes, BW %u Mbit %s%s",
3347 ifp
->ifindex
, ifp
->mtu
, bandwidth
,
3348 if_flag_dump(ifp
->flags
), VTY_NEWLINE
);
3351 /* Is interface OSPF enabled? */
3353 if (ospf_oi_count(ifp
) == 0) {
3354 json_object_boolean_false_add(json_interface_sub
,
3357 } else if (!is_up
) {
3358 json_object_boolean_false_add(json_interface_sub
,
3362 json_object_boolean_true_add(json_interface_sub
,
3365 if (ospf_oi_count(ifp
) == 0) {
3366 vty_out(vty
, " OSPF not enabled on this interface%s",
3369 } else if (!is_up
) {
3371 " OSPF is enabled, but not running on this interface%s",
3377 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
3378 struct ospf_interface
*oi
= rn
->info
;
3383 if (CHECK_FLAG(oi
->connected
->flags
, ZEBRA_IFA_UNNUMBERED
)) {
3385 json_object_boolean_true_add(json_interface_sub
,
3388 vty_out(vty
, " This interface is UNNUMBERED,");
3390 /* Show OSPF interface information. */
3392 json_object_string_add(
3393 json_interface_sub
, "ipAddress",
3394 inet_ntoa(oi
->address
->u
.prefix4
));
3395 json_object_int_add(json_interface_sub
,
3396 "ipAddressPrefixlen",
3397 oi
->address
->prefixlen
);
3399 vty_out(vty
, " Internet Address %s/%d,",
3400 inet_ntoa(oi
->address
->u
.prefix4
),
3401 oi
->address
->prefixlen
);
3403 if (oi
->connected
->destination
3404 || oi
->type
== OSPF_IFTYPE_VIRTUALLINK
) {
3405 struct in_addr
*dest
;
3408 if (CONNECTED_PEER(oi
->connected
)
3409 || oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3414 /* For Vlinks, showing the peer address is
3416 * * * * * informative than the local
3417 * interface that is being used
3419 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3420 dest
= &oi
->vl_data
->peer_addr
;
3422 dest
= &oi
->connected
->destination
->u
3426 json_object_string_add(
3428 "ospfIfType", dstr
);
3429 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3430 json_object_string_add(
3435 json_object_string_add(
3440 vty_out(vty
, " %s %s,", dstr
,
3445 json_object_string_add(json_interface_sub
, "area",
3446 ospf_area_desc_string(oi
->area
));
3447 if (OSPF_IF_PARAM(oi
, mtu_ignore
))
3448 json_object_boolean_true_add(
3450 "mtuMismatchDetect");
3451 json_object_string_add(json_interface_sub
, "routerId",
3452 inet_ntoa(ospf
->router_id
));
3453 json_object_string_add(json_interface_sub
,
3455 ospf_network_type_str
[oi
->type
]);
3456 json_object_int_add(json_interface_sub
, "cost",
3458 json_object_int_add(
3459 json_interface_sub
, "transmitDelayMsecs",
3460 1000 / OSPF_IF_PARAM(oi
, transmit_delay
));
3461 json_object_string_add(json_interface_sub
, "state",
3462 lookup_msg(ospf_ism_state_msg
,
3464 json_object_int_add(json_interface_sub
, "priority",
3467 vty_out(vty
, " Area %s%s",
3468 ospf_area_desc_string(oi
->area
), VTY_NEWLINE
);
3470 vty_out(vty
, " MTU mismatch detection:%s%s",
3471 OSPF_IF_PARAM(oi
, mtu_ignore
) ? "disabled"
3476 " Router ID %s, Network Type %s, Cost: %d%s",
3477 inet_ntoa(ospf
->router_id
),
3478 ospf_network_type_str
[oi
->type
],
3479 oi
->output_cost
, VTY_NEWLINE
);
3482 " Transmit Delay is %d sec, State %s, Priority %d%s",
3483 OSPF_IF_PARAM(oi
, transmit_delay
),
3484 lookup_msg(ospf_ism_state_msg
, oi
->state
, NULL
),
3485 PRIORITY(oi
), VTY_NEWLINE
);
3488 /* Show DR information. */
3489 if (DR(oi
).s_addr
== 0) {
3492 " No backup designated router on this network%s",
3495 nbr
= ospf_nbr_lookup_by_addr(oi
->nbrs
, &BDR(oi
));
3499 " No backup designated router on this network%s",
3503 json_object_string_add(
3504 json_interface_sub
, "bdrId",
3505 inet_ntoa(nbr
->router_id
));
3506 json_object_string_add(
3509 inet_ntoa(nbr
->address
.u
3513 " Backup Designated Router (ID) %s,",
3514 inet_ntoa(nbr
->router_id
));
3515 vty_out(vty
, " Interface Address %s%s",
3517 nbr
->address
.u
.prefix4
),
3523 /* Next network-LSA sequence number we'll use, if we're elected
3526 && ntohl(oi
->params
->network_lsa_seqnum
)
3527 != OSPF_INITIAL_SEQUENCE_NUMBER
) {
3529 json_object_int_add(
3531 "networkLsaSequence",
3532 ntohl(oi
->params
->network_lsa_seqnum
));
3535 " Saved Network-LSA sequence number 0x%x%s",
3536 ntohl(oi
->params
->network_lsa_seqnum
),
3541 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3542 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
)) {
3543 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3544 json_object_boolean_true_add(
3546 "mcastMemberOspfAllRouters");
3547 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3548 json_object_boolean_true_add(
3550 "mcastMemberOspfDesignatedRouters");
3553 vty_out(vty
, " Multicast group memberships:");
3554 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3555 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
)) {
3556 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3557 vty_out(vty
, " OSPFAllRouters");
3558 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3559 vty_out(vty
, " OSPFDesignatedRouters");
3561 vty_out(vty
, " <None>");
3562 vty_out(vty
, "%s", VTY_NEWLINE
);
3566 if (OSPF_IF_PARAM(oi
, fast_hello
) == 0)
3567 json_object_int_add(
3568 json_interface_sub
, "timerMsecs",
3569 1000 / OSPF_IF_PARAM(oi
, v_hello
));
3571 json_object_int_add(
3572 json_interface_sub
, "timerMsecs",
3573 1000 / OSPF_IF_PARAM(oi
, fast_hello
));
3574 json_object_int_add(json_interface_sub
,
3576 1000 / OSPF_IF_PARAM(oi
, v_wait
));
3577 json_object_int_add(json_interface_sub
,
3579 1000 / OSPF_IF_PARAM(oi
, v_wait
));
3580 json_object_int_add(
3581 json_interface_sub
, "timerRetransmit",
3582 1000 / OSPF_IF_PARAM(oi
, retransmit_interval
));
3584 vty_out(vty
, " Timer intervals configured,");
3585 vty_out(vty
, " Hello ");
3586 if (OSPF_IF_PARAM(oi
, fast_hello
) == 0)
3587 vty_out(vty
, "%ds,",
3588 OSPF_IF_PARAM(oi
, v_hello
));
3590 vty_out(vty
, "%dms,",
3591 1000 / OSPF_IF_PARAM(oi
, fast_hello
));
3592 vty_out(vty
, " Dead %ds, Wait %ds, Retransmit %d%s",
3593 OSPF_IF_PARAM(oi
, v_wait
),
3594 OSPF_IF_PARAM(oi
, v_wait
),
3595 OSPF_IF_PARAM(oi
, retransmit_interval
),
3599 if (OSPF_IF_PASSIVE_STATUS(oi
) == OSPF_IF_ACTIVE
) {
3600 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3602 long time_store
= 0;
3606 &oi
->t_hello
->u
.sands
,
3609 json_object_int_add(json_interface_sub
,
3610 "timerHelloInMsecs",
3613 vty_out(vty
, " Hello due in %s%s",
3614 ospf_timer_dump(oi
->t_hello
, timebuf
,
3617 } else /* passive-interface is set */
3620 json_object_boolean_true_add(
3622 "timerPassiveIface");
3625 " No Hellos (Passive interface)%s",
3630 json_object_int_add(json_interface_sub
, "nbrCount",
3631 ospf_nbr_count(oi
, 0));
3632 json_object_int_add(json_interface_sub
,
3634 ospf_nbr_count(oi
, NSM_Full
));
3637 " Neighbor Count is %d, Adjacent neighbor count is %d%s",
3638 ospf_nbr_count(oi
, 0),
3639 ospf_nbr_count(oi
, NSM_Full
), VTY_NEWLINE
);
3640 ospf_bfd_interface_show(vty
, ifp
, json_interface_sub
, use_json
);
3644 static int show_ip_ospf_interface_common(struct vty
*vty
, struct ospf
*ospf
,
3645 int argc
, struct cmd_token
**argv
,
3646 int iface_argv
, u_char use_json
)
3648 struct interface
*ifp
;
3649 struct listnode
*node
;
3650 json_object
*json
= NULL
;
3651 json_object
*json_interface_sub
= NULL
;
3654 json
= json_object_new_object();
3657 if (ospf
->instance
) {
3659 json_object_int_add(json
, "ospfInstance",
3662 vty_out(vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
,
3663 ospf
->instance
, VTY_NEWLINE
, VTY_NEWLINE
);
3666 if (argc
== iface_argv
) {
3667 /* Show All Interfaces.*/
3668 for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT
), node
, ifp
)) {
3669 if (ospf_oi_count(ifp
)) {
3671 json_interface_sub
=
3672 json_object_new_object();
3674 show_ip_ospf_interface_sub(vty
, ospf
, ifp
,
3679 json_object_object_add(
3681 json_interface_sub
);
3685 /* Interface name is specified. */
3686 if ((ifp
= if_lookup_by_name(argv
[iface_argv
]->arg
,
3690 json_object_boolean_true_add(json
,
3693 vty_out(vty
, "No such interface name%s",
3697 json_interface_sub
= json_object_new_object();
3699 show_ip_ospf_interface_sub(
3700 vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3703 json_object_object_add(json
, ifp
->name
,
3704 json_interface_sub
);
3709 vty_out(vty
, "%s%s", json_object_to_json_string_ext(
3710 json
, JSON_C_TO_STRING_PRETTY
),
3712 json_object_free(json
);
3714 vty_out(vty
, "%s", VTY_NEWLINE
);
3719 DEFUN (show_ip_ospf_interface
,
3720 show_ip_ospf_interface_cmd
,
3721 "show ip ospf interface [INTERFACE] [json]",
3724 "OSPF information\n"
3725 "Interface information\n"
3730 u_char uj
= use_json(argc
, argv
);
3732 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3738 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 4, uj
);
3741 DEFUN (show_ip_ospf_instance_interface
,
3742 show_ip_ospf_instance_interface_cmd
,
3743 "show ip ospf (1-65535) interface [INTERFACE] [json]",
3746 "OSPF information\n"
3748 "Interface information\n"
3754 u_short instance
= 0;
3755 u_char uj
= use_json(argc
, argv
);
3757 VTY_GET_INTEGER("Instance", instance
, argv
[idx_number
]->arg
);
3758 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
3759 || !ospf
->oi_running
)
3765 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 5, uj
);
3768 static void show_ip_ospf_neighbour_header(struct vty
*vty
)
3770 vty_out(vty
, "%s%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
3771 VTY_NEWLINE
, "Neighbor ID", "Pri", "State", "Dead Time",
3772 "Address", "Interface", "RXmtL", "RqstL", "DBsmL", VTY_NEWLINE
);
3775 static void show_ip_ospf_neighbor_sub(struct vty
*vty
,
3776 struct ospf_interface
*oi
,
3777 json_object
*json
, u_char use_json
)
3779 struct route_node
*rn
;
3780 struct ospf_neighbor
*nbr
;
3782 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3783 json_object
*json_neighbor
= NULL
;
3785 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
)) {
3786 if ((nbr
= rn
->info
)) {
3787 /* Do not show myself. */
3788 if (nbr
!= oi
->nbr_self
) {
3789 /* Down state is not shown. */
3790 if (nbr
->state
!= NSM_Down
) {
3793 json_object_new_object();
3794 ospf_nbr_state_message(
3807 json_object_int_add(
3811 json_object_string_add(
3812 json_neighbor
, "state",
3814 json_object_int_add(
3818 json_object_string_add(
3821 inet_ntoa(nbr
->src
));
3822 json_object_string_add(
3826 json_object_int_add(
3828 "retransmitCounter",
3829 ospf_ls_retransmit_count(
3831 json_object_int_add(
3834 ospf_ls_request_count(
3836 json_object_int_add(
3839 ospf_db_summary_count(
3841 if (nbr
->state
== NSM_Attempt
3842 && nbr
->router_id
.s_addr
3844 json_object_object_add(
3849 json_object_object_add(
3855 ospf_nbr_state_message(
3858 if (nbr
->state
== NSM_Attempt
3859 && nbr
->router_id
.s_addr
3874 vty_out(vty
, "%9s ",
3879 vty_out(vty
, "%-15s ",
3880 inet_ntoa(nbr
->src
));
3882 "%-20s %5ld %5ld %5d%s",
3884 ospf_ls_retransmit_count(
3886 ospf_ls_request_count(
3888 ospf_db_summary_count(
3898 static int show_ip_ospf_neighbor_common(struct vty
*vty
, struct ospf
*ospf
,
3901 struct ospf_interface
*oi
;
3902 struct listnode
*node
;
3903 json_object
*json
= NULL
;
3906 json
= json_object_new_object();
3908 show_ip_ospf_neighbour_header(vty
);
3910 if (ospf
->instance
) {
3912 json_object_int_add(json
, "ospfInstance",
3915 vty_out(vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
,
3916 ospf
->instance
, VTY_NEWLINE
, VTY_NEWLINE
);
3919 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
))
3920 show_ip_ospf_neighbor_sub(vty
, oi
, json
, use_json
);
3923 vty_out(vty
, "%s%s", json_object_to_json_string_ext(
3924 json
, JSON_C_TO_STRING_PRETTY
),
3926 json_object_free(json
);
3928 vty_out(vty
, "%s", VTY_NEWLINE
);
3933 DEFUN (show_ip_ospf_neighbor
,
3934 show_ip_ospf_neighbor_cmd
,
3935 "show ip ospf neighbor [json]",
3938 "OSPF information\n"
3943 u_char uj
= use_json(argc
, argv
);
3945 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3948 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
3952 DEFUN (show_ip_ospf_instance_neighbor
,
3953 show_ip_ospf_instance_neighbor_cmd
,
3954 "show ip ospf (1-65535) neighbor [json]",
3957 "OSPF information\n"
3964 u_short instance
= 0;
3965 u_char uj
= use_json(argc
, argv
);
3967 VTY_GET_INTEGER("Instance", instance
, argv
[idx_number
]->arg
);
3968 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
3969 || !ospf
->oi_running
)
3972 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
3975 static int show_ip_ospf_neighbor_all_common(struct vty
*vty
, struct ospf
*ospf
,
3978 struct listnode
*node
;
3979 struct ospf_interface
*oi
;
3980 json_object
*json
= NULL
;
3981 json_object
*json_neighbor_sub
= NULL
;
3984 json
= json_object_new_object();
3985 json_neighbor_sub
= json_object_new_object();
3987 show_ip_ospf_neighbour_header(vty
);
3989 if (ospf
->instance
) {
3991 json_object_int_add(json
, "ospfInstance",
3994 vty_out(vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
,
3995 ospf
->instance
, VTY_NEWLINE
, VTY_NEWLINE
);
3998 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
3999 struct listnode
*nbr_node
;
4000 struct ospf_nbr_nbma
*nbr_nbma
;
4002 show_ip_ospf_neighbor_sub(vty
, oi
, json
, use_json
);
4004 /* print Down neighbor status */
4005 for (ALL_LIST_ELEMENTS_RO(oi
->nbr_nbma
, nbr_node
, nbr_nbma
)) {
4006 if (nbr_nbma
->nbr
== NULL
4007 || nbr_nbma
->nbr
->state
== NSM_Down
) {
4009 json_object_int_add(json_neighbor_sub
,
4011 nbr_nbma
->priority
);
4012 json_object_boolean_true_add(
4015 json_object_string_add(
4019 json_object_int_add(
4021 "nbrNbmaRetransmitCounter", 0);
4022 json_object_int_add(
4024 "nbrNbmaRequestCounter", 0);
4025 json_object_int_add(
4027 "nbrNbmaDbSummaryCounter", 0);
4028 json_object_object_add(
4029 json
, inet_ntoa(nbr_nbma
->addr
),
4032 vty_out(vty
, "%-15s %3d %-15s %9s ",
4033 "-", nbr_nbma
->priority
, "Down",
4036 "%-15s %-20s %5d %5d %5d%s",
4037 inet_ntoa(nbr_nbma
->addr
),
4038 IF_NAME(oi
), 0, 0, 0,
4046 vty_out(vty
, "%s%s", json_object_to_json_string_ext(
4047 json
, JSON_C_TO_STRING_PRETTY
),
4049 json_object_free(json
);
4051 vty_out(vty
, "%s", VTY_NEWLINE
);
4056 DEFUN (show_ip_ospf_neighbor_all
,
4057 show_ip_ospf_neighbor_all_cmd
,
4058 "show ip ospf neighbor all [json]",
4061 "OSPF information\n"
4063 "include down status neighbor\n"
4067 u_char uj
= use_json(argc
, argv
);
4069 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4072 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
4075 DEFUN (show_ip_ospf_instance_neighbor_all
,
4076 show_ip_ospf_instance_neighbor_all_cmd
,
4077 "show ip ospf (1-65535) neighbor all [json]",
4080 "OSPF information\n"
4083 "include down status neighbor\n"
4088 u_short instance
= 0;
4089 u_char uj
= use_json(argc
, argv
);
4091 VTY_GET_INTEGER("Instance", instance
, argv
[idx_number
]->arg
);
4092 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
4093 || !ospf
->oi_running
)
4096 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
4099 static int show_ip_ospf_neighbor_int_common(struct vty
*vty
, struct ospf
*ospf
,
4101 struct cmd_token
**argv
,
4104 struct interface
*ifp
;
4105 struct route_node
*rn
;
4106 json_object
*json
= NULL
;
4109 json
= json_object_new_object();
4111 show_ip_ospf_neighbour_header(vty
);
4113 if (ospf
->instance
) {
4115 json_object_int_add(json
, "ospfInstance",
4118 vty_out(vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
,
4119 ospf
->instance
, VTY_NEWLINE
, VTY_NEWLINE
);
4122 ifp
= if_lookup_by_name(argv
[arg_base
]->arg
, VRF_DEFAULT
);
4125 json_object_boolean_true_add(json
, "noSuchIface");
4127 vty_out(vty
, "No such interface.%s", VTY_NEWLINE
);
4131 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
4132 struct ospf_interface
*oi
= rn
->info
;
4137 show_ip_ospf_neighbor_sub(vty
, oi
, json
, use_json
);
4141 vty_out(vty
, "%s%s", json_object_to_json_string_ext(
4142 json
, JSON_C_TO_STRING_PRETTY
),
4144 json_object_free(json
);
4146 vty_out(vty
, "%s", VTY_NEWLINE
);
4151 DEFUN (show_ip_ospf_neighbor_int
,
4152 show_ip_ospf_neighbor_int_cmd
,
4153 "show ip ospf neighbor IFNAME [json]",
4156 "OSPF information\n"
4162 u_char uj
= use_json(argc
, argv
);
4164 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4167 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 0, argv
, uj
);
4170 DEFUN (show_ip_ospf_instance_neighbor_int
,
4171 show_ip_ospf_instance_neighbor_int_cmd
,
4172 "show ip ospf (1-65535) neighbor IFNAME [json]",
4175 "OSPF information\n"
4183 u_short instance
= 0;
4184 u_char uj
= use_json(argc
, argv
);
4186 VTY_GET_INTEGER("Instance", instance
, argv
[idx_number
]->arg
);
4187 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
4188 || !ospf
->oi_running
)
4191 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 1, argv
, uj
);
4194 static void show_ip_ospf_nbr_nbma_detail_sub(struct vty
*vty
,
4195 struct ospf_interface
*oi
,
4196 struct ospf_nbr_nbma
*nbr_nbma
,
4197 u_char use_json
, json_object
*json
)
4199 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4200 json_object
*json_sub
= NULL
;
4203 json_sub
= json_object_new_object();
4204 else /* Show neighbor ID. */
4205 vty_out(vty
, " Neighbor %s,", "-");
4207 /* Show interface address. */
4209 json_object_string_add(json_sub
, "ifaceAddress",
4210 inet_ntoa(nbr_nbma
->addr
));
4212 vty_out(vty
, " interface address %s%s",
4213 inet_ntoa(nbr_nbma
->addr
), VTY_NEWLINE
);
4217 json_object_string_add(json_sub
, "areaId",
4218 ospf_area_desc_string(oi
->area
));
4219 json_object_string_add(json_sub
, "iface", IF_NAME(oi
));
4221 vty_out(vty
, " In the area %s via interface %s%s",
4222 ospf_area_desc_string(oi
->area
), IF_NAME(oi
),
4225 /* Show neighbor priority and state. */
4227 json_object_int_add(json_sub
, "nbrPriority",
4228 nbr_nbma
->priority
);
4229 json_object_string_add(json_sub
, "nbrState", "down");
4231 vty_out(vty
, " Neighbor priority is %d, State is %s,",
4232 nbr_nbma
->priority
, "Down");
4234 /* Show state changes. */
4236 json_object_int_add(json_sub
, "stateChangeCounter",
4237 nbr_nbma
->state_change
);
4239 vty_out(vty
, " %d state changes%s", nbr_nbma
->state_change
,
4242 /* Show PollInterval */
4244 json_object_int_add(json_sub
, "pollInterval", nbr_nbma
->v_poll
);
4246 vty_out(vty
, " Poll interval %d%s", nbr_nbma
->v_poll
,
4249 /* Show poll-interval timer. */
4252 time_store
= monotime_until(&nbr_nbma
->t_poll
->u
.sands
, NULL
)
4254 json_object_int_add(json_sub
, "pollIntervalTimerDueMsec",
4257 vty_out(vty
, " Poll timer due in %s%s",
4258 ospf_timer_dump(nbr_nbma
->t_poll
, timebuf
,
4262 /* Show poll-interval timer thread. */
4264 if (nbr_nbma
->t_poll
!= NULL
)
4265 json_object_string_add(json_sub
,
4266 "pollIntervalTimerThread", "on");
4268 vty_out(vty
, " Thread Poll Timer %s%s",
4269 nbr_nbma
->t_poll
!= NULL
? "on" : "off", VTY_NEWLINE
);
4272 json_object_object_add(json
, "noNbrId", json_sub
);
4275 static void show_ip_ospf_neighbor_detail_sub(struct vty
*vty
,
4276 struct ospf_interface
*oi
,
4277 struct ospf_neighbor
*nbr
,
4278 u_char use_json
, json_object
*json
)
4280 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4281 json_object
*json_sub
= NULL
;
4284 json_sub
= json_object_new_object();
4286 /* Show neighbor ID. */
4287 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4288 vty_out(vty
, " Neighbor %s,", "-");
4290 vty_out(vty
, " Neighbor %s,",
4291 inet_ntoa(nbr
->router_id
));
4294 /* Show interface address. */
4296 json_object_string_add(json_sub
, "ifaceAddress",
4297 inet_ntoa(nbr
->address
.u
.prefix4
));
4299 vty_out(vty
, " interface address %s%s",
4300 inet_ntoa(nbr
->address
.u
.prefix4
), VTY_NEWLINE
);
4304 json_object_string_add(json_sub
, "areaId",
4305 ospf_area_desc_string(oi
->area
));
4306 json_object_string_add(json_sub
, "ifaceName", oi
->ifp
->name
);
4308 vty_out(vty
, " In the area %s via interface %s%s",
4309 ospf_area_desc_string(oi
->area
), oi
->ifp
->name
,
4312 /* Show neighbor priority and state. */
4314 json_object_int_add(json_sub
, "nbrPriority", nbr
->priority
);
4315 json_object_string_add(
4316 json_sub
, "nbrState",
4317 lookup_msg(ospf_nsm_state_msg
, nbr
->state
, NULL
));
4319 vty_out(vty
, " Neighbor priority is %d, State is %s,",
4321 lookup_msg(ospf_nsm_state_msg
, nbr
->state
, NULL
));
4323 /* Show state changes. */
4325 json_object_int_add(json_sub
, "stateChangeCounter",
4328 vty_out(vty
, " %d state changes%s", nbr
->state_change
,
4331 if (nbr
->ts_last_progress
.tv_sec
|| nbr
->ts_last_progress
.tv_usec
) {
4336 monotime_since(&nbr
->ts_last_progress
, &res
) / 1000LL;
4338 json_object_int_add(json_sub
, "lastPrgrsvChangeMsec",
4342 " Most recent state change statistics:%s",
4344 vty_out(vty
, " Progressive change %s ago%s",
4345 ospf_timeval_dump(&res
, timebuf
,
4351 if (nbr
->ts_last_regress
.tv_sec
|| nbr
->ts_last_regress
.tv_usec
) {
4356 monotime_since(&nbr
->ts_last_regress
, &res
) / 1000LL;
4358 json_object_int_add(json_sub
,
4359 "lastRegressiveChangeMsec",
4361 if (nbr
->last_regress_str
)
4362 json_object_string_add(
4363 json_sub
, "lastRegressiveChangeReason",
4364 nbr
->last_regress_str
);
4367 " Regressive change %s ago, due to %s%s",
4368 ospf_timeval_dump(&res
, timebuf
,
4370 (nbr
->last_regress_str
? nbr
->last_regress_str
4376 /* Show Designated Rotuer ID. */
4378 json_object_string_add(json_sub
, "routerDesignatedId",
4379 inet_ntoa(nbr
->d_router
));
4381 vty_out(vty
, " DR is %s,", inet_ntoa(nbr
->d_router
));
4383 /* Show Backup Designated Rotuer ID. */
4385 json_object_string_add(json_sub
, "routerDesignatedBackupId",
4386 inet_ntoa(nbr
->bd_router
));
4388 vty_out(vty
, " BDR is %s%s", inet_ntoa(nbr
->bd_router
),
4393 json_object_int_add(json_sub
, "optionsCounter", nbr
->options
);
4394 json_object_string_add(json_sub
, "optionsList",
4395 ospf_options_dump(nbr
->options
));
4397 vty_out(vty
, " Options %d %s%s", nbr
->options
,
4398 ospf_options_dump(nbr
->options
), VTY_NEWLINE
);
4400 /* Show Router Dead interval timer. */
4402 if (nbr
->t_inactivity
) {
4404 time_store
= monotime_until(&nbr
->t_inactivity
->u
.sands
,
4407 json_object_int_add(json_sub
,
4408 "routerDeadIntervalTimerDueMsec",
4411 json_object_int_add(
4412 json_sub
, "routerDeadIntervalTimerDueMsec", -1);
4414 vty_out(vty
, " Dead timer due in %s%s",
4415 ospf_timer_dump(nbr
->t_inactivity
, timebuf
,
4419 /* Show Database Summary list. */
4421 json_object_int_add(json_sub
, "databaseSummaryListCounter",
4422 ospf_db_summary_count(nbr
));
4424 vty_out(vty
, " Database Summary List %d%s",
4425 ospf_db_summary_count(nbr
), VTY_NEWLINE
);
4427 /* Show Link State Request list. */
4429 json_object_int_add(json_sub
, "linkStateRequestListCounter",
4430 ospf_ls_request_count(nbr
));
4432 vty_out(vty
, " Link State Request List %ld%s",
4433 ospf_ls_request_count(nbr
), VTY_NEWLINE
);
4435 /* Show Link State Retransmission list. */
4437 json_object_int_add(json_sub
,
4438 "linkStateRetransmissionListCounter",
4439 ospf_ls_retransmit_count(nbr
));
4441 vty_out(vty
, " Link State Retransmission List %ld%s",
4442 ospf_ls_retransmit_count(nbr
), VTY_NEWLINE
);
4444 /* Show inactivity timer thread. */
4446 if (nbr
->t_inactivity
!= NULL
)
4447 json_object_string_add(json_sub
,
4448 "threadInactivityTimer", "on");
4450 vty_out(vty
, " Thread Inactivity Timer %s%s",
4451 nbr
->t_inactivity
!= NULL
? "on" : "off", VTY_NEWLINE
);
4453 /* Show Database Description retransmission thread. */
4455 if (nbr
->t_db_desc
!= NULL
)
4456 json_object_string_add(
4458 "threadDatabaseDescriptionRetransmission",
4462 " Thread Database Description Retransmision %s%s",
4463 nbr
->t_db_desc
!= NULL
? "on" : "off", VTY_NEWLINE
);
4465 /* Show Link State Request Retransmission thread. */
4467 if (nbr
->t_ls_req
!= NULL
)
4468 json_object_string_add(
4470 "threadLinkStateRequestRetransmission", "on");
4473 " Thread Link State Request Retransmission %s%s",
4474 nbr
->t_ls_req
!= NULL
? "on" : "off", VTY_NEWLINE
);
4476 /* Show Link State Update Retransmission thread. */
4478 if (nbr
->t_ls_upd
!= NULL
)
4479 json_object_string_add(
4480 json_sub
, "threadLinkStateUpdateRetransmission",
4484 " Thread Link State Update Retransmission %s%s%s",
4485 nbr
->t_ls_upd
!= NULL
? "on" : "off", VTY_NEWLINE
,
4489 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4490 json_object_object_add(json
, "noNbrId", json_sub
);
4492 json_object_object_add(json
, inet_ntoa(nbr
->router_id
),
4496 ospf_bfd_show_info(vty
, nbr
->bfd_info
, json
, use_json
, 0);
4499 static int show_ip_ospf_neighbor_id_common(struct vty
*vty
, struct ospf
*ospf
,
4501 struct cmd_token
**argv
,
4504 struct listnode
*node
;
4505 struct ospf_neighbor
*nbr
;
4506 struct ospf_interface
*oi
;
4507 struct in_addr router_id
;
4509 json_object
*json
= NULL
;
4512 json
= json_object_new_object();
4514 if (ospf
->instance
) {
4516 json_object_int_add(json
, "ospfInstance",
4519 vty_out(vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
,
4520 ospf
->instance
, VTY_NEWLINE
, VTY_NEWLINE
);
4523 ret
= inet_aton(argv
[arg_base
]->arg
, &router_id
);
4526 vty_out(vty
, "Please specify Neighbor ID by A.B.C.D%s",
4531 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
4532 if ((nbr
= ospf_nbr_lookup_by_routerid(oi
->nbrs
, &router_id
))) {
4533 show_ip_ospf_neighbor_detail_sub(vty
, oi
, nbr
, use_json
,
4539 vty_out(vty
, "%s%s", json_object_to_json_string_ext(
4540 json
, JSON_C_TO_STRING_PRETTY
),
4542 json_object_free(json
);
4544 vty_out(vty
, "%s", VTY_NEWLINE
);
4549 DEFUN (show_ip_ospf_neighbor_id
,
4550 show_ip_ospf_neighbor_id_cmd
,
4551 "show ip ospf neighbor A.B.C.D [json]",
4554 "OSPF information\n"
4560 u_char uj
= use_json(argc
, argv
);
4562 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4565 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 0, argv
, uj
);
4568 DEFUN (show_ip_ospf_instance_neighbor_id
,
4569 show_ip_ospf_instance_neighbor_id_cmd
,
4570 "show ip ospf (1-65535) neighbor A.B.C.D [json]",
4573 "OSPF information\n"
4581 u_short instance
= 0;
4582 u_char uj
= use_json(argc
, argv
);
4584 VTY_GET_INTEGER("Instance", instance
, argv
[idx_number
]->arg
);
4585 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
4586 || !ospf
->oi_running
)
4589 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 1, argv
, uj
);
4592 static int show_ip_ospf_neighbor_detail_common(struct vty
*vty
,
4596 struct ospf_interface
*oi
;
4597 struct listnode
*node
;
4598 json_object
*json
= NULL
;
4601 json
= json_object_new_object();
4603 if (ospf
->instance
) {
4605 json_object_int_add(json
, "ospfInstance",
4608 vty_out(vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
,
4609 ospf
->instance
, VTY_NEWLINE
, VTY_NEWLINE
);
4612 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
4613 struct route_node
*rn
;
4614 struct ospf_neighbor
*nbr
;
4616 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
)) {
4617 if ((nbr
= rn
->info
)) {
4618 if (nbr
!= oi
->nbr_self
) {
4619 if (nbr
->state
!= NSM_Down
) {
4620 show_ip_ospf_neighbor_detail_sub(
4621 vty
, oi
, nbr
, use_json
,
4630 vty_out(vty
, "%s%s", json_object_to_json_string_ext(
4631 json
, JSON_C_TO_STRING_PRETTY
),
4633 json_object_free(json
);
4635 vty_out(vty
, "%s", VTY_NEWLINE
);
4640 DEFUN (show_ip_ospf_neighbor_detail
,
4641 show_ip_ospf_neighbor_detail_cmd
,
4642 "show ip ospf neighbor detail [json]",
4645 "OSPF information\n"
4647 "detail of all neighbors\n"
4651 u_char uj
= use_json(argc
, argv
);
4653 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4656 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4659 DEFUN (show_ip_ospf_instance_neighbor_detail
,
4660 show_ip_ospf_instance_neighbor_detail_cmd
,
4661 "show ip ospf (1-65535) neighbor detail [json]",
4664 "OSPF information\n"
4667 "detail of all neighbors\n"
4672 u_short instance
= 0;
4673 u_char uj
= use_json(argc
, argv
);
4675 VTY_GET_INTEGER("Instance", instance
, argv
[idx_number
]->arg
);
4676 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
4677 || !ospf
->oi_running
)
4680 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4683 static int show_ip_ospf_neighbor_detail_all_common(struct vty
*vty
,
4687 struct listnode
*node
;
4688 struct ospf_interface
*oi
;
4689 json_object
*json
= NULL
;
4692 json
= json_object_new_object();
4694 if (ospf
->instance
) {
4696 json_object_int_add(json
, "ospfInstance",
4699 vty_out(vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
,
4700 ospf
->instance
, VTY_NEWLINE
, VTY_NEWLINE
);
4703 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
4704 struct route_node
*rn
;
4705 struct ospf_neighbor
*nbr
;
4706 struct ospf_nbr_nbma
*nbr_nbma
;
4708 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
))
4709 if ((nbr
= rn
->info
))
4710 if (nbr
!= oi
->nbr_self
)
4711 if (nbr
->state
!= NSM_Down
)
4712 show_ip_ospf_neighbor_detail_sub(
4716 if (oi
->type
== OSPF_IFTYPE_NBMA
) {
4717 struct listnode
*nd
;
4719 for (ALL_LIST_ELEMENTS_RO(oi
->nbr_nbma
, nd
, nbr_nbma
)) {
4720 if (nbr_nbma
->nbr
== NULL
4721 || nbr_nbma
->nbr
->state
== NSM_Down
)
4722 show_ip_ospf_nbr_nbma_detail_sub(
4723 vty
, oi
, nbr_nbma
, use_json
,
4730 vty_out(vty
, "%s%s", json_object_to_json_string_ext(
4731 json
, JSON_C_TO_STRING_PRETTY
),
4733 json_object_free(json
);
4735 vty_out(vty
, "%s", VTY_NEWLINE
);
4741 DEFUN (show_ip_ospf_neighbor_detail_all
,
4742 show_ip_ospf_neighbor_detail_all_cmd
,
4743 "show ip ospf neighbor detail all [json]",
4746 "OSPF information\n"
4748 "detail of all neighbors\n"
4749 "include down status neighbor\n"
4753 u_char uj
= use_json(argc
, argv
);
4755 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4758 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4761 DEFUN (show_ip_ospf_instance_neighbor_detail_all
,
4762 show_ip_ospf_instance_neighbor_detail_all_cmd
,
4763 "show ip ospf (1-65535) neighbor detail all [json]",
4766 "OSPF information\n"
4769 "detail of all neighbors\n"
4770 "include down status neighbor\n"
4775 u_short instance
= 0;
4776 u_char uj
= use_json(argc
, argv
);
4778 VTY_GET_INTEGER("Instance", instance
, argv
[idx_number
]->arg
);
4779 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
4780 || !ospf
->oi_running
)
4783 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4786 static int show_ip_ospf_neighbor_int_detail_common(struct vty
*vty
,
4789 struct cmd_token
**argv
,
4792 struct ospf_interface
*oi
;
4793 struct interface
*ifp
;
4794 struct route_node
*rn
, *nrn
;
4795 struct ospf_neighbor
*nbr
;
4796 json_object
*json
= NULL
;
4799 json
= json_object_new_object();
4801 if (ospf
->instance
) {
4803 json_object_int_add(json
, "ospfInstance",
4806 vty_out(vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
,
4807 ospf
->instance
, VTY_NEWLINE
, VTY_NEWLINE
);
4810 ifp
= if_lookup_by_name(argv
[arg_base
]->arg
, VRF_DEFAULT
);
4813 vty_out(vty
, "No such interface.%s", VTY_NEWLINE
);
4817 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
4818 if ((oi
= rn
->info
)) {
4819 for (nrn
= route_top(oi
->nbrs
); nrn
;
4820 nrn
= route_next(nrn
)) {
4821 if ((nbr
= nrn
->info
)) {
4822 if (nbr
!= oi
->nbr_self
) {
4823 if (nbr
->state
!= NSM_Down
)
4824 show_ip_ospf_neighbor_detail_sub(
4834 vty_out(vty
, "%s%s", json_object_to_json_string_ext(
4835 json
, JSON_C_TO_STRING_PRETTY
),
4837 json_object_free(json
);
4839 vty_out(vty
, "%s", VTY_NEWLINE
);
4844 DEFUN (show_ip_ospf_neighbor_int_detail
,
4845 show_ip_ospf_neighbor_int_detail_cmd
,
4846 "show ip ospf neighbor IFNAME detail [json]",
4849 "OSPF information\n"
4852 "detail of all neighbors\n"
4856 u_char uj
= use_json(argc
, argv
);
4858 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4861 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 0, argv
, uj
);
4864 DEFUN (show_ip_ospf_instance_neighbor_int_detail
,
4865 show_ip_ospf_instance_neighbor_int_detail_cmd
,
4866 "show ip ospf (1-65535) neighbor IFNAME detail [json]",
4869 "OSPF information\n"
4873 "detail of all neighbors\n"
4878 u_short instance
= 0;
4879 u_char uj
= use_json(argc
, argv
);
4881 VTY_GET_INTEGER("Instance", instance
, argv
[idx_number
]->arg
);
4882 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
4883 || !ospf
->oi_running
)
4886 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 1, argv
, uj
);
4889 /* Show functions */
4890 static int show_lsa_summary(struct vty
*vty
, struct ospf_lsa
*lsa
, int self
)
4892 struct router_lsa
*rl
;
4893 struct summary_lsa
*sl
;
4894 struct as_external_lsa
*asel
;
4895 struct prefix_ipv4 p
;
4898 /* If self option is set, check LSA self flag. */
4899 if (self
== 0 || IS_LSA_SELF(lsa
)) {
4900 /* LSA common part show. */
4901 vty_out(vty
, "%-15s ", inet_ntoa(lsa
->data
->id
));
4902 vty_out(vty
, "%-15s %4d 0x%08lx 0x%04x",
4903 inet_ntoa(lsa
->data
->adv_router
), LS_AGE(lsa
),
4904 (u_long
)ntohl(lsa
->data
->ls_seqnum
),
4905 ntohs(lsa
->data
->checksum
));
4906 /* LSA specific part show. */
4907 switch (lsa
->data
->type
) {
4908 case OSPF_ROUTER_LSA
:
4909 rl
= (struct router_lsa
*)lsa
->data
;
4910 vty_out(vty
, " %-d", ntohs(rl
->links
));
4912 case OSPF_SUMMARY_LSA
:
4913 sl
= (struct summary_lsa
*)lsa
->data
;
4916 p
.prefix
= sl
->header
.id
;
4917 p
.prefixlen
= ip_masklen(sl
->mask
);
4918 apply_mask_ipv4(&p
);
4920 vty_out(vty
, " %s/%d", inet_ntoa(p
.prefix
),
4923 case OSPF_AS_EXTERNAL_LSA
:
4924 case OSPF_AS_NSSA_LSA
:
4925 asel
= (struct as_external_lsa
*)lsa
->data
;
4928 p
.prefix
= asel
->header
.id
;
4929 p
.prefixlen
= ip_masklen(asel
->mask
);
4930 apply_mask_ipv4(&p
);
4932 vty_out(vty
, " %s %s/%d [0x%lx]",
4933 IS_EXTERNAL_METRIC(asel
->e
[0].tos
)
4936 inet_ntoa(p
.prefix
), p
.prefixlen
,
4937 (u_long
)ntohl(asel
->e
[0].route_tag
));
4939 case OSPF_NETWORK_LSA
:
4940 case OSPF_ASBR_SUMMARY_LSA
:
4941 case OSPF_OPAQUE_LINK_LSA
:
4942 case OSPF_OPAQUE_AREA_LSA
:
4943 case OSPF_OPAQUE_AS_LSA
:
4947 vty_out(vty
, VTY_NEWLINE
);
4953 static const char *show_database_desc
[] = {
4955 "Router Link States",
4957 "Summary Link States",
4958 "ASBR-Summary Link States",
4959 "AS External Link States",
4960 "Group Membership LSA",
4961 "NSSA-external Link States",
4963 "Link-Local Opaque-LSA",
4964 "Area-Local Opaque-LSA",
4965 "AS-external Opaque-LSA",
4968 static const char *show_database_header
[] = {
4970 "Link ID ADV Router Age Seq# CkSum Link count",
4971 "Link ID ADV Router Age Seq# CkSum",
4972 "Link ID ADV Router Age Seq# CkSum Route",
4973 "Link ID ADV Router Age Seq# CkSum",
4974 "Link ID ADV Router Age Seq# CkSum Route",
4975 " --- header for Group Member ----",
4976 "Link ID ADV Router Age Seq# CkSum Route",
4978 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4979 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4980 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4983 static void show_ip_ospf_database_header(struct vty
*vty
, struct ospf_lsa
*lsa
)
4985 struct router_lsa
*rlsa
= (struct router_lsa
*)lsa
->data
;
4987 vty_out(vty
, " LS age: %d%s", LS_AGE(lsa
), VTY_NEWLINE
);
4988 vty_out(vty
, " Options: 0x%-2x : %s%s", lsa
->data
->options
,
4989 ospf_options_dump(lsa
->data
->options
), VTY_NEWLINE
);
4990 vty_out(vty
, " LS Flags: 0x%-2x %s%s", lsa
->flags
,
4991 ((lsa
->flags
& OSPF_LSA_LOCAL_XLT
) ? "(Translated from Type-7)"
4995 if (lsa
->data
->type
== OSPF_ROUTER_LSA
) {
4996 vty_out(vty
, " Flags: 0x%x", rlsa
->flags
);
4999 vty_out(vty
, " :%s%s%s%s",
5000 IS_ROUTER_LSA_BORDER(rlsa
) ? " ABR" : "",
5001 IS_ROUTER_LSA_EXTERNAL(rlsa
) ? " ASBR" : "",
5002 IS_ROUTER_LSA_VIRTUAL(rlsa
) ? " VL-endpoint"
5004 IS_ROUTER_LSA_SHORTCUT(rlsa
) ? " Shortcut"
5007 vty_out(vty
, "%s", VTY_NEWLINE
);
5009 vty_out(vty
, " LS Type: %s%s",
5010 lookup_msg(ospf_lsa_type_msg
, lsa
->data
->type
, NULL
),
5012 vty_out(vty
, " Link State ID: %s %s%s", inet_ntoa(lsa
->data
->id
),
5013 lookup_msg(ospf_link_state_id_type_msg
, lsa
->data
->type
, NULL
),
5015 vty_out(vty
, " Advertising Router: %s%s",
5016 inet_ntoa(lsa
->data
->adv_router
), VTY_NEWLINE
);
5017 vty_out(vty
, " LS Seq Number: %08lx%s",
5018 (u_long
)ntohl(lsa
->data
->ls_seqnum
), VTY_NEWLINE
);
5019 vty_out(vty
, " Checksum: 0x%04x%s", ntohs(lsa
->data
->checksum
),
5021 vty_out(vty
, " Length: %d%s", ntohs(lsa
->data
->length
), VTY_NEWLINE
);
5024 const char *link_type_desc
[] = {
5026 "another Router (point-to-point)",
5027 "a Transit Network",
5032 const char *link_id_desc
[] = {
5033 "(null)", "Neighboring Router ID", "Designated Router address",
5034 "Net", "Neighboring Router ID",
5037 const char *link_data_desc
[] = {
5038 "(null)", "Router Interface address", "Router Interface address",
5039 "Network Mask", "Router Interface address",
5042 /* Show router-LSA each Link information. */
5043 static void show_ip_ospf_database_router_links(struct vty
*vty
,
5044 struct router_lsa
*rl
)
5049 len
= ntohs(rl
->header
.length
) - 4;
5050 for (i
= 0; i
< ntohs(rl
->links
) && len
> 0; len
-= 12, i
++) {
5051 type
= rl
->link
[i
].type
;
5053 vty_out(vty
, " Link connected to: %s%s",
5054 link_type_desc
[type
], VTY_NEWLINE
);
5055 vty_out(vty
, " (Link ID) %s: %s%s", link_id_desc
[type
],
5056 inet_ntoa(rl
->link
[i
].link_id
), VTY_NEWLINE
);
5057 vty_out(vty
, " (Link Data) %s: %s%s", link_data_desc
[type
],
5058 inet_ntoa(rl
->link
[i
].link_data
), VTY_NEWLINE
);
5059 vty_out(vty
, " Number of TOS metrics: 0%s", VTY_NEWLINE
);
5060 vty_out(vty
, " TOS 0 Metric: %d%s",
5061 ntohs(rl
->link
[i
].metric
), VTY_NEWLINE
);
5062 vty_out(vty
, "%s", VTY_NEWLINE
);
5066 /* Show router-LSA detail information. */
5067 static int show_router_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5070 struct router_lsa
*rl
= (struct router_lsa
*)lsa
->data
;
5072 show_ip_ospf_database_header(vty
, lsa
);
5074 vty_out(vty
, " Number of Links: %d%s%s", ntohs(rl
->links
),
5075 VTY_NEWLINE
, VTY_NEWLINE
);
5077 show_ip_ospf_database_router_links(vty
, rl
);
5078 vty_out(vty
, "%s", VTY_NEWLINE
);
5084 /* Show network-LSA detail information. */
5085 static int show_network_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5090 struct network_lsa
*nl
= (struct network_lsa
*)lsa
->data
;
5092 show_ip_ospf_database_header(vty
, lsa
);
5094 vty_out(vty
, " Network Mask: /%d%s", ip_masklen(nl
->mask
),
5097 length
= ntohs(lsa
->data
->length
) - OSPF_LSA_HEADER_SIZE
- 4;
5099 for (i
= 0; length
> 0; i
++, length
-= 4)
5100 vty_out(vty
, " Attached Router: %s%s",
5101 inet_ntoa(nl
->routers
[i
]), VTY_NEWLINE
);
5103 vty_out(vty
, "%s", VTY_NEWLINE
);
5109 /* Show summary-LSA detail information. */
5110 static int show_summary_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5113 struct summary_lsa
*sl
= (struct summary_lsa
*)lsa
->data
;
5115 show_ip_ospf_database_header(vty
, lsa
);
5117 vty_out(vty
, " Network Mask: /%d%s", ip_masklen(sl
->mask
),
5119 vty_out(vty
, " TOS: 0 Metric: %d%s",
5120 GET_METRIC(sl
->metric
), VTY_NEWLINE
);
5121 vty_out(vty
, "%s", VTY_NEWLINE
);
5127 /* Show summary-ASBR-LSA detail information. */
5128 static int show_summary_asbr_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5131 struct summary_lsa
*sl
= (struct summary_lsa
*)lsa
->data
;
5133 show_ip_ospf_database_header(vty
, lsa
);
5135 vty_out(vty
, " Network Mask: /%d%s", ip_masklen(sl
->mask
),
5137 vty_out(vty
, " TOS: 0 Metric: %d%s",
5138 GET_METRIC(sl
->metric
), VTY_NEWLINE
);
5139 vty_out(vty
, "%s", VTY_NEWLINE
);
5145 /* Show AS-external-LSA detail information. */
5146 static int show_as_external_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5149 struct as_external_lsa
*al
=
5150 (struct as_external_lsa
*)lsa
->data
;
5152 show_ip_ospf_database_header(vty
, lsa
);
5154 vty_out(vty
, " Network Mask: /%d%s", ip_masklen(al
->mask
),
5156 vty_out(vty
, " Metric Type: %s%s",
5157 IS_EXTERNAL_METRIC(al
->e
[0].tos
)
5158 ? "2 (Larger than any link state path)"
5161 vty_out(vty
, " TOS: 0%s", VTY_NEWLINE
);
5162 vty_out(vty
, " Metric: %d%s",
5163 GET_METRIC(al
->e
[0].metric
), VTY_NEWLINE
);
5164 vty_out(vty
, " Forward Address: %s%s",
5165 inet_ntoa(al
->e
[0].fwd_addr
), VTY_NEWLINE
);
5168 " External Route Tag: %" ROUTE_TAG_PRI
"%s%s",
5169 (route_tag_t
)ntohl(al
->e
[0].route_tag
), VTY_NEWLINE
,
5177 show_as_external_lsa_stdvty (struct ospf_lsa
*lsa
)
5179 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5181 /* show_ip_ospf_database_header (vty, lsa); */
5183 zlog_debug( " Network Mask: /%d%s",
5184 ip_masklen (al
->mask
), "\n");
5185 zlog_debug( " Metric Type: %s%s",
5186 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5187 "2 (Larger than any link state path)" : "1", "\n");
5188 zlog_debug( " TOS: 0%s", "\n");
5189 zlog_debug( " Metric: %d%s",
5190 GET_METRIC (al
->e
[0].metric
), "\n");
5191 zlog_debug( " Forward Address: %s%s",
5192 inet_ntoa (al
->e
[0].fwd_addr
), "\n");
5194 zlog_debug( " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5195 (route_tag_t
)ntohl (al
->e
[0].route_tag
), "\n", "\n");
5200 /* Show AS-NSSA-LSA detail information. */
5201 static int show_as_nssa_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5204 struct as_external_lsa
*al
=
5205 (struct as_external_lsa
*)lsa
->data
;
5207 show_ip_ospf_database_header(vty
, lsa
);
5209 vty_out(vty
, " Network Mask: /%d%s", ip_masklen(al
->mask
),
5211 vty_out(vty
, " Metric Type: %s%s",
5212 IS_EXTERNAL_METRIC(al
->e
[0].tos
)
5213 ? "2 (Larger than any link state path)"
5216 vty_out(vty
, " TOS: 0%s", VTY_NEWLINE
);
5217 vty_out(vty
, " Metric: %d%s",
5218 GET_METRIC(al
->e
[0].metric
), VTY_NEWLINE
);
5219 vty_out(vty
, " NSSA: Forward Address: %s%s",
5220 inet_ntoa(al
->e
[0].fwd_addr
), VTY_NEWLINE
);
5223 " External Route Tag: %" ROUTE_TAG_PRI
"%s%s",
5224 (route_tag_t
)ntohl(al
->e
[0].route_tag
), VTY_NEWLINE
,
5231 static int show_func_dummy(struct vty
*vty
, struct ospf_lsa
*lsa
)
5236 static int show_opaque_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5239 show_ip_ospf_database_header(vty
, lsa
);
5240 show_opaque_info_detail(vty
, lsa
);
5242 vty_out(vty
, "%s", VTY_NEWLINE
);
5247 int (*show_function
[])(struct vty
*, struct ospf_lsa
*) = {
5249 show_router_lsa_detail
,
5250 show_network_lsa_detail
,
5251 show_summary_lsa_detail
,
5252 show_summary_asbr_lsa_detail
,
5253 show_as_external_lsa_detail
,
5255 show_as_nssa_lsa_detail
, /* almost same as external */
5257 show_opaque_lsa_detail
,
5258 show_opaque_lsa_detail
,
5259 show_opaque_lsa_detail
,
5262 static void show_lsa_prefix_set(struct vty
*vty
, struct prefix_ls
*lp
,
5263 struct in_addr
*id
, struct in_addr
*adv_router
)
5265 memset(lp
, 0, sizeof(struct prefix_ls
));
5269 else if (adv_router
== NULL
) {
5275 lp
->adv_router
= *adv_router
;
5279 static void show_lsa_detail_proc(struct vty
*vty
, struct route_table
*rt
,
5280 struct in_addr
*id
, struct in_addr
*adv_router
)
5282 struct prefix_ls lp
;
5283 struct route_node
*rn
, *start
;
5284 struct ospf_lsa
*lsa
;
5286 show_lsa_prefix_set(vty
, &lp
, id
, adv_router
);
5287 start
= route_node_get(rt
, (struct prefix
*)&lp
);
5289 route_lock_node(start
);
5290 for (rn
= start
; rn
; rn
= route_next_until(rn
, start
))
5291 if ((lsa
= rn
->info
)) {
5292 if (show_function
[lsa
->data
->type
] != NULL
)
5293 show_function
[lsa
->data
->type
](vty
,
5296 route_unlock_node(start
);
5300 /* Show detail LSA information
5301 -- if id is NULL then show all LSAs. */
5302 static void show_lsa_detail(struct vty
*vty
, struct ospf
*ospf
, int type
,
5303 struct in_addr
*id
, struct in_addr
*adv_router
)
5305 struct listnode
*node
;
5306 struct ospf_area
*area
;
5309 case OSPF_AS_EXTERNAL_LSA
:
5310 case OSPF_OPAQUE_AS_LSA
:
5311 vty_out(vty
, " %s %s%s",
5312 show_database_desc
[type
], VTY_NEWLINE
, VTY_NEWLINE
);
5313 show_lsa_detail_proc(vty
, AS_LSDB(ospf
, type
), id
, adv_router
);
5316 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
5317 vty_out(vty
, "%s %s (Area %s)%s%s",
5318 VTY_NEWLINE
, show_database_desc
[type
],
5319 ospf_area_desc_string(area
), VTY_NEWLINE
,
5321 show_lsa_detail_proc(vty
, AREA_LSDB(area
, type
), id
,
5328 static void show_lsa_detail_adv_router_proc(struct vty
*vty
,
5329 struct route_table
*rt
,
5330 struct in_addr
*adv_router
)
5332 struct route_node
*rn
;
5333 struct ospf_lsa
*lsa
;
5335 for (rn
= route_top(rt
); rn
; rn
= route_next(rn
))
5336 if ((lsa
= rn
->info
))
5337 if (IPV4_ADDR_SAME(adv_router
,
5338 &lsa
->data
->adv_router
)) {
5339 if (CHECK_FLAG(lsa
->flags
, OSPF_LSA_LOCAL_XLT
))
5341 if (show_function
[lsa
->data
->type
] != NULL
)
5342 show_function
[lsa
->data
->type
](vty
,
5347 /* Show detail LSA information. */
5348 static void show_lsa_detail_adv_router(struct vty
*vty
, struct ospf
*ospf
,
5349 int type
, struct in_addr
*adv_router
)
5351 struct listnode
*node
;
5352 struct ospf_area
*area
;
5355 case OSPF_AS_EXTERNAL_LSA
:
5356 case OSPF_OPAQUE_AS_LSA
:
5357 vty_out(vty
, " %s %s%s",
5358 show_database_desc
[type
], VTY_NEWLINE
, VTY_NEWLINE
);
5359 show_lsa_detail_adv_router_proc(vty
, AS_LSDB(ospf
, type
),
5363 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
5364 vty_out(vty
, "%s %s (Area %s)%s%s",
5365 VTY_NEWLINE
, show_database_desc
[type
],
5366 ospf_area_desc_string(area
), VTY_NEWLINE
,
5368 show_lsa_detail_adv_router_proc(
5369 vty
, AREA_LSDB(area
, type
), adv_router
);
5375 static void show_ip_ospf_database_summary(struct vty
*vty
, struct ospf
*ospf
,
5378 struct ospf_lsa
*lsa
;
5379 struct route_node
*rn
;
5380 struct ospf_area
*area
;
5381 struct listnode
*node
;
5384 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
5385 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++) {
5387 case OSPF_AS_EXTERNAL_LSA
:
5388 case OSPF_OPAQUE_AS_LSA
:
5393 if (ospf_lsdb_count_self(area
->lsdb
, type
) > 0
5395 && ospf_lsdb_count(area
->lsdb
, type
) > 0)) {
5396 vty_out(vty
, " %s (Area %s)%s%s",
5397 show_database_desc
[type
],
5398 ospf_area_desc_string(area
),
5399 VTY_NEWLINE
, VTY_NEWLINE
);
5400 vty_out(vty
, "%s%s", show_database_header
[type
],
5403 LSDB_LOOP(AREA_LSDB(area
, type
), rn
, lsa
)
5404 show_lsa_summary(vty
, lsa
, self
);
5406 vty_out(vty
, "%s", VTY_NEWLINE
);
5411 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++) {
5413 case OSPF_AS_EXTERNAL_LSA
:
5414 case OSPF_OPAQUE_AS_LSA
:
5419 if (ospf_lsdb_count_self(ospf
->lsdb
, type
)
5420 || (!self
&& ospf_lsdb_count(ospf
->lsdb
, type
))) {
5421 vty_out(vty
, " %s%s%s",
5422 show_database_desc
[type
], VTY_NEWLINE
,
5424 vty_out(vty
, "%s%s", show_database_header
[type
],
5427 LSDB_LOOP(AS_LSDB(ospf
, type
), rn
, lsa
)
5428 show_lsa_summary(vty
, lsa
, self
);
5430 vty_out(vty
, "%s", VTY_NEWLINE
);
5434 vty_out(vty
, "%s", VTY_NEWLINE
);
5437 static void show_ip_ospf_database_maxage(struct vty
*vty
, struct ospf
*ospf
)
5439 struct route_node
*rn
;
5441 vty_out(vty
, "%s MaxAge Link States:%s%s", VTY_NEWLINE
,
5442 VTY_NEWLINE
, VTY_NEWLINE
);
5444 for (rn
= route_top(ospf
->maxage_lsa
); rn
; rn
= route_next(rn
)) {
5445 struct ospf_lsa
*lsa
;
5447 if ((lsa
= rn
->info
) != NULL
) {
5448 vty_out(vty
, "Link type: %d%s", lsa
->data
->type
,
5450 vty_out(vty
, "Link State ID: %s%s",
5451 inet_ntoa(lsa
->data
->id
), VTY_NEWLINE
);
5452 vty_out(vty
, "Advertising Router: %s%s",
5453 inet_ntoa(lsa
->data
->adv_router
), VTY_NEWLINE
);
5454 vty_out(vty
, "LSA lock count: %d%s", lsa
->lock
,
5456 vty_out(vty
, "%s", VTY_NEWLINE
);
5461 #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
5462 #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
5464 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
5465 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
5466 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
5467 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
5469 #define OSPF_LSA_TYPES_DESC \
5470 "ASBR summary link states\n" \
5471 "External link states\n" \
5472 "Network link states\n" \
5473 "Router link states\n" \
5474 "Network summary link states\n" OSPF_LSA_TYPE_NSSA_DESC \
5475 OSPF_LSA_TYPE_OPAQUE_LINK_DESC OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
5476 OSPF_LSA_TYPE_OPAQUE_AS_DESC
5478 static int show_ip_ospf_database_common(struct vty
*vty
, struct ospf
*ospf
,
5479 int arg_base
, int argc
,
5480 struct cmd_token
**argv
)
5484 struct in_addr id
, adv_router
;
5487 vty_out(vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
,
5488 ospf
->instance
, VTY_NEWLINE
);
5490 vty_out(vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5491 inet_ntoa(ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5494 if (argc
== arg_base
+ 4) {
5495 show_ip_ospf_database_summary(vty
, ospf
, 0);
5499 /* Set database type to show. */
5500 if (strncmp(argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5501 type
= OSPF_ROUTER_LSA
;
5502 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5503 type
= OSPF_NETWORK_LSA
;
5504 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5505 type
= OSPF_AS_NSSA_LSA
;
5506 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "su", 2) == 0)
5507 type
= OSPF_SUMMARY_LSA
;
5508 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5509 type
= OSPF_ASBR_SUMMARY_LSA
;
5510 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5511 type
= OSPF_AS_EXTERNAL_LSA
;
5512 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "se", 2) == 0) {
5513 show_ip_ospf_database_summary(vty
, ospf
, 1);
5515 } else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "m", 1) == 0) {
5516 show_ip_ospf_database_maxage(vty
, ospf
);
5518 } else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5519 type
= OSPF_OPAQUE_LINK_LSA
;
5520 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5521 type
= OSPF_OPAQUE_AREA_LSA
;
5522 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5523 type
= OSPF_OPAQUE_AS_LSA
;
5527 /* `show ip ospf database LSA'. */
5528 if (argc
== arg_base
+ 5)
5529 show_lsa_detail(vty
, ospf
, type
, NULL
, NULL
);
5530 else if (argc
>= arg_base
+ 6) {
5531 ret
= inet_aton(argv
[arg_base
+ 5]->arg
, &id
);
5535 /* `show ip ospf database LSA ID'. */
5536 if (argc
== arg_base
+ 6)
5537 show_lsa_detail(vty
, ospf
, type
, &id
, NULL
);
5538 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
5539 else if (argc
== arg_base
+ 7) {
5540 if (strncmp(argv
[arg_base
+ 6]->text
, "s", 1) == 0)
5541 adv_router
= ospf
->router_id
;
5543 ret
= inet_aton(argv
[arg_base
+ 7]->arg
,
5548 show_lsa_detail(vty
, ospf
, type
, &id
, &adv_router
);
5555 DEFUN (show_ip_ospf_database_max
,
5556 show_ip_ospf_database_max_cmd
,
5557 "show ip ospf database <max-age|self-originate>",
5560 "OSPF information\n"
5561 "Database summary\n"
5562 "LSAs in MaxAge list\n"
5563 "Self-originated link states\n")
5567 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5570 return (show_ip_ospf_database_common(vty
, ospf
, 0, argc
, argv
));
5573 DEFUN (show_ip_ospf_instance_database
,
5574 show_ip_ospf_instance_database_cmd
,
5575 "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>]]]",
5578 "OSPF information\n"
5580 "Database summary\n"
5582 "Link State ID (as an IP address)\n"
5583 "Self-originated link states\n"
5584 "Advertising Router link states\n"
5585 "Advertising Router (as an IP address)\n")
5588 u_short instance
= 0;
5591 if (argv_find(argv
, argc
, "(1-65535)", &idx
)) {
5592 VTY_GET_INTEGER("Instance", instance
, argv
[idx
]->arg
);
5593 ospf
= ospf_lookup_instance(instance
);
5595 ospf
= ospf_lookup();
5598 if (!ospf
|| !ospf
->oi_running
)
5601 return (show_ip_ospf_database_common(vty
, ospf
, idx
? 1 : 0, argc
,
5605 DEFUN (show_ip_ospf_instance_database_max
,
5606 show_ip_ospf_instance_database_max_cmd
,
5607 "show ip ospf (1-65535) database <max-age|self-originate>",
5610 "OSPF information\n"
5612 "Database summary\n"
5613 "LSAs in MaxAge list\n"
5614 "Self-originated link states\n")
5618 u_short instance
= 0;
5620 VTY_GET_INTEGER("Instance", instance
, argv
[idx_number
]->arg
);
5622 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
5623 || !ospf
->oi_running
)
5626 return (show_ip_ospf_database_common(vty
, ospf
, 1, argc
, argv
));
5630 static int show_ip_ospf_database_type_adv_router_common(struct vty
*vty
,
5632 int arg_base
, int argc
,
5633 struct cmd_token
**argv
)
5637 struct in_addr adv_router
;
5640 vty_out(vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
,
5641 ospf
->instance
, VTY_NEWLINE
);
5643 vty_out(vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5644 inet_ntoa(ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5646 if (argc
!= arg_base
+ 7)
5649 /* Set database type to show. */
5650 if (strncmp(argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5651 type
= OSPF_ROUTER_LSA
;
5652 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5653 type
= OSPF_NETWORK_LSA
;
5654 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5655 type
= OSPF_AS_NSSA_LSA
;
5656 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "s", 1) == 0)
5657 type
= OSPF_SUMMARY_LSA
;
5658 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5659 type
= OSPF_ASBR_SUMMARY_LSA
;
5660 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5661 type
= OSPF_AS_EXTERNAL_LSA
;
5662 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5663 type
= OSPF_OPAQUE_LINK_LSA
;
5664 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5665 type
= OSPF_OPAQUE_AREA_LSA
;
5666 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5667 type
= OSPF_OPAQUE_AS_LSA
;
5671 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
5672 if (strncmp(argv
[arg_base
+ 5]->text
, "s", 1) == 0)
5673 adv_router
= ospf
->router_id
;
5675 ret
= inet_aton(argv
[arg_base
+ 6]->arg
, &adv_router
);
5680 show_lsa_detail_adv_router(vty
, ospf
, type
, &adv_router
);
5685 DEFUN (show_ip_ospf_database_type_adv_router
,
5686 show_ip_ospf_database_type_adv_router_cmd
,
5687 "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>",
5690 "OSPF information\n"
5691 "Database summary\n"
5693 "Advertising Router link states\n"
5694 "Advertising Router (as an IP address)\n"
5695 "Self-originated link states\n")
5699 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5702 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 0, argc
,
5706 DEFUN (show_ip_ospf_instance_database_type_adv_router
,
5707 show_ip_ospf_instance_database_type_adv_router_cmd
,
5708 "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>",
5711 "OSPF information\n"
5713 "Database summary\n"
5715 "Advertising Router link states\n"
5716 "Advertising Router (as an IP address)\n"
5717 "Self-originated link states\n")
5721 u_short instance
= 0;
5723 VTY_GET_INTEGER("Instance", instance
, argv
[idx_number
]->arg
);
5725 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
5726 || !ospf
->oi_running
)
5729 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 1, argc
,
5733 DEFUN (ip_ospf_authentication_args
,
5734 ip_ospf_authentication_args_addr_cmd
,
5735 "ip ospf authentication <null|message-digest> [A.B.C.D]",
5737 "OSPF interface commands\n"
5738 "Enable authentication on this interface\n"
5739 "Use null authentication\n"
5740 "Use message-digest authentication\n"
5741 "Address of interface\n")
5743 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5744 int idx_encryption
= 3;
5746 struct in_addr addr
;
5748 struct ospf_if_params
*params
;
5750 params
= IF_DEF_PARAMS(ifp
);
5753 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5756 "Please specify interface address by A.B.C.D%s",
5761 params
= ospf_get_if_params(ifp
, addr
);
5762 ospf_if_update_params(ifp
, addr
);
5765 /* Handle null authentication */
5766 if (argv
[idx_encryption
]->arg
[0] == 'n') {
5767 SET_IF_PARAM(params
, auth_type
);
5768 params
->auth_type
= OSPF_AUTH_NULL
;
5772 /* Handle message-digest authentication */
5773 if (argv
[idx_encryption
]->arg
[0] == 'm') {
5774 SET_IF_PARAM(params
, auth_type
);
5775 params
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5779 vty_out(vty
, "You shouldn't get here!%s", VTY_NEWLINE
);
5783 DEFUN (ip_ospf_authentication
,
5784 ip_ospf_authentication_addr_cmd
,
5785 "ip ospf authentication [A.B.C.D]",
5787 "OSPF interface commands\n"
5788 "Enable authentication on this interface\n"
5789 "Address of interface")
5791 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5793 struct in_addr addr
;
5795 struct ospf_if_params
*params
;
5797 params
= IF_DEF_PARAMS(ifp
);
5800 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5803 "Please specify interface address by A.B.C.D%s",
5808 params
= ospf_get_if_params(ifp
, addr
);
5809 ospf_if_update_params(ifp
, addr
);
5812 SET_IF_PARAM(params
, auth_type
);
5813 params
->auth_type
= OSPF_AUTH_SIMPLE
;
5818 DEFUN (no_ip_ospf_authentication_args
,
5819 no_ip_ospf_authentication_args_addr_cmd
,
5820 "no ip ospf authentication <null|message-digest> [A.B.C.D]",
5823 "OSPF interface commands\n"
5824 "Enable authentication on this interface\n"
5825 "Use null authentication\n"
5826 "Use message-digest authentication\n"
5827 "Address of interface")
5829 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5830 int idx_encryption
= 4;
5832 struct in_addr addr
;
5834 struct ospf_if_params
*params
;
5835 struct route_node
*rn
;
5838 params
= IF_DEF_PARAMS(ifp
);
5841 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5844 "Please specify interface address by A.B.C.D%s",
5849 params
= ospf_lookup_if_params(ifp
, addr
);
5850 if (params
== NULL
) {
5851 vty_out(vty
, "Ip Address specified is unknown%s",
5855 params
->auth_type
= OSPF_AUTH_NOTSET
;
5856 UNSET_IF_PARAM(params
, auth_type
);
5857 if (params
!= IF_DEF_PARAMS(ifp
)) {
5858 ospf_free_if_params(ifp
, addr
);
5859 ospf_if_update_params(ifp
, addr
);
5862 if (argv
[idx_encryption
]->arg
[0] == 'n') {
5863 auth_type
= OSPF_AUTH_NULL
;
5864 } else if (argv
[idx_encryption
]->arg
[0] == 'm') {
5865 auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5867 vty_out(vty
, "Unexpected input encountered%s",
5872 * Here we have a case where the user has entered
5873 * 'no ip ospf authentication (null | message_digest )'
5874 * we need to find if we have any ip addresses underneath it
5876 * correspond to the associated type.
5878 if (params
->auth_type
== auth_type
) {
5879 params
->auth_type
= OSPF_AUTH_NOTSET
;
5880 UNSET_IF_PARAM(params
, auth_type
);
5883 for (rn
= route_top(IF_OIFS_PARAMS(ifp
)); rn
;
5884 rn
= route_next(rn
)) {
5885 if ((params
= rn
->info
)) {
5886 if (params
->auth_type
== auth_type
) {
5887 params
->auth_type
= OSPF_AUTH_NOTSET
;
5888 UNSET_IF_PARAM(params
, auth_type
);
5889 if (params
!= IF_DEF_PARAMS(ifp
)) {
5890 ospf_free_if_params(
5891 ifp
, rn
->p
.u
.prefix4
);
5892 ospf_if_update_params(
5893 ifp
, rn
->p
.u
.prefix4
);
5903 DEFUN (no_ip_ospf_authentication
,
5904 no_ip_ospf_authentication_addr_cmd
,
5905 "no ip ospf authentication [A.B.C.D]",
5908 "OSPF interface commands\n"
5909 "Enable authentication on this interface\n"
5910 "Address of interface")
5912 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5914 struct in_addr addr
;
5916 struct ospf_if_params
*params
;
5917 struct route_node
*rn
;
5919 params
= IF_DEF_PARAMS(ifp
);
5922 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5925 "Please specify interface address by A.B.C.D%s",
5930 params
= ospf_lookup_if_params(ifp
, addr
);
5931 if (params
== NULL
) {
5932 vty_out(vty
, "Ip Address specified is unknown%s",
5937 params
->auth_type
= OSPF_AUTH_NOTSET
;
5938 UNSET_IF_PARAM(params
, auth_type
);
5939 if (params
!= IF_DEF_PARAMS(ifp
)) {
5940 ospf_free_if_params(ifp
, addr
);
5941 ospf_if_update_params(ifp
, addr
);
5945 * When a user enters 'no ip ospf authentication'
5946 * We should remove all authentication types from
5949 if ((params
->auth_type
== OSPF_AUTH_NULL
)
5950 || (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
5951 || (params
->auth_type
== OSPF_AUTH_SIMPLE
)) {
5952 params
->auth_type
= OSPF_AUTH_NOTSET
;
5953 UNSET_IF_PARAM(params
, auth_type
);
5956 for (rn
= route_top(IF_OIFS_PARAMS(ifp
)); rn
;
5957 rn
= route_next(rn
)) {
5958 if ((params
= rn
->info
)) {
5960 if ((params
->auth_type
== OSPF_AUTH_NULL
)
5961 || (params
->auth_type
5962 == OSPF_AUTH_CRYPTOGRAPHIC
)
5963 || (params
->auth_type
5964 == OSPF_AUTH_SIMPLE
)) {
5965 params
->auth_type
= OSPF_AUTH_NOTSET
;
5966 UNSET_IF_PARAM(params
, auth_type
);
5967 if (params
!= IF_DEF_PARAMS(ifp
)) {
5968 ospf_free_if_params(
5969 ifp
, rn
->p
.u
.prefix4
);
5970 ospf_if_update_params(
5971 ifp
, rn
->p
.u
.prefix4
);
5982 DEFUN (ip_ospf_authentication_key
,
5983 ip_ospf_authentication_key_addr_cmd
,
5984 "ip ospf authentication-key AUTH_KEY [A.B.C.D]",
5986 "OSPF interface commands\n"
5987 "Authentication password (key)\n"
5988 "The OSPF password (key)\n"
5989 "Address of interface")
5991 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5993 struct in_addr addr
;
5994 struct ospf_if_params
*params
;
5996 params
= IF_DEF_PARAMS(ifp
);
5998 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
5999 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6001 "Please specify interface address by A.B.C.D%s",
6006 params
= ospf_get_if_params(ifp
, addr
);
6007 ospf_if_update_params(ifp
, addr
);
6010 memset(params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
6011 strncpy((char *)params
->auth_simple
, argv
[3]->arg
,
6012 OSPF_AUTH_SIMPLE_SIZE
);
6013 SET_IF_PARAM(params
, auth_simple
);
6018 DEFUN_HIDDEN (ospf_authentication_key
,
6019 ospf_authentication_key_cmd
,
6020 "ospf authentication-key AUTH_KEY [A.B.C.D]",
6021 "OSPF interface commands\n"
6022 "Authentication password (key)\n"
6023 "The OSPF password (key)\n"
6024 "Address of interface\n")
6026 return ip_ospf_authentication_key(self
, vty
, argc
, argv
);
6029 DEFUN (no_ip_ospf_authentication_key
,
6030 no_ip_ospf_authentication_key_authkey_addr_cmd
,
6031 "no ip ospf authentication-key [AUTH_KEY [A.B.C.D]]",
6034 "OSPF interface commands\n"
6035 "Authentication password (key)\n"
6036 "The OSPF password (key)")
6038 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6040 struct in_addr addr
;
6041 struct ospf_if_params
*params
;
6042 params
= IF_DEF_PARAMS(ifp
);
6044 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6045 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6047 "Please specify interface address by A.B.C.D%s",
6052 params
= ospf_lookup_if_params(ifp
, addr
);
6057 memset(params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
);
6058 UNSET_IF_PARAM(params
, auth_simple
);
6060 if (params
!= IF_DEF_PARAMS(ifp
)) {
6061 ospf_free_if_params(ifp
, addr
);
6062 ospf_if_update_params(ifp
, addr
);
6068 DEFUN_HIDDEN (no_ospf_authentication_key
,
6069 no_ospf_authentication_key_authkey_addr_cmd
,
6070 "no ospf authentication-key [AUTH_KEY [A.B.C.D]]",
6072 "OSPF interface commands\n"
6073 "Authentication password (key)\n"
6074 "The OSPF password (key)")
6076 return no_ip_ospf_authentication_key(self
, vty
, argc
, argv
);
6079 DEFUN (ip_ospf_message_digest_key
,
6080 ip_ospf_message_digest_key_cmd
,
6081 "ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
6083 "OSPF interface commands\n"
6084 "Message digest authentication password (key)\n"
6086 "Use MD5 algorithm\n"
6087 "The OSPF password (key)\n"
6088 "Address of interface\n")
6090 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6091 struct crypt_key
*ck
;
6093 struct in_addr addr
;
6094 struct ospf_if_params
*params
;
6096 params
= IF_DEF_PARAMS(ifp
);
6099 argv_find(argv
, argc
, "(1-255)", &idx
);
6100 char *keyid
= argv
[idx
]->arg
;
6101 argv_find(argv
, argc
, "KEY", &idx
);
6102 char *cryptkey
= argv
[idx
]->arg
;
6104 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6105 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6107 "Please specify interface address by A.B.C.D%s",
6112 params
= ospf_get_if_params(ifp
, addr
);
6113 ospf_if_update_params(ifp
, addr
);
6116 key_id
= strtol(keyid
, NULL
, 10);
6117 if (ospf_crypt_key_lookup(params
->auth_crypt
, key_id
) != NULL
) {
6118 vty_out(vty
, "OSPF: Key %d already exists%s", key_id
,
6123 ck
= ospf_crypt_key_new();
6124 ck
->key_id
= (u_char
)key_id
;
6125 memset(ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+ 1);
6126 strncpy((char *)ck
->auth_key
, cryptkey
, OSPF_AUTH_MD5_SIZE
);
6128 ospf_crypt_key_add(params
->auth_crypt
, ck
);
6129 SET_IF_PARAM(params
, auth_crypt
);
6134 DEFUN_HIDDEN (ospf_message_digest_key
,
6135 ospf_message_digest_key_cmd
,
6136 "ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
6137 "OSPF interface commands\n"
6138 "Message digest authentication password (key)\n"
6140 "Use MD5 algorithm\n"
6141 "The OSPF password (key)\n"
6142 "Address of interface\n")
6144 return ip_ospf_message_digest_key(self
, vty
, argc
, argv
);
6147 DEFUN (no_ip_ospf_message_digest_key
,
6148 no_ip_ospf_message_digest_key_cmd
,
6149 "no ip ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
6152 "OSPF interface commands\n"
6153 "Message digest authentication password (key)\n"
6155 "Use MD5 algorithm\n"
6156 "The OSPF password (key)\n"
6157 "Address of interface\n")
6159 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6161 struct crypt_key
*ck
;
6163 struct in_addr addr
;
6164 struct ospf_if_params
*params
;
6165 params
= IF_DEF_PARAMS(ifp
);
6167 argv_find(argv
, argc
, "(1-255)", &idx
);
6168 char *keyid
= argv
[idx
]->arg
;
6170 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6171 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6173 "Please specify interface address by A.B.C.D%s",
6178 params
= ospf_lookup_if_params(ifp
, addr
);
6183 key_id
= strtol(keyid
, NULL
, 10);
6184 ck
= ospf_crypt_key_lookup(params
->auth_crypt
, key_id
);
6186 vty_out(vty
, "OSPF: Key %d does not exist%s", key_id
,
6191 ospf_crypt_key_delete(params
->auth_crypt
, key_id
);
6193 if (params
!= IF_DEF_PARAMS(ifp
)) {
6194 ospf_free_if_params(ifp
, addr
);
6195 ospf_if_update_params(ifp
, addr
);
6201 DEFUN_HIDDEN (no_ospf_message_digest_key
,
6202 no_ospf_message_digest_key_cmd
,
6203 "no ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
6205 "OSPF interface commands\n"
6206 "Message digest authentication password (key)\n"
6208 "Address of interface")
6210 return no_ip_ospf_message_digest_key(self
, vty
, argc
, argv
);
6213 DEFUN (ip_ospf_cost
,
6215 "ip ospf cost (1-65535) [A.B.C.D]",
6217 "OSPF interface commands\n"
6220 "Address of interface\n")
6222 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6225 struct in_addr addr
;
6226 struct ospf_if_params
*params
;
6227 params
= IF_DEF_PARAMS(ifp
);
6230 char *coststr
= NULL
, *ifaddr
= NULL
;
6231 coststr
= argv_find(argv
, argc
, "(1-65535)", &idx
) ? argv
[idx
]->arg
6233 ifaddr
= argv_find(argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6235 cost
= strtol(coststr
, NULL
, 10);
6238 if (!inet_aton(ifaddr
, &addr
)) {
6240 "Please specify interface address by A.B.C.D%s",
6245 params
= ospf_get_if_params(ifp
, addr
);
6246 ospf_if_update_params(ifp
, addr
);
6249 SET_IF_PARAM(params
, output_cost_cmd
);
6250 params
->output_cost_cmd
= cost
;
6252 ospf_if_recalculate_output_cost(ifp
);
6257 DEFUN_HIDDEN (ospf_cost
,
6259 "ospf cost (1-65535) [A.B.C.D]",
6260 "OSPF interface commands\n"
6263 "Address of interface\n")
6265 return ip_ospf_cost(self
, vty
, argc
, argv
);
6268 DEFUN (no_ip_ospf_cost
,
6269 no_ip_ospf_cost_cmd
,
6270 "no ip ospf cost [(1-65535)] [A.B.C.D]",
6272 "OSPF interface commands\n"
6274 "Address of interface")
6276 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6278 struct in_addr addr
;
6279 struct ospf_if_params
*params
;
6281 params
= IF_DEF_PARAMS(ifp
);
6284 char *ifaddr
= NULL
;
6285 ifaddr
= argv_find(argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6287 /* According to the semantics we are mimicking "no ip ospf cost N" is
6288 * always treated as "no ip ospf cost" regardless of the actual value
6289 * of N already configured for the interface. Thus ignore cost. */
6292 if (!inet_aton(ifaddr
, &addr
)) {
6294 "Please specify interface address by A.B.C.D%s",
6299 params
= ospf_lookup_if_params(ifp
, addr
);
6304 UNSET_IF_PARAM(params
, output_cost_cmd
);
6306 if (params
!= IF_DEF_PARAMS(ifp
)) {
6307 ospf_free_if_params(ifp
, addr
);
6308 ospf_if_update_params(ifp
, addr
);
6311 ospf_if_recalculate_output_cost(ifp
);
6316 DEFUN_HIDDEN (no_ospf_cost
,
6318 "no ospf cost [(1-65535)] [A.B.C.D]",
6320 "OSPF interface commands\n"
6323 "Address of interface\n")
6325 return no_ip_ospf_cost(self
, vty
, argc
, argv
);
6328 static void ospf_nbr_timer_update(struct ospf_interface
*oi
)
6330 struct route_node
*rn
;
6331 struct ospf_neighbor
*nbr
;
6333 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
))
6334 if ((nbr
= rn
->info
)) {
6335 nbr
->v_inactivity
= OSPF_IF_PARAM(oi
, v_wait
);
6336 nbr
->v_db_desc
= OSPF_IF_PARAM(oi
, retransmit_interval
);
6337 nbr
->v_ls_req
= OSPF_IF_PARAM(oi
, retransmit_interval
);
6338 nbr
->v_ls_upd
= OSPF_IF_PARAM(oi
, retransmit_interval
);
6342 static int ospf_vty_dead_interval_set(struct vty
*vty
, const char *interval_str
,
6343 const char *nbr_str
,
6344 const char *fast_hello_str
)
6346 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6349 struct in_addr addr
;
6351 struct ospf_if_params
*params
;
6352 struct ospf_interface
*oi
;
6353 struct route_node
*rn
;
6355 params
= IF_DEF_PARAMS(ifp
);
6358 ret
= inet_aton(nbr_str
, &addr
);
6361 "Please specify interface address by A.B.C.D%s",
6366 params
= ospf_get_if_params(ifp
, addr
);
6367 ospf_if_update_params(ifp
, addr
);
6371 VTY_GET_INTEGER_RANGE("Router Dead Interval", seconds
,
6372 interval_str
, 1, 65535);
6374 /* reset fast_hello too, just to be sure */
6375 UNSET_IF_PARAM(params
, fast_hello
);
6376 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6377 } else if (fast_hello_str
) {
6378 VTY_GET_INTEGER_RANGE("Hello Multiplier", hellomult
,
6379 fast_hello_str
, 1, 10);
6380 /* 1s dead-interval with sub-second hellos desired */
6381 seconds
= OSPF_ROUTER_DEAD_INTERVAL_MINIMAL
;
6382 SET_IF_PARAM(params
, fast_hello
);
6383 params
->fast_hello
= hellomult
;
6386 "Please specify dead-interval or hello-multiplier%s",
6391 SET_IF_PARAM(params
, v_wait
);
6392 params
->v_wait
= seconds
;
6394 /* Update timer values in neighbor structure. */
6397 if ((ospf
= ospf_lookup())) {
6398 oi
= ospf_if_lookup_by_local_addr(ospf
, ifp
, addr
);
6400 ospf_nbr_timer_update(oi
);
6403 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
))
6404 if ((oi
= rn
->info
))
6405 ospf_nbr_timer_update(oi
);
6411 DEFUN (ip_ospf_dead_interval
,
6412 ip_ospf_dead_interval_cmd
,
6413 "ip ospf dead-interval (1-65535) [A.B.C.D]",
6415 "OSPF interface commands\n"
6416 "Interval time after which a neighbor is declared down\n"
6418 "Address of interface\n")
6421 char *interval
= argv_find(argv
, argc
, "(1-65535)", &idx
)
6425 argv_find(argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6426 return ospf_vty_dead_interval_set(vty
, interval
, ifaddr
, NULL
);
6430 DEFUN_HIDDEN (ospf_dead_interval
,
6431 ospf_dead_interval_cmd
,
6432 "ospf dead-interval (1-65535) [A.B.C.D]",
6433 "OSPF interface commands\n"
6434 "Interval time after which a neighbor is declared down\n"
6436 "Address of interface\n")
6438 return ip_ospf_dead_interval(self
, vty
, argc
, argv
);
6441 DEFUN (ip_ospf_dead_interval_minimal
,
6442 ip_ospf_dead_interval_minimal_addr_cmd
,
6443 "ip ospf dead-interval minimal hello-multiplier (1-10) [A.B.C.D]",
6445 "OSPF interface commands\n"
6446 "Interval time after which a neighbor is declared down\n"
6447 "Minimal 1s dead-interval with fast sub-second hellos\n"
6448 "Hello multiplier factor\n"
6449 "Number of Hellos to send each second\n"
6450 "Address of interface\n")
6455 return ospf_vty_dead_interval_set(
6456 vty
, NULL
, argv
[idx_ipv4
]->arg
, argv
[idx_number
]->arg
);
6458 return ospf_vty_dead_interval_set(vty
, NULL
, NULL
,
6459 argv
[idx_number
]->arg
);
6462 DEFUN (no_ip_ospf_dead_interval
,
6463 no_ip_ospf_dead_interval_cmd
,
6464 "no ip ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6467 "OSPF interface commands\n"
6468 "Interval time after which a neighbor is declared down\n"
6470 "Address of interface")
6472 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6473 int idx_ipv4
= argc
- 1;
6474 struct in_addr addr
= {.s_addr
= 0L};
6476 struct ospf_if_params
*params
;
6477 struct ospf_interface
*oi
;
6478 struct route_node
*rn
;
6480 params
= IF_DEF_PARAMS(ifp
);
6482 if (argv
[idx_ipv4
]->type
== IPV4_TKN
) {
6483 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6486 "Please specify interface address by A.B.C.D%s",
6491 params
= ospf_lookup_if_params(ifp
, addr
);
6496 UNSET_IF_PARAM(params
, v_wait
);
6497 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
6499 UNSET_IF_PARAM(params
, fast_hello
);
6500 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6502 if (params
!= IF_DEF_PARAMS(ifp
)) {
6503 ospf_free_if_params(ifp
, addr
);
6504 ospf_if_update_params(ifp
, addr
);
6507 /* Update timer values in neighbor structure. */
6511 if ((ospf
= ospf_lookup())) {
6512 oi
= ospf_if_lookup_by_local_addr(ospf
, ifp
, addr
);
6514 ospf_nbr_timer_update(oi
);
6517 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
))
6518 if ((oi
= rn
->info
))
6519 ospf_nbr_timer_update(oi
);
6525 DEFUN_HIDDEN (no_ospf_dead_interval
,
6526 no_ospf_dead_interval_cmd
,
6527 "no ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6529 "OSPF interface commands\n"
6530 "Interval time after which a neighbor is declared down\n"
6532 "Address of interface")
6534 return no_ip_ospf_dead_interval(self
, vty
, argc
, argv
);
6537 DEFUN (ip_ospf_hello_interval
,
6538 ip_ospf_hello_interval_cmd
,
6539 "ip ospf hello-interval (1-65535) [A.B.C.D]",
6541 "OSPF interface commands\n"
6542 "Time between HELLO packets\n"
6544 "Address of interface\n")
6546 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6548 struct in_addr addr
;
6549 struct ospf_if_params
*params
;
6550 params
= IF_DEF_PARAMS(ifp
);
6551 u_int32_t seconds
= 0;
6553 argv_find(argv
, argc
, "(1-65535)", &idx
);
6554 seconds
= strtol(argv
[idx
]->arg
, NULL
, 10);
6556 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6557 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6559 "Please specify interface address by A.B.C.D%s",
6564 params
= ospf_get_if_params(ifp
, addr
);
6565 ospf_if_update_params(ifp
, addr
);
6568 SET_IF_PARAM(params
, v_hello
);
6569 params
->v_hello
= seconds
;
6574 DEFUN_HIDDEN (ospf_hello_interval
,
6575 ospf_hello_interval_cmd
,
6576 "ospf hello-interval (1-65535) [A.B.C.D]",
6577 "OSPF interface commands\n"
6578 "Time between HELLO packets\n"
6580 "Address of interface\n")
6582 return ip_ospf_hello_interval(self
, vty
, argc
, argv
);
6585 DEFUN (no_ip_ospf_hello_interval
,
6586 no_ip_ospf_hello_interval_cmd
,
6587 "no ip ospf hello-interval [(1-65535) [A.B.C.D]]",
6590 "OSPF interface commands\n"
6591 "Time between HELLO packets\n" // ignored
6593 "Address of interface\n")
6595 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6597 struct in_addr addr
;
6598 struct ospf_if_params
*params
;
6599 params
= IF_DEF_PARAMS(ifp
);
6601 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6602 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6604 "Please specify interface address by A.B.C.D%s",
6609 params
= ospf_lookup_if_params(ifp
, addr
);
6614 UNSET_IF_PARAM(params
, v_hello
);
6615 params
->v_hello
= OSPF_HELLO_INTERVAL_DEFAULT
;
6617 if (params
!= IF_DEF_PARAMS(ifp
)) {
6618 ospf_free_if_params(ifp
, addr
);
6619 ospf_if_update_params(ifp
, addr
);
6625 DEFUN_HIDDEN (no_ospf_hello_interval
,
6626 no_ospf_hello_interval_cmd
,
6627 "no ospf hello-interval [(1-65535) [A.B.C.D]]",
6629 "OSPF interface commands\n"
6630 "Time between HELLO packets\n" // ignored
6632 "Address of interface\n")
6634 return no_ip_ospf_hello_interval(self
, vty
, argc
, argv
);
6637 DEFUN (ip_ospf_network
,
6638 ip_ospf_network_cmd
,
6639 "ip ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
6641 "OSPF interface commands\n"
6643 "Specify OSPF broadcast multi-access network\n"
6644 "Specify OSPF NBMA network\n"
6645 "Specify OSPF point-to-multipoint network\n"
6646 "Specify OSPF point-to-point network\n")
6648 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6650 int old_type
= IF_DEF_PARAMS(ifp
)->type
;
6651 struct route_node
*rn
;
6653 if (old_type
== OSPF_IFTYPE_LOOPBACK
) {
6655 "This is a loopback interface. Can't set network type.%s",
6660 if (argv_find(argv
, argc
, "broadcast", &idx
))
6661 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_BROADCAST
;
6662 else if (argv_find(argv
, argc
, "non-broadcast", &idx
))
6663 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_NBMA
;
6664 else if (argv_find(argv
, argc
, "point-to-multipoint", &idx
))
6665 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_POINTOMULTIPOINT
;
6666 else if (argv_find(argv
, argc
, "point-to-point", &idx
))
6667 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_POINTOPOINT
;
6669 if (IF_DEF_PARAMS(ifp
)->type
== old_type
)
6672 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), type
);
6674 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
6675 struct ospf_interface
*oi
= rn
->info
;
6680 oi
->type
= IF_DEF_PARAMS(ifp
)->type
;
6682 if (oi
->state
> ISM_Down
) {
6683 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceDown
);
6684 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceUp
);
6691 DEFUN_HIDDEN (ospf_network
,
6693 "ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
6694 "OSPF interface commands\n"
6696 "Specify OSPF broadcast multi-access network\n"
6697 "Specify OSPF NBMA network\n"
6698 "Specify OSPF point-to-multipoint network\n"
6699 "Specify OSPF point-to-point network\n")
6701 return ip_ospf_network(self
, vty
, argc
, argv
);
6704 DEFUN (no_ip_ospf_network
,
6705 no_ip_ospf_network_cmd
,
6706 "no ip ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
6709 "OSPF interface commands\n"
6711 "Specify OSPF broadcast multi-access network\n"
6712 "Specify OSPF NBMA network\n"
6713 "Specify OSPF point-to-multipoint network\n"
6714 "Specify OSPF point-to-point network\n")
6716 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6717 int old_type
= IF_DEF_PARAMS(ifp
)->type
;
6718 struct route_node
*rn
;
6720 IF_DEF_PARAMS(ifp
)->type
= ospf_default_iftype(ifp
);
6722 if (IF_DEF_PARAMS(ifp
)->type
== old_type
)
6725 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
6726 struct ospf_interface
*oi
= rn
->info
;
6731 oi
->type
= IF_DEF_PARAMS(ifp
)->type
;
6733 if (oi
->state
> ISM_Down
) {
6734 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceDown
);
6735 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceUp
);
6742 DEFUN_HIDDEN (no_ospf_network
,
6743 no_ospf_network_cmd
,
6744 "no ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
6746 "OSPF interface commands\n"
6748 "Specify OSPF broadcast multi-access network\n"
6749 "Specify OSPF NBMA network\n"
6750 "Specify OSPF point-to-multipoint network\n"
6751 "Specify OSPF point-to-point network\n")
6753 return no_ip_ospf_network(self
, vty
, argc
, argv
);
6756 DEFUN (ip_ospf_priority
,
6757 ip_ospf_priority_cmd
,
6758 "ip ospf priority (0-255) [A.B.C.D]",
6760 "OSPF interface commands\n"
6763 "Address of interface")
6765 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6768 struct route_node
*rn
;
6769 struct in_addr addr
;
6770 struct ospf_if_params
*params
;
6771 params
= IF_DEF_PARAMS(ifp
);
6773 argv_find(argv
, argc
, "(0-255)", &idx
);
6774 priority
= strtol(argv
[idx
]->arg
, NULL
, 10);
6776 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6777 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6779 "Please specify interface address by A.B.C.D%s",
6784 params
= ospf_get_if_params(ifp
, addr
);
6785 ospf_if_update_params(ifp
, addr
);
6788 SET_IF_PARAM(params
, priority
);
6789 params
->priority
= priority
;
6791 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
6792 struct ospf_interface
*oi
= rn
->info
;
6797 if (PRIORITY(oi
) != OSPF_IF_PARAM(oi
, priority
)) {
6798 PRIORITY(oi
) = OSPF_IF_PARAM(oi
, priority
);
6799 OSPF_ISM_EVENT_SCHEDULE(oi
, ISM_NeighborChange
);
6806 DEFUN_HIDDEN (ospf_priority
,
6808 "ospf priority (0-255) [A.B.C.D]",
6809 "OSPF interface commands\n"
6812 "Address of interface")
6814 return ip_ospf_priority(self
, vty
, argc
, argv
);
6817 DEFUN (no_ip_ospf_priority
,
6818 no_ip_ospf_priority_cmd
,
6819 "no ip ospf priority [(0-255) [A.B.C.D]]",
6822 "OSPF interface commands\n"
6823 "Router priority\n" // ignored
6825 "Address of interface")
6827 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6829 struct route_node
*rn
;
6830 struct in_addr addr
;
6831 struct ospf_if_params
*params
;
6833 params
= IF_DEF_PARAMS(ifp
);
6835 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6836 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6838 "Please specify interface address by A.B.C.D%s",
6843 params
= ospf_lookup_if_params(ifp
, addr
);
6848 UNSET_IF_PARAM(params
, priority
);
6849 params
->priority
= OSPF_ROUTER_PRIORITY_DEFAULT
;
6851 if (params
!= IF_DEF_PARAMS(ifp
)) {
6852 ospf_free_if_params(ifp
, addr
);
6853 ospf_if_update_params(ifp
, addr
);
6856 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
6857 struct ospf_interface
*oi
= rn
->info
;
6862 if (PRIORITY(oi
) != OSPF_IF_PARAM(oi
, priority
)) {
6863 PRIORITY(oi
) = OSPF_IF_PARAM(oi
, priority
);
6864 OSPF_ISM_EVENT_SCHEDULE(oi
, ISM_NeighborChange
);
6871 DEFUN_HIDDEN (no_ospf_priority
,
6872 no_ospf_priority_cmd
,
6873 "no ospf priority [(0-255) [A.B.C.D]]",
6875 "OSPF interface commands\n"
6878 "Address of interface")
6880 return no_ip_ospf_priority(self
, vty
, argc
, argv
);
6883 DEFUN (ip_ospf_retransmit_interval
,
6884 ip_ospf_retransmit_interval_addr_cmd
,
6885 "ip ospf retransmit-interval (3-65535) [A.B.C.D]",
6887 "OSPF interface commands\n"
6888 "Time between retransmitting lost link state advertisements\n"
6890 "Address of interface")
6892 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6895 struct in_addr addr
;
6896 struct ospf_if_params
*params
;
6897 params
= IF_DEF_PARAMS(ifp
);
6899 argv_find(argv
, argc
, "(3-65535)", &idx
);
6900 seconds
= strtol(argv
[idx
]->arg
, NULL
, 10);
6902 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6903 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6905 "Please specify interface address by A.B.C.D%s",
6910 params
= ospf_get_if_params(ifp
, addr
);
6911 ospf_if_update_params(ifp
, addr
);
6914 SET_IF_PARAM(params
, retransmit_interval
);
6915 params
->retransmit_interval
= seconds
;
6920 DEFUN_HIDDEN (ospf_retransmit_interval
,
6921 ospf_retransmit_interval_cmd
,
6922 "ospf retransmit-interval (3-65535) [A.B.C.D]",
6923 "OSPF interface commands\n"
6924 "Time between retransmitting lost link state advertisements\n"
6926 "Address of interface")
6928 return ip_ospf_retransmit_interval(self
, vty
, argc
, argv
);
6931 DEFUN (no_ip_ospf_retransmit_interval
,
6932 no_ip_ospf_retransmit_interval_addr_cmd
,
6933 "no ip ospf retransmit-interval [(3-65535)] [A.B.C.D]",
6936 "OSPF interface commands\n"
6937 "Time between retransmitting lost link state advertisements\n"
6939 "Address of interface\n")
6941 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6943 struct in_addr addr
;
6944 struct ospf_if_params
*params
;
6946 params
= IF_DEF_PARAMS(ifp
);
6948 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6949 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6951 "Please specify interface address by A.B.C.D%s",
6956 params
= ospf_lookup_if_params(ifp
, addr
);
6961 UNSET_IF_PARAM(params
, retransmit_interval
);
6962 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
6964 if (params
!= IF_DEF_PARAMS(ifp
)) {
6965 ospf_free_if_params(ifp
, addr
);
6966 ospf_if_update_params(ifp
, addr
);
6972 DEFUN_HIDDEN (no_ospf_retransmit_interval
,
6973 no_ospf_retransmit_interval_cmd
,
6974 "no ospf retransmit-interval [(3-65535)] [A.B.C.D]",
6976 "OSPF interface commands\n"
6977 "Time between retransmitting lost link state advertisements\n"
6979 "Address of interface\n")
6981 return no_ip_ospf_retransmit_interval(self
, vty
, argc
, argv
);
6984 DEFUN (ip_ospf_transmit_delay
,
6985 ip_ospf_transmit_delay_addr_cmd
,
6986 "ip ospf transmit-delay (1-65535) [A.B.C.D]",
6988 "OSPF interface commands\n"
6989 "Link state transmit delay\n"
6991 "Address of interface")
6993 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6996 struct in_addr addr
;
6997 struct ospf_if_params
*params
;
6999 params
= IF_DEF_PARAMS(ifp
);
7000 argv_find(argv
, argc
, "(1-65535)", &idx
);
7001 seconds
= strtol(argv
[idx
]->arg
, NULL
, 10);
7003 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7004 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7006 "Please specify interface address by A.B.C.D%s",
7011 params
= ospf_get_if_params(ifp
, addr
);
7012 ospf_if_update_params(ifp
, addr
);
7015 SET_IF_PARAM(params
, transmit_delay
);
7016 params
->transmit_delay
= seconds
;
7021 DEFUN_HIDDEN (ospf_transmit_delay
,
7022 ospf_transmit_delay_cmd
,
7023 "ospf transmit-delay (1-65535) [A.B.C.D]",
7024 "OSPF interface commands\n"
7025 "Link state transmit delay\n"
7027 "Address of interface")
7029 return ip_ospf_transmit_delay(self
, vty
, argc
, argv
);
7032 DEFUN (no_ip_ospf_transmit_delay
,
7033 no_ip_ospf_transmit_delay_addr_cmd
,
7034 "no ip ospf transmit-delay [(1-65535)] [A.B.C.D]",
7037 "OSPF interface commands\n"
7038 "Link state transmit delay\n"
7039 "Address of interface")
7041 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7043 struct in_addr addr
;
7044 struct ospf_if_params
*params
;
7046 params
= IF_DEF_PARAMS(ifp
);
7048 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7049 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7051 "Please specify interface address by A.B.C.D%s",
7056 params
= ospf_lookup_if_params(ifp
, addr
);
7061 UNSET_IF_PARAM(params
, transmit_delay
);
7062 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
7064 if (params
!= IF_DEF_PARAMS(ifp
)) {
7065 ospf_free_if_params(ifp
, addr
);
7066 ospf_if_update_params(ifp
, addr
);
7073 DEFUN_HIDDEN (no_ospf_transmit_delay
,
7074 no_ospf_transmit_delay_cmd
,
7075 "no ospf transmit-delay",
7077 "OSPF interface commands\n"
7078 "Link state transmit delay\n")
7080 return no_ip_ospf_transmit_delay(self
, vty
, argc
, argv
);
7083 DEFUN (ip_ospf_area
,
7085 "ip ospf [(1-65535)] area <A.B.C.D|(0-4294967295)>",
7087 "OSPF interface commands\n"
7089 "Enable OSPF on this interface\n"
7090 "OSPF area ID in IP address format\n"
7091 "OSPF area ID as a decimal value\n")
7093 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7096 struct in_addr area_id
;
7098 struct ospf_if_params
*params
;
7099 struct route_node
*rn
;
7100 u_short instance
= 0;
7102 if (argv_find(argv
, argc
, "(1-65535)", &idx
))
7103 instance
= strtol(argv
[idx
]->arg
, NULL
, 10);
7104 char *areaid
= argv
[argc
- 1]->arg
;
7106 ospf
= ospf_lookup_instance(instance
);
7108 params
= IF_DEF_PARAMS(ifp
);
7109 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
7110 ospf_interface_unset(ifp
);
7111 ospf
= ospf_lookup();
7112 ospf
->if_ospf_cli_count
--;
7117 ret
= str2area_id(areaid
, &area_id
, &format
);
7119 vty_out(vty
, "Please specify area by A.B.C.D|<0-4294967295>%s",
7123 if (memcmp(ifp
->name
, "VLINK", 5) == 0) {
7124 vty_out(vty
, "Cannot enable OSPF on a virtual link.%s",
7129 params
= IF_DEF_PARAMS(ifp
);
7130 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
7132 "Must remove previous area config before changing ospf area %s",
7137 for (rn
= route_top(ospf
->networks
); rn
; rn
= route_next(rn
)) {
7138 if (rn
->info
!= NULL
) {
7140 "Please remove all network commands first.%s",
7146 /* enable ospf on this interface with area_id */
7147 ospf_interface_set(ifp
, area_id
);
7148 ospf
->if_ospf_cli_count
++;
7153 DEFUN (no_ip_ospf_area
,
7154 no_ip_ospf_area_cmd
,
7155 "no ip ospf [(1-65535)] area [<A.B.C.D|(0-4294967295)>]",
7158 "OSPF interface commands\n"
7160 "Disable OSPF on this interface\n"
7161 "OSPF area ID in IP address format\n"
7162 "OSPF area ID as a decimal value\n")
7164 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7167 struct ospf_if_params
*params
;
7168 u_short instance
= 0;
7170 if (argv_find(argv
, argc
, "(1-65535)", &idx
))
7171 instance
= strtol(argv
[idx
]->arg
, NULL
, 10);
7173 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
)
7176 params
= IF_DEF_PARAMS(ifp
);
7177 if (!OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
7179 "Can't find specified interface area configuration.%s",
7184 ospf_interface_unset(ifp
);
7185 ospf
->if_ospf_cli_count
--;
7189 DEFUN (ospf_redistribute_source
,
7190 ospf_redistribute_source_cmd
,
7191 "redistribute " FRR_REDIST_STR_OSPFD
" [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7193 FRR_REDIST_HELP_STR_OSPFD
7194 "Metric for redistributed routes\n"
7195 "OSPF default metric\n"
7196 "OSPF exterior metric type for redistributed routes\n"
7197 "Set OSPF External Type 1 metrics\n"
7198 "Set OSPF External Type 2 metrics\n"
7199 "Route map reference\n"
7200 "Pointer to route-map entries\n")
7202 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7203 int idx_protocol
= 1;
7207 struct ospf_redist
*red
;
7213 /* Get distribute source. */
7214 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
7218 red
= ospf_redist_add(ospf
, source
, 0);
7220 /* Get metric value. */
7221 if (argv_find(argv
, argc
, "(0-16777214)", &idx
)) {
7222 if (!str2metric(argv
[idx
]->arg
, &metric
))
7225 /* Get metric type. */
7226 else if (argv_find(argv
, argc
, "(1-2)", &idx
)) {
7227 if (!str2metric_type(argv
[idx
]->arg
, &type
))
7231 else if (argv_find(argv
, argc
, "WORD", &idx
)) {
7232 ospf_routemap_set(red
, argv
[idx
]->arg
);
7234 ospf_routemap_unset(red
);
7236 return ospf_redistribute_set(ospf
, source
, 0, type
, metric
);
7239 DEFUN (no_ospf_redistribute_source
,
7240 no_ospf_redistribute_source_cmd
,
7241 "no redistribute " FRR_REDIST_STR_OSPFD
" [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7244 FRR_REDIST_HELP_STR_OSPFD
7245 "Metric for redistributed routes\n"
7246 "OSPF default metric\n"
7247 "OSPF exterior metric type for redistributed routes\n"
7248 "Set OSPF External Type 1 metrics\n"
7249 "Set OSPF External Type 2 metrics\n"
7250 "Route map reference\n"
7251 "Pointer to route-map entries\n")
7253 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7254 int idx_protocol
= 2;
7256 struct ospf_redist
*red
;
7258 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
7262 red
= ospf_redist_lookup(ospf
, source
, 0);
7266 ospf_routemap_unset(red
);
7267 return ospf_redistribute_unset(ospf
, source
, 0);
7270 DEFUN (ospf_redistribute_instance_source
,
7271 ospf_redistribute_instance_source_cmd
,
7272 "redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
7274 "Open Shortest Path First\n"
7275 "Non-main Kernel Routing Table\n"
7276 "Instance ID/Table ID\n"
7277 "Metric for redistributed routes\n"
7278 "OSPF default metric\n"
7279 "OSPF exterior metric type for redistributed routes\n"
7280 "Set OSPF External Type 1 metrics\n"
7281 "Set OSPF External Type 2 metrics\n"
7282 "Route map reference\n"
7283 "Pointer to route-map entries\n")
7285 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7286 int idx_ospf_table
= 1;
7293 struct ospf_redist
*red
;
7298 source
= proto_redistnum(AFI_IP
, argv
[idx_ospf_table
]->text
);
7300 VTY_GET_INTEGER("Instance ID", instance
, argv
[idx_number
]->arg
);
7305 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
) {
7307 "Instance redistribution in non-instanced OSPF not allowed%s",
7312 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
)) {
7313 vty_out(vty
, "Same instance OSPF redistribution not allowed%s",
7318 /* Get metric value. */
7319 if (argv_find(argv
, argc
, "metric", &idx
))
7320 if (!str2metric(argv
[idx
+ 1]->arg
, &metric
))
7324 /* Get metric type. */
7325 if (argv_find(argv
, argc
, "metric-type", &idx
))
7326 if (!str2metric_type(argv
[idx
+ 1]->arg
, &type
))
7329 red
= ospf_redist_add(ospf
, source
, instance
);
7332 if (argv_find(argv
, argc
, "route-map", &idx
))
7333 ospf_routemap_set(red
, argv
[idx
+ 1]->arg
);
7335 ospf_routemap_unset(red
);
7337 return ospf_redistribute_set(ospf
, source
, instance
, type
, metric
);
7340 DEFUN (no_ospf_redistribute_instance_source
,
7341 no_ospf_redistribute_instance_source_cmd
,
7342 "no redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
7345 "Open Shortest Path First\n"
7346 "Non-main Kernel Routing Table\n"
7347 "Instance ID/Table Id\n"
7348 "Metric for redistributed routes\n"
7349 "OSPF default metric\n"
7350 "OSPF exterior metric type for redistributed routes\n"
7351 "Set OSPF External Type 1 metrics\n"
7352 "Set OSPF External Type 2 metrics\n"
7353 "Route map reference\n"
7354 "Pointer to route-map entries\n")
7356 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7357 int idx_ospf_table
= 2;
7360 struct ospf_redist
*red
;
7363 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
7364 source
= ZEBRA_ROUTE_OSPF
;
7366 source
= ZEBRA_ROUTE_TABLE
;
7368 VTY_GET_INTEGER("Instance ID", instance
, argv
[idx_number
]->arg
);
7370 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
) {
7372 "Instance redistribution in non-instanced OSPF not allowed%s",
7377 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
)) {
7378 vty_out(vty
, "Same instance OSPF redistribution not allowed%s",
7383 red
= ospf_redist_lookup(ospf
, source
, instance
);
7387 ospf_routemap_unset(red
);
7388 return ospf_redistribute_unset(ospf
, source
, instance
);
7391 DEFUN (ospf_distribute_list_out
,
7392 ospf_distribute_list_out_cmd
,
7393 "distribute-list WORD out " FRR_REDIST_STR_OSPFD
,
7394 "Filter networks in routing updates\n"
7395 "Access-list name\n"
7397 FRR_REDIST_HELP_STR_OSPFD
)
7399 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7403 char *proto
= argv
[argc
- 1]->text
;
7405 /* Get distribute source. */
7406 source
= proto_redistnum(AFI_IP
, proto
);
7410 return ospf_distribute_list_out_set(ospf
, source
, argv
[idx_word
]->arg
);
7413 DEFUN (no_ospf_distribute_list_out
,
7414 no_ospf_distribute_list_out_cmd
,
7415 "no distribute-list WORD out " FRR_REDIST_STR_OSPFD
,
7417 "Filter networks in routing updates\n"
7418 "Access-list name\n"
7420 FRR_REDIST_HELP_STR_OSPFD
)
7422 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7426 char *proto
= argv
[argc
- 1]->text
;
7427 source
= proto_redistnum(AFI_IP
, proto
);
7431 return ospf_distribute_list_out_unset(ospf
, source
,
7432 argv
[idx_word
]->arg
);
7435 /* Default information originate. */
7436 DEFUN (ospf_default_information_originate
,
7437 ospf_default_information_originate_cmd
,
7438 "default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7439 "Control distribution of default information\n"
7440 "Distribute a default route\n"
7441 "Always advertise default route\n"
7442 "OSPF default metric\n"
7444 "OSPF metric type for default routes\n"
7445 "Set OSPF External Type 1 metrics\n"
7446 "Set OSPF External Type 2 metrics\n"
7447 "Route map reference\n"
7448 "Pointer to route-map entries\n")
7450 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7451 int default_originate
= DEFAULT_ORIGINATE_ZEBRA
;
7454 struct ospf_redist
*red
;
7457 red
= ospf_redist_add(ospf
, DEFAULT_ROUTE
, 0);
7459 /* Check whether "always" was specified */
7460 if (argv_find(argv
, argc
, "always", &idx
))
7461 default_originate
= DEFAULT_ORIGINATE_ALWAYS
;
7462 /* Get metric value */
7463 else if (argv_find(argv
, argc
, "(0-16777214)", &idx
)) {
7464 if (!str2metric(argv
[idx
]->arg
, &metric
))
7467 /* Get metric type. */
7468 else if (argv_find(argv
, argc
, "(1-2)", &idx
)) {
7469 if (!str2metric_type(argv
[idx
]->arg
, &type
))
7473 else if (argv_find(argv
, argc
, "WORD", &idx
))
7474 ospf_routemap_set(red
, argv
[idx
]->arg
);
7476 ospf_routemap_unset(red
);
7478 return ospf_redistribute_default_set(ospf
, default_originate
, type
,
7482 DEFUN (no_ospf_default_information_originate
,
7483 no_ospf_default_information_originate_cmd
,
7484 "no default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7486 "Control distribution of default information\n"
7487 "Distribute a default route\n"
7488 "Always advertise default route\n"
7489 "OSPF default metric\n"
7491 "OSPF metric type for default routes\n"
7492 "Set OSPF External Type 1 metrics\n"
7493 "Set OSPF External Type 2 metrics\n"
7494 "Route map reference\n"
7495 "Pointer to route-map entries\n")
7497 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7498 struct prefix_ipv4 p
;
7499 struct ospf_external
*ext
;
7500 struct ospf_redist
*red
;
7503 p
.prefix
.s_addr
= 0;
7506 ospf_external_lsa_flush(ospf
, DEFAULT_ROUTE
, &p
, 0);
7508 if ((ext
= ospf_external_lookup(DEFAULT_ROUTE
, 0))
7509 && EXTERNAL_INFO(ext
)) {
7510 ospf_external_info_delete(DEFAULT_ROUTE
, 0, p
);
7511 ospf_external_del(DEFAULT_ROUTE
, 0);
7514 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
7518 ospf_routemap_unset(red
);
7519 return ospf_redistribute_default_unset(ospf
);
7522 DEFUN (ospf_default_metric
,
7523 ospf_default_metric_cmd
,
7524 "default-metric (0-16777214)",
7525 "Set metric of redistributed routes\n"
7528 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7532 if (!str2metric(argv
[idx_number
]->arg
, &metric
))
7535 ospf
->default_metric
= metric
;
7540 DEFUN (no_ospf_default_metric
,
7541 no_ospf_default_metric_cmd
,
7542 "no default-metric [(0-16777214)]",
7544 "Set metric of redistributed routes\n"
7547 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7549 ospf
->default_metric
= -1;
7555 DEFUN (ospf_distance
,
7558 "Administrative distance\n"
7559 "OSPF Administrative distance\n")
7561 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7564 ospf
->distance_all
= atoi(argv
[idx_number
]->arg
);
7569 DEFUN (no_ospf_distance
,
7570 no_ospf_distance_cmd
,
7571 "no distance (1-255)",
7573 "Administrative distance\n"
7574 "OSPF Administrative distance\n")
7576 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7578 ospf
->distance_all
= 0;
7583 DEFUN (no_ospf_distance_ospf
,
7584 no_ospf_distance_ospf_cmd
,
7585 "no distance ospf [{intra-area [(1-255)]|inter-area [(1-255)]|external [(1-255)]}]",
7587 "Administrative distance\n"
7588 "OSPF administrative distance\n"
7589 "Intra-area routes\n"
7590 "Distance for intra-area routes\n"
7591 "Inter-area routes\n"
7592 "Distance for inter-area routes\n"
7594 "Distance for external routes\n")
7596 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7602 if (argv_find(argv
, argc
, "intra-area", &idx
) || argc
== 3)
7603 idx
= ospf
->distance_intra
= 0;
7604 if (argv_find(argv
, argc
, "inter-area", &idx
) || argc
== 3)
7605 idx
= ospf
->distance_inter
= 0;
7606 if (argv_find(argv
, argc
, "external", &idx
) || argc
== 3)
7607 ospf
->distance_external
= 0;
7612 DEFUN (ospf_distance_ospf
,
7613 ospf_distance_ospf_cmd
,
7614 "distance ospf {intra-area (1-255)|inter-area (1-255)|external (1-255)}",
7615 "Administrative distance\n"
7616 "OSPF administrative distance\n"
7617 "Intra-area routes\n"
7618 "Distance for intra-area routes\n"
7619 "Inter-area routes\n"
7620 "Distance for inter-area routes\n"
7622 "Distance for external routes\n")
7624 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7627 if (argv_find(argv
, argc
, "intra-area", &idx
))
7628 ospf
->distance_intra
= atoi(argv
[idx
+ 1]->arg
);
7630 if (argv_find(argv
, argc
, "inter-area", &idx
))
7631 ospf
->distance_inter
= atoi(argv
[idx
+ 1]->arg
);
7633 if (argv_find(argv
, argc
, "external", &idx
))
7634 ospf
->distance_external
= atoi(argv
[idx
+ 1]->arg
);
7640 DEFUN (ospf_distance_source
,
7641 ospf_distance_source_cmd
,
7642 "distance (1-255) A.B.C.D/M",
7643 "Administrative distance\n"
7645 "IP source prefix\n")
7647 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7649 int idx_ipv4_prefixlen
= 2;
7654 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
7659 DEFUN (no_ospf_distance_source
,
7660 no_ospf_distance_source_cmd
,
7661 "no distance (1-255) A.B.C.D/M",
7663 "Administrative distance\n"
7665 "IP source prefix\n")
7667 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7669 int idx_ipv4_prefixlen
= 3;
7674 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
7679 DEFUN (ospf_distance_source_access_list
,
7680 ospf_distance_source_access_list_cmd
,
7681 "distance (1-255) A.B.C.D/M WORD",
7682 "Administrative distance\n"
7684 "IP source prefix\n"
7685 "Access list name\n")
7687 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7689 int idx_ipv4_prefixlen
= 2;
7695 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
7700 DEFUN (no_ospf_distance_source_access_list
,
7701 no_ospf_distance_source_access_list_cmd
,
7702 "no distance (1-255) A.B.C.D/M WORD",
7704 "Administrative distance\n"
7706 "IP source prefix\n"
7707 "Access list name\n")
7709 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7711 int idx_ipv4_prefixlen
= 3;
7717 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
7723 DEFUN (ip_ospf_mtu_ignore
,
7724 ip_ospf_mtu_ignore_addr_cmd
,
7725 "ip ospf mtu-ignore [A.B.C.D]",
7727 "OSPF interface commands\n"
7728 "Disable MTU mismatch detection on this interface\n"
7729 "Address of interface")
7731 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7733 struct in_addr addr
;
7736 struct ospf_if_params
*params
;
7737 params
= IF_DEF_PARAMS(ifp
);
7740 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7743 "Please specify interface address by A.B.C.D%s",
7747 params
= ospf_get_if_params(ifp
, addr
);
7748 ospf_if_update_params(ifp
, addr
);
7750 params
->mtu_ignore
= 1;
7751 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
7752 SET_IF_PARAM(params
, mtu_ignore
);
7754 UNSET_IF_PARAM(params
, mtu_ignore
);
7755 if (params
!= IF_DEF_PARAMS(ifp
)) {
7756 ospf_free_if_params(ifp
, addr
);
7757 ospf_if_update_params(ifp
, addr
);
7763 DEFUN (no_ip_ospf_mtu_ignore
,
7764 no_ip_ospf_mtu_ignore_addr_cmd
,
7765 "no ip ospf mtu-ignore [A.B.C.D]",
7767 "OSPF interface commands\n"
7768 "Disable MTU mismatch detection on this interface\n"
7769 "Address of interface")
7771 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7773 struct in_addr addr
;
7776 struct ospf_if_params
*params
;
7777 params
= IF_DEF_PARAMS(ifp
);
7780 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7783 "Please specify interface address by A.B.C.D%s",
7787 params
= ospf_get_if_params(ifp
, addr
);
7788 ospf_if_update_params(ifp
, addr
);
7790 params
->mtu_ignore
= 0;
7791 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
7792 SET_IF_PARAM(params
, mtu_ignore
);
7794 UNSET_IF_PARAM(params
, mtu_ignore
);
7795 if (params
!= IF_DEF_PARAMS(ifp
)) {
7796 ospf_free_if_params(ifp
, addr
);
7797 ospf_if_update_params(ifp
, addr
);
7804 DEFUN (ospf_max_metric_router_lsa_admin
,
7805 ospf_max_metric_router_lsa_admin_cmd
,
7806 "max-metric router-lsa administrative",
7807 "OSPF maximum / infinite-distance metric\n"
7808 "Advertise own Router-LSA with infinite distance (stub router)\n"
7809 "Administratively applied, for an indefinite period\n")
7811 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7812 struct listnode
*ln
;
7813 struct ospf_area
*area
;
7815 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
7816 SET_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
7818 if (!CHECK_FLAG(area
->stub_router_state
,
7819 OSPF_AREA_IS_STUB_ROUTED
))
7820 ospf_router_lsa_update_area(area
);
7823 /* Allows for areas configured later to get the property */
7824 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_SET
;
7829 DEFUN (no_ospf_max_metric_router_lsa_admin
,
7830 no_ospf_max_metric_router_lsa_admin_cmd
,
7831 "no max-metric router-lsa administrative",
7833 "OSPF maximum / infinite-distance metric\n"
7834 "Advertise own Router-LSA with infinite distance (stub router)\n"
7835 "Administratively applied, for an indefinite period\n")
7837 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7838 struct listnode
*ln
;
7839 struct ospf_area
*area
;
7841 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
7842 UNSET_FLAG(area
->stub_router_state
,
7843 OSPF_AREA_ADMIN_STUB_ROUTED
);
7845 /* Don't trample on the start-up stub timer */
7846 if (CHECK_FLAG(area
->stub_router_state
,
7847 OSPF_AREA_IS_STUB_ROUTED
)
7848 && !area
->t_stub_router
) {
7849 UNSET_FLAG(area
->stub_router_state
,
7850 OSPF_AREA_IS_STUB_ROUTED
);
7851 ospf_router_lsa_update_area(area
);
7854 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET
;
7858 DEFUN (ospf_max_metric_router_lsa_startup
,
7859 ospf_max_metric_router_lsa_startup_cmd
,
7860 "max-metric router-lsa on-startup (5-86400)",
7861 "OSPF maximum / infinite-distance metric\n"
7862 "Advertise own Router-LSA with infinite distance (stub router)\n"
7863 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7864 "Time (seconds) to advertise self as stub-router\n")
7866 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7868 unsigned int seconds
;
7871 vty_out(vty
, "%% Must supply stub-router period");
7875 VTY_GET_INTEGER("stub-router startup period", seconds
,
7876 argv
[idx_number
]->arg
);
7878 ospf
->stub_router_startup_time
= seconds
;
7883 DEFUN (no_ospf_max_metric_router_lsa_startup
,
7884 no_ospf_max_metric_router_lsa_startup_cmd
,
7885 "no max-metric router-lsa on-startup [(5-86400)]",
7887 "OSPF maximum / infinite-distance metric\n"
7888 "Advertise own Router-LSA with infinite distance (stub router)\n"
7889 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7890 "Time (seconds) to advertise self as stub-router\n")
7892 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7893 struct listnode
*ln
;
7894 struct ospf_area
*area
;
7896 ospf
->stub_router_startup_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
7898 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
7899 SET_FLAG(area
->stub_router_state
,
7900 OSPF_AREA_WAS_START_STUB_ROUTED
);
7901 OSPF_TIMER_OFF(area
->t_stub_router
);
7903 /* Don't trample on admin stub routed */
7904 if (!CHECK_FLAG(area
->stub_router_state
,
7905 OSPF_AREA_ADMIN_STUB_ROUTED
)) {
7906 UNSET_FLAG(area
->stub_router_state
,
7907 OSPF_AREA_IS_STUB_ROUTED
);
7908 ospf_router_lsa_update_area(area
);
7915 DEFUN (ospf_max_metric_router_lsa_shutdown
,
7916 ospf_max_metric_router_lsa_shutdown_cmd
,
7917 "max-metric router-lsa on-shutdown (5-100)",
7918 "OSPF maximum / infinite-distance metric\n"
7919 "Advertise own Router-LSA with infinite distance (stub router)\n"
7920 "Advertise stub-router prior to full shutdown of OSPF\n"
7921 "Time (seconds) to wait till full shutdown\n")
7923 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7925 unsigned int seconds
;
7928 vty_out(vty
, "%% Must supply stub-router shutdown period");
7932 VTY_GET_INTEGER("stub-router shutdown wait period", seconds
,
7933 argv
[idx_number
]->arg
);
7935 ospf
->stub_router_shutdown_time
= seconds
;
7940 DEFUN (no_ospf_max_metric_router_lsa_shutdown
,
7941 no_ospf_max_metric_router_lsa_shutdown_cmd
,
7942 "no max-metric router-lsa on-shutdown [(5-100)]",
7944 "OSPF maximum / infinite-distance metric\n"
7945 "Advertise own Router-LSA with infinite distance (stub router)\n"
7946 "Advertise stub-router prior to full shutdown of OSPF\n"
7947 "Time (seconds) to wait till full shutdown\n")
7949 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7951 ospf
->stub_router_shutdown_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
7956 static void config_write_stub_router(struct vty
*vty
, struct ospf
*ospf
)
7958 struct listnode
*ln
;
7959 struct ospf_area
*area
;
7961 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
7962 vty_out(vty
, " max-metric router-lsa on-startup %u%s",
7963 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
7964 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
7965 vty_out(vty
, " max-metric router-lsa on-shutdown %u%s",
7966 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
7967 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
7968 if (CHECK_FLAG(area
->stub_router_state
,
7969 OSPF_AREA_ADMIN_STUB_ROUTED
)) {
7970 vty_out(vty
, " max-metric router-lsa administrative%s",
7978 static void show_ip_ospf_route_network(struct vty
*vty
, struct route_table
*rt
)
7980 struct route_node
*rn
;
7981 struct ospf_route
* or ;
7982 struct listnode
*pnode
, *pnnode
;
7983 struct ospf_path
*path
;
7985 vty_out(vty
, "============ OSPF network routing table ============%s",
7988 for (rn
= route_top(rt
); rn
; rn
= route_next(rn
))
7989 if ((or = rn
->info
) != NULL
) {
7991 snprintf(buf1
, 19, "%s/%d", inet_ntoa(rn
->p
.u
.prefix4
),
7994 switch (or->path_type
) {
7995 case OSPF_PATH_INTER_AREA
:
7996 if (or->type
== OSPF_DESTINATION_NETWORK
)
7998 "N IA %-18s [%d] area: %s%s",
8000 inet_ntoa(or->u
.std
.area_id
),
8002 else if (or->type
== OSPF_DESTINATION_DISCARD
)
8004 "D IA %-18s Discard entry%s",
8007 case OSPF_PATH_INTRA_AREA
:
8008 vty_out(vty
, "N %-18s [%d] area: %s%s",
8010 inet_ntoa(or->u
.std
.area_id
),
8017 if (or->type
== OSPF_DESTINATION_NETWORK
)
8018 for (ALL_LIST_ELEMENTS(or->paths
, pnode
, pnnode
,
8020 if (if_lookup_by_index(path
->ifindex
,
8022 if (path
->nexthop
.s_addr
== 0)
8024 "%24s directly attached to %s%s",
8032 "%24s via %s, %s%s",
8043 vty_out(vty
, "%s", VTY_NEWLINE
);
8046 static void show_ip_ospf_route_router(struct vty
*vty
, struct route_table
*rtrs
)
8048 struct route_node
*rn
;
8049 struct ospf_route
* or ;
8050 struct listnode
*pnode
;
8051 struct listnode
*node
;
8052 struct ospf_path
*path
;
8054 vty_out(vty
, "============ OSPF router routing table =============%s",
8056 for (rn
= route_top(rtrs
); rn
; rn
= route_next(rn
))
8060 vty_out(vty
, "R %-15s ",
8061 inet_ntoa(rn
->p
.u
.prefix4
));
8063 for (ALL_LIST_ELEMENTS_RO((struct list
*)rn
->info
, node
,
8066 vty_out(vty
, "%24s", "");
8069 vty_out(vty
, "%s [%d] area: %s",
8070 (or->path_type
== OSPF_PATH_INTER_AREA
8073 or->cost
, inet_ntoa(or->u
.std
.area_id
));
8075 vty_out(vty
, "%s%s%s",
8076 (or->u
.std
.flags
& ROUTER_LSA_BORDER
8079 (or->u
.std
.flags
& ROUTER_LSA_EXTERNAL
8084 for (ALL_LIST_ELEMENTS_RO(or->paths
, pnode
,
8086 if (if_lookup_by_index(path
->ifindex
,
8088 if (path
->nexthop
.s_addr
== 0)
8090 "%24s directly attached to %s%s",
8098 "%24s via %s, %s%s",
8110 vty_out(vty
, "%s", VTY_NEWLINE
);
8113 static void show_ip_ospf_route_external(struct vty
*vty
, struct route_table
*rt
)
8115 struct route_node
*rn
;
8116 struct ospf_route
*er
;
8117 struct listnode
*pnode
, *pnnode
;
8118 struct ospf_path
*path
;
8120 vty_out(vty
, "============ OSPF external routing table ===========%s",
8122 for (rn
= route_top(rt
); rn
; rn
= route_next(rn
))
8123 if ((er
= rn
->info
) != NULL
) {
8125 snprintf(buf1
, 19, "%s/%d", inet_ntoa(rn
->p
.u
.prefix4
),
8128 switch (er
->path_type
) {
8129 case OSPF_PATH_TYPE1_EXTERNAL
:
8131 "N E1 %-18s [%d] tag: %" ROUTE_TAG_PRI
8133 buf1
, er
->cost
, er
->u
.ext
.tag
,
8136 case OSPF_PATH_TYPE2_EXTERNAL
:
8138 "N E2 %-18s [%d/%d] tag: %" ROUTE_TAG_PRI
8140 buf1
, er
->cost
, er
->u
.ext
.type2_cost
,
8141 er
->u
.ext
.tag
, VTY_NEWLINE
);
8145 for (ALL_LIST_ELEMENTS(er
->paths
, pnode
, pnnode
,
8147 if (if_lookup_by_index(path
->ifindex
,
8149 if (path
->nexthop
.s_addr
== 0)
8151 "%24s directly attached to %s%s",
8159 "%24s via %s, %s%s",
8170 vty_out(vty
, "%s", VTY_NEWLINE
);
8173 static int show_ip_ospf_border_routers_common(struct vty
*vty
,
8177 vty_out(vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
,
8178 ospf
->instance
, VTY_NEWLINE
, VTY_NEWLINE
);
8180 if (ospf
->new_table
== NULL
) {
8181 vty_out(vty
, "No OSPF routing information exist%s",
8186 /* Show Network routes.
8187 show_ip_ospf_route_network (vty, ospf->new_table); */
8189 /* Show Router routes. */
8190 show_ip_ospf_route_router(vty
, ospf
->new_rtrs
);
8192 vty_out(vty
, "%s", VTY_NEWLINE
);
8197 DEFUN (show_ip_ospf_border_routers
,
8198 show_ip_ospf_border_routers_cmd
,
8199 "show ip ospf border-routers",
8202 "OSPF information\n"
8203 "Show all the ABR's and ASBR's\n")
8207 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
8210 return show_ip_ospf_border_routers_common(vty
, ospf
);
8213 DEFUN (show_ip_ospf_instance_border_routers
,
8214 show_ip_ospf_instance_border_routers_cmd
,
8215 "show ip ospf (1-65535) border-routers",
8218 "OSPF information\n"
8220 "Show all the ABR's and ASBR's\n")
8224 u_short instance
= 0;
8226 VTY_GET_INTEGER("Instance", instance
, argv
[idx_number
]->arg
);
8227 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
8228 || !ospf
->oi_running
)
8231 return show_ip_ospf_border_routers_common(vty
, ospf
);
8234 static int show_ip_ospf_route_common(struct vty
*vty
, struct ospf
*ospf
)
8237 vty_out(vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
,
8238 ospf
->instance
, VTY_NEWLINE
, VTY_NEWLINE
);
8240 if (ospf
->new_table
== NULL
) {
8241 vty_out(vty
, "No OSPF routing information exist%s",
8246 /* Show Network routes. */
8247 show_ip_ospf_route_network(vty
, ospf
->new_table
);
8249 /* Show Router routes. */
8250 show_ip_ospf_route_router(vty
, ospf
->new_rtrs
);
8252 /* Show AS External routes. */
8253 show_ip_ospf_route_external(vty
, ospf
->old_external_route
);
8255 vty_out(vty
, "%s", VTY_NEWLINE
);
8260 DEFUN (show_ip_ospf_route
,
8261 show_ip_ospf_route_cmd
,
8262 "show ip ospf route",
8265 "OSPF information\n"
8266 "OSPF routing table\n")
8270 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
8273 return show_ip_ospf_route_common(vty
, ospf
);
8276 DEFUN (show_ip_ospf_instance_route
,
8277 show_ip_ospf_instance_route_cmd
,
8278 "show ip ospf (1-65535) route",
8281 "OSPF information\n"
8283 "OSPF routing table\n")
8287 u_short instance
= 0;
8289 VTY_GET_INTEGER("Instance", instance
, argv
[idx_number
]->arg
);
8290 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
8291 || !ospf
->oi_running
)
8294 return show_ip_ospf_route_common(vty
, ospf
);
8297 const char *ospf_abr_type_str
[] = {"unknown", "standard", "ibm", "cisco",
8300 const char *ospf_shortcut_mode_str
[] = {"default", "enable", "disable"};
8302 const char *ospf_int_type_str
[] = {"unknown", /* should never be used. */
8303 "point-to-point", "broadcast",
8304 "non-broadcast", "point-to-multipoint",
8305 "virtual-link", /* should never be used. */
8308 /* Configuration write function for ospfd. */
8309 static int config_write_interface(struct vty
*vty
)
8311 struct listnode
*n1
, *n2
;
8312 struct interface
*ifp
;
8313 struct crypt_key
*ck
;
8315 struct route_node
*rn
= NULL
;
8316 struct ospf_if_params
*params
;
8317 struct ospf
*ospf
= ospf_lookup();
8319 for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT
), n1
, ifp
)) {
8320 if (memcmp(ifp
->name
, "VLINK", 5) == 0)
8323 if (ifp
->ifindex
== IFINDEX_DELETED
)
8326 vty_out(vty
, "!%s", VTY_NEWLINE
);
8327 vty_out(vty
, "interface %s%s", ifp
->name
, VTY_NEWLINE
);
8329 vty_out(vty
, " description %s%s", ifp
->desc
,
8334 params
= IF_DEF_PARAMS(ifp
);
8337 /* Interface Network print. */
8338 if (OSPF_IF_PARAM_CONFIGURED(params
, type
)
8339 && params
->type
!= OSPF_IFTYPE_LOOPBACK
) {
8340 if (params
->type
!= ospf_default_iftype(ifp
)) {
8341 vty_out(vty
, " ip ospf network %s",
8344 if (params
!= IF_DEF_PARAMS(ifp
))
8348 vty_out(vty
, "%s", VTY_NEWLINE
);
8352 /* OSPF interface authentication print */
8353 if (OSPF_IF_PARAM_CONFIGURED(params
, auth_type
)
8354 && params
->auth_type
!= OSPF_AUTH_NOTSET
) {
8355 const char *auth_str
;
8357 /* Translation tables are not that much help
8359 of the simple option */
8360 switch (params
->auth_type
) {
8362 case OSPF_AUTH_NULL
:
8366 case OSPF_AUTH_SIMPLE
:
8370 case OSPF_AUTH_CRYPTOGRAPHIC
:
8371 auth_str
= " message-digest";
8379 vty_out(vty
, " ip ospf authentication%s",
8381 if (params
!= IF_DEF_PARAMS(ifp
))
8383 inet_ntoa(rn
->p
.u
.prefix4
));
8384 vty_out(vty
, "%s", VTY_NEWLINE
);
8387 /* Simple Authentication Password print. */
8388 if (OSPF_IF_PARAM_CONFIGURED(params
, auth_simple
)
8389 && params
->auth_simple
[0] != '\0') {
8390 vty_out(vty
, " ip ospf authentication-key %s",
8391 params
->auth_simple
);
8392 if (params
!= IF_DEF_PARAMS(ifp
))
8394 inet_ntoa(rn
->p
.u
.prefix4
));
8395 vty_out(vty
, "%s", VTY_NEWLINE
);
8398 /* Cryptographic Authentication Key print. */
8399 for (ALL_LIST_ELEMENTS_RO(params
->auth_crypt
, n2
, ck
)) {
8401 " ip ospf message-digest-key %d md5 %s",
8402 ck
->key_id
, ck
->auth_key
);
8403 if (params
!= IF_DEF_PARAMS(ifp
))
8405 inet_ntoa(rn
->p
.u
.prefix4
));
8406 vty_out(vty
, "%s", VTY_NEWLINE
);
8409 /* Interface Output Cost print. */
8410 if (OSPF_IF_PARAM_CONFIGURED(params
, output_cost_cmd
)) {
8411 vty_out(vty
, " ip ospf cost %u",
8412 params
->output_cost_cmd
);
8413 if (params
!= IF_DEF_PARAMS(ifp
))
8415 inet_ntoa(rn
->p
.u
.prefix4
));
8416 vty_out(vty
, "%s", VTY_NEWLINE
);
8419 /* Hello Interval print. */
8420 if (OSPF_IF_PARAM_CONFIGURED(params
, v_hello
)
8421 && params
->v_hello
!= OSPF_HELLO_INTERVAL_DEFAULT
) {
8422 vty_out(vty
, " ip ospf hello-interval %u",
8424 if (params
!= IF_DEF_PARAMS(ifp
))
8426 inet_ntoa(rn
->p
.u
.prefix4
));
8427 vty_out(vty
, "%s", VTY_NEWLINE
);
8431 /* Router Dead Interval print. */
8432 if (OSPF_IF_PARAM_CONFIGURED(params
, v_wait
)
8434 != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
) {
8435 vty_out(vty
, " ip ospf dead-interval ");
8438 if (OSPF_IF_PARAM_CONFIGURED(params
,
8441 "minimal hello-multiplier %d",
8442 params
->fast_hello
);
8444 vty_out(vty
, "%u", params
->v_wait
);
8446 if (params
!= IF_DEF_PARAMS(ifp
))
8448 inet_ntoa(rn
->p
.u
.prefix4
));
8449 vty_out(vty
, "%s", VTY_NEWLINE
);
8452 /* Router Priority print. */
8453 if (OSPF_IF_PARAM_CONFIGURED(params
, priority
)
8455 != OSPF_ROUTER_PRIORITY_DEFAULT
) {
8456 vty_out(vty
, " ip ospf priority %u",
8458 if (params
!= IF_DEF_PARAMS(ifp
))
8460 inet_ntoa(rn
->p
.u
.prefix4
));
8461 vty_out(vty
, "%s", VTY_NEWLINE
);
8464 /* Retransmit Interval print. */
8465 if (OSPF_IF_PARAM_CONFIGURED(params
,
8466 retransmit_interval
)
8467 && params
->retransmit_interval
8468 != OSPF_RETRANSMIT_INTERVAL_DEFAULT
) {
8469 vty_out(vty
, " ip ospf retransmit-interval %u",
8470 params
->retransmit_interval
);
8471 if (params
!= IF_DEF_PARAMS(ifp
))
8473 inet_ntoa(rn
->p
.u
.prefix4
));
8474 vty_out(vty
, "%s", VTY_NEWLINE
);
8477 /* Transmit Delay print. */
8478 if (OSPF_IF_PARAM_CONFIGURED(params
, transmit_delay
)
8479 && params
->transmit_delay
8480 != OSPF_TRANSMIT_DELAY_DEFAULT
) {
8481 vty_out(vty
, " ip ospf transmit-delay %u",
8482 params
->transmit_delay
);
8483 if (params
!= IF_DEF_PARAMS(ifp
))
8485 inet_ntoa(rn
->p
.u
.prefix4
));
8486 vty_out(vty
, "%s", VTY_NEWLINE
);
8490 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
8492 vty_out(vty
, " ip ospf %d area %s%s",
8494 inet_ntoa(params
->if_area
),
8497 vty_out(vty
, " ip ospf area %s%s",
8498 inet_ntoa(params
->if_area
),
8503 ospf_bfd_write_config(vty
, params
);
8505 /* MTU ignore print. */
8506 if (OSPF_IF_PARAM_CONFIGURED(params
, mtu_ignore
)
8507 && params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
) {
8508 if (params
->mtu_ignore
== 0)
8509 vty_out(vty
, " no ip ospf mtu-ignore");
8511 vty_out(vty
, " ip ospf mtu-ignore");
8512 if (params
!= IF_DEF_PARAMS(ifp
))
8514 inet_ntoa(rn
->p
.u
.prefix4
));
8515 vty_out(vty
, "%s", VTY_NEWLINE
);
8521 rn
= route_top(IF_OIFS_PARAMS(ifp
));
8523 rn
= route_next(rn
);
8533 ospf_opaque_config_write_if(vty
, ifp
);
8539 static int config_write_network_area(struct vty
*vty
, struct ospf
*ospf
)
8541 struct route_node
*rn
;
8542 u_char buf
[INET_ADDRSTRLEN
];
8544 /* `network area' print. */
8545 for (rn
= route_top(ospf
->networks
); rn
; rn
= route_next(rn
))
8547 struct ospf_network
*n
= rn
->info
;
8549 memset(buf
, 0, INET_ADDRSTRLEN
);
8551 /* Create Area ID string by specified Area ID format. */
8552 if (n
->area_id_fmt
== OSPF_AREA_ID_FMT_DOTTEDQUAD
)
8553 strncpy((char *)buf
, inet_ntoa(n
->area_id
),
8556 sprintf((char *)buf
, "%lu",
8557 (unsigned long int)ntohl(
8558 n
->area_id
.s_addr
));
8560 /* Network print. */
8561 vty_out(vty
, " network %s/%d area %s%s",
8562 inet_ntoa(rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
8569 static int config_write_ospf_area(struct vty
*vty
, struct ospf
*ospf
)
8571 struct listnode
*node
;
8572 struct ospf_area
*area
;
8573 u_char buf
[INET_ADDRSTRLEN
];
8575 /* Area configuration print. */
8576 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
8577 struct route_node
*rn1
;
8579 area_id2str((char *)buf
, INET_ADDRSTRLEN
, &area
->area_id
,
8582 if (area
->auth_type
!= OSPF_AUTH_NULL
) {
8583 if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
8584 vty_out(vty
, " area %s authentication%s", buf
,
8588 " area %s authentication message-digest%s",
8592 if (area
->shortcut_configured
!= OSPF_SHORTCUT_DEFAULT
)
8593 vty_out(vty
, " area %s shortcut %s%s", buf
,
8594 ospf_shortcut_mode_str
8595 [area
->shortcut_configured
],
8598 if ((area
->external_routing
== OSPF_AREA_STUB
)
8599 || (area
->external_routing
== OSPF_AREA_NSSA
)) {
8600 if (area
->external_routing
== OSPF_AREA_STUB
)
8601 vty_out(vty
, " area %s stub", buf
);
8602 else if (area
->external_routing
== OSPF_AREA_NSSA
) {
8603 vty_out(vty
, " area %s nssa", buf
);
8604 switch (area
->NSSATranslatorRole
) {
8605 case OSPF_NSSA_ROLE_NEVER
:
8606 vty_out(vty
, " translate-never");
8608 case OSPF_NSSA_ROLE_ALWAYS
:
8609 vty_out(vty
, " translate-always");
8611 case OSPF_NSSA_ROLE_CANDIDATE
:
8613 vty_out(vty
, " translate-candidate");
8617 if (area
->no_summary
)
8618 vty_out(vty
, " no-summary");
8620 vty_out(vty
, "%s", VTY_NEWLINE
);
8622 if (area
->default_cost
!= 1)
8623 vty_out(vty
, " area %s default-cost %d%s", buf
,
8624 area
->default_cost
, VTY_NEWLINE
);
8627 for (rn1
= route_top(area
->ranges
); rn1
; rn1
= route_next(rn1
))
8629 struct ospf_area_range
*range
= rn1
->info
;
8631 vty_out(vty
, " area %s range %s/%d", buf
,
8632 inet_ntoa(rn1
->p
.u
.prefix4
),
8635 if (range
->cost_config
8636 != OSPF_AREA_RANGE_COST_UNSPEC
)
8637 vty_out(vty
, " cost %d",
8638 range
->cost_config
);
8640 if (!CHECK_FLAG(range
->flags
,
8641 OSPF_AREA_RANGE_ADVERTISE
))
8642 vty_out(vty
, " not-advertise");
8644 if (CHECK_FLAG(range
->flags
,
8645 OSPF_AREA_RANGE_SUBSTITUTE
))
8646 vty_out(vty
, " substitute %s/%d",
8647 inet_ntoa(range
->subst_addr
),
8648 range
->subst_masklen
);
8650 vty_out(vty
, "%s", VTY_NEWLINE
);
8653 if (EXPORT_NAME(area
))
8654 vty_out(vty
, " area %s export-list %s%s", buf
,
8655 EXPORT_NAME(area
), VTY_NEWLINE
);
8657 if (IMPORT_NAME(area
))
8658 vty_out(vty
, " area %s import-list %s%s", buf
,
8659 IMPORT_NAME(area
), VTY_NEWLINE
);
8661 if (PREFIX_NAME_IN(area
))
8662 vty_out(vty
, " area %s filter-list prefix %s in%s", buf
,
8663 PREFIX_NAME_IN(area
), VTY_NEWLINE
);
8665 if (PREFIX_NAME_OUT(area
))
8666 vty_out(vty
, " area %s filter-list prefix %s out%s",
8667 buf
, PREFIX_NAME_OUT(area
), VTY_NEWLINE
);
8673 static int config_write_ospf_nbr_nbma(struct vty
*vty
, struct ospf
*ospf
)
8675 struct ospf_nbr_nbma
*nbr_nbma
;
8676 struct route_node
*rn
;
8678 /* Static Neighbor configuration print. */
8679 for (rn
= route_top(ospf
->nbr_nbma
); rn
; rn
= route_next(rn
))
8680 if ((nbr_nbma
= rn
->info
)) {
8681 vty_out(vty
, " neighbor %s", inet_ntoa(nbr_nbma
->addr
));
8683 if (nbr_nbma
->priority
8684 != OSPF_NEIGHBOR_PRIORITY_DEFAULT
)
8685 vty_out(vty
, " priority %d",
8686 nbr_nbma
->priority
);
8688 if (nbr_nbma
->v_poll
!= OSPF_POLL_INTERVAL_DEFAULT
)
8689 vty_out(vty
, " poll-interval %d",
8692 vty_out(vty
, "%s", VTY_NEWLINE
);
8698 static int config_write_virtual_link(struct vty
*vty
, struct ospf
*ospf
)
8700 struct listnode
*node
;
8701 struct ospf_vl_data
*vl_data
;
8702 char buf
[INET_ADDRSTRLEN
];
8704 /* Virtual-Link print */
8705 for (ALL_LIST_ELEMENTS_RO(ospf
->vlinks
, node
, vl_data
)) {
8706 struct listnode
*n2
;
8707 struct crypt_key
*ck
;
8708 struct ospf_interface
*oi
;
8710 if (vl_data
!= NULL
) {
8711 memset(buf
, 0, INET_ADDRSTRLEN
);
8713 area_id2str(buf
, sizeof(buf
), &vl_data
->vl_area_id
,
8714 vl_data
->vl_area_id_fmt
);
8715 oi
= vl_data
->vl_oi
;
8718 if (OSPF_IF_PARAM(oi
, v_hello
)
8719 != OSPF_HELLO_INTERVAL_DEFAULT
8720 || OSPF_IF_PARAM(oi
, v_wait
)
8721 != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
8722 || OSPF_IF_PARAM(oi
, retransmit_interval
)
8723 != OSPF_RETRANSMIT_INTERVAL_DEFAULT
8724 || OSPF_IF_PARAM(oi
, transmit_delay
)
8725 != OSPF_TRANSMIT_DELAY_DEFAULT
)
8727 " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
8728 buf
, inet_ntoa(vl_data
->vl_peer
),
8729 OSPF_IF_PARAM(oi
, v_hello
),
8730 OSPF_IF_PARAM(oi
, retransmit_interval
),
8731 OSPF_IF_PARAM(oi
, transmit_delay
),
8732 OSPF_IF_PARAM(oi
, v_wait
), VTY_NEWLINE
);
8734 vty_out(vty
, " area %s virtual-link %s%s", buf
,
8735 inet_ntoa(vl_data
->vl_peer
),
8738 if (IF_DEF_PARAMS(vl_data
->vl_oi
->ifp
)->auth_simple
[0]
8741 " area %s virtual-link %s authentication-key %s%s",
8742 buf
, inet_ntoa(vl_data
->vl_peer
),
8743 IF_DEF_PARAMS(vl_data
->vl_oi
->ifp
)
8747 for (ALL_LIST_ELEMENTS_RO(
8748 IF_DEF_PARAMS(vl_data
->vl_oi
->ifp
)
8752 " area %s virtual-link %s"
8753 " message-digest-key %d md5 %s%s",
8754 buf
, inet_ntoa(vl_data
->vl_peer
),
8755 ck
->key_id
, ck
->auth_key
, VTY_NEWLINE
);
8763 static int config_write_ospf_redistribute(struct vty
*vty
, struct ospf
*ospf
)
8767 /* redistribute print. */
8768 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++) {
8769 struct list
*red_list
;
8770 struct listnode
*node
;
8771 struct ospf_redist
*red
;
8773 red_list
= ospf
->redist
[type
];
8777 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
8778 vty_out(vty
, " redistribute %s",
8779 zebra_route_string(type
));
8781 vty_out(vty
, " %d", red
->instance
);
8783 if (red
->dmetric
.value
>= 0)
8784 vty_out(vty
, " metric %d", red
->dmetric
.value
);
8786 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
8787 vty_out(vty
, " metric-type 1");
8789 if (ROUTEMAP_NAME(red
))
8790 vty_out(vty
, " route-map %s",
8791 ROUTEMAP_NAME(red
));
8793 vty_out(vty
, "%s", VTY_NEWLINE
);
8800 static int config_write_ospf_default_metric(struct vty
*vty
, struct ospf
*ospf
)
8802 if (ospf
->default_metric
!= -1)
8803 vty_out(vty
, " default-metric %d%s", ospf
->default_metric
,
8808 static int config_write_ospf_distribute(struct vty
*vty
, struct ospf
*ospf
)
8811 struct ospf_redist
*red
;
8814 /* distribute-list print. */
8815 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
8816 if (DISTRIBUTE_NAME(ospf
, type
))
8817 vty_out(vty
, " distribute-list %s out %s%s",
8818 DISTRIBUTE_NAME(ospf
, type
),
8819 zebra_route_string(type
), VTY_NEWLINE
);
8821 /* default-information print. */
8822 if (ospf
->default_originate
!= DEFAULT_ORIGINATE_NONE
) {
8823 vty_out(vty
, " default-information originate");
8824 if (ospf
->default_originate
== DEFAULT_ORIGINATE_ALWAYS
)
8825 vty_out(vty
, " always");
8827 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
8829 if (red
->dmetric
.value
>= 0)
8830 vty_out(vty
, " metric %d",
8831 red
->dmetric
.value
);
8832 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
8833 vty_out(vty
, " metric-type 1");
8835 if (ROUTEMAP_NAME(red
))
8836 vty_out(vty
, " route-map %s",
8837 ROUTEMAP_NAME(red
));
8840 vty_out(vty
, "%s", VTY_NEWLINE
);
8847 static int config_write_ospf_distance(struct vty
*vty
, struct ospf
*ospf
)
8849 struct route_node
*rn
;
8850 struct ospf_distance
*odistance
;
8852 if (ospf
->distance_all
)
8853 vty_out(vty
, " distance %d%s", ospf
->distance_all
, VTY_NEWLINE
);
8855 if (ospf
->distance_intra
|| ospf
->distance_inter
8856 || ospf
->distance_external
) {
8857 vty_out(vty
, " distance ospf");
8859 if (ospf
->distance_intra
)
8860 vty_out(vty
, " intra-area %d", ospf
->distance_intra
);
8861 if (ospf
->distance_inter
)
8862 vty_out(vty
, " inter-area %d", ospf
->distance_inter
);
8863 if (ospf
->distance_external
)
8864 vty_out(vty
, " external %d", ospf
->distance_external
);
8866 vty_out(vty
, "%s", VTY_NEWLINE
);
8869 for (rn
= route_top(ospf
->distance_table
); rn
; rn
= route_next(rn
))
8870 if ((odistance
= rn
->info
) != NULL
) {
8871 vty_out(vty
, " distance %d %s/%d %s%s",
8872 odistance
->distance
, inet_ntoa(rn
->p
.u
.prefix4
),
8874 odistance
->access_list
? odistance
->access_list
8881 /* OSPF configuration write function. */
8882 static int ospf_config_write(struct vty
*vty
)
8885 struct interface
*ifp
;
8886 struct ospf_interface
*oi
;
8887 struct listnode
*node
;
8890 ospf
= ospf_lookup();
8891 if (ospf
!= NULL
&& ospf
->oi_running
) {
8892 /* `router ospf' print. */
8894 vty_out(vty
, "router ospf %d%s", ospf
->instance
,
8897 vty_out(vty
, "router ospf%s", VTY_NEWLINE
);
8901 if (!ospf
->networks
)
8904 /* Router ID print. */
8905 if (ospf
->router_id_static
.s_addr
!= 0)
8906 vty_out(vty
, " ospf router-id %s%s",
8907 inet_ntoa(ospf
->router_id_static
), VTY_NEWLINE
);
8909 /* ABR type print. */
8910 if (ospf
->abr_type
!= OSPF_ABR_DEFAULT
)
8911 vty_out(vty
, " ospf abr-type %s%s",
8912 ospf_abr_type_str
[ospf
->abr_type
], VTY_NEWLINE
);
8914 /* log-adjacency-changes flag print. */
8915 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
)) {
8916 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
8917 vty_out(vty
, " log-adjacency-changes detail%s",
8919 else if (!DFLT_OSPF_LOG_ADJACENCY_CHANGES
)
8920 vty_out(vty
, " log-adjacency-changes%s",
8922 } else if (DFLT_OSPF_LOG_ADJACENCY_CHANGES
) {
8923 vty_out(vty
, " no log-adjacency-changes%s",
8927 /* RFC1583 compatibility flag print -- Compatible with CISCO
8929 if (CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
8930 vty_out(vty
, " compatible rfc1583%s", VTY_NEWLINE
);
8932 /* auto-cost reference-bandwidth configuration. */
8933 if (ospf
->ref_bandwidth
!= OSPF_DEFAULT_REF_BANDWIDTH
) {
8935 "! Important: ensure reference bandwidth "
8936 "is consistent across all routers%s",
8938 vty_out(vty
, " auto-cost reference-bandwidth %d%s",
8939 ospf
->ref_bandwidth
, VTY_NEWLINE
);
8942 /* SPF timers print. */
8943 if (ospf
->spf_delay
!= OSPF_SPF_DELAY_DEFAULT
8944 || ospf
->spf_holdtime
!= OSPF_SPF_HOLDTIME_DEFAULT
8945 || ospf
->spf_max_holdtime
!= OSPF_SPF_MAX_HOLDTIME_DEFAULT
)
8946 vty_out(vty
, " timers throttle spf %d %d %d%s",
8947 ospf
->spf_delay
, ospf
->spf_holdtime
,
8948 ospf
->spf_max_holdtime
, VTY_NEWLINE
);
8950 /* LSA timers print. */
8951 if (ospf
->min_ls_interval
!= OSPF_MIN_LS_INTERVAL
)
8952 vty_out(vty
, " timers throttle lsa all %d%s",
8953 ospf
->min_ls_interval
, VTY_NEWLINE
);
8954 if (ospf
->min_ls_arrival
!= OSPF_MIN_LS_ARRIVAL
)
8955 vty_out(vty
, " timers lsa min-arrival %d%s",
8956 ospf
->min_ls_arrival
, VTY_NEWLINE
);
8958 /* Write multiplier print. */
8959 if (ospf
->write_oi_count
!= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
)
8960 vty_out(vty
, " ospf write-multiplier %d%s",
8961 ospf
->write_oi_count
, VTY_NEWLINE
);
8963 /* Max-metric router-lsa print */
8964 config_write_stub_router(vty
, ospf
);
8966 /* SPF refresh parameters print. */
8967 if (ospf
->lsa_refresh_interval
8968 != OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
8969 vty_out(vty
, " refresh timer %d%s",
8970 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
8972 /* Redistribute information print. */
8973 config_write_ospf_redistribute(vty
, ospf
);
8975 /* passive-interface print. */
8976 if (ospf
->passive_interface_default
== OSPF_IF_PASSIVE
)
8977 vty_out(vty
, " passive-interface default%s",
8980 for (ALL_LIST_ELEMENTS_RO(om
->iflist
, node
, ifp
))
8981 if (OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp
),
8983 && IF_DEF_PARAMS(ifp
)->passive_interface
8984 != ospf
->passive_interface_default
) {
8985 vty_out(vty
, " %spassive-interface %s%s",
8986 IF_DEF_PARAMS(ifp
)->passive_interface
8989 ifp
->name
, VTY_NEWLINE
);
8991 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
8992 if (!OSPF_IF_PARAM_CONFIGURED(oi
->params
,
8995 if (OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(oi
->ifp
),
8996 passive_interface
)) {
8997 if (oi
->params
->passive_interface
8998 == IF_DEF_PARAMS(oi
->ifp
)
8999 ->passive_interface
)
9001 } else if (oi
->params
->passive_interface
9002 == ospf
->passive_interface_default
)
9005 vty_out(vty
, " %spassive-interface %s %s%s",
9006 oi
->params
->passive_interface
? "" : "no ",
9008 inet_ntoa(oi
->address
->u
.prefix4
), VTY_NEWLINE
);
9011 /* Network area print. */
9012 config_write_network_area(vty
, ospf
);
9014 /* Area config print. */
9015 config_write_ospf_area(vty
, ospf
);
9017 /* static neighbor print. */
9018 config_write_ospf_nbr_nbma(vty
, ospf
);
9020 /* Virtual-Link print. */
9021 config_write_virtual_link(vty
, ospf
);
9023 /* Default metric configuration. */
9024 config_write_ospf_default_metric(vty
, ospf
);
9026 /* Distribute-list and default-information print. */
9027 config_write_ospf_distribute(vty
, ospf
);
9029 /* Distance configuration. */
9030 config_write_ospf_distance(vty
, ospf
);
9032 ospf_opaque_config_write_router(vty
, ospf
);
9038 void ospf_vty_show_init(void)
9040 /* "show ip ospf" commands. */
9041 install_element(VIEW_NODE
, &show_ip_ospf_cmd
);
9043 install_element(VIEW_NODE
, &show_ip_ospf_instance_cmd
);
9045 /* "show ip ospf database" commands. */
9046 install_element(VIEW_NODE
, &show_ip_ospf_database_type_adv_router_cmd
);
9047 install_element(VIEW_NODE
, &show_ip_ospf_database_max_cmd
);
9049 install_element(VIEW_NODE
,
9050 &show_ip_ospf_instance_database_type_adv_router_cmd
);
9051 install_element(VIEW_NODE
, &show_ip_ospf_instance_database_cmd
);
9052 install_element(VIEW_NODE
, &show_ip_ospf_instance_database_max_cmd
);
9054 /* "show ip ospf interface" commands. */
9055 install_element(VIEW_NODE
, &show_ip_ospf_interface_cmd
);
9057 install_element(VIEW_NODE
, &show_ip_ospf_instance_interface_cmd
);
9059 /* "show ip ospf neighbor" commands. */
9060 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_int_detail_cmd
);
9061 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_int_cmd
);
9062 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_id_cmd
);
9063 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_detail_all_cmd
);
9064 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_detail_cmd
);
9065 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_cmd
);
9066 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_all_cmd
);
9068 install_element(VIEW_NODE
,
9069 &show_ip_ospf_instance_neighbor_int_detail_cmd
);
9070 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_cmd
);
9071 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_id_cmd
);
9072 install_element(VIEW_NODE
,
9073 &show_ip_ospf_instance_neighbor_detail_all_cmd
);
9074 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_cmd
);
9075 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_cmd
);
9076 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_all_cmd
);
9078 /* "show ip ospf route" commands. */
9079 install_element(VIEW_NODE
, &show_ip_ospf_route_cmd
);
9080 install_element(VIEW_NODE
, &show_ip_ospf_border_routers_cmd
);
9082 install_element(VIEW_NODE
, &show_ip_ospf_instance_route_cmd
);
9083 install_element(VIEW_NODE
, &show_ip_ospf_instance_border_routers_cmd
);
9087 /* ospfd's interface node. */
9088 static struct cmd_node interface_node
= {INTERFACE_NODE
, "%s(config-if)# ", 1};
9090 /* Initialization of OSPF interface. */
9091 static void ospf_vty_if_init(void)
9093 /* Install interface node. */
9094 install_node(&interface_node
, config_write_interface
);
9097 /* "ip ospf authentication" commands. */
9098 install_element(INTERFACE_NODE
, &ip_ospf_authentication_args_addr_cmd
);
9099 install_element(INTERFACE_NODE
, &ip_ospf_authentication_addr_cmd
);
9100 install_element(INTERFACE_NODE
,
9101 &no_ip_ospf_authentication_args_addr_cmd
);
9102 install_element(INTERFACE_NODE
, &no_ip_ospf_authentication_addr_cmd
);
9103 install_element(INTERFACE_NODE
, &ip_ospf_authentication_key_addr_cmd
);
9104 install_element(INTERFACE_NODE
,
9105 &no_ip_ospf_authentication_key_authkey_addr_cmd
);
9106 install_element(INTERFACE_NODE
,
9107 &no_ospf_authentication_key_authkey_addr_cmd
);
9109 /* "ip ospf message-digest-key" commands. */
9110 install_element(INTERFACE_NODE
, &ip_ospf_message_digest_key_cmd
);
9111 install_element(INTERFACE_NODE
, &no_ip_ospf_message_digest_key_cmd
);
9113 /* "ip ospf cost" commands. */
9114 install_element(INTERFACE_NODE
, &ip_ospf_cost_cmd
);
9115 install_element(INTERFACE_NODE
, &no_ip_ospf_cost_cmd
);
9117 /* "ip ospf mtu-ignore" commands. */
9118 install_element(INTERFACE_NODE
, &ip_ospf_mtu_ignore_addr_cmd
);
9119 install_element(INTERFACE_NODE
, &no_ip_ospf_mtu_ignore_addr_cmd
);
9121 /* "ip ospf dead-interval" commands. */
9122 install_element(INTERFACE_NODE
, &ip_ospf_dead_interval_cmd
);
9123 install_element(INTERFACE_NODE
,
9124 &ip_ospf_dead_interval_minimal_addr_cmd
);
9125 install_element(INTERFACE_NODE
, &no_ip_ospf_dead_interval_cmd
);
9127 /* "ip ospf hello-interval" commands. */
9128 install_element(INTERFACE_NODE
, &ip_ospf_hello_interval_cmd
);
9129 install_element(INTERFACE_NODE
, &no_ip_ospf_hello_interval_cmd
);
9131 /* "ip ospf network" commands. */
9132 install_element(INTERFACE_NODE
, &ip_ospf_network_cmd
);
9133 install_element(INTERFACE_NODE
, &no_ip_ospf_network_cmd
);
9135 /* "ip ospf priority" commands. */
9136 install_element(INTERFACE_NODE
, &ip_ospf_priority_cmd
);
9137 install_element(INTERFACE_NODE
, &no_ip_ospf_priority_cmd
);
9139 /* "ip ospf retransmit-interval" commands. */
9140 install_element(INTERFACE_NODE
, &ip_ospf_retransmit_interval_addr_cmd
);
9141 install_element(INTERFACE_NODE
,
9142 &no_ip_ospf_retransmit_interval_addr_cmd
);
9144 /* "ip ospf transmit-delay" commands. */
9145 install_element(INTERFACE_NODE
, &ip_ospf_transmit_delay_addr_cmd
);
9146 install_element(INTERFACE_NODE
, &no_ip_ospf_transmit_delay_addr_cmd
);
9148 /* "ip ospf area" commands. */
9149 install_element(INTERFACE_NODE
, &ip_ospf_area_cmd
);
9150 install_element(INTERFACE_NODE
, &no_ip_ospf_area_cmd
);
9152 /* These commands are compatibitliy for previous version. */
9153 install_element(INTERFACE_NODE
, &ospf_authentication_key_cmd
);
9154 install_element(INTERFACE_NODE
, &ospf_message_digest_key_cmd
);
9155 install_element(INTERFACE_NODE
, &no_ospf_message_digest_key_cmd
);
9156 install_element(INTERFACE_NODE
, &ospf_dead_interval_cmd
);
9157 install_element(INTERFACE_NODE
, &no_ospf_dead_interval_cmd
);
9158 install_element(INTERFACE_NODE
, &ospf_hello_interval_cmd
);
9159 install_element(INTERFACE_NODE
, &no_ospf_hello_interval_cmd
);
9160 install_element(INTERFACE_NODE
, &ospf_cost_cmd
);
9161 install_element(INTERFACE_NODE
, &no_ospf_cost_cmd
);
9162 install_element(INTERFACE_NODE
, &ospf_network_cmd
);
9163 install_element(INTERFACE_NODE
, &no_ospf_network_cmd
);
9164 install_element(INTERFACE_NODE
, &ospf_priority_cmd
);
9165 install_element(INTERFACE_NODE
, &no_ospf_priority_cmd
);
9166 install_element(INTERFACE_NODE
, &ospf_retransmit_interval_cmd
);
9167 install_element(INTERFACE_NODE
, &no_ospf_retransmit_interval_cmd
);
9168 install_element(INTERFACE_NODE
, &ospf_transmit_delay_cmd
);
9169 install_element(INTERFACE_NODE
, &no_ospf_transmit_delay_cmd
);
9172 static void ospf_vty_zebra_init(void)
9174 install_element(OSPF_NODE
, &ospf_redistribute_source_cmd
);
9175 install_element(OSPF_NODE
, &no_ospf_redistribute_source_cmd
);
9176 install_element(OSPF_NODE
, &ospf_redistribute_instance_source_cmd
);
9177 install_element(OSPF_NODE
, &no_ospf_redistribute_instance_source_cmd
);
9179 install_element(OSPF_NODE
, &ospf_distribute_list_out_cmd
);
9180 install_element(OSPF_NODE
, &no_ospf_distribute_list_out_cmd
);
9182 install_element(OSPF_NODE
, &ospf_default_information_originate_cmd
);
9183 install_element(OSPF_NODE
, &no_ospf_default_information_originate_cmd
);
9185 install_element(OSPF_NODE
, &ospf_default_metric_cmd
);
9186 install_element(OSPF_NODE
, &no_ospf_default_metric_cmd
);
9188 install_element(OSPF_NODE
, &ospf_distance_cmd
);
9189 install_element(OSPF_NODE
, &no_ospf_distance_cmd
);
9190 install_element(OSPF_NODE
, &no_ospf_distance_ospf_cmd
);
9191 install_element(OSPF_NODE
, &ospf_distance_ospf_cmd
);
9193 install_element (OSPF_NODE
, &ospf_distance_source_cmd
);
9194 install_element (OSPF_NODE
, &no_ospf_distance_source_cmd
);
9195 install_element (OSPF_NODE
, &ospf_distance_source_access_list_cmd
);
9196 install_element (OSPF_NODE
, &no_ospf_distance_source_access_list_cmd
);
9200 static struct cmd_node ospf_node
= {OSPF_NODE
, "%s(config-router)# ", 1};
9202 static void ospf_interface_clear(struct interface
*ifp
)
9204 if (!if_is_operative(ifp
))
9207 if (IS_DEBUG_OSPF(ism
, ISM_EVENTS
))
9208 zlog_debug("ISM[%s]: clear by reset", ifp
->name
);
9213 DEFUN (clear_ip_ospf_interface
,
9214 clear_ip_ospf_interface_cmd
,
9215 "clear ip ospf interface [IFNAME]",
9218 "OSPF information\n"
9219 "Interface information\n"
9223 struct interface
*ifp
;
9224 struct listnode
*node
;
9226 if (argc
== 4) /* Clear all the ospfv2 interfaces. */
9228 for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT
), node
, ifp
))
9229 ospf_interface_clear(ifp
);
9230 } else /* Interface name is specified. */
9232 if ((ifp
= if_lookup_by_name(argv
[idx_ifname
]->text
,
9235 vty_out(vty
, "No such interface name%s", VTY_NEWLINE
);
9237 ospf_interface_clear(ifp
);
9243 void ospf_vty_clear_init(void)
9245 install_element(ENABLE_NODE
, &clear_ip_ospf_interface_cmd
);
9249 /* Install OSPF related vty commands. */
9250 void ospf_vty_init(void)
9252 /* Install ospf top node. */
9253 install_node(&ospf_node
, ospf_config_write
);
9255 /* "router ospf" commands. */
9256 install_element(CONFIG_NODE
, &router_ospf_cmd
);
9257 install_element(CONFIG_NODE
, &no_router_ospf_cmd
);
9260 install_default(OSPF_NODE
);
9262 /* "ospf router-id" commands. */
9263 install_element(OSPF_NODE
, &ospf_router_id_cmd
);
9264 install_element(OSPF_NODE
, &ospf_router_id_old_cmd
);
9265 install_element(OSPF_NODE
, &no_ospf_router_id_cmd
);
9267 /* "passive-interface" commands. */
9268 install_element(OSPF_NODE
, &ospf_passive_interface_addr_cmd
);
9269 install_element(OSPF_NODE
, &no_ospf_passive_interface_addr_cmd
);
9271 /* "ospf abr-type" commands. */
9272 install_element(OSPF_NODE
, &ospf_abr_type_cmd
);
9273 install_element(OSPF_NODE
, &no_ospf_abr_type_cmd
);
9275 /* "ospf log-adjacency-changes" commands. */
9276 install_element(OSPF_NODE
, &ospf_log_adjacency_changes_cmd
);
9277 install_element(OSPF_NODE
, &ospf_log_adjacency_changes_detail_cmd
);
9278 install_element(OSPF_NODE
, &no_ospf_log_adjacency_changes_cmd
);
9279 install_element(OSPF_NODE
, &no_ospf_log_adjacency_changes_detail_cmd
);
9281 /* "ospf rfc1583-compatible" commands. */
9282 install_element(OSPF_NODE
, &ospf_compatible_rfc1583_cmd
);
9283 install_element(OSPF_NODE
, &no_ospf_compatible_rfc1583_cmd
);
9284 install_element(OSPF_NODE
, &ospf_rfc1583_flag_cmd
);
9285 install_element(OSPF_NODE
, &no_ospf_rfc1583_flag_cmd
);
9287 /* "network area" commands. */
9288 install_element(OSPF_NODE
, &ospf_network_area_cmd
);
9289 install_element(OSPF_NODE
, &no_ospf_network_area_cmd
);
9291 /* "area authentication" commands. */
9292 install_element(OSPF_NODE
,
9293 &ospf_area_authentication_message_digest_cmd
);
9294 install_element(OSPF_NODE
, &ospf_area_authentication_cmd
);
9295 install_element(OSPF_NODE
, &no_ospf_area_authentication_cmd
);
9297 /* "area range" commands. */
9298 install_element(OSPF_NODE
, &ospf_area_range_cmd
);
9299 install_element(OSPF_NODE
, &ospf_area_range_cost_cmd
);
9300 install_element(OSPF_NODE
, &ospf_area_range_not_advertise_cmd
);
9301 install_element(OSPF_NODE
, &no_ospf_area_range_cmd
);
9302 install_element(OSPF_NODE
, &ospf_area_range_substitute_cmd
);
9303 install_element(OSPF_NODE
, &no_ospf_area_range_substitute_cmd
);
9305 /* "area virtual-link" commands. */
9306 install_element(OSPF_NODE
, &ospf_area_vlink_cmd
);
9307 install_element(OSPF_NODE
, &ospf_area_vlink_intervals_cmd
);
9308 install_element(OSPF_NODE
, &no_ospf_area_vlink_cmd
);
9309 install_element(OSPF_NODE
, &no_ospf_area_vlink_intervals_cmd
);
9312 /* "area stub" commands. */
9313 install_element(OSPF_NODE
, &ospf_area_stub_no_summary_cmd
);
9314 install_element(OSPF_NODE
, &ospf_area_stub_cmd
);
9315 install_element(OSPF_NODE
, &no_ospf_area_stub_no_summary_cmd
);
9316 install_element(OSPF_NODE
, &no_ospf_area_stub_cmd
);
9318 /* "area nssa" commands. */
9319 install_element(OSPF_NODE
, &ospf_area_nssa_cmd
);
9320 install_element(OSPF_NODE
, &ospf_area_nssa_translate_no_summary_cmd
);
9321 install_element(OSPF_NODE
, &ospf_area_nssa_translate_cmd
);
9322 install_element(OSPF_NODE
, &ospf_area_nssa_no_summary_cmd
);
9323 install_element(OSPF_NODE
, &no_ospf_area_nssa_cmd
);
9325 install_element(OSPF_NODE
, &ospf_area_default_cost_cmd
);
9326 install_element(OSPF_NODE
, &no_ospf_area_default_cost_cmd
);
9328 install_element(OSPF_NODE
, &ospf_area_shortcut_cmd
);
9329 install_element(OSPF_NODE
, &no_ospf_area_shortcut_cmd
);
9331 install_element(OSPF_NODE
, &ospf_area_export_list_cmd
);
9332 install_element(OSPF_NODE
, &no_ospf_area_export_list_cmd
);
9334 install_element(OSPF_NODE
, &ospf_area_filter_list_cmd
);
9335 install_element(OSPF_NODE
, &no_ospf_area_filter_list_cmd
);
9337 install_element(OSPF_NODE
, &ospf_area_import_list_cmd
);
9338 install_element(OSPF_NODE
, &no_ospf_area_import_list_cmd
);
9340 /* SPF timer commands */
9341 install_element(OSPF_NODE
, &ospf_timers_throttle_spf_cmd
);
9342 install_element(OSPF_NODE
, &no_ospf_timers_throttle_spf_cmd
);
9344 /* LSA timers commands */
9345 install_element(OSPF_NODE
, &ospf_timers_min_ls_interval_cmd
);
9346 install_element(OSPF_NODE
, &no_ospf_timers_min_ls_interval_cmd
);
9347 install_element(OSPF_NODE
, &ospf_timers_min_ls_arrival_cmd
);
9348 install_element(OSPF_NODE
, &no_ospf_timers_min_ls_arrival_cmd
);
9349 install_element(OSPF_NODE
, &ospf_timers_lsa_cmd
);
9350 install_element(OSPF_NODE
, &no_ospf_timers_lsa_cmd
);
9352 /* refresh timer commands */
9353 install_element(OSPF_NODE
, &ospf_refresh_timer_cmd
);
9354 install_element(OSPF_NODE
, &no_ospf_refresh_timer_val_cmd
);
9356 /* max-metric commands */
9357 install_element(OSPF_NODE
, &ospf_max_metric_router_lsa_admin_cmd
);
9358 install_element(OSPF_NODE
, &no_ospf_max_metric_router_lsa_admin_cmd
);
9359 install_element(OSPF_NODE
, &ospf_max_metric_router_lsa_startup_cmd
);
9360 install_element(OSPF_NODE
, &no_ospf_max_metric_router_lsa_startup_cmd
);
9361 install_element(OSPF_NODE
, &ospf_max_metric_router_lsa_shutdown_cmd
);
9362 install_element(OSPF_NODE
, &no_ospf_max_metric_router_lsa_shutdown_cmd
);
9364 /* reference bandwidth commands */
9365 install_element(OSPF_NODE
, &ospf_auto_cost_reference_bandwidth_cmd
);
9366 install_element(OSPF_NODE
, &no_ospf_auto_cost_reference_bandwidth_cmd
);
9368 /* "neighbor" commands. */
9369 install_element(OSPF_NODE
, &ospf_neighbor_cmd
);
9370 install_element(OSPF_NODE
, &ospf_neighbor_poll_interval_cmd
);
9371 install_element(OSPF_NODE
, &no_ospf_neighbor_cmd
);
9372 install_element(OSPF_NODE
, &no_ospf_neighbor_poll_cmd
);
9374 /* write multiplier commands */
9375 install_element(OSPF_NODE
, &ospf_write_multiplier_cmd
);
9376 install_element(OSPF_NODE
, &write_multiplier_cmd
);
9377 install_element(OSPF_NODE
, &no_ospf_write_multiplier_cmd
);
9378 install_element(OSPF_NODE
, &no_write_multiplier_cmd
);
9380 /* Init interface related vty commands. */
9383 /* Init zebra related vty commands. */
9384 ospf_vty_zebra_init();