2 * Copyright (C) 2005 6WIND <alain.ritoux@6wind.com>
3 * Copyright (C) 2000 Toshiaki Takada
5 * This file is part of GNU Zebra.
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; see the file COPYING; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
38 #include "lib/printfrr.h"
40 #include "ospfd/ospfd.h"
41 #include "ospfd/ospf_asbr.h"
42 #include "ospfd/ospf_lsa.h"
43 #include "ospfd/ospf_lsdb.h"
44 #include "ospfd/ospf_ism.h"
45 #include "ospfd/ospf_interface.h"
46 #include "ospfd/ospf_nsm.h"
47 #include "ospfd/ospf_neighbor.h"
48 #include "ospfd/ospf_flood.h"
49 #include "ospfd/ospf_abr.h"
50 #include "ospfd/ospf_spf.h"
51 #include "ospfd/ospf_route.h"
52 #include "ospfd/ospf_zebra.h"
53 /*#include "ospfd/ospf_routemap.h" */
54 #include "ospfd/ospf_vty.h"
55 #include "ospfd/ospf_dump.h"
56 #include "ospfd/ospf_bfd.h"
57 #include "ospfd/ospf_ldp_sync.h"
60 FRR_CFG_DEFAULT_BOOL(OSPF_LOG_ADJACENCY_CHANGES
,
61 { .val_bool
= true, .match_profile
= "datacenter", },
62 { .val_bool
= false },
65 static const char *const ospf_network_type_str
[] = {
66 "Null", "POINTOPOINT", "BROADCAST", "NBMA", "POINTOMULTIPOINT",
67 "VIRTUALLINK", "LOOPBACK"};
69 /* Utility functions. */
70 int str2area_id(const char *str
, struct in_addr
*area_id
, int *area_id_fmt
)
74 area_id
->s_addr
= htonl(strtoul(str
, &ep
, 10));
75 if (*ep
&& !inet_aton(str
, area_id
))
79 *ep
? OSPF_AREA_ID_FMT_DOTTEDQUAD
: OSPF_AREA_ID_FMT_DECIMAL
;
84 static void area_id2str(char *buf
, int length
, struct in_addr
*area_id
,
87 if (area_id_fmt
== OSPF_AREA_ID_FMT_DOTTEDQUAD
)
88 inet_ntop(AF_INET
, area_id
, buf
, length
);
90 snprintf(buf
, length
, "%lu",
91 (unsigned long)ntohl(area_id
->s_addr
));
94 static int str2metric(const char *str
, int *metric
)
100 *metric
= strtol(str
, NULL
, 10);
101 if (*metric
< 0 || *metric
> 16777214) {
102 /* vty_out (vty, "OSPF metric value is invalid\n"); */
109 static int str2metric_type(const char *str
, int *metric_type
)
115 if (strncmp(str
, "1", 1) == 0)
116 *metric_type
= EXTERNAL_METRIC_TYPE_1
;
117 else if (strncmp(str
, "2", 1) == 0)
118 *metric_type
= EXTERNAL_METRIC_TYPE_2
;
125 int ospf_oi_count(struct interface
*ifp
)
127 struct route_node
*rn
;
130 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
))
137 #define OSPF_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf) \
138 if (argv_find(argv, argc, "vrf", &idx_vrf)) { \
139 vrf_name = argv[idx_vrf + 1]->arg; \
140 all_vrf = strmatch(vrf_name, "all"); \
143 static int ospf_router_cmd_parse(struct vty
*vty
, struct cmd_token
*argv
[],
144 const int argc
, unsigned short *instance
,
145 const char **vrf_name
)
147 int idx_vrf
= 0, idx_inst
= 0;
150 if (argv_find(argv
, argc
, "(1-65535)", &idx_inst
)) {
151 if (ospf_instance
== 0) {
153 "%% OSPF is not running in instance mode\n");
154 return CMD_WARNING_CONFIG_FAILED
;
157 *instance
= strtoul(argv
[idx_inst
]->arg
, NULL
, 10);
160 *vrf_name
= VRF_DEFAULT_NAME
;
161 if (argv_find(argv
, argc
, "vrf", &idx_vrf
)) {
162 if (ospf_instance
!= 0) {
164 "%% VRF is not supported in instance mode\n");
165 return CMD_WARNING_CONFIG_FAILED
;
168 *vrf_name
= argv
[idx_vrf
+ 1]->arg
;
174 static void ospf_show_vrf_name(struct ospf
*ospf
, struct vty
*vty
,
175 json_object
*json
, uint8_t use_vrf
)
179 json_object_string_add(json
, "vrfName",
180 ospf_get_name(ospf
));
181 json_object_int_add(json
, "vrfId", ospf
->vrf_id
);
183 vty_out(vty
, "VRF Name: %s\n", ospf_get_name(ospf
));
187 #ifndef VTYSH_EXTRACT_PL
188 #include "ospfd/ospf_vty_clippy.c"
191 DEFUN_NOSH (router_ospf
,
193 "router ospf [{(1-65535)|vrf NAME}]",
194 "Enable a routing process\n"
195 "Start OSPF configuration\n"
199 unsigned short instance
;
200 const char *vrf_name
;
201 bool created
= false;
205 ret
= ospf_router_cmd_parse(vty
, argv
, argc
, &instance
, &vrf_name
);
206 if (ret
!= CMD_SUCCESS
)
209 if (instance
!= ospf_instance
) {
210 VTY_PUSH_CONTEXT_NULL(OSPF_NODE
);
211 return CMD_NOT_MY_INSTANCE
;
214 ospf
= ospf_get(instance
, vrf_name
, &created
);
217 if (DFLT_OSPF_LOG_ADJACENCY_CHANGES
)
218 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
220 if (IS_DEBUG_OSPF_EVENT
)
222 "Config command 'router ospf %d' received, vrf %s id %u oi_running %u",
223 ospf
->instance
, ospf_get_name(ospf
), ospf
->vrf_id
,
226 VTY_PUSH_CONTEXT(OSPF_NODE
, ospf
);
231 DEFUN (no_router_ospf
,
233 "no router ospf [{(1-65535)|vrf NAME}]",
235 "Enable a routing process\n"
236 "Start OSPF configuration\n"
240 unsigned short instance
;
241 const char *vrf_name
;
245 ret
= ospf_router_cmd_parse(vty
, argv
, argc
, &instance
, &vrf_name
);
246 if (ret
!= CMD_SUCCESS
)
249 if (instance
!= ospf_instance
)
250 return CMD_NOT_MY_INSTANCE
;
252 ospf
= ospf_lookup(instance
, vrf_name
);
256 ret
= CMD_WARNING_CONFIG_FAILED
;
262 DEFPY (ospf_router_id
,
264 "ospf router-id A.B.C.D",
265 "OSPF specific commands\n"
266 "router-id for the OSPF process\n"
267 "OSPF router-id in IP address format\n")
269 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
271 struct listnode
*node
;
272 struct ospf_area
*area
;
274 ospf
->router_id_static
= router_id
;
276 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
))
277 if (area
->full_nbrs
) {
279 "For this router-id change to take effect, use \"clear ip ospf process\" command\n");
283 ospf_router_id_update(ospf
);
288 DEFUN_HIDDEN (ospf_router_id_old
,
289 ospf_router_id_old_cmd
,
291 "router-id for the OSPF process\n"
292 "OSPF router-id in IP address format\n")
294 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
296 struct listnode
*node
;
297 struct ospf_area
*area
;
298 struct in_addr router_id
;
301 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &router_id
);
303 vty_out(vty
, "Please specify Router ID by A.B.C.D\n");
304 return CMD_WARNING_CONFIG_FAILED
;
307 ospf
->router_id_static
= router_id
;
309 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
))
310 if (area
->full_nbrs
) {
312 "For this router-id change to take effect, use \"clear ip ospf process\" command\n");
316 ospf_router_id_update(ospf
);
321 DEFPY (no_ospf_router_id
,
322 no_ospf_router_id_cmd
,
323 "no ospf router-id [A.B.C.D]",
325 "OSPF specific commands\n"
326 "router-id for the OSPF process\n"
327 "OSPF router-id in IP address format\n")
329 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
330 struct listnode
*node
;
331 struct ospf_area
*area
;
334 if (!IPV4_ADDR_SAME(&ospf
->router_id_static
, &router_id
)) {
335 vty_out(vty
, "%% OSPF router-id doesn't match\n");
336 return CMD_WARNING_CONFIG_FAILED
;
340 ospf
->router_id_static
.s_addr
= 0;
342 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
))
343 if (area
->full_nbrs
) {
345 "For this router-id change to take effect, use \"clear ip ospf process\" command\n");
349 ospf_router_id_update(ospf
);
355 static void ospf_passive_interface_default_update(struct ospf
*ospf
,
359 struct ospf_interface
*oi
;
361 ospf
->passive_interface_default
= newval
;
363 /* update multicast memberships */
364 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, ln
, oi
))
365 ospf_if_set_multicast(oi
);
368 static void ospf_passive_interface_update(struct interface
*ifp
,
369 struct ospf_if_params
*params
,
370 struct in_addr addr
, uint8_t newval
)
372 struct route_node
*rn
;
374 if (OSPF_IF_PARAM_CONFIGURED(params
, passive_interface
)) {
375 if (params
->passive_interface
== newval
)
378 params
->passive_interface
= newval
;
379 UNSET_IF_PARAM(params
, passive_interface
);
380 if (params
!= IF_DEF_PARAMS(ifp
)) {
381 ospf_free_if_params(ifp
, addr
);
382 ospf_if_update_params(ifp
, addr
);
385 params
->passive_interface
= newval
;
386 SET_IF_PARAM(params
, passive_interface
);
390 * XXX We should call ospf_if_set_multicast on exactly those
391 * interfaces for which the passive property changed. It is too much
392 * work to determine this set, so we do this for every interface.
393 * This is safe and reasonable because ospf_if_set_multicast uses a
394 * record of joined groups to avoid systems calls if the desired
395 * memberships match the current memership.
398 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
399 struct ospf_interface
*oi
= rn
->info
;
402 ospf_if_set_multicast(oi
);
406 * XXX It is not clear what state transitions the interface needs to
407 * undergo when going from active to passive and vice versa. Fixing
408 * this will require precise identification of interfaces having such a
413 DEFUN (ospf_passive_interface_default
,
414 ospf_passive_interface_default_cmd
,
415 "passive-interface default",
416 "Suppress routing updates on an interface\n"
417 "Suppress routing updates on interfaces by default\n")
419 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
421 ospf_passive_interface_default_update(ospf
, OSPF_IF_PASSIVE
);
426 DEFUN_HIDDEN (ospf_passive_interface_addr
,
427 ospf_passive_interface_addr_cmd
,
428 "passive-interface IFNAME [A.B.C.D]",
429 "Suppress routing updates on an interface\n"
433 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
435 struct interface
*ifp
= NULL
;
436 struct in_addr addr
= {.s_addr
= INADDR_ANY
};
437 struct ospf_if_params
*params
;
441 "This command is deprecated, because it is not VRF-aware.\n");
443 "Please, use \"ip ospf passive\" on an interface instead.\n");
445 if (ospf
->vrf_id
!= VRF_UNKNOWN
)
446 ifp
= if_get_by_name(argv
[1]->arg
, ospf
->vrf_id
, ospf
->name
);
449 vty_out(vty
, "interface %s not found.\n", (char *)argv
[1]->arg
);
450 return CMD_WARNING_CONFIG_FAILED
;
454 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
457 "Please specify interface address by A.B.C.D\n");
458 return CMD_WARNING_CONFIG_FAILED
;
461 params
= ospf_get_if_params(ifp
, addr
);
462 ospf_if_update_params(ifp
, addr
);
464 params
= IF_DEF_PARAMS(ifp
);
467 ospf_passive_interface_update(ifp
, params
, addr
, OSPF_IF_PASSIVE
);
472 DEFUN (no_ospf_passive_interface_default
,
473 no_ospf_passive_interface_default_cmd
,
474 "no passive-interface default",
476 "Allow routing updates on an interface\n"
477 "Allow routing updates on interfaces by default\n")
479 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
481 ospf_passive_interface_default_update(ospf
, OSPF_IF_ACTIVE
);
486 DEFUN_HIDDEN (no_ospf_passive_interface
,
487 no_ospf_passive_interface_addr_cmd
,
488 "no passive-interface IFNAME [A.B.C.D]",
490 "Allow routing updates on an interface\n"
494 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
496 struct interface
*ifp
= NULL
;
497 struct in_addr addr
= {.s_addr
= INADDR_ANY
};
498 struct ospf_if_params
*params
;
502 "This command is deprecated, because it is not VRF-aware.\n");
504 "Please, use \"no ip ospf passive\" on an interface instead.\n");
506 if (ospf
->vrf_id
!= VRF_UNKNOWN
)
507 ifp
= if_get_by_name(argv
[2]->arg
, ospf
->vrf_id
, ospf
->name
);
510 vty_out(vty
, "interface %s not found.\n", (char *)argv
[2]->arg
);
511 return CMD_WARNING_CONFIG_FAILED
;
515 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
518 "Please specify interface address by A.B.C.D\n");
519 return CMD_WARNING_CONFIG_FAILED
;
521 params
= ospf_lookup_if_params(ifp
, addr
);
525 params
= IF_DEF_PARAMS(ifp
);
528 ospf_passive_interface_update(ifp
, params
, addr
, OSPF_IF_ACTIVE
);
534 DEFUN (ospf_network_area
,
535 ospf_network_area_cmd
,
536 "network A.B.C.D/M area <A.B.C.D|(0-4294967295)>",
537 "Enable routing on an IP network\n"
538 "OSPF network prefix\n"
539 "Set the OSPF area ID\n"
540 "OSPF area ID in IP address format\n"
541 "OSPF area ID as a decimal value\n")
543 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
544 int idx_ipv4_prefixlen
= 1;
545 int idx_ipv4_number
= 3;
546 struct prefix_ipv4 p
;
547 struct in_addr area_id
;
551 if (ospf
->instance
) {
553 "The network command is not supported in multi-instance ospf\n");
554 return CMD_WARNING_CONFIG_FAILED
;
557 count
= ospf_count_area_params(ospf
);
560 "Please remove all ip ospf area x.x.x.x commands first.\n");
561 if (IS_DEBUG_OSPF_EVENT
)
563 "%s ospf vrf %s num of %u ip ospf area x config",
564 __func__
, ospf_get_name(ospf
), count
);
565 return CMD_WARNING_CONFIG_FAILED
;
568 /* Get network prefix and Area ID. */
569 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
570 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
572 ret
= ospf_network_set(ospf
, &p
, area_id
, format
);
574 vty_out(vty
, "There is already same network statement.\n");
575 return CMD_WARNING_CONFIG_FAILED
;
581 DEFUN (no_ospf_network_area
,
582 no_ospf_network_area_cmd
,
583 "no network A.B.C.D/M area <A.B.C.D|(0-4294967295)>",
585 "Enable routing on an IP network\n"
586 "OSPF network prefix\n"
587 "Set the OSPF area ID\n"
588 "OSPF area ID in IP address format\n"
589 "OSPF area ID as a decimal value\n")
591 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
592 int idx_ipv4_prefixlen
= 2;
593 int idx_ipv4_number
= 4;
594 struct prefix_ipv4 p
;
595 struct in_addr area_id
;
598 if (ospf
->instance
) {
600 "The network command is not supported in multi-instance ospf\n");
601 return CMD_WARNING_CONFIG_FAILED
;
604 /* Get network prefix and Area ID. */
605 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
606 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
608 ret
= ospf_network_unset(ospf
, &p
, area_id
);
611 "Can't find specified network area configuration.\n");
612 return CMD_WARNING_CONFIG_FAILED
;
618 DEFUN (ospf_area_range
,
620 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [advertise [cost (0-16777215)]]",
621 "OSPF area parameters\n"
622 "OSPF area ID in IP address format\n"
623 "OSPF area ID as a decimal value\n"
624 "Summarize routes matching address/mask (border routers only)\n"
625 "Area range prefix\n"
626 "Advertise this range (default)\n"
627 "User specified metric for this range\n"
628 "Advertised metric for this range\n")
630 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
631 int idx_ipv4_number
= 1;
632 int idx_ipv4_prefixlen
= 3;
634 struct prefix_ipv4 p
;
635 struct in_addr area_id
;
639 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
640 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
642 ospf_area_range_set(ospf
, area_id
, &p
, OSPF_AREA_RANGE_ADVERTISE
);
643 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
646 cost
= strtoul(argv
[idx_cost
]->arg
, NULL
, 10);
647 ospf_area_range_cost_set(ospf
, area_id
, &p
, cost
);
653 DEFUN (ospf_area_range_cost
,
654 ospf_area_range_cost_cmd
,
655 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M cost (0-16777215)",
656 "OSPF area parameters\n"
657 "OSPF area ID in IP address format\n"
658 "OSPF area ID as a decimal value\n"
659 "Summarize routes matching address/mask (border routers only)\n"
660 "Area range prefix\n"
661 "User specified metric for this range\n"
662 "Advertised metric for this range\n")
664 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
665 int idx_ipv4_number
= 1;
666 int idx_ipv4_prefixlen
= 3;
668 struct prefix_ipv4 p
;
669 struct in_addr area_id
;
673 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
674 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
676 ospf_area_range_set(ospf
, area_id
, &p
, OSPF_AREA_RANGE_ADVERTISE
);
677 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
680 cost
= strtoul(argv
[idx_cost
]->arg
, NULL
, 10);
681 ospf_area_range_cost_set(ospf
, area_id
, &p
, cost
);
686 DEFUN (ospf_area_range_not_advertise
,
687 ospf_area_range_not_advertise_cmd
,
688 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M not-advertise",
689 "OSPF area parameters\n"
690 "OSPF area ID in IP address format\n"
691 "OSPF area ID as a decimal value\n"
692 "Summarize routes matching address/mask (border routers only)\n"
693 "Area range prefix\n"
694 "DoNotAdvertise this range\n")
696 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
697 int idx_ipv4_number
= 1;
698 int idx_ipv4_prefixlen
= 3;
699 struct prefix_ipv4 p
;
700 struct in_addr area_id
;
703 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
704 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
706 ospf_area_range_set(ospf
, area_id
, &p
, 0);
707 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
709 ospf_area_range_substitute_unset(ospf
, area_id
, &p
);
714 DEFUN (no_ospf_area_range
,
715 no_ospf_area_range_cmd
,
716 "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [<cost (0-16777215)|advertise [cost (0-16777215)]|not-advertise>]",
718 "OSPF area parameters\n"
719 "OSPF area ID in IP address format\n"
720 "OSPF area ID as a decimal value\n"
721 "Summarize routes matching address/mask (border routers only)\n"
722 "Area range prefix\n"
723 "User specified metric for this range\n"
724 "Advertised metric for this range\n"
725 "Advertise this range (default)\n"
726 "User specified metric for this range\n"
727 "Advertised metric for this range\n"
728 "DoNotAdvertise this range\n")
730 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
731 int idx_ipv4_number
= 2;
732 int idx_ipv4_prefixlen
= 4;
733 struct prefix_ipv4 p
;
734 struct in_addr area_id
;
737 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
738 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
740 ospf_area_range_unset(ospf
, area_id
, &p
);
745 DEFUN (ospf_area_range_substitute
,
746 ospf_area_range_substitute_cmd
,
747 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M",
748 "OSPF area parameters\n"
749 "OSPF area ID in IP address format\n"
750 "OSPF area ID as a decimal value\n"
751 "Summarize routes matching address/mask (border routers only)\n"
752 "Area range prefix\n"
753 "Announce area range as another prefix\n"
754 "Network prefix to be announced instead of range\n")
756 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
757 int idx_ipv4_number
= 1;
758 int idx_ipv4_prefixlen
= 3;
759 int idx_ipv4_prefixlen_2
= 5;
760 struct prefix_ipv4 p
, s
;
761 struct in_addr area_id
;
764 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
765 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
766 str2prefix_ipv4(argv
[idx_ipv4_prefixlen_2
]->arg
, &s
);
768 ospf_area_range_substitute_set(ospf
, area_id
, &p
, &s
);
769 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
775 DEFUN (no_ospf_area_range_substitute
,
776 no_ospf_area_range_substitute_cmd
,
777 "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M",
779 "OSPF area parameters\n"
780 "OSPF area ID in IP address format\n"
781 "OSPF area ID as a decimal value\n"
782 "Summarize routes matching address/mask (border routers only)\n"
783 "Area range prefix\n"
784 "Announce area range as another prefix\n"
785 "Network prefix to be announced instead of range\n")
787 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
788 int idx_ipv4_number
= 2;
789 int idx_ipv4_prefixlen
= 4;
790 int idx_ipv4_prefixlen_2
= 6;
791 struct prefix_ipv4 p
, s
;
792 struct in_addr area_id
;
795 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
796 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
797 str2prefix_ipv4(argv
[idx_ipv4_prefixlen_2
]->arg
, &s
);
799 ospf_area_range_substitute_unset(ospf
, area_id
, &p
);
805 /* Command Handler Logic in VLink stuff is delicate!!
807 ALTER AT YOUR OWN RISK!!!!
809 Various dummy values are used to represent 'NoChange' state for
810 VLink configuration NOT being changed by a VLink command, and
811 special syntax is used within the command strings so that the
812 typed in command verbs can be seen in the configuration command
813 bacckend handler. This is to drastically reduce the verbeage
814 required to coe up with a reasonably compatible Cisco VLink command
816 - Matthew Grant <grantma@anathoth.gen.nz>
817 Wed, 21 Feb 2001 15:13:52 +1300
820 /* Configuration data for virtual links
822 struct ospf_vl_config_data
{
823 struct vty
*vty
; /* vty stuff */
824 struct in_addr area_id
; /* area ID from command line */
825 int area_id_fmt
; /* command line area ID format */
826 struct in_addr vl_peer
; /* command line vl_peer */
827 int auth_type
; /* Authehntication type, if given */
828 char *auth_key
; /* simple password if present */
829 int crypto_key_id
; /* Cryptographic key ID */
830 char *md5_key
; /* MD5 authentication key */
831 int hello_interval
; /* Obvious what these are... */
832 int retransmit_interval
;
837 static void ospf_vl_config_data_init(struct ospf_vl_config_data
*vl_config
,
840 memset(vl_config
, 0, sizeof(struct ospf_vl_config_data
));
841 vl_config
->auth_type
= OSPF_AUTH_CMD_NOTSEEN
;
842 vl_config
->vty
= vty
;
845 static struct ospf_vl_data
*
846 ospf_find_vl_data(struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
848 struct ospf_area
*area
;
849 struct ospf_vl_data
*vl_data
;
851 struct in_addr area_id
;
853 vty
= vl_config
->vty
;
854 area_id
= vl_config
->area_id
;
856 if (area_id
.s_addr
== OSPF_AREA_BACKBONE
) {
858 "Configuring VLs over the backbone is not allowed\n");
861 area
= ospf_area_get(ospf
, area_id
);
862 ospf_area_display_format_set(ospf
, area
, vl_config
->area_id_fmt
);
864 if (area
->external_routing
!= OSPF_AREA_DEFAULT
) {
865 if (vl_config
->area_id_fmt
== OSPF_AREA_ID_FMT_DOTTEDQUAD
)
866 vty_out(vty
, "Area %pI4 is %s\n", &area_id
,
867 area
->external_routing
== OSPF_AREA_NSSA
871 vty_out(vty
, "Area %ld is %s\n",
872 (unsigned long)ntohl(area_id
.s_addr
),
873 area
->external_routing
== OSPF_AREA_NSSA
879 if ((vl_data
= ospf_vl_lookup(ospf
, area
, vl_config
->vl_peer
))
881 vl_data
= ospf_vl_data_new(area
, vl_config
->vl_peer
);
882 if (vl_data
->vl_oi
== NULL
) {
883 vl_data
->vl_oi
= ospf_vl_new(ospf
, vl_data
);
884 ospf_vl_add(ospf
, vl_data
);
885 ospf_spf_calculate_schedule(ospf
,
886 SPF_FLAG_CONFIG_CHANGE
);
893 static int ospf_vl_set_security(struct ospf_vl_data
*vl_data
,
894 struct ospf_vl_config_data
*vl_config
)
896 struct crypt_key
*ck
;
898 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
900 vty
= vl_config
->vty
;
902 if (vl_config
->auth_type
!= OSPF_AUTH_CMD_NOTSEEN
) {
903 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), auth_type
);
904 IF_DEF_PARAMS(ifp
)->auth_type
= vl_config
->auth_type
;
907 if (vl_config
->auth_key
) {
908 memset(IF_DEF_PARAMS(ifp
)->auth_simple
, 0,
909 OSPF_AUTH_SIMPLE_SIZE
+ 1);
910 strlcpy((char *)IF_DEF_PARAMS(ifp
)->auth_simple
,
912 sizeof(IF_DEF_PARAMS(ifp
)->auth_simple
));
913 } else if (vl_config
->md5_key
) {
914 if (ospf_crypt_key_lookup(IF_DEF_PARAMS(ifp
)->auth_crypt
,
915 vl_config
->crypto_key_id
)
917 vty_out(vty
, "OSPF: Key %d already exists\n",
918 vl_config
->crypto_key_id
);
921 ck
= ospf_crypt_key_new();
922 ck
->key_id
= vl_config
->crypto_key_id
;
923 memset(ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+ 1);
924 strlcpy((char *)ck
->auth_key
, vl_config
->md5_key
,
925 sizeof(ck
->auth_key
));
927 ospf_crypt_key_add(IF_DEF_PARAMS(ifp
)->auth_crypt
, ck
);
928 } else if (vl_config
->crypto_key_id
!= 0) {
931 if (ospf_crypt_key_lookup(IF_DEF_PARAMS(ifp
)->auth_crypt
,
932 vl_config
->crypto_key_id
)
934 vty_out(vty
, "OSPF: Key %d does not exist\n",
935 vl_config
->crypto_key_id
);
936 return CMD_WARNING_CONFIG_FAILED
;
939 ospf_crypt_key_delete(IF_DEF_PARAMS(ifp
)->auth_crypt
,
940 vl_config
->crypto_key_id
);
946 static int ospf_vl_set_timers(struct ospf_vl_data
*vl_data
,
947 struct ospf_vl_config_data
*vl_config
)
949 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
950 /* Virtual Link data initialised to defaults, so only set
952 if (vl_config
->hello_interval
) {
953 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), v_hello
);
954 IF_DEF_PARAMS(ifp
)->v_hello
= vl_config
->hello_interval
;
957 if (vl_config
->dead_interval
) {
958 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), v_wait
);
959 IF_DEF_PARAMS(ifp
)->v_wait
= vl_config
->dead_interval
;
962 if (vl_config
->retransmit_interval
) {
963 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), retransmit_interval
);
964 IF_DEF_PARAMS(ifp
)->retransmit_interval
=
965 vl_config
->retransmit_interval
;
968 if (vl_config
->transmit_delay
) {
969 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), transmit_delay
);
970 IF_DEF_PARAMS(ifp
)->transmit_delay
= vl_config
->transmit_delay
;
977 /* The business end of all of the above */
978 static int ospf_vl_set(struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
980 struct ospf_vl_data
*vl_data
;
983 vl_data
= ospf_find_vl_data(ospf
, vl_config
);
985 return CMD_WARNING_CONFIG_FAILED
;
987 /* Process this one first as it can have a fatal result, which can
988 only logically occur if the virtual link exists already
989 Thus a command error does not result in a change to the
990 running configuration such as unexpectedly altered timer
992 ret
= ospf_vl_set_security(vl_data
, vl_config
);
993 if (ret
!= CMD_SUCCESS
)
996 /* Set any time based parameters, these area already range checked */
998 ret
= ospf_vl_set_timers(vl_data
, vl_config
);
999 if (ret
!= CMD_SUCCESS
)
1005 /* This stuff exists to make specifying all the alias commands A LOT simpler
1007 #define VLINK_HELPSTR_IPADDR \
1008 "OSPF area parameters\n" \
1009 "OSPF area ID in IP address format\n" \
1010 "OSPF area ID as a decimal value\n" \
1011 "Configure a virtual link\n" \
1012 "Router ID of the remote ABR\n"
1014 #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
1015 "Enable authentication on this virtual link\n" \
1018 #define VLINK_HELPSTR_AUTHTYPE_ALL \
1019 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
1020 "Use null authentication\n" \
1021 "Use message-digest authentication\n"
1023 #define VLINK_HELPSTR_TIME_PARAM \
1024 "Time between HELLO packets\n" \
1026 "Time between retransmitting lost link state advertisements\n" \
1028 "Link state transmit delay\n" \
1030 "Interval time after which a neighbor is declared down\n" \
1033 #define VLINK_HELPSTR_AUTH_SIMPLE \
1034 "Authentication password (key)\n" \
1035 "The OSPF password (key)\n"
1037 #define VLINK_HELPSTR_AUTH_MD5 \
1038 "Message digest authentication password (key)\n" \
1040 "Use MD5 algorithm\n" \
1041 "The OSPF password (key)\n"
1043 DEFUN (ospf_area_vlink
,
1044 ospf_area_vlink_cmd
,
1045 "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>]",
1046 VLINK_HELPSTR_IPADDR
1047 "Enable authentication on this virtual link\n"
1048 "Use message-digest authentication\n"
1049 "Use null authentication\n"
1050 VLINK_HELPSTR_AUTH_MD5
1051 VLINK_HELPSTR_AUTH_SIMPLE
)
1053 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1054 int idx_ipv4_number
= 1;
1056 struct ospf_vl_config_data vl_config
;
1057 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+ 1];
1058 char md5_key
[OSPF_AUTH_MD5_SIZE
+ 1];
1062 ospf_vl_config_data_init(&vl_config
, vty
);
1064 /* Read off first 2 parameters and check them */
1065 ret
= str2area_id(argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
,
1066 &vl_config
.area_id_fmt
);
1068 vty_out(vty
, "OSPF area ID is invalid\n");
1069 return CMD_WARNING_CONFIG_FAILED
;
1072 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1074 vty_out(vty
, "Please specify valid Router ID as a.b.c.d\n");
1075 return CMD_WARNING_CONFIG_FAILED
;
1079 /* Thats all folks! - BUGS B. strikes again!!!*/
1081 return ospf_vl_set(ospf
, &vl_config
);
1084 if (argv_find(argv
, argc
, "authentication", &idx
)) {
1085 /* authentication - this option can only occur
1086 at start of command line */
1087 vl_config
.auth_type
= OSPF_AUTH_SIMPLE
;
1090 if (argv_find(argv
, argc
, "message-digest", &idx
)) {
1091 /* authentication message-digest */
1092 vl_config
.auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
1093 } else if (argv_find(argv
, argc
, "null", &idx
)) {
1094 /* "authentication null" */
1095 vl_config
.auth_type
= OSPF_AUTH_NULL
;
1098 if (argv_find(argv
, argc
, "message-digest-key", &idx
)) {
1099 vl_config
.md5_key
= NULL
;
1100 vl_config
.crypto_key_id
= strtol(argv
[idx
+ 1]->arg
, NULL
, 10);
1101 if (vl_config
.crypto_key_id
< 0)
1102 return CMD_WARNING_CONFIG_FAILED
;
1104 strlcpy(md5_key
, argv
[idx
+ 3]->arg
, sizeof(md5_key
));
1105 vl_config
.md5_key
= md5_key
;
1108 if (argv_find(argv
, argc
, "authentication-key", &idx
)) {
1109 strlcpy(auth_key
, argv
[idx
+ 1]->arg
, sizeof(auth_key
));
1110 vl_config
.auth_key
= auth_key
;
1113 /* Action configuration */
1115 return ospf_vl_set(ospf
, &vl_config
);
1118 DEFUN (no_ospf_area_vlink
,
1119 no_ospf_area_vlink_cmd
,
1120 "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>]",
1122 VLINK_HELPSTR_IPADDR
1123 "Enable authentication on this virtual link\n"
1124 "Use message-digest authentication\n"
1125 "Use null authentication\n"
1126 VLINK_HELPSTR_AUTH_MD5
1127 VLINK_HELPSTR_AUTH_SIMPLE
)
1129 VTY_DECLVAR_INSTANCE_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\n");
1145 return CMD_WARNING_CONFIG_FAILED
;
1148 area
= ospf_area_lookup_by_area_id(ospf
, vl_config
.area_id
);
1150 vty_out(vty
, "Area does not exist\n");
1151 return CMD_WARNING_CONFIG_FAILED
;
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\n");
1157 return CMD_WARNING_CONFIG_FAILED
;
1160 vl_data
= ospf_vl_lookup(ospf
, area
, vl_config
.vl_peer
);
1162 vty_out(vty
, "Virtual link does not exist\n");
1163 return CMD_WARNING_CONFIG_FAILED
;
1167 /* Basic VLink no command */
1168 /* Thats all folks! - BUGS B. strikes again!!!*/
1169 ospf_vl_delete(ospf
, vl_data
);
1170 ospf_area_check_free(ospf
, vl_config
.area_id
);
1174 /* If we are down here, we are reseting parameters */
1175 /* Deal with other parameters */
1177 if (argv_find(argv
, argc
, "authentication", &idx
)) {
1178 /* authentication - this option can only occur
1179 at start of command line */
1180 vl_config
.auth_type
= OSPF_AUTH_NOTSET
;
1183 if (argv_find(argv
, argc
, "message-digest-key", &idx
)) {
1184 vl_config
.md5_key
= NULL
;
1185 vl_config
.crypto_key_id
= strtol(argv
[idx
+ 1]->arg
, NULL
, 10);
1186 if (vl_config
.crypto_key_id
< 0)
1187 return CMD_WARNING_CONFIG_FAILED
;
1190 if (argv_find(argv
, argc
, "authentication-key", &idx
)) {
1191 /* Reset authentication-key to 0 */
1192 memset(auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1193 vl_config
.auth_key
= auth_key
;
1196 /* Action configuration */
1198 return ospf_vl_set(ospf
, &vl_config
);
1201 DEFUN (ospf_area_vlink_intervals
,
1202 ospf_area_vlink_intervals_cmd
,
1203 "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)}",
1204 VLINK_HELPSTR_IPADDR
1205 VLINK_HELPSTR_TIME_PARAM
)
1207 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1208 struct ospf_vl_config_data vl_config
;
1211 ospf_vl_config_data_init(&vl_config
, vty
);
1213 char *area_id
= argv
[1]->arg
;
1214 char *router_id
= argv
[3]->arg
;
1216 ret
= str2area_id(area_id
, &vl_config
.area_id
, &vl_config
.area_id_fmt
);
1218 vty_out(vty
, "OSPF area ID is invalid\n");
1219 return CMD_WARNING_CONFIG_FAILED
;
1222 ret
= inet_aton(router_id
, &vl_config
.vl_peer
);
1224 vty_out(vty
, "Please specify valid Router ID as a.b.c.d\n");
1225 return CMD_WARNING_CONFIG_FAILED
;
1228 for (int idx
= 4; idx
< argc
; idx
++) {
1229 if (strmatch(argv
[idx
]->text
, "hello-interval"))
1230 vl_config
.hello_interval
=
1231 strtol(argv
[++idx
]->arg
, NULL
, 10);
1232 else if (strmatch(argv
[idx
]->text
, "retransmit-interval"))
1233 vl_config
.retransmit_interval
=
1234 strtol(argv
[++idx
]->arg
, NULL
, 10);
1235 else if (strmatch(argv
[idx
]->text
, "transmit-delay"))
1236 vl_config
.transmit_delay
=
1237 strtol(argv
[++idx
]->arg
, NULL
, 10);
1238 else if (strmatch(argv
[idx
]->text
, "dead-interval"))
1239 vl_config
.dead_interval
=
1240 strtol(argv
[++idx
]->arg
, NULL
, 10);
1243 /* Action configuration */
1244 return ospf_vl_set(ospf
, &vl_config
);
1247 DEFUN (no_ospf_area_vlink_intervals
,
1248 no_ospf_area_vlink_intervals_cmd
,
1249 "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)}",
1251 VLINK_HELPSTR_IPADDR
1252 VLINK_HELPSTR_TIME_PARAM
)
1254 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1255 struct ospf_vl_config_data vl_config
;
1258 ospf_vl_config_data_init(&vl_config
, vty
);
1260 char *area_id
= argv
[2]->arg
;
1261 char *router_id
= argv
[4]->arg
;
1263 ret
= str2area_id(area_id
, &vl_config
.area_id
, &vl_config
.area_id_fmt
);
1265 vty_out(vty
, "OSPF area ID is invalid\n");
1266 return CMD_WARNING_CONFIG_FAILED
;
1269 ret
= inet_aton(router_id
, &vl_config
.vl_peer
);
1271 vty_out(vty
, "Please specify valid Router ID as a.b.c.d\n");
1272 return CMD_WARNING_CONFIG_FAILED
;
1275 for (int idx
= 5; idx
< argc
; idx
++) {
1276 if (strmatch(argv
[idx
]->text
, "hello-interval"))
1277 vl_config
.hello_interval
= OSPF_HELLO_INTERVAL_DEFAULT
;
1278 else if (strmatch(argv
[idx
]->text
, "retransmit-interval"))
1279 vl_config
.retransmit_interval
=
1280 OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
1281 else if (strmatch(argv
[idx
]->text
, "transmit-delay"))
1282 vl_config
.transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
1283 else if (strmatch(argv
[idx
]->text
, "dead-interval"))
1284 vl_config
.dead_interval
=
1285 OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
1288 /* Action configuration */
1289 return ospf_vl_set(ospf
, &vl_config
);
1292 DEFUN (ospf_area_shortcut
,
1293 ospf_area_shortcut_cmd
,
1294 "area <A.B.C.D|(0-4294967295)> shortcut <default|enable|disable>",
1295 "OSPF area parameters\n"
1296 "OSPF area ID in IP address format\n"
1297 "OSPF area ID as a decimal value\n"
1298 "Configure the area's shortcutting mode\n"
1299 "Set default shortcutting behavior\n"
1300 "Enable shortcutting through the area\n"
1301 "Disable shortcutting through the area\n")
1303 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1304 int idx_ipv4_number
= 1;
1305 int idx_enable_disable
= 3;
1306 struct ospf_area
*area
;
1307 struct in_addr area_id
;
1311 VTY_GET_OSPF_AREA_ID_NO_BB("shortcut", area_id
, format
,
1312 argv
[idx_ipv4_number
]->arg
);
1314 area
= ospf_area_get(ospf
, area_id
);
1315 ospf_area_display_format_set(ospf
, area
, format
);
1317 if (strncmp(argv
[idx_enable_disable
]->arg
, "de", 2) == 0)
1318 mode
= OSPF_SHORTCUT_DEFAULT
;
1319 else if (strncmp(argv
[idx_enable_disable
]->arg
, "di", 2) == 0)
1320 mode
= OSPF_SHORTCUT_DISABLE
;
1321 else if (strncmp(argv
[idx_enable_disable
]->arg
, "e", 1) == 0)
1322 mode
= OSPF_SHORTCUT_ENABLE
;
1324 return CMD_WARNING_CONFIG_FAILED
;
1326 ospf_area_shortcut_set(ospf
, area
, mode
);
1328 if (ospf
->abr_type
!= OSPF_ABR_SHORTCUT
)
1330 "Shortcut area setting will take effect only when the router is configured as Shortcut ABR\n");
1335 DEFUN (no_ospf_area_shortcut
,
1336 no_ospf_area_shortcut_cmd
,
1337 "no area <A.B.C.D|(0-4294967295)> shortcut <enable|disable>",
1339 "OSPF area parameters\n"
1340 "OSPF area ID in IP address format\n"
1341 "OSPF area ID as a decimal value\n"
1342 "Deconfigure the area's shortcutting mode\n"
1343 "Deconfigure enabled shortcutting through the area\n"
1344 "Deconfigure disabled shortcutting through the area\n")
1346 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1347 int idx_ipv4_number
= 2;
1348 struct ospf_area
*area
;
1349 struct in_addr area_id
;
1352 VTY_GET_OSPF_AREA_ID_NO_BB("shortcut", area_id
, format
,
1353 argv
[idx_ipv4_number
]->arg
);
1355 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1359 ospf_area_shortcut_unset(ospf
, area
);
1365 DEFUN (ospf_area_stub
,
1367 "area <A.B.C.D|(0-4294967295)> stub",
1368 "OSPF area parameters\n"
1369 "OSPF area ID in IP address format\n"
1370 "OSPF area ID as a decimal value\n"
1371 "Configure OSPF area as stub\n")
1373 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1374 int idx_ipv4_number
= 1;
1375 struct in_addr area_id
;
1378 VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id
, format
,
1379 argv
[idx_ipv4_number
]->arg
);
1381 ret
= ospf_area_stub_set(ospf
, area_id
);
1382 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1386 "First deconfigure all virtual link through this area\n");
1387 return CMD_WARNING_CONFIG_FAILED
;
1390 /* Flush the external LSAs from the specified area */
1391 ospf_flush_lsa_from_area(ospf
, area_id
, OSPF_AS_EXTERNAL_LSA
);
1392 ospf_area_no_summary_unset(ospf
, area_id
);
1397 DEFUN (ospf_area_stub_no_summary
,
1398 ospf_area_stub_no_summary_cmd
,
1399 "area <A.B.C.D|(0-4294967295)> stub no-summary",
1400 "OSPF stub parameters\n"
1401 "OSPF area ID in IP address format\n"
1402 "OSPF area ID as a decimal value\n"
1403 "Configure OSPF area as stub\n"
1404 "Do not inject inter-area routes into stub\n")
1406 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1407 int idx_ipv4_number
= 1;
1408 struct in_addr area_id
;
1411 VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id
, format
,
1412 argv
[idx_ipv4_number
]->arg
);
1414 ret
= ospf_area_stub_set(ospf
, area_id
);
1415 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1419 "%% Area cannot be stub as it contains a virtual link\n");
1420 return CMD_WARNING_CONFIG_FAILED
;
1423 ospf_area_no_summary_set(ospf
, area_id
);
1428 DEFUN (no_ospf_area_stub
,
1429 no_ospf_area_stub_cmd
,
1430 "no area <A.B.C.D|(0-4294967295)> stub",
1432 "OSPF area parameters\n"
1433 "OSPF area ID in IP address format\n"
1434 "OSPF area ID as a decimal value\n"
1435 "Configure OSPF area as stub\n")
1437 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1438 int idx_ipv4_number
= 2;
1439 struct in_addr area_id
;
1442 VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id
, format
,
1443 argv
[idx_ipv4_number
]->arg
);
1445 ospf_area_stub_unset(ospf
, area_id
);
1446 ospf_area_no_summary_unset(ospf
, area_id
);
1451 DEFUN (no_ospf_area_stub_no_summary
,
1452 no_ospf_area_stub_no_summary_cmd
,
1453 "no area <A.B.C.D|(0-4294967295)> stub no-summary",
1455 "OSPF area parameters\n"
1456 "OSPF area ID in IP address format\n"
1457 "OSPF area ID as a decimal value\n"
1458 "Configure OSPF area as stub\n"
1459 "Do not inject inter-area routes into area\n")
1461 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1462 int idx_ipv4_number
= 2;
1463 struct in_addr area_id
;
1466 VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id
, format
,
1467 argv
[idx_ipv4_number
]->arg
);
1468 ospf_area_no_summary_unset(ospf
, area_id
);
1473 static int ospf_area_nssa_cmd_handler(struct vty
*vty
, int argc
,
1474 struct cmd_token
**argv
, int cfg_nosum
,
1477 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1478 struct in_addr area_id
;
1481 VTY_GET_OSPF_AREA_ID_NO_BB("NSSA", area_id
, format
, argv
[1]->arg
);
1483 ret
= ospf_area_nssa_set(ospf
, area_id
);
1484 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1488 "%% Area cannot be nssa as it contains a virtual link\n");
1489 return CMD_WARNING_CONFIG_FAILED
;
1493 if (strncmp(argv
[3]->text
, "translate-c", 11) == 0)
1494 ospf_area_nssa_translator_role_set(
1495 ospf
, area_id
, OSPF_NSSA_ROLE_CANDIDATE
);
1496 else if (strncmp(argv
[3]->text
, "translate-n", 11) == 0)
1497 ospf_area_nssa_translator_role_set(
1498 ospf
, area_id
, OSPF_NSSA_ROLE_NEVER
);
1499 else if (strncmp(argv
[3]->text
, "translate-a", 11) == 0)
1500 ospf_area_nssa_translator_role_set(
1501 ospf
, area_id
, OSPF_NSSA_ROLE_ALWAYS
);
1503 ospf_area_nssa_translator_role_set(ospf
, area_id
,
1504 OSPF_NSSA_ROLE_CANDIDATE
);
1509 ospf_area_no_summary_set(ospf
, area_id
);
1511 ospf_area_no_summary_unset(ospf
, area_id
);
1514 /* Flush the external LSA for the specified area */
1515 ospf_flush_lsa_from_area(ospf
, area_id
, OSPF_AS_EXTERNAL_LSA
);
1516 ospf_schedule_abr_task(ospf
);
1517 ospf_schedule_asbr_nssa_redist_update(ospf
);
1523 DEFUN (ospf_area_nssa_translate
,
1524 ospf_area_nssa_translate_cmd
,
1525 "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always>",
1526 "OSPF area parameters\n"
1527 "OSPF area ID in IP address format\n"
1528 "OSPF area ID as a decimal value\n"
1529 "Configure OSPF area as nssa\n"
1530 "Configure NSSA-ABR for translate election (default)\n"
1531 "Configure NSSA-ABR to never translate\n"
1532 "Configure NSSA-ABR to always translate\n")
1534 return ospf_area_nssa_cmd_handler(vty
, argc
, argv
, 0, 0);
1537 DEFUN (ospf_area_nssa
,
1539 "area <A.B.C.D|(0-4294967295)> nssa",
1540 "OSPF area parameters\n"
1541 "OSPF area ID in IP address format\n"
1542 "OSPF area ID as a decimal value\n"
1543 "Configure OSPF area as nssa\n")
1545 return ospf_area_nssa_cmd_handler(vty
, argc
, argv
, 0, 0);
1548 DEFUN(ospf_area_nssa_suppress_fa
, ospf_area_nssa_suppress_fa_cmd
,
1549 "area <A.B.C.D|(0-4294967295)> nssa suppress-fa",
1550 "OSPF area parameters\n"
1551 "OSPF area ID in IP address format\n"
1552 "OSPF area ID as a decimal value\n"
1553 "Configure OSPF area as nssa\n"
1554 "Suppress forwarding address\n")
1556 int idx_ipv4_number
= 1;
1557 struct in_addr area_id
;
1560 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1561 VTY_GET_OSPF_AREA_ID_NO_BB("NSSA", area_id
, format
,
1562 argv
[idx_ipv4_number
]->arg
);
1564 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1566 ospf_area_nssa_suppress_fa_set(ospf
, area_id
);
1568 ospf_schedule_abr_task(ospf
);
1573 DEFUN(no_ospf_area_nssa_suppress_fa
, no_ospf_area_nssa_suppress_fa_cmd
,
1574 "no area <A.B.C.D|(0-4294967295)> nssa suppress-fa",
1576 "OSPF area parameters\n"
1577 "OSPF area ID in IP address format\n"
1578 "OSPF area ID as a decimal value\n"
1579 "Configure OSPF area as nssa\n"
1580 "Suppress forwarding address\n")
1582 int idx_ipv4_number
= 2;
1583 struct in_addr area_id
;
1586 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1588 VTY_GET_OSPF_AREA_ID_NO_BB("nssa", area_id
, format
,
1589 argv
[idx_ipv4_number
]->arg
);
1591 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1593 ospf_area_nssa_suppress_fa_unset(ospf
, area_id
);
1595 ospf_schedule_abr_task(ospf
);
1600 DEFUN (ospf_area_nssa_no_summary
,
1601 ospf_area_nssa_no_summary_cmd
,
1602 "area <A.B.C.D|(0-4294967295)> nssa no-summary",
1603 "OSPF area parameters\n"
1604 "OSPF area ID in IP address format\n"
1605 "OSPF area ID as a decimal value\n"
1606 "Configure OSPF area as nssa\n"
1607 "Do not inject inter-area routes into nssa\n")
1609 int idx_ipv4_number
= 1;
1610 struct in_addr area_id
;
1613 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1614 VTY_GET_OSPF_AREA_ID_NO_BB("NSSA", area_id
, format
,
1615 argv
[idx_ipv4_number
]->arg
);
1617 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1619 ospf_area_nssa_no_summary_set(ospf
, area_id
);
1621 ospf_schedule_abr_task(ospf
);
1626 DEFUN (no_ospf_area_nssa_no_summary
,
1627 no_ospf_area_nssa_no_summary_cmd
,
1628 "no area <A.B.C.D|(0-4294967295)> nssa no-summary",
1630 "OSPF area parameters\n"
1631 "OSPF area ID in IP address format\n"
1632 "OSPF area ID as a decimal value\n"
1633 "Configure OSPF area as nssa\n"
1634 "Do not inject inter-area routes into nssa\n")
1636 int idx_ipv4_number
= 2;
1637 struct in_addr area_id
;
1640 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1642 VTY_GET_OSPF_AREA_ID_NO_BB("nssa", area_id
, format
,
1643 argv
[idx_ipv4_number
]->arg
);
1645 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1647 ospf_area_no_summary_unset(ospf
, area_id
);
1649 ospf_schedule_abr_task(ospf
);
1654 DEFUN (no_ospf_area_nssa
,
1655 no_ospf_area_nssa_cmd
,
1656 "no area <A.B.C.D|(0-4294967295)> nssa [<translate-candidate|translate-never|translate-always>]",
1658 "OSPF area parameters\n"
1659 "OSPF area ID in IP address format\n"
1660 "OSPF area ID as a decimal value\n"
1661 "Configure OSPF area as nssa\n"
1662 "Configure NSSA-ABR for translate election (default)\n"
1663 "Configure NSSA-ABR to never translate\n"
1664 "Configure NSSA-ABR to always translate\n")
1666 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1667 int idx_ipv4_number
= 2;
1668 struct in_addr area_id
;
1671 VTY_GET_OSPF_AREA_ID_NO_BB("NSSA", area_id
, format
,
1672 argv
[idx_ipv4_number
]->arg
);
1674 /* Flush the NSSA LSA for the specified area */
1675 ospf_flush_lsa_from_area(ospf
, area_id
, OSPF_AS_NSSA_LSA
);
1676 ospf_area_nssa_unset(ospf
, area_id
, argc
);
1678 ospf_schedule_abr_task(ospf
);
1684 DEFUN (ospf_area_default_cost
,
1685 ospf_area_default_cost_cmd
,
1686 "area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1687 "OSPF area parameters\n"
1688 "OSPF area ID in IP address format\n"
1689 "OSPF area ID as a decimal value\n"
1690 "Set the summary-default cost of a NSSA or stub area\n"
1691 "Stub's advertised default summary cost\n")
1693 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1694 int idx_ipv4_number
= 1;
1696 struct ospf_area
*area
;
1697 struct in_addr area_id
;
1700 struct prefix_ipv4 p
;
1702 VTY_GET_OSPF_AREA_ID_NO_BB("default-cost", area_id
, format
,
1703 argv
[idx_ipv4_number
]->arg
);
1704 cost
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1706 area
= ospf_area_get(ospf
, area_id
);
1707 ospf_area_display_format_set(ospf
, area
, format
);
1709 if (area
->external_routing
== OSPF_AREA_DEFAULT
) {
1710 vty_out(vty
, "The area is neither stub, nor NSSA\n");
1711 return CMD_WARNING_CONFIG_FAILED
;
1714 area
->default_cost
= cost
;
1717 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1719 if (IS_DEBUG_OSPF_EVENT
)
1721 "ospf_abr_announce_stub_defaults(): announcing 0.0.0.0/0 to area %pI4",
1723 ospf_abr_announce_network_to_area(&p
, area
->default_cost
, area
);
1728 DEFUN (no_ospf_area_default_cost
,
1729 no_ospf_area_default_cost_cmd
,
1730 "no area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1732 "OSPF area parameters\n"
1733 "OSPF area ID in IP address format\n"
1734 "OSPF area ID as a decimal value\n"
1735 "Set the summary-default cost of a NSSA or stub area\n"
1736 "Stub's advertised default summary cost\n")
1738 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1739 int idx_ipv4_number
= 2;
1740 struct ospf_area
*area
;
1741 struct in_addr area_id
;
1743 struct prefix_ipv4 p
;
1745 VTY_GET_OSPF_AREA_ID_NO_BB("default-cost", area_id
, format
,
1746 argv
[idx_ipv4_number
]->arg
);
1748 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1752 if (area
->external_routing
== OSPF_AREA_DEFAULT
) {
1753 vty_out(vty
, "The area is neither stub, nor NSSA\n");
1754 return CMD_WARNING_CONFIG_FAILED
;
1757 area
->default_cost
= 1;
1760 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1762 if (IS_DEBUG_OSPF_EVENT
)
1764 "ospf_abr_announce_stub_defaults(): announcing 0.0.0.0/0 to area %pI4",
1766 ospf_abr_announce_network_to_area(&p
, area
->default_cost
, area
);
1769 ospf_area_check_free(ospf
, area_id
);
1774 DEFUN (ospf_area_export_list
,
1775 ospf_area_export_list_cmd
,
1776 "area <A.B.C.D|(0-4294967295)> export-list ACCESSLIST4_NAME",
1777 "OSPF area parameters\n"
1778 "OSPF area ID in IP address format\n"
1779 "OSPF area ID as a decimal value\n"
1780 "Set the filter for networks announced to other areas\n"
1781 "Name of the access-list\n")
1783 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1784 int idx_ipv4_number
= 1;
1785 struct ospf_area
*area
;
1786 struct in_addr area_id
;
1789 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1791 area
= ospf_area_get(ospf
, area_id
);
1792 ospf_area_display_format_set(ospf
, area
, format
);
1793 ospf_area_export_list_set(ospf
, area
, argv
[3]->arg
);
1798 DEFUN (no_ospf_area_export_list
,
1799 no_ospf_area_export_list_cmd
,
1800 "no area <A.B.C.D|(0-4294967295)> export-list ACCESSLIST4_NAME",
1802 "OSPF area parameters\n"
1803 "OSPF area ID in IP address format\n"
1804 "OSPF area ID as a decimal value\n"
1805 "Unset the filter for networks announced to other areas\n"
1806 "Name of the access-list\n")
1808 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1809 int idx_ipv4_number
= 2;
1810 struct ospf_area
*area
;
1811 struct in_addr area_id
;
1814 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1816 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1820 ospf_area_export_list_unset(ospf
, area
);
1826 DEFUN (ospf_area_import_list
,
1827 ospf_area_import_list_cmd
,
1828 "area <A.B.C.D|(0-4294967295)> import-list ACCESSLIST4_NAME",
1829 "OSPF area parameters\n"
1830 "OSPF area ID in IP address format\n"
1831 "OSPF area ID as a decimal value\n"
1832 "Set the filter for networks from other areas announced to the specified one\n"
1833 "Name of the access-list\n")
1835 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1836 int idx_ipv4_number
= 1;
1837 struct ospf_area
*area
;
1838 struct in_addr area_id
;
1841 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1843 area
= ospf_area_get(ospf
, area_id
);
1844 ospf_area_display_format_set(ospf
, area
, format
);
1845 ospf_area_import_list_set(ospf
, area
, argv
[3]->arg
);
1850 DEFUN (no_ospf_area_import_list
,
1851 no_ospf_area_import_list_cmd
,
1852 "no area <A.B.C.D|(0-4294967295)> import-list ACCESSLIST4_NAME",
1854 "OSPF area parameters\n"
1855 "OSPF area ID in IP address format\n"
1856 "OSPF area ID as a decimal value\n"
1857 "Unset the filter for networks announced to other areas\n"
1858 "Name of the access-list\n")
1860 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1861 int idx_ipv4_number
= 2;
1862 struct ospf_area
*area
;
1863 struct in_addr area_id
;
1866 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1868 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1872 ospf_area_import_list_unset(ospf
, area
);
1877 DEFUN (ospf_area_filter_list
,
1878 ospf_area_filter_list_cmd
,
1879 "area <A.B.C.D|(0-4294967295)> filter-list prefix PREFIXLIST_NAME <in|out>",
1880 "OSPF area parameters\n"
1881 "OSPF area ID in IP address format\n"
1882 "OSPF area ID as a decimal value\n"
1883 "Filter networks between OSPF areas\n"
1884 "Filter prefixes between OSPF areas\n"
1885 "Name of an IP prefix-list\n"
1886 "Filter networks sent to this area\n"
1887 "Filter networks sent from this area\n")
1889 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1890 int idx_ipv4_number
= 1;
1893 struct ospf_area
*area
;
1894 struct in_addr area_id
;
1895 struct prefix_list
*plist
;
1898 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1900 area
= ospf_area_get(ospf
, area_id
);
1901 ospf_area_display_format_set(ospf
, area
, format
);
1902 plist
= prefix_list_lookup(AFI_IP
, argv
[idx_word
]->arg
);
1903 if (strncmp(argv
[idx_in_out
]->arg
, "in", 2) == 0) {
1904 PREFIX_LIST_IN(area
) = plist
;
1905 if (PREFIX_NAME_IN(area
))
1906 free(PREFIX_NAME_IN(area
));
1908 PREFIX_NAME_IN(area
) = strdup(argv
[idx_word
]->arg
);
1909 ospf_schedule_abr_task(ospf
);
1911 PREFIX_LIST_OUT(area
) = plist
;
1912 if (PREFIX_NAME_OUT(area
))
1913 free(PREFIX_NAME_OUT(area
));
1915 PREFIX_NAME_OUT(area
) = strdup(argv
[idx_word
]->arg
);
1916 ospf_schedule_abr_task(ospf
);
1922 DEFUN (no_ospf_area_filter_list
,
1923 no_ospf_area_filter_list_cmd
,
1924 "no area <A.B.C.D|(0-4294967295)> filter-list prefix PREFIXLIST_NAME <in|out>",
1926 "OSPF area parameters\n"
1927 "OSPF area ID in IP address format\n"
1928 "OSPF area ID as a decimal value\n"
1929 "Filter networks between OSPF areas\n"
1930 "Filter prefixes between OSPF areas\n"
1931 "Name of an IP prefix-list\n"
1932 "Filter networks sent to this area\n"
1933 "Filter networks sent from this area\n")
1935 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1936 int idx_ipv4_number
= 2;
1939 struct ospf_area
*area
;
1940 struct in_addr area_id
;
1943 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1945 if ((area
= ospf_area_lookup_by_area_id(ospf
, area_id
)) == NULL
)
1948 if (strncmp(argv
[idx_in_out
]->arg
, "in", 2) == 0) {
1949 if (PREFIX_NAME_IN(area
))
1950 if (strcmp(PREFIX_NAME_IN(area
), argv
[idx_word
]->arg
)
1954 PREFIX_LIST_IN(area
) = NULL
;
1955 if (PREFIX_NAME_IN(area
))
1956 free(PREFIX_NAME_IN(area
));
1958 PREFIX_NAME_IN(area
) = NULL
;
1960 ospf_schedule_abr_task(ospf
);
1962 if (PREFIX_NAME_OUT(area
))
1963 if (strcmp(PREFIX_NAME_OUT(area
), argv
[idx_word
]->arg
)
1967 PREFIX_LIST_OUT(area
) = NULL
;
1968 if (PREFIX_NAME_OUT(area
))
1969 free(PREFIX_NAME_OUT(area
));
1971 PREFIX_NAME_OUT(area
) = NULL
;
1973 ospf_schedule_abr_task(ospf
);
1980 DEFUN (ospf_area_authentication_message_digest
,
1981 ospf_area_authentication_message_digest_cmd
,
1982 "[no] area <A.B.C.D|(0-4294967295)> authentication message-digest",
1984 "OSPF area parameters\n"
1985 "OSPF area ID in IP address format\n"
1986 "OSPF area ID as a decimal value\n"
1987 "Enable authentication\n"
1988 "Use message-digest authentication\n")
1990 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1992 struct ospf_area
*area
;
1993 struct in_addr area_id
;
1996 argv_find(argv
, argc
, "area", &idx
);
1997 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx
+ 1]->arg
);
1999 area
= ospf_area_get(ospf
, area_id
);
2000 ospf_area_display_format_set(ospf
, area
, format
);
2001 area
->auth_type
= strmatch(argv
[0]->text
, "no")
2003 : OSPF_AUTH_CRYPTOGRAPHIC
;
2008 DEFUN (ospf_area_authentication
,
2009 ospf_area_authentication_cmd
,
2010 "area <A.B.C.D|(0-4294967295)> authentication",
2011 "OSPF area parameters\n"
2012 "OSPF area ID in IP address format\n"
2013 "OSPF area ID as a decimal value\n"
2014 "Enable authentication\n")
2016 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2017 int idx_ipv4_number
= 1;
2018 struct ospf_area
*area
;
2019 struct in_addr area_id
;
2022 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
2024 area
= ospf_area_get(ospf
, area_id
);
2025 ospf_area_display_format_set(ospf
, area
, format
);
2026 area
->auth_type
= OSPF_AUTH_SIMPLE
;
2031 DEFUN (no_ospf_area_authentication
,
2032 no_ospf_area_authentication_cmd
,
2033 "no area <A.B.C.D|(0-4294967295)> authentication",
2035 "OSPF area parameters\n"
2036 "OSPF area ID in IP address format\n"
2037 "OSPF area ID as a decimal value\n"
2038 "Enable authentication\n")
2040 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2041 int idx_ipv4_number
= 2;
2042 struct ospf_area
*area
;
2043 struct in_addr area_id
;
2046 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
2048 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
2052 area
->auth_type
= OSPF_AUTH_NULL
;
2054 ospf_area_check_free(ospf
, area_id
);
2060 DEFUN (ospf_abr_type
,
2062 "ospf abr-type <cisco|ibm|shortcut|standard>",
2063 "OSPF specific commands\n"
2064 "Set OSPF ABR type\n"
2065 "Alternative ABR, cisco implementation\n"
2066 "Alternative ABR, IBM implementation\n"
2068 "Standard behavior (RFC2328)\n")
2070 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2072 uint8_t abr_type
= OSPF_ABR_UNKNOWN
;
2074 if (strncmp(argv
[idx_vendor
]->arg
, "c", 1) == 0)
2075 abr_type
= OSPF_ABR_CISCO
;
2076 else if (strncmp(argv
[idx_vendor
]->arg
, "i", 1) == 0)
2077 abr_type
= OSPF_ABR_IBM
;
2078 else if (strncmp(argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2079 abr_type
= OSPF_ABR_SHORTCUT
;
2080 else if (strncmp(argv
[idx_vendor
]->arg
, "st", 2) == 0)
2081 abr_type
= OSPF_ABR_STAND
;
2083 return CMD_WARNING_CONFIG_FAILED
;
2085 /* If ABR type value is changed, schedule ABR task. */
2086 if (ospf
->abr_type
!= abr_type
) {
2087 ospf
->abr_type
= abr_type
;
2088 ospf_schedule_abr_task(ospf
);
2094 DEFUN (no_ospf_abr_type
,
2095 no_ospf_abr_type_cmd
,
2096 "no ospf abr-type <cisco|ibm|shortcut|standard>",
2098 "OSPF specific commands\n"
2099 "Set OSPF ABR type\n"
2100 "Alternative ABR, cisco implementation\n"
2101 "Alternative ABR, IBM implementation\n"
2105 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2107 uint8_t abr_type
= OSPF_ABR_UNKNOWN
;
2109 if (strncmp(argv
[idx_vendor
]->arg
, "c", 1) == 0)
2110 abr_type
= OSPF_ABR_CISCO
;
2111 else if (strncmp(argv
[idx_vendor
]->arg
, "i", 1) == 0)
2112 abr_type
= OSPF_ABR_IBM
;
2113 else if (strncmp(argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2114 abr_type
= OSPF_ABR_SHORTCUT
;
2115 else if (strncmp(argv
[idx_vendor
]->arg
, "st", 2) == 0)
2116 abr_type
= OSPF_ABR_STAND
;
2118 return CMD_WARNING_CONFIG_FAILED
;
2120 /* If ABR type value is changed, schedule ABR task. */
2121 if (ospf
->abr_type
== abr_type
) {
2122 ospf
->abr_type
= OSPF_ABR_DEFAULT
;
2123 ospf_schedule_abr_task(ospf
);
2129 DEFUN (ospf_log_adjacency_changes
,
2130 ospf_log_adjacency_changes_cmd
,
2131 "log-adjacency-changes",
2132 "Log changes in adjacency state\n")
2134 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2136 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2137 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2141 DEFUN (ospf_log_adjacency_changes_detail
,
2142 ospf_log_adjacency_changes_detail_cmd
,
2143 "log-adjacency-changes detail",
2144 "Log changes in adjacency state\n"
2145 "Log all state changes\n")
2147 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2149 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2150 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2154 DEFUN (no_ospf_log_adjacency_changes
,
2155 no_ospf_log_adjacency_changes_cmd
,
2156 "no log-adjacency-changes",
2158 "Log changes in adjacency state\n")
2160 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2162 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2163 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2167 DEFUN (no_ospf_log_adjacency_changes_detail
,
2168 no_ospf_log_adjacency_changes_detail_cmd
,
2169 "no log-adjacency-changes detail",
2171 "Log changes in adjacency state\n"
2172 "Log all state changes\n")
2174 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2176 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2180 DEFUN (ospf_compatible_rfc1583
,
2181 ospf_compatible_rfc1583_cmd
,
2182 "compatible rfc1583",
2183 "OSPF compatibility list\n"
2184 "compatible with RFC 1583\n")
2186 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2188 if (!CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)) {
2189 SET_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2190 ospf_spf_calculate_schedule(ospf
, SPF_FLAG_CONFIG_CHANGE
);
2195 DEFUN (no_ospf_compatible_rfc1583
,
2196 no_ospf_compatible_rfc1583_cmd
,
2197 "no compatible rfc1583",
2199 "OSPF compatibility list\n"
2200 "compatible with RFC 1583\n")
2202 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2204 if (CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)) {
2205 UNSET_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2206 ospf_spf_calculate_schedule(ospf
, SPF_FLAG_CONFIG_CHANGE
);
2211 ALIAS(ospf_compatible_rfc1583
, ospf_rfc1583_flag_cmd
,
2212 "ospf rfc1583compatibility",
2213 "OSPF specific commands\n"
2214 "Enable the RFC1583Compatibility flag\n")
2216 ALIAS(no_ospf_compatible_rfc1583
, no_ospf_rfc1583_flag_cmd
,
2217 "no ospf rfc1583compatibility", NO_STR
2218 "OSPF specific commands\n"
2219 "Disable the RFC1583Compatibility flag\n")
2221 static void ospf_table_reinstall_routes(struct ospf
*ospf
,
2222 struct route_table
*rt
)
2224 struct route_node
*rn
;
2229 for (rn
= route_top(rt
); rn
; rn
= route_next(rn
)) {
2230 struct ospf_route
*or;
2236 if (or->type
== OSPF_DESTINATION_NETWORK
)
2237 ospf_zebra_add(ospf
, (struct prefix_ipv4
*)&rn
->p
, or);
2238 else if (or->type
== OSPF_DESTINATION_DISCARD
)
2239 ospf_zebra_add_discard(ospf
,
2240 (struct prefix_ipv4
*)&rn
->p
);
2244 static void ospf_reinstall_routes(struct ospf
*ospf
)
2246 ospf_table_reinstall_routes(ospf
, ospf
->new_table
);
2247 ospf_table_reinstall_routes(ospf
, ospf
->new_external_route
);
2250 DEFPY (ospf_send_extra_data
,
2251 ospf_send_extra_data_cmd
,
2252 "[no] ospf send-extra-data zebra",
2255 "Extra data to Zebra for display/use\n"
2258 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2260 if (no
&& CHECK_FLAG(ospf
->config
, OSPF_SEND_EXTRA_DATA_TO_ZEBRA
)) {
2261 UNSET_FLAG(ospf
->config
, OSPF_SEND_EXTRA_DATA_TO_ZEBRA
);
2262 ospf_reinstall_routes(ospf
);
2263 } else if (!CHECK_FLAG(ospf
->config
, OSPF_SEND_EXTRA_DATA_TO_ZEBRA
)) {
2264 SET_FLAG(ospf
->config
, OSPF_SEND_EXTRA_DATA_TO_ZEBRA
);
2265 ospf_reinstall_routes(ospf
);
2271 static int ospf_timers_spf_set(struct vty
*vty
, unsigned int delay
,
2272 unsigned int hold
, unsigned int max
)
2274 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2276 ospf
->spf_delay
= delay
;
2277 ospf
->spf_holdtime
= hold
;
2278 ospf
->spf_max_holdtime
= max
;
2283 DEFUN (ospf_timers_min_ls_interval
,
2284 ospf_timers_min_ls_interval_cmd
,
2285 "timers throttle lsa all (0-5000)",
2286 "Adjust routing timers\n"
2287 "Throttling adaptive timer\n"
2288 "LSA delay between transmissions\n"
2290 "Delay (msec) between sending LSAs\n")
2292 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2294 unsigned int interval
;
2297 vty_out(vty
, "Insufficient arguments\n");
2298 return CMD_WARNING_CONFIG_FAILED
;
2301 interval
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2303 ospf
->min_ls_interval
= interval
;
2308 DEFUN (no_ospf_timers_min_ls_interval
,
2309 no_ospf_timers_min_ls_interval_cmd
,
2310 "no timers throttle lsa all [(0-5000)]",
2312 "Adjust routing timers\n"
2313 "Throttling adaptive timer\n"
2314 "LSA delay between transmissions\n"
2316 "Delay (msec) between sending LSAs\n")
2318 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2319 ospf
->min_ls_interval
= OSPF_MIN_LS_INTERVAL
;
2324 DEFUN (ospf_timers_throttle_spf
,
2325 ospf_timers_throttle_spf_cmd
,
2326 "timers throttle spf (0-600000) (0-600000) (0-600000)",
2327 "Adjust routing timers\n"
2328 "Throttling adaptive timer\n"
2330 "Delay (msec) from first change received till SPF calculation\n"
2331 "Initial hold time (msec) between consecutive SPF calculations\n"
2332 "Maximum hold time (msec)\n")
2335 int idx_number_2
= 4;
2336 int idx_number_3
= 5;
2337 unsigned int delay
, hold
, max
;
2340 vty_out(vty
, "Insufficient arguments\n");
2341 return CMD_WARNING_CONFIG_FAILED
;
2344 delay
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2345 hold
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
2346 max
= strtoul(argv
[idx_number_3
]->arg
, NULL
, 10);
2348 return ospf_timers_spf_set(vty
, delay
, hold
, max
);
2351 DEFUN (no_ospf_timers_throttle_spf
,
2352 no_ospf_timers_throttle_spf_cmd
,
2353 "no timers throttle spf [(0-600000)(0-600000)(0-600000)]",
2355 "Adjust routing timers\n"
2356 "Throttling adaptive timer\n"
2358 "Delay (msec) from first change received till SPF calculation\n"
2359 "Initial hold time (msec) between consecutive SPF calculations\n"
2360 "Maximum hold time (msec)\n")
2362 return ospf_timers_spf_set(vty
, OSPF_SPF_DELAY_DEFAULT
,
2363 OSPF_SPF_HOLDTIME_DEFAULT
,
2364 OSPF_SPF_MAX_HOLDTIME_DEFAULT
);
2368 DEFUN (ospf_timers_lsa_min_arrival
,
2369 ospf_timers_lsa_min_arrival_cmd
,
2370 "timers lsa min-arrival (0-600000)",
2371 "Adjust routing timers\n"
2373 "Minimum delay in receiving new version of a LSA\n"
2374 "Delay in milliseconds\n")
2376 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2377 ospf
->min_ls_arrival
= strtoul(argv
[argc
- 1]->arg
, NULL
, 10);
2381 DEFUN (no_ospf_timers_lsa_min_arrival
,
2382 no_ospf_timers_lsa_min_arrival_cmd
,
2383 "no timers lsa min-arrival [(0-600000)]",
2385 "Adjust routing timers\n"
2387 "Minimum delay in receiving new version of a LSA\n"
2388 "Delay in milliseconds\n")
2390 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2391 unsigned int minarrival
;
2394 minarrival
= strtoul(argv
[argc
- 1]->arg
, NULL
, 10);
2396 if (ospf
->min_ls_arrival
!= minarrival
2397 || minarrival
== OSPF_MIN_LS_ARRIVAL
)
2401 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2406 DEFUN (ospf_neighbor
,
2408 "neighbor A.B.C.D [priority (0-255) [poll-interval (1-65535)]]",
2410 "Neighbor IP address\n"
2411 "Neighbor Priority\n"
2413 "Dead Neighbor Polling interval\n"
2416 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2420 struct in_addr nbr_addr
;
2421 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2422 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2424 if (!inet_aton(argv
[idx_ipv4
]->arg
, &nbr_addr
)) {
2425 vty_out(vty
, "Please specify Neighbor ID by A.B.C.D\n");
2426 return CMD_WARNING_CONFIG_FAILED
;
2430 priority
= strtoul(argv
[idx_pri
]->arg
, NULL
, 10);
2433 interval
= strtoul(argv
[idx_poll
]->arg
, NULL
, 10);
2435 ospf_nbr_nbma_set(ospf
, nbr_addr
);
2438 ospf_nbr_nbma_priority_set(ospf
, nbr_addr
, priority
);
2441 ospf_nbr_nbma_poll_interval_set(ospf
, nbr_addr
, interval
);
2446 DEFUN (ospf_neighbor_poll_interval
,
2447 ospf_neighbor_poll_interval_cmd
,
2448 "neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2450 "Neighbor IP address\n"
2451 "Dead Neighbor Polling interval\n"
2453 "OSPF priority of non-broadcast neighbor\n"
2456 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2460 struct in_addr nbr_addr
;
2461 unsigned int priority
;
2462 unsigned int interval
;
2464 if (!inet_aton(argv
[idx_ipv4
]->arg
, &nbr_addr
)) {
2465 vty_out(vty
, "Please specify Neighbor ID by A.B.C.D\n");
2466 return CMD_WARNING_CONFIG_FAILED
;
2469 interval
= strtoul(argv
[idx_poll
]->arg
, NULL
, 10);
2471 priority
= argc
> 4 ? strtoul(argv
[idx_pri
]->arg
, NULL
, 10)
2472 : OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2474 ospf_nbr_nbma_set(ospf
, nbr_addr
);
2475 ospf_nbr_nbma_poll_interval_set(ospf
, nbr_addr
, interval
);
2478 ospf_nbr_nbma_priority_set(ospf
, nbr_addr
, priority
);
2483 DEFUN (no_ospf_neighbor
,
2484 no_ospf_neighbor_cmd
,
2485 "no neighbor A.B.C.D [priority (0-255) [poll-interval (1-65525)]]",
2488 "Neighbor IP address\n"
2489 "Neighbor Priority\n"
2491 "Dead Neighbor Polling interval\n"
2494 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2496 struct in_addr nbr_addr
;
2498 if (!inet_aton(argv
[idx_ipv4
]->arg
, &nbr_addr
)) {
2499 vty_out(vty
, "Please specify Neighbor ID by A.B.C.D\n");
2500 return CMD_WARNING_CONFIG_FAILED
;
2503 (void)ospf_nbr_nbma_unset(ospf
, nbr_addr
);
2508 DEFUN (no_ospf_neighbor_poll
,
2509 no_ospf_neighbor_poll_cmd
,
2510 "no neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2513 "Neighbor IP address\n"
2514 "Dead Neighbor Polling interval\n"
2516 "Neighbor Priority\n"
2519 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2521 struct in_addr nbr_addr
;
2523 if (!inet_aton(argv
[idx_ipv4
]->arg
, &nbr_addr
)) {
2524 vty_out(vty
, "Please specify Neighbor ID by A.B.C.D\n");
2525 return CMD_WARNING_CONFIG_FAILED
;
2528 (void)ospf_nbr_nbma_unset(ospf
, nbr_addr
);
2533 DEFUN (ospf_refresh_timer
,
2534 ospf_refresh_timer_cmd
,
2535 "refresh timer (10-1800)",
2536 "Adjust refresh parameters\n"
2537 "Set refresh timer\n"
2538 "Timer value in seconds\n")
2540 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2542 unsigned int interval
;
2544 interval
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2545 interval
= (interval
/ OSPF_LSA_REFRESHER_GRANULARITY
)
2546 * OSPF_LSA_REFRESHER_GRANULARITY
;
2548 ospf_timers_refresh_set(ospf
, interval
);
2553 DEFUN (no_ospf_refresh_timer
,
2554 no_ospf_refresh_timer_val_cmd
,
2555 "no refresh timer [(10-1800)]",
2557 "Adjust refresh parameters\n"
2558 "Unset refresh timer\n"
2559 "Timer value in seconds\n")
2561 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2563 unsigned int interval
;
2566 interval
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2568 if (ospf
->lsa_refresh_interval
!= interval
2569 || interval
== OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
2573 ospf_timers_refresh_unset(ospf
);
2579 DEFUN (ospf_auto_cost_reference_bandwidth
,
2580 ospf_auto_cost_reference_bandwidth_cmd
,
2581 "auto-cost reference-bandwidth (1-4294967)",
2582 "Calculate OSPF interface cost according to bandwidth\n"
2583 "Use reference bandwidth method to assign OSPF cost\n"
2584 "The reference bandwidth in terms of Mbits per second\n")
2586 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2587 struct vrf
*vrf
= vrf_lookup_by_id(ospf
->vrf_id
);
2590 struct interface
*ifp
;
2592 refbw
= strtol(argv
[idx_number
]->arg
, NULL
, 10);
2593 if (refbw
< 1 || refbw
> 4294967) {
2594 vty_out(vty
, "reference-bandwidth value is invalid\n");
2595 return CMD_WARNING_CONFIG_FAILED
;
2598 /* If reference bandwidth is changed. */
2599 if ((refbw
) == ospf
->ref_bandwidth
)
2602 ospf
->ref_bandwidth
= refbw
;
2603 FOR_ALL_INTERFACES (vrf
, ifp
)
2604 ospf_if_recalculate_output_cost(ifp
);
2609 DEFUN (no_ospf_auto_cost_reference_bandwidth
,
2610 no_ospf_auto_cost_reference_bandwidth_cmd
,
2611 "no auto-cost reference-bandwidth [(1-4294967)]",
2613 "Calculate OSPF interface cost according to bandwidth\n"
2614 "Use reference bandwidth method to assign OSPF cost\n"
2615 "The reference bandwidth in terms of Mbits per second\n")
2617 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2618 struct vrf
*vrf
= vrf_lookup_by_id(ospf
->vrf_id
);
2619 struct interface
*ifp
;
2621 if (ospf
->ref_bandwidth
== OSPF_DEFAULT_REF_BANDWIDTH
)
2624 ospf
->ref_bandwidth
= OSPF_DEFAULT_REF_BANDWIDTH
;
2625 vty_out(vty
, "%% OSPF: Reference bandwidth is changed.\n");
2627 " Please ensure reference bandwidth is consistent across all routers\n");
2629 FOR_ALL_INTERFACES (vrf
, ifp
)
2630 ospf_if_recalculate_output_cost(ifp
);
2635 DEFUN (ospf_write_multiplier
,
2636 ospf_write_multiplier_cmd
,
2637 "ospf write-multiplier (1-100)",
2638 "OSPF specific commands\n"
2639 "Write multiplier\n"
2640 "Maximum number of interface serviced per write\n")
2642 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2644 uint32_t write_oi_count
;
2651 write_oi_count
= strtol(argv
[idx_number
]->arg
, NULL
, 10);
2652 if (write_oi_count
< 1 || write_oi_count
> 100) {
2653 vty_out(vty
, "write-multiplier value is invalid\n");
2654 return CMD_WARNING_CONFIG_FAILED
;
2657 ospf
->write_oi_count
= write_oi_count
;
2661 ALIAS(ospf_write_multiplier
, write_multiplier_cmd
, "write-multiplier (1-100)",
2662 "Write multiplier\n"
2663 "Maximum number of interface serviced per write\n")
2665 DEFUN (no_ospf_write_multiplier
,
2666 no_ospf_write_multiplier_cmd
,
2667 "no ospf write-multiplier (1-100)",
2669 "OSPF specific commands\n"
2670 "Write multiplier\n"
2671 "Maximum number of interface serviced per write\n")
2673 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2675 ospf
->write_oi_count
= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
;
2679 ALIAS(no_ospf_write_multiplier
, no_write_multiplier_cmd
,
2680 "no write-multiplier (1-100)", NO_STR
2681 "Write multiplier\n"
2682 "Maximum number of interface serviced per write\n")
2684 DEFUN(ospf_ti_lfa
, ospf_ti_lfa_cmd
, "fast-reroute ti-lfa [node-protection]",
2685 "Fast Reroute for MPLS and IP resilience\n"
2686 "Topology Independent LFA (Loop-Free Alternate)\n"
2687 "TI-LFA node protection (default is link protection)\n")
2689 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2691 ospf
->ti_lfa_enabled
= true;
2694 ospf
->ti_lfa_protection_type
= OSPF_TI_LFA_NODE_PROTECTION
;
2696 ospf
->ti_lfa_protection_type
= OSPF_TI_LFA_LINK_PROTECTION
;
2698 ospf_spf_calculate_schedule(ospf
, SPF_FLAG_CONFIG_CHANGE
);
2703 DEFUN(no_ospf_ti_lfa
, no_ospf_ti_lfa_cmd
,
2704 "no fast-reroute ti-lfa [node-protection]",
2706 "Fast Reroute for MPLS and IP resilience\n"
2707 "Topology Independent LFA (Loop-Free Alternate)\n"
2708 "TI-LFA node protection (default is link protection)\n")
2710 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2712 ospf
->ti_lfa_enabled
= false;
2714 ospf
->ti_lfa_protection_type
= OSPF_TI_LFA_UNDEFINED_PROTECTION
;
2716 ospf_spf_calculate_schedule(ospf
, SPF_FLAG_CONFIG_CHANGE
);
2721 static void ospf_maxpath_set(struct vty
*vty
, struct ospf
*ospf
, uint16_t paths
)
2723 if (ospf
->max_multipath
== paths
)
2726 ospf
->max_multipath
= paths
;
2728 /* Send deletion notification to zebra to delete all
2729 * ospf specific routes and reinitiat SPF to reflect
2730 * the new max multipath.
2732 ospf_restart_spf(ospf
);
2735 /* Ospf Maximum multiple paths config support */
2736 DEFUN (ospf_max_multipath
,
2737 ospf_max_multipath_cmd
,
2738 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2739 "Max no of multiple paths for ECMP support\n"
2740 "Number of paths\n")
2742 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2746 maxpaths
= strtol(argv
[idx_number
]->arg
, NULL
, 10);
2748 ospf_maxpath_set(vty
, ospf
, maxpaths
);
2752 DEFUN (no_ospf_max_multipath
,
2753 no_ospf_max_multipath_cmd
,
2756 "Max no of multiple paths for ECMP support\n")
2758 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2759 uint16_t maxpaths
= MULTIPATH_NUM
;
2761 ospf_maxpath_set(vty
, ospf
, maxpaths
);
2765 static const char *const ospf_abr_type_descr_str
[] = {
2766 "Unknown", "Standard (RFC2328)", "Alternative IBM",
2767 "Alternative Cisco", "Alternative Shortcut"
2770 static const char *const ospf_shortcut_mode_descr_str
[] = {
2771 "Default", "Enabled", "Disabled"
2774 static void show_ip_ospf_area(struct vty
*vty
, struct ospf_area
*area
,
2775 json_object
*json_areas
, bool use_json
)
2777 json_object
*json_area
= NULL
;
2778 char buf
[PREFIX_STRLEN
];
2781 json_area
= json_object_new_object();
2785 vty_out(vty
, " Area ID: %pI4", &area
->area_id
);
2787 /* Show Area type/mode. */
2788 if (OSPF_IS_AREA_BACKBONE(area
)) {
2790 json_object_boolean_true_add(json_area
, "backbone");
2792 vty_out(vty
, " (Backbone)\n");
2795 if (area
->external_routing
== OSPF_AREA_STUB
) {
2796 if (area
->no_summary
)
2797 json_object_boolean_true_add(
2798 json_area
, "stubNoSummary");
2799 if (area
->shortcut_configured
)
2800 json_object_boolean_true_add(
2801 json_area
, "stubShortcut");
2802 } else if (area
->external_routing
== OSPF_AREA_NSSA
) {
2803 if (area
->no_summary
)
2804 json_object_boolean_true_add(
2805 json_area
, "nssaNoSummary");
2806 if (area
->shortcut_configured
)
2807 json_object_boolean_true_add(
2808 json_area
, "nssaShortcut");
2811 json_object_string_add(
2812 json_area
, "shortcuttingMode",
2813 ospf_shortcut_mode_descr_str
2814 [area
->shortcut_configured
]);
2815 if (area
->shortcut_capability
)
2816 json_object_boolean_true_add(json_area
,
2819 if (area
->external_routing
== OSPF_AREA_STUB
)
2820 vty_out(vty
, " (Stub%s%s)",
2821 area
->no_summary
? ", no summary" : "",
2822 area
->shortcut_configured
? "; " : "");
2823 else if (area
->external_routing
== OSPF_AREA_NSSA
)
2824 vty_out(vty
, " (NSSA%s%s)",
2825 area
->no_summary
? ", no summary" : "",
2826 area
->shortcut_configured
? "; " : "");
2829 vty_out(vty
, " Shortcutting mode: %s",
2830 ospf_shortcut_mode_descr_str
2831 [area
->shortcut_configured
]);
2832 vty_out(vty
, ", S-bit consensus: %s\n",
2833 area
->shortcut_capability
? "ok" : "no");
2837 /* Show number of interfaces */
2839 json_object_int_add(json_area
, "areaIfTotalCounter",
2840 listcount(area
->oiflist
));
2841 json_object_int_add(json_area
, "areaIfActiveCounter",
2845 " Number of interfaces in this area: Total: %d, Active: %d\n",
2846 listcount(area
->oiflist
), area
->act_ints
);
2848 if (area
->external_routing
== OSPF_AREA_NSSA
) {
2850 json_object_boolean_true_add(json_area
, "nssa");
2851 if (!IS_OSPF_ABR(area
->ospf
))
2852 json_object_boolean_false_add(json_area
, "abr");
2853 else if (area
->NSSATranslatorState
) {
2854 json_object_boolean_true_add(json_area
, "abr");
2855 if (area
->NSSATranslatorRole
2856 == OSPF_NSSA_ROLE_CANDIDATE
)
2857 json_object_boolean_true_add(
2859 "nssaTranslatorElected");
2860 else if (area
->NSSATranslatorRole
2861 == OSPF_NSSA_ROLE_ALWAYS
)
2862 json_object_boolean_true_add(
2864 "nssaTranslatorAlways");
2866 json_object_boolean_true_add(
2868 "nssaTranslatorNever");
2870 json_object_boolean_true_add(json_area
, "abr");
2871 if (area
->NSSATranslatorRole
2872 == OSPF_NSSA_ROLE_CANDIDATE
)
2873 json_object_boolean_false_add(
2875 "nssaTranslatorElected");
2877 json_object_boolean_true_add(
2879 "nssaTranslatorNever");
2883 " It is an NSSA configuration.\n Elected NSSA/ABR performs type-7/type-5 LSA translation.\n");
2884 if (!IS_OSPF_ABR(area
->ospf
))
2886 " It is not ABR, therefore not Translator.\n");
2887 else if (area
->NSSATranslatorState
) {
2888 vty_out(vty
, " We are an ABR and ");
2889 if (area
->NSSATranslatorRole
2890 == OSPF_NSSA_ROLE_CANDIDATE
)
2892 "the NSSA Elected Translator.\n");
2893 else if (area
->NSSATranslatorRole
2894 == OSPF_NSSA_ROLE_ALWAYS
)
2896 "always an NSSA Translator.\n");
2899 "never an NSSA Translator.\n");
2901 vty_out(vty
, " We are an ABR, but ");
2902 if (area
->NSSATranslatorRole
2903 == OSPF_NSSA_ROLE_CANDIDATE
)
2905 "not the NSSA Elected Translator.\n");
2908 "never an NSSA Translator.\n");
2913 /* Stub-router state for this area */
2914 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
)) {
2915 char timebuf
[OSPF_TIME_DUMP_SIZE
];
2918 json_object_boolean_true_add(
2919 json_area
, "originStubMaxDistRouterLsa");
2920 if (CHECK_FLAG(area
->stub_router_state
,
2921 OSPF_AREA_ADMIN_STUB_ROUTED
))
2922 json_object_boolean_true_add(
2923 json_area
, "indefiniteActiveAdmin");
2924 if (area
->t_stub_router
) {
2928 &area
->t_stub_router
->u
.sands
,
2931 json_object_int_add(
2933 "activeStartupRemainderMsecs",
2938 " Originating stub / maximum-distance Router-LSA\n");
2939 if (CHECK_FLAG(area
->stub_router_state
,
2940 OSPF_AREA_ADMIN_STUB_ROUTED
))
2942 " Administratively activated (indefinitely)\n");
2943 if (area
->t_stub_router
)
2945 " Active from startup, %s remaining\n",
2946 ospf_timer_dump(area
->t_stub_router
,
2953 /* Show number of fully adjacent neighbors. */
2954 json_object_int_add(json_area
, "nbrFullAdjacentCounter",
2957 /* Show authentication type. */
2958 if (area
->auth_type
== OSPF_AUTH_NULL
)
2959 json_object_string_add(json_area
, "authentication",
2960 "authenticationNone");
2961 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
2962 json_object_string_add(json_area
, "authentication",
2963 "authenticationSimplePassword");
2964 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
2965 json_object_string_add(json_area
, "authentication",
2966 "authenticationMessageDigest");
2968 if (!OSPF_IS_AREA_BACKBONE(area
))
2969 json_object_int_add(json_area
,
2970 "virtualAdjacenciesPassingCounter",
2973 /* Show SPF calculation times. */
2974 json_object_int_add(json_area
, "spfExecutedCounter",
2975 area
->spf_calculation
);
2976 json_object_int_add(json_area
, "lsaNumber", area
->lsdb
->total
);
2977 json_object_int_add(
2978 json_area
, "lsaRouterNumber",
2979 ospf_lsdb_count(area
->lsdb
, OSPF_ROUTER_LSA
));
2980 json_object_int_add(
2981 json_area
, "lsaRouterChecksum",
2982 ospf_lsdb_checksum(area
->lsdb
, OSPF_ROUTER_LSA
));
2983 json_object_int_add(
2984 json_area
, "lsaNetworkNumber",
2985 ospf_lsdb_count(area
->lsdb
, OSPF_NETWORK_LSA
));
2986 json_object_int_add(
2987 json_area
, "lsaNetworkChecksum",
2988 ospf_lsdb_checksum(area
->lsdb
, OSPF_NETWORK_LSA
));
2989 json_object_int_add(
2990 json_area
, "lsaSummaryNumber",
2991 ospf_lsdb_count(area
->lsdb
, OSPF_SUMMARY_LSA
));
2992 json_object_int_add(
2993 json_area
, "lsaSummaryChecksum",
2994 ospf_lsdb_checksum(area
->lsdb
, OSPF_SUMMARY_LSA
));
2995 json_object_int_add(
2996 json_area
, "lsaAsbrNumber",
2997 ospf_lsdb_count(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2998 json_object_int_add(
2999 json_area
, "lsaAsbrChecksum",
3000 ospf_lsdb_checksum(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
3001 json_object_int_add(
3002 json_area
, "lsaNssaNumber",
3003 ospf_lsdb_count(area
->lsdb
, OSPF_AS_NSSA_LSA
));
3004 json_object_int_add(
3005 json_area
, "lsaNssaChecksum",
3006 ospf_lsdb_checksum(area
->lsdb
, OSPF_AS_NSSA_LSA
));
3008 /* Show number of fully adjacent neighbors. */
3010 " Number of fully adjacent neighbors in this area: %d\n",
3013 /* Show authentication type. */
3014 vty_out(vty
, " Area has ");
3015 if (area
->auth_type
== OSPF_AUTH_NULL
)
3016 vty_out(vty
, "no authentication\n");
3017 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
3018 vty_out(vty
, "simple password authentication\n");
3019 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
3020 vty_out(vty
, "message digest authentication\n");
3022 if (!OSPF_IS_AREA_BACKBONE(area
))
3024 " Number of full virtual adjacencies going through this area: %d\n",
3027 /* Show SPF calculation times. */
3028 vty_out(vty
, " SPF algorithm executed %d times\n",
3029 area
->spf_calculation
);
3031 /* Show number of LSA. */
3032 vty_out(vty
, " Number of LSA %ld\n", area
->lsdb
->total
);
3034 " Number of router LSA %ld. Checksum Sum 0x%08x\n",
3035 ospf_lsdb_count(area
->lsdb
, OSPF_ROUTER_LSA
),
3036 ospf_lsdb_checksum(area
->lsdb
, OSPF_ROUTER_LSA
));
3038 " Number of network LSA %ld. Checksum Sum 0x%08x\n",
3039 ospf_lsdb_count(area
->lsdb
, OSPF_NETWORK_LSA
),
3040 ospf_lsdb_checksum(area
->lsdb
, OSPF_NETWORK_LSA
));
3042 " Number of summary LSA %ld. Checksum Sum 0x%08x\n",
3043 ospf_lsdb_count(area
->lsdb
, OSPF_SUMMARY_LSA
),
3044 ospf_lsdb_checksum(area
->lsdb
, OSPF_SUMMARY_LSA
));
3046 " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x\n",
3047 ospf_lsdb_count(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
),
3048 ospf_lsdb_checksum(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
3049 vty_out(vty
, " Number of NSSA LSA %ld. Checksum Sum 0x%08x\n",
3050 ospf_lsdb_count(area
->lsdb
, OSPF_AS_NSSA_LSA
),
3051 ospf_lsdb_checksum(area
->lsdb
, OSPF_AS_NSSA_LSA
));
3055 json_object_int_add(
3056 json_area
, "lsaOpaqueLinkNumber",
3057 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
3058 json_object_int_add(
3059 json_area
, "lsaOpaqueLinkChecksum",
3060 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
3061 json_object_int_add(
3062 json_area
, "lsaOpaqueAreaNumber",
3063 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
3064 json_object_int_add(
3065 json_area
, "lsaOpaqueAreaChecksum",
3066 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
3069 " Number of opaque link LSA %ld. Checksum Sum 0x%08x\n",
3070 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
),
3071 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
3073 " Number of opaque area LSA %ld. Checksum Sum 0x%08x\n",
3074 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
),
3075 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
3079 json_object_object_add(json_areas
,
3080 inet_ntop(AF_INET
, &area
->area_id
,
3087 static int show_ip_ospf_common(struct vty
*vty
, struct ospf
*ospf
,
3088 json_object
*json
, uint8_t use_vrf
)
3090 struct listnode
*node
, *nnode
;
3091 struct ospf_area
*area
;
3092 struct timeval result
;
3093 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3094 json_object
*json_vrf
= NULL
;
3095 json_object
*json_areas
= NULL
;
3099 json_vrf
= json_object_new_object();
3102 json_areas
= json_object_new_object();
3105 if (ospf
->instance
) {
3107 json_object_int_add(json
, "ospfInstance",
3110 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
3114 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
3116 /* Show Router ID. */
3118 json_object_string_addf(json_vrf
, "routerId", "%pI4",
3121 vty_out(vty
, " OSPF Routing Process, Router ID: %pI4\n",
3125 /* Graceful shutdown */
3126 if (ospf
->t_deferred_shutdown
) {
3131 &ospf
->t_deferred_shutdown
->u
.sands
,
3134 json_object_int_add(json_vrf
, "deferredShutdownMsecs",
3138 " Deferred shutdown in progress, %s remaining\n",
3139 ospf_timer_dump(ospf
->t_deferred_shutdown
,
3140 timebuf
, sizeof(timebuf
)));
3144 /* Show capability. */
3146 json_object_boolean_true_add(json_vrf
, "tosRoutesOnly");
3147 json_object_boolean_true_add(json_vrf
, "rfc2328Conform");
3148 if (CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)) {
3149 json_object_boolean_true_add(json_vrf
,
3150 "rfc1583Compatibility");
3153 vty_out(vty
, " Supports only single TOS (TOS0) routes\n");
3154 vty_out(vty
, " This implementation conforms to RFC2328\n");
3155 vty_out(vty
, " RFC1583Compatibility flag is %s\n",
3156 CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)
3162 if (CHECK_FLAG(ospf
->config
, OSPF_OPAQUE_CAPABLE
)) {
3163 json_object_boolean_true_add(json_vrf
, "opaqueCapable");
3166 vty_out(vty
, " OpaqueCapability flag is %s\n",
3167 CHECK_FLAG(ospf
->config
, OSPF_OPAQUE_CAPABLE
)
3172 /* Show stub-router configuration */
3173 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
3174 || ospf
->stub_router_shutdown_time
3175 != OSPF_STUB_ROUTER_UNCONFIGURED
) {
3177 json_object_boolean_true_add(json_vrf
,
3178 "stubAdvertisement");
3179 if (ospf
->stub_router_startup_time
3180 != OSPF_STUB_ROUTER_UNCONFIGURED
)
3181 json_object_int_add(
3182 json_vrf
, "postStartEnabledSecs",
3183 ospf
->stub_router_startup_time
);
3184 if (ospf
->stub_router_shutdown_time
3185 != OSPF_STUB_ROUTER_UNCONFIGURED
)
3186 json_object_int_add(
3187 json_vrf
, "preShutdownEnabledSecs",
3188 ospf
->stub_router_shutdown_time
);
3191 " Stub router advertisement is configured\n");
3192 if (ospf
->stub_router_startup_time
3193 != OSPF_STUB_ROUTER_UNCONFIGURED
)
3195 " Enabled for %us after start-up\n",
3196 ospf
->stub_router_startup_time
);
3197 if (ospf
->stub_router_shutdown_time
3198 != OSPF_STUB_ROUTER_UNCONFIGURED
)
3200 " Enabled for %us prior to full shutdown\n",
3201 ospf
->stub_router_shutdown_time
);
3205 /* Show SPF timers. */
3207 json_object_int_add(json_vrf
, "spfScheduleDelayMsecs",
3209 json_object_int_add(json_vrf
, "holdtimeMinMsecs",
3210 ospf
->spf_holdtime
);
3211 json_object_int_add(json_vrf
, "holdtimeMaxMsecs",
3212 ospf
->spf_max_holdtime
);
3213 json_object_int_add(json_vrf
, "holdtimeMultplier",
3214 ospf
->spf_hold_multiplier
);
3217 " Initial SPF scheduling delay %d millisec(s)\n"
3218 " Minimum hold time between consecutive SPFs %d millisec(s)\n"
3219 " Maximum hold time between consecutive SPFs %d millisec(s)\n"
3220 " Hold time multiplier is currently %d\n",
3221 ospf
->spf_delay
, ospf
->spf_holdtime
,
3222 ospf
->spf_max_holdtime
, ospf
->spf_hold_multiplier
);
3226 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
) {
3227 long time_store
= 0;
3230 monotime_since(&ospf
->ts_spf
, NULL
) / 1000LL;
3231 json_object_int_add(json_vrf
, "spfLastExecutedMsecs",
3234 time_store
= (1000 * ospf
->ts_spf_duration
.tv_sec
)
3235 + (ospf
->ts_spf_duration
.tv_usec
/ 1000);
3236 json_object_int_add(json_vrf
, "spfLastDurationMsecs",
3239 json_object_boolean_true_add(json_vrf
, "spfHasNotRun");
3241 vty_out(vty
, " SPF algorithm ");
3242 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
) {
3243 monotime_since(&ospf
->ts_spf
, &result
);
3244 vty_out(vty
, "last executed %s ago\n",
3245 ospf_timeval_dump(&result
, timebuf
,
3247 vty_out(vty
, " Last SPF duration %s\n",
3248 ospf_timeval_dump(&ospf
->ts_spf_duration
,
3249 timebuf
, sizeof(timebuf
)));
3251 vty_out(vty
, "has not been run\n");
3255 if (ospf
->t_spf_calc
) {
3258 monotime_until(&ospf
->t_spf_calc
->u
.sands
, NULL
)
3260 json_object_int_add(json_vrf
, "spfTimerDueInMsecs",
3264 json_object_int_add(json_vrf
, "lsaMinIntervalMsecs",
3265 ospf
->min_ls_interval
);
3266 json_object_int_add(json_vrf
, "lsaMinArrivalMsecs",
3267 ospf
->min_ls_arrival
);
3268 /* Show write multiplier values */
3269 json_object_int_add(json_vrf
, "writeMultiplier",
3270 ospf
->write_oi_count
);
3271 /* Show refresh parameters. */
3272 json_object_int_add(json_vrf
, "refreshTimerMsecs",
3273 ospf
->lsa_refresh_interval
* 1000);
3275 /* show max multipath */
3276 json_object_int_add(json_vrf
, "maximumPaths",
3277 ospf
->max_multipath
);
3279 /* show administrative distance */
3280 json_object_int_add(json_vrf
, "preference",
3282 ? ospf
->distance_all
3283 : ZEBRA_OSPF_DISTANCE_DEFAULT
);
3285 vty_out(vty
, " SPF timer %s%s\n",
3286 (ospf
->t_spf_calc
? "due in " : "is "),
3287 ospf_timer_dump(ospf
->t_spf_calc
, timebuf
,
3290 vty_out(vty
, " LSA minimum interval %d msecs\n",
3291 ospf
->min_ls_interval
);
3292 vty_out(vty
, " LSA minimum arrival %d msecs\n",
3293 ospf
->min_ls_arrival
);
3295 /* Show write multiplier values */
3296 vty_out(vty
, " Write Multiplier set to %d \n",
3297 ospf
->write_oi_count
);
3299 /* Show refresh parameters. */
3300 vty_out(vty
, " Refresh timer %d secs\n",
3301 ospf
->lsa_refresh_interval
);
3303 /* show max multipath */
3304 vty_out(vty
, " Maximum multiple paths(ECMP) supported %d\n",
3305 ospf
->max_multipath
);
3307 /* show administrative distance */
3308 vty_out(vty
, " Administrative distance %u\n",
3309 ospf
->distance_all
? ospf
->distance_all
3310 : ZEBRA_OSPF_DISTANCE_DEFAULT
);
3313 /* Show ABR/ASBR flags. */
3314 if (CHECK_FLAG(ospf
->flags
, OSPF_FLAG_ABR
)) {
3316 json_object_string_add(
3317 json_vrf
, "abrType",
3318 ospf_abr_type_descr_str
[ospf
->abr_type
]);
3321 " This router is an ABR, ABR type is: %s\n",
3322 ospf_abr_type_descr_str
[ospf
->abr_type
]);
3324 if (CHECK_FLAG(ospf
->flags
, OSPF_FLAG_ASBR
)) {
3326 json_object_string_add(
3327 json_vrf
, "asbrRouter",
3328 "injectingExternalRoutingInformation");
3331 " This router is an ASBR (injecting external routing information)\n");
3334 /* Show Number of AS-external-LSAs. */
3336 json_object_int_add(
3337 json_vrf
, "lsaExternalCounter",
3338 ospf_lsdb_count(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3339 json_object_int_add(
3340 json_vrf
, "lsaExternalChecksum",
3341 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3344 " Number of external LSA %ld. Checksum Sum 0x%08x\n",
3345 ospf_lsdb_count(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
),
3346 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3350 json_object_int_add(
3351 json_vrf
, "lsaAsopaqueCounter",
3352 ospf_lsdb_count(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3353 json_object_int_add(
3354 json_vrf
, "lsaAsOpaqueChecksum",
3355 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3358 " Number of opaque AS LSA %ld. Checksum Sum 0x%08x\n",
3359 ospf_lsdb_count(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
),
3360 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3363 /* Show number of areas attached. */
3365 json_object_int_add(json_vrf
, "attachedAreaCounter",
3366 listcount(ospf
->areas
));
3368 vty_out(vty
, " Number of areas attached to this router: %d\n",
3369 listcount(ospf
->areas
));
3371 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
)) {
3372 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
)) {
3374 json_object_boolean_true_add(
3375 json_vrf
, "adjacencyChangesLoggedAll");
3378 " All adjacency changes are logged\n");
3381 json_object_boolean_true_add(
3382 json_vrf
, "adjacencyChangesLogged");
3384 vty_out(vty
, " Adjacency changes are logged\n");
3388 /* show LDP-Sync status */
3389 ospf_ldp_sync_show_info(vty
, ospf
, json_vrf
, json
? 1 : 0);
3391 /* Show each area status. */
3392 for (ALL_LIST_ELEMENTS(ospf
->areas
, node
, nnode
, area
))
3393 show_ip_ospf_area(vty
, area
, json_areas
, json
? 1 : 0);
3397 json_object_object_add(json_vrf
, "areas", json_areas
);
3398 json_object_object_add(json
, ospf_get_name(ospf
),
3401 json_object_object_add(json
, "areas", json_areas
);
3409 DEFUN (show_ip_ospf
,
3411 "show ip ospf [vrf <NAME|all>] [json]",
3414 "OSPF information\n"
3420 bool uj
= use_json(argc
, argv
);
3421 struct listnode
*node
= NULL
;
3422 char *vrf_name
= NULL
;
3423 bool all_vrf
= false;
3424 int ret
= CMD_SUCCESS
;
3427 json_object
*json
= NULL
;
3428 uint8_t use_vrf
= 0;
3430 if (listcount(om
->ospf
) == 0)
3433 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
3436 json
= json_object_new_object();
3438 /* vrf input is provided could be all or specific vrf*/
3440 bool ospf_output
= false;
3445 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
3446 if (!ospf
->oi_running
)
3449 ret
= show_ip_ospf_common(vty
, ospf
, json
,
3453 vty_json(vty
, json
);
3454 else if (!ospf_output
)
3455 vty_out(vty
, "%% OSPF instance not found\n");
3458 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
3459 if ((ospf
== NULL
) || !ospf
->oi_running
) {
3461 vty_json(vty
, json
);
3463 vty_out(vty
, "%% OSPF instance not found\n");
3468 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
3469 /* Display default ospf (instance 0) info */
3470 if (ospf
== NULL
|| !ospf
->oi_running
) {
3472 vty_json(vty
, json
);
3474 vty_out(vty
, "%% OSPF instance not found\n");
3481 show_ip_ospf_common(vty
, ospf
, json
, use_vrf
);
3483 vty_out(vty
, "%s\n",
3484 json_object_to_json_string_ext(
3485 json
, JSON_C_TO_STRING_PRETTY
));
3489 json_object_free(json
);
3494 DEFUN (show_ip_ospf_instance
,
3495 show_ip_ospf_instance_cmd
,
3496 "show ip ospf (1-65535) [json]",
3499 "OSPF information\n"
3505 unsigned short instance
= 0;
3506 bool uj
= use_json(argc
, argv
);
3507 int ret
= CMD_SUCCESS
;
3508 json_object
*json
= NULL
;
3510 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3511 if (instance
!= ospf_instance
)
3512 return CMD_NOT_MY_INSTANCE
;
3514 ospf
= ospf_lookup_instance(instance
);
3515 if (!ospf
|| !ospf
->oi_running
)
3519 json
= json_object_new_object();
3521 ret
= show_ip_ospf_common(vty
, ospf
, json
, 0);
3524 vty_json(vty
, json
);
3529 static void ospf_interface_auth_show(struct vty
*vty
, struct ospf_interface
*oi
,
3530 json_object
*json
, bool use_json
)
3534 auth_type
= OSPF_IF_PARAM(oi
, auth_type
);
3536 switch (auth_type
) {
3537 case OSPF_AUTH_NULL
:
3539 json_object_string_add(json
, "authentication",
3540 "authenticationNone");
3542 vty_out(vty
, " Authentication NULL is enabled\n");
3544 case OSPF_AUTH_SIMPLE
: {
3546 json_object_string_add(json
, "authentication",
3547 "authenticationSimplePassword");
3550 " Simple password authentication enabled\n");
3553 case OSPF_AUTH_CRYPTOGRAPHIC
: {
3554 struct crypt_key
*ckey
;
3556 if (list_isempty(OSPF_IF_PARAM(oi
, auth_crypt
)))
3559 ckey
= listgetdata(listtail(OSPF_IF_PARAM(oi
, auth_crypt
)));
3562 json_object_string_add(json
, "authentication",
3563 "authenticationMessageDigest");
3566 " Cryptographic authentication enabled\n");
3567 vty_out(vty
, " Algorithm:MD5\n");
3577 static void show_ip_ospf_interface_sub(struct vty
*vty
, struct ospf
*ospf
,
3578 struct interface
*ifp
,
3579 json_object
*json_interface_sub
,
3583 struct ospf_neighbor
*nbr
;
3584 struct route_node
*rn
;
3585 uint32_t bandwidth
= ifp
->bandwidth
? ifp
->bandwidth
: ifp
->speed
;
3587 /* Is interface up? */
3589 is_up
= if_is_operative(ifp
);
3591 json_object_boolean_true_add(json_interface_sub
,
3594 json_object_boolean_false_add(json_interface_sub
,
3597 json_object_int_add(json_interface_sub
, "ifIndex",
3599 json_object_int_add(json_interface_sub
, "mtuBytes", ifp
->mtu
);
3600 json_object_int_add(json_interface_sub
, "bandwidthMbit",
3602 json_object_string_add(json_interface_sub
, "ifFlags",
3603 if_flag_dump(ifp
->flags
));
3605 vty_out(vty
, "%s is %s\n", ifp
->name
,
3606 ((is_up
= if_is_operative(ifp
)) ? "up" : "down"));
3607 vty_out(vty
, " ifindex %u, MTU %u bytes, BW %u Mbit %s\n",
3608 ifp
->ifindex
, ifp
->mtu
, bandwidth
,
3609 if_flag_dump(ifp
->flags
));
3612 /* Is interface OSPF enabled? */
3614 if (ospf_oi_count(ifp
) == 0) {
3615 json_object_boolean_false_add(json_interface_sub
,
3618 } else if (!is_up
) {
3619 json_object_boolean_false_add(json_interface_sub
,
3623 json_object_boolean_true_add(json_interface_sub
,
3626 if (ospf_oi_count(ifp
) == 0) {
3627 vty_out(vty
, " OSPF not enabled on this interface\n");
3629 } else if (!is_up
) {
3631 " OSPF is enabled, but not running on this interface\n");
3636 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
3637 struct ospf_interface
*oi
= rn
->info
;
3642 if (CHECK_FLAG(oi
->connected
->flags
, ZEBRA_IFA_UNNUMBERED
)) {
3644 json_object_boolean_true_add(json_interface_sub
,
3647 vty_out(vty
, " This interface is UNNUMBERED,");
3649 struct in_addr dest
;
3652 /* Show OSPF interface information. */
3654 json_object_string_addf(
3655 json_interface_sub
, "ipAddress", "%pI4",
3656 &oi
->address
->u
.prefix4
);
3657 json_object_int_add(json_interface_sub
,
3658 "ipAddressPrefixlen",
3659 oi
->address
->prefixlen
);
3661 vty_out(vty
, " Internet Address %pFX,",
3664 /* For Vlinks, showing the peer address is
3665 * probably more informative than the local
3666 * interface that is being used */
3667 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
) {
3669 dest
= oi
->vl_data
->peer_addr
;
3670 } else if (CONNECTED_PEER(oi
->connected
)
3671 && oi
->connected
->destination
) {
3673 dest
= oi
->connected
->destination
->u
.prefix4
;
3676 dest
.s_addr
= ipv4_broadcast_addr(
3677 oi
->connected
->address
->u
.prefix4
.s_addr
,
3678 oi
->connected
->address
->prefixlen
);
3682 json_object_string_add(
3684 "ospfIfType", dstr
);
3685 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3686 json_object_string_addf(
3687 json_interface_sub
, "vlinkPeer",
3690 json_object_string_addf(
3692 "localIfUsed", "%pI4", &dest
);
3694 vty_out(vty
, " %s %pI4,", dstr
,
3698 json_object_string_add(json_interface_sub
, "area",
3699 ospf_area_desc_string(oi
->area
));
3700 if (OSPF_IF_PARAM(oi
, mtu_ignore
))
3701 json_object_boolean_true_add(
3703 "mtuMismatchDetect");
3704 json_object_string_addf(json_interface_sub
, "routerId",
3705 "%pI4", &ospf
->router_id
);
3706 json_object_string_add(json_interface_sub
,
3708 ospf_network_type_str
[oi
->type
]);
3709 json_object_int_add(json_interface_sub
, "cost",
3711 json_object_int_add(
3712 json_interface_sub
, "transmitDelaySecs",
3713 OSPF_IF_PARAM(oi
, transmit_delay
));
3714 json_object_string_add(json_interface_sub
, "state",
3715 lookup_msg(ospf_ism_state_msg
,
3717 json_object_int_add(json_interface_sub
, "priority",
3720 vty_out(vty
, " Area %s\n",
3721 ospf_area_desc_string(oi
->area
));
3723 vty_out(vty
, " MTU mismatch detection: %s\n",
3724 OSPF_IF_PARAM(oi
, mtu_ignore
) ? "disabled"
3728 " Router ID %pI4, Network Type %s, Cost: %d\n",
3730 ospf_network_type_str
[oi
->type
],
3734 " Transmit Delay is %d sec, State %s, Priority %d\n",
3735 OSPF_IF_PARAM(oi
, transmit_delay
),
3736 lookup_msg(ospf_ism_state_msg
, oi
->state
, NULL
),
3740 /* Show DR information. */
3741 if (DR(oi
).s_addr
== INADDR_ANY
) {
3744 " No backup designated router on this network\n");
3746 nbr
= ospf_nbr_lookup_by_addr(oi
->nbrs
, &DR(oi
));
3749 json_object_string_addf(
3750 json_interface_sub
, "drId",
3751 "%pI4", &nbr
->router_id
);
3752 json_object_string_addf(
3753 json_interface_sub
, "drAddress",
3755 &nbr
->address
.u
.prefix4
);
3758 " Designated Router (ID) %pI4",
3761 " Interface Address %pFX\n",
3767 nbr
= ospf_nbr_lookup_by_addr(oi
->nbrs
, &BDR(oi
));
3771 " No backup designated router on this network\n");
3774 json_object_string_addf(
3775 json_interface_sub
, "bdrId",
3776 "%pI4", &nbr
->router_id
);
3777 json_object_string_addf(
3779 "bdrAddress", "%pI4",
3780 &nbr
->address
.u
.prefix4
);
3783 " Backup Designated Router (ID) %pI4,",
3785 vty_out(vty
, " Interface Address %pI4\n",
3786 &nbr
->address
.u
.prefix4
);
3791 /* Next network-LSA sequence number we'll use, if we're elected
3794 && ntohl(oi
->params
->network_lsa_seqnum
)
3795 != OSPF_INITIAL_SEQUENCE_NUMBER
) {
3797 json_object_int_add(
3799 "networkLsaSequence",
3800 ntohl(oi
->params
->network_lsa_seqnum
));
3803 " Saved Network-LSA sequence number 0x%x\n",
3804 ntohl(oi
->params
->network_lsa_seqnum
));
3808 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3809 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
)) {
3810 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3811 json_object_boolean_true_add(
3813 "mcastMemberOspfAllRouters");
3814 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3815 json_object_boolean_true_add(
3817 "mcastMemberOspfDesignatedRouters");
3820 vty_out(vty
, " Multicast group memberships:");
3821 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3822 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
)) {
3823 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3824 vty_out(vty
, " OSPFAllRouters");
3825 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3826 vty_out(vty
, " OSPFDesignatedRouters");
3828 vty_out(vty
, " <None>");
3833 if (OSPF_IF_PARAM(oi
, fast_hello
) == 0)
3834 json_object_int_add(
3835 json_interface_sub
, "timerMsecs",
3836 OSPF_IF_PARAM(oi
, v_hello
) * 1000);
3838 json_object_int_add(
3839 json_interface_sub
, "timerMsecs",
3840 1000 / OSPF_IF_PARAM(oi
, fast_hello
));
3841 json_object_int_add(json_interface_sub
,
3843 OSPF_IF_PARAM(oi
, v_wait
));
3844 json_object_int_add(json_interface_sub
,
3846 OSPF_IF_PARAM(oi
, v_wait
));
3847 json_object_int_add(
3848 json_interface_sub
, "timerRetransmitSecs",
3849 OSPF_IF_PARAM(oi
, retransmit_interval
));
3851 vty_out(vty
, " Timer intervals configured,");
3852 vty_out(vty
, " Hello ");
3853 if (OSPF_IF_PARAM(oi
, fast_hello
) == 0)
3854 vty_out(vty
, "%ds,",
3855 OSPF_IF_PARAM(oi
, v_hello
));
3857 vty_out(vty
, "%dms,",
3858 1000 / OSPF_IF_PARAM(oi
, fast_hello
));
3859 vty_out(vty
, " Dead %ds, Wait %ds, Retransmit %d\n",
3860 OSPF_IF_PARAM(oi
, v_wait
),
3861 OSPF_IF_PARAM(oi
, v_wait
),
3862 OSPF_IF_PARAM(oi
, retransmit_interval
));
3865 if (OSPF_IF_PASSIVE_STATUS(oi
) == OSPF_IF_ACTIVE
) {
3866 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3868 long time_store
= 0;
3872 &oi
->t_hello
->u
.sands
,
3875 json_object_int_add(json_interface_sub
,
3876 "timerHelloInMsecs",
3879 vty_out(vty
, " Hello due in %s\n",
3880 ospf_timer_dump(oi
->t_hello
, timebuf
,
3882 } else /* passive-interface is set */
3885 json_object_boolean_true_add(
3887 "timerPassiveIface");
3890 " No Hellos (Passive interface)\n");
3894 json_object_int_add(json_interface_sub
, "nbrCount",
3895 ospf_nbr_count(oi
, 0));
3896 json_object_int_add(json_interface_sub
,
3898 ospf_nbr_count(oi
, NSM_Full
));
3901 " Neighbor Count is %d, Adjacent neighbor count is %d\n",
3902 ospf_nbr_count(oi
, 0),
3903 ospf_nbr_count(oi
, NSM_Full
));
3905 ospf_interface_bfd_show(vty
, ifp
, json_interface_sub
);
3907 /* OSPF Authentication information */
3908 ospf_interface_auth_show(vty
, oi
, json_interface_sub
, use_json
);
3912 static int show_ip_ospf_interface_common(struct vty
*vty
, struct ospf
*ospf
,
3913 char *intf_name
, uint8_t use_vrf
,
3914 json_object
*json
, bool use_json
)
3916 struct interface
*ifp
;
3917 struct vrf
*vrf
= vrf_lookup_by_id(ospf
->vrf_id
);
3918 json_object
*json_vrf
= NULL
;
3919 json_object
*json_interface_sub
= NULL
, *json_interface
= NULL
;
3923 json_vrf
= json_object_new_object();
3926 json_interface
= json_object_new_object();
3929 if (ospf
->instance
) {
3931 json_object_int_add(json
, "ospfInstance",
3934 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
3937 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
3939 if (intf_name
== NULL
) {
3940 /* Show All Interfaces.*/
3941 FOR_ALL_INTERFACES (vrf
, ifp
) {
3942 if (ospf_oi_count(ifp
)) {
3944 json_interface_sub
=
3945 json_object_new_object();
3947 show_ip_ospf_interface_sub(vty
, ospf
, ifp
,
3952 json_object_object_add(
3953 json_interface
, ifp
->name
,
3954 json_interface_sub
);
3959 json_object_object_add(json_vrf
, "interfaces",
3962 /* Interface name is specified. */
3963 ifp
= if_lookup_by_name(intf_name
, ospf
->vrf_id
);
3966 json_object_boolean_true_add(json_vrf
,
3969 vty_out(vty
, "No such interface name\n");
3972 json_interface_sub
= json_object_new_object();
3973 json_interface
= json_object_new_object();
3976 show_ip_ospf_interface_sub(
3977 vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3980 json_object_object_add(json_interface
,
3982 json_interface_sub
);
3983 json_object_object_add(json_vrf
, "interfaces",
3991 json_object_object_add(json
, ospf_get_name(ospf
),
4000 static void show_ip_ospf_interface_traffic_sub(struct vty
*vty
,
4001 struct ospf_interface
*oi
,
4002 json_object
*json_interface_sub
,
4006 json_object_int_add(json_interface_sub
, "ifIndex",
4008 json_object_int_add(json_interface_sub
, "helloIn",
4010 json_object_int_add(json_interface_sub
, "helloOut",
4012 json_object_int_add(json_interface_sub
, "dbDescIn",
4014 json_object_int_add(json_interface_sub
, "dbDescOut",
4016 json_object_int_add(json_interface_sub
, "lsReqIn",
4018 json_object_int_add(json_interface_sub
, "lsReqOut",
4020 json_object_int_add(json_interface_sub
, "lsUpdIn",
4022 json_object_int_add(json_interface_sub
, "lsUpdOut",
4024 json_object_int_add(json_interface_sub
, "lsAckIn",
4026 json_object_int_add(json_interface_sub
, "lsAckOut",
4030 "%-10s %8u/%-8u %7u/%-7u %7u/%-7u %7u/%-7u %7u/%-7u\n",
4031 oi
->ifp
->name
, oi
->hello_in
, oi
->hello_out
,
4032 oi
->db_desc_in
, oi
->db_desc_out
, oi
->ls_req_in
,
4033 oi
->ls_req_out
, oi
->ls_upd_in
, oi
->ls_upd_out
,
4034 oi
->ls_ack_in
, oi
->ls_ack_out
);
4038 /* OSPFv2 Packet Counters */
4039 static int show_ip_ospf_interface_traffic_common(
4040 struct vty
*vty
, struct ospf
*ospf
, char *intf_name
, json_object
*json
,
4041 int display_once
, uint8_t use_vrf
, bool use_json
)
4043 struct vrf
*vrf
= NULL
;
4044 struct interface
*ifp
= NULL
;
4045 json_object
*json_vrf
= NULL
;
4046 json_object
*json_interface_sub
= NULL
;
4048 if (!use_json
&& !display_once
) {
4050 vty_out(vty
, "%-12s%-17s%-17s%-17s%-17s%-17s\n", "Interface",
4051 " HELLO", " DB-Desc", " LS-Req", " LS-Update",
4053 vty_out(vty
, "%-10s%-18s%-18s%-17s%-17s%-17s\n", "",
4054 " Rx/Tx", " Rx/Tx", " Rx/Tx", " Rx/Tx",
4057 "--------------------------------------------------------------------------------------------\n");
4058 } else if (use_json
) {
4060 json_vrf
= json_object_new_object();
4065 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
4067 if (intf_name
== NULL
) {
4068 vrf
= vrf_lookup_by_id(ospf
->vrf_id
);
4069 FOR_ALL_INTERFACES (vrf
, ifp
) {
4070 struct route_node
*rn
;
4071 struct ospf_interface
*oi
;
4073 if (ospf_oi_count(ifp
) == 0)
4076 for (rn
= route_top(IF_OIFS(ifp
)); rn
;
4077 rn
= route_next(rn
)) {
4084 json_interface_sub
=
4085 json_object_new_object();
4088 show_ip_ospf_interface_traffic_sub(
4089 vty
, oi
, json_interface_sub
, use_json
);
4091 json_object_object_add(
4092 json_vrf
, ifp
->name
,
4093 json_interface_sub
);
4098 /* Interface name is specified. */
4099 ifp
= if_lookup_by_name(intf_name
, ospf
->vrf_id
);
4101 struct route_node
*rn
;
4102 struct ospf_interface
*oi
;
4104 if (ospf_oi_count(ifp
) == 0) {
4106 " OSPF not enabled on this interface %s\n",
4111 for (rn
= route_top(IF_OIFS(ifp
)); rn
;
4112 rn
= route_next(rn
)) {
4116 json_interface_sub
=
4117 json_object_new_object();
4120 show_ip_ospf_interface_traffic_sub(
4121 vty
, oi
, json_interface_sub
, use_json
);
4123 json_object_object_add(
4124 json_vrf
, ifp
->name
,
4125 json_interface_sub
);
4133 json_object_object_add(json
, ospf_get_name(ospf
),
4141 DEFUN (show_ip_ospf_interface
,
4142 show_ip_ospf_interface_cmd
,
4143 "show ip ospf [vrf <NAME|all>] interface [INTERFACE] [json]",
4146 "OSPF information\n"
4149 "Interface information\n"
4154 bool uj
= use_json(argc
, argv
);
4155 struct listnode
*node
= NULL
;
4156 char *vrf_name
= NULL
, *intf_name
= NULL
;
4157 bool all_vrf
= false;
4158 int ret
= CMD_SUCCESS
;
4160 int idx_vrf
= 0, idx_intf
= 0;
4161 uint8_t use_vrf
= 0;
4162 json_object
*json
= NULL
;
4164 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
4166 if (argv_find(argv
, argc
, "INTERFACE", &idx_intf
))
4167 intf_name
= argv
[idx_intf
]->arg
;
4170 json
= json_object_new_object();
4172 /* vrf input is provided could be all or specific vrf*/
4176 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
4177 if (!ospf
->oi_running
)
4179 ret
= show_ip_ospf_interface_common(
4180 vty
, ospf
, intf_name
, use_vrf
, json
,
4185 vty_json(vty
, json
);
4187 vty_out(vty
, "%% OSPF instance not found\n");
4191 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
4192 if (ospf
== NULL
|| !ospf
->oi_running
) {
4194 vty_json(vty
, json
);
4196 vty_out(vty
, "%% OSPF instance not found\n");
4200 ret
= show_ip_ospf_interface_common(vty
, ospf
, intf_name
,
4204 /* Display default ospf (instance 0) info */
4205 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
4206 if (ospf
== NULL
|| !ospf
->oi_running
) {
4208 vty_json(vty
, json
);
4210 vty_out(vty
, "%% OSPF instance not found\n");
4214 ret
= show_ip_ospf_interface_common(vty
, ospf
, intf_name
,
4219 vty_json(vty
, json
);
4224 DEFUN (show_ip_ospf_instance_interface
,
4225 show_ip_ospf_instance_interface_cmd
,
4226 "show ip ospf (1-65535) interface [INTERFACE] [json]",
4229 "OSPF information\n"
4231 "Interface information\n"
4238 unsigned short instance
= 0;
4239 bool uj
= use_json(argc
, argv
);
4240 char *intf_name
= NULL
;
4241 int ret
= CMD_SUCCESS
;
4242 json_object
*json
= NULL
;
4244 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4245 if (instance
!= ospf_instance
)
4246 return CMD_NOT_MY_INSTANCE
;
4248 ospf
= ospf_lookup_instance(instance
);
4249 if (!ospf
|| !ospf
->oi_running
)
4253 json
= json_object_new_object();
4255 if (argv_find(argv
, argc
, "INTERFACE", &idx_intf
))
4256 intf_name
= argv
[idx_intf
]->arg
;
4258 ret
= show_ip_ospf_interface_common(vty
, ospf
, intf_name
, 0, json
, uj
);
4261 vty_json(vty
, json
);
4266 DEFUN (show_ip_ospf_interface_traffic
,
4267 show_ip_ospf_interface_traffic_cmd
,
4268 "show ip ospf [vrf <NAME|all>] interface traffic [INTERFACE] [json]",
4271 "OSPF information\n"
4274 "Interface information\n"
4275 "Protocol Packet counters\n"
4279 struct ospf
*ospf
= NULL
;
4280 struct listnode
*node
= NULL
;
4281 char *vrf_name
= NULL
, *intf_name
= NULL
;
4282 bool all_vrf
= false;
4284 int idx_vrf
= 0, idx_intf
= 0;
4285 bool uj
= use_json(argc
, argv
);
4286 json_object
*json
= NULL
;
4287 int ret
= CMD_SUCCESS
;
4288 int display_once
= 0;
4289 uint8_t use_vrf
= 0;
4291 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
4293 if (argv_find(argv
, argc
, "INTERFACE", &idx_intf
))
4294 intf_name
= argv
[idx_intf
]->arg
;
4297 json
= json_object_new_object();
4302 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
4303 if (!ospf
->oi_running
)
4306 ret
= show_ip_ospf_interface_traffic_common(
4307 vty
, ospf
, intf_name
, json
,
4308 display_once
, use_vrf
, uj
);
4313 vty_json(vty
, json
);
4317 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
4318 if (ospf
== NULL
|| !ospf
->oi_running
) {
4320 json_object_free(json
);
4324 ret
= show_ip_ospf_interface_traffic_common(
4325 vty
, ospf
, intf_name
, json
, display_once
, use_vrf
, uj
);
4327 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
4328 if (ospf
== NULL
|| !ospf
->oi_running
) {
4330 json_object_free(json
);
4334 ret
= show_ip_ospf_interface_traffic_common(
4335 vty
, ospf
, intf_name
, json
, display_once
, use_vrf
, uj
);
4339 vty_json(vty
, json
);
4345 static void show_ip_ospf_neighbour_header(struct vty
*vty
)
4347 vty_out(vty
, "\n%-15s %-3s %-15s %-15s %-9s %-15s %-32s %5s %5s %5s\n",
4348 "Neighbor ID", "Pri", "State", "Up Time", "Dead Time",
4349 "Address", "Interface", "RXmtL", "RqstL", "DBsmL");
4352 static void show_ip_ospf_neighbor_sub(struct vty
*vty
,
4353 struct ospf_interface
*oi
,
4354 json_object
*json
, bool use_json
)
4356 struct route_node
*rn
;
4357 struct ospf_neighbor
*nbr
, *prev_nbr
= NULL
;
4359 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4360 json_object
*json_neighbor
= NULL
, *json_neigh_array
= NULL
;
4361 struct timeval res
= {.tv_sec
= 0, .tv_usec
= 0};
4363 char uptime
[OSPF_TIME_DUMP_SIZE
];
4365 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
)) {
4366 if ((nbr
= rn
->info
)) {
4367 /* Do not show myself. */
4368 if (nbr
== oi
->nbr_self
)
4370 /* Down state is not shown. */
4371 if (nbr
->state
== NSM_Down
)
4374 if (nbr
->ts_last_progress
.tv_sec
4375 || nbr
->ts_last_progress
.tv_usec
)
4376 time_val
= monotime_since(
4377 &nbr
->ts_last_progress
, &res
)
4381 char neigh_str
[INET_ADDRSTRLEN
];
4384 && !IPV4_ADDR_SAME(&prev_nbr
->src
,
4386 /* Start new neigh list */
4387 json_neigh_array
= NULL
;
4390 if (nbr
->state
== NSM_Attempt
4391 && nbr
->router_id
.s_addr
== INADDR_ANY
)
4392 strlcpy(neigh_str
, "neighbor",
4395 inet_ntop(AF_INET
, &nbr
->router_id
,
4396 neigh_str
, sizeof(neigh_str
));
4398 json_object_object_get_ex(json
, neigh_str
,
4401 if (!json_neigh_array
) {
4403 json_object_new_array();
4404 json_object_object_add(
4409 json_neighbor
= json_object_new_object();
4411 ospf_nbr_ism_state_message(nbr
, msgbuf
, 16);
4413 json_object_int_add(json_neighbor
, "priority",
4415 json_object_string_add(json_neighbor
, "state",
4418 json_object_string_add(
4419 json_neighbor
, "converged",
4420 lookup_msg(ospf_nsm_state_msg
,
4422 json_object_string_add(
4423 json_neighbor
, "role",
4424 lookup_msg(ospf_ism_state_msg
,
4425 ospf_nbr_ism_state(nbr
),
4428 if (nbr
->t_inactivity
) {
4431 time_store
= monotime_until(
4436 json_object_int_add(json_neighbor
,
4439 json_object_int_add(json_neighbor
,
4442 json_object_string_add(
4443 json_neighbor
, "upTime",
4447 json_object_string_add(
4448 json_neighbor
, "deadTime",
4454 json_object_string_add(json_neighbor
,
4458 json_object_string_addf(json_neighbor
,
4461 json_object_string_add(json_neighbor
,
4464 json_object_int_add(
4465 json_neighbor
, "retransmitCounter",
4466 ospf_ls_retransmit_count(nbr
));
4467 json_object_int_add(json_neighbor
,
4469 ospf_ls_request_count(nbr
));
4470 json_object_int_add(json_neighbor
,
4472 ospf_db_summary_count(nbr
));
4474 json_object_array_add(json_neigh_array
,
4477 ospf_nbr_ism_state_message(nbr
, msgbuf
, 16);
4479 if (nbr
->state
== NSM_Attempt
4480 && nbr
->router_id
.s_addr
== INADDR_ANY
)
4481 vty_out(vty
, "%-15s %3d %-15s ", "-",
4482 nbr
->priority
, msgbuf
);
4484 vty_out(vty
, "%-15pI4 %3d %-15s ",
4485 &nbr
->router_id
, nbr
->priority
,
4488 vty_out(vty
, "%-15s ",
4489 ospf_timeval_dump(&res
, uptime
,
4492 vty_out(vty
, "%9s ",
4493 ospf_timer_dump(nbr
->t_inactivity
,
4496 vty_out(vty
, "%-15pI4 ", &nbr
->src
);
4497 vty_out(vty
, "%-32s %5ld %5ld %5d\n",
4499 ospf_ls_retransmit_count(nbr
),
4500 ospf_ls_request_count(nbr
),
4501 ospf_db_summary_count(nbr
));
4508 static int show_ip_ospf_neighbor_common(struct vty
*vty
, struct ospf
*ospf
,
4509 json_object
*json
, bool use_json
,
4512 struct ospf_interface
*oi
;
4513 struct listnode
*node
;
4514 json_object
*json_vrf
= NULL
;
4515 json_object
*json_nbr_sub
= NULL
;
4519 json_vrf
= json_object_new_object();
4522 json_nbr_sub
= json_object_new_object();
4525 if (ospf
->instance
) {
4527 json_object_int_add(json
, "ospfInstance",
4530 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
4533 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
4535 show_ip_ospf_neighbour_header(vty
);
4537 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
4538 if (ospf_interface_neighbor_count(oi
) == 0)
4540 show_ip_ospf_neighbor_sub(vty
, oi
, json_nbr_sub
, use_json
);
4544 json_object_object_add(json_vrf
, "neighbors", json_nbr_sub
);
4546 json_object_object_add(json
, ospf_get_name(ospf
),
4554 DEFUN (show_ip_ospf_neighbor
,
4555 show_ip_ospf_neighbor_cmd
,
4556 "show ip ospf [vrf <NAME|all>] neighbor [json]",
4559 "OSPF information\n"
4566 bool uj
= use_json(argc
, argv
);
4567 struct listnode
*node
= NULL
;
4568 char *vrf_name
= NULL
;
4569 bool all_vrf
= false;
4570 int ret
= CMD_SUCCESS
;
4573 uint8_t use_vrf
= 0;
4574 json_object
*json
= NULL
;
4576 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
4579 json
= json_object_new_object();
4581 /* vrf input is provided could be all or specific vrf*/
4585 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
4586 if (!ospf
->oi_running
)
4588 ret
= show_ip_ospf_neighbor_common(
4589 vty
, ospf
, json
, uj
, use_vrf
);
4593 vty_json(vty
, json
);
4595 vty_out(vty
, "OSPF instance not found\n");
4600 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
4601 if (ospf
== NULL
|| !ospf
->oi_running
) {
4603 vty_json(vty
, json
);
4605 vty_out(vty
, "%% OSPF instance not found\n");
4610 /* Display default ospf (instance 0) info */
4611 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
4612 if (ospf
== NULL
|| !ospf
->oi_running
) {
4614 vty_json(vty
, json
);
4616 vty_out(vty
, "%% OSPF instance not found\n");
4623 ret
= show_ip_ospf_neighbor_common(vty
, ospf
, json
, uj
,
4627 vty_out(vty
, "%s\n",
4628 json_object_to_json_string_ext(
4629 json
, JSON_C_TO_STRING_PRETTY
));
4634 json_object_free(json
);
4640 DEFUN (show_ip_ospf_instance_neighbor
,
4641 show_ip_ospf_instance_neighbor_cmd
,
4642 "show ip ospf (1-65535) neighbor [json]",
4645 "OSPF information\n"
4652 unsigned short instance
= 0;
4653 bool uj
= use_json(argc
, argv
);
4654 json_object
*json
= NULL
;
4655 int ret
= CMD_SUCCESS
;
4657 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4658 if (instance
!= ospf_instance
)
4659 return CMD_NOT_MY_INSTANCE
;
4661 ospf
= ospf_lookup_instance(instance
);
4662 if (!ospf
|| !ospf
->oi_running
)
4666 json
= json_object_new_object();
4668 ret
= show_ip_ospf_neighbor_common(vty
, ospf
, json
, uj
, 0);
4671 vty_json(vty
, json
);
4676 static int show_ip_ospf_neighbor_all_common(struct vty
*vty
, struct ospf
*ospf
,
4677 json_object
*json
, bool use_json
,
4680 struct listnode
*node
;
4681 struct ospf_interface
*oi
;
4682 char buf
[PREFIX_STRLEN
];
4683 json_object
*json_vrf
= NULL
;
4684 json_object
*json_neighbor_sub
= NULL
;
4688 json_vrf
= json_object_new_object();
4693 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
4695 show_ip_ospf_neighbour_header(vty
);
4697 if (ospf
->instance
) {
4699 json_object_int_add(json_vrf
, "ospfInstance",
4702 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
4705 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
4706 struct listnode
*nbr_node
;
4707 struct ospf_nbr_nbma
*nbr_nbma
;
4709 show_ip_ospf_neighbor_sub(vty
, oi
, json_vrf
, use_json
);
4711 /* print Down neighbor status */
4712 for (ALL_LIST_ELEMENTS_RO(oi
->nbr_nbma
, nbr_node
, nbr_nbma
)) {
4713 if (nbr_nbma
->nbr
== NULL
4714 || nbr_nbma
->nbr
->state
== NSM_Down
) {
4717 json_object_new_object();
4718 json_object_int_add(json_neighbor_sub
,
4720 nbr_nbma
->priority
);
4721 json_object_boolean_true_add(
4724 json_object_string_add(
4728 json_object_int_add(
4730 "nbrNbmaRetransmitCounter", 0);
4731 json_object_int_add(
4733 "nbrNbmaRequestCounter", 0);
4734 json_object_int_add(
4736 "nbrNbmaDbSummaryCounter", 0);
4737 json_object_object_add(
4740 &nbr_nbma
->addr
, buf
,
4744 vty_out(vty
, "%-15s %3d %-15s %9s ",
4745 "-", nbr_nbma
->priority
, "Down",
4748 "%-32pI4 %-20s %5d %5d %5d\n",
4750 IF_NAME(oi
), 0, 0, 0);
4758 json_object_object_add(json
, ospf_get_name(ospf
),
4766 DEFUN (show_ip_ospf_neighbor_all
,
4767 show_ip_ospf_neighbor_all_cmd
,
4768 "show ip ospf [vrf <NAME|all>] neighbor all [json]",
4771 "OSPF information\n"
4775 "include down status neighbor\n"
4779 bool uj
= use_json(argc
, argv
);
4780 struct listnode
*node
= NULL
;
4781 char *vrf_name
= NULL
;
4782 bool all_vrf
= false;
4783 int ret
= CMD_SUCCESS
;
4786 uint8_t use_vrf
= 0;
4787 json_object
*json
= NULL
;
4789 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
4792 json
= json_object_new_object();
4794 /* vrf input is provided could be all or specific vrf*/
4798 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
4799 if (!ospf
->oi_running
)
4801 ret
= show_ip_ospf_neighbor_all_common(
4802 vty
, ospf
, json
, uj
, use_vrf
);
4806 vty_json(vty
, json
);
4811 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
4812 if (ospf
== NULL
|| !ospf
->oi_running
) {
4814 json_object_free(json
);
4818 /* Display default ospf (instance 0) info */
4819 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
4820 if (ospf
== NULL
|| !ospf
->oi_running
) {
4822 json_object_free(json
);
4828 ret
= show_ip_ospf_neighbor_all_common(vty
, ospf
, json
, uj
,
4831 vty_out(vty
, "%s\n",
4832 json_object_to_json_string_ext(
4833 json
, JSON_C_TO_STRING_PRETTY
));
4838 json_object_free(json
);
4843 DEFUN (show_ip_ospf_instance_neighbor_all
,
4844 show_ip_ospf_instance_neighbor_all_cmd
,
4845 "show ip ospf (1-65535) neighbor all [json]",
4848 "OSPF information\n"
4851 "include down status neighbor\n"
4856 unsigned short instance
= 0;
4857 bool uj
= use_json(argc
, argv
);
4858 json_object
*json
= NULL
;
4859 int ret
= CMD_SUCCESS
;
4861 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4862 if (instance
!= ospf_instance
)
4863 return CMD_NOT_MY_INSTANCE
;
4865 ospf
= ospf_lookup_instance(instance
);
4866 if (!ospf
|| !ospf
->oi_running
)
4869 json
= json_object_new_object();
4871 ret
= show_ip_ospf_neighbor_all_common(vty
, ospf
, json
, uj
, 0);
4874 vty_json(vty
, json
);
4879 static int show_ip_ospf_neighbor_int_common(struct vty
*vty
, struct ospf
*ospf
,
4881 struct cmd_token
**argv
,
4882 bool use_json
, uint8_t use_vrf
)
4884 struct interface
*ifp
;
4885 struct route_node
*rn
;
4886 json_object
*json
= NULL
;
4889 json
= json_object_new_object();
4891 if (ospf
->instance
) {
4893 json_object_int_add(json
, "ospfInstance",
4896 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
4899 ospf_show_vrf_name(ospf
, vty
, json
, use_vrf
);
4901 ifp
= if_lookup_by_name(argv
[arg_base
]->arg
, ospf
->vrf_id
);
4904 json_object_boolean_true_add(json
, "noSuchIface");
4906 vty_out(vty
, "No such interface.\n");
4910 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
4911 struct ospf_interface
*oi
= rn
->info
;
4916 show_ip_ospf_neighbor_sub(vty
, oi
, json
, use_json
);
4920 vty_json(vty
, json
);
4927 DEFUN (show_ip_ospf_neighbor_int
,
4928 show_ip_ospf_neighbor_int_cmd
,
4929 "show ip ospf [vrf <NAME>] neighbor IFNAME [json]",
4932 "OSPF information\n"
4941 bool uj
= use_json(argc
, argv
);
4942 int ret
= CMD_SUCCESS
;
4943 struct interface
*ifp
= NULL
;
4944 char *vrf_name
= NULL
;
4945 vrf_id_t vrf_id
= VRF_DEFAULT
;
4946 struct vrf
*vrf
= NULL
;
4948 if (argv_find(argv
, argc
, "vrf", &idx_vrf
))
4949 vrf_name
= argv
[idx_vrf
+ 1]->arg
;
4950 if (vrf_name
&& strmatch(vrf_name
, VRF_DEFAULT_NAME
))
4953 vrf
= vrf_lookup_by_name(vrf_name
);
4955 vrf_id
= vrf
->vrf_id
;
4957 ospf
= ospf_lookup_by_vrf_id(vrf_id
);
4959 if (!ospf
|| !ospf
->oi_running
)
4963 show_ip_ospf_neighbour_header(vty
);
4965 argv_find(argv
, argc
, "IFNAME", &idx_ifname
);
4967 ifp
= if_lookup_by_name(argv
[idx_ifname
]->arg
, vrf_id
);
4971 ret
= show_ip_ospf_neighbor_int_common(vty
, ospf
, idx_ifname
,
4976 DEFUN (show_ip_ospf_instance_neighbor_int
,
4977 show_ip_ospf_instance_neighbor_int_cmd
,
4978 "show ip ospf (1-65535) neighbor IFNAME [json]",
4981 "OSPF information\n"
4990 unsigned short instance
= 0;
4991 bool uj
= use_json(argc
, argv
);
4994 show_ip_ospf_neighbour_header(vty
);
4996 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4997 if (instance
!= ospf_instance
)
4998 return CMD_NOT_MY_INSTANCE
;
5000 ospf
= ospf_lookup_instance(instance
);
5001 if (!ospf
|| !ospf
->oi_running
)
5005 show_ip_ospf_neighbour_header(vty
);
5007 return show_ip_ospf_neighbor_int_common(vty
, ospf
, idx_ifname
, argv
, uj
,
5011 static void show_ip_ospf_nbr_nbma_detail_sub(struct vty
*vty
,
5012 struct ospf_interface
*oi
,
5013 struct ospf_nbr_nbma
*nbr_nbma
,
5014 bool use_json
, json_object
*json
)
5016 char timebuf
[OSPF_TIME_DUMP_SIZE
];
5017 json_object
*json_sub
= NULL
;
5020 json_sub
= json_object_new_object();
5021 else /* Show neighbor ID. */
5022 vty_out(vty
, " Neighbor %s,", "-");
5024 /* Show interface address. */
5026 json_object_string_addf(json_sub
, "ifaceAddress", "%pI4",
5029 vty_out(vty
, " interface address %pI4\n",
5034 json_object_string_add(json_sub
, "areaId",
5035 ospf_area_desc_string(oi
->area
));
5036 json_object_string_add(json_sub
, "iface", IF_NAME(oi
));
5038 vty_out(vty
, " In the area %s via interface %s\n",
5039 ospf_area_desc_string(oi
->area
), IF_NAME(oi
));
5041 /* Show neighbor priority and state. */
5043 json_object_int_add(json_sub
, "nbrPriority",
5044 nbr_nbma
->priority
);
5045 json_object_string_add(json_sub
, "nbrState", "down");
5047 vty_out(vty
, " Neighbor priority is %d, State is %s,",
5048 nbr_nbma
->priority
, "Down");
5050 /* Show state changes. */
5052 json_object_int_add(json_sub
, "stateChangeCounter",
5053 nbr_nbma
->state_change
);
5055 vty_out(vty
, " %d state changes\n", nbr_nbma
->state_change
);
5057 /* Show PollInterval */
5059 json_object_int_add(json_sub
, "pollInterval", nbr_nbma
->v_poll
);
5061 vty_out(vty
, " Poll interval %d\n", nbr_nbma
->v_poll
);
5063 /* Show poll-interval timer. */
5064 if (nbr_nbma
->t_poll
) {
5067 time_store
= monotime_until(&nbr_nbma
->t_poll
->u
.sands
,
5069 json_object_int_add(json_sub
,
5070 "pollIntervalTimerDueMsec",
5073 vty_out(vty
, " Poll timer due in %s\n",
5074 ospf_timer_dump(nbr_nbma
->t_poll
, timebuf
,
5078 /* Show poll-interval timer thread. */
5080 if (nbr_nbma
->t_poll
!= NULL
)
5081 json_object_string_add(json_sub
,
5082 "pollIntervalTimerThread", "on");
5084 vty_out(vty
, " Thread Poll Timer %s\n",
5085 nbr_nbma
->t_poll
!= NULL
? "on" : "off");
5088 json_object_object_add(json
, "noNbrId", json_sub
);
5091 static void show_ip_ospf_neighbor_detail_sub(struct vty
*vty
,
5092 struct ospf_interface
*oi
,
5093 struct ospf_neighbor
*nbr
,
5094 struct ospf_neighbor
*prev_nbr
,
5095 json_object
*json
, bool use_json
)
5097 char timebuf
[OSPF_TIME_DUMP_SIZE
];
5098 json_object
*json_neigh
= NULL
, *json_neigh_array
= NULL
;
5099 char neigh_str
[INET_ADDRSTRLEN
] = {0};
5103 !IPV4_ADDR_SAME(&prev_nbr
->src
, &nbr
->src
)) {
5104 json_neigh_array
= NULL
;
5107 if (nbr
->state
== NSM_Attempt
5108 && nbr
->router_id
.s_addr
== INADDR_ANY
)
5109 strlcpy(neigh_str
, "noNbrId", sizeof(neigh_str
));
5111 inet_ntop(AF_INET
, &nbr
->router_id
,
5112 neigh_str
, sizeof(neigh_str
));
5114 json_object_object_get_ex(json
, neigh_str
, &json_neigh_array
);
5116 if (!json_neigh_array
) {
5117 json_neigh_array
= json_object_new_array();
5118 json_object_object_add(json
, neigh_str
,
5122 json_neigh
= json_object_new_object();
5125 /* Show neighbor ID. */
5126 if (nbr
->state
== NSM_Attempt
5127 && nbr
->router_id
.s_addr
== INADDR_ANY
)
5128 vty_out(vty
, " Neighbor %s,", "-");
5130 vty_out(vty
, " Neighbor %pI4,",
5134 /* Show interface address. */
5136 json_object_string_addf(json_neigh
, "ifaceAddress", "%pI4",
5137 &nbr
->address
.u
.prefix4
);
5139 vty_out(vty
, " interface address %pI4\n",
5140 &nbr
->address
.u
.prefix4
);
5144 json_object_string_add(json_neigh
, "areaId",
5145 ospf_area_desc_string(oi
->area
));
5146 json_object_string_add(json_neigh
, "ifaceName", oi
->ifp
->name
);
5148 vty_out(vty
, " In the area %s via interface %s\n",
5149 ospf_area_desc_string(oi
->area
), oi
->ifp
->name
);
5151 /* Show neighbor priority and state. */
5153 json_object_int_add(json_neigh
, "nbrPriority", nbr
->priority
);
5154 json_object_string_add(
5155 json_neigh
, "nbrState",
5156 lookup_msg(ospf_nsm_state_msg
, nbr
->state
, NULL
));
5158 vty_out(vty
, " Neighbor priority is %d, State is %s,",
5160 lookup_msg(ospf_nsm_state_msg
, nbr
->state
, NULL
));
5162 /* Show state changes. */
5164 json_object_int_add(json_neigh
, "stateChangeCounter",
5167 vty_out(vty
, " %d state changes\n", nbr
->state_change
);
5169 if (nbr
->ts_last_progress
.tv_sec
|| nbr
->ts_last_progress
.tv_usec
) {
5174 monotime_since(&nbr
->ts_last_progress
, &res
) / 1000LL;
5176 json_object_int_add(json_neigh
, "lastPrgrsvChangeMsec",
5180 " Most recent state change statistics:\n");
5181 vty_out(vty
, " Progressive change %s ago\n",
5182 ospf_timeval_dump(&res
, timebuf
,
5187 if (nbr
->ts_last_regress
.tv_sec
|| nbr
->ts_last_regress
.tv_usec
) {
5192 monotime_since(&nbr
->ts_last_regress
, &res
) / 1000LL;
5194 json_object_int_add(json_neigh
,
5195 "lastRegressiveChangeMsec",
5197 if (nbr
->last_regress_str
)
5198 json_object_string_add(
5200 "lastRegressiveChangeReason",
5201 nbr
->last_regress_str
);
5204 " Regressive change %s ago, due to %s\n",
5205 ospf_timeval_dump(&res
, timebuf
,
5207 (nbr
->last_regress_str
? nbr
->last_regress_str
5212 /* Show Designated Rotuer ID. */
5214 json_object_string_addf(json_neigh
, "routerDesignatedId",
5215 "%pI4", &nbr
->d_router
);
5217 vty_out(vty
, " DR is %pI4,", &nbr
->d_router
);
5219 /* Show Backup Designated Rotuer ID. */
5221 json_object_string_addf(json_neigh
, "routerDesignatedBackupId",
5222 "%pI4", &nbr
->bd_router
);
5224 vty_out(vty
, " BDR is %pI4\n", &nbr
->bd_router
);
5228 json_object_int_add(json_neigh
, "optionsCounter", nbr
->options
);
5229 json_object_string_add(json_neigh
, "optionsList",
5230 ospf_options_dump(nbr
->options
));
5232 vty_out(vty
, " Options %d %s\n", nbr
->options
,
5233 ospf_options_dump(nbr
->options
));
5235 /* Show Router Dead interval timer. */
5237 if (nbr
->t_inactivity
) {
5239 time_store
= monotime_until(&nbr
->t_inactivity
->u
.sands
,
5242 json_object_int_add(json_neigh
,
5243 "routerDeadIntervalTimerDueMsec",
5246 json_object_int_add(
5248 "routerDeadIntervalTimerDueMsec", -1);
5250 vty_out(vty
, " Dead timer due in %s\n",
5251 ospf_timer_dump(nbr
->t_inactivity
, timebuf
,
5254 /* Show Database Summary list. */
5256 json_object_int_add(json_neigh
, "databaseSummaryListCounter",
5257 ospf_db_summary_count(nbr
));
5259 vty_out(vty
, " Database Summary List %d\n",
5260 ospf_db_summary_count(nbr
));
5262 /* Show Link State Request list. */
5264 json_object_int_add(json_neigh
, "linkStateRequestListCounter",
5265 ospf_ls_request_count(nbr
));
5267 vty_out(vty
, " Link State Request List %ld\n",
5268 ospf_ls_request_count(nbr
));
5270 /* Show Link State Retransmission list. */
5272 json_object_int_add(json_neigh
,
5273 "linkStateRetransmissionListCounter",
5274 ospf_ls_retransmit_count(nbr
));
5276 vty_out(vty
, " Link State Retransmission List %ld\n",
5277 ospf_ls_retransmit_count(nbr
));
5279 /* Show inactivity timer thread. */
5281 if (nbr
->t_inactivity
!= NULL
)
5282 json_object_string_add(json_neigh
,
5283 "threadInactivityTimer", "on");
5285 vty_out(vty
, " Thread Inactivity Timer %s\n",
5286 nbr
->t_inactivity
!= NULL
? "on" : "off");
5288 /* Show Database Description retransmission thread. */
5290 if (nbr
->t_db_desc
!= NULL
)
5291 json_object_string_add(
5293 "threadDatabaseDescriptionRetransmission",
5297 " Thread Database Description Retransmision %s\n",
5298 nbr
->t_db_desc
!= NULL
? "on" : "off");
5300 /* Show Link State Request Retransmission thread. */
5302 if (nbr
->t_ls_req
!= NULL
)
5303 json_object_string_add(
5305 "threadLinkStateRequestRetransmission", "on");
5308 " Thread Link State Request Retransmission %s\n",
5309 nbr
->t_ls_req
!= NULL
? "on" : "off");
5311 /* Show Link State Update Retransmission thread. */
5313 if (nbr
->t_ls_upd
!= NULL
)
5314 json_object_string_add(
5316 "threadLinkStateUpdateRetransmission",
5320 " Thread Link State Update Retransmission %s\n\n",
5321 nbr
->t_ls_upd
!= NULL
? "on" : "off");
5324 vty_out(vty
, " Graceful restart Helper info:\n");
5326 if (OSPF_GR_IS_ACTIVE_HELPER(nbr
)) {
5328 " Graceful Restart HELPER Status : Inprogress.\n");
5331 " Graceful Restart grace period time: %d (seconds).\n",
5332 nbr
->gr_helper_info
.recvd_grace_period
);
5333 vty_out(vty
, " Graceful Restart reason: %s.\n",
5334 ospf_restart_reason2str(
5335 nbr
->gr_helper_info
.gr_restart_reason
));
5338 " Graceful Restart HELPER Status : None\n");
5341 if (nbr
->gr_helper_info
.rejected_reason
5342 != OSPF_HELPER_REJECTED_NONE
)
5343 vty_out(vty
, " Helper rejected reason: %s.\n",
5344 ospf_rejected_reason2str(
5345 nbr
->gr_helper_info
.rejected_reason
));
5347 if (nbr
->gr_helper_info
.helper_exit_reason
5348 != OSPF_GR_HELPER_EXIT_NONE
)
5349 vty_out(vty
, " Last helper exit reason: %s.\n\n",
5350 ospf_exit_reason2str(
5351 nbr
->gr_helper_info
.helper_exit_reason
));
5355 json_object_string_add(json_neigh
, "grHelperStatus",
5356 OSPF_GR_IS_ACTIVE_HELPER(nbr
) ?
5359 if (OSPF_GR_IS_ACTIVE_HELPER(nbr
)) {
5360 json_object_int_add(
5361 json_neigh
, "graceInterval",
5362 nbr
->gr_helper_info
.recvd_grace_period
);
5363 json_object_string_add(
5364 json_neigh
, "grRestartReason",
5365 ospf_restart_reason2str(
5366 nbr
->gr_helper_info
.gr_restart_reason
));
5369 if (nbr
->gr_helper_info
.rejected_reason
5370 != OSPF_HELPER_REJECTED_NONE
)
5371 json_object_string_add(
5372 json_neigh
, "helperRejectReason",
5373 ospf_rejected_reason2str(
5374 nbr
->gr_helper_info
.rejected_reason
));
5376 if (nbr
->gr_helper_info
.helper_exit_reason
5377 != OSPF_GR_HELPER_EXIT_NONE
)
5378 json_object_string_add(
5379 json_neigh
, "helperExitReason",
5380 ospf_exit_reason2str(
5382 .helper_exit_reason
));
5385 bfd_sess_show(vty
, json_neigh
, nbr
->bfd_session
);
5388 json_object_array_add(json_neigh_array
, json_neigh
);
5392 static int show_ip_ospf_neighbor_id_common(struct vty
*vty
, struct ospf
*ospf
,
5393 struct in_addr
*router_id
,
5394 bool use_json
, uint8_t use_vrf
)
5396 struct listnode
*node
;
5397 struct ospf_neighbor
*nbr
;
5398 struct ospf_interface
*oi
;
5399 json_object
*json
= NULL
;
5402 json
= json_object_new_object();
5404 if (ospf
->instance
) {
5406 json_object_int_add(json
, "ospfInstance",
5409 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
5412 ospf_show_vrf_name(ospf
, vty
, json
, use_vrf
);
5414 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
5415 if ((nbr
= ospf_nbr_lookup_by_routerid(oi
->nbrs
, router_id
))) {
5416 show_ip_ospf_neighbor_detail_sub(vty
, oi
, nbr
, NULL
,
5422 vty_json(vty
, json
);
5429 DEFPY (show_ip_ospf_neighbor_id
,
5430 show_ip_ospf_neighbor_id_cmd
,
5431 "show ip ospf neighbor A.B.C.D$router_id [json$json]",
5434 "OSPF information\n"
5440 struct listnode
*node
;
5441 int ret
= CMD_SUCCESS
;
5443 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
5444 if (!ospf
->oi_running
)
5446 ret
= show_ip_ospf_neighbor_id_common(vty
, ospf
, &router_id
,
5453 DEFPY (show_ip_ospf_instance_neighbor_id
,
5454 show_ip_ospf_instance_neighbor_id_cmd
,
5455 "show ip ospf (1-65535)$instance neighbor A.B.C.D$router_id [json$json]",
5458 "OSPF information\n"
5466 if (instance
!= ospf_instance
)
5467 return CMD_NOT_MY_INSTANCE
;
5469 ospf
= ospf_lookup_instance(instance
);
5470 if (!ospf
|| !ospf
->oi_running
)
5473 return show_ip_ospf_neighbor_id_common(vty
, ospf
, &router_id
, !!json
,
5477 static int show_ip_ospf_neighbor_detail_common(struct vty
*vty
,
5479 json_object
*json
, bool use_json
,
5482 struct ospf_interface
*oi
;
5483 struct listnode
*node
;
5484 json_object
*json_vrf
= NULL
;
5485 json_object
*json_nbr_sub
= NULL
;
5489 json_vrf
= json_object_new_object();
5493 json_nbr_sub
= json_object_new_object();
5496 if (ospf
->instance
) {
5498 json_object_int_add(json
, "ospfInstance",
5501 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
5504 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
5506 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
5507 struct route_node
*rn
;
5508 struct ospf_neighbor
*nbr
, *prev_nbr
= NULL
;
5510 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
)) {
5511 if ((nbr
= rn
->info
)) {
5512 if (nbr
!= oi
->nbr_self
) {
5513 if (nbr
->state
!= NSM_Down
) {
5514 show_ip_ospf_neighbor_detail_sub(
5515 vty
, oi
, nbr
, prev_nbr
,
5516 json_nbr_sub
, use_json
);
5525 json_object_object_add(json_vrf
, "neighbors",
5528 json_object_object_add(json
, ospf_get_name(ospf
),
5536 DEFUN (show_ip_ospf_neighbor_detail
,
5537 show_ip_ospf_neighbor_detail_cmd
,
5538 "show ip ospf [vrf <NAME|all>] neighbor detail [json]",
5541 "OSPF information\n"
5545 "detail of all neighbors\n"
5549 bool uj
= use_json(argc
, argv
);
5550 struct listnode
*node
= NULL
;
5551 char *vrf_name
= NULL
;
5552 bool all_vrf
= false;
5553 int ret
= CMD_SUCCESS
;
5556 uint8_t use_vrf
= 0;
5557 json_object
*json
= NULL
;
5559 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
5562 json
= json_object_new_object();
5564 /* vrf input is provided could be all or specific vrf*/
5568 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
5569 if (!ospf
->oi_running
)
5571 ret
= show_ip_ospf_neighbor_detail_common(
5572 vty
, ospf
, json
, uj
, use_vrf
);
5575 vty_json(vty
, json
);
5579 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
5580 if (ospf
== NULL
|| !ospf
->oi_running
) {
5582 json_object_free(json
);
5586 /* Display default ospf (instance 0) info */
5587 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
5588 if (ospf
== NULL
|| !ospf
->oi_running
) {
5590 json_object_free(json
);
5596 ret
= show_ip_ospf_neighbor_detail_common(vty
, ospf
, json
, uj
,
5599 vty_out(vty
, "%s\n",
5600 json_object_to_json_string_ext(
5601 json
, JSON_C_TO_STRING_PRETTY
));
5606 json_object_free(json
);
5611 DEFUN (show_ip_ospf_instance_neighbor_detail
,
5612 show_ip_ospf_instance_neighbor_detail_cmd
,
5613 "show ip ospf (1-65535) neighbor detail [json]",
5616 "OSPF information\n"
5619 "detail of all neighbors\n"
5624 unsigned short instance
= 0;
5625 bool uj
= use_json(argc
, argv
);
5626 json_object
*json
= NULL
;
5627 int ret
= CMD_SUCCESS
;
5629 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5630 if (instance
!= ospf_instance
)
5631 return CMD_NOT_MY_INSTANCE
;
5633 ospf
= ospf_lookup_instance(instance
);
5634 if (!ospf
|| !ospf
->oi_running
)
5638 json
= json_object_new_object();
5640 ret
= show_ip_ospf_neighbor_detail_common(vty
, ospf
, json
, uj
, 0);
5643 vty_json(vty
, json
);
5648 static int show_ip_ospf_neighbor_detail_all_common(struct vty
*vty
,
5654 struct listnode
*node
;
5655 struct ospf_interface
*oi
;
5656 json_object
*json_vrf
= NULL
;
5660 json_vrf
= json_object_new_object();
5665 if (ospf
->instance
) {
5667 json_object_int_add(json
, "ospfInstance",
5670 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
5673 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
5675 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
5676 struct route_node
*rn
;
5677 struct ospf_neighbor
*nbr
, *prev_nbr
= NULL
;
5678 struct ospf_nbr_nbma
*nbr_nbma
;
5680 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
)) {
5681 if ((nbr
= rn
->info
)) {
5682 if (nbr
!= oi
->nbr_self
)
5683 if (nbr
->state
!= NSM_Down
)
5684 show_ip_ospf_neighbor_detail_sub(
5687 json_vrf
, use_json
);
5692 if (oi
->type
== OSPF_IFTYPE_NBMA
) {
5693 struct listnode
*nd
;
5695 for (ALL_LIST_ELEMENTS_RO(oi
->nbr_nbma
, nd
, nbr_nbma
)) {
5696 if (nbr_nbma
->nbr
== NULL
5697 || nbr_nbma
->nbr
->state
== NSM_Down
)
5698 show_ip_ospf_nbr_nbma_detail_sub(
5699 vty
, oi
, nbr_nbma
, use_json
,
5707 json_object_object_add(json
, ospf_get_name(ospf
),
5716 DEFUN (show_ip_ospf_neighbor_detail_all
,
5717 show_ip_ospf_neighbor_detail_all_cmd
,
5718 "show ip ospf [vrf <NAME|all>] neighbor detail all [json]",
5721 "OSPF information\n"
5725 "detail of all neighbors\n"
5726 "include down status neighbor\n"
5730 bool uj
= use_json(argc
, argv
);
5731 struct listnode
*node
= NULL
;
5732 char *vrf_name
= NULL
;
5733 bool all_vrf
= false;
5734 int ret
= CMD_SUCCESS
;
5737 uint8_t use_vrf
= 0;
5738 json_object
*json
= NULL
;
5740 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
5743 json
= json_object_new_object();
5745 /* vrf input is provided could be all or specific vrf*/
5749 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
5750 if (!ospf
->oi_running
)
5752 ret
= show_ip_ospf_neighbor_detail_all_common(
5753 vty
, ospf
, json
, uj
, use_vrf
);
5757 vty_json(vty
, json
);
5761 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
5762 if (ospf
== NULL
|| !ospf
->oi_running
) {
5764 json_object_free(json
);
5768 /* Display default ospf (instance 0) info */
5769 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
5770 if (ospf
== NULL
|| !ospf
->oi_running
) {
5772 json_object_free(json
);
5778 ret
= show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, json
,
5781 vty_out(vty
, "%s\n",
5782 json_object_to_json_string_ext(
5783 json
, JSON_C_TO_STRING_PRETTY
));
5788 json_object_free(json
);
5793 DEFUN (show_ip_ospf_instance_neighbor_detail_all
,
5794 show_ip_ospf_instance_neighbor_detail_all_cmd
,
5795 "show ip ospf (1-65535) neighbor detail all [json]",
5798 "OSPF information\n"
5801 "detail of all neighbors\n"
5802 "include down status neighbor\n"
5807 unsigned short instance
= 0;
5808 bool uj
= use_json(argc
, argv
);
5809 json_object
*json
= NULL
;
5810 int ret
= CMD_SUCCESS
;
5812 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5813 if (instance
!= ospf_instance
)
5814 return CMD_NOT_MY_INSTANCE
;
5816 ospf
= ospf_lookup_instance(instance
);
5817 if (!ospf
|| !ospf
->oi_running
)
5821 json
= json_object_new_object();
5823 ret
= show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, json
, uj
, 0);
5826 vty_json(vty
, json
);
5831 static int show_ip_ospf_neighbor_int_detail_common(struct vty
*vty
,
5834 struct cmd_token
**argv
,
5837 struct ospf_interface
*oi
;
5838 struct interface
*ifp
;
5839 struct route_node
*rn
, *nrn
;
5840 struct ospf_neighbor
*nbr
;
5841 json_object
*json
= NULL
;
5844 json
= json_object_new_object();
5846 if (ospf
->instance
) {
5848 json_object_int_add(json
, "ospfInstance",
5851 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
5854 ifp
= if_lookup_by_name(argv
[arg_base
]->arg
, ospf
->vrf_id
);
5857 vty_out(vty
, "No such interface.\n");
5859 vty_out(vty
, "{}\n");
5860 json_object_free(json
);
5865 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
5866 if ((oi
= rn
->info
)) {
5867 for (nrn
= route_top(oi
->nbrs
); nrn
;
5868 nrn
= route_next(nrn
)) {
5869 if ((nbr
= nrn
->info
)) {
5870 if (nbr
!= oi
->nbr_self
) {
5871 if (nbr
->state
!= NSM_Down
)
5872 show_ip_ospf_neighbor_detail_sub(
5883 vty_json(vty
, json
);
5890 DEFUN (show_ip_ospf_neighbor_int_detail
,
5891 show_ip_ospf_neighbor_int_detail_cmd
,
5892 "show ip ospf neighbor IFNAME detail [json]",
5895 "OSPF information\n"
5898 "detail of all neighbors\n"
5902 bool uj
= use_json(argc
, argv
);
5903 struct listnode
*node
= NULL
;
5904 int ret
= CMD_SUCCESS
;
5905 bool ospf_output
= false;
5907 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
5908 if (!ospf
->oi_running
)
5911 ret
= show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 4,
5916 vty_out(vty
, "%% OSPF instance not found\n");
5921 DEFUN (show_ip_ospf_instance_neighbor_int_detail
,
5922 show_ip_ospf_instance_neighbor_int_detail_cmd
,
5923 "show ip ospf (1-65535) neighbor IFNAME detail [json]",
5926 "OSPF information\n"
5930 "detail of all neighbors\n"
5936 unsigned short instance
= 0;
5937 bool uj
= use_json(argc
, argv
);
5939 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5940 if (instance
!= ospf_instance
)
5941 return CMD_NOT_MY_INSTANCE
;
5943 ospf
= ospf_lookup_instance(instance
);
5944 if (!ospf
|| !ospf
->oi_running
)
5947 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, idx_ifname
,
5951 /* Show functions */
5952 static int show_lsa_summary(struct vty
*vty
, struct ospf_lsa
*lsa
, int self
,
5953 json_object
*json_lsa
)
5955 struct router_lsa
*rl
;
5956 struct summary_lsa
*sl
;
5957 struct as_external_lsa
*asel
;
5958 struct prefix_ipv4 p
;
5961 /* If self option is set, check LSA self flag. */
5962 if (self
== 0 || IS_LSA_SELF(lsa
)) {
5965 /* LSA common part show. */
5966 vty_out(vty
, "%-15pI4",
5968 vty_out(vty
, "%-15pI4 %4d 0x%08lx 0x%04x",
5969 &lsa
->data
->adv_router
, LS_AGE(lsa
),
5970 (unsigned long)ntohl(
5971 lsa
->data
->ls_seqnum
),
5972 ntohs(lsa
->data
->checksum
));
5977 snprintf(seqnum
, sizeof(seqnum
), "%x",
5978 ntohl(lsa
->data
->ls_seqnum
));
5979 snprintf(checksum
, sizeof(checksum
), "%x",
5980 ntohs(lsa
->data
->checksum
));
5981 json_object_string_addf(json_lsa
, "lsId",
5982 "%pI4", &lsa
->data
->id
);
5983 json_object_string_addf(
5984 json_lsa
, "advertisedRouter", "%pI4",
5985 &lsa
->data
->adv_router
);
5986 json_object_int_add(json_lsa
, "lsaAge",
5988 json_object_string_add(
5989 json_lsa
, "sequenceNumber", seqnum
);
5990 json_object_string_add(json_lsa
, "checksum",
5994 /* LSA specific part show. */
5995 switch (lsa
->data
->type
) {
5996 case OSPF_ROUTER_LSA
:
5997 rl
= (struct router_lsa
*)lsa
->data
;
6000 vty_out(vty
, " %-d", ntohs(rl
->links
));
6002 json_object_int_add(json_lsa
,
6006 case OSPF_SUMMARY_LSA
:
6007 sl
= (struct summary_lsa
*)lsa
->data
;
6010 p
.prefix
= sl
->header
.id
;
6011 p
.prefixlen
= ip_masklen(sl
->mask
);
6012 apply_mask_ipv4(&p
);
6015 vty_out(vty
, " %pFX", &p
);
6017 json_object_string_addf(
6018 json_lsa
, "summaryAddress",
6022 case OSPF_AS_EXTERNAL_LSA
:
6023 case OSPF_AS_NSSA_LSA
:
6024 asel
= (struct as_external_lsa
*)lsa
->data
;
6027 p
.prefix
= asel
->header
.id
;
6028 p
.prefixlen
= ip_masklen(asel
->mask
);
6029 apply_mask_ipv4(&p
);
6032 vty_out(vty
, " %s %pFX [0x%lx]",
6038 (unsigned long)ntohl(
6039 asel
->e
[0].route_tag
));
6041 json_object_string_add(
6042 json_lsa
, "metricType",
6047 json_object_string_addf(
6048 json_lsa
, "route", "%pFX", &p
);
6049 json_object_int_add(
6051 (unsigned long)ntohl(
6052 asel
->e
[0].route_tag
));
6055 case OSPF_NETWORK_LSA
:
6056 case OSPF_ASBR_SUMMARY_LSA
:
6057 case OSPF_OPAQUE_LINK_LSA
:
6058 case OSPF_OPAQUE_AREA_LSA
:
6059 case OSPF_OPAQUE_AS_LSA
:
6074 static const char *const show_database_desc
[] = {
6076 "Router Link States",
6078 "Summary Link States",
6079 "ASBR-Summary Link States",
6080 "AS External Link States",
6081 "Group Membership LSA",
6082 "NSSA-external Link States",
6084 "Link-Local Opaque-LSA",
6085 "Area-Local Opaque-LSA",
6086 "AS-external Opaque-LSA",
6089 static const char * const show_database_desc_json
[] = {
6092 "networkLinkStates",
6093 "summaryLinkStates",
6094 "asbrSummaryLinkStates",
6095 "asExternalLinkStates",
6096 "groupMembershipLsa",
6097 "nssaExternalLinkStates",
6099 "linkLocalOpaqueLsa",
6100 "areaLocalOpaqueLsa",
6101 "asExternalOpaqueLsa",
6104 static const char *const show_database_desc_count_json
[] = {
6106 "routerLinkStatesCount",
6107 "networkLinkStatesCount",
6108 "summaryLinkStatesCount",
6109 "asbrSummaryLinkStatesCount",
6110 "asExternalLinkStatesCount",
6111 "groupMembershipLsaCount",
6112 "nssaExternalLinkStatesCount",
6114 "linkLocalOpaqueLsaCount",
6115 "areaLocalOpaqueLsaCount",
6116 "asExternalOpaqueLsaCount",
6119 static const char *const show_database_header
[] = {
6121 "Link ID ADV Router Age Seq# CkSum Link count",
6122 "Link ID ADV Router Age Seq# CkSum",
6123 "Link ID ADV Router Age Seq# CkSum Route",
6124 "Link ID ADV Router Age Seq# CkSum",
6125 "Link ID ADV Router Age Seq# CkSum Route",
6126 " --- header for Group Member ----",
6127 "Link ID ADV Router Age Seq# CkSum Route",
6129 "Opaque-Type/Id ADV Router Age Seq# CkSum",
6130 "Opaque-Type/Id ADV Router Age Seq# CkSum",
6131 "Opaque-Type/Id ADV Router Age Seq# CkSum",
6134 static void show_ip_ospf_database_header(struct vty
*vty
, struct ospf_lsa
*lsa
,
6137 struct router_lsa
*rlsa
= (struct router_lsa
*)lsa
->data
;
6140 vty_out(vty
, " LS age: %d\n", LS_AGE(lsa
));
6141 vty_out(vty
, " Options: 0x%-2x : %s\n", lsa
->data
->options
,
6142 ospf_options_dump(lsa
->data
->options
));
6143 vty_out(vty
, " LS Flags: 0x%-2x %s\n", lsa
->flags
,
6144 ((lsa
->flags
& OSPF_LSA_LOCAL_XLT
)
6145 ? "(Translated from Type-7)"
6148 if (lsa
->data
->type
== OSPF_ROUTER_LSA
) {
6149 vty_out(vty
, " Flags: 0x%x", rlsa
->flags
);
6152 vty_out(vty
, " :%s%s%s%s",
6153 IS_ROUTER_LSA_BORDER(rlsa
) ? " ABR"
6155 IS_ROUTER_LSA_EXTERNAL(rlsa
) ? " ASBR"
6157 IS_ROUTER_LSA_VIRTUAL(rlsa
)
6160 IS_ROUTER_LSA_SHORTCUT(rlsa
)
6166 vty_out(vty
, " LS Type: %s\n",
6167 lookup_msg(ospf_lsa_type_msg
, lsa
->data
->type
, NULL
));
6168 vty_out(vty
, " Link State ID: %pI4 %s\n",
6170 lookup_msg(ospf_link_state_id_type_msg
, lsa
->data
->type
,
6172 vty_out(vty
, " Advertising Router: %pI4\n",
6173 &lsa
->data
->adv_router
);
6174 vty_out(vty
, " LS Seq Number: %08lx\n",
6175 (unsigned long)ntohl(lsa
->data
->ls_seqnum
));
6176 vty_out(vty
, " Checksum: 0x%04x\n",
6177 ntohs(lsa
->data
->checksum
));
6178 vty_out(vty
, " Length: %d\n\n", ntohs(lsa
->data
->length
));
6183 snprintf(seqnum
, 10, "%x", ntohl(lsa
->data
->ls_seqnum
));
6184 snprintf(checksum
, 10, "%x", ntohs(lsa
->data
->checksum
));
6186 json_object_int_add(json
, "lsaAge", LS_AGE(lsa
));
6187 json_object_string_add(json
, "options",
6188 ospf_options_dump(lsa
->data
->options
));
6189 json_object_int_add(json
, "lsaFlags", lsa
->flags
);
6191 if (lsa
->flags
& OSPF_LSA_LOCAL_XLT
)
6192 json_object_boolean_true_add(json
,
6193 "translatedFromType7");
6195 if (lsa
->data
->type
== OSPF_ROUTER_LSA
) {
6196 json_object_int_add(json
, "flags", rlsa
->flags
);
6199 if (IS_ROUTER_LSA_BORDER(rlsa
))
6200 json_object_boolean_true_add(json
,
6202 if (IS_ROUTER_LSA_EXTERNAL(rlsa
))
6203 json_object_boolean_true_add(json
,
6205 if (IS_ROUTER_LSA_VIRTUAL(rlsa
))
6206 json_object_boolean_true_add(
6207 json
, "vlEndpoint");
6208 if (IS_ROUTER_LSA_SHORTCUT(rlsa
))
6209 json_object_boolean_true_add(
6214 json_object_string_add(
6216 lookup_msg(ospf_lsa_type_msg
, lsa
->data
->type
, NULL
));
6217 json_object_string_addf(json
, "linkStateId", "%pI4",
6219 json_object_string_addf(json
, "advertisingRouter", "%pI4",
6220 &lsa
->data
->adv_router
);
6221 json_object_string_add(json
, "lsaSeqNumber", seqnum
);
6222 json_object_string_add(json
, "checksum", checksum
);
6223 json_object_int_add(json
, "length", ntohs(lsa
->data
->length
));
6227 static const char *const link_type_desc
[] = {
6229 "another Router (point-to-point)",
6230 "a Transit Network",
6235 static const char *const link_id_desc
[] = {
6236 "(null)", "Neighboring Router ID", "Designated Router address",
6237 "Net", "Neighboring Router ID",
6240 static const char *const link_data_desc
[] = {
6241 "(null)", "Router Interface address", "Router Interface address",
6242 "Network Mask", "Router Interface address",
6245 static const char *const link_id_desc_json
[] = {
6246 "null", "neighborRouterId", "designatedRouterAddress",
6247 "networkAddress", "neighborRouterId",
6250 static const char *const link_data_desc_json
[] = {
6251 "null", "routerInterfaceAddress", "routerInterfaceAddress",
6252 "networkMask", "routerInterfaceAddress",
6255 /* Show router-LSA each Link information. */
6256 static void show_ip_ospf_database_router_links(struct vty
*vty
,
6257 struct router_lsa
*rl
,
6262 json_object
*json_links
= NULL
;
6263 json_object
*json_link
= NULL
;
6265 char buf
[PREFIX_STRLEN
];
6268 json_links
= json_object_new_object();
6270 len
= ntohs(rl
->header
.length
) - 4;
6271 for (i
= 0; i
< ntohs(rl
->links
) && len
> 0; len
-= 12, i
++) {
6272 type
= rl
->link
[i
].type
;
6277 snprintf(link
, sizeof(link
), "link%u", i
);
6278 json_link
= json_object_new_object();
6279 json_object_string_add(json_link
, "linkType",
6280 link_type_desc
[type
]);
6281 json_object_string_add(json_link
,
6282 link_id_desc_json
[type
],
6284 &rl
->link
[i
].link_id
,
6286 json_object_string_add(
6287 json_link
, link_data_desc_json
[type
],
6288 inet_ntop(AF_INET
, &rl
->link
[i
].link_data
,
6290 json_object_int_add(json_link
, "numOfTosMetrics",
6292 json_object_int_add(json_link
, "tos0Metric",
6293 ntohs(rl
->link
[i
].metric
));
6294 json_object_object_add(json_links
, link
, json_link
);
6296 vty_out(vty
, " Link connected to: %s\n",
6297 link_type_desc
[type
]);
6298 vty_out(vty
, " (Link ID) %s: %pI4\n",
6300 &rl
->link
[i
].link_id
);
6301 vty_out(vty
, " (Link Data) %s: %pI4\n",
6302 link_data_desc
[type
],
6303 &rl
->link
[i
].link_data
);
6304 vty_out(vty
, " Number of TOS metrics: 0\n");
6305 vty_out(vty
, " TOS 0 Metric: %d\n",
6306 ntohs(rl
->link
[i
].metric
));
6311 json_object_object_add(json
, "routerLinks", json_links
);
6314 /* Show router-LSA detail information. */
6315 static int show_router_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
,
6319 struct router_lsa
*rl
= (struct router_lsa
*)lsa
->data
;
6321 show_ip_ospf_database_header(vty
, lsa
, json
);
6324 vty_out(vty
, " Number of Links: %d\n\n",
6327 json_object_int_add(json
, "numOfLinks",
6330 show_ip_ospf_database_router_links(vty
, rl
, json
);
6339 /* Show network-LSA detail information. */
6340 static int show_network_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
,
6344 char buf
[PREFIX_STRLEN
];
6345 json_object
*json_attached_rt
= NULL
;
6346 json_object
*json_router
= NULL
;
6349 json_attached_rt
= json_object_new_object();
6352 struct network_lsa
*nl
= (struct network_lsa
*)lsa
->data
;
6353 struct in_addr
*addr
;
6355 show_ip_ospf_database_header(vty
, lsa
, json
);
6358 vty_out(vty
, " Network Mask: /%d\n",
6359 ip_masklen(nl
->mask
));
6361 json_object_int_add(json
, "networkMask",
6362 ip_masklen(nl
->mask
));
6364 length
= lsa
->size
- OSPF_LSA_HEADER_SIZE
- 4;
6365 addr
= &nl
->routers
[0];
6366 for (i
= 0; length
> 0 && addr
;
6367 length
-= 4, addr
= &nl
->routers
[++i
])
6369 vty_out(vty
, " Attached Router: %pI4\n",
6373 json_router
= json_object_new_object();
6374 json_object_string_add(
6375 json_router
, "attachedRouterId",
6376 inet_ntop(AF_INET
, addr
, buf
,
6378 json_object_object_add(json_attached_rt
,
6379 inet_ntop(AF_INET
, addr
,
6387 json_object_object_add(json
, "attchedRouters",
6393 /* Show summary-LSA detail information. */
6394 static int show_summary_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
,
6398 struct summary_lsa
*sl
= (struct summary_lsa
*)lsa
->data
;
6400 show_ip_ospf_database_header(vty
, lsa
, json
);
6403 vty_out(vty
, " Network Mask: /%d\n",
6404 ip_masklen(sl
->mask
));
6405 vty_out(vty
, " TOS: 0 Metric: %d\n",
6406 GET_METRIC(sl
->metric
));
6409 json_object_int_add(json
, "networkMask",
6410 ip_masklen(sl
->mask
));
6411 json_object_int_add(json
, "tos0Metric",
6412 GET_METRIC(sl
->metric
));
6419 /* Show summary-ASBR-LSA detail information. */
6420 static int show_summary_asbr_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
,
6424 struct summary_lsa
*sl
= (struct summary_lsa
*)lsa
->data
;
6426 show_ip_ospf_database_header(vty
, lsa
, json
);
6429 vty_out(vty
, " Network Mask: /%d\n",
6430 ip_masklen(sl
->mask
));
6431 vty_out(vty
, " TOS: 0 Metric: %d\n",
6432 GET_METRIC(sl
->metric
));
6435 json_object_int_add(json
, "networkMask",
6436 ip_masklen(sl
->mask
));
6437 json_object_int_add(json
, "tos0Metric",
6438 GET_METRIC(sl
->metric
));
6445 /* Show AS-external-LSA detail information. */
6446 static int show_as_external_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
,
6452 struct as_external_lsa
*al
=
6453 (struct as_external_lsa
*)lsa
->data
;
6455 show_ip_ospf_database_header(vty
, lsa
, json
);
6458 vty_out(vty
, " Network Mask: /%d\n",
6459 ip_masklen(al
->mask
));
6460 vty_out(vty
, " Metric Type: %s\n",
6461 IS_EXTERNAL_METRIC(al
->e
[0].tos
)
6462 ? "2 (Larger than any link state path)"
6464 vty_out(vty
, " TOS: 0\n");
6465 vty_out(vty
, " Metric: %d\n",
6466 GET_METRIC(al
->e
[0].metric
));
6467 vty_out(vty
, " Forward Address: %pI4\n",
6468 &al
->e
[0].fwd_addr
);
6470 " External Route Tag: %" ROUTE_TAG_PRI
"\n\n",
6471 (route_tag_t
)ntohl(al
->e
[0].route_tag
));
6473 json_object_int_add(json
, "networkMask",
6474 ip_masklen(al
->mask
));
6475 json_object_string_add(
6477 IS_EXTERNAL_METRIC(al
->e
[0].tos
)
6478 ? "E2 (Larger than any link state path)"
6480 json_object_int_add(json
, "tos", tos
);
6481 json_object_int_add(json
, "metric",
6482 GET_METRIC(al
->e
[0].metric
));
6483 json_object_string_addf(json
, "forwardAddress", "%pI4",
6484 &(al
->e
[0].fwd_addr
));
6485 json_object_int_add(
6486 json
, "externalRouteTag",
6487 (route_tag_t
)ntohl(al
->e
[0].route_tag
));
6494 /* Show AS-NSSA-LSA detail information. */
6495 static int show_as_nssa_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
,
6501 struct as_external_lsa
*al
=
6502 (struct as_external_lsa
*)lsa
->data
;
6504 show_ip_ospf_database_header(vty
, lsa
, json
);
6507 vty_out(vty
, " Network Mask: /%d\n",
6508 ip_masklen(al
->mask
));
6509 vty_out(vty
, " Metric Type: %s\n",
6510 IS_EXTERNAL_METRIC(al
->e
[0].tos
)
6511 ? "2 (Larger than any link state path)"
6513 vty_out(vty
, " TOS: 0\n");
6514 vty_out(vty
, " Metric: %d\n",
6515 GET_METRIC(al
->e
[0].metric
));
6516 vty_out(vty
, " NSSA: Forward Address: %pI4\n",
6517 &al
->e
[0].fwd_addr
);
6519 " External Route Tag: %" ROUTE_TAG_PRI
6521 (route_tag_t
)ntohl(al
->e
[0].route_tag
));
6523 json_object_int_add(json
, "networkMask",
6524 ip_masklen(al
->mask
));
6525 json_object_string_add(
6527 IS_EXTERNAL_METRIC(al
->e
[0].tos
)
6528 ? "E2 (Larger than any link state path)"
6530 json_object_int_add(json
, "tos", tos
);
6531 json_object_int_add(json
, "metric",
6532 GET_METRIC(al
->e
[0].metric
));
6533 json_object_string_addf(json
, "nssaForwardAddress",
6534 "%pI4", &al
->e
[0].fwd_addr
);
6535 json_object_int_add(
6536 json
, "externalRouteTag",
6537 (route_tag_t
)ntohl(al
->e
[0].route_tag
));
6544 static int show_func_dummy(struct vty
*vty
, struct ospf_lsa
*lsa
,
6550 static int show_opaque_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
,
6554 show_ip_ospf_database_header(vty
, lsa
, json
);
6555 show_opaque_info_detail(vty
, lsa
, json
);
6562 int (*show_function
[])(struct vty
*, struct ospf_lsa
*, json_object
*) = {
6564 show_router_lsa_detail
,
6565 show_network_lsa_detail
,
6566 show_summary_lsa_detail
,
6567 show_summary_asbr_lsa_detail
,
6568 show_as_external_lsa_detail
,
6570 show_as_nssa_lsa_detail
, /* almost same as external */
6572 show_opaque_lsa_detail
,
6573 show_opaque_lsa_detail
,
6574 show_opaque_lsa_detail
,
6577 static void show_lsa_prefix_set(struct vty
*vty
, struct prefix_ls
*lp
,
6578 struct in_addr
*id
, struct in_addr
*adv_router
)
6580 memset(lp
, 0, sizeof(struct prefix_ls
));
6584 else if (adv_router
== NULL
) {
6585 lp
->prefixlen
= IPV4_MAX_BITLEN
;
6590 lp
->adv_router
= *adv_router
;
6594 static void show_lsa_detail_proc(struct vty
*vty
, struct route_table
*rt
,
6595 struct in_addr
*id
, struct in_addr
*adv_router
,
6598 struct prefix_ls lp
;
6599 struct route_node
*rn
, *start
;
6600 struct ospf_lsa
*lsa
;
6601 json_object
*json_lsa
= NULL
;
6603 show_lsa_prefix_set(vty
, &lp
, id
, adv_router
);
6604 start
= route_node_get(rt
, (struct prefix
*)&lp
);
6606 route_lock_node(start
);
6607 for (rn
= start
; rn
; rn
= route_next_until(rn
, start
))
6608 if ((lsa
= rn
->info
)) {
6610 json_lsa
= json_object_new_object();
6611 json_object_array_add(json
, json_lsa
);
6614 if (show_function
[lsa
->data
->type
] != NULL
)
6615 show_function
[lsa
->data
->type
](
6616 vty
, lsa
, json_lsa
);
6618 route_unlock_node(start
);
6622 /* Show detail LSA information
6623 -- if id is NULL then show all LSAs. */
6624 static void show_lsa_detail(struct vty
*vty
, struct ospf
*ospf
, int type
,
6625 struct in_addr
*id
, struct in_addr
*adv_router
,
6628 struct listnode
*node
;
6629 struct ospf_area
*area
;
6630 char buf
[PREFIX_STRLEN
];
6631 json_object
*json_lsa_type
= NULL
;
6632 json_object
*json_areas
= NULL
;
6633 json_object
*json_lsa_array
= NULL
;
6636 json_lsa_type
= json_object_new_object();
6639 case OSPF_AS_EXTERNAL_LSA
:
6640 case OSPF_OPAQUE_AS_LSA
:
6642 vty_out(vty
, " %s \n\n",
6643 show_database_desc
[type
]);
6645 json_lsa_array
= json_object_new_array();
6647 show_lsa_detail_proc(vty
, AS_LSDB(ospf
, type
), id
, adv_router
,
6650 json_object_object_add(json
,
6651 show_database_desc_json
[type
],
6657 json_areas
= json_object_new_object();
6659 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
6662 "\n %s (Area %s)\n\n",
6663 show_database_desc
[type
],
6664 ospf_area_desc_string(area
));
6666 json_lsa_array
= json_object_new_array();
6667 json_object_object_add(json_areas
,
6675 show_lsa_detail_proc(vty
, AREA_LSDB(area
, type
), id
,
6676 adv_router
, json_lsa_array
);
6680 json_object_object_add(json_lsa_type
, "areas",
6682 json_object_object_add(json
,
6683 show_database_desc_json
[type
],
6690 static void show_lsa_detail_adv_router_proc(struct vty
*vty
,
6691 struct route_table
*rt
,
6692 struct in_addr
*adv_router
,
6695 char buf
[PREFIX_STRLEN
];
6696 struct route_node
*rn
;
6697 struct ospf_lsa
*lsa
;
6699 for (rn
= route_top(rt
); rn
; rn
= route_next(rn
))
6700 if ((lsa
= rn
->info
)) {
6701 json_object
*json_lsa
= NULL
;
6703 if (IPV4_ADDR_SAME(adv_router
,
6704 &lsa
->data
->adv_router
)) {
6705 if (CHECK_FLAG(lsa
->flags
, OSPF_LSA_LOCAL_XLT
))
6708 json_lsa
= json_object_new_object();
6710 if (show_function
[lsa
->data
->type
] != NULL
)
6711 show_function
[lsa
->data
->type
](
6712 vty
, lsa
, json_lsa
);
6714 json_object_object_add(
6724 /* Show detail LSA information. */
6725 static void show_lsa_detail_adv_router(struct vty
*vty
, struct ospf
*ospf
,
6726 int type
, struct in_addr
*adv_router
,
6729 struct listnode
*node
;
6730 struct ospf_area
*area
;
6731 char buf
[PREFIX_STRLEN
];
6732 json_object
*json_lstype
= NULL
;
6733 json_object
*json_area
= NULL
;
6736 json_lstype
= json_object_new_object();
6739 case OSPF_AS_EXTERNAL_LSA
:
6740 case OSPF_OPAQUE_AS_LSA
:
6742 vty_out(vty
, " %s \n\n",
6743 show_database_desc
[type
]);
6745 show_lsa_detail_adv_router_proc(vty
, AS_LSDB(ospf
, type
),
6746 adv_router
, json_lstype
);
6750 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
6752 json_area
= json_object_new_object();
6755 "\n %s (Area %s)\n\n",
6756 show_database_desc
[type
],
6757 ospf_area_desc_string(area
));
6758 show_lsa_detail_adv_router_proc(vty
,
6759 AREA_LSDB(area
, type
),
6760 adv_router
, json_area
);
6763 json_object_object_add(json_lstype
,
6774 json_object_object_add(json
, show_database_desc
[type
],
6778 void show_ip_ospf_database_summary(struct vty
*vty
, struct ospf
*ospf
, int self
,
6781 struct ospf_lsa
*lsa
;
6782 struct route_node
*rn
;
6783 struct ospf_area
*area
;
6784 struct listnode
*node
;
6785 char buf
[PREFIX_STRLEN
];
6786 json_object
*json_areas
= NULL
;
6787 json_object
*json_area
= NULL
;
6788 json_object
*json_lsa
= NULL
;
6790 json_object
*json_lsa_array
= NULL
;
6794 json_areas
= json_object_new_object();
6796 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
6798 json_area
= json_object_new_object();
6800 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++) {
6803 case OSPF_AS_EXTERNAL_LSA
:
6804 case OSPF_OPAQUE_AS_LSA
:
6809 if (ospf_lsdb_count_self(area
->lsdb
, type
) > 0
6811 && ospf_lsdb_count(area
->lsdb
, type
) > 0)) {
6815 " %s (Area %s)\n\n",
6816 show_database_desc
[type
],
6817 ospf_area_desc_string(area
));
6818 vty_out(vty
, "%s\n",
6819 show_database_header
[type
]);
6822 json_object_new_array();
6823 json_object_object_add(
6825 show_database_desc_json
[type
],
6829 LSDB_LOOP (AREA_LSDB(area
, type
), rn
, lsa
) {
6832 json_object_new_object();
6833 json_object_array_add(
6838 count
+= show_lsa_summary(
6839 vty
, lsa
, self
, json_lsa
);
6845 json_object_int_add(
6848 show_database_desc_count_json
6854 json_object_object_add(json_areas
,
6862 json_object_object_add(json
, "areas", json_areas
);
6864 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++) {
6867 case OSPF_AS_EXTERNAL_LSA
:
6868 case OSPF_OPAQUE_AS_LSA
:
6873 if (ospf_lsdb_count_self(ospf
->lsdb
, type
)
6874 || (!self
&& ospf_lsdb_count(ospf
->lsdb
, type
))) {
6876 vty_out(vty
, " %s\n\n",
6877 show_database_desc
[type
]);
6878 vty_out(vty
, "%s\n",
6879 show_database_header
[type
]);
6881 json_lsa_array
= json_object_new_array();
6882 json_object_object_add(
6883 json
, show_database_desc_json
[type
],
6887 LSDB_LOOP (AS_LSDB(ospf
, type
), rn
, lsa
) {
6889 json_lsa
= json_object_new_object();
6890 json_object_array_add(json_lsa_array
,
6894 count
+= show_lsa_summary(vty
, lsa
, self
,
6901 json_object_int_add(
6903 show_database_desc_count_json
[type
],
6912 static void show_ip_ospf_database_maxage(struct vty
*vty
, struct ospf
*ospf
,
6915 struct route_node
*rn
;
6916 char buf
[PREFIX_STRLEN
];
6917 json_object
*json_maxage
= NULL
;
6920 vty_out(vty
, "\n MaxAge Link States:\n\n");
6922 json_maxage
= json_object_new_object();
6924 for (rn
= route_top(ospf
->maxage_lsa
); rn
; rn
= route_next(rn
)) {
6925 struct ospf_lsa
*lsa
;
6926 json_object
*json_lsa
= NULL
;
6928 if ((lsa
= rn
->info
) != NULL
) {
6930 vty_out(vty
, "Link type: %d\n",
6932 vty_out(vty
, "Link State ID: %pI4\n",
6934 vty_out(vty
, "Advertising Router: %pI4\n",
6935 &lsa
->data
->adv_router
);
6936 vty_out(vty
, "LSA lock count: %d\n", lsa
->lock
);
6939 json_lsa
= json_object_new_object();
6940 json_object_int_add(json_lsa
, "linkType",
6942 json_object_string_addf(json_lsa
, "linkStateId",
6943 "%pI4", &lsa
->data
->id
);
6944 json_object_string_addf(
6945 json_lsa
, "advertisingRouter", "%pI4",
6946 &lsa
->data
->adv_router
);
6947 json_object_int_add(json_lsa
, "lsaLockCount",
6949 json_object_object_add(
6959 json_object_object_add(json
, "maxAgeLinkStates", json_maxage
);
6962 #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
6963 #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
6965 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
6966 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
6967 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
6968 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
6970 #define OSPF_LSA_TYPES_DESC \
6971 "ASBR summary link states\n" \
6972 "External link states\n" \
6973 "Network link states\n" \
6974 "Router link states\n" \
6975 "Network summary link states\n" OSPF_LSA_TYPE_NSSA_DESC \
6976 OSPF_LSA_TYPE_OPAQUE_LINK_DESC OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
6977 OSPF_LSA_TYPE_OPAQUE_AS_DESC
6979 static int show_ip_ospf_database_common(struct vty
*vty
, struct ospf
*ospf
,
6980 int arg_base
, int argc
,
6981 struct cmd_token
**argv
,
6982 uint8_t use_vrf
, json_object
*json
,
6987 struct in_addr id
, adv_router
;
6988 json_object
*json_vrf
= NULL
;
6992 json_vrf
= json_object_new_object();
6997 if (ospf
->instance
) {
6999 json_object_int_add(json_vrf
, "ospfInstance",
7002 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
7005 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
7007 /* Show Router ID. */
7009 json_object_string_addf(json_vrf
, "routerId", "%pI4",
7012 vty_out(vty
, "\n OSPF Router with ID (%pI4)\n\n",
7017 if ((argc
== arg_base
+ 4) || (uj
&& (argc
== arg_base
+ 5))) {
7018 show_ip_ospf_database_summary(vty
, ospf
, 0, json_vrf
);
7021 json_object_object_add(
7022 json
, ospf_get_name(ospf
), json_vrf
);
7027 /* Set database type to show. */
7028 if (strncmp(argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
7029 type
= OSPF_ROUTER_LSA
;
7030 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
7031 type
= OSPF_NETWORK_LSA
;
7032 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
7033 type
= OSPF_AS_NSSA_LSA
;
7034 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "su", 2) == 0)
7035 type
= OSPF_SUMMARY_LSA
;
7036 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
7037 type
= OSPF_ASBR_SUMMARY_LSA
;
7038 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
7039 type
= OSPF_AS_EXTERNAL_LSA
;
7040 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "se", 2) == 0) {
7041 show_ip_ospf_database_summary(vty
, ospf
, 1, json_vrf
);
7044 json_object_object_add(
7045 json
, ospf_get_name(ospf
), json_vrf
);
7048 } else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "m", 1) == 0) {
7049 show_ip_ospf_database_maxage(vty
, ospf
, json_vrf
);
7052 json_object_object_add(
7053 json
, ospf_get_name(ospf
), json_vrf
);
7056 } else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
7057 type
= OSPF_OPAQUE_LINK_LSA
;
7058 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
7059 type
= OSPF_OPAQUE_AREA_LSA
;
7060 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
7061 type
= OSPF_OPAQUE_AS_LSA
;
7065 /* `show ip ospf database LSA'. */
7066 if ((argc
== arg_base
+ 5) || (uj
&& (argc
== arg_base
+ 6)))
7067 show_lsa_detail(vty
, ospf
, type
, NULL
, NULL
, json_vrf
);
7068 else if (argc
>= arg_base
+ 6) {
7069 ret
= inet_aton(argv
[arg_base
+ 5]->arg
, &id
);
7073 /* `show ip ospf database LSA ID'. */
7074 if ((argc
== arg_base
+ 6) || (uj
&& (argc
== arg_base
+ 7)))
7075 show_lsa_detail(vty
, ospf
, type
, &id
, NULL
, json_vrf
);
7076 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
7077 else if ((argc
== arg_base
+ 7)
7078 || (uj
&& (argc
== arg_base
+ 8))) {
7079 if (strncmp(argv
[arg_base
+ 6]->text
, "s", 1) == 0)
7080 adv_router
= ospf
->router_id
;
7082 ret
= inet_aton(argv
[arg_base
+ 7]->arg
,
7087 show_lsa_detail(vty
, ospf
, type
, &id
, &adv_router
,
7094 json_object_object_add(json
, ospf_get_name(ospf
),
7101 DEFUN (show_ip_ospf_database_max
,
7102 show_ip_ospf_database_max_cmd
,
7103 "show ip ospf [vrf <NAME|all>] database <max-age|self-originate> [json]",
7106 "OSPF information\n"
7109 "Database summary\n"
7110 "LSAs in MaxAge list\n"
7111 "Self-originated link states\n"
7114 struct ospf
*ospf
= NULL
;
7115 struct listnode
*node
= NULL
;
7116 char *vrf_name
= NULL
;
7117 bool all_vrf
= false;
7118 int ret
= CMD_SUCCESS
;
7121 uint8_t use_vrf
= 0;
7122 bool uj
= use_json(argc
, argv
);
7123 json_object
*json
= NULL
;
7126 json
= json_object_new_object();
7128 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
7131 bool ospf_output
= false;
7136 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
7137 if (!ospf
->oi_running
)
7140 ret
= show_ip_ospf_database_common(
7141 vty
, ospf
, idx_vrf
? 2 : 0, argc
, argv
,
7146 vty_out(vty
, "%% OSPF instance not found\n");
7148 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
7149 if (ospf
== NULL
|| !ospf
->oi_running
) {
7150 vty_out(vty
, "%% OSPF instance not found\n");
7153 ret
= (show_ip_ospf_database_common(
7154 vty
, ospf
, idx_vrf
? 2 : 0, argc
, argv
, use_vrf
,
7158 /* Display default ospf (instance 0) info */
7159 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
7160 if (ospf
== NULL
|| !ospf
->oi_running
) {
7161 vty_out(vty
, "%% OSPF instance not found\n");
7165 ret
= show_ip_ospf_database_common(vty
, ospf
, 0, argc
, argv
,
7170 vty_out(vty
, "%s\n", json_object_to_json_string(json
));
7171 json_object_free(json
);
7177 ALIAS (show_ip_ospf_database_max
,
7178 show_ip_ospf_database_cmd
,
7179 "show ip ospf [vrf <NAME|all>] 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>]]] [json]",
7182 "OSPF information\n"
7185 "Database summary\n"
7187 "Link State ID (as an IP address)\n"
7188 "Self-originated link states\n"
7189 "Advertising Router link states\n"
7190 "Advertising Router (as an IP address)\n"
7193 DEFUN (show_ip_ospf_instance_database_max
,
7194 show_ip_ospf_instance_database_max_cmd
,
7195 "show ip ospf (1-65535) database <max-age|self-originate> [json]",
7198 "OSPF information\n"
7200 "Database summary\n"
7201 "LSAs in MaxAge list\n"
7202 "Self-originated link states\n"
7207 unsigned short instance
= 0;
7208 bool uj
= use_json(argc
, argv
);
7209 json_object
*json
= NULL
;
7212 json
= json_object_new_object();
7214 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7215 if (instance
!= ospf_instance
)
7216 return CMD_NOT_MY_INSTANCE
;
7218 ospf
= ospf_lookup_instance(instance
);
7219 if (!ospf
|| !ospf
->oi_running
)
7222 show_ip_ospf_database_common(vty
, ospf
, 1, argc
, argv
, 0, json
, uj
);
7225 vty_json(vty
, json
);
7230 ALIAS (show_ip_ospf_instance_database_max
,
7231 show_ip_ospf_instance_database_cmd
,
7232 "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>]]] [json]",
7235 "OSPF information\n"
7237 "Database summary\n"
7239 "Link State ID (as an IP address)\n"
7240 "Self-originated link states\n"
7241 "Advertising Router link states\n"
7242 "Advertising Router (as an IP address)\n"
7245 static int show_ip_ospf_database_type_adv_router_common(struct vty
*vty
,
7247 int arg_base
, int argc
,
7248 struct cmd_token
**argv
,
7255 struct in_addr adv_router
;
7256 json_object
*json_vrf
= NULL
;
7260 json_vrf
= json_object_new_object();
7265 if (ospf
->instance
) {
7267 json_object_int_add(json
, "ospfInstance",
7270 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
7273 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
7275 /* Show Router ID. */
7277 json_object_string_addf(json_vrf
, "routerId", "%pI4",
7280 vty_out(vty
, "\n OSPF Router with ID (%pI4)\n\n",
7284 /* Set database type to show. */
7285 if (strncmp(argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
7286 type
= OSPF_ROUTER_LSA
;
7287 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
7288 type
= OSPF_NETWORK_LSA
;
7289 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
7290 type
= OSPF_AS_NSSA_LSA
;
7291 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "s", 1) == 0)
7292 type
= OSPF_SUMMARY_LSA
;
7293 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
7294 type
= OSPF_ASBR_SUMMARY_LSA
;
7295 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
7296 type
= OSPF_AS_EXTERNAL_LSA
;
7297 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
7298 type
= OSPF_OPAQUE_LINK_LSA
;
7299 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
7300 type
= OSPF_OPAQUE_AREA_LSA
;
7301 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
7302 type
= OSPF_OPAQUE_AS_LSA
;
7306 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
7307 if (strncmp(argv
[arg_base
+ 5]->text
, "s", 1) == 0)
7308 adv_router
= ospf
->router_id
;
7310 ret
= inet_aton(argv
[arg_base
+ 6]->arg
, &adv_router
);
7315 show_lsa_detail_adv_router(vty
, ospf
, type
, &adv_router
, json_vrf
);
7319 json_object_object_add(json
, ospf_get_name(ospf
),
7326 DEFUN (show_ip_ospf_database_type_adv_router
,
7327 show_ip_ospf_database_type_adv_router_cmd
,
7328 "show ip ospf [vrf <NAME|all>] database <asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as> <adv-router A.B.C.D|self-originate> [json]",
7331 "OSPF information\n"
7334 "Database summary\n"
7336 "Advertising Router link states\n"
7337 "Advertising Router (as an IP address)\n"
7338 "Self-originated link states\n"
7341 struct ospf
*ospf
= NULL
;
7342 struct listnode
*node
= NULL
;
7343 char *vrf_name
= NULL
;
7344 bool all_vrf
= false;
7345 int ret
= CMD_SUCCESS
;
7348 uint8_t use_vrf
= 0;
7349 bool uj
= use_json(argc
, argv
);
7350 json_object
*json
= NULL
;
7353 json
= json_object_new_object();
7355 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
7358 bool ospf_output
= false;
7363 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
7364 if (!ospf
->oi_running
)
7367 ret
= show_ip_ospf_database_type_adv_router_common(
7368 vty
, ospf
, 2, argc
, argv
, use_vrf
, json
,
7372 vty_out(vty
, "%% OSPF instance not found\n");
7374 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
7375 if ((ospf
== NULL
) || !ospf
->oi_running
) {
7376 vty_out(vty
, "%% OSPF instance not found\n");
7380 ret
= show_ip_ospf_database_type_adv_router_common(
7381 vty
, ospf
, 2, argc
, argv
, use_vrf
, json
, uj
);
7384 /* Display default ospf (instance 0) info */
7385 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
7386 if (ospf
== NULL
|| !ospf
->oi_running
) {
7387 vty_out(vty
, "%% OSPF instance not found\n");
7391 ret
= show_ip_ospf_database_type_adv_router_common(
7392 vty
, ospf
, 0, argc
, argv
, use_vrf
, json
, uj
);
7396 vty_out(vty
, "%s\n", json_object_to_json_string(json
));
7397 json_object_free(json
);
7403 DEFUN (show_ip_ospf_instance_database_type_adv_router
,
7404 show_ip_ospf_instance_database_type_adv_router_cmd
,
7405 "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> [json]",
7408 "OSPF information\n"
7410 "Database summary\n"
7412 "Advertising Router link states\n"
7413 "Advertising Router (as an IP address)\n"
7414 "Self-originated link states\n"
7419 unsigned short instance
= 0;
7420 bool uj
= use_json(argc
, argv
);
7421 json_object
*json
= NULL
;
7424 json
= json_object_new_object();
7426 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7427 if (instance
!= ospf_instance
)
7428 return CMD_NOT_MY_INSTANCE
;
7430 ospf
= ospf_lookup_instance(instance
);
7431 if (!ospf
|| !ospf
->oi_running
)
7434 show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 1, argc
, argv
,
7438 vty_json(vty
, json
);
7443 DEFUN (ip_ospf_authentication_args
,
7444 ip_ospf_authentication_args_addr_cmd
,
7445 "ip ospf authentication <null|message-digest> [A.B.C.D]",
7447 "OSPF interface commands\n"
7448 "Enable authentication on this interface\n"
7449 "Use null authentication\n"
7450 "Use message-digest authentication\n"
7451 "Address of interface\n")
7453 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7454 int idx_encryption
= 3;
7456 struct in_addr addr
;
7458 struct ospf_if_params
*params
;
7460 params
= IF_DEF_PARAMS(ifp
);
7463 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7466 "Please specify interface address by A.B.C.D\n");
7467 return CMD_WARNING_CONFIG_FAILED
;
7470 params
= ospf_get_if_params(ifp
, addr
);
7471 ospf_if_update_params(ifp
, addr
);
7474 /* Handle null authentication */
7475 if (argv
[idx_encryption
]->arg
[0] == 'n') {
7476 SET_IF_PARAM(params
, auth_type
);
7477 params
->auth_type
= OSPF_AUTH_NULL
;
7481 /* Handle message-digest authentication */
7482 if (argv
[idx_encryption
]->arg
[0] == 'm') {
7483 SET_IF_PARAM(params
, auth_type
);
7484 params
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
7488 vty_out(vty
, "You shouldn't get here!\n");
7489 return CMD_WARNING_CONFIG_FAILED
;
7492 DEFUN (ip_ospf_authentication
,
7493 ip_ospf_authentication_addr_cmd
,
7494 "ip ospf authentication [A.B.C.D]",
7496 "OSPF interface commands\n"
7497 "Enable authentication on this interface\n"
7498 "Address of interface\n")
7500 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7502 struct in_addr addr
;
7504 struct ospf_if_params
*params
;
7506 params
= IF_DEF_PARAMS(ifp
);
7509 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7512 "Please specify interface address by A.B.C.D\n");
7513 return CMD_WARNING_CONFIG_FAILED
;
7516 params
= ospf_get_if_params(ifp
, addr
);
7517 ospf_if_update_params(ifp
, addr
);
7520 SET_IF_PARAM(params
, auth_type
);
7521 params
->auth_type
= OSPF_AUTH_SIMPLE
;
7526 DEFUN (no_ip_ospf_authentication_args
,
7527 no_ip_ospf_authentication_args_addr_cmd
,
7528 "no ip ospf authentication <null|message-digest> [A.B.C.D]",
7531 "OSPF interface commands\n"
7532 "Enable authentication on this interface\n"
7533 "Use null authentication\n"
7534 "Use message-digest authentication\n"
7535 "Address of interface\n")
7537 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7538 int idx_encryption
= 4;
7540 struct in_addr addr
;
7542 struct ospf_if_params
*params
;
7543 struct route_node
*rn
;
7546 params
= IF_DEF_PARAMS(ifp
);
7549 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7552 "Please specify interface address by A.B.C.D\n");
7553 return CMD_WARNING_CONFIG_FAILED
;
7556 params
= ospf_lookup_if_params(ifp
, addr
);
7557 if (params
== NULL
) {
7558 vty_out(vty
, "Ip Address specified is unknown\n");
7559 return CMD_WARNING_CONFIG_FAILED
;
7561 params
->auth_type
= OSPF_AUTH_NOTSET
;
7562 UNSET_IF_PARAM(params
, auth_type
);
7563 if (params
!= IF_DEF_PARAMS(ifp
)) {
7564 ospf_free_if_params(ifp
, addr
);
7565 ospf_if_update_params(ifp
, addr
);
7568 if (argv
[idx_encryption
]->arg
[0] == 'n') {
7569 auth_type
= OSPF_AUTH_NULL
;
7570 } else if (argv
[idx_encryption
]->arg
[0] == 'm') {
7571 auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
7573 vty_out(vty
, "Unexpected input encountered\n");
7574 return CMD_WARNING_CONFIG_FAILED
;
7577 * Here we have a case where the user has entered
7578 * 'no ip ospf authentication (null | message_digest )'
7579 * we need to find if we have any ip addresses underneath it
7581 * correspond to the associated type.
7583 if (params
->auth_type
== auth_type
) {
7584 params
->auth_type
= OSPF_AUTH_NOTSET
;
7585 UNSET_IF_PARAM(params
, auth_type
);
7588 for (rn
= route_top(IF_OIFS_PARAMS(ifp
)); rn
;
7589 rn
= route_next(rn
)) {
7590 if ((params
= rn
->info
)) {
7591 if (params
->auth_type
== auth_type
) {
7592 params
->auth_type
= OSPF_AUTH_NOTSET
;
7593 UNSET_IF_PARAM(params
, auth_type
);
7594 if (params
!= IF_DEF_PARAMS(ifp
)) {
7595 ospf_free_if_params(
7596 ifp
, rn
->p
.u
.prefix4
);
7597 ospf_if_update_params(
7598 ifp
, rn
->p
.u
.prefix4
);
7608 DEFUN (no_ip_ospf_authentication
,
7609 no_ip_ospf_authentication_addr_cmd
,
7610 "no ip ospf authentication [A.B.C.D]",
7613 "OSPF interface commands\n"
7614 "Enable authentication on this interface\n"
7615 "Address of interface\n")
7617 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7619 struct in_addr addr
;
7621 struct ospf_if_params
*params
;
7622 struct route_node
*rn
;
7624 params
= IF_DEF_PARAMS(ifp
);
7627 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7630 "Please specify interface address by A.B.C.D\n");
7631 return CMD_WARNING_CONFIG_FAILED
;
7634 params
= ospf_lookup_if_params(ifp
, addr
);
7635 if (params
== NULL
) {
7636 vty_out(vty
, "Ip Address specified is unknown\n");
7637 return CMD_WARNING_CONFIG_FAILED
;
7640 params
->auth_type
= OSPF_AUTH_NOTSET
;
7641 UNSET_IF_PARAM(params
, auth_type
);
7642 if (params
!= IF_DEF_PARAMS(ifp
)) {
7643 ospf_free_if_params(ifp
, addr
);
7644 ospf_if_update_params(ifp
, addr
);
7648 * When a user enters 'no ip ospf authentication'
7649 * We should remove all authentication types from
7652 if ((params
->auth_type
== OSPF_AUTH_NULL
)
7653 || (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
7654 || (params
->auth_type
== OSPF_AUTH_SIMPLE
)) {
7655 params
->auth_type
= OSPF_AUTH_NOTSET
;
7656 UNSET_IF_PARAM(params
, auth_type
);
7659 for (rn
= route_top(IF_OIFS_PARAMS(ifp
)); rn
;
7660 rn
= route_next(rn
)) {
7661 if ((params
= rn
->info
)) {
7663 if ((params
->auth_type
== OSPF_AUTH_NULL
)
7664 || (params
->auth_type
7665 == OSPF_AUTH_CRYPTOGRAPHIC
)
7666 || (params
->auth_type
7667 == OSPF_AUTH_SIMPLE
)) {
7668 params
->auth_type
= OSPF_AUTH_NOTSET
;
7669 UNSET_IF_PARAM(params
, auth_type
);
7670 if (params
!= IF_DEF_PARAMS(ifp
)) {
7671 ospf_free_if_params(
7672 ifp
, rn
->p
.u
.prefix4
);
7673 ospf_if_update_params(
7674 ifp
, rn
->p
.u
.prefix4
);
7685 DEFUN (ip_ospf_authentication_key
,
7686 ip_ospf_authentication_key_addr_cmd
,
7687 "ip ospf authentication-key AUTH_KEY [A.B.C.D]",
7689 "OSPF interface commands\n"
7690 "Authentication password (key)\n"
7691 "The OSPF password (key)\n"
7692 "Address of interface\n")
7694 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7696 struct in_addr addr
;
7697 struct ospf_if_params
*params
;
7699 params
= IF_DEF_PARAMS(ifp
);
7701 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7702 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7704 "Please specify interface address by A.B.C.D\n");
7705 return CMD_WARNING_CONFIG_FAILED
;
7708 params
= ospf_get_if_params(ifp
, addr
);
7709 ospf_if_update_params(ifp
, addr
);
7712 strlcpy((char *)params
->auth_simple
, argv
[3]->arg
,
7713 sizeof(params
->auth_simple
));
7714 SET_IF_PARAM(params
, auth_simple
);
7719 DEFUN_HIDDEN (ospf_authentication_key
,
7720 ospf_authentication_key_cmd
,
7721 "ospf authentication-key AUTH_KEY [A.B.C.D]",
7722 "OSPF interface commands\n"
7723 VLINK_HELPSTR_AUTH_SIMPLE
7724 "Address of interface\n")
7726 return ip_ospf_authentication_key(self
, vty
, argc
, argv
);
7729 DEFUN (no_ip_ospf_authentication_key
,
7730 no_ip_ospf_authentication_key_authkey_addr_cmd
,
7731 "no ip ospf authentication-key [AUTH_KEY [A.B.C.D]]",
7734 "OSPF interface commands\n"
7735 VLINK_HELPSTR_AUTH_SIMPLE
7736 "Address of interface\n")
7738 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7740 struct in_addr addr
;
7741 struct ospf_if_params
*params
;
7742 params
= IF_DEF_PARAMS(ifp
);
7744 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7745 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7747 "Please specify interface address by A.B.C.D\n");
7748 return CMD_WARNING_CONFIG_FAILED
;
7751 params
= ospf_lookup_if_params(ifp
, addr
);
7756 memset(params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
);
7757 UNSET_IF_PARAM(params
, auth_simple
);
7759 if (params
!= IF_DEF_PARAMS(ifp
)) {
7760 ospf_free_if_params(ifp
, addr
);
7761 ospf_if_update_params(ifp
, addr
);
7767 DEFUN_HIDDEN (no_ospf_authentication_key
,
7768 no_ospf_authentication_key_authkey_addr_cmd
,
7769 "no ospf authentication-key [AUTH_KEY [A.B.C.D]]",
7771 "OSPF interface commands\n"
7772 VLINK_HELPSTR_AUTH_SIMPLE
7773 "Address of interface\n")
7775 return no_ip_ospf_authentication_key(self
, vty
, argc
, argv
);
7778 DEFUN (ip_ospf_message_digest_key
,
7779 ip_ospf_message_digest_key_cmd
,
7780 "ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
7782 "OSPF interface commands\n"
7783 "Message digest authentication password (key)\n"
7785 "Use MD5 algorithm\n"
7786 "The OSPF password (key)\n"
7787 "Address of interface\n")
7789 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7790 struct crypt_key
*ck
;
7792 struct in_addr addr
;
7793 struct ospf_if_params
*params
;
7795 params
= IF_DEF_PARAMS(ifp
);
7798 argv_find(argv
, argc
, "(1-255)", &idx
);
7799 char *keyid
= argv
[idx
]->arg
;
7800 argv_find(argv
, argc
, "KEY", &idx
);
7801 char *cryptkey
= argv
[idx
]->arg
;
7803 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7804 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7806 "Please specify interface address by A.B.C.D\n");
7807 return CMD_WARNING_CONFIG_FAILED
;
7810 params
= ospf_get_if_params(ifp
, addr
);
7811 ospf_if_update_params(ifp
, addr
);
7814 key_id
= strtol(keyid
, NULL
, 10);
7816 /* Remove existing key, if any */
7817 ospf_crypt_key_delete(params
->auth_crypt
, key_id
);
7819 ck
= ospf_crypt_key_new();
7820 ck
->key_id
= (uint8_t)key_id
;
7821 strlcpy((char *)ck
->auth_key
, cryptkey
, sizeof(ck
->auth_key
));
7823 ospf_crypt_key_add(params
->auth_crypt
, ck
);
7824 SET_IF_PARAM(params
, auth_crypt
);
7829 DEFUN_HIDDEN (ospf_message_digest_key
,
7830 ospf_message_digest_key_cmd
,
7831 "ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
7832 "OSPF interface commands\n"
7833 "Message digest authentication password (key)\n"
7835 "Use MD5 algorithm\n"
7836 "The OSPF password (key)\n"
7837 "Address of interface\n")
7839 return ip_ospf_message_digest_key(self
, vty
, argc
, argv
);
7842 DEFUN (no_ip_ospf_message_digest_key
,
7843 no_ip_ospf_message_digest_key_cmd
,
7844 "no ip ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
7847 "OSPF interface commands\n"
7848 "Message digest authentication password (key)\n"
7850 "Use MD5 algorithm\n"
7851 "The OSPF password (key)\n"
7852 "Address of interface\n")
7854 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7856 struct crypt_key
*ck
;
7858 struct in_addr addr
;
7859 struct ospf_if_params
*params
;
7860 params
= IF_DEF_PARAMS(ifp
);
7862 argv_find(argv
, argc
, "(1-255)", &idx
);
7863 char *keyid
= argv
[idx
]->arg
;
7865 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7866 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7868 "Please specify interface address by A.B.C.D\n");
7869 return CMD_WARNING_CONFIG_FAILED
;
7872 params
= ospf_lookup_if_params(ifp
, addr
);
7877 key_id
= strtol(keyid
, NULL
, 10);
7878 ck
= ospf_crypt_key_lookup(params
->auth_crypt
, key_id
);
7880 vty_out(vty
, "OSPF: Key %d does not exist\n", key_id
);
7881 return CMD_WARNING_CONFIG_FAILED
;
7884 ospf_crypt_key_delete(params
->auth_crypt
, key_id
);
7886 if (params
!= IF_DEF_PARAMS(ifp
)) {
7887 ospf_free_if_params(ifp
, addr
);
7888 ospf_if_update_params(ifp
, addr
);
7894 DEFUN_HIDDEN (no_ospf_message_digest_key
,
7895 no_ospf_message_digest_key_cmd
,
7896 "no ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
7898 "OSPF interface commands\n"
7899 "Message digest authentication password (key)\n"
7901 "Use MD5 algorithm\n"
7902 "The OSPF password (key)\n"
7903 "Address of interface\n")
7905 return no_ip_ospf_message_digest_key(self
, vty
, argc
, argv
);
7908 DEFUN (ip_ospf_cost
,
7910 "ip ospf cost (1-65535) [A.B.C.D]",
7912 "OSPF interface commands\n"
7915 "Address of interface\n")
7917 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7919 uint32_t cost
= OSPF_OUTPUT_COST_DEFAULT
;
7920 struct in_addr addr
;
7921 struct ospf_if_params
*params
;
7922 params
= IF_DEF_PARAMS(ifp
);
7925 char *coststr
= NULL
, *ifaddr
= NULL
;
7927 argv_find(argv
, argc
, "(1-65535)", &idx
);
7928 coststr
= argv
[idx
]->arg
;
7929 cost
= strtol(coststr
, NULL
, 10);
7931 ifaddr
= argv_find(argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
7933 if (!inet_aton(ifaddr
, &addr
)) {
7935 "Please specify interface address by A.B.C.D\n");
7936 return CMD_WARNING_CONFIG_FAILED
;
7939 params
= ospf_get_if_params(ifp
, addr
);
7940 ospf_if_update_params(ifp
, addr
);
7943 SET_IF_PARAM(params
, output_cost_cmd
);
7944 params
->output_cost_cmd
= cost
;
7946 ospf_if_recalculate_output_cost(ifp
);
7951 DEFUN_HIDDEN (ospf_cost
,
7953 "ospf cost (1-65535) [A.B.C.D]",
7954 "OSPF interface commands\n"
7957 "Address of interface\n")
7959 return ip_ospf_cost(self
, vty
, argc
, argv
);
7962 DEFUN (no_ip_ospf_cost
,
7963 no_ip_ospf_cost_cmd
,
7964 "no ip ospf cost [(1-65535)] [A.B.C.D]",
7967 "OSPF interface commands\n"
7970 "Address of interface\n")
7972 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7974 struct in_addr addr
;
7975 struct ospf_if_params
*params
;
7977 params
= IF_DEF_PARAMS(ifp
);
7980 char *ifaddr
= NULL
;
7981 ifaddr
= argv_find(argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
7983 /* According to the semantics we are mimicking "no ip ospf cost N" is
7984 * always treated as "no ip ospf cost" regardless of the actual value
7985 * of N already configured for the interface. Thus ignore cost. */
7988 if (!inet_aton(ifaddr
, &addr
)) {
7990 "Please specify interface address by A.B.C.D\n");
7991 return CMD_WARNING_CONFIG_FAILED
;
7994 params
= ospf_lookup_if_params(ifp
, addr
);
7999 UNSET_IF_PARAM(params
, output_cost_cmd
);
8001 if (params
!= IF_DEF_PARAMS(ifp
)) {
8002 ospf_free_if_params(ifp
, addr
);
8003 ospf_if_update_params(ifp
, addr
);
8006 ospf_if_recalculate_output_cost(ifp
);
8011 DEFUN_HIDDEN (no_ospf_cost
,
8013 "no ospf cost [(1-65535)] [A.B.C.D]",
8015 "OSPF interface commands\n"
8018 "Address of interface\n")
8020 return no_ip_ospf_cost(self
, vty
, argc
, argv
);
8023 static void ospf_nbr_timer_update(struct ospf_interface
*oi
)
8025 struct route_node
*rn
;
8026 struct ospf_neighbor
*nbr
;
8028 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
))
8029 if ((nbr
= rn
->info
)) {
8030 nbr
->v_inactivity
= OSPF_IF_PARAM(oi
, v_wait
);
8031 nbr
->v_db_desc
= OSPF_IF_PARAM(oi
, retransmit_interval
);
8032 nbr
->v_ls_req
= OSPF_IF_PARAM(oi
, retransmit_interval
);
8033 nbr
->v_ls_upd
= OSPF_IF_PARAM(oi
, retransmit_interval
);
8037 static int ospf_vty_dead_interval_set(struct vty
*vty
, const char *interval_str
,
8038 const char *nbr_str
,
8039 const char *fast_hello_str
)
8041 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8044 struct in_addr addr
;
8046 struct ospf_if_params
*params
;
8047 struct ospf_interface
*oi
;
8048 struct route_node
*rn
;
8050 params
= IF_DEF_PARAMS(ifp
);
8053 ret
= inet_aton(nbr_str
, &addr
);
8056 "Please specify interface address by A.B.C.D\n");
8057 return CMD_WARNING_CONFIG_FAILED
;
8060 params
= ospf_get_if_params(ifp
, addr
);
8061 ospf_if_update_params(ifp
, addr
);
8065 seconds
= strtoul(interval_str
, NULL
, 10);
8067 /* reset fast_hello too, just to be sure */
8068 UNSET_IF_PARAM(params
, fast_hello
);
8069 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
8070 } else if (fast_hello_str
) {
8071 hellomult
= strtoul(fast_hello_str
, NULL
, 10);
8072 /* 1s dead-interval with sub-second hellos desired */
8073 seconds
= OSPF_ROUTER_DEAD_INTERVAL_MINIMAL
;
8074 SET_IF_PARAM(params
, fast_hello
);
8075 params
->fast_hello
= hellomult
;
8078 "Please specify dead-interval or hello-multiplier\n");
8079 return CMD_WARNING_CONFIG_FAILED
;
8082 SET_IF_PARAM(params
, v_wait
);
8083 params
->v_wait
= seconds
;
8084 params
->is_v_wait_set
= true;
8086 /* Update timer values in neighbor structure. */
8088 struct ospf
*ospf
= NULL
;
8090 ospf
= ifp
->vrf
->info
;
8092 oi
= ospf_if_lookup_by_local_addr(ospf
, ifp
, addr
);
8094 ospf_nbr_timer_update(oi
);
8097 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
))
8098 if ((oi
= rn
->info
))
8099 ospf_nbr_timer_update(oi
);
8105 DEFUN (ip_ospf_dead_interval
,
8106 ip_ospf_dead_interval_cmd
,
8107 "ip ospf dead-interval (1-65535) [A.B.C.D]",
8109 "OSPF interface commands\n"
8110 "Interval time after which a neighbor is declared down\n"
8112 "Address of interface\n")
8115 char *interval
= argv_find(argv
, argc
, "(1-65535)", &idx
)
8119 argv_find(argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
8120 return ospf_vty_dead_interval_set(vty
, interval
, ifaddr
, NULL
);
8124 DEFUN_HIDDEN (ospf_dead_interval
,
8125 ospf_dead_interval_cmd
,
8126 "ospf dead-interval (1-65535) [A.B.C.D]",
8127 "OSPF interface commands\n"
8128 "Interval time after which a neighbor is declared down\n"
8130 "Address of interface\n")
8132 return ip_ospf_dead_interval(self
, vty
, argc
, argv
);
8135 DEFUN (ip_ospf_dead_interval_minimal
,
8136 ip_ospf_dead_interval_minimal_addr_cmd
,
8137 "ip ospf dead-interval minimal hello-multiplier (1-10) [A.B.C.D]",
8139 "OSPF interface commands\n"
8140 "Interval time after which a neighbor is declared down\n"
8141 "Minimal 1s dead-interval with fast sub-second hellos\n"
8142 "Hello multiplier factor\n"
8143 "Number of Hellos to send each second\n"
8144 "Address of interface\n")
8149 return ospf_vty_dead_interval_set(
8150 vty
, NULL
, argv
[idx_ipv4
]->arg
, argv
[idx_number
]->arg
);
8152 return ospf_vty_dead_interval_set(vty
, NULL
, NULL
,
8153 argv
[idx_number
]->arg
);
8156 DEFUN (no_ip_ospf_dead_interval
,
8157 no_ip_ospf_dead_interval_cmd
,
8158 "no ip ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
8161 "OSPF interface commands\n"
8162 "Interval time after which a neighbor is declared down\n"
8164 "Minimal 1s dead-interval with fast sub-second hellos\n"
8165 "Hello multiplier factor\n"
8166 "Number of Hellos to send each second\n"
8167 "Address of interface\n")
8169 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8170 int idx_ipv4
= argc
- 1;
8171 struct in_addr addr
= {.s_addr
= 0L};
8173 struct ospf_if_params
*params
;
8174 struct ospf_interface
*oi
;
8175 struct route_node
*rn
;
8177 params
= IF_DEF_PARAMS(ifp
);
8179 if (argv
[idx_ipv4
]->type
== IPV4_TKN
) {
8180 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
8183 "Please specify interface address by A.B.C.D\n");
8184 return CMD_WARNING_CONFIG_FAILED
;
8187 params
= ospf_lookup_if_params(ifp
, addr
);
8192 UNSET_IF_PARAM(params
, v_wait
);
8193 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
8194 params
->is_v_wait_set
= false;
8196 UNSET_IF_PARAM(params
, fast_hello
);
8197 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
8199 if (params
!= IF_DEF_PARAMS(ifp
)) {
8200 ospf_free_if_params(ifp
, addr
);
8201 ospf_if_update_params(ifp
, addr
);
8204 /* Update timer values in neighbor structure. */
8206 struct ospf
*ospf
= NULL
;
8208 ospf
= ifp
->vrf
->info
;
8210 oi
= ospf_if_lookup_by_local_addr(ospf
, ifp
, addr
);
8212 ospf_nbr_timer_update(oi
);
8215 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
))
8216 if ((oi
= rn
->info
))
8217 ospf_nbr_timer_update(oi
);
8223 DEFUN_HIDDEN (no_ospf_dead_interval
,
8224 no_ospf_dead_interval_cmd
,
8225 "no ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
8227 "OSPF interface commands\n"
8228 "Interval time after which a neighbor is declared down\n"
8230 "Minimal 1s dead-interval with fast sub-second hellos\n"
8231 "Hello multiplier factor\n"
8232 "Number of Hellos to send each second\n"
8233 "Address of interface\n")
8235 return no_ip_ospf_dead_interval(self
, vty
, argc
, argv
);
8238 DEFUN (ip_ospf_hello_interval
,
8239 ip_ospf_hello_interval_cmd
,
8240 "ip ospf hello-interval (1-65535) [A.B.C.D]",
8242 "OSPF interface commands\n"
8243 "Time between HELLO packets\n"
8245 "Address of interface\n")
8247 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8249 struct in_addr addr
= {.s_addr
= 0L};
8250 struct ospf_if_params
*params
;
8251 params
= IF_DEF_PARAMS(ifp
);
8252 uint32_t seconds
= 0;
8253 bool is_addr
= false;
8254 uint32_t old_interval
= 0;
8256 argv_find(argv
, argc
, "(1-65535)", &idx
);
8257 seconds
= strtol(argv
[idx
]->arg
, NULL
, 10);
8259 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
8260 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
8262 "Please specify interface address by A.B.C.D\n");
8263 return CMD_WARNING_CONFIG_FAILED
;
8266 params
= ospf_get_if_params(ifp
, addr
);
8267 ospf_if_update_params(ifp
, addr
);
8271 old_interval
= params
->v_hello
;
8273 /* Return, if same interval is configured. */
8274 if (old_interval
== seconds
)
8277 SET_IF_PARAM(params
, v_hello
);
8278 params
->v_hello
= seconds
;
8280 if (!params
->is_v_wait_set
) {
8281 SET_IF_PARAM(params
, v_wait
);
8283 * The router dead interval should
8284 * be some multiple of the HelloInterval (perhaps 4 times the
8285 * hello interval) and must be the same for all routers
8286 * attached to a common network.
8288 params
->v_wait
= 4 * seconds
;
8291 ospf_reset_hello_timer(ifp
, addr
, is_addr
);
8296 DEFUN_HIDDEN (ospf_hello_interval
,
8297 ospf_hello_interval_cmd
,
8298 "ospf hello-interval (1-65535) [A.B.C.D]",
8299 "OSPF interface commands\n"
8300 "Time between HELLO packets\n"
8302 "Address of interface\n")
8304 return ip_ospf_hello_interval(self
, vty
, argc
, argv
);
8307 DEFUN (no_ip_ospf_hello_interval
,
8308 no_ip_ospf_hello_interval_cmd
,
8309 "no ip ospf hello-interval [(1-65535) [A.B.C.D]]",
8312 "OSPF interface commands\n"
8313 "Time between HELLO packets\n" // ignored
8315 "Address of interface\n")
8317 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8319 struct in_addr addr
= {.s_addr
= 0L};
8320 struct ospf_if_params
*params
;
8321 struct route_node
*rn
;
8323 params
= IF_DEF_PARAMS(ifp
);
8325 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
8326 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
8328 "Please specify interface address by A.B.C.D\n");
8329 return CMD_WARNING_CONFIG_FAILED
;
8332 params
= ospf_lookup_if_params(ifp
, addr
);
8337 UNSET_IF_PARAM(params
, v_hello
);
8338 params
->v_hello
= OSPF_HELLO_INTERVAL_DEFAULT
;
8340 if (!params
->is_v_wait_set
) {
8341 UNSET_IF_PARAM(params
, v_wait
);
8342 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
8345 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
8346 struct ospf_interface
*oi
= rn
->info
;
8351 oi
->type
= IF_DEF_PARAMS(ifp
)->type
;
8352 oi
->ptp_dmvpn
= IF_DEF_PARAMS(ifp
)->ptp_dmvpn
;
8354 if (oi
->state
> ISM_Down
) {
8355 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceDown
);
8356 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceUp
);
8360 if (params
!= IF_DEF_PARAMS(ifp
)) {
8361 ospf_free_if_params(ifp
, addr
);
8362 ospf_if_update_params(ifp
, addr
);
8368 DEFUN_HIDDEN (no_ospf_hello_interval
,
8369 no_ospf_hello_interval_cmd
,
8370 "no ospf hello-interval [(1-65535) [A.B.C.D]]",
8372 "OSPF interface commands\n"
8373 "Time between HELLO packets\n" // ignored
8375 "Address of interface\n")
8377 return no_ip_ospf_hello_interval(self
, vty
, argc
, argv
);
8380 DEFUN(ip_ospf_network
, ip_ospf_network_cmd
,
8381 "ip ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point [dmvpn]>",
8383 "OSPF interface commands\n"
8385 "Specify OSPF broadcast multi-access network\n"
8386 "Specify OSPF NBMA network\n"
8387 "Specify OSPF point-to-multipoint network\n"
8388 "Specify OSPF point-to-point network\n"
8389 "Specify OSPF point-to-point DMVPN network\n")
8391 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8393 int old_type
= IF_DEF_PARAMS(ifp
)->type
;
8394 uint8_t old_ptp_dmvpn
= IF_DEF_PARAMS(ifp
)->ptp_dmvpn
;
8395 struct route_node
*rn
;
8397 if (old_type
== OSPF_IFTYPE_LOOPBACK
) {
8399 "This is a loopback interface. Can't set network type.\n");
8400 return CMD_WARNING_CONFIG_FAILED
;
8403 IF_DEF_PARAMS(ifp
)->ptp_dmvpn
= 0;
8405 if (argv_find(argv
, argc
, "broadcast", &idx
))
8406 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_BROADCAST
;
8407 else if (argv_find(argv
, argc
, "non-broadcast", &idx
))
8408 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_NBMA
;
8409 else if (argv_find(argv
, argc
, "point-to-multipoint", &idx
))
8410 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_POINTOMULTIPOINT
;
8411 else if (argv_find(argv
, argc
, "point-to-point", &idx
)) {
8412 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_POINTOPOINT
;
8413 if (argv_find(argv
, argc
, "dmvpn", &idx
))
8414 IF_DEF_PARAMS(ifp
)->ptp_dmvpn
= 1;
8417 if (IF_DEF_PARAMS(ifp
)->type
== old_type
8418 && IF_DEF_PARAMS(ifp
)->ptp_dmvpn
== old_ptp_dmvpn
)
8421 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), type
);
8423 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
8424 struct ospf_interface
*oi
= rn
->info
;
8429 oi
->type
= IF_DEF_PARAMS(ifp
)->type
;
8431 if (oi
->state
> ISM_Down
) {
8432 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceDown
);
8433 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceUp
);
8440 DEFUN_HIDDEN (ospf_network
,
8442 "ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
8443 "OSPF interface commands\n"
8445 "Specify OSPF broadcast multi-access network\n"
8446 "Specify OSPF NBMA network\n"
8447 "Specify OSPF point-to-multipoint network\n"
8448 "Specify OSPF point-to-point network\n")
8450 return ip_ospf_network(self
, vty
, argc
, argv
);
8453 DEFUN (no_ip_ospf_network
,
8454 no_ip_ospf_network_cmd
,
8455 "no ip ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
8458 "OSPF interface commands\n"
8460 "Specify OSPF broadcast multi-access network\n"
8461 "Specify OSPF NBMA network\n"
8462 "Specify OSPF point-to-multipoint network\n"
8463 "Specify OSPF point-to-point network\n")
8465 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8466 int old_type
= IF_DEF_PARAMS(ifp
)->type
;
8467 struct route_node
*rn
;
8469 IF_DEF_PARAMS(ifp
)->type
= ospf_default_iftype(ifp
);
8470 IF_DEF_PARAMS(ifp
)->ptp_dmvpn
= 0;
8472 if (IF_DEF_PARAMS(ifp
)->type
== old_type
)
8475 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
8476 struct ospf_interface
*oi
= rn
->info
;
8481 oi
->type
= IF_DEF_PARAMS(ifp
)->type
;
8483 if (oi
->state
> ISM_Down
) {
8484 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceDown
);
8485 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceUp
);
8492 DEFUN_HIDDEN (no_ospf_network
,
8493 no_ospf_network_cmd
,
8494 "no ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
8496 "OSPF interface commands\n"
8498 "Specify OSPF broadcast multi-access network\n"
8499 "Specify OSPF NBMA network\n"
8500 "Specify OSPF point-to-multipoint network\n"
8501 "Specify OSPF point-to-point network\n")
8503 return no_ip_ospf_network(self
, vty
, argc
, argv
);
8506 DEFUN (ip_ospf_priority
,
8507 ip_ospf_priority_cmd
,
8508 "ip ospf priority (0-255) [A.B.C.D]",
8510 "OSPF interface commands\n"
8513 "Address of interface\n")
8515 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8518 struct route_node
*rn
;
8519 struct in_addr addr
;
8520 struct ospf_if_params
*params
;
8521 params
= IF_DEF_PARAMS(ifp
);
8523 argv_find(argv
, argc
, "(0-255)", &idx
);
8524 priority
= strtol(argv
[idx
]->arg
, NULL
, 10);
8526 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
8527 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
8529 "Please specify interface address by A.B.C.D\n");
8530 return CMD_WARNING_CONFIG_FAILED
;
8533 params
= ospf_get_if_params(ifp
, addr
);
8534 ospf_if_update_params(ifp
, addr
);
8537 SET_IF_PARAM(params
, priority
);
8538 params
->priority
= priority
;
8540 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
8541 struct ospf_interface
*oi
= rn
->info
;
8546 if (PRIORITY(oi
) != OSPF_IF_PARAM(oi
, priority
)) {
8547 PRIORITY(oi
) = OSPF_IF_PARAM(oi
, priority
);
8548 OSPF_ISM_EVENT_SCHEDULE(oi
, ISM_NeighborChange
);
8555 DEFUN_HIDDEN (ospf_priority
,
8557 "ospf priority (0-255) [A.B.C.D]",
8558 "OSPF interface commands\n"
8561 "Address of interface\n")
8563 return ip_ospf_priority(self
, vty
, argc
, argv
);
8566 DEFUN (no_ip_ospf_priority
,
8567 no_ip_ospf_priority_cmd
,
8568 "no ip ospf priority [(0-255) [A.B.C.D]]",
8571 "OSPF interface commands\n"
8572 "Router priority\n" // ignored
8574 "Address of interface\n")
8576 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8578 struct route_node
*rn
;
8579 struct in_addr addr
;
8580 struct ospf_if_params
*params
;
8582 params
= IF_DEF_PARAMS(ifp
);
8584 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
8585 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
8587 "Please specify interface address by A.B.C.D\n");
8588 return CMD_WARNING_CONFIG_FAILED
;
8591 params
= ospf_lookup_if_params(ifp
, addr
);
8596 UNSET_IF_PARAM(params
, priority
);
8597 params
->priority
= OSPF_ROUTER_PRIORITY_DEFAULT
;
8599 if (params
!= IF_DEF_PARAMS(ifp
)) {
8600 ospf_free_if_params(ifp
, addr
);
8601 ospf_if_update_params(ifp
, addr
);
8604 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
8605 struct ospf_interface
*oi
= rn
->info
;
8610 if (PRIORITY(oi
) != OSPF_IF_PARAM(oi
, priority
)) {
8611 PRIORITY(oi
) = OSPF_IF_PARAM(oi
, priority
);
8612 OSPF_ISM_EVENT_SCHEDULE(oi
, ISM_NeighborChange
);
8619 DEFUN_HIDDEN (no_ospf_priority
,
8620 no_ospf_priority_cmd
,
8621 "no ospf priority [(0-255) [A.B.C.D]]",
8623 "OSPF interface commands\n"
8626 "Address of interface\n")
8628 return no_ip_ospf_priority(self
, vty
, argc
, argv
);
8631 DEFUN (ip_ospf_retransmit_interval
,
8632 ip_ospf_retransmit_interval_addr_cmd
,
8633 "ip ospf retransmit-interval (1-65535) [A.B.C.D]",
8635 "OSPF interface commands\n"
8636 "Time between retransmitting lost link state advertisements\n"
8638 "Address of interface\n")
8640 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8643 struct in_addr addr
;
8644 struct ospf_if_params
*params
;
8645 params
= IF_DEF_PARAMS(ifp
);
8647 argv_find(argv
, argc
, "(1-65535)", &idx
);
8648 seconds
= strtol(argv
[idx
]->arg
, NULL
, 10);
8650 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
8651 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
8653 "Please specify interface address by A.B.C.D\n");
8654 return CMD_WARNING_CONFIG_FAILED
;
8657 params
= ospf_get_if_params(ifp
, addr
);
8658 ospf_if_update_params(ifp
, addr
);
8661 SET_IF_PARAM(params
, retransmit_interval
);
8662 params
->retransmit_interval
= seconds
;
8667 DEFUN_HIDDEN (ospf_retransmit_interval
,
8668 ospf_retransmit_interval_cmd
,
8669 "ospf retransmit-interval (1-65535) [A.B.C.D]",
8670 "OSPF interface commands\n"
8671 "Time between retransmitting lost link state advertisements\n"
8673 "Address of interface\n")
8675 return ip_ospf_retransmit_interval(self
, vty
, argc
, argv
);
8678 DEFUN (no_ip_ospf_retransmit_interval
,
8679 no_ip_ospf_retransmit_interval_addr_cmd
,
8680 "no ip ospf retransmit-interval [(1-65535)] [A.B.C.D]",
8683 "OSPF interface commands\n"
8684 "Time between retransmitting lost link state advertisements\n"
8686 "Address of interface\n")
8688 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8690 struct in_addr addr
;
8691 struct ospf_if_params
*params
;
8693 params
= IF_DEF_PARAMS(ifp
);
8695 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
8696 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
8698 "Please specify interface address by A.B.C.D\n");
8699 return CMD_WARNING_CONFIG_FAILED
;
8702 params
= ospf_lookup_if_params(ifp
, addr
);
8707 UNSET_IF_PARAM(params
, retransmit_interval
);
8708 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
8710 if (params
!= IF_DEF_PARAMS(ifp
)) {
8711 ospf_free_if_params(ifp
, addr
);
8712 ospf_if_update_params(ifp
, addr
);
8718 DEFUN_HIDDEN (no_ospf_retransmit_interval
,
8719 no_ospf_retransmit_interval_cmd
,
8720 "no ospf retransmit-interval [(1-65535)] [A.B.C.D]",
8722 "OSPF interface commands\n"
8723 "Time between retransmitting lost link state advertisements\n"
8725 "Address of interface\n")
8727 return no_ip_ospf_retransmit_interval(self
, vty
, argc
, argv
);
8730 DEFUN (ip_ospf_transmit_delay
,
8731 ip_ospf_transmit_delay_addr_cmd
,
8732 "ip ospf transmit-delay (1-65535) [A.B.C.D]",
8734 "OSPF interface commands\n"
8735 "Link state transmit delay\n"
8737 "Address of interface\n")
8739 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8742 struct in_addr addr
;
8743 struct ospf_if_params
*params
;
8745 params
= IF_DEF_PARAMS(ifp
);
8746 argv_find(argv
, argc
, "(1-65535)", &idx
);
8747 seconds
= strtol(argv
[idx
]->arg
, NULL
, 10);
8749 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
8750 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
8752 "Please specify interface address by A.B.C.D\n");
8753 return CMD_WARNING_CONFIG_FAILED
;
8756 params
= ospf_get_if_params(ifp
, addr
);
8757 ospf_if_update_params(ifp
, addr
);
8760 SET_IF_PARAM(params
, transmit_delay
);
8761 params
->transmit_delay
= seconds
;
8766 DEFUN_HIDDEN (ospf_transmit_delay
,
8767 ospf_transmit_delay_cmd
,
8768 "ospf transmit-delay (1-65535) [A.B.C.D]",
8769 "OSPF interface commands\n"
8770 "Link state transmit delay\n"
8772 "Address of interface\n")
8774 return ip_ospf_transmit_delay(self
, vty
, argc
, argv
);
8777 DEFUN (no_ip_ospf_transmit_delay
,
8778 no_ip_ospf_transmit_delay_addr_cmd
,
8779 "no ip ospf transmit-delay [(1-65535)] [A.B.C.D]",
8782 "OSPF interface commands\n"
8783 "Link state transmit delay\n"
8785 "Address of interface\n")
8787 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8789 struct in_addr addr
;
8790 struct ospf_if_params
*params
;
8792 params
= IF_DEF_PARAMS(ifp
);
8794 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
8795 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
8797 "Please specify interface address by A.B.C.D\n");
8798 return CMD_WARNING_CONFIG_FAILED
;
8801 params
= ospf_lookup_if_params(ifp
, addr
);
8806 UNSET_IF_PARAM(params
, transmit_delay
);
8807 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
8809 if (params
!= IF_DEF_PARAMS(ifp
)) {
8810 ospf_free_if_params(ifp
, addr
);
8811 ospf_if_update_params(ifp
, addr
);
8818 DEFUN_HIDDEN (no_ospf_transmit_delay
,
8819 no_ospf_transmit_delay_cmd
,
8820 "no ospf transmit-delay [(1-65535) [A.B.C.D]]",
8822 "OSPF interface commands\n"
8823 "Link state transmit delay\n"
8825 "Address of interface\n")
8827 return no_ip_ospf_transmit_delay(self
, vty
, argc
, argv
);
8830 DEFUN (ip_ospf_area
,
8832 "ip ospf [(1-65535)] area <A.B.C.D|(0-4294967295)> [A.B.C.D]",
8834 "OSPF interface commands\n"
8836 "Enable OSPF on this interface\n"
8837 "OSPF area ID in IP address format\n"
8838 "OSPF area ID as a decimal value\n"
8839 "Address of interface\n")
8841 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8844 struct in_addr area_id
;
8845 struct in_addr addr
;
8846 struct ospf_if_params
*params
= NULL
;
8847 struct route_node
*rn
;
8848 struct ospf
*ospf
= NULL
;
8849 unsigned short instance
= 0;
8853 if (argv_find(argv
, argc
, "(1-65535)", &idx
))
8854 instance
= strtol(argv
[idx
]->arg
, NULL
, 10);
8856 argv_find(argv
, argc
, "area", &idx
);
8857 areaid
= argv
[idx
+ 1]->arg
;
8860 ospf
= ifp
->vrf
->info
;
8862 ospf
= ospf_lookup_instance(instance
);
8864 if (instance
&& instance
!= ospf_instance
) {
8866 * At this point we know we have received
8867 * an instance and there is no ospf instance
8868 * associated with it. This means we are
8869 * in a situation where we have an
8870 * ospf command that is setup for a different
8871 * process(instance). We need to safely
8872 * remove the command from ourselves and
8873 * allow the other instance(process) handle
8874 * the configuration command.
8878 params
= IF_DEF_PARAMS(ifp
);
8879 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
8880 UNSET_IF_PARAM(params
, if_area
);
8884 for (rn
= route_top(IF_OIFS_PARAMS(ifp
)); rn
; rn
= route_next(rn
))
8885 if ((params
= rn
->info
) && OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
8886 UNSET_IF_PARAM(params
, if_area
);
8891 ospf
= ifp
->vrf
->info
;
8893 ospf_interface_area_unset(ospf
, ifp
);
8896 return CMD_NOT_MY_INSTANCE
;
8899 ret
= str2area_id(areaid
, &area_id
, &format
);
8901 vty_out(vty
, "Please specify area by A.B.C.D|<0-4294967295>\n");
8902 return CMD_WARNING_CONFIG_FAILED
;
8904 if (memcmp(ifp
->name
, "VLINK", 5) == 0) {
8905 vty_out(vty
, "Cannot enable OSPF on a virtual link.\n");
8906 return CMD_WARNING_CONFIG_FAILED
;
8910 for (rn
= route_top(ospf
->networks
); rn
; rn
= route_next(rn
)) {
8911 if (rn
->info
!= NULL
) {
8913 "Please remove all network commands first.\n");
8914 return CMD_WARNING_CONFIG_FAILED
;
8919 params
= IF_DEF_PARAMS(ifp
);
8920 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)
8921 && !IPV4_ADDR_SAME(¶ms
->if_area
, &area_id
)) {
8923 "Must remove previous area config before changing ospf area \n");
8924 return CMD_WARNING_CONFIG_FAILED
;
8927 // Check if we have an address arg and proccess it
8928 if (argc
== idx
+ 3) {
8929 if (!inet_aton(argv
[idx
+ 2]->arg
, &addr
)) {
8931 "Please specify Intf Address by A.B.C.D\n");
8932 return CMD_WARNING_CONFIG_FAILED
;
8934 // update/create address-level params
8935 params
= ospf_get_if_params((ifp
), (addr
));
8936 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
8937 if (!IPV4_ADDR_SAME(¶ms
->if_area
, &area_id
)) {
8939 "Must remove previous area/address config before changing ospf area\n");
8940 return CMD_WARNING_CONFIG_FAILED
;
8944 ospf_if_update_params((ifp
), (addr
));
8947 /* enable ospf on this interface with area_id */
8949 SET_IF_PARAM(params
, if_area
);
8950 params
->if_area
= area_id
;
8951 params
->if_area_id_fmt
= format
;
8955 ospf_interface_area_set(ospf
, ifp
);
8960 DEFUN (no_ip_ospf_area
,
8961 no_ip_ospf_area_cmd
,
8962 "no ip ospf [(1-65535)] area [<A.B.C.D|(0-4294967295)> [A.B.C.D]]",
8965 "OSPF interface commands\n"
8967 "Disable OSPF on this interface\n"
8968 "OSPF area ID in IP address format\n"
8969 "OSPF area ID as a decimal value\n"
8970 "Address of interface\n")
8972 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8975 struct ospf_if_params
*params
;
8976 unsigned short instance
= 0;
8977 struct in_addr addr
;
8978 struct in_addr area_id
;
8980 if (argv_find(argv
, argc
, "(1-65535)", &idx
))
8981 instance
= strtol(argv
[idx
]->arg
, NULL
, 10);
8984 ospf
= ifp
->vrf
->info
;
8986 ospf
= ospf_lookup_instance(instance
);
8988 if (instance
&& instance
!= ospf_instance
)
8989 return CMD_NOT_MY_INSTANCE
;
8991 argv_find(argv
, argc
, "area", &idx
);
8993 // Check if we have an address arg and proccess it
8994 if (argc
== idx
+ 3) {
8995 if (!inet_aton(argv
[idx
+ 2]->arg
, &addr
)) {
8997 "Please specify Intf Address by A.B.C.D\n");
8998 return CMD_WARNING_CONFIG_FAILED
;
9000 params
= ospf_lookup_if_params(ifp
, addr
);
9001 if ((params
) == NULL
)
9004 params
= IF_DEF_PARAMS(ifp
);
9006 area_id
= params
->if_area
;
9007 if (!OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
9009 "Can't find specified interface area configuration.\n");
9010 return CMD_WARNING_CONFIG_FAILED
;
9013 UNSET_IF_PARAM(params
, if_area
);
9014 if (params
!= IF_DEF_PARAMS((ifp
))) {
9015 ospf_free_if_params((ifp
), (addr
));
9016 ospf_if_update_params((ifp
), (addr
));
9020 ospf_interface_area_unset(ospf
, ifp
);
9021 ospf_area_check_free(ospf
, area_id
);
9027 DEFUN (ip_ospf_passive
,
9028 ip_ospf_passive_cmd
,
9029 "ip ospf passive [A.B.C.D]",
9031 "OSPF interface commands\n"
9032 "Suppress routing updates on an interface\n"
9033 "Address of interface\n")
9035 VTY_DECLVAR_CONTEXT(interface
, ifp
);
9037 struct in_addr addr
= {.s_addr
= INADDR_ANY
};
9038 struct ospf_if_params
*params
;
9042 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
9045 "Please specify interface address by A.B.C.D\n");
9046 return CMD_WARNING_CONFIG_FAILED
;
9048 params
= ospf_get_if_params(ifp
, addr
);
9049 ospf_if_update_params(ifp
, addr
);
9051 params
= IF_DEF_PARAMS(ifp
);
9054 ospf_passive_interface_update(ifp
, params
, addr
, OSPF_IF_PASSIVE
);
9059 DEFUN (no_ip_ospf_passive
,
9060 no_ip_ospf_passive_cmd
,
9061 "no ip ospf passive [A.B.C.D]",
9064 "OSPF interface commands\n"
9065 "Enable routing updates on an interface\n"
9066 "Address of interface\n")
9068 VTY_DECLVAR_CONTEXT(interface
, ifp
);
9070 struct in_addr addr
= {.s_addr
= INADDR_ANY
};
9071 struct ospf_if_params
*params
;
9075 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
9078 "Please specify interface address by A.B.C.D\n");
9079 return CMD_WARNING_CONFIG_FAILED
;
9081 params
= ospf_lookup_if_params(ifp
, addr
);
9085 params
= IF_DEF_PARAMS(ifp
);
9088 ospf_passive_interface_update(ifp
, params
, addr
, OSPF_IF_ACTIVE
);
9093 DEFUN (ospf_redistribute_source
,
9094 ospf_redistribute_source_cmd
,
9095 "redistribute " FRR_REDIST_STR_OSPFD
" [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
9097 FRR_REDIST_HELP_STR_OSPFD
9098 "Metric for redistributed routes\n"
9099 "OSPF default metric\n"
9100 "OSPF exterior metric type for redistributed routes\n"
9101 "Set OSPF External Type 1/2 metrics\n"
9102 "Route map reference\n"
9103 "Pointer to route-map entries\n")
9105 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9106 int idx_protocol
= 1;
9110 struct ospf_redist
*red
;
9112 bool update
= false;
9114 /* Get distribute source. */
9115 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
9117 return CMD_WARNING_CONFIG_FAILED
;
9119 /* Get metric value. */
9120 if (argv_find(argv
, argc
, "(0-16777214)", &idx
)) {
9121 if (!str2metric(argv
[idx
]->arg
, &metric
))
9122 return CMD_WARNING_CONFIG_FAILED
;
9125 /* Get metric type. */
9126 if (argv_find(argv
, argc
, "(1-2)", &idx
)) {
9127 if (!str2metric_type(argv
[idx
]->arg
, &type
))
9128 return CMD_WARNING_CONFIG_FAILED
;
9132 red
= ospf_redist_lookup(ospf
, source
, 0);
9134 red
= ospf_redist_add(ospf
, source
, 0);
9139 if (argv_find(argv
, argc
, "WORD", &idx
)) {
9140 ospf_routemap_set(red
, argv
[idx
]->arg
);
9142 ospf_routemap_unset(red
);
9145 return ospf_redistribute_update(ospf
, red
, source
, 0, type
,
9148 return ospf_redistribute_set(ospf
, red
, source
, 0, type
,
9152 DEFUN (no_ospf_redistribute_source
,
9153 no_ospf_redistribute_source_cmd
,
9154 "no redistribute " FRR_REDIST_STR_OSPFD
" [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
9157 FRR_REDIST_HELP_STR_OSPFD
9158 "Metric for redistributed routes\n"
9159 "OSPF default metric\n"
9160 "OSPF exterior metric type for redistributed routes\n"
9161 "Set OSPF External Type 1/2 metrics\n"
9162 "Route map reference\n"
9163 "Pointer to route-map entries\n")
9165 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9166 int idx_protocol
= 2;
9168 struct ospf_redist
*red
;
9170 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
9172 return CMD_WARNING_CONFIG_FAILED
;
9174 red
= ospf_redist_lookup(ospf
, source
, 0);
9178 ospf_routemap_unset(red
);
9179 ospf_redist_del(ospf
, source
, 0);
9181 return ospf_redistribute_unset(ospf
, source
, 0);
9184 DEFUN (ospf_redistribute_instance_source
,
9185 ospf_redistribute_instance_source_cmd
,
9186 "redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
9188 "Open Shortest Path First\n"
9189 "Non-main Kernel Routing Table\n"
9190 "Instance ID/Table ID\n"
9191 "Metric for redistributed routes\n"
9192 "OSPF default metric\n"
9193 "OSPF exterior metric type for redistributed routes\n"
9194 "Set OSPF External Type 1/2 metrics\n"
9195 "Route map reference\n"
9196 "Pointer to route-map entries\n")
9198 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9199 int idx_ospf_table
= 1;
9205 unsigned short instance
;
9206 struct ospf_redist
*red
;
9207 bool update
= false;
9209 source
= proto_redistnum(AFI_IP
, argv
[idx_ospf_table
]->text
);
9212 vty_out(vty
, "Unknown instance redistribution\n");
9213 return CMD_WARNING_CONFIG_FAILED
;
9216 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
9218 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
) {
9220 "Instance redistribution in non-instanced OSPF not allowed\n");
9221 return CMD_WARNING_CONFIG_FAILED
;
9224 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
)) {
9225 vty_out(vty
, "Same instance OSPF redistribution not allowed\n");
9226 return CMD_WARNING_CONFIG_FAILED
;
9229 /* Get metric value. */
9230 if (argv_find(argv
, argc
, "metric", &idx
))
9231 if (!str2metric(argv
[idx
+ 1]->arg
, &metric
))
9232 return CMD_WARNING_CONFIG_FAILED
;
9235 /* Get metric type. */
9236 if (argv_find(argv
, argc
, "metric-type", &idx
))
9237 if (!str2metric_type(argv
[idx
+ 1]->arg
, &type
))
9238 return CMD_WARNING_CONFIG_FAILED
;
9240 red
= ospf_redist_lookup(ospf
, source
, instance
);
9242 red
= ospf_redist_add(ospf
, source
, instance
);
9247 if (argv_find(argv
, argc
, "route-map", &idx
))
9248 ospf_routemap_set(red
, argv
[idx
+ 1]->arg
);
9250 ospf_routemap_unset(red
);
9253 return ospf_redistribute_update(ospf
, red
, source
, instance
,
9256 return ospf_redistribute_set(ospf
, red
, source
, instance
, type
,
9260 DEFUN (no_ospf_redistribute_instance_source
,
9261 no_ospf_redistribute_instance_source_cmd
,
9262 "no redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
9265 "Open Shortest Path First\n"
9266 "Non-main Kernel Routing Table\n"
9267 "Instance ID/Table Id\n"
9268 "Metric for redistributed routes\n"
9269 "OSPF default metric\n"
9270 "OSPF exterior metric type for redistributed routes\n"
9271 "Set OSPF External Type 1/2 metrics\n"
9272 "Route map reference\n"
9273 "Pointer to route-map entries\n")
9275 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9276 int idx_ospf_table
= 2;
9278 unsigned int instance
;
9279 struct ospf_redist
*red
;
9282 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
9283 source
= ZEBRA_ROUTE_OSPF
;
9285 source
= ZEBRA_ROUTE_TABLE
;
9287 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
9289 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
) {
9291 "Instance redistribution in non-instanced OSPF not allowed\n");
9292 return CMD_WARNING_CONFIG_FAILED
;
9295 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
)) {
9296 vty_out(vty
, "Same instance OSPF redistribution not allowed\n");
9297 return CMD_WARNING_CONFIG_FAILED
;
9300 red
= ospf_redist_lookup(ospf
, source
, instance
);
9304 ospf_routemap_unset(red
);
9305 ospf_redist_del(ospf
, source
, instance
);
9307 return ospf_redistribute_unset(ospf
, source
, instance
);
9310 DEFUN (ospf_distribute_list_out
,
9311 ospf_distribute_list_out_cmd
,
9312 "distribute-list ACCESSLIST4_NAME out " FRR_REDIST_STR_OSPFD
,
9313 "Filter networks in routing updates\n"
9314 "Access-list name\n"
9316 FRR_REDIST_HELP_STR_OSPFD
)
9318 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9322 char *proto
= argv
[argc
- 1]->text
;
9324 /* Get distribute source. */
9325 source
= proto_redistnum(AFI_IP
, proto
);
9327 return CMD_WARNING_CONFIG_FAILED
;
9329 return ospf_distribute_list_out_set(ospf
, source
, argv
[idx_word
]->arg
);
9332 DEFUN (no_ospf_distribute_list_out
,
9333 no_ospf_distribute_list_out_cmd
,
9334 "no distribute-list ACCESSLIST4_NAME out " FRR_REDIST_STR_OSPFD
,
9336 "Filter networks in routing updates\n"
9337 "Access-list name\n"
9339 FRR_REDIST_HELP_STR_OSPFD
)
9341 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9345 char *proto
= argv
[argc
- 1]->text
;
9346 source
= proto_redistnum(AFI_IP
, proto
);
9348 return CMD_WARNING_CONFIG_FAILED
;
9350 return ospf_distribute_list_out_unset(ospf
, source
,
9351 argv
[idx_word
]->arg
);
9354 /* Default information originate. */
9355 DEFUN (ospf_default_information_originate
,
9356 ospf_default_information_originate_cmd
,
9357 "default-information originate [{always|metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
9358 "Control distribution of default information\n"
9359 "Distribute a default route\n"
9360 "Always advertise default route\n"
9361 "OSPF default metric\n"
9363 "OSPF metric type for default routes\n"
9364 "Set OSPF External Type 1/2 metrics\n"
9365 "Route map reference\n"
9366 "Pointer to route-map entries\n")
9368 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9369 int default_originate
= DEFAULT_ORIGINATE_ZEBRA
;
9372 struct ospf_redist
*red
;
9374 int cur_originate
= ospf
->default_originate
;
9375 bool sameRtmap
= false;
9378 red
= ospf_redist_add(ospf
, DEFAULT_ROUTE
, 0);
9380 /* Check whether "always" was specified */
9381 if (argv_find(argv
, argc
, "always", &idx
))
9382 default_originate
= DEFAULT_ORIGINATE_ALWAYS
;
9384 /* Get metric value */
9385 if (argv_find(argv
, argc
, "(0-16777214)", &idx
)) {
9386 if (!str2metric(argv
[idx
]->arg
, &metric
))
9387 return CMD_WARNING_CONFIG_FAILED
;
9390 /* Get metric type. */
9391 if (argv_find(argv
, argc
, "(1-2)", &idx
)) {
9392 if (!str2metric_type(argv
[idx
]->arg
, &type
))
9393 return CMD_WARNING_CONFIG_FAILED
;
9397 if (argv_find(argv
, argc
, "WORD", &idx
))
9398 rtmap
= argv
[idx
]->arg
;
9400 /* To check if user is providing same route map */
9401 if ((!rtmap
&& !ROUTEMAP_NAME(red
)) ||
9402 (rtmap
&& ROUTEMAP_NAME(red
) &&
9403 (strcmp(rtmap
, ROUTEMAP_NAME(red
)) == 0)))
9406 /* Don't allow if the same lsa is already originated. */
9408 && (red
->dmetric
.type
== type
)
9409 && (red
->dmetric
.value
== metric
)
9410 && (cur_originate
== default_originate
))
9413 /* Updating Metric details */
9414 red
->dmetric
.type
= type
;
9415 red
->dmetric
.value
= metric
;
9417 /* updating route map details */
9419 ospf_routemap_set(red
, rtmap
);
9421 ospf_routemap_unset(red
);
9423 return ospf_redistribute_default_set(ospf
, default_originate
, type
,
9427 DEFUN (no_ospf_default_information_originate
,
9428 no_ospf_default_information_originate_cmd
,
9429 "no default-information originate [{always|metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
9431 "Control distribution of default information\n"
9432 "Distribute a default route\n"
9433 "Always advertise default route\n"
9434 "OSPF default metric\n"
9436 "OSPF metric type for default routes\n"
9437 "Set OSPF External Type 1/2 metrics\n"
9438 "Route map reference\n"
9439 "Pointer to route-map entries\n")
9441 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9442 struct ospf_redist
*red
;
9444 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
9448 ospf_routemap_unset(red
);
9449 ospf_redist_del(ospf
, DEFAULT_ROUTE
, 0);
9451 return ospf_redistribute_default_set(ospf
, DEFAULT_ORIGINATE_NONE
,
9455 DEFUN (ospf_default_metric
,
9456 ospf_default_metric_cmd
,
9457 "default-metric (0-16777214)",
9458 "Set metric of redistributed routes\n"
9461 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9465 if (!str2metric(argv
[idx_number
]->arg
, &metric
))
9466 return CMD_WARNING_CONFIG_FAILED
;
9468 ospf
->default_metric
= metric
;
9473 DEFUN (no_ospf_default_metric
,
9474 no_ospf_default_metric_cmd
,
9475 "no default-metric [(0-16777214)]",
9477 "Set metric of redistributed routes\n"
9480 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9482 ospf
->default_metric
= -1;
9488 DEFUN (ospf_distance
,
9491 "Administrative distance\n"
9492 "OSPF Administrative distance\n")
9494 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9498 distance
= atoi(argv
[idx_number
]->arg
);
9499 if (ospf
->distance_all
!= distance
) {
9500 ospf
->distance_all
= distance
;
9501 ospf_restart_spf(ospf
);
9507 DEFUN (no_ospf_distance
,
9508 no_ospf_distance_cmd
,
9509 "no distance (1-255)",
9511 "Administrative distance\n"
9512 "OSPF Administrative distance\n")
9514 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9516 if (ospf
->distance_all
) {
9517 ospf
->distance_all
= 0;
9518 ospf_restart_spf(ospf
);
9524 DEFUN (no_ospf_distance_ospf
,
9525 no_ospf_distance_ospf_cmd
,
9526 "no distance ospf [{intra-area [(1-255)]|inter-area [(1-255)]|external [(1-255)]}]",
9528 "Administrative distance\n"
9529 "OSPF administrative distance\n"
9530 "Intra-area routes\n"
9531 "Distance for intra-area routes\n"
9532 "Inter-area routes\n"
9533 "Distance for inter-area routes\n"
9535 "Distance for external routes\n")
9537 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9540 if (argv_find(argv
, argc
, "intra-area", &idx
) || argc
== 3)
9541 idx
= ospf
->distance_intra
= 0;
9542 if (argv_find(argv
, argc
, "inter-area", &idx
) || argc
== 3)
9543 idx
= ospf
->distance_inter
= 0;
9544 if (argv_find(argv
, argc
, "external", &idx
) || argc
== 3)
9545 ospf
->distance_external
= 0;
9550 DEFUN (ospf_distance_ospf
,
9551 ospf_distance_ospf_cmd
,
9552 "distance ospf {intra-area (1-255)|inter-area (1-255)|external (1-255)}",
9553 "Administrative distance\n"
9554 "OSPF administrative distance\n"
9555 "Intra-area routes\n"
9556 "Distance for intra-area routes\n"
9557 "Inter-area routes\n"
9558 "Distance for inter-area routes\n"
9560 "Distance for external routes\n")
9562 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9565 ospf
->distance_intra
= 0;
9566 ospf
->distance_inter
= 0;
9567 ospf
->distance_external
= 0;
9569 if (argv_find(argv
, argc
, "intra-area", &idx
))
9570 ospf
->distance_intra
= atoi(argv
[idx
+ 1]->arg
);
9572 if (argv_find(argv
, argc
, "inter-area", &idx
))
9573 ospf
->distance_inter
= atoi(argv
[idx
+ 1]->arg
);
9575 if (argv_find(argv
, argc
, "external", &idx
))
9576 ospf
->distance_external
= atoi(argv
[idx
+ 1]->arg
);
9581 DEFUN (ip_ospf_mtu_ignore
,
9582 ip_ospf_mtu_ignore_addr_cmd
,
9583 "ip ospf mtu-ignore [A.B.C.D]",
9585 "OSPF interface commands\n"
9586 "Disable MTU mismatch detection on this interface\n"
9587 "Address of interface\n")
9589 VTY_DECLVAR_CONTEXT(interface
, ifp
);
9591 struct in_addr addr
;
9594 struct ospf_if_params
*params
;
9595 params
= IF_DEF_PARAMS(ifp
);
9598 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
9601 "Please specify interface address by A.B.C.D\n");
9602 return CMD_WARNING_CONFIG_FAILED
;
9604 params
= ospf_get_if_params(ifp
, addr
);
9605 ospf_if_update_params(ifp
, addr
);
9607 params
->mtu_ignore
= 1;
9608 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
9609 SET_IF_PARAM(params
, mtu_ignore
);
9611 UNSET_IF_PARAM(params
, mtu_ignore
);
9612 if (params
!= IF_DEF_PARAMS(ifp
)) {
9613 ospf_free_if_params(ifp
, addr
);
9614 ospf_if_update_params(ifp
, addr
);
9620 DEFUN (no_ip_ospf_mtu_ignore
,
9621 no_ip_ospf_mtu_ignore_addr_cmd
,
9622 "no ip ospf mtu-ignore [A.B.C.D]",
9625 "OSPF interface commands\n"
9626 "Disable MTU mismatch detection on this interface\n"
9627 "Address of interface\n")
9629 VTY_DECLVAR_CONTEXT(interface
, ifp
);
9631 struct in_addr addr
;
9634 struct ospf_if_params
*params
;
9635 params
= IF_DEF_PARAMS(ifp
);
9638 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
9641 "Please specify interface address by A.B.C.D\n");
9642 return CMD_WARNING_CONFIG_FAILED
;
9644 params
= ospf_get_if_params(ifp
, addr
);
9645 ospf_if_update_params(ifp
, addr
);
9647 params
->mtu_ignore
= 0;
9648 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
9649 SET_IF_PARAM(params
, mtu_ignore
);
9651 UNSET_IF_PARAM(params
, mtu_ignore
);
9652 if (params
!= IF_DEF_PARAMS(ifp
)) {
9653 ospf_free_if_params(ifp
, addr
);
9654 ospf_if_update_params(ifp
, addr
);
9661 DEFUN (ospf_max_metric_router_lsa_admin
,
9662 ospf_max_metric_router_lsa_admin_cmd
,
9663 "max-metric router-lsa administrative",
9664 "OSPF maximum / infinite-distance metric\n"
9665 "Advertise own Router-LSA with infinite distance (stub router)\n"
9666 "Administratively applied, for an indefinite period\n")
9668 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9669 struct listnode
*ln
;
9670 struct ospf_area
*area
;
9672 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
9673 SET_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
9675 if (!CHECK_FLAG(area
->stub_router_state
,
9676 OSPF_AREA_IS_STUB_ROUTED
))
9677 ospf_router_lsa_update_area(area
);
9680 /* Allows for areas configured later to get the property */
9681 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_SET
;
9686 DEFUN (no_ospf_max_metric_router_lsa_admin
,
9687 no_ospf_max_metric_router_lsa_admin_cmd
,
9688 "no max-metric router-lsa administrative",
9690 "OSPF maximum / infinite-distance metric\n"
9691 "Advertise own Router-LSA with infinite distance (stub router)\n"
9692 "Administratively applied, for an indefinite period\n")
9694 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9695 struct listnode
*ln
;
9696 struct ospf_area
*area
;
9698 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
9699 UNSET_FLAG(area
->stub_router_state
,
9700 OSPF_AREA_ADMIN_STUB_ROUTED
);
9702 /* Don't trample on the start-up stub timer */
9703 if (CHECK_FLAG(area
->stub_router_state
,
9704 OSPF_AREA_IS_STUB_ROUTED
)
9705 && !area
->t_stub_router
) {
9706 UNSET_FLAG(area
->stub_router_state
,
9707 OSPF_AREA_IS_STUB_ROUTED
);
9708 ospf_router_lsa_update_area(area
);
9711 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET
;
9715 DEFUN (ospf_max_metric_router_lsa_startup
,
9716 ospf_max_metric_router_lsa_startup_cmd
,
9717 "max-metric router-lsa on-startup (5-86400)",
9718 "OSPF maximum / infinite-distance metric\n"
9719 "Advertise own Router-LSA with infinite distance (stub router)\n"
9720 "Automatically advertise stub Router-LSA on startup of OSPF\n"
9721 "Time (seconds) to advertise self as stub-router\n")
9723 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9725 unsigned int seconds
;
9728 vty_out(vty
, "%% Must supply stub-router period");
9729 return CMD_WARNING_CONFIG_FAILED
;
9732 seconds
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
9734 ospf
->stub_router_startup_time
= seconds
;
9739 DEFUN (no_ospf_max_metric_router_lsa_startup
,
9740 no_ospf_max_metric_router_lsa_startup_cmd
,
9741 "no max-metric router-lsa on-startup [(5-86400)]",
9743 "OSPF maximum / infinite-distance metric\n"
9744 "Advertise own Router-LSA with infinite distance (stub router)\n"
9745 "Automatically advertise stub Router-LSA on startup of OSPF\n"
9746 "Time (seconds) to advertise self as stub-router\n")
9748 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9749 struct listnode
*ln
;
9750 struct ospf_area
*area
;
9752 ospf
->stub_router_startup_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
9754 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
9755 SET_FLAG(area
->stub_router_state
,
9756 OSPF_AREA_WAS_START_STUB_ROUTED
);
9757 OSPF_TIMER_OFF(area
->t_stub_router
);
9759 /* Don't trample on admin stub routed */
9760 if (!CHECK_FLAG(area
->stub_router_state
,
9761 OSPF_AREA_ADMIN_STUB_ROUTED
)) {
9762 UNSET_FLAG(area
->stub_router_state
,
9763 OSPF_AREA_IS_STUB_ROUTED
);
9764 ospf_router_lsa_update_area(area
);
9771 DEFUN (ospf_max_metric_router_lsa_shutdown
,
9772 ospf_max_metric_router_lsa_shutdown_cmd
,
9773 "max-metric router-lsa on-shutdown (5-100)",
9774 "OSPF maximum / infinite-distance metric\n"
9775 "Advertise own Router-LSA with infinite distance (stub router)\n"
9776 "Advertise stub-router prior to full shutdown of OSPF\n"
9777 "Time (seconds) to wait till full shutdown\n")
9779 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9781 unsigned int seconds
;
9784 vty_out(vty
, "%% Must supply stub-router shutdown period");
9785 return CMD_WARNING_CONFIG_FAILED
;
9788 seconds
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
9790 ospf
->stub_router_shutdown_time
= seconds
;
9795 DEFUN (no_ospf_max_metric_router_lsa_shutdown
,
9796 no_ospf_max_metric_router_lsa_shutdown_cmd
,
9797 "no max-metric router-lsa on-shutdown [(5-100)]",
9799 "OSPF maximum / infinite-distance metric\n"
9800 "Advertise own Router-LSA with infinite distance (stub router)\n"
9801 "Advertise stub-router prior to full shutdown of OSPF\n"
9802 "Time (seconds) to wait till full shutdown\n")
9804 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9806 ospf
->stub_router_shutdown_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
9811 DEFUN (ospf_proactive_arp
,
9812 ospf_proactive_arp_cmd
,
9814 "Allow sending ARP requests proactively\n")
9816 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9818 ospf
->proactive_arp
= true;
9823 DEFUN (no_ospf_proactive_arp
,
9824 no_ospf_proactive_arp_cmd
,
9827 "Disallow sending ARP requests proactively\n")
9829 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9831 ospf
->proactive_arp
= false;
9836 /* Graceful Restart HELPER Commands */
9837 DEFPY(ospf_gr_helper_enable
, ospf_gr_helper_enable_cmd
,
9838 "graceful-restart helper enable [A.B.C.D$address]",
9839 "OSPF Graceful Restart\n"
9841 "Enable Helper support\n"
9842 "Advertising Router-ID\n")
9844 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9847 ospf_gr_helper_support_set_per_routerid(ospf
, &address
,
9852 ospf_gr_helper_support_set(ospf
, OSPF_GR_TRUE
);
9857 DEFPY(no_ospf_gr_helper_enable
,
9858 no_ospf_gr_helper_enable_cmd
,
9859 "no graceful-restart helper enable [A.B.C.D$address]",
9861 "OSPF Graceful Restart\n"
9863 "Enable Helper support\n"
9864 "Advertising Router-ID\n")
9866 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9869 ospf_gr_helper_support_set_per_routerid(ospf
, &address
,
9874 ospf_gr_helper_support_set(ospf
, OSPF_GR_FALSE
);
9878 #if CONFDATE > 20220921
9880 "Time to remove the deprecated \"[no] graceful-restart helper-only\" commands")
9883 DEFPY_HIDDEN(ospf_gr_helper_only
, ospf_gr_helper_only_cmd
,
9884 "graceful-restart helper-only [A.B.C.D]",
9885 "OSPF Graceful Restart\n"
9886 "Enable Helper support\n"
9887 "Advertising router id\n")
9889 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9890 struct in_addr addr
;
9894 "%% This command is deprecated. Please, use `graceful-restart helper enable` instead.\n");
9897 ret
= inet_aton(argv
[2]->arg
, &addr
);
9900 "Please specify the valid routerid address.\n");
9901 return CMD_WARNING_CONFIG_FAILED
;
9904 ospf_gr_helper_support_set_per_routerid(ospf
, &addr
, OSPF_GR_TRUE
);
9908 ospf_gr_helper_support_set(ospf
, OSPF_GR_TRUE
);
9913 ALIAS_HIDDEN(no_ospf_gr_helper_enable
,
9914 no_ospf_gr_helper_only_cmd
,
9915 "no graceful-restart helper-only [A.B.C.D]",
9917 "OSPF Graceful Restart\n"
9918 "Disable Helper support\n"
9919 "Advertising router id\n")
9921 DEFPY(ospf_gr_helper_enable_lsacheck
,
9922 ospf_gr_helper_enable_lsacheck_cmd
,
9923 "graceful-restart helper strict-lsa-checking",
9924 "OSPF Graceful Restart\n"
9926 "Enable strict LSA check\n")
9928 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9930 ospf_gr_helper_lsa_check_set(ospf
, OSPF_GR_TRUE
);
9934 DEFPY(no_ospf_gr_helper_enable_lsacheck
,
9935 no_ospf_gr_helper_enable_lsacheck_cmd
,
9936 "no graceful-restart helper strict-lsa-checking",
9938 "OSPF Graceful Restart\n"
9940 "Disable strict LSA check\n")
9942 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9944 ospf_gr_helper_lsa_check_set(ospf
, OSPF_GR_FALSE
);
9948 DEFPY(ospf_gr_helper_supported_grace_time
,
9949 ospf_gr_helper_supported_grace_time_cmd
,
9950 "graceful-restart helper supported-grace-time (10-1800)$interval",
9951 "OSPF Graceful Restart\n"
9953 "Supported grace timer\n"
9954 "Grace interval(in seconds)\n")
9956 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9958 ospf_gr_helper_supported_gracetime_set(ospf
, interval
);
9962 DEFPY(no_ospf_gr_helper_supported_grace_time
,
9963 no_ospf_gr_helper_supported_grace_time_cmd
,
9964 "no graceful-restart helper supported-grace-time (10-1800)$interval",
9966 "OSPF Graceful Restart\n"
9968 "Supported grace timer\n"
9969 "Grace interval(in seconds)\n")
9971 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9973 ospf_gr_helper_supported_gracetime_set(ospf
, OSPF_MAX_GRACE_INTERVAL
);
9977 DEFPY(ospf_gr_helper_planned_only
,
9978 ospf_gr_helper_planned_only_cmd
,
9979 "graceful-restart helper planned-only",
9980 "OSPF Graceful Restart\n"
9982 "Supported only planned restart\n")
9984 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9986 ospf_gr_helper_set_supported_planned_only_restart(ospf
, OSPF_GR_TRUE
);
9991 /* External Route Aggregation */
9992 DEFUN (ospf_external_route_aggregation
,
9993 ospf_external_route_aggregation_cmd
,
9994 "summary-address A.B.C.D/M [tag (1-4294967295)]",
9995 "External summary address\n"
9996 "Summary address prefix\n"
9998 "Router tag value\n")
10000 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
10001 struct prefix_ipv4 p
;
10003 route_tag_t tag
= 0;
10004 int ret
= OSPF_SUCCESS
;
10006 str2prefix_ipv4(argv
[idx
]->arg
, &p
);
10008 if (is_default_prefix4(&p
)) {
10010 "Default address shouldn't be configured as summary address.\n");
10011 return CMD_SUCCESS
;
10014 /* Apply mask for given prefix. */
10015 apply_mask((struct prefix
*)&p
);
10017 if (!is_valid_summary_addr(&p
)) {
10018 vty_out(vty
, "Not a valid summary address.\n");
10019 return CMD_WARNING_CONFIG_FAILED
;
10023 tag
= strtoul(argv
[idx
+ 2]->arg
, NULL
, 10);
10025 ret
= ospf_asbr_external_aggregator_set(ospf
, &p
, tag
);
10026 if (ret
== OSPF_INVALID
)
10027 vty_out(vty
, "Invalid configuration!!\n");
10029 return CMD_SUCCESS
;
10032 DEFUN (no_ospf_external_route_aggregation
,
10033 no_ospf_external_route_aggregation_cmd
,
10034 "no summary-address A.B.C.D/M [tag (1-4294967295)]",
10036 "External summary address\n"
10037 "Summary address prefix\n"
10039 "Router tag value\n")
10041 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
10042 struct prefix_ipv4 p
;
10044 route_tag_t tag
= 0;
10045 int ret
= OSPF_SUCCESS
;
10047 str2prefix_ipv4(argv
[idx
]->arg
, &p
);
10049 if (is_default_prefix4(&p
)) {
10051 "Default address shouldn't be configured as summary address.\n");
10052 return CMD_SUCCESS
;
10055 /* Apply mask for given prefix. */
10056 apply_mask((struct prefix
*)&p
);
10058 if (!is_valid_summary_addr(&p
)) {
10059 vty_out(vty
, "Not a valid summary address.\n");
10060 return CMD_WARNING_CONFIG_FAILED
;
10064 tag
= strtoul(argv
[idx
+ 2]->arg
, NULL
, 10);
10066 ret
= ospf_asbr_external_aggregator_unset(ospf
, &p
, tag
);
10067 if (ret
== OSPF_INVALID
)
10068 vty_out(vty
, "Invalid configuration!!\n");
10070 return CMD_SUCCESS
;
10073 DEFPY(no_ospf_gr_helper_planned_only
,
10074 no_ospf_gr_helper_planned_only_cmd
,
10075 "no graceful-restart helper planned-only",
10077 "OSPF Graceful Restart\n"
10079 "Supported only for planned restart\n")
10081 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
10083 ospf_gr_helper_set_supported_planned_only_restart(ospf
, OSPF_GR_FALSE
);
10085 return CMD_SUCCESS
;
10088 static int ospf_print_vty_helper_dis_rtr_walkcb(struct hash_bucket
*bucket
,
10091 struct advRtr
*rtr
= bucket
->data
;
10092 struct vty
*vty
= (struct vty
*)arg
;
10093 static unsigned int count
;
10095 vty_out(vty
, "%-6pI4,", &rtr
->advRtrAddr
);
10098 if (count
% 5 == 0)
10099 vty_out(vty
, "\n");
10101 return HASHWALK_CONTINUE
;
10104 static int ospf_show_gr_helper_details(struct vty
*vty
, struct ospf
*ospf
,
10105 uint8_t use_vrf
, json_object
*json
,
10106 bool uj
, bool detail
)
10108 struct listnode
*node
;
10109 struct ospf_interface
*oi
;
10110 char buf
[PREFIX_STRLEN
];
10111 json_object
*json_vrf
= NULL
;
10115 json_vrf
= json_object_new_object();
10120 if (ospf
->instance
) {
10122 json_object_int_add(json
, "ospfInstance",
10125 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
10128 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
10132 json_object_object_add(json
, ospf_get_name(ospf
),
10135 vty_out(vty
, "\n");
10137 /* Show Router ID. */
10139 json_object_string_add(json_vrf
, "routerId",
10140 inet_ntop(AF_INET
, &ospf
->router_id
,
10141 buf
, sizeof(buf
)));
10143 vty_out(vty
, "\n OSPF Router with ID (%pI4)\n\n",
10149 if (ospf
->is_helper_supported
)
10151 " Graceful restart helper support enabled.\n");
10154 " Graceful restart helper support disabled.\n");
10156 if (ospf
->strict_lsa_check
)
10157 vty_out(vty
, " Strict LSA check is enabled.\n");
10159 vty_out(vty
, " Strict LSA check is disabled.\n");
10161 if (ospf
->only_planned_restart
)
10163 " Helper supported for planned restarts only.\n");
10166 " Helper supported for Planned and Unplanned Restarts.\n");
10169 " Supported Graceful restart interval: %d(in seconds).\n",
10170 ospf
->supported_grace_time
);
10172 if (OSPF_HELPER_ENABLE_RTR_COUNT(ospf
)) {
10173 vty_out(vty
, " Enable Router list:\n");
10175 hash_walk(ospf
->enable_rtr_list
,
10176 ospf_print_vty_helper_dis_rtr_walkcb
, vty
);
10177 vty_out(vty
, "\n\n");
10180 if (ospf
->last_exit_reason
!= OSPF_GR_HELPER_EXIT_NONE
) {
10181 vty_out(vty
, " Last Helper exit Reason :%s\n",
10182 ospf_exit_reason2str(ospf
->last_exit_reason
));
10185 if (ospf
->active_restarter_cnt
)
10187 " Number of Active neighbours in graceful restart: %d\n",
10188 ospf
->active_restarter_cnt
);
10190 vty_out(vty
, "\n");
10193 json_object_string_add(
10194 json_vrf
, "helperSupport",
10195 (ospf
->is_helper_supported
) ? "Enabled" : "Disabled");
10196 json_object_string_add(json_vrf
, "strictLsaCheck",
10197 (ospf
->strict_lsa_check
) ? "Enabled"
10199 json_object_string_add(
10200 json_vrf
, "restartSupoort",
10201 (ospf
->only_planned_restart
)
10202 ? "Planned Restart only"
10203 : "Planned and Unplanned Restarts");
10205 json_object_int_add(json_vrf
, "supportedGracePeriod",
10206 ospf
->supported_grace_time
);
10208 if (ospf
->last_exit_reason
!= OSPF_GR_HELPER_EXIT_NONE
)
10209 json_object_string_add(
10210 json_vrf
, "LastExitReason",
10211 ospf_exit_reason2str(ospf
->last_exit_reason
));
10213 if (ospf
->active_restarter_cnt
)
10214 json_object_int_add(json_vrf
, "activeRestarterCnt",
10215 ospf
->active_restarter_cnt
);
10221 json_object
*json_neighbors
= NULL
;
10223 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
10224 struct route_node
*rn
;
10225 struct ospf_neighbor
*nbr
;
10226 json_object
*json_neigh
;
10228 if (ospf_interface_neighbor_count(oi
) == 0)
10232 json_object_object_get_ex(json_vrf
, "Neighbors",
10234 if (!json_neighbors
) {
10236 json_object_new_object();
10237 json_object_object_add(json_vrf
,
10243 for (rn
= route_top(oi
->nbrs
); rn
;
10244 rn
= route_next(rn
)) {
10251 if (!OSPF_GR_IS_ACTIVE_HELPER(nbr
))
10255 vty_out(vty
, " Neighbour %d :\n", cnt
);
10256 vty_out(vty
, " Address : %pI4\n",
10257 &nbr
->address
.u
.prefix4
);
10258 vty_out(vty
, " Routerid : %pI4\n",
10261 " Received Grace period : %d(in seconds).\n",
10262 nbr
->gr_helper_info
10263 .recvd_grace_period
);
10265 " Actual Grace period : %d(in seconds)\n",
10266 nbr
->gr_helper_info
10267 .actual_grace_period
);
10269 " Remaining GraceTime:%ld(in seconds).\n",
10270 thread_timer_remain_second(
10271 nbr
->gr_helper_info
10274 " Graceful Restart reason: %s.\n\n",
10275 ospf_restart_reason2str(
10276 nbr
->gr_helper_info
10277 .gr_restart_reason
));
10280 json_neigh
= json_object_new_object();
10281 json_object_string_add(
10282 json_neigh
, "srcAddr",
10283 inet_ntop(AF_INET
, &nbr
->src
,
10284 buf
, sizeof(buf
)));
10286 json_object_string_add(
10287 json_neigh
, "routerid",
10290 buf
, sizeof(buf
)));
10291 json_object_int_add(
10293 "recvdGraceInterval",
10294 nbr
->gr_helper_info
10295 .recvd_grace_period
);
10296 json_object_int_add(
10298 "actualGraceInterval",
10299 nbr
->gr_helper_info
10300 .actual_grace_period
);
10301 json_object_int_add(
10302 json_neigh
, "remainGracetime",
10303 thread_timer_remain_second(
10304 nbr
->gr_helper_info
10306 json_object_string_add(
10307 json_neigh
, "restartReason",
10308 ospf_restart_reason2str(
10309 nbr
->gr_helper_info
10310 .gr_restart_reason
));
10311 json_object_object_add(
10313 inet_ntop(AF_INET
, &nbr
->src
,
10320 return CMD_SUCCESS
;
10323 DEFUN (ospf_external_route_aggregation_no_adrvertise
,
10324 ospf_external_route_aggregation_no_adrvertise_cmd
,
10325 "summary-address A.B.C.D/M no-advertise",
10326 "External summary address\n"
10327 "Summary address prefix\n"
10328 "Don't advertise summary route \n")
10330 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
10331 struct prefix_ipv4 p
;
10333 int ret
= OSPF_SUCCESS
;
10335 str2prefix_ipv4(argv
[idx
]->arg
, &p
);
10337 if (is_default_prefix4(&p
)) {
10339 "Default address shouldn't be configured as summary address.\n");
10340 return CMD_SUCCESS
;
10343 /* Apply mask for given prefix. */
10344 apply_mask((struct prefix
*)&p
);
10346 if (!is_valid_summary_addr(&p
)) {
10347 vty_out(vty
, "Not a valid summary address.\n");
10348 return CMD_WARNING_CONFIG_FAILED
;
10351 ret
= ospf_asbr_external_rt_no_advertise(ospf
, &p
);
10352 if (ret
== OSPF_INVALID
)
10353 vty_out(vty
, "Invalid configuration!!\n");
10355 return CMD_SUCCESS
;
10358 DEFUN (no_ospf_external_route_aggregation_no_adrvertise
,
10359 no_ospf_external_route_aggregation_no_adrvertise_cmd
,
10360 "no summary-address A.B.C.D/M no-advertise",
10362 "External summary address\n"
10363 "Summary address prefix\n"
10364 "Advertise summary route to the AS \n")
10366 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
10367 struct prefix_ipv4 p
;
10369 int ret
= OSPF_SUCCESS
;
10371 str2prefix_ipv4(argv
[idx
]->arg
, &p
);
10373 if (is_default_prefix4(&p
)) {
10375 "Default address shouldn't be configured as summary address.\n");
10376 return CMD_SUCCESS
;
10379 /* Apply mask for given prefix. */
10380 apply_mask((struct prefix
*)&p
);
10382 if (!is_valid_summary_addr(&p
)) {
10383 vty_out(vty
, "Not a valid summary address.\n");
10384 return CMD_WARNING_CONFIG_FAILED
;
10387 ret
= ospf_asbr_external_rt_advertise(ospf
, &p
);
10388 if (ret
== OSPF_INVALID
)
10389 vty_out(vty
, "Invalid configuration!!\n");
10391 return CMD_SUCCESS
;
10394 DEFUN (ospf_route_aggregation_timer
,
10395 ospf_route_aggregation_timer_cmd
,
10396 "aggregation timer (5-1800)",
10397 "External route aggregation\n"
10398 "Delay timer (in seconds)\n"
10399 "Timer interval(in seconds)\n")
10401 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
10402 uint16_t interval
= 0;
10404 interval
= strtoul(argv
[2]->arg
, NULL
, 10);
10406 ospf_external_aggregator_timer_set(ospf
, interval
);
10408 return CMD_SUCCESS
;
10411 DEFPY (show_ip_ospf_gr_helper
,
10412 show_ip_ospf_gr_helper_cmd
,
10413 "show ip ospf [vrf <NAME|all>] graceful-restart helper [detail] [json]",
10416 "OSPF information\n"
10419 "OSPF Graceful Restart\n"
10420 "Helper details in the router\n"
10421 "Detailed informtion\n"
10424 char *vrf_name
= NULL
;
10425 bool all_vrf
= false;
10426 int ret
= CMD_SUCCESS
;
10429 uint8_t use_vrf
= 0;
10430 bool uj
= use_json(argc
, argv
);
10431 struct ospf
*ospf
= NULL
;
10432 json_object
*json
= NULL
;
10433 struct listnode
*node
= NULL
;
10435 bool detail
= false;
10437 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
10439 if (argv_find(argv
, argc
, "detail", &idx
))
10443 json
= json_object_new_object();
10445 /* vrf input is provided */
10450 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
10451 if (!ospf
->oi_running
)
10454 ret
= ospf_show_gr_helper_details(
10455 vty
, ospf
, use_vrf
, json
, uj
, detail
);
10459 vty_json(vty
, json
);
10464 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
10466 if (ospf
== NULL
|| !ospf
->oi_running
) {
10469 vty_json(vty
, json
);
10471 vty_out(vty
, "%% OSPF instance not found\n");
10473 return CMD_SUCCESS
;
10478 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
10480 if (ospf
== NULL
|| !ospf
->oi_running
) {
10483 vty_json(vty
, json
);
10485 vty_out(vty
, "%% OSPF instance not found\n");
10487 return CMD_SUCCESS
;
10490 ospf_show_gr_helper_details(vty
, ospf
, use_vrf
, json
, uj
,
10495 vty_json(vty
, json
);
10497 return CMD_SUCCESS
;
10499 /* Graceful Restart HELPER commands end */
10500 DEFUN (no_ospf_route_aggregation_timer
,
10501 no_ospf_route_aggregation_timer_cmd
,
10502 "no aggregation timer",
10504 "External route aggregation\n"
10507 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
10509 ospf_external_aggregator_timer_set(ospf
, OSPF_EXTL_AGGR_DEFAULT_DELAY
);
10511 return CMD_SUCCESS
;
10514 /* External Route Aggregation End */
10516 static void config_write_stub_router(struct vty
*vty
, struct ospf
*ospf
)
10518 struct listnode
*ln
;
10519 struct ospf_area
*area
;
10521 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
10522 vty_out(vty
, " max-metric router-lsa on-startup %u\n",
10523 ospf
->stub_router_startup_time
);
10524 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
10525 vty_out(vty
, " max-metric router-lsa on-shutdown %u\n",
10526 ospf
->stub_router_shutdown_time
);
10527 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
10528 if (CHECK_FLAG(area
->stub_router_state
,
10529 OSPF_AREA_ADMIN_STUB_ROUTED
)) {
10530 vty_out(vty
, " max-metric router-lsa administrative\n");
10537 #if CONFDATE > 20230131
10538 CPP_NOTICE("Remove JSON object commands with keys containing whitespaces")
10540 static void show_ip_ospf_route_network(struct vty
*vty
, struct ospf
*ospf
,
10541 struct route_table
*rt
,
10544 struct route_node
*rn
;
10545 struct ospf_route
* or ;
10546 struct listnode
*pnode
, *pnnode
;
10547 struct ospf_path
*path
;
10548 json_object
*json_route
= NULL
, *json_nexthop_array
= NULL
,
10549 *json_nexthop
= NULL
;
10553 "============ OSPF network routing table ============\n");
10555 for (rn
= route_top(rt
); rn
; rn
= route_next(rn
)) {
10556 char buf1
[PREFIX2STR_BUFFER
];
10558 if ((or = rn
->info
) == NULL
)
10561 prefix2str(&rn
->p
, buf1
, sizeof(buf1
));
10564 json_route
= json_object_new_object();
10565 json_object_object_add(json
, buf1
, json_route
);
10568 switch (or->path_type
) {
10569 case OSPF_PATH_INTER_AREA
:
10570 if (or->type
== OSPF_DESTINATION_NETWORK
) {
10572 json_object_string_add(json_route
,
10575 json_object_int_add(json_route
, "cost",
10577 json_object_string_addf(
10578 json_route
, "area", "%pI4",
10579 &or->u
.std
.area_id
);
10582 "N IA %-18s [%d] area: %pI4\n",
10584 &or->u
.std
.area_id
);
10586 } else if (or->type
== OSPF_DESTINATION_DISCARD
) {
10588 json_object_string_add(json_route
,
10593 "D IA %-18s Discard entry\n",
10598 case OSPF_PATH_INTRA_AREA
:
10600 json_object_string_add(json_route
, "routeType",
10602 json_object_int_add(json_route
, "cost",
10604 json_object_string_addf(json_route
, "area",
10606 &or->u
.std
.area_id
);
10608 vty_out(vty
, "N %-18s [%d] area: %pI4\n",
10610 &or->u
.std
.area_id
);
10617 if (or->type
== OSPF_DESTINATION_NETWORK
) {
10619 json_nexthop_array
= json_object_new_array();
10620 json_object_object_add(json_route
, "nexthops",
10621 json_nexthop_array
);
10624 for (ALL_LIST_ELEMENTS(or->paths
, pnode
, pnnode
,
10627 json_nexthop
= json_object_new_object();
10628 json_object_array_add(
10629 json_nexthop_array
,
10632 if (if_lookup_by_index(path
->ifindex
,
10635 if (path
->nexthop
.s_addr
10638 json_object_string_add(
10641 json_object_string_add(
10643 "directly attached to",
10647 json_object_string_add(
10649 "directlyAttachedTo",
10655 "%24s directly attached to %s\n",
10663 json_object_string_addf(
10667 json_object_string_add(
10675 "%24s via %pI4, %s\n",
10688 vty_out(vty
, "\n");
10691 static void show_ip_ospf_route_router(struct vty
*vty
, struct ospf
*ospf
,
10692 struct route_table
*rtrs
,
10695 struct route_node
*rn
;
10696 struct ospf_route
* or ;
10697 struct listnode
*pnode
;
10698 struct listnode
*node
;
10699 struct ospf_path
*path
;
10700 char buf
[PREFIX_STRLEN
];
10701 json_object
*json_route
= NULL
, *json_nexthop_array
= NULL
,
10702 *json_nexthop
= NULL
;
10706 "============ OSPF router routing table =============\n");
10708 for (rn
= route_top(rtrs
); rn
; rn
= route_next(rn
)) {
10709 if (rn
->info
== NULL
)
10714 json_route
= json_object_new_object();
10715 json_object_object_add(
10716 json
, inet_ntop(AF_INET
, &rn
->p
.u
.prefix4
,
10719 json_object_string_add(json_route
, "routeType", "R ");
10721 vty_out(vty
, "R %-15pI4 ",
10725 for (ALL_LIST_ELEMENTS_RO((struct list
*)rn
->info
, node
, or)) {
10728 vty_out(vty
, "%24s", "");
10733 json_object_int_add(json_route
, "cost",
10735 json_object_string_addf(json_route
, "area",
10737 &or->u
.std
.area_id
);
10738 if (or->path_type
== OSPF_PATH_INTER_AREA
)
10739 json_object_boolean_true_add(json_route
,
10741 if (or->u
.std
.flags
& ROUTER_LSA_BORDER
)
10742 json_object_string_add(json_route
,
10745 else if (or->u
.std
.flags
& ROUTER_LSA_EXTERNAL
)
10746 json_object_string_add(json_route
,
10750 vty_out(vty
, "%s [%d] area: %pI4",
10751 (or->path_type
== OSPF_PATH_INTER_AREA
10754 or->cost
, &or->u
.std
.area_id
);
10756 vty_out(vty
, "%s%s\n",
10757 (or->u
.std
.flags
& ROUTER_LSA_BORDER
10760 (or->u
.std
.flags
& ROUTER_LSA_EXTERNAL
10766 json_nexthop_array
= json_object_new_array();
10767 json_object_object_add(json_route
, "nexthops",
10768 json_nexthop_array
);
10771 for (ALL_LIST_ELEMENTS_RO(or->paths
, pnode
, path
)) {
10773 json_nexthop
= json_object_new_object();
10774 json_object_array_add(
10775 json_nexthop_array
,
10778 if (if_lookup_by_index(path
->ifindex
,
10780 if (path
->nexthop
.s_addr
10783 json_object_string_add(
10786 json_object_string_add(
10788 "directly attached to",
10792 json_object_string_add(
10794 "directlyAttachedTo",
10800 "%24s directly attached to %s\n",
10808 json_object_string_addf(
10812 json_object_string_add(
10820 "%24s via %pI4, %s\n",
10833 vty_out(vty
, "\n");
10836 static void show_ip_ospf_route_external(struct vty
*vty
, struct ospf
*ospf
,
10837 struct route_table
*rt
,
10840 struct route_node
*rn
;
10841 struct ospf_route
*er
;
10842 struct listnode
*pnode
, *pnnode
;
10843 struct ospf_path
*path
;
10844 json_object
*json_route
= NULL
, *json_nexthop_array
= NULL
,
10845 *json_nexthop
= NULL
;
10849 "============ OSPF external routing table ===========\n");
10851 for (rn
= route_top(rt
); rn
; rn
= route_next(rn
)) {
10852 if ((er
= rn
->info
) == NULL
)
10857 snprintfrr(buf1
, sizeof(buf1
), "%pFX", &rn
->p
);
10859 json_route
= json_object_new_object();
10860 json_object_object_add(json
, buf1
, json_route
);
10863 switch (er
->path_type
) {
10864 case OSPF_PATH_TYPE1_EXTERNAL
:
10866 json_object_string_add(json_route
, "routeType",
10868 json_object_int_add(json_route
, "cost",
10870 json_object_int_add(json_route
, "tag",
10874 "N E1 %-18s [%d] tag: %" ROUTE_TAG_PRI
10876 buf1
, er
->cost
, er
->u
.ext
.tag
);
10879 case OSPF_PATH_TYPE2_EXTERNAL
:
10881 json_object_string_add(json_route
, "routeType",
10883 json_object_int_add(json_route
, "cost",
10885 json_object_int_add(json_route
, "type2cost",
10886 er
->u
.ext
.type2_cost
);
10887 json_object_int_add(json_route
, "tag",
10891 "N E2 %-18s [%d/%d] tag: %" ROUTE_TAG_PRI
10893 buf1
, er
->cost
, er
->u
.ext
.type2_cost
,
10900 json_nexthop_array
= json_object_new_array();
10901 json_object_object_add(json_route
, "nexthops",
10902 json_nexthop_array
);
10905 for (ALL_LIST_ELEMENTS(er
->paths
, pnode
, pnnode
, path
)) {
10907 json_nexthop
= json_object_new_object();
10908 json_object_array_add(json_nexthop_array
,
10912 if (if_lookup_by_index(path
->ifindex
, ospf
->vrf_id
)) {
10913 if (path
->nexthop
.s_addr
== INADDR_ANY
) {
10915 json_object_string_add(
10916 json_nexthop
, "ip",
10918 json_object_string_add(
10920 "directly attached to",
10924 json_object_string_add(
10926 "directlyAttachedTo",
10932 "%24s directly attached to %s\n",
10940 json_object_string_addf(
10941 json_nexthop
, "ip",
10942 "%pI4", &path
->nexthop
);
10943 json_object_string_add(
10944 json_nexthop
, "via",
10950 "%24s via %pI4, %s\n",
10962 vty_out(vty
, "\n");
10965 static int show_ip_ospf_border_routers_common(struct vty
*vty
,
10969 if (ospf
->instance
)
10970 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
10972 ospf_show_vrf_name(ospf
, vty
, NULL
, use_vrf
);
10974 if (ospf
->new_table
== NULL
) {
10975 vty_out(vty
, "No OSPF routing information exist\n");
10976 return CMD_SUCCESS
;
10979 /* Show Network routes.
10980 show_ip_ospf_route_network (vty, ospf->new_table); */
10982 /* Show Router routes. */
10983 show_ip_ospf_route_router(vty
, ospf
, ospf
->new_rtrs
, NULL
);
10985 vty_out(vty
, "\n");
10987 return CMD_SUCCESS
;
10990 DEFUN (show_ip_ospf_border_routers
,
10991 show_ip_ospf_border_routers_cmd
,
10992 "show ip ospf [vrf <NAME|all>] border-routers",
10995 "OSPF information\n"
10998 "Show all the ABR's and ASBR's\n")
11000 struct ospf
*ospf
= NULL
;
11001 struct listnode
*node
= NULL
;
11002 char *vrf_name
= NULL
;
11003 bool all_vrf
= false;
11004 int ret
= CMD_SUCCESS
;
11007 uint8_t use_vrf
= 0;
11009 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
11012 bool ospf_output
= false;
11017 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
11018 if (!ospf
->oi_running
)
11021 ospf_output
= true;
11022 ret
= show_ip_ospf_border_routers_common(
11023 vty
, ospf
, use_vrf
);
11027 vty_out(vty
, "%% OSPF instance not found\n");
11029 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
11030 if (ospf
== NULL
|| !ospf
->oi_running
) {
11031 vty_out(vty
, "%% OSPF instance not found\n");
11032 return CMD_SUCCESS
;
11035 ret
= show_ip_ospf_border_routers_common(vty
, ospf
,
11039 /* Display default ospf (instance 0) info */
11040 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
11041 if (ospf
== NULL
|| !ospf
->oi_running
) {
11042 vty_out(vty
, "%% OSPF instance not found\n");
11043 return CMD_SUCCESS
;
11046 ret
= show_ip_ospf_border_routers_common(vty
, ospf
, use_vrf
);
11052 DEFUN (show_ip_ospf_instance_border_routers
,
11053 show_ip_ospf_instance_border_routers_cmd
,
11054 "show ip ospf (1-65535) border-routers",
11057 "OSPF information\n"
11059 "Show all the ABR's and ASBR's\n")
11061 int idx_number
= 3;
11063 unsigned short instance
= 0;
11065 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11066 if (instance
!= ospf_instance
)
11067 return CMD_NOT_MY_INSTANCE
;
11069 ospf
= ospf_lookup_instance(instance
);
11070 if (!ospf
|| !ospf
->oi_running
)
11071 return CMD_SUCCESS
;
11073 return show_ip_ospf_border_routers_common(vty
, ospf
, 0);
11076 static int show_ip_ospf_route_common(struct vty
*vty
, struct ospf
*ospf
,
11077 json_object
*json
, uint8_t use_vrf
)
11079 json_object
*json_vrf
= NULL
;
11081 if (ospf
->instance
)
11082 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
11087 json_vrf
= json_object_new_object();
11092 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
11094 if (ospf
->new_table
== NULL
) {
11095 vty_out(vty
, "No OSPF routing information exist\n");
11096 return CMD_SUCCESS
;
11099 /* Show Network routes. */
11100 show_ip_ospf_route_network(vty
, ospf
, ospf
->new_table
, json_vrf
);
11102 /* Show Router routes. */
11103 show_ip_ospf_route_router(vty
, ospf
, ospf
->new_rtrs
, json_vrf
);
11105 /* Show AS External routes. */
11106 show_ip_ospf_route_external(vty
, ospf
, ospf
->old_external_route
,
11111 // json_object_object_add(json_vrf, "areas",
11113 json_object_object_add(json
, ospf_get_name(ospf
),
11117 vty_out(vty
, "\n");
11120 return CMD_SUCCESS
;
11123 DEFUN (show_ip_ospf_route
,
11124 show_ip_ospf_route_cmd
,
11125 "show ip ospf [vrf <NAME|all>] route [json]",
11128 "OSPF information\n"
11131 "OSPF routing table\n"
11134 struct ospf
*ospf
= NULL
;
11135 struct listnode
*node
= NULL
;
11136 char *vrf_name
= NULL
;
11137 bool all_vrf
= false;
11138 int ret
= CMD_SUCCESS
;
11141 uint8_t use_vrf
= 0;
11142 bool uj
= use_json(argc
, argv
);
11143 json_object
*json
= NULL
;
11146 json
= json_object_new_object();
11148 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
11150 /* vrf input is provided could be all or specific vrf*/
11152 bool ospf_output
= false;
11157 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
11158 if (!ospf
->oi_running
)
11160 ospf_output
= true;
11161 ret
= show_ip_ospf_route_common(vty
, ospf
, json
,
11166 /* Keep Non-pretty format */
11167 vty_json(vty
, json
);
11168 } else if (!ospf_output
)
11169 vty_out(vty
, "%% OSPF instance not found\n");
11173 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
11174 if (ospf
== NULL
|| !ospf
->oi_running
) {
11176 vty_json(vty
, json
);
11178 vty_out(vty
, "%% OSPF instance not found\n");
11180 return CMD_SUCCESS
;
11183 /* Display default ospf (instance 0) info */
11184 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
11185 if (ospf
== NULL
|| !ospf
->oi_running
) {
11187 vty_json(vty
, json
);
11189 vty_out(vty
, "%% OSPF instance not found\n");
11191 return CMD_SUCCESS
;
11196 ret
= show_ip_ospf_route_common(vty
, ospf
, json
, use_vrf
);
11197 /* Keep Non-pretty format */
11199 vty_out(vty
, "%s\n",
11200 json_object_to_json_string_ext(
11201 json
, JSON_C_TO_STRING_NOSLASHESCAPE
));
11205 json_object_free(json
);
11210 DEFUN (show_ip_ospf_instance_route
,
11211 show_ip_ospf_instance_route_cmd
,
11212 "show ip ospf (1-65535) route",
11215 "OSPF information\n"
11217 "OSPF routing table\n")
11219 int idx_number
= 3;
11221 unsigned short instance
= 0;
11223 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11224 if (instance
!= ospf_instance
)
11225 return CMD_NOT_MY_INSTANCE
;
11227 ospf
= ospf_lookup_instance(instance
);
11228 if (!ospf
|| !ospf
->oi_running
)
11229 return CMD_SUCCESS
;
11231 return show_ip_ospf_route_common(vty
, ospf
, NULL
, 0);
11235 DEFUN (show_ip_ospf_vrfs
,
11236 show_ip_ospf_vrfs_cmd
,
11237 "show ip ospf vrfs [json]",
11240 "OSPF information\n"
11241 "Show OSPF VRFs \n"
11244 bool uj
= use_json(argc
, argv
);
11245 json_object
*json
= NULL
;
11246 json_object
*json_vrfs
= NULL
;
11247 struct ospf
*ospf
= NULL
;
11248 struct listnode
*node
= NULL
;
11250 static const char header
[] = "Name Id RouterId ";
11253 json
= json_object_new_object();
11254 json_vrfs
= json_object_new_object();
11257 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
11258 json_object
*json_vrf
= NULL
;
11259 const char *name
= NULL
;
11260 int64_t vrf_id_ui
= 0;
11264 if (!uj
&& count
== 1)
11265 vty_out(vty
, "%s\n", header
);
11267 json_vrf
= json_object_new_object();
11269 name
= ospf_get_name(ospf
);
11271 vrf_id_ui
= (ospf
->vrf_id
== VRF_UNKNOWN
)
11273 : (int64_t)ospf
->vrf_id
;
11276 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
11277 json_object_string_addf(json_vrf
, "routerId", "%pI4",
11280 json_object_object_add(json_vrfs
, name
, json_vrf
);
11283 vty_out(vty
, "%-25s %-5d %-16pI4 \n", name
,
11284 ospf
->vrf_id
, &ospf
->router_id
);
11289 json_object_object_add(json
, "vrfs", json_vrfs
);
11290 json_object_int_add(json
, "totalVrfs", count
);
11292 vty_json(vty
, json
);
11295 vty_out(vty
, "\nTotal number of OSPF VRFs: %d\n",
11299 return CMD_SUCCESS
;
11301 DEFPY (clear_ip_ospf_neighbor
,
11302 clear_ip_ospf_neighbor_cmd
,
11303 "clear ip ospf [(1-65535)]$instance neighbor [A.B.C.D$nbr_id]",
11306 "OSPF information\n"
11308 "Reset OSPF Neighbor\n"
11311 struct listnode
*node
;
11312 struct ospf
*ospf
= NULL
;
11314 /* If user does not specify the arguments,
11315 * instance = 0 and nbr_id = 0.0.0.0
11317 if (instance
!= 0) {
11318 /* This means clear only the particular ospf process */
11319 if (instance
!= ospf_instance
)
11320 return CMD_NOT_MY_INSTANCE
;
11323 /* Clear all the ospf processes */
11324 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
11325 if (!ospf
->oi_running
)
11328 if (nbr_id_str
&& IPV4_ADDR_SAME(&ospf
->router_id
, &nbr_id
)) {
11329 vty_out(vty
, "Self router-id is not allowed.\r\n ");
11330 return CMD_SUCCESS
;
11333 ospf_neighbor_reset(ospf
, nbr_id
, nbr_id_str
);
11336 return CMD_SUCCESS
;
11339 DEFPY (clear_ip_ospf_process
,
11340 clear_ip_ospf_process_cmd
,
11341 "clear ip ospf [(1-65535)]$instance process",
11344 "OSPF information\n"
11346 "Reset OSPF Process\n")
11348 struct listnode
*node
;
11349 struct ospf
*ospf
= NULL
;
11351 /* Check if instance is not passed as an argument */
11352 if (instance
!= 0) {
11353 /* This means clear only the particular ospf process */
11354 if (instance
!= ospf_instance
)
11355 return CMD_NOT_MY_INSTANCE
;
11358 /* Clear all the ospf processes */
11359 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
11360 if (!ospf
->oi_running
)
11363 ospf_process_reset(ospf
);
11366 return CMD_SUCCESS
;
11369 static const char *const ospf_abr_type_str
[] = {
11370 "unknown", "standard", "ibm", "cisco", "shortcut"
11373 static const char *const ospf_shortcut_mode_str
[] = {
11374 "default", "enable", "disable"
11376 static int ospf_vty_external_rt_walkcb(struct hash_bucket
*bucket
,
11379 struct external_info
*ei
= bucket
->data
;
11380 struct vty
*vty
= (struct vty
*)arg
;
11381 static unsigned int count
;
11383 vty_out(vty
, "%-4pI4/%d, ", &ei
->p
.prefix
, ei
->p
.prefixlen
);
11386 if (count
% 5 == 0)
11387 vty_out(vty
, "\n");
11389 if (OSPF_EXTERNAL_RT_COUNT(ei
->aggr_route
) == count
)
11392 return HASHWALK_CONTINUE
;
11395 static int ospf_json_external_rt_walkcb(struct hash_bucket
*bucket
,
11398 struct external_info
*ei
= bucket
->data
;
11399 struct json_object
*json
= (struct json_object
*)arg
;
11400 char buf
[PREFIX2STR_BUFFER
];
11402 static unsigned int count
;
11404 prefix2str(&ei
->p
, buf
, sizeof(buf
));
11406 snprintf(exnalbuf
, 20, "Exnl Addr-%d", count
);
11408 json_object_string_add(json
, exnalbuf
, buf
);
11412 if (OSPF_EXTERNAL_RT_COUNT(ei
->aggr_route
) == count
)
11415 return HASHWALK_CONTINUE
;
11418 static int ospf_show_summary_address(struct vty
*vty
, struct ospf
*ospf
,
11419 uint8_t use_vrf
, json_object
*json
,
11420 bool uj
, bool detail
)
11422 struct route_node
*rn
;
11423 json_object
*json_vrf
= NULL
;
11426 static char header
[] =
11427 "Summary-address Metric-type Metric Tag External_Rt_count\n";
11429 mtype
= metric_type(ospf
, 0, ospf
->instance
);
11430 mval
= metric_value(ospf
, 0, ospf
->instance
);
11433 vty_out(vty
, "%s\n", header
);
11437 json_vrf
= json_object_new_object();
11442 if (ospf
->instance
) {
11444 json_object_int_add(json
, "ospfInstance",
11447 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
11450 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
11453 vty_out(vty
, "aggregation delay interval :%u(in seconds)\n\n",
11454 ospf
->aggr_delay_interval
);
11456 json_object_int_add(json_vrf
, "aggregation delay interval",
11457 ospf
->aggr_delay_interval
);
11458 json_object_int_add(json_vrf
, "aggregationDelayInterval",
11459 ospf
->aggr_delay_interval
);
11462 for (rn
= route_top(ospf
->rt_aggr_tbl
); rn
; rn
= route_next(rn
))
11464 struct ospf_external_aggr_rt
*aggr
= rn
->info
;
11465 json_object
*json_aggr
= NULL
;
11466 char buf
[PREFIX2STR_BUFFER
];
11468 prefix2str(&aggr
->p
, buf
, sizeof(buf
));
11472 json_aggr
= json_object_new_object();
11474 json_object_object_add(json_vrf
, buf
,
11477 json_object_string_add(json_aggr
,
11478 "Summary address", buf
);
11479 json_object_string_add(json_aggr
,
11480 "summaryAddress", buf
);
11482 json_object_string_add(
11483 json_aggr
, "Metric-type",
11484 (mtype
== EXTERNAL_METRIC_TYPE_1
)
11487 json_object_string_add(
11488 json_aggr
, "metricType",
11489 (mtype
== EXTERNAL_METRIC_TYPE_1
)
11493 json_object_int_add(json_aggr
, "Metric", mval
);
11495 json_object_int_add(json_aggr
, "Tag",
11498 json_object_int_add(
11499 json_aggr
, "External route count",
11500 OSPF_EXTERNAL_RT_COUNT(aggr
));
11501 json_object_int_add(
11502 json_aggr
, "externalRouteCount",
11503 OSPF_EXTERNAL_RT_COUNT(aggr
));
11505 if (OSPF_EXTERNAL_RT_COUNT(aggr
) && detail
) {
11507 aggr
->match_extnl_hash
,
11508 ospf_json_external_rt_walkcb
,
11513 vty_out(vty
, "%-20s", buf
);
11515 (mtype
== EXTERNAL_METRIC_TYPE_1
)
11516 ? vty_out(vty
, "%-16s", "E1")
11517 : vty_out(vty
, "%-16s", "E2");
11518 vty_out(vty
, "%-11d", mval
);
11520 vty_out(vty
, "%-12u", aggr
->tag
);
11522 vty_out(vty
, "%-5ld\n",
11523 OSPF_EXTERNAL_RT_COUNT(aggr
));
11525 if (OSPF_EXTERNAL_RT_COUNT(aggr
) && detail
) {
11527 "Matched External routes:\n");
11529 aggr
->match_extnl_hash
,
11530 ospf_vty_external_rt_walkcb
,
11532 vty_out(vty
, "\n");
11535 vty_out(vty
, "\n");
11541 json_object_object_add(json
, ospf_get_name(ospf
),
11544 vty_out(vty
, "\n");
11546 return CMD_SUCCESS
;
11549 DEFUN (show_ip_ospf_external_aggregator
,
11550 show_ip_ospf_external_aggregator_cmd
,
11551 "show ip ospf [vrf <NAME|all>] summary-address [detail] [json]",
11553 "OSPF information\n"
11556 "Show external summary addresses\n"
11557 "Detailed informtion\n"
11560 char *vrf_name
= NULL
;
11561 bool all_vrf
= false;
11562 int ret
= CMD_SUCCESS
;
11565 uint8_t use_vrf
= 0;
11566 bool uj
= use_json(argc
, argv
);
11567 struct ospf
*ospf
= NULL
;
11568 json_object
*json
= NULL
;
11569 struct listnode
*node
= NULL
;
11571 bool detail
= false;
11573 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
11575 if (argv_find(argv
, argc
, "detail", &idx
))
11579 json
= json_object_new_object();
11581 /* vrf input is provided */
11585 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
11586 if (!ospf
->oi_running
)
11588 ret
= ospf_show_summary_address(
11589 vty
, ospf
, use_vrf
, json
, uj
, detail
);
11593 vty_json(vty
, json
);
11598 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
11600 if (ospf
== NULL
|| !ospf
->oi_running
) {
11602 vty_json(vty
, json
);
11604 vty_out(vty
, "%% OSPF instance not found\n");
11606 return CMD_SUCCESS
;
11608 ospf_show_summary_address(vty
, ospf
, use_vrf
, json
, uj
, detail
);
11612 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
11613 if (ospf
== NULL
|| !ospf
->oi_running
) {
11615 vty_json(vty
, json
);
11617 vty_out(vty
, "%% OSPF instance not found\n");
11619 return CMD_SUCCESS
;
11622 ospf_show_summary_address(vty
, ospf
, use_vrf
, json
, uj
, detail
);
11626 vty_json(vty
, json
);
11627 return CMD_SUCCESS
;
11630 static const char *const ospf_int_type_str
[] = {
11631 "unknown", /* should never be used. */
11635 "point-to-multipoint",
11636 "virtual-link", /* should never be used. */
11640 static const char *interface_config_auth_str(struct ospf_if_params
*params
)
11642 if (!OSPF_IF_PARAM_CONFIGURED(params
, auth_type
)
11643 || params
->auth_type
== OSPF_AUTH_NOTSET
)
11646 /* Translation tables are not that much help
11647 * here due to syntax
11648 * of the simple option */
11649 switch (params
->auth_type
) {
11651 case OSPF_AUTH_NULL
:
11654 case OSPF_AUTH_SIMPLE
:
11657 case OSPF_AUTH_CRYPTOGRAPHIC
:
11658 return " message-digest";
11664 static int config_write_interface_one(struct vty
*vty
, struct vrf
*vrf
)
11666 struct listnode
*node
;
11667 struct interface
*ifp
;
11668 struct crypt_key
*ck
;
11669 struct route_node
*rn
= NULL
;
11670 struct ospf_if_params
*params
;
11671 const char *auth_str
;
11674 FOR_ALL_INTERFACES (vrf
, ifp
) {
11676 if (memcmp(ifp
->name
, "VLINK", 5) == 0)
11679 if_vty_config_start(vty
, ifp
);
11682 vty_out(vty
, " description %s\n", ifp
->desc
);
11686 params
= IF_DEF_PARAMS(ifp
);
11689 /* Interface Network print. */
11690 if (OSPF_IF_PARAM_CONFIGURED(params
, type
)
11691 && params
->type
!= OSPF_IFTYPE_LOOPBACK
) {
11692 if (params
->type
!= ospf_default_iftype(ifp
)) {
11693 vty_out(vty
, " ip ospf network %s",
11697 == OSPF_IFTYPE_POINTOPOINT
11698 && params
->ptp_dmvpn
)
11699 vty_out(vty
, " dmvpn");
11700 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11701 vty_out(vty
, " %pI4",
11703 vty_out(vty
, "\n");
11707 /* OSPF interface authentication print */
11708 auth_str
= interface_config_auth_str(params
);
11710 vty_out(vty
, " ip ospf authentication%s",
11712 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11713 vty_out(vty
, " %pI4",
11715 vty_out(vty
, "\n");
11718 /* Simple Authentication Password print. */
11719 if (OSPF_IF_PARAM_CONFIGURED(params
, auth_simple
)
11720 && params
->auth_simple
[0] != '\0') {
11721 vty_out(vty
, " ip ospf authentication-key %s",
11722 params
->auth_simple
);
11723 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11724 vty_out(vty
, " %pI4",
11726 vty_out(vty
, "\n");
11729 /* Cryptographic Authentication Key print. */
11730 if (params
&& params
->auth_crypt
) {
11731 for (ALL_LIST_ELEMENTS_RO(params
->auth_crypt
,
11734 " ip ospf message-digest-key %d md5 %s",
11735 ck
->key_id
, ck
->auth_key
);
11736 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11737 vty_out(vty
, " %pI4",
11739 vty_out(vty
, "\n");
11743 /* Interface Output Cost print. */
11744 if (OSPF_IF_PARAM_CONFIGURED(params
, output_cost_cmd
)) {
11745 vty_out(vty
, " ip ospf cost %u",
11746 params
->output_cost_cmd
);
11747 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11748 vty_out(vty
, " %pI4",
11750 vty_out(vty
, "\n");
11753 /* Hello Interval print. */
11754 if (OSPF_IF_PARAM_CONFIGURED(params
, v_hello
)
11755 && params
->v_hello
!= OSPF_HELLO_INTERVAL_DEFAULT
) {
11756 vty_out(vty
, " ip ospf hello-interval %u",
11758 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11759 vty_out(vty
, " %pI4",
11761 vty_out(vty
, "\n");
11765 /* Router Dead Interval print. */
11766 if (OSPF_IF_PARAM_CONFIGURED(params
, v_wait
)
11767 && params
->is_v_wait_set
) {
11768 vty_out(vty
, " ip ospf dead-interval ");
11771 if (OSPF_IF_PARAM_CONFIGURED(params
,
11774 "minimal hello-multiplier %d",
11775 params
->fast_hello
);
11777 vty_out(vty
, "%u", params
->v_wait
);
11779 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11780 vty_out(vty
, " %pI4",
11782 vty_out(vty
, "\n");
11785 /* Router Priority print. */
11786 if (OSPF_IF_PARAM_CONFIGURED(params
, priority
)
11787 && params
->priority
11788 != OSPF_ROUTER_PRIORITY_DEFAULT
) {
11789 vty_out(vty
, " ip ospf priority %u",
11791 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11792 vty_out(vty
, " %pI4",
11794 vty_out(vty
, "\n");
11797 /* Retransmit Interval print. */
11798 if (OSPF_IF_PARAM_CONFIGURED(params
,
11799 retransmit_interval
)
11800 && params
->retransmit_interval
11801 != OSPF_RETRANSMIT_INTERVAL_DEFAULT
) {
11802 vty_out(vty
, " ip ospf retransmit-interval %u",
11803 params
->retransmit_interval
);
11804 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11805 vty_out(vty
, " %pI4",
11807 vty_out(vty
, "\n");
11810 /* Transmit Delay print. */
11811 if (OSPF_IF_PARAM_CONFIGURED(params
, transmit_delay
)
11812 && params
->transmit_delay
11813 != OSPF_TRANSMIT_DELAY_DEFAULT
) {
11814 vty_out(vty
, " ip ospf transmit-delay %u",
11815 params
->transmit_delay
);
11816 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11817 vty_out(vty
, " %pI4",
11819 vty_out(vty
, "\n");
11823 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
11825 vty_out(vty
, " ip ospf %d",
11828 vty_out(vty
, " ip ospf");
11830 char buf
[INET_ADDRSTRLEN
];
11832 area_id2str(buf
, sizeof(buf
), ¶ms
->if_area
,
11833 params
->if_area_id_fmt
);
11834 vty_out(vty
, " area %s", buf
);
11835 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11836 vty_out(vty
, " %pI4",
11838 vty_out(vty
, "\n");
11842 if (params
&& params
->bfd_config
)
11843 ospf_bfd_write_config(vty
, params
);
11845 /* MTU ignore print. */
11846 if (OSPF_IF_PARAM_CONFIGURED(params
, mtu_ignore
)
11847 && params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
) {
11848 if (params
->mtu_ignore
== 0)
11849 vty_out(vty
, " no ip ospf mtu-ignore");
11851 vty_out(vty
, " ip ospf mtu-ignore");
11852 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11853 vty_out(vty
, " %pI4",
11855 vty_out(vty
, "\n");
11858 if (OSPF_IF_PARAM_CONFIGURED(params
,
11859 passive_interface
)) {
11860 vty_out(vty
, " %sip ospf passive",
11861 params
->passive_interface
11865 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11866 vty_out(vty
, " %pI4", &rn
->p
.u
.prefix4
);
11867 vty_out(vty
, "\n");
11870 /* LDP-Sync print */
11871 if (params
&& params
->ldp_sync_info
)
11872 ospf_ldp_sync_if_write_config(vty
, params
);
11876 rn
= route_top(IF_OIFS_PARAMS(ifp
));
11878 rn
= route_next(rn
);
11883 if (params
!= NULL
)
11888 ospf_opaque_config_write_if(vty
, ifp
);
11890 if_vty_config_end(vty
);
11896 /* Configuration write function for ospfd. */
11897 static int config_write_interface(struct vty
*vty
)
11900 struct vrf
*vrf
= NULL
;
11902 /* Display all VRF aware OSPF interface configuration */
11903 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
11904 write
+= config_write_interface_one(vty
, vrf
);
11910 static int config_write_network_area(struct vty
*vty
, struct ospf
*ospf
)
11912 struct route_node
*rn
;
11913 char buf
[INET_ADDRSTRLEN
];
11915 /* `network area' print. */
11916 for (rn
= route_top(ospf
->networks
); rn
; rn
= route_next(rn
))
11918 struct ospf_network
*n
= rn
->info
;
11920 /* Create Area ID string by specified Area ID format. */
11921 if (n
->area_id_fmt
== OSPF_AREA_ID_FMT_DOTTEDQUAD
)
11922 inet_ntop(AF_INET
, &n
->area_id
, buf
,
11925 snprintf(buf
, sizeof(buf
), "%lu",
11926 (unsigned long int)ntohl(
11927 n
->area_id
.s_addr
));
11929 /* Network print. */
11930 vty_out(vty
, " network %pFX area %s\n", &rn
->p
, buf
);
11936 static int config_write_ospf_area(struct vty
*vty
, struct ospf
*ospf
)
11938 struct listnode
*node
;
11939 struct ospf_area
*area
;
11940 char buf
[INET_ADDRSTRLEN
];
11942 /* Area configuration print. */
11943 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
11944 struct route_node
*rn1
;
11946 area_id2str(buf
, sizeof(buf
), &area
->area_id
,
11947 area
->area_id_fmt
);
11949 if (area
->auth_type
!= OSPF_AUTH_NULL
) {
11950 if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
11951 vty_out(vty
, " area %s authentication\n", buf
);
11954 " area %s authentication message-digest\n",
11958 if (area
->shortcut_configured
!= OSPF_SHORTCUT_DEFAULT
)
11959 vty_out(vty
, " area %s shortcut %s\n", buf
,
11960 ospf_shortcut_mode_str
11961 [area
->shortcut_configured
]);
11963 if ((area
->external_routing
== OSPF_AREA_STUB
)
11964 || (area
->external_routing
== OSPF_AREA_NSSA
)) {
11965 if (area
->external_routing
== OSPF_AREA_STUB
) {
11966 vty_out(vty
, " area %s stub", buf
);
11967 if (area
->no_summary
)
11968 vty_out(vty
, " no-summary\n");
11969 vty_out(vty
, "\n");
11970 } else if (area
->external_routing
== OSPF_AREA_NSSA
) {
11971 switch (area
->NSSATranslatorRole
) {
11972 case OSPF_NSSA_ROLE_NEVER
:
11974 " area %s nssa translate-never\n",
11977 case OSPF_NSSA_ROLE_ALWAYS
:
11979 " area %s nssa translate-always\n",
11982 case OSPF_NSSA_ROLE_CANDIDATE
:
11983 vty_out(vty
, " area %s nssa \n", buf
);
11986 if (area
->no_summary
)
11988 " area %s nssa no-summary\n",
11990 if (area
->suppress_fa
)
11992 " area %s nssa suppress-fa\n",
11996 if (area
->default_cost
!= 1)
11997 vty_out(vty
, " area %s default-cost %d\n", buf
,
11998 area
->default_cost
);
12001 for (rn1
= route_top(area
->ranges
); rn1
; rn1
= route_next(rn1
))
12003 struct ospf_area_range
*range
= rn1
->info
;
12005 vty_out(vty
, " area %s range %pFX", buf
,
12008 if (range
->cost_config
12009 != OSPF_AREA_RANGE_COST_UNSPEC
)
12010 vty_out(vty
, " cost %d",
12011 range
->cost_config
);
12013 if (!CHECK_FLAG(range
->flags
,
12014 OSPF_AREA_RANGE_ADVERTISE
))
12015 vty_out(vty
, " not-advertise");
12017 if (CHECK_FLAG(range
->flags
,
12018 OSPF_AREA_RANGE_SUBSTITUTE
))
12019 vty_out(vty
, " substitute %pI4/%d",
12020 &range
->subst_addr
,
12021 range
->subst_masklen
);
12023 vty_out(vty
, "\n");
12026 if (EXPORT_NAME(area
))
12027 vty_out(vty
, " area %s export-list %s\n", buf
,
12028 EXPORT_NAME(area
));
12030 if (IMPORT_NAME(area
))
12031 vty_out(vty
, " area %s import-list %s\n", buf
,
12032 IMPORT_NAME(area
));
12034 if (PREFIX_NAME_IN(area
))
12035 vty_out(vty
, " area %s filter-list prefix %s in\n", buf
,
12036 PREFIX_NAME_IN(area
));
12038 if (PREFIX_NAME_OUT(area
))
12039 vty_out(vty
, " area %s filter-list prefix %s out\n",
12040 buf
, PREFIX_NAME_OUT(area
));
12046 static int config_write_ospf_nbr_nbma(struct vty
*vty
, struct ospf
*ospf
)
12048 struct ospf_nbr_nbma
*nbr_nbma
;
12049 struct route_node
*rn
;
12051 /* Static Neighbor configuration print. */
12052 for (rn
= route_top(ospf
->nbr_nbma
); rn
; rn
= route_next(rn
))
12053 if ((nbr_nbma
= rn
->info
)) {
12054 vty_out(vty
, " neighbor %pI4", &nbr_nbma
->addr
);
12056 if (nbr_nbma
->priority
12057 != OSPF_NEIGHBOR_PRIORITY_DEFAULT
)
12058 vty_out(vty
, " priority %d",
12059 nbr_nbma
->priority
);
12061 if (nbr_nbma
->v_poll
!= OSPF_POLL_INTERVAL_DEFAULT
)
12062 vty_out(vty
, " poll-interval %d",
12065 vty_out(vty
, "\n");
12071 static int config_write_virtual_link(struct vty
*vty
, struct ospf
*ospf
)
12073 struct listnode
*node
;
12074 struct ospf_vl_data
*vl_data
;
12075 const char *auth_str
;
12076 char buf
[INET_ADDRSTRLEN
];
12078 /* Virtual-Link print */
12079 for (ALL_LIST_ELEMENTS_RO(ospf
->vlinks
, node
, vl_data
)) {
12080 struct listnode
*n2
;
12081 struct crypt_key
*ck
;
12082 struct ospf_interface
*oi
;
12084 if (vl_data
!= NULL
) {
12085 area_id2str(buf
, sizeof(buf
), &vl_data
->vl_area_id
,
12086 vl_data
->vl_area_id_fmt
);
12087 oi
= vl_data
->vl_oi
;
12090 if (OSPF_IF_PARAM(oi
, v_hello
)
12091 != OSPF_HELLO_INTERVAL_DEFAULT
12092 || OSPF_IF_PARAM(oi
, v_wait
)
12093 != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
12094 || OSPF_IF_PARAM(oi
, retransmit_interval
)
12095 != OSPF_RETRANSMIT_INTERVAL_DEFAULT
12096 || OSPF_IF_PARAM(oi
, transmit_delay
)
12097 != OSPF_TRANSMIT_DELAY_DEFAULT
)
12099 " area %s virtual-link %pI4 hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d\n",
12100 buf
, &vl_data
->vl_peer
,
12101 OSPF_IF_PARAM(oi
, v_hello
),
12102 OSPF_IF_PARAM(oi
, retransmit_interval
),
12103 OSPF_IF_PARAM(oi
, transmit_delay
),
12104 OSPF_IF_PARAM(oi
, v_wait
));
12106 vty_out(vty
, " area %s virtual-link %pI4\n", buf
,
12107 &vl_data
->vl_peer
);
12109 auth_str
= interface_config_auth_str(
12110 IF_DEF_PARAMS(oi
->ifp
));
12113 " area %s virtual-link %pI4 authentication%s\n",
12114 buf
, &vl_data
->vl_peer
, auth_str
);
12116 if (IF_DEF_PARAMS(vl_data
->vl_oi
->ifp
)->auth_simple
[0]
12119 " area %s virtual-link %pI4 authentication-key %s\n",
12120 buf
, &vl_data
->vl_peer
,
12121 IF_DEF_PARAMS(vl_data
->vl_oi
->ifp
)
12124 for (ALL_LIST_ELEMENTS_RO(
12125 IF_DEF_PARAMS(vl_data
->vl_oi
->ifp
)
12129 " area %s virtual-link %pI4 message-digest-key %d md5 %s\n",
12130 buf
, &vl_data
->vl_peer
,
12131 ck
->key_id
, ck
->auth_key
);
12139 static int config_write_ospf_redistribute(struct vty
*vty
, struct ospf
*ospf
)
12143 /* redistribute print. */
12144 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++) {
12145 struct list
*red_list
;
12146 struct listnode
*node
;
12147 struct ospf_redist
*red
;
12149 red_list
= ospf
->redist
[type
];
12153 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
12154 vty_out(vty
, " redistribute %s",
12155 zebra_route_string(type
));
12157 vty_out(vty
, " %d", red
->instance
);
12159 if (red
->dmetric
.value
>= 0)
12160 vty_out(vty
, " metric %d", red
->dmetric
.value
);
12162 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
12163 vty_out(vty
, " metric-type 1");
12165 if (ROUTEMAP_NAME(red
))
12166 vty_out(vty
, " route-map %s",
12167 ROUTEMAP_NAME(red
));
12169 vty_out(vty
, "\n");
12176 static int ospf_cfg_write_helper_dis_rtr_walkcb(struct hash_bucket
*bucket
,
12179 struct advRtr
*rtr
= bucket
->data
;
12180 struct vty
*vty
= (struct vty
*)arg
;
12182 vty_out(vty
, " graceful-restart helper enable %pI4\n",
12184 return HASHWALK_CONTINUE
;
12187 static void config_write_ospf_gr(struct vty
*vty
, struct ospf
*ospf
)
12189 if (!ospf
->gr_info
.restart_support
)
12192 if (ospf
->gr_info
.grace_period
== OSPF_DFLT_GRACE_INTERVAL
)
12193 vty_out(vty
, " graceful-restart\n");
12195 vty_out(vty
, " graceful-restart grace-period %u\n",
12196 ospf
->gr_info
.grace_period
);
12199 static int config_write_ospf_gr_helper(struct vty
*vty
, struct ospf
*ospf
)
12201 if (ospf
->is_helper_supported
)
12202 vty_out(vty
, " graceful-restart helper enable\n");
12204 if (!ospf
->strict_lsa_check
)
12206 " no graceful-restart helper strict-lsa-checking\n");
12208 if (ospf
->only_planned_restart
)
12209 vty_out(vty
, " graceful-restart helper planned-only\n");
12211 if (ospf
->supported_grace_time
!= OSPF_MAX_GRACE_INTERVAL
)
12213 " graceful-restart helper supported-grace-time %d\n",
12214 ospf
->supported_grace_time
);
12216 if (OSPF_HELPER_ENABLE_RTR_COUNT(ospf
)) {
12217 hash_walk(ospf
->enable_rtr_list
,
12218 ospf_cfg_write_helper_dis_rtr_walkcb
, vty
);
12223 static int config_write_ospf_external_aggregator(struct vty
*vty
,
12226 struct route_node
*rn
;
12228 if (ospf
->aggr_delay_interval
!= OSPF_EXTL_AGGR_DEFAULT_DELAY
)
12229 vty_out(vty
, " aggregation timer %u\n",
12230 ospf
->aggr_delay_interval
);
12232 /* print 'summary-address A.B.C.D/M' */
12233 for (rn
= route_top(ospf
->rt_aggr_tbl
); rn
; rn
= route_next(rn
))
12235 struct ospf_external_aggr_rt
*aggr
= rn
->info
;
12237 vty_out(vty
, " summary-address %pI4/%d",
12238 &aggr
->p
.prefix
, aggr
->p
.prefixlen
);
12240 vty_out(vty
, " tag %u", aggr
->tag
);
12242 if (CHECK_FLAG(aggr
->flags
,
12243 OSPF_EXTERNAL_AGGRT_NO_ADVERTISE
))
12244 vty_out(vty
, " no-advertise");
12246 vty_out(vty
, "\n");
12252 static int config_write_ospf_default_metric(struct vty
*vty
, struct ospf
*ospf
)
12254 if (ospf
->default_metric
!= -1)
12255 vty_out(vty
, " default-metric %d\n", ospf
->default_metric
);
12259 static int config_write_ospf_distribute(struct vty
*vty
, struct ospf
*ospf
)
12262 struct ospf_redist
*red
;
12265 /* distribute-list print. */
12266 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
12267 if (DISTRIBUTE_NAME(ospf
, type
))
12268 vty_out(vty
, " distribute-list %s out %s\n",
12269 DISTRIBUTE_NAME(ospf
, type
),
12270 zebra_route_string(type
));
12272 /* default-information print. */
12273 if (ospf
->default_originate
!= DEFAULT_ORIGINATE_NONE
) {
12274 vty_out(vty
, " default-information originate");
12275 if (ospf
->default_originate
== DEFAULT_ORIGINATE_ALWAYS
)
12276 vty_out(vty
, " always");
12278 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
12280 if (red
->dmetric
.value
>= 0)
12281 vty_out(vty
, " metric %d",
12282 red
->dmetric
.value
);
12284 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
12285 vty_out(vty
, " metric-type 1");
12287 if (ROUTEMAP_NAME(red
))
12288 vty_out(vty
, " route-map %s",
12289 ROUTEMAP_NAME(red
));
12292 vty_out(vty
, "\n");
12299 static int config_write_ospf_distance(struct vty
*vty
, struct ospf
*ospf
)
12301 struct route_node
*rn
;
12302 struct ospf_distance
*odistance
;
12304 if (ospf
->distance_all
)
12305 vty_out(vty
, " distance %d\n", ospf
->distance_all
);
12307 if (ospf
->distance_intra
|| ospf
->distance_inter
12308 || ospf
->distance_external
) {
12309 vty_out(vty
, " distance ospf");
12311 if (ospf
->distance_intra
)
12312 vty_out(vty
, " intra-area %d", ospf
->distance_intra
);
12313 if (ospf
->distance_inter
)
12314 vty_out(vty
, " inter-area %d", ospf
->distance_inter
);
12315 if (ospf
->distance_external
)
12316 vty_out(vty
, " external %d", ospf
->distance_external
);
12318 vty_out(vty
, "\n");
12321 for (rn
= route_top(ospf
->distance_table
); rn
; rn
= route_next(rn
))
12322 if ((odistance
= rn
->info
) != NULL
) {
12323 vty_out(vty
, " distance %d %pFX %s\n",
12324 odistance
->distance
, &rn
->p
,
12325 odistance
->access_list
? odistance
->access_list
12331 static int ospf_config_write_one(struct vty
*vty
, struct ospf
*ospf
)
12335 /* `router ospf' print. */
12336 if (ospf
->instance
&& strcmp(ospf
->name
, VRF_DEFAULT_NAME
)) {
12337 vty_out(vty
, "router ospf %d vrf %s\n", ospf
->instance
,
12339 } else if (ospf
->instance
) {
12340 vty_out(vty
, "router ospf %d\n", ospf
->instance
);
12341 } else if (strcmp(ospf
->name
, VRF_DEFAULT_NAME
)) {
12342 vty_out(vty
, "router ospf vrf %s\n", ospf
->name
);
12344 vty_out(vty
, "router ospf\n");
12346 if (!ospf
->networks
) {
12351 /* Router ID print. */
12352 if (ospf
->router_id_static
.s_addr
!= INADDR_ANY
)
12353 vty_out(vty
, " ospf router-id %pI4\n",
12354 &ospf
->router_id_static
);
12356 /* zebra opaque attributes configuration. */
12357 if (CHECK_FLAG(ospf
->config
, OSPF_SEND_EXTRA_DATA_TO_ZEBRA
))
12358 vty_out(vty
, " ospf send-extra-data zebra\n");
12360 /* ABR type print. */
12361 if (ospf
->abr_type
!= OSPF_ABR_DEFAULT
)
12362 vty_out(vty
, " ospf abr-type %s\n",
12363 ospf_abr_type_str
[ospf
->abr_type
]);
12365 /* log-adjacency-changes flag print. */
12366 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
)) {
12367 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
12368 vty_out(vty
, " log-adjacency-changes detail\n");
12369 else if (!SAVE_OSPF_LOG_ADJACENCY_CHANGES
)
12370 vty_out(vty
, " log-adjacency-changes\n");
12371 } else if (SAVE_OSPF_LOG_ADJACENCY_CHANGES
) {
12372 vty_out(vty
, " no log-adjacency-changes\n");
12375 /* RFC1583 compatibility flag print -- Compatible with CISCO
12377 if (CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
12378 vty_out(vty
, " compatible rfc1583\n");
12380 /* auto-cost reference-bandwidth configuration. */
12381 if (ospf
->ref_bandwidth
!= OSPF_DEFAULT_REF_BANDWIDTH
) {
12383 "! Important: ensure reference bandwidth is consistent across all routers\n");
12384 vty_out(vty
, " auto-cost reference-bandwidth %d\n",
12385 ospf
->ref_bandwidth
);
12388 /* SPF timers print. */
12389 if (ospf
->spf_delay
!= OSPF_SPF_DELAY_DEFAULT
12390 || ospf
->spf_holdtime
!= OSPF_SPF_HOLDTIME_DEFAULT
12391 || ospf
->spf_max_holdtime
!= OSPF_SPF_MAX_HOLDTIME_DEFAULT
)
12392 vty_out(vty
, " timers throttle spf %d %d %d\n", ospf
->spf_delay
,
12393 ospf
->spf_holdtime
, ospf
->spf_max_holdtime
);
12395 /* LSA timers print. */
12396 if (ospf
->min_ls_interval
!= OSPF_MIN_LS_INTERVAL
)
12397 vty_out(vty
, " timers throttle lsa all %d\n",
12398 ospf
->min_ls_interval
);
12399 if (ospf
->min_ls_arrival
!= OSPF_MIN_LS_ARRIVAL
)
12400 vty_out(vty
, " timers lsa min-arrival %d\n",
12401 ospf
->min_ls_arrival
);
12403 /* Write multiplier print. */
12404 if (ospf
->write_oi_count
!= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
)
12405 vty_out(vty
, " ospf write-multiplier %d\n",
12406 ospf
->write_oi_count
);
12408 if (ospf
->max_multipath
!= MULTIPATH_NUM
)
12409 vty_out(vty
, " maximum-paths %d\n", ospf
->max_multipath
);
12411 /* Max-metric router-lsa print */
12412 config_write_stub_router(vty
, ospf
);
12414 /* SPF refresh parameters print. */
12415 if (ospf
->lsa_refresh_interval
!= OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
12416 vty_out(vty
, " refresh timer %d\n", ospf
->lsa_refresh_interval
);
12418 /* Redistribute information print. */
12419 config_write_ospf_redistribute(vty
, ospf
);
12421 /* Graceful Restart print */
12422 config_write_ospf_gr(vty
, ospf
);
12423 config_write_ospf_gr_helper(vty
, ospf
);
12425 /* Print external route aggregation. */
12426 config_write_ospf_external_aggregator(vty
, ospf
);
12428 /* passive-interface print. */
12429 if (ospf
->passive_interface_default
== OSPF_IF_PASSIVE
)
12430 vty_out(vty
, " passive-interface default\n");
12432 /* proactive-arp print. */
12433 if (ospf
->proactive_arp
!= OSPF_PROACTIVE_ARP_DEFAULT
) {
12434 if (ospf
->proactive_arp
)
12435 vty_out(vty
, " proactive-arp\n");
12437 vty_out(vty
, " no proactive-arp\n");
12440 /* TI-LFA print. */
12441 if (ospf
->ti_lfa_enabled
) {
12442 if (ospf
->ti_lfa_protection_type
== OSPF_TI_LFA_NODE_PROTECTION
)
12443 vty_out(vty
, " fast-reroute ti-lfa node-protection\n");
12445 vty_out(vty
, " fast-reroute ti-lfa\n");
12448 /* Network area print. */
12449 config_write_network_area(vty
, ospf
);
12451 /* Area config print. */
12452 config_write_ospf_area(vty
, ospf
);
12454 /* static neighbor print. */
12455 config_write_ospf_nbr_nbma(vty
, ospf
);
12457 /* Virtual-Link print. */
12458 config_write_virtual_link(vty
, ospf
);
12460 /* Default metric configuration. */
12461 config_write_ospf_default_metric(vty
, ospf
);
12463 /* Distribute-list and default-information print. */
12464 config_write_ospf_distribute(vty
, ospf
);
12466 /* Distance configuration. */
12467 config_write_ospf_distance(vty
, ospf
);
12469 ospf_opaque_config_write_router(vty
, ospf
);
12471 /* LDP-Sync print */
12472 ospf_ldp_sync_write_config(vty
, ospf
);
12474 vty_out(vty
, "exit\n");
12480 /* OSPF configuration write function. */
12481 static int ospf_config_write(struct vty
*vty
)
12484 struct listnode
*ospf_node
= NULL
;
12487 if (listcount(om
->ospf
) == 0)
12490 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, ospf_node
, ospf
)) {
12491 /* VRF Default check if it is running.
12492 * Upon daemon start, there could be default instance
12493 * in absence of 'router ospf'/oi_running is disabled. */
12494 if (ospf
->vrf_id
== VRF_DEFAULT
&& ospf
->oi_running
)
12495 write
+= ospf_config_write_one(vty
, ospf
);
12496 /* For Non-Default VRF simply display the configuration,
12497 * even if it is not oi_running. */
12498 else if (ospf
->vrf_id
!= VRF_DEFAULT
)
12499 write
+= ospf_config_write_one(vty
, ospf
);
12504 void ospf_vty_show_init(void)
12506 /* "show ip ospf" commands. */
12507 install_element(VIEW_NODE
, &show_ip_ospf_cmd
);
12509 install_element(VIEW_NODE
, &show_ip_ospf_instance_cmd
);
12511 /* "show ip ospf database" commands. */
12512 install_element(VIEW_NODE
, &show_ip_ospf_database_cmd
);
12513 install_element(VIEW_NODE
, &show_ip_ospf_database_max_cmd
);
12514 install_element(VIEW_NODE
,
12515 &show_ip_ospf_database_type_adv_router_cmd
);
12516 install_element(VIEW_NODE
,
12517 &show_ip_ospf_instance_database_type_adv_router_cmd
);
12518 install_element(VIEW_NODE
, &show_ip_ospf_instance_database_cmd
);
12519 install_element(VIEW_NODE
, &show_ip_ospf_instance_database_max_cmd
);
12521 /* "show ip ospf interface" commands. */
12522 install_element(VIEW_NODE
, &show_ip_ospf_interface_cmd
);
12524 install_element(VIEW_NODE
, &show_ip_ospf_instance_interface_cmd
);
12525 /* "show ip ospf interface traffic */
12526 install_element(VIEW_NODE
, &show_ip_ospf_interface_traffic_cmd
);
12528 /* "show ip ospf neighbor" commands. */
12529 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_int_detail_cmd
);
12530 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_int_cmd
);
12531 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_id_cmd
);
12532 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_detail_all_cmd
);
12533 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_detail_cmd
);
12534 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_cmd
);
12535 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_all_cmd
);
12537 install_element(VIEW_NODE
,
12538 &show_ip_ospf_instance_neighbor_int_detail_cmd
);
12539 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_cmd
);
12540 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_id_cmd
);
12541 install_element(VIEW_NODE
,
12542 &show_ip_ospf_instance_neighbor_detail_all_cmd
);
12543 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_cmd
);
12544 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_cmd
);
12545 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_all_cmd
);
12547 /* "show ip ospf route" commands. */
12548 install_element(VIEW_NODE
, &show_ip_ospf_route_cmd
);
12549 install_element(VIEW_NODE
, &show_ip_ospf_border_routers_cmd
);
12551 install_element(VIEW_NODE
, &show_ip_ospf_instance_route_cmd
);
12552 install_element(VIEW_NODE
, &show_ip_ospf_instance_border_routers_cmd
);
12554 /* "show ip ospf vrfs" commands. */
12555 install_element(VIEW_NODE
, &show_ip_ospf_vrfs_cmd
);
12557 /* "show ip ospf gr-helper details" command */
12558 install_element(VIEW_NODE
, &show_ip_ospf_gr_helper_cmd
);
12560 /* "show ip ospf summary-address" command */
12561 install_element(VIEW_NODE
, &show_ip_ospf_external_aggregator_cmd
);
12564 /* Initialization of OSPF interface. */
12565 static void ospf_vty_if_init(void)
12567 /* Install interface node. */
12568 if_cmd_init(config_write_interface
);
12570 /* "ip ospf authentication" commands. */
12571 install_element(INTERFACE_NODE
, &ip_ospf_authentication_args_addr_cmd
);
12572 install_element(INTERFACE_NODE
, &ip_ospf_authentication_addr_cmd
);
12573 install_element(INTERFACE_NODE
,
12574 &no_ip_ospf_authentication_args_addr_cmd
);
12575 install_element(INTERFACE_NODE
, &no_ip_ospf_authentication_addr_cmd
);
12576 install_element(INTERFACE_NODE
, &ip_ospf_authentication_key_addr_cmd
);
12577 install_element(INTERFACE_NODE
,
12578 &no_ip_ospf_authentication_key_authkey_addr_cmd
);
12579 install_element(INTERFACE_NODE
,
12580 &no_ospf_authentication_key_authkey_addr_cmd
);
12582 /* "ip ospf message-digest-key" commands. */
12583 install_element(INTERFACE_NODE
, &ip_ospf_message_digest_key_cmd
);
12584 install_element(INTERFACE_NODE
, &no_ip_ospf_message_digest_key_cmd
);
12586 /* "ip ospf cost" commands. */
12587 install_element(INTERFACE_NODE
, &ip_ospf_cost_cmd
);
12588 install_element(INTERFACE_NODE
, &no_ip_ospf_cost_cmd
);
12590 /* "ip ospf mtu-ignore" commands. */
12591 install_element(INTERFACE_NODE
, &ip_ospf_mtu_ignore_addr_cmd
);
12592 install_element(INTERFACE_NODE
, &no_ip_ospf_mtu_ignore_addr_cmd
);
12594 /* "ip ospf dead-interval" commands. */
12595 install_element(INTERFACE_NODE
, &ip_ospf_dead_interval_cmd
);
12596 install_element(INTERFACE_NODE
,
12597 &ip_ospf_dead_interval_minimal_addr_cmd
);
12598 install_element(INTERFACE_NODE
, &no_ip_ospf_dead_interval_cmd
);
12600 /* "ip ospf hello-interval" commands. */
12601 install_element(INTERFACE_NODE
, &ip_ospf_hello_interval_cmd
);
12602 install_element(INTERFACE_NODE
, &no_ip_ospf_hello_interval_cmd
);
12604 /* "ip ospf network" commands. */
12605 install_element(INTERFACE_NODE
, &ip_ospf_network_cmd
);
12606 install_element(INTERFACE_NODE
, &no_ip_ospf_network_cmd
);
12608 /* "ip ospf priority" commands. */
12609 install_element(INTERFACE_NODE
, &ip_ospf_priority_cmd
);
12610 install_element(INTERFACE_NODE
, &no_ip_ospf_priority_cmd
);
12612 /* "ip ospf retransmit-interval" commands. */
12613 install_element(INTERFACE_NODE
, &ip_ospf_retransmit_interval_addr_cmd
);
12614 install_element(INTERFACE_NODE
,
12615 &no_ip_ospf_retransmit_interval_addr_cmd
);
12617 /* "ip ospf transmit-delay" commands. */
12618 install_element(INTERFACE_NODE
, &ip_ospf_transmit_delay_addr_cmd
);
12619 install_element(INTERFACE_NODE
, &no_ip_ospf_transmit_delay_addr_cmd
);
12621 /* "ip ospf area" commands. */
12622 install_element(INTERFACE_NODE
, &ip_ospf_area_cmd
);
12623 install_element(INTERFACE_NODE
, &no_ip_ospf_area_cmd
);
12625 /* "ip ospf passive" commands. */
12626 install_element(INTERFACE_NODE
, &ip_ospf_passive_cmd
);
12627 install_element(INTERFACE_NODE
, &no_ip_ospf_passive_cmd
);
12629 /* These commands are compatibitliy for previous version. */
12630 install_element(INTERFACE_NODE
, &ospf_authentication_key_cmd
);
12631 install_element(INTERFACE_NODE
, &ospf_message_digest_key_cmd
);
12632 install_element(INTERFACE_NODE
, &no_ospf_message_digest_key_cmd
);
12633 install_element(INTERFACE_NODE
, &ospf_dead_interval_cmd
);
12634 install_element(INTERFACE_NODE
, &no_ospf_dead_interval_cmd
);
12635 install_element(INTERFACE_NODE
, &ospf_hello_interval_cmd
);
12636 install_element(INTERFACE_NODE
, &no_ospf_hello_interval_cmd
);
12637 install_element(INTERFACE_NODE
, &ospf_cost_cmd
);
12638 install_element(INTERFACE_NODE
, &no_ospf_cost_cmd
);
12639 install_element(INTERFACE_NODE
, &ospf_network_cmd
);
12640 install_element(INTERFACE_NODE
, &no_ospf_network_cmd
);
12641 install_element(INTERFACE_NODE
, &ospf_priority_cmd
);
12642 install_element(INTERFACE_NODE
, &no_ospf_priority_cmd
);
12643 install_element(INTERFACE_NODE
, &ospf_retransmit_interval_cmd
);
12644 install_element(INTERFACE_NODE
, &no_ospf_retransmit_interval_cmd
);
12645 install_element(INTERFACE_NODE
, &ospf_transmit_delay_cmd
);
12646 install_element(INTERFACE_NODE
, &no_ospf_transmit_delay_cmd
);
12649 static void ospf_vty_zebra_init(void)
12651 install_element(OSPF_NODE
, &ospf_redistribute_source_cmd
);
12652 install_element(OSPF_NODE
, &no_ospf_redistribute_source_cmd
);
12653 install_element(OSPF_NODE
, &ospf_redistribute_instance_source_cmd
);
12654 install_element(OSPF_NODE
, &no_ospf_redistribute_instance_source_cmd
);
12656 install_element(OSPF_NODE
, &ospf_distribute_list_out_cmd
);
12657 install_element(OSPF_NODE
, &no_ospf_distribute_list_out_cmd
);
12659 install_element(OSPF_NODE
, &ospf_default_information_originate_cmd
);
12660 install_element(OSPF_NODE
, &no_ospf_default_information_originate_cmd
);
12662 install_element(OSPF_NODE
, &ospf_default_metric_cmd
);
12663 install_element(OSPF_NODE
, &no_ospf_default_metric_cmd
);
12665 install_element(OSPF_NODE
, &ospf_distance_cmd
);
12666 install_element(OSPF_NODE
, &no_ospf_distance_cmd
);
12667 install_element(OSPF_NODE
, &no_ospf_distance_ospf_cmd
);
12668 install_element(OSPF_NODE
, &ospf_distance_ospf_cmd
);
12670 /*Ospf garcefull restart helper configurations */
12671 install_element(OSPF_NODE
, &ospf_gr_helper_enable_cmd
);
12672 install_element(OSPF_NODE
, &no_ospf_gr_helper_enable_cmd
);
12673 install_element(OSPF_NODE
, &ospf_gr_helper_only_cmd
);
12674 install_element(OSPF_NODE
, &no_ospf_gr_helper_only_cmd
);
12675 install_element(OSPF_NODE
, &ospf_gr_helper_enable_lsacheck_cmd
);
12676 install_element(OSPF_NODE
, &no_ospf_gr_helper_enable_lsacheck_cmd
);
12677 install_element(OSPF_NODE
, &ospf_gr_helper_supported_grace_time_cmd
);
12678 install_element(OSPF_NODE
, &no_ospf_gr_helper_supported_grace_time_cmd
);
12679 install_element(OSPF_NODE
, &ospf_gr_helper_planned_only_cmd
);
12680 install_element(OSPF_NODE
, &no_ospf_gr_helper_planned_only_cmd
);
12682 /* External LSA summarisation config commands.*/
12683 install_element(OSPF_NODE
, &ospf_external_route_aggregation_cmd
);
12684 install_element(OSPF_NODE
, &no_ospf_external_route_aggregation_cmd
);
12685 install_element(OSPF_NODE
,
12686 &ospf_external_route_aggregation_no_adrvertise_cmd
);
12687 install_element(OSPF_NODE
,
12688 &no_ospf_external_route_aggregation_no_adrvertise_cmd
);
12689 install_element(OSPF_NODE
, &ospf_route_aggregation_timer_cmd
);
12690 install_element(OSPF_NODE
, &no_ospf_route_aggregation_timer_cmd
);
12693 static int ospf_config_write(struct vty
*vty
);
12694 static struct cmd_node ospf_node
= {
12697 .parent_node
= CONFIG_NODE
,
12698 .prompt
= "%s(config-router)# ",
12699 .config_write
= ospf_config_write
,
12702 static void ospf_interface_clear(struct interface
*ifp
)
12704 if (!if_is_operative(ifp
))
12707 if (IS_DEBUG_OSPF(ism
, ISM_EVENTS
))
12708 zlog_debug("ISM[%s]: clear by reset", ifp
->name
);
12710 ospf_if_reset(ifp
);
12713 DEFUN (clear_ip_ospf_interface
,
12714 clear_ip_ospf_interface_cmd
,
12715 "clear ip ospf [vrf NAME] interface [IFNAME]",
12718 "OSPF information\n"
12720 "Interface information\n"
12721 "Interface name\n")
12723 int idx_ifname
= 0;
12725 struct interface
*ifp
;
12726 struct listnode
*node
;
12727 struct ospf
*ospf
= NULL
;
12728 char *vrf_name
= NULL
;
12729 vrf_id_t vrf_id
= VRF_DEFAULT
;
12730 struct vrf
*vrf
= NULL
;
12732 if (argv_find(argv
, argc
, "vrf", &idx_vrf
))
12733 vrf_name
= argv
[idx_vrf
+ 1]->arg
;
12734 if (vrf_name
&& strmatch(vrf_name
, VRF_DEFAULT_NAME
))
12737 vrf
= vrf_lookup_by_name(vrf_name
);
12739 vrf_id
= vrf
->vrf_id
;
12741 if (!argv_find(argv
, argc
, "IFNAME", &idx_ifname
)) {
12742 /* Clear all the ospfv2 interfaces. */
12743 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
12744 if (vrf_id
!= ospf
->vrf_id
)
12747 vrf
= vrf_lookup_by_id(ospf
->vrf_id
);
12748 FOR_ALL_INTERFACES (vrf
, ifp
)
12749 ospf_interface_clear(ifp
);
12752 /* Interface name is specified. */
12753 ifp
= if_lookup_by_name(argv
[idx_ifname
]->arg
, vrf_id
);
12755 vty_out(vty
, "No such interface name\n");
12757 ospf_interface_clear(ifp
);
12760 return CMD_SUCCESS
;
12763 void ospf_vty_clear_init(void)
12765 install_element(ENABLE_NODE
, &clear_ip_ospf_interface_cmd
);
12766 install_element(ENABLE_NODE
, &clear_ip_ospf_process_cmd
);
12767 install_element(ENABLE_NODE
, &clear_ip_ospf_neighbor_cmd
);
12771 /* Install OSPF related vty commands. */
12772 void ospf_vty_init(void)
12774 /* Install ospf top node. */
12775 install_node(&ospf_node
);
12777 /* "router ospf" commands. */
12778 install_element(CONFIG_NODE
, &router_ospf_cmd
);
12779 install_element(CONFIG_NODE
, &no_router_ospf_cmd
);
12782 install_default(OSPF_NODE
);
12784 /* "ospf router-id" commands. */
12785 install_element(OSPF_NODE
, &ospf_router_id_cmd
);
12786 install_element(OSPF_NODE
, &ospf_router_id_old_cmd
);
12787 install_element(OSPF_NODE
, &no_ospf_router_id_cmd
);
12789 /* "passive-interface" commands. */
12790 install_element(OSPF_NODE
, &ospf_passive_interface_default_cmd
);
12791 install_element(OSPF_NODE
, &ospf_passive_interface_addr_cmd
);
12792 install_element(OSPF_NODE
, &no_ospf_passive_interface_default_cmd
);
12793 install_element(OSPF_NODE
, &no_ospf_passive_interface_addr_cmd
);
12795 /* "ospf abr-type" commands. */
12796 install_element(OSPF_NODE
, &ospf_abr_type_cmd
);
12797 install_element(OSPF_NODE
, &no_ospf_abr_type_cmd
);
12799 /* "ospf log-adjacency-changes" commands. */
12800 install_element(OSPF_NODE
, &ospf_log_adjacency_changes_cmd
);
12801 install_element(OSPF_NODE
, &ospf_log_adjacency_changes_detail_cmd
);
12802 install_element(OSPF_NODE
, &no_ospf_log_adjacency_changes_cmd
);
12803 install_element(OSPF_NODE
, &no_ospf_log_adjacency_changes_detail_cmd
);
12805 /* "ospf rfc1583-compatible" commands. */
12806 install_element(OSPF_NODE
, &ospf_compatible_rfc1583_cmd
);
12807 install_element(OSPF_NODE
, &no_ospf_compatible_rfc1583_cmd
);
12808 install_element(OSPF_NODE
, &ospf_rfc1583_flag_cmd
);
12809 install_element(OSPF_NODE
, &no_ospf_rfc1583_flag_cmd
);
12811 /* "ospf send-extra-data zebra" commands. */
12812 install_element(OSPF_NODE
, &ospf_send_extra_data_cmd
);
12814 /* "network area" commands. */
12815 install_element(OSPF_NODE
, &ospf_network_area_cmd
);
12816 install_element(OSPF_NODE
, &no_ospf_network_area_cmd
);
12818 /* "area authentication" commands. */
12819 install_element(OSPF_NODE
,
12820 &ospf_area_authentication_message_digest_cmd
);
12821 install_element(OSPF_NODE
, &ospf_area_authentication_cmd
);
12822 install_element(OSPF_NODE
, &no_ospf_area_authentication_cmd
);
12824 /* "area range" commands. */
12825 install_element(OSPF_NODE
, &ospf_area_range_cmd
);
12826 install_element(OSPF_NODE
, &ospf_area_range_cost_cmd
);
12827 install_element(OSPF_NODE
, &ospf_area_range_not_advertise_cmd
);
12828 install_element(OSPF_NODE
, &no_ospf_area_range_cmd
);
12829 install_element(OSPF_NODE
, &ospf_area_range_substitute_cmd
);
12830 install_element(OSPF_NODE
, &no_ospf_area_range_substitute_cmd
);
12832 /* "area virtual-link" commands. */
12833 install_element(OSPF_NODE
, &ospf_area_vlink_cmd
);
12834 install_element(OSPF_NODE
, &ospf_area_vlink_intervals_cmd
);
12835 install_element(OSPF_NODE
, &no_ospf_area_vlink_cmd
);
12836 install_element(OSPF_NODE
, &no_ospf_area_vlink_intervals_cmd
);
12839 /* "area stub" commands. */
12840 install_element(OSPF_NODE
, &ospf_area_stub_no_summary_cmd
);
12841 install_element(OSPF_NODE
, &ospf_area_stub_cmd
);
12842 install_element(OSPF_NODE
, &no_ospf_area_stub_no_summary_cmd
);
12843 install_element(OSPF_NODE
, &no_ospf_area_stub_cmd
);
12845 /* "area nssa" commands. */
12846 install_element(OSPF_NODE
, &ospf_area_nssa_cmd
);
12847 install_element(OSPF_NODE
, &ospf_area_nssa_translate_cmd
);
12848 install_element(OSPF_NODE
, &ospf_area_nssa_no_summary_cmd
);
12849 install_element(OSPF_NODE
, &no_ospf_area_nssa_no_summary_cmd
);
12850 install_element(OSPF_NODE
, &ospf_area_nssa_suppress_fa_cmd
);
12851 install_element(OSPF_NODE
, &no_ospf_area_nssa_suppress_fa_cmd
);
12852 install_element(OSPF_NODE
, &no_ospf_area_nssa_cmd
);
12854 install_element(OSPF_NODE
, &ospf_area_default_cost_cmd
);
12855 install_element(OSPF_NODE
, &no_ospf_area_default_cost_cmd
);
12857 install_element(OSPF_NODE
, &ospf_area_shortcut_cmd
);
12858 install_element(OSPF_NODE
, &no_ospf_area_shortcut_cmd
);
12860 install_element(OSPF_NODE
, &ospf_area_export_list_cmd
);
12861 install_element(OSPF_NODE
, &no_ospf_area_export_list_cmd
);
12863 install_element(OSPF_NODE
, &ospf_area_filter_list_cmd
);
12864 install_element(OSPF_NODE
, &no_ospf_area_filter_list_cmd
);
12866 install_element(OSPF_NODE
, &ospf_area_import_list_cmd
);
12867 install_element(OSPF_NODE
, &no_ospf_area_import_list_cmd
);
12869 /* SPF timer commands */
12870 install_element(OSPF_NODE
, &ospf_timers_throttle_spf_cmd
);
12871 install_element(OSPF_NODE
, &no_ospf_timers_throttle_spf_cmd
);
12873 /* LSA timers commands */
12874 install_element(OSPF_NODE
, &ospf_timers_min_ls_interval_cmd
);
12875 install_element(OSPF_NODE
, &no_ospf_timers_min_ls_interval_cmd
);
12876 install_element(OSPF_NODE
, &ospf_timers_lsa_min_arrival_cmd
);
12877 install_element(OSPF_NODE
, &no_ospf_timers_lsa_min_arrival_cmd
);
12879 /* refresh timer commands */
12880 install_element(OSPF_NODE
, &ospf_refresh_timer_cmd
);
12881 install_element(OSPF_NODE
, &no_ospf_refresh_timer_val_cmd
);
12883 /* max-metric commands */
12884 install_element(OSPF_NODE
, &ospf_max_metric_router_lsa_admin_cmd
);
12885 install_element(OSPF_NODE
, &no_ospf_max_metric_router_lsa_admin_cmd
);
12886 install_element(OSPF_NODE
, &ospf_max_metric_router_lsa_startup_cmd
);
12887 install_element(OSPF_NODE
, &no_ospf_max_metric_router_lsa_startup_cmd
);
12888 install_element(OSPF_NODE
, &ospf_max_metric_router_lsa_shutdown_cmd
);
12889 install_element(OSPF_NODE
, &no_ospf_max_metric_router_lsa_shutdown_cmd
);
12891 /* reference bandwidth commands */
12892 install_element(OSPF_NODE
, &ospf_auto_cost_reference_bandwidth_cmd
);
12893 install_element(OSPF_NODE
, &no_ospf_auto_cost_reference_bandwidth_cmd
);
12895 /* "neighbor" commands. */
12896 install_element(OSPF_NODE
, &ospf_neighbor_cmd
);
12897 install_element(OSPF_NODE
, &ospf_neighbor_poll_interval_cmd
);
12898 install_element(OSPF_NODE
, &no_ospf_neighbor_cmd
);
12899 install_element(OSPF_NODE
, &no_ospf_neighbor_poll_cmd
);
12901 /* write multiplier commands */
12902 install_element(OSPF_NODE
, &ospf_write_multiplier_cmd
);
12903 install_element(OSPF_NODE
, &write_multiplier_cmd
);
12904 install_element(OSPF_NODE
, &no_ospf_write_multiplier_cmd
);
12905 install_element(OSPF_NODE
, &no_write_multiplier_cmd
);
12907 /* "proactive-arp" commands. */
12908 install_element(OSPF_NODE
, &ospf_proactive_arp_cmd
);
12909 install_element(OSPF_NODE
, &no_ospf_proactive_arp_cmd
);
12911 /* TI-LFA commands */
12912 install_element(OSPF_NODE
, &ospf_ti_lfa_cmd
);
12913 install_element(OSPF_NODE
, &no_ospf_ti_lfa_cmd
);
12915 /* Max path configurations */
12916 install_element(OSPF_NODE
, &ospf_max_multipath_cmd
);
12917 install_element(OSPF_NODE
, &no_ospf_max_multipath_cmd
);
12919 vrf_cmd_init(NULL
);
12921 /* Init interface related vty commands. */
12922 ospf_vty_if_init();
12924 /* Init zebra related vty commands. */
12925 ospf_vty_zebra_init();