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)|substitute A.B.C.D/M}",
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"
663 "Announce area range as another prefix\n"
664 "Network prefix to be announced instead of range\n")
666 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
667 int idx_ipv4_number
= 1;
668 int idx_ipv4_prefixlen
= 3;
670 struct prefix_ipv4 p
, s
;
671 struct in_addr area_id
;
675 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
676 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
678 ospf_area_range_set(ospf
, area_id
, &p
, OSPF_AREA_RANGE_ADVERTISE
);
679 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
682 if (argv_find(argv
, argc
, "cost", &idx
)) {
683 cost
= strtoul(argv
[idx
+ 1]->arg
, NULL
, 10);
684 ospf_area_range_cost_set(ospf
, area_id
, &p
, cost
);
688 if (argv_find(argv
, argc
, "substitute", &idx
)) {
689 str2prefix_ipv4(argv
[idx
+ 1]->arg
, &s
);
690 ospf_area_range_substitute_set(ospf
, area_id
, &p
, &s
);
696 DEFUN (ospf_area_range_not_advertise
,
697 ospf_area_range_not_advertise_cmd
,
698 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M not-advertise",
699 "OSPF area parameters\n"
700 "OSPF area ID in IP address format\n"
701 "OSPF area ID as a decimal value\n"
702 "Summarize routes matching address/mask (border routers only)\n"
703 "Area range prefix\n"
704 "DoNotAdvertise this range\n")
706 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
707 int idx_ipv4_number
= 1;
708 int idx_ipv4_prefixlen
= 3;
709 struct prefix_ipv4 p
;
710 struct in_addr area_id
;
713 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
714 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
716 ospf_area_range_set(ospf
, area_id
, &p
, 0);
717 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
719 ospf_area_range_substitute_unset(ospf
, area_id
, &p
);
724 DEFUN (no_ospf_area_range
,
725 no_ospf_area_range_cmd
,
726 "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [<cost (0-16777215)|advertise [cost (0-16777215)]|not-advertise>]",
728 "OSPF area parameters\n"
729 "OSPF area ID in IP address format\n"
730 "OSPF area ID as a decimal value\n"
731 "Summarize routes matching address/mask (border routers only)\n"
732 "Area range prefix\n"
733 "User specified metric for this range\n"
734 "Advertised metric for this range\n"
735 "Advertise this range (default)\n"
736 "User specified metric for this range\n"
737 "Advertised metric for this range\n"
738 "DoNotAdvertise this range\n")
740 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
741 int idx_ipv4_number
= 2;
742 int idx_ipv4_prefixlen
= 4;
743 struct prefix_ipv4 p
;
744 struct in_addr area_id
;
747 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
748 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
750 ospf_area_range_unset(ospf
, area_id
, &p
);
755 DEFUN (no_ospf_area_range_substitute
,
756 no_ospf_area_range_substitute_cmd
,
757 "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M",
759 "OSPF area parameters\n"
760 "OSPF area ID in IP address format\n"
761 "OSPF area ID as a decimal value\n"
762 "Summarize routes matching address/mask (border routers only)\n"
763 "Area range prefix\n"
764 "Announce area range as another prefix\n"
765 "Network prefix to be announced instead of range\n")
767 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
768 int idx_ipv4_number
= 2;
769 int idx_ipv4_prefixlen
= 4;
770 int idx_ipv4_prefixlen_2
= 6;
771 struct prefix_ipv4 p
, s
;
772 struct in_addr area_id
;
775 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
776 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
777 str2prefix_ipv4(argv
[idx_ipv4_prefixlen_2
]->arg
, &s
);
779 ospf_area_range_substitute_unset(ospf
, area_id
, &p
);
785 /* Command Handler Logic in VLink stuff is delicate!!
787 ALTER AT YOUR OWN RISK!!!!
789 Various dummy values are used to represent 'NoChange' state for
790 VLink configuration NOT being changed by a VLink command, and
791 special syntax is used within the command strings so that the
792 typed in command verbs can be seen in the configuration command
793 bacckend handler. This is to drastically reduce the verbeage
794 required to coe up with a reasonably compatible Cisco VLink command
796 - Matthew Grant <grantma@anathoth.gen.nz>
797 Wed, 21 Feb 2001 15:13:52 +1300
800 /* Configuration data for virtual links
802 struct ospf_vl_config_data
{
803 struct vty
*vty
; /* vty stuff */
804 struct in_addr area_id
; /* area ID from command line */
805 int area_id_fmt
; /* command line area ID format */
806 struct in_addr vl_peer
; /* command line vl_peer */
807 int auth_type
; /* Authehntication type, if given */
808 char *auth_key
; /* simple password if present */
809 int crypto_key_id
; /* Cryptographic key ID */
810 char *md5_key
; /* MD5 authentication key */
811 int hello_interval
; /* Obvious what these are... */
812 int retransmit_interval
;
817 static void ospf_vl_config_data_init(struct ospf_vl_config_data
*vl_config
,
820 memset(vl_config
, 0, sizeof(struct ospf_vl_config_data
));
821 vl_config
->auth_type
= OSPF_AUTH_CMD_NOTSEEN
;
822 vl_config
->vty
= vty
;
825 static struct ospf_vl_data
*
826 ospf_find_vl_data(struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
828 struct ospf_area
*area
;
829 struct ospf_vl_data
*vl_data
;
831 struct in_addr area_id
;
833 vty
= vl_config
->vty
;
834 area_id
= vl_config
->area_id
;
836 if (area_id
.s_addr
== OSPF_AREA_BACKBONE
) {
838 "Configuring VLs over the backbone is not allowed\n");
841 area
= ospf_area_get(ospf
, area_id
);
842 ospf_area_display_format_set(ospf
, area
, vl_config
->area_id_fmt
);
844 if (area
->external_routing
!= OSPF_AREA_DEFAULT
) {
845 if (vl_config
->area_id_fmt
== OSPF_AREA_ID_FMT_DOTTEDQUAD
)
846 vty_out(vty
, "Area %pI4 is %s\n", &area_id
,
847 area
->external_routing
== OSPF_AREA_NSSA
851 vty_out(vty
, "Area %ld is %s\n",
852 (unsigned long)ntohl(area_id
.s_addr
),
853 area
->external_routing
== OSPF_AREA_NSSA
859 if ((vl_data
= ospf_vl_lookup(ospf
, area
, vl_config
->vl_peer
))
861 vl_data
= ospf_vl_data_new(area
, vl_config
->vl_peer
);
862 if (vl_data
->vl_oi
== NULL
) {
863 vl_data
->vl_oi
= ospf_vl_new(ospf
, vl_data
);
864 ospf_vl_add(ospf
, vl_data
);
865 ospf_spf_calculate_schedule(ospf
,
866 SPF_FLAG_CONFIG_CHANGE
);
873 static int ospf_vl_set_security(struct ospf_vl_data
*vl_data
,
874 struct ospf_vl_config_data
*vl_config
)
876 struct crypt_key
*ck
;
878 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
880 vty
= vl_config
->vty
;
882 if (vl_config
->auth_type
!= OSPF_AUTH_CMD_NOTSEEN
) {
883 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), auth_type
);
884 IF_DEF_PARAMS(ifp
)->auth_type
= vl_config
->auth_type
;
887 if (vl_config
->auth_key
) {
888 memset(IF_DEF_PARAMS(ifp
)->auth_simple
, 0,
889 OSPF_AUTH_SIMPLE_SIZE
+ 1);
890 strlcpy((char *)IF_DEF_PARAMS(ifp
)->auth_simple
,
892 sizeof(IF_DEF_PARAMS(ifp
)->auth_simple
));
893 } else if (vl_config
->md5_key
) {
894 if (ospf_crypt_key_lookup(IF_DEF_PARAMS(ifp
)->auth_crypt
,
895 vl_config
->crypto_key_id
)
897 vty_out(vty
, "OSPF: Key %d already exists\n",
898 vl_config
->crypto_key_id
);
901 ck
= ospf_crypt_key_new();
902 ck
->key_id
= vl_config
->crypto_key_id
;
903 memset(ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+ 1);
904 strlcpy((char *)ck
->auth_key
, vl_config
->md5_key
,
905 sizeof(ck
->auth_key
));
907 ospf_crypt_key_add(IF_DEF_PARAMS(ifp
)->auth_crypt
, ck
);
908 } else if (vl_config
->crypto_key_id
!= 0) {
911 if (ospf_crypt_key_lookup(IF_DEF_PARAMS(ifp
)->auth_crypt
,
912 vl_config
->crypto_key_id
)
914 vty_out(vty
, "OSPF: Key %d does not exist\n",
915 vl_config
->crypto_key_id
);
916 return CMD_WARNING_CONFIG_FAILED
;
919 ospf_crypt_key_delete(IF_DEF_PARAMS(ifp
)->auth_crypt
,
920 vl_config
->crypto_key_id
);
926 static int ospf_vl_set_timers(struct ospf_vl_data
*vl_data
,
927 struct ospf_vl_config_data
*vl_config
)
929 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
930 /* Virtual Link data initialised to defaults, so only set
932 if (vl_config
->hello_interval
) {
933 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), v_hello
);
934 IF_DEF_PARAMS(ifp
)->v_hello
= vl_config
->hello_interval
;
937 if (vl_config
->dead_interval
) {
938 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), v_wait
);
939 IF_DEF_PARAMS(ifp
)->v_wait
= vl_config
->dead_interval
;
942 if (vl_config
->retransmit_interval
) {
943 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), retransmit_interval
);
944 IF_DEF_PARAMS(ifp
)->retransmit_interval
=
945 vl_config
->retransmit_interval
;
948 if (vl_config
->transmit_delay
) {
949 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), transmit_delay
);
950 IF_DEF_PARAMS(ifp
)->transmit_delay
= vl_config
->transmit_delay
;
957 /* The business end of all of the above */
958 static int ospf_vl_set(struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
960 struct ospf_vl_data
*vl_data
;
963 vl_data
= ospf_find_vl_data(ospf
, vl_config
);
965 return CMD_WARNING_CONFIG_FAILED
;
967 /* Process this one first as it can have a fatal result, which can
968 only logically occur if the virtual link exists already
969 Thus a command error does not result in a change to the
970 running configuration such as unexpectedly altered timer
972 ret
= ospf_vl_set_security(vl_data
, vl_config
);
973 if (ret
!= CMD_SUCCESS
)
976 /* Set any time based parameters, these area already range checked */
978 ret
= ospf_vl_set_timers(vl_data
, vl_config
);
979 if (ret
!= CMD_SUCCESS
)
985 /* This stuff exists to make specifying all the alias commands A LOT simpler
987 #define VLINK_HELPSTR_IPADDR \
988 "OSPF area parameters\n" \
989 "OSPF area ID in IP address format\n" \
990 "OSPF area ID as a decimal value\n" \
991 "Configure a virtual link\n" \
992 "Router ID of the remote ABR\n"
994 #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
995 "Enable authentication on this virtual link\n" \
998 #define VLINK_HELPSTR_AUTHTYPE_ALL \
999 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
1000 "Use null authentication\n" \
1001 "Use message-digest authentication\n"
1003 #define VLINK_HELPSTR_TIME_PARAM \
1004 "Time between HELLO packets\n" \
1006 "Time between retransmitting lost link state advertisements\n" \
1008 "Link state transmit delay\n" \
1010 "Interval time after which a neighbor is declared down\n" \
1013 #define VLINK_HELPSTR_AUTH_SIMPLE \
1014 "Authentication password (key)\n" \
1015 "The OSPF password (key)\n"
1017 #define VLINK_HELPSTR_AUTH_MD5 \
1018 "Message digest authentication password (key)\n" \
1020 "Use MD5 algorithm\n" \
1021 "The OSPF password (key)\n"
1023 DEFUN (ospf_area_vlink
,
1024 ospf_area_vlink_cmd
,
1025 "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>]",
1026 VLINK_HELPSTR_IPADDR
1027 "Enable authentication on this virtual link\n"
1028 "Use message-digest authentication\n"
1029 "Use null authentication\n"
1030 VLINK_HELPSTR_AUTH_MD5
1031 VLINK_HELPSTR_AUTH_SIMPLE
)
1033 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1034 int idx_ipv4_number
= 1;
1036 struct ospf_vl_config_data vl_config
;
1037 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+ 1];
1038 char md5_key
[OSPF_AUTH_MD5_SIZE
+ 1];
1042 ospf_vl_config_data_init(&vl_config
, vty
);
1044 /* Read off first 2 parameters and check them */
1045 ret
= str2area_id(argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
,
1046 &vl_config
.area_id_fmt
);
1048 vty_out(vty
, "OSPF area ID is invalid\n");
1049 return CMD_WARNING_CONFIG_FAILED
;
1052 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1054 vty_out(vty
, "Please specify valid Router ID as a.b.c.d\n");
1055 return CMD_WARNING_CONFIG_FAILED
;
1059 /* Thats all folks! - BUGS B. strikes again!!!*/
1061 return ospf_vl_set(ospf
, &vl_config
);
1064 if (argv_find(argv
, argc
, "authentication", &idx
)) {
1065 /* authentication - this option can only occur
1066 at start of command line */
1067 vl_config
.auth_type
= OSPF_AUTH_SIMPLE
;
1070 if (argv_find(argv
, argc
, "message-digest", &idx
)) {
1071 /* authentication message-digest */
1072 vl_config
.auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
1073 } else if (argv_find(argv
, argc
, "null", &idx
)) {
1074 /* "authentication null" */
1075 vl_config
.auth_type
= OSPF_AUTH_NULL
;
1078 if (argv_find(argv
, argc
, "message-digest-key", &idx
)) {
1079 vl_config
.md5_key
= NULL
;
1080 vl_config
.crypto_key_id
= strtol(argv
[idx
+ 1]->arg
, NULL
, 10);
1081 if (vl_config
.crypto_key_id
< 0)
1082 return CMD_WARNING_CONFIG_FAILED
;
1084 strlcpy(md5_key
, argv
[idx
+ 3]->arg
, sizeof(md5_key
));
1085 vl_config
.md5_key
= md5_key
;
1088 if (argv_find(argv
, argc
, "authentication-key", &idx
)) {
1089 strlcpy(auth_key
, argv
[idx
+ 1]->arg
, sizeof(auth_key
));
1090 vl_config
.auth_key
= auth_key
;
1093 /* Action configuration */
1095 return ospf_vl_set(ospf
, &vl_config
);
1098 DEFUN (no_ospf_area_vlink
,
1099 no_ospf_area_vlink_cmd
,
1100 "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>]",
1102 VLINK_HELPSTR_IPADDR
1103 "Enable authentication on this virtual link\n"
1104 "Use message-digest authentication\n"
1105 "Use null authentication\n"
1106 VLINK_HELPSTR_AUTH_MD5
1107 VLINK_HELPSTR_AUTH_SIMPLE
)
1109 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1110 int idx_ipv4_number
= 2;
1112 struct ospf_area
*area
;
1113 struct ospf_vl_config_data vl_config
;
1114 struct ospf_vl_data
*vl_data
= NULL
;
1115 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+ 1];
1119 ospf_vl_config_data_init(&vl_config
, vty
);
1121 ret
= str2area_id(argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
,
1124 vty_out(vty
, "OSPF area ID is invalid\n");
1125 return CMD_WARNING_CONFIG_FAILED
;
1128 area
= ospf_area_lookup_by_area_id(ospf
, vl_config
.area_id
);
1130 vty_out(vty
, "Area does not exist\n");
1131 return CMD_WARNING_CONFIG_FAILED
;
1134 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1136 vty_out(vty
, "Please specify valid Router ID as a.b.c.d\n");
1137 return CMD_WARNING_CONFIG_FAILED
;
1140 vl_data
= ospf_vl_lookup(ospf
, area
, vl_config
.vl_peer
);
1142 vty_out(vty
, "Virtual link does not exist\n");
1143 return CMD_WARNING_CONFIG_FAILED
;
1147 /* Basic VLink no command */
1148 /* Thats all folks! - BUGS B. strikes again!!!*/
1149 ospf_vl_delete(ospf
, vl_data
);
1150 ospf_area_check_free(ospf
, vl_config
.area_id
);
1154 /* If we are down here, we are reseting parameters */
1155 /* Deal with other parameters */
1157 if (argv_find(argv
, argc
, "authentication", &idx
)) {
1158 /* authentication - this option can only occur
1159 at start of command line */
1160 vl_config
.auth_type
= OSPF_AUTH_NOTSET
;
1163 if (argv_find(argv
, argc
, "message-digest-key", &idx
)) {
1164 vl_config
.md5_key
= NULL
;
1165 vl_config
.crypto_key_id
= strtol(argv
[idx
+ 1]->arg
, NULL
, 10);
1166 if (vl_config
.crypto_key_id
< 0)
1167 return CMD_WARNING_CONFIG_FAILED
;
1170 if (argv_find(argv
, argc
, "authentication-key", &idx
)) {
1171 /* Reset authentication-key to 0 */
1172 memset(auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1173 vl_config
.auth_key
= auth_key
;
1176 /* Action configuration */
1178 return ospf_vl_set(ospf
, &vl_config
);
1181 DEFUN (ospf_area_vlink_intervals
,
1182 ospf_area_vlink_intervals_cmd
,
1183 "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)}",
1184 VLINK_HELPSTR_IPADDR
1185 VLINK_HELPSTR_TIME_PARAM
)
1187 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1188 struct ospf_vl_config_data vl_config
;
1191 ospf_vl_config_data_init(&vl_config
, vty
);
1193 char *area_id
= argv
[1]->arg
;
1194 char *router_id
= argv
[3]->arg
;
1196 ret
= str2area_id(area_id
, &vl_config
.area_id
, &vl_config
.area_id_fmt
);
1198 vty_out(vty
, "OSPF area ID is invalid\n");
1199 return CMD_WARNING_CONFIG_FAILED
;
1202 ret
= inet_aton(router_id
, &vl_config
.vl_peer
);
1204 vty_out(vty
, "Please specify valid Router ID as a.b.c.d\n");
1205 return CMD_WARNING_CONFIG_FAILED
;
1208 for (int idx
= 4; idx
< argc
; idx
++) {
1209 if (strmatch(argv
[idx
]->text
, "hello-interval"))
1210 vl_config
.hello_interval
=
1211 strtol(argv
[++idx
]->arg
, NULL
, 10);
1212 else if (strmatch(argv
[idx
]->text
, "retransmit-interval"))
1213 vl_config
.retransmit_interval
=
1214 strtol(argv
[++idx
]->arg
, NULL
, 10);
1215 else if (strmatch(argv
[idx
]->text
, "transmit-delay"))
1216 vl_config
.transmit_delay
=
1217 strtol(argv
[++idx
]->arg
, NULL
, 10);
1218 else if (strmatch(argv
[idx
]->text
, "dead-interval"))
1219 vl_config
.dead_interval
=
1220 strtol(argv
[++idx
]->arg
, NULL
, 10);
1223 /* Action configuration */
1224 return ospf_vl_set(ospf
, &vl_config
);
1227 DEFUN (no_ospf_area_vlink_intervals
,
1228 no_ospf_area_vlink_intervals_cmd
,
1229 "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)}",
1231 VLINK_HELPSTR_IPADDR
1232 VLINK_HELPSTR_TIME_PARAM
)
1234 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1235 struct ospf_vl_config_data vl_config
;
1238 ospf_vl_config_data_init(&vl_config
, vty
);
1240 char *area_id
= argv
[2]->arg
;
1241 char *router_id
= argv
[4]->arg
;
1243 ret
= str2area_id(area_id
, &vl_config
.area_id
, &vl_config
.area_id_fmt
);
1245 vty_out(vty
, "OSPF area ID is invalid\n");
1246 return CMD_WARNING_CONFIG_FAILED
;
1249 ret
= inet_aton(router_id
, &vl_config
.vl_peer
);
1251 vty_out(vty
, "Please specify valid Router ID as a.b.c.d\n");
1252 return CMD_WARNING_CONFIG_FAILED
;
1255 for (int idx
= 5; idx
< argc
; idx
++) {
1256 if (strmatch(argv
[idx
]->text
, "hello-interval"))
1257 vl_config
.hello_interval
= OSPF_HELLO_INTERVAL_DEFAULT
;
1258 else if (strmatch(argv
[idx
]->text
, "retransmit-interval"))
1259 vl_config
.retransmit_interval
=
1260 OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
1261 else if (strmatch(argv
[idx
]->text
, "transmit-delay"))
1262 vl_config
.transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
1263 else if (strmatch(argv
[idx
]->text
, "dead-interval"))
1264 vl_config
.dead_interval
=
1265 OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
1268 /* Action configuration */
1269 return ospf_vl_set(ospf
, &vl_config
);
1272 DEFUN (ospf_area_shortcut
,
1273 ospf_area_shortcut_cmd
,
1274 "area <A.B.C.D|(0-4294967295)> shortcut <default|enable|disable>",
1275 "OSPF area parameters\n"
1276 "OSPF area ID in IP address format\n"
1277 "OSPF area ID as a decimal value\n"
1278 "Configure the area's shortcutting mode\n"
1279 "Set default shortcutting behavior\n"
1280 "Enable shortcutting through the area\n"
1281 "Disable shortcutting through the area\n")
1283 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1284 int idx_ipv4_number
= 1;
1285 int idx_enable_disable
= 3;
1286 struct ospf_area
*area
;
1287 struct in_addr area_id
;
1291 VTY_GET_OSPF_AREA_ID_NO_BB("shortcut", area_id
, format
,
1292 argv
[idx_ipv4_number
]->arg
);
1294 area
= ospf_area_get(ospf
, area_id
);
1295 ospf_area_display_format_set(ospf
, area
, format
);
1297 if (strncmp(argv
[idx_enable_disable
]->arg
, "de", 2) == 0)
1298 mode
= OSPF_SHORTCUT_DEFAULT
;
1299 else if (strncmp(argv
[idx_enable_disable
]->arg
, "di", 2) == 0)
1300 mode
= OSPF_SHORTCUT_DISABLE
;
1301 else if (strncmp(argv
[idx_enable_disable
]->arg
, "e", 1) == 0)
1302 mode
= OSPF_SHORTCUT_ENABLE
;
1304 return CMD_WARNING_CONFIG_FAILED
;
1306 ospf_area_shortcut_set(ospf
, area
, mode
);
1308 if (ospf
->abr_type
!= OSPF_ABR_SHORTCUT
)
1310 "Shortcut area setting will take effect only when the router is configured as Shortcut ABR\n");
1315 DEFUN (no_ospf_area_shortcut
,
1316 no_ospf_area_shortcut_cmd
,
1317 "no area <A.B.C.D|(0-4294967295)> shortcut <enable|disable>",
1319 "OSPF area parameters\n"
1320 "OSPF area ID in IP address format\n"
1321 "OSPF area ID as a decimal value\n"
1322 "Deconfigure the area's shortcutting mode\n"
1323 "Deconfigure enabled shortcutting through the area\n"
1324 "Deconfigure disabled shortcutting through the area\n")
1326 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1327 int idx_ipv4_number
= 2;
1328 struct ospf_area
*area
;
1329 struct in_addr area_id
;
1332 VTY_GET_OSPF_AREA_ID_NO_BB("shortcut", area_id
, format
,
1333 argv
[idx_ipv4_number
]->arg
);
1335 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1339 ospf_area_shortcut_unset(ospf
, area
);
1345 DEFUN (ospf_area_stub
,
1347 "area <A.B.C.D|(0-4294967295)> stub",
1348 "OSPF area parameters\n"
1349 "OSPF area ID in IP address format\n"
1350 "OSPF area ID as a decimal value\n"
1351 "Configure OSPF area as stub\n")
1353 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1354 int idx_ipv4_number
= 1;
1355 struct in_addr area_id
;
1358 VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id
, format
,
1359 argv
[idx_ipv4_number
]->arg
);
1361 ret
= ospf_area_stub_set(ospf
, area_id
);
1362 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1366 "First deconfigure all virtual link through this area\n");
1367 return CMD_WARNING_CONFIG_FAILED
;
1370 /* Flush the external LSAs from the specified area */
1371 ospf_flush_lsa_from_area(ospf
, area_id
, OSPF_AS_EXTERNAL_LSA
);
1372 ospf_area_no_summary_unset(ospf
, area_id
);
1377 DEFUN (ospf_area_stub_no_summary
,
1378 ospf_area_stub_no_summary_cmd
,
1379 "area <A.B.C.D|(0-4294967295)> stub no-summary",
1380 "OSPF stub parameters\n"
1381 "OSPF area ID in IP address format\n"
1382 "OSPF area ID as a decimal value\n"
1383 "Configure OSPF area as stub\n"
1384 "Do not inject inter-area routes into stub\n")
1386 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1387 int idx_ipv4_number
= 1;
1388 struct in_addr area_id
;
1391 VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id
, format
,
1392 argv
[idx_ipv4_number
]->arg
);
1394 ret
= ospf_area_stub_set(ospf
, area_id
);
1395 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1399 "%% Area cannot be stub as it contains a virtual link\n");
1400 return CMD_WARNING_CONFIG_FAILED
;
1403 ospf_area_no_summary_set(ospf
, area_id
);
1408 DEFUN (no_ospf_area_stub
,
1409 no_ospf_area_stub_cmd
,
1410 "no area <A.B.C.D|(0-4294967295)> stub",
1412 "OSPF area parameters\n"
1413 "OSPF area ID in IP address format\n"
1414 "OSPF area ID as a decimal value\n"
1415 "Configure OSPF area as stub\n")
1417 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1418 int idx_ipv4_number
= 2;
1419 struct in_addr area_id
;
1422 VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id
, format
,
1423 argv
[idx_ipv4_number
]->arg
);
1425 ospf_area_stub_unset(ospf
, area_id
);
1426 ospf_area_no_summary_unset(ospf
, area_id
);
1431 DEFUN (no_ospf_area_stub_no_summary
,
1432 no_ospf_area_stub_no_summary_cmd
,
1433 "no area <A.B.C.D|(0-4294967295)> stub no-summary",
1435 "OSPF area parameters\n"
1436 "OSPF area ID in IP address format\n"
1437 "OSPF area ID as a decimal value\n"
1438 "Configure OSPF area as stub\n"
1439 "Do not inject inter-area routes into area\n")
1441 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1442 int idx_ipv4_number
= 2;
1443 struct in_addr area_id
;
1446 VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id
, format
,
1447 argv
[idx_ipv4_number
]->arg
);
1448 ospf_area_no_summary_unset(ospf
, area_id
);
1453 static int ospf_area_nssa_cmd_handler(struct vty
*vty
, int argc
,
1454 struct cmd_token
**argv
, int cfg_nosum
,
1457 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1458 struct in_addr area_id
;
1461 VTY_GET_OSPF_AREA_ID_NO_BB("NSSA", area_id
, format
, argv
[1]->arg
);
1463 ret
= ospf_area_nssa_set(ospf
, area_id
);
1464 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1468 "%% Area cannot be nssa as it contains a virtual link\n");
1469 return CMD_WARNING_CONFIG_FAILED
;
1473 if (strncmp(argv
[3]->text
, "translate-c", 11) == 0)
1474 ospf_area_nssa_translator_role_set(
1475 ospf
, area_id
, OSPF_NSSA_ROLE_CANDIDATE
);
1476 else if (strncmp(argv
[3]->text
, "translate-n", 11) == 0)
1477 ospf_area_nssa_translator_role_set(
1478 ospf
, area_id
, OSPF_NSSA_ROLE_NEVER
);
1479 else if (strncmp(argv
[3]->text
, "translate-a", 11) == 0)
1480 ospf_area_nssa_translator_role_set(
1481 ospf
, area_id
, OSPF_NSSA_ROLE_ALWAYS
);
1483 ospf_area_nssa_translator_role_set(ospf
, area_id
,
1484 OSPF_NSSA_ROLE_CANDIDATE
);
1489 ospf_area_no_summary_set(ospf
, area_id
);
1491 ospf_area_no_summary_unset(ospf
, area_id
);
1494 /* Flush the external LSA for the specified area */
1495 ospf_flush_lsa_from_area(ospf
, area_id
, OSPF_AS_EXTERNAL_LSA
);
1496 ospf_schedule_abr_task(ospf
);
1497 ospf_schedule_asbr_nssa_redist_update(ospf
);
1503 DEFUN (ospf_area_nssa_translate
,
1504 ospf_area_nssa_translate_cmd
,
1505 "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always>",
1506 "OSPF area parameters\n"
1507 "OSPF area ID in IP address format\n"
1508 "OSPF area ID as a decimal value\n"
1509 "Configure OSPF area as nssa\n"
1510 "Configure NSSA-ABR for translate election (default)\n"
1511 "Configure NSSA-ABR to never translate\n"
1512 "Configure NSSA-ABR to always translate\n")
1514 return ospf_area_nssa_cmd_handler(vty
, argc
, argv
, 0, 0);
1517 DEFUN (ospf_area_nssa
,
1519 "area <A.B.C.D|(0-4294967295)> nssa",
1520 "OSPF area parameters\n"
1521 "OSPF area ID in IP address format\n"
1522 "OSPF area ID as a decimal value\n"
1523 "Configure OSPF area as nssa\n")
1525 return ospf_area_nssa_cmd_handler(vty
, argc
, argv
, 0, 0);
1528 DEFUN(ospf_area_nssa_suppress_fa
, ospf_area_nssa_suppress_fa_cmd
,
1529 "area <A.B.C.D|(0-4294967295)> nssa suppress-fa",
1530 "OSPF area parameters\n"
1531 "OSPF area ID in IP address format\n"
1532 "OSPF area ID as a decimal value\n"
1533 "Configure OSPF area as nssa\n"
1534 "Suppress forwarding address\n")
1536 int idx_ipv4_number
= 1;
1537 struct in_addr area_id
;
1540 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1541 VTY_GET_OSPF_AREA_ID_NO_BB("NSSA", area_id
, format
,
1542 argv
[idx_ipv4_number
]->arg
);
1544 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1546 ospf_area_nssa_suppress_fa_set(ospf
, area_id
);
1548 ospf_schedule_abr_task(ospf
);
1553 DEFUN(no_ospf_area_nssa_suppress_fa
, no_ospf_area_nssa_suppress_fa_cmd
,
1554 "no area <A.B.C.D|(0-4294967295)> nssa suppress-fa",
1556 "OSPF area parameters\n"
1557 "OSPF area ID in IP address format\n"
1558 "OSPF area ID as a decimal value\n"
1559 "Configure OSPF area as nssa\n"
1560 "Suppress forwarding address\n")
1562 int idx_ipv4_number
= 2;
1563 struct in_addr area_id
;
1566 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1568 VTY_GET_OSPF_AREA_ID_NO_BB("nssa", area_id
, format
,
1569 argv
[idx_ipv4_number
]->arg
);
1571 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1573 ospf_area_nssa_suppress_fa_unset(ospf
, area_id
);
1575 ospf_schedule_abr_task(ospf
);
1580 DEFUN (ospf_area_nssa_no_summary
,
1581 ospf_area_nssa_no_summary_cmd
,
1582 "area <A.B.C.D|(0-4294967295)> nssa no-summary",
1583 "OSPF area parameters\n"
1584 "OSPF area ID in IP address format\n"
1585 "OSPF area ID as a decimal value\n"
1586 "Configure OSPF area as nssa\n"
1587 "Do not inject inter-area routes into nssa\n")
1589 int idx_ipv4_number
= 1;
1590 struct in_addr area_id
;
1593 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1594 VTY_GET_OSPF_AREA_ID_NO_BB("NSSA", area_id
, format
,
1595 argv
[idx_ipv4_number
]->arg
);
1597 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1599 ospf_area_nssa_no_summary_set(ospf
, area_id
);
1601 ospf_schedule_abr_task(ospf
);
1606 DEFUN (no_ospf_area_nssa_no_summary
,
1607 no_ospf_area_nssa_no_summary_cmd
,
1608 "no area <A.B.C.D|(0-4294967295)> nssa no-summary",
1610 "OSPF area parameters\n"
1611 "OSPF area ID in IP address format\n"
1612 "OSPF area ID as a decimal value\n"
1613 "Configure OSPF area as nssa\n"
1614 "Do not inject inter-area routes into nssa\n")
1616 int idx_ipv4_number
= 2;
1617 struct in_addr area_id
;
1620 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1622 VTY_GET_OSPF_AREA_ID_NO_BB("nssa", area_id
, format
,
1623 argv
[idx_ipv4_number
]->arg
);
1625 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1627 ospf_area_no_summary_unset(ospf
, area_id
);
1629 ospf_schedule_abr_task(ospf
);
1634 DEFUN (no_ospf_area_nssa
,
1635 no_ospf_area_nssa_cmd
,
1636 "no area <A.B.C.D|(0-4294967295)> nssa [<translate-candidate|translate-never|translate-always>]",
1638 "OSPF area parameters\n"
1639 "OSPF area ID in IP address format\n"
1640 "OSPF area ID as a decimal value\n"
1641 "Configure OSPF area as nssa\n"
1642 "Configure NSSA-ABR for translate election (default)\n"
1643 "Configure NSSA-ABR to never translate\n"
1644 "Configure NSSA-ABR to always translate\n")
1646 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1647 int idx_ipv4_number
= 2;
1648 struct in_addr area_id
;
1651 VTY_GET_OSPF_AREA_ID_NO_BB("NSSA", area_id
, format
,
1652 argv
[idx_ipv4_number
]->arg
);
1654 /* Flush the NSSA LSA for the specified area */
1655 ospf_flush_lsa_from_area(ospf
, area_id
, OSPF_AS_NSSA_LSA
);
1656 ospf_area_nssa_unset(ospf
, area_id
, argc
);
1658 ospf_schedule_abr_task(ospf
);
1664 DEFUN (ospf_area_default_cost
,
1665 ospf_area_default_cost_cmd
,
1666 "area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1667 "OSPF area parameters\n"
1668 "OSPF area ID in IP address format\n"
1669 "OSPF area ID as a decimal value\n"
1670 "Set the summary-default cost of a NSSA or stub area\n"
1671 "Stub's advertised default summary cost\n")
1673 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1674 int idx_ipv4_number
= 1;
1676 struct ospf_area
*area
;
1677 struct in_addr area_id
;
1680 struct prefix_ipv4 p
;
1682 VTY_GET_OSPF_AREA_ID_NO_BB("default-cost", area_id
, format
,
1683 argv
[idx_ipv4_number
]->arg
);
1684 cost
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1686 area
= ospf_area_get(ospf
, area_id
);
1687 ospf_area_display_format_set(ospf
, area
, format
);
1689 if (area
->external_routing
== OSPF_AREA_DEFAULT
) {
1690 vty_out(vty
, "The area is neither stub, nor NSSA\n");
1691 return CMD_WARNING_CONFIG_FAILED
;
1694 area
->default_cost
= cost
;
1697 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1699 if (IS_DEBUG_OSPF_EVENT
)
1701 "ospf_abr_announce_stub_defaults(): announcing 0.0.0.0/0 to area %pI4",
1703 ospf_abr_announce_network_to_area(&p
, area
->default_cost
, area
);
1708 DEFUN (no_ospf_area_default_cost
,
1709 no_ospf_area_default_cost_cmd
,
1710 "no area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1712 "OSPF area parameters\n"
1713 "OSPF area ID in IP address format\n"
1714 "OSPF area ID as a decimal value\n"
1715 "Set the summary-default cost of a NSSA or stub area\n"
1716 "Stub's advertised default summary cost\n")
1718 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1719 int idx_ipv4_number
= 2;
1720 struct ospf_area
*area
;
1721 struct in_addr area_id
;
1723 struct prefix_ipv4 p
;
1725 VTY_GET_OSPF_AREA_ID_NO_BB("default-cost", area_id
, format
,
1726 argv
[idx_ipv4_number
]->arg
);
1728 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1732 if (area
->external_routing
== OSPF_AREA_DEFAULT
) {
1733 vty_out(vty
, "The area is neither stub, nor NSSA\n");
1734 return CMD_WARNING_CONFIG_FAILED
;
1737 area
->default_cost
= 1;
1740 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1742 if (IS_DEBUG_OSPF_EVENT
)
1744 "ospf_abr_announce_stub_defaults(): announcing 0.0.0.0/0 to area %pI4",
1746 ospf_abr_announce_network_to_area(&p
, area
->default_cost
, area
);
1749 ospf_area_check_free(ospf
, area_id
);
1754 DEFUN (ospf_area_export_list
,
1755 ospf_area_export_list_cmd
,
1756 "area <A.B.C.D|(0-4294967295)> export-list ACCESSLIST4_NAME",
1757 "OSPF area parameters\n"
1758 "OSPF area ID in IP address format\n"
1759 "OSPF area ID as a decimal value\n"
1760 "Set the filter for networks announced to other areas\n"
1761 "Name of the access-list\n")
1763 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1764 int idx_ipv4_number
= 1;
1765 struct ospf_area
*area
;
1766 struct in_addr area_id
;
1769 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1771 area
= ospf_area_get(ospf
, area_id
);
1772 ospf_area_display_format_set(ospf
, area
, format
);
1773 ospf_area_export_list_set(ospf
, area
, argv
[3]->arg
);
1778 DEFUN (no_ospf_area_export_list
,
1779 no_ospf_area_export_list_cmd
,
1780 "no area <A.B.C.D|(0-4294967295)> export-list ACCESSLIST4_NAME",
1782 "OSPF area parameters\n"
1783 "OSPF area ID in IP address format\n"
1784 "OSPF area ID as a decimal value\n"
1785 "Unset the filter for networks announced to other areas\n"
1786 "Name of the access-list\n")
1788 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1789 int idx_ipv4_number
= 2;
1790 struct ospf_area
*area
;
1791 struct in_addr area_id
;
1794 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1796 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1800 ospf_area_export_list_unset(ospf
, area
);
1806 DEFUN (ospf_area_import_list
,
1807 ospf_area_import_list_cmd
,
1808 "area <A.B.C.D|(0-4294967295)> import-list ACCESSLIST4_NAME",
1809 "OSPF area parameters\n"
1810 "OSPF area ID in IP address format\n"
1811 "OSPF area ID as a decimal value\n"
1812 "Set the filter for networks from other areas announced to the specified one\n"
1813 "Name of the access-list\n")
1815 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1816 int idx_ipv4_number
= 1;
1817 struct ospf_area
*area
;
1818 struct in_addr area_id
;
1821 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1823 area
= ospf_area_get(ospf
, area_id
);
1824 ospf_area_display_format_set(ospf
, area
, format
);
1825 ospf_area_import_list_set(ospf
, area
, argv
[3]->arg
);
1830 DEFUN (no_ospf_area_import_list
,
1831 no_ospf_area_import_list_cmd
,
1832 "no area <A.B.C.D|(0-4294967295)> import-list ACCESSLIST4_NAME",
1834 "OSPF area parameters\n"
1835 "OSPF area ID in IP address format\n"
1836 "OSPF area ID as a decimal value\n"
1837 "Unset the filter for networks announced to other areas\n"
1838 "Name of the access-list\n")
1840 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1841 int idx_ipv4_number
= 2;
1842 struct ospf_area
*area
;
1843 struct in_addr area_id
;
1846 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1848 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1852 ospf_area_import_list_unset(ospf
, area
);
1857 DEFUN (ospf_area_filter_list
,
1858 ospf_area_filter_list_cmd
,
1859 "area <A.B.C.D|(0-4294967295)> filter-list prefix PREFIXLIST_NAME <in|out>",
1860 "OSPF area parameters\n"
1861 "OSPF area ID in IP address format\n"
1862 "OSPF area ID as a decimal value\n"
1863 "Filter networks between OSPF areas\n"
1864 "Filter prefixes between OSPF areas\n"
1865 "Name of an IP prefix-list\n"
1866 "Filter networks sent to this area\n"
1867 "Filter networks sent from this area\n")
1869 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1870 int idx_ipv4_number
= 1;
1873 struct ospf_area
*area
;
1874 struct in_addr area_id
;
1875 struct prefix_list
*plist
;
1878 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1880 area
= ospf_area_get(ospf
, area_id
);
1881 ospf_area_display_format_set(ospf
, area
, format
);
1882 plist
= prefix_list_lookup(AFI_IP
, argv
[idx_word
]->arg
);
1883 if (strncmp(argv
[idx_in_out
]->arg
, "in", 2) == 0) {
1884 PREFIX_LIST_IN(area
) = plist
;
1885 if (PREFIX_NAME_IN(area
))
1886 free(PREFIX_NAME_IN(area
));
1888 PREFIX_NAME_IN(area
) = strdup(argv
[idx_word
]->arg
);
1889 ospf_schedule_abr_task(ospf
);
1891 PREFIX_LIST_OUT(area
) = plist
;
1892 if (PREFIX_NAME_OUT(area
))
1893 free(PREFIX_NAME_OUT(area
));
1895 PREFIX_NAME_OUT(area
) = strdup(argv
[idx_word
]->arg
);
1896 ospf_schedule_abr_task(ospf
);
1902 DEFUN (no_ospf_area_filter_list
,
1903 no_ospf_area_filter_list_cmd
,
1904 "no area <A.B.C.D|(0-4294967295)> filter-list prefix PREFIXLIST_NAME <in|out>",
1906 "OSPF area parameters\n"
1907 "OSPF area ID in IP address format\n"
1908 "OSPF area ID as a decimal value\n"
1909 "Filter networks between OSPF areas\n"
1910 "Filter prefixes between OSPF areas\n"
1911 "Name of an IP prefix-list\n"
1912 "Filter networks sent to this area\n"
1913 "Filter networks sent from this area\n")
1915 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1916 int idx_ipv4_number
= 2;
1919 struct ospf_area
*area
;
1920 struct in_addr area_id
;
1923 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1925 if ((area
= ospf_area_lookup_by_area_id(ospf
, area_id
)) == NULL
)
1928 if (strncmp(argv
[idx_in_out
]->arg
, "in", 2) == 0) {
1929 if (PREFIX_NAME_IN(area
))
1930 if (strcmp(PREFIX_NAME_IN(area
), argv
[idx_word
]->arg
)
1934 PREFIX_LIST_IN(area
) = NULL
;
1935 if (PREFIX_NAME_IN(area
))
1936 free(PREFIX_NAME_IN(area
));
1938 PREFIX_NAME_IN(area
) = NULL
;
1940 ospf_schedule_abr_task(ospf
);
1942 if (PREFIX_NAME_OUT(area
))
1943 if (strcmp(PREFIX_NAME_OUT(area
), argv
[idx_word
]->arg
)
1947 PREFIX_LIST_OUT(area
) = NULL
;
1948 if (PREFIX_NAME_OUT(area
))
1949 free(PREFIX_NAME_OUT(area
));
1951 PREFIX_NAME_OUT(area
) = NULL
;
1953 ospf_schedule_abr_task(ospf
);
1960 DEFUN (ospf_area_authentication_message_digest
,
1961 ospf_area_authentication_message_digest_cmd
,
1962 "[no] area <A.B.C.D|(0-4294967295)> authentication message-digest",
1964 "OSPF area parameters\n"
1965 "OSPF area ID in IP address format\n"
1966 "OSPF area ID as a decimal value\n"
1967 "Enable authentication\n"
1968 "Use message-digest authentication\n")
1970 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1972 struct ospf_area
*area
;
1973 struct in_addr area_id
;
1976 argv_find(argv
, argc
, "area", &idx
);
1977 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx
+ 1]->arg
);
1979 area
= ospf_area_get(ospf
, area_id
);
1980 ospf_area_display_format_set(ospf
, area
, format
);
1981 area
->auth_type
= strmatch(argv
[0]->text
, "no")
1983 : OSPF_AUTH_CRYPTOGRAPHIC
;
1988 DEFUN (ospf_area_authentication
,
1989 ospf_area_authentication_cmd
,
1990 "area <A.B.C.D|(0-4294967295)> authentication",
1991 "OSPF area parameters\n"
1992 "OSPF area ID in IP address format\n"
1993 "OSPF area ID as a decimal value\n"
1994 "Enable authentication\n")
1996 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1997 int idx_ipv4_number
= 1;
1998 struct ospf_area
*area
;
1999 struct in_addr area_id
;
2002 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
2004 area
= ospf_area_get(ospf
, area_id
);
2005 ospf_area_display_format_set(ospf
, area
, format
);
2006 area
->auth_type
= OSPF_AUTH_SIMPLE
;
2011 DEFUN (no_ospf_area_authentication
,
2012 no_ospf_area_authentication_cmd
,
2013 "no area <A.B.C.D|(0-4294967295)> authentication",
2015 "OSPF area parameters\n"
2016 "OSPF area ID in IP address format\n"
2017 "OSPF area ID as a decimal value\n"
2018 "Enable authentication\n")
2020 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2021 int idx_ipv4_number
= 2;
2022 struct ospf_area
*area
;
2023 struct in_addr area_id
;
2026 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
2028 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
2032 area
->auth_type
= OSPF_AUTH_NULL
;
2034 ospf_area_check_free(ospf
, area_id
);
2040 DEFUN (ospf_abr_type
,
2042 "ospf abr-type <cisco|ibm|shortcut|standard>",
2043 "OSPF specific commands\n"
2044 "Set OSPF ABR type\n"
2045 "Alternative ABR, cisco implementation\n"
2046 "Alternative ABR, IBM implementation\n"
2048 "Standard behavior (RFC2328)\n")
2050 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2052 uint8_t abr_type
= OSPF_ABR_UNKNOWN
;
2054 if (strncmp(argv
[idx_vendor
]->arg
, "c", 1) == 0)
2055 abr_type
= OSPF_ABR_CISCO
;
2056 else if (strncmp(argv
[idx_vendor
]->arg
, "i", 1) == 0)
2057 abr_type
= OSPF_ABR_IBM
;
2058 else if (strncmp(argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2059 abr_type
= OSPF_ABR_SHORTCUT
;
2060 else if (strncmp(argv
[idx_vendor
]->arg
, "st", 2) == 0)
2061 abr_type
= OSPF_ABR_STAND
;
2063 return CMD_WARNING_CONFIG_FAILED
;
2065 /* If ABR type value is changed, schedule ABR task. */
2066 if (ospf
->abr_type
!= abr_type
) {
2067 ospf
->abr_type
= abr_type
;
2068 ospf_schedule_abr_task(ospf
);
2074 DEFUN (no_ospf_abr_type
,
2075 no_ospf_abr_type_cmd
,
2076 "no ospf abr-type <cisco|ibm|shortcut|standard>",
2078 "OSPF specific commands\n"
2079 "Set OSPF ABR type\n"
2080 "Alternative ABR, cisco implementation\n"
2081 "Alternative ABR, IBM implementation\n"
2085 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2087 uint8_t abr_type
= OSPF_ABR_UNKNOWN
;
2089 if (strncmp(argv
[idx_vendor
]->arg
, "c", 1) == 0)
2090 abr_type
= OSPF_ABR_CISCO
;
2091 else if (strncmp(argv
[idx_vendor
]->arg
, "i", 1) == 0)
2092 abr_type
= OSPF_ABR_IBM
;
2093 else if (strncmp(argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2094 abr_type
= OSPF_ABR_SHORTCUT
;
2095 else if (strncmp(argv
[idx_vendor
]->arg
, "st", 2) == 0)
2096 abr_type
= OSPF_ABR_STAND
;
2098 return CMD_WARNING_CONFIG_FAILED
;
2100 /* If ABR type value is changed, schedule ABR task. */
2101 if (ospf
->abr_type
== abr_type
) {
2102 ospf
->abr_type
= OSPF_ABR_DEFAULT
;
2103 ospf_schedule_abr_task(ospf
);
2109 DEFUN (ospf_log_adjacency_changes
,
2110 ospf_log_adjacency_changes_cmd
,
2111 "log-adjacency-changes",
2112 "Log changes in adjacency state\n")
2114 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2116 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2117 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2121 DEFUN (ospf_log_adjacency_changes_detail
,
2122 ospf_log_adjacency_changes_detail_cmd
,
2123 "log-adjacency-changes detail",
2124 "Log changes in adjacency state\n"
2125 "Log all state changes\n")
2127 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2129 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2130 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2134 DEFUN (no_ospf_log_adjacency_changes
,
2135 no_ospf_log_adjacency_changes_cmd
,
2136 "no log-adjacency-changes",
2138 "Log changes in adjacency state\n")
2140 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2142 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2143 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2147 DEFUN (no_ospf_log_adjacency_changes_detail
,
2148 no_ospf_log_adjacency_changes_detail_cmd
,
2149 "no log-adjacency-changes detail",
2151 "Log changes in adjacency state\n"
2152 "Log all state changes\n")
2154 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2156 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2160 DEFUN (ospf_compatible_rfc1583
,
2161 ospf_compatible_rfc1583_cmd
,
2162 "compatible rfc1583",
2163 "OSPF compatibility list\n"
2164 "compatible with RFC 1583\n")
2166 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2168 if (!CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)) {
2169 SET_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2170 ospf_spf_calculate_schedule(ospf
, SPF_FLAG_CONFIG_CHANGE
);
2175 DEFUN (no_ospf_compatible_rfc1583
,
2176 no_ospf_compatible_rfc1583_cmd
,
2177 "no compatible rfc1583",
2179 "OSPF compatibility list\n"
2180 "compatible with RFC 1583\n")
2182 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2184 if (CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)) {
2185 UNSET_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2186 ospf_spf_calculate_schedule(ospf
, SPF_FLAG_CONFIG_CHANGE
);
2191 ALIAS(ospf_compatible_rfc1583
, ospf_rfc1583_flag_cmd
,
2192 "ospf rfc1583compatibility",
2193 "OSPF specific commands\n"
2194 "Enable the RFC1583Compatibility flag\n")
2196 ALIAS(no_ospf_compatible_rfc1583
, no_ospf_rfc1583_flag_cmd
,
2197 "no ospf rfc1583compatibility", NO_STR
2198 "OSPF specific commands\n"
2199 "Disable the RFC1583Compatibility flag\n")
2201 static void ospf_table_reinstall_routes(struct ospf
*ospf
,
2202 struct route_table
*rt
)
2204 struct route_node
*rn
;
2209 for (rn
= route_top(rt
); rn
; rn
= route_next(rn
)) {
2210 struct ospf_route
*or;
2216 if (or->type
== OSPF_DESTINATION_NETWORK
)
2217 ospf_zebra_add(ospf
, (struct prefix_ipv4
*)&rn
->p
, or);
2218 else if (or->type
== OSPF_DESTINATION_DISCARD
)
2219 ospf_zebra_add_discard(ospf
,
2220 (struct prefix_ipv4
*)&rn
->p
);
2224 static void ospf_reinstall_routes(struct ospf
*ospf
)
2226 ospf_table_reinstall_routes(ospf
, ospf
->new_table
);
2227 ospf_table_reinstall_routes(ospf
, ospf
->new_external_route
);
2230 DEFPY (ospf_send_extra_data
,
2231 ospf_send_extra_data_cmd
,
2232 "[no] ospf send-extra-data zebra",
2235 "Extra data to Zebra for display/use\n"
2238 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2240 if (no
&& CHECK_FLAG(ospf
->config
, OSPF_SEND_EXTRA_DATA_TO_ZEBRA
)) {
2241 UNSET_FLAG(ospf
->config
, OSPF_SEND_EXTRA_DATA_TO_ZEBRA
);
2242 ospf_reinstall_routes(ospf
);
2243 } else if (!CHECK_FLAG(ospf
->config
, OSPF_SEND_EXTRA_DATA_TO_ZEBRA
)) {
2244 SET_FLAG(ospf
->config
, OSPF_SEND_EXTRA_DATA_TO_ZEBRA
);
2245 ospf_reinstall_routes(ospf
);
2251 static int ospf_timers_spf_set(struct vty
*vty
, unsigned int delay
,
2252 unsigned int hold
, unsigned int max
)
2254 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2256 ospf
->spf_delay
= delay
;
2257 ospf
->spf_holdtime
= hold
;
2258 ospf
->spf_max_holdtime
= max
;
2263 DEFUN (ospf_timers_min_ls_interval
,
2264 ospf_timers_min_ls_interval_cmd
,
2265 "timers throttle lsa all (0-5000)",
2266 "Adjust routing timers\n"
2267 "Throttling adaptive timer\n"
2268 "LSA delay between transmissions\n"
2270 "Delay (msec) between sending LSAs\n")
2272 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2274 unsigned int interval
;
2277 vty_out(vty
, "Insufficient arguments\n");
2278 return CMD_WARNING_CONFIG_FAILED
;
2281 interval
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2283 ospf
->min_ls_interval
= interval
;
2288 DEFUN (no_ospf_timers_min_ls_interval
,
2289 no_ospf_timers_min_ls_interval_cmd
,
2290 "no timers throttle lsa all [(0-5000)]",
2292 "Adjust routing timers\n"
2293 "Throttling adaptive timer\n"
2294 "LSA delay between transmissions\n"
2296 "Delay (msec) between sending LSAs\n")
2298 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2299 ospf
->min_ls_interval
= OSPF_MIN_LS_INTERVAL
;
2304 DEFUN (ospf_timers_throttle_spf
,
2305 ospf_timers_throttle_spf_cmd
,
2306 "timers throttle spf (0-600000) (0-600000) (0-600000)",
2307 "Adjust routing timers\n"
2308 "Throttling adaptive timer\n"
2310 "Delay (msec) from first change received till SPF calculation\n"
2311 "Initial hold time (msec) between consecutive SPF calculations\n"
2312 "Maximum hold time (msec)\n")
2315 int idx_number_2
= 4;
2316 int idx_number_3
= 5;
2317 unsigned int delay
, hold
, max
;
2320 vty_out(vty
, "Insufficient arguments\n");
2321 return CMD_WARNING_CONFIG_FAILED
;
2324 delay
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2325 hold
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
2326 max
= strtoul(argv
[idx_number_3
]->arg
, NULL
, 10);
2328 return ospf_timers_spf_set(vty
, delay
, hold
, max
);
2331 DEFUN (no_ospf_timers_throttle_spf
,
2332 no_ospf_timers_throttle_spf_cmd
,
2333 "no timers throttle spf [(0-600000)(0-600000)(0-600000)]",
2335 "Adjust routing timers\n"
2336 "Throttling adaptive timer\n"
2338 "Delay (msec) from first change received till SPF calculation\n"
2339 "Initial hold time (msec) between consecutive SPF calculations\n"
2340 "Maximum hold time (msec)\n")
2342 return ospf_timers_spf_set(vty
, OSPF_SPF_DELAY_DEFAULT
,
2343 OSPF_SPF_HOLDTIME_DEFAULT
,
2344 OSPF_SPF_MAX_HOLDTIME_DEFAULT
);
2348 DEFUN (ospf_timers_lsa_min_arrival
,
2349 ospf_timers_lsa_min_arrival_cmd
,
2350 "timers lsa min-arrival (0-600000)",
2351 "Adjust routing timers\n"
2353 "Minimum delay in receiving new version of a LSA\n"
2354 "Delay in milliseconds\n")
2356 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2357 ospf
->min_ls_arrival
= strtoul(argv
[argc
- 1]->arg
, NULL
, 10);
2361 DEFUN (no_ospf_timers_lsa_min_arrival
,
2362 no_ospf_timers_lsa_min_arrival_cmd
,
2363 "no timers lsa min-arrival [(0-600000)]",
2365 "Adjust routing timers\n"
2367 "Minimum delay in receiving new version of a LSA\n"
2368 "Delay in milliseconds\n")
2370 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2371 unsigned int minarrival
;
2374 minarrival
= strtoul(argv
[argc
- 1]->arg
, NULL
, 10);
2376 if (ospf
->min_ls_arrival
!= minarrival
2377 || minarrival
== OSPF_MIN_LS_ARRIVAL
)
2381 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2386 DEFUN (ospf_neighbor
,
2388 "neighbor A.B.C.D [priority (0-255) [poll-interval (1-65535)]]",
2390 "Neighbor IP address\n"
2391 "Neighbor Priority\n"
2393 "Dead Neighbor Polling interval\n"
2396 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2400 struct in_addr nbr_addr
;
2401 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2402 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2404 if (!inet_aton(argv
[idx_ipv4
]->arg
, &nbr_addr
)) {
2405 vty_out(vty
, "Please specify Neighbor ID by A.B.C.D\n");
2406 return CMD_WARNING_CONFIG_FAILED
;
2410 priority
= strtoul(argv
[idx_pri
]->arg
, NULL
, 10);
2413 interval
= strtoul(argv
[idx_poll
]->arg
, NULL
, 10);
2415 ospf_nbr_nbma_set(ospf
, nbr_addr
);
2418 ospf_nbr_nbma_priority_set(ospf
, nbr_addr
, priority
);
2421 ospf_nbr_nbma_poll_interval_set(ospf
, nbr_addr
, interval
);
2426 DEFUN (ospf_neighbor_poll_interval
,
2427 ospf_neighbor_poll_interval_cmd
,
2428 "neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2430 "Neighbor IP address\n"
2431 "Dead Neighbor Polling interval\n"
2433 "OSPF priority of non-broadcast neighbor\n"
2436 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2440 struct in_addr nbr_addr
;
2441 unsigned int priority
;
2442 unsigned int interval
;
2444 if (!inet_aton(argv
[idx_ipv4
]->arg
, &nbr_addr
)) {
2445 vty_out(vty
, "Please specify Neighbor ID by A.B.C.D\n");
2446 return CMD_WARNING_CONFIG_FAILED
;
2449 interval
= strtoul(argv
[idx_poll
]->arg
, NULL
, 10);
2451 priority
= argc
> 4 ? strtoul(argv
[idx_pri
]->arg
, NULL
, 10)
2452 : OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2454 ospf_nbr_nbma_set(ospf
, nbr_addr
);
2455 ospf_nbr_nbma_poll_interval_set(ospf
, nbr_addr
, interval
);
2458 ospf_nbr_nbma_priority_set(ospf
, nbr_addr
, priority
);
2463 DEFUN (no_ospf_neighbor
,
2464 no_ospf_neighbor_cmd
,
2465 "no neighbor A.B.C.D [priority (0-255) [poll-interval (1-65525)]]",
2468 "Neighbor IP address\n"
2469 "Neighbor Priority\n"
2471 "Dead Neighbor Polling interval\n"
2474 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2476 struct in_addr nbr_addr
;
2478 if (!inet_aton(argv
[idx_ipv4
]->arg
, &nbr_addr
)) {
2479 vty_out(vty
, "Please specify Neighbor ID by A.B.C.D\n");
2480 return CMD_WARNING_CONFIG_FAILED
;
2483 (void)ospf_nbr_nbma_unset(ospf
, nbr_addr
);
2488 DEFUN (no_ospf_neighbor_poll
,
2489 no_ospf_neighbor_poll_cmd
,
2490 "no neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2493 "Neighbor IP address\n"
2494 "Dead Neighbor Polling interval\n"
2496 "Neighbor Priority\n"
2499 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2501 struct in_addr nbr_addr
;
2503 if (!inet_aton(argv
[idx_ipv4
]->arg
, &nbr_addr
)) {
2504 vty_out(vty
, "Please specify Neighbor ID by A.B.C.D\n");
2505 return CMD_WARNING_CONFIG_FAILED
;
2508 (void)ospf_nbr_nbma_unset(ospf
, nbr_addr
);
2513 DEFUN (ospf_refresh_timer
,
2514 ospf_refresh_timer_cmd
,
2515 "refresh timer (10-1800)",
2516 "Adjust refresh parameters\n"
2517 "Set refresh timer\n"
2518 "Timer value in seconds\n")
2520 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2522 unsigned int interval
;
2524 interval
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2525 interval
= (interval
/ OSPF_LSA_REFRESHER_GRANULARITY
)
2526 * OSPF_LSA_REFRESHER_GRANULARITY
;
2528 ospf_timers_refresh_set(ospf
, interval
);
2533 DEFUN (no_ospf_refresh_timer
,
2534 no_ospf_refresh_timer_val_cmd
,
2535 "no refresh timer [(10-1800)]",
2537 "Adjust refresh parameters\n"
2538 "Unset refresh timer\n"
2539 "Timer value in seconds\n")
2541 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2543 unsigned int interval
;
2546 interval
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2548 if (ospf
->lsa_refresh_interval
!= interval
2549 || interval
== OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
2553 ospf_timers_refresh_unset(ospf
);
2559 DEFUN (ospf_auto_cost_reference_bandwidth
,
2560 ospf_auto_cost_reference_bandwidth_cmd
,
2561 "auto-cost reference-bandwidth (1-4294967)",
2562 "Calculate OSPF interface cost according to bandwidth\n"
2563 "Use reference bandwidth method to assign OSPF cost\n"
2564 "The reference bandwidth in terms of Mbits per second\n")
2566 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2567 struct vrf
*vrf
= vrf_lookup_by_id(ospf
->vrf_id
);
2570 struct interface
*ifp
;
2572 refbw
= strtol(argv
[idx_number
]->arg
, NULL
, 10);
2573 if (refbw
< 1 || refbw
> 4294967) {
2574 vty_out(vty
, "reference-bandwidth value is invalid\n");
2575 return CMD_WARNING_CONFIG_FAILED
;
2578 /* If reference bandwidth is changed. */
2579 if ((refbw
) == ospf
->ref_bandwidth
)
2582 ospf
->ref_bandwidth
= refbw
;
2583 FOR_ALL_INTERFACES (vrf
, ifp
)
2584 ospf_if_recalculate_output_cost(ifp
);
2589 DEFUN (no_ospf_auto_cost_reference_bandwidth
,
2590 no_ospf_auto_cost_reference_bandwidth_cmd
,
2591 "no auto-cost reference-bandwidth [(1-4294967)]",
2593 "Calculate OSPF interface cost according to bandwidth\n"
2594 "Use reference bandwidth method to assign OSPF cost\n"
2595 "The reference bandwidth in terms of Mbits per second\n")
2597 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2598 struct vrf
*vrf
= vrf_lookup_by_id(ospf
->vrf_id
);
2599 struct interface
*ifp
;
2601 if (ospf
->ref_bandwidth
== OSPF_DEFAULT_REF_BANDWIDTH
)
2604 ospf
->ref_bandwidth
= OSPF_DEFAULT_REF_BANDWIDTH
;
2605 vty_out(vty
, "%% OSPF: Reference bandwidth is changed.\n");
2607 " Please ensure reference bandwidth is consistent across all routers\n");
2609 FOR_ALL_INTERFACES (vrf
, ifp
)
2610 ospf_if_recalculate_output_cost(ifp
);
2615 DEFUN (ospf_write_multiplier
,
2616 ospf_write_multiplier_cmd
,
2617 "ospf write-multiplier (1-100)",
2618 "OSPF specific commands\n"
2619 "Write multiplier\n"
2620 "Maximum number of interface serviced per write\n")
2622 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2624 uint32_t write_oi_count
;
2631 write_oi_count
= strtol(argv
[idx_number
]->arg
, NULL
, 10);
2632 if (write_oi_count
< 1 || write_oi_count
> 100) {
2633 vty_out(vty
, "write-multiplier value is invalid\n");
2634 return CMD_WARNING_CONFIG_FAILED
;
2637 ospf
->write_oi_count
= write_oi_count
;
2641 ALIAS(ospf_write_multiplier
, write_multiplier_cmd
, "write-multiplier (1-100)",
2642 "Write multiplier\n"
2643 "Maximum number of interface serviced per write\n")
2645 DEFUN (no_ospf_write_multiplier
,
2646 no_ospf_write_multiplier_cmd
,
2647 "no ospf write-multiplier (1-100)",
2649 "OSPF specific commands\n"
2650 "Write multiplier\n"
2651 "Maximum number of interface serviced per write\n")
2653 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2655 ospf
->write_oi_count
= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
;
2659 ALIAS(no_ospf_write_multiplier
, no_write_multiplier_cmd
,
2660 "no write-multiplier (1-100)", NO_STR
2661 "Write multiplier\n"
2662 "Maximum number of interface serviced per write\n")
2664 DEFUN(ospf_ti_lfa
, ospf_ti_lfa_cmd
, "fast-reroute ti-lfa [node-protection]",
2665 "Fast Reroute for MPLS and IP resilience\n"
2666 "Topology Independent LFA (Loop-Free Alternate)\n"
2667 "TI-LFA node protection (default is link protection)\n")
2669 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2671 ospf
->ti_lfa_enabled
= true;
2674 ospf
->ti_lfa_protection_type
= OSPF_TI_LFA_NODE_PROTECTION
;
2676 ospf
->ti_lfa_protection_type
= OSPF_TI_LFA_LINK_PROTECTION
;
2678 ospf_spf_calculate_schedule(ospf
, SPF_FLAG_CONFIG_CHANGE
);
2683 DEFUN(no_ospf_ti_lfa
, no_ospf_ti_lfa_cmd
,
2684 "no fast-reroute ti-lfa [node-protection]",
2686 "Fast Reroute for MPLS and IP resilience\n"
2687 "Topology Independent LFA (Loop-Free Alternate)\n"
2688 "TI-LFA node protection (default is link protection)\n")
2690 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2692 ospf
->ti_lfa_enabled
= false;
2694 ospf
->ti_lfa_protection_type
= OSPF_TI_LFA_UNDEFINED_PROTECTION
;
2696 ospf_spf_calculate_schedule(ospf
, SPF_FLAG_CONFIG_CHANGE
);
2701 static void ospf_maxpath_set(struct vty
*vty
, struct ospf
*ospf
, uint16_t paths
)
2703 if (ospf
->max_multipath
== paths
)
2706 ospf
->max_multipath
= paths
;
2708 /* Send deletion notification to zebra to delete all
2709 * ospf specific routes and reinitiat SPF to reflect
2710 * the new max multipath.
2712 ospf_restart_spf(ospf
);
2715 /* Ospf Maximum multiple paths config support */
2716 DEFUN (ospf_max_multipath
,
2717 ospf_max_multipath_cmd
,
2718 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2719 "Max no of multiple paths for ECMP support\n"
2720 "Number of paths\n")
2722 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2726 maxpaths
= strtol(argv
[idx_number
]->arg
, NULL
, 10);
2728 ospf_maxpath_set(vty
, ospf
, maxpaths
);
2732 DEFUN (no_ospf_max_multipath
,
2733 no_ospf_max_multipath_cmd
,
2736 "Max no of multiple paths for ECMP support\n")
2738 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2739 uint16_t maxpaths
= MULTIPATH_NUM
;
2741 ospf_maxpath_set(vty
, ospf
, maxpaths
);
2745 static const char *const ospf_abr_type_descr_str
[] = {
2746 "Unknown", "Standard (RFC2328)", "Alternative IBM",
2747 "Alternative Cisco", "Alternative Shortcut"
2750 static const char *const ospf_shortcut_mode_descr_str
[] = {
2751 "Default", "Enabled", "Disabled"
2754 static void show_ip_ospf_area(struct vty
*vty
, struct ospf_area
*area
,
2755 json_object
*json_areas
, bool use_json
)
2757 json_object
*json_area
= NULL
;
2758 char buf
[PREFIX_STRLEN
];
2761 json_area
= json_object_new_object();
2765 vty_out(vty
, " Area ID: %pI4", &area
->area_id
);
2767 /* Show Area type/mode. */
2768 if (OSPF_IS_AREA_BACKBONE(area
)) {
2770 json_object_boolean_true_add(json_area
, "backbone");
2772 vty_out(vty
, " (Backbone)\n");
2775 if (area
->external_routing
== OSPF_AREA_STUB
) {
2776 if (area
->no_summary
)
2777 json_object_boolean_true_add(
2778 json_area
, "stubNoSummary");
2779 if (area
->shortcut_configured
)
2780 json_object_boolean_true_add(
2781 json_area
, "stubShortcut");
2782 } else if (area
->external_routing
== OSPF_AREA_NSSA
) {
2783 if (area
->no_summary
)
2784 json_object_boolean_true_add(
2785 json_area
, "nssaNoSummary");
2786 if (area
->shortcut_configured
)
2787 json_object_boolean_true_add(
2788 json_area
, "nssaShortcut");
2791 json_object_string_add(
2792 json_area
, "shortcuttingMode",
2793 ospf_shortcut_mode_descr_str
2794 [area
->shortcut_configured
]);
2795 if (area
->shortcut_capability
)
2796 json_object_boolean_true_add(json_area
,
2799 if (area
->external_routing
== OSPF_AREA_STUB
)
2800 vty_out(vty
, " (Stub%s%s)",
2801 area
->no_summary
? ", no summary" : "",
2802 area
->shortcut_configured
? "; " : "");
2803 else if (area
->external_routing
== OSPF_AREA_NSSA
)
2804 vty_out(vty
, " (NSSA%s%s)",
2805 area
->no_summary
? ", no summary" : "",
2806 area
->shortcut_configured
? "; " : "");
2809 vty_out(vty
, " Shortcutting mode: %s",
2810 ospf_shortcut_mode_descr_str
2811 [area
->shortcut_configured
]);
2812 vty_out(vty
, ", S-bit consensus: %s\n",
2813 area
->shortcut_capability
? "ok" : "no");
2817 /* Show number of interfaces */
2819 json_object_int_add(json_area
, "areaIfTotalCounter",
2820 listcount(area
->oiflist
));
2821 json_object_int_add(json_area
, "areaIfActiveCounter",
2825 " Number of interfaces in this area: Total: %d, Active: %d\n",
2826 listcount(area
->oiflist
), area
->act_ints
);
2828 if (area
->external_routing
== OSPF_AREA_NSSA
) {
2830 json_object_boolean_true_add(json_area
, "nssa");
2831 if (!IS_OSPF_ABR(area
->ospf
))
2832 json_object_boolean_false_add(json_area
, "abr");
2833 else if (area
->NSSATranslatorState
) {
2834 json_object_boolean_true_add(json_area
, "abr");
2835 if (area
->NSSATranslatorRole
2836 == OSPF_NSSA_ROLE_CANDIDATE
)
2837 json_object_boolean_true_add(
2839 "nssaTranslatorElected");
2840 else if (area
->NSSATranslatorRole
2841 == OSPF_NSSA_ROLE_ALWAYS
)
2842 json_object_boolean_true_add(
2844 "nssaTranslatorAlways");
2846 json_object_boolean_true_add(
2848 "nssaTranslatorNever");
2850 json_object_boolean_true_add(json_area
, "abr");
2851 if (area
->NSSATranslatorRole
2852 == OSPF_NSSA_ROLE_CANDIDATE
)
2853 json_object_boolean_false_add(
2855 "nssaTranslatorElected");
2857 json_object_boolean_true_add(
2859 "nssaTranslatorNever");
2863 " It is an NSSA configuration.\n Elected NSSA/ABR performs type-7/type-5 LSA translation.\n");
2864 if (!IS_OSPF_ABR(area
->ospf
))
2866 " It is not ABR, therefore not Translator.\n");
2867 else if (area
->NSSATranslatorState
) {
2868 vty_out(vty
, " We are an ABR and ");
2869 if (area
->NSSATranslatorRole
2870 == OSPF_NSSA_ROLE_CANDIDATE
)
2872 "the NSSA Elected Translator.\n");
2873 else if (area
->NSSATranslatorRole
2874 == OSPF_NSSA_ROLE_ALWAYS
)
2876 "always an NSSA Translator.\n");
2879 "never an NSSA Translator.\n");
2881 vty_out(vty
, " We are an ABR, but ");
2882 if (area
->NSSATranslatorRole
2883 == OSPF_NSSA_ROLE_CANDIDATE
)
2885 "not the NSSA Elected Translator.\n");
2888 "never an NSSA Translator.\n");
2893 /* Stub-router state for this area */
2894 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
)) {
2895 char timebuf
[OSPF_TIME_DUMP_SIZE
];
2898 json_object_boolean_true_add(
2899 json_area
, "originStubMaxDistRouterLsa");
2900 if (CHECK_FLAG(area
->stub_router_state
,
2901 OSPF_AREA_ADMIN_STUB_ROUTED
))
2902 json_object_boolean_true_add(
2903 json_area
, "indefiniteActiveAdmin");
2904 if (area
->t_stub_router
) {
2908 &area
->t_stub_router
->u
.sands
,
2911 json_object_int_add(
2913 "activeStartupRemainderMsecs",
2918 " Originating stub / maximum-distance Router-LSA\n");
2919 if (CHECK_FLAG(area
->stub_router_state
,
2920 OSPF_AREA_ADMIN_STUB_ROUTED
))
2922 " Administratively activated (indefinitely)\n");
2923 if (area
->t_stub_router
)
2925 " Active from startup, %s remaining\n",
2926 ospf_timer_dump(area
->t_stub_router
,
2933 /* Show number of fully adjacent neighbors. */
2934 json_object_int_add(json_area
, "nbrFullAdjacentCounter",
2937 /* Show authentication type. */
2938 if (area
->auth_type
== OSPF_AUTH_NULL
)
2939 json_object_string_add(json_area
, "authentication",
2940 "authenticationNone");
2941 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
2942 json_object_string_add(json_area
, "authentication",
2943 "authenticationSimplePassword");
2944 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
2945 json_object_string_add(json_area
, "authentication",
2946 "authenticationMessageDigest");
2948 if (!OSPF_IS_AREA_BACKBONE(area
))
2949 json_object_int_add(json_area
,
2950 "virtualAdjacenciesPassingCounter",
2953 /* Show SPF calculation times. */
2954 json_object_int_add(json_area
, "spfExecutedCounter",
2955 area
->spf_calculation
);
2956 json_object_int_add(json_area
, "lsaNumber", area
->lsdb
->total
);
2957 json_object_int_add(
2958 json_area
, "lsaRouterNumber",
2959 ospf_lsdb_count(area
->lsdb
, OSPF_ROUTER_LSA
));
2960 json_object_int_add(
2961 json_area
, "lsaRouterChecksum",
2962 ospf_lsdb_checksum(area
->lsdb
, OSPF_ROUTER_LSA
));
2963 json_object_int_add(
2964 json_area
, "lsaNetworkNumber",
2965 ospf_lsdb_count(area
->lsdb
, OSPF_NETWORK_LSA
));
2966 json_object_int_add(
2967 json_area
, "lsaNetworkChecksum",
2968 ospf_lsdb_checksum(area
->lsdb
, OSPF_NETWORK_LSA
));
2969 json_object_int_add(
2970 json_area
, "lsaSummaryNumber",
2971 ospf_lsdb_count(area
->lsdb
, OSPF_SUMMARY_LSA
));
2972 json_object_int_add(
2973 json_area
, "lsaSummaryChecksum",
2974 ospf_lsdb_checksum(area
->lsdb
, OSPF_SUMMARY_LSA
));
2975 json_object_int_add(
2976 json_area
, "lsaAsbrNumber",
2977 ospf_lsdb_count(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2978 json_object_int_add(
2979 json_area
, "lsaAsbrChecksum",
2980 ospf_lsdb_checksum(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2981 json_object_int_add(
2982 json_area
, "lsaNssaNumber",
2983 ospf_lsdb_count(area
->lsdb
, OSPF_AS_NSSA_LSA
));
2984 json_object_int_add(
2985 json_area
, "lsaNssaChecksum",
2986 ospf_lsdb_checksum(area
->lsdb
, OSPF_AS_NSSA_LSA
));
2988 /* Show number of fully adjacent neighbors. */
2990 " Number of fully adjacent neighbors in this area: %d\n",
2993 /* Show authentication type. */
2994 vty_out(vty
, " Area has ");
2995 if (area
->auth_type
== OSPF_AUTH_NULL
)
2996 vty_out(vty
, "no authentication\n");
2997 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
2998 vty_out(vty
, "simple password authentication\n");
2999 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
3000 vty_out(vty
, "message digest authentication\n");
3002 if (!OSPF_IS_AREA_BACKBONE(area
))
3004 " Number of full virtual adjacencies going through this area: %d\n",
3007 /* Show SPF calculation times. */
3008 vty_out(vty
, " SPF algorithm executed %d times\n",
3009 area
->spf_calculation
);
3011 /* Show number of LSA. */
3012 vty_out(vty
, " Number of LSA %ld\n", area
->lsdb
->total
);
3014 " Number of router LSA %ld. Checksum Sum 0x%08x\n",
3015 ospf_lsdb_count(area
->lsdb
, OSPF_ROUTER_LSA
),
3016 ospf_lsdb_checksum(area
->lsdb
, OSPF_ROUTER_LSA
));
3018 " Number of network LSA %ld. Checksum Sum 0x%08x\n",
3019 ospf_lsdb_count(area
->lsdb
, OSPF_NETWORK_LSA
),
3020 ospf_lsdb_checksum(area
->lsdb
, OSPF_NETWORK_LSA
));
3022 " Number of summary LSA %ld. Checksum Sum 0x%08x\n",
3023 ospf_lsdb_count(area
->lsdb
, OSPF_SUMMARY_LSA
),
3024 ospf_lsdb_checksum(area
->lsdb
, OSPF_SUMMARY_LSA
));
3026 " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x\n",
3027 ospf_lsdb_count(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
),
3028 ospf_lsdb_checksum(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
3029 vty_out(vty
, " Number of NSSA LSA %ld. Checksum Sum 0x%08x\n",
3030 ospf_lsdb_count(area
->lsdb
, OSPF_AS_NSSA_LSA
),
3031 ospf_lsdb_checksum(area
->lsdb
, OSPF_AS_NSSA_LSA
));
3035 json_object_int_add(
3036 json_area
, "lsaOpaqueLinkNumber",
3037 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
3038 json_object_int_add(
3039 json_area
, "lsaOpaqueLinkChecksum",
3040 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
3041 json_object_int_add(
3042 json_area
, "lsaOpaqueAreaNumber",
3043 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
3044 json_object_int_add(
3045 json_area
, "lsaOpaqueAreaChecksum",
3046 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
3049 " Number of opaque link LSA %ld. Checksum Sum 0x%08x\n",
3050 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
),
3051 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
3053 " Number of opaque area LSA %ld. Checksum Sum 0x%08x\n",
3054 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
),
3055 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
3059 json_object_object_add(json_areas
,
3060 inet_ntop(AF_INET
, &area
->area_id
,
3067 static int show_ip_ospf_common(struct vty
*vty
, struct ospf
*ospf
,
3068 json_object
*json
, uint8_t use_vrf
)
3070 struct listnode
*node
, *nnode
;
3071 struct ospf_area
*area
;
3072 struct timeval result
;
3073 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3074 json_object
*json_vrf
= NULL
;
3075 json_object
*json_areas
= NULL
;
3079 json_vrf
= json_object_new_object();
3082 json_areas
= json_object_new_object();
3085 if (ospf
->instance
) {
3087 json_object_int_add(json
, "ospfInstance",
3090 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
3094 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
3096 /* Show Router ID. */
3098 json_object_string_addf(json_vrf
, "routerId", "%pI4",
3101 vty_out(vty
, " OSPF Routing Process, Router ID: %pI4\n",
3105 /* Graceful shutdown */
3106 if (ospf
->t_deferred_shutdown
) {
3111 &ospf
->t_deferred_shutdown
->u
.sands
,
3114 json_object_int_add(json_vrf
, "deferredShutdownMsecs",
3118 " Deferred shutdown in progress, %s remaining\n",
3119 ospf_timer_dump(ospf
->t_deferred_shutdown
,
3120 timebuf
, sizeof(timebuf
)));
3124 /* Show capability. */
3126 json_object_boolean_true_add(json_vrf
, "tosRoutesOnly");
3127 json_object_boolean_true_add(json_vrf
, "rfc2328Conform");
3128 if (CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)) {
3129 json_object_boolean_true_add(json_vrf
,
3130 "rfc1583Compatibility");
3133 vty_out(vty
, " Supports only single TOS (TOS0) routes\n");
3134 vty_out(vty
, " This implementation conforms to RFC2328\n");
3135 vty_out(vty
, " RFC1583Compatibility flag is %s\n",
3136 CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)
3142 if (CHECK_FLAG(ospf
->config
, OSPF_OPAQUE_CAPABLE
)) {
3143 json_object_boolean_true_add(json_vrf
, "opaqueCapable");
3146 vty_out(vty
, " OpaqueCapability flag is %s\n",
3147 CHECK_FLAG(ospf
->config
, OSPF_OPAQUE_CAPABLE
)
3152 /* Show stub-router configuration */
3153 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
3154 || ospf
->stub_router_shutdown_time
3155 != OSPF_STUB_ROUTER_UNCONFIGURED
) {
3157 json_object_boolean_true_add(json_vrf
,
3158 "stubAdvertisement");
3159 if (ospf
->stub_router_startup_time
3160 != OSPF_STUB_ROUTER_UNCONFIGURED
)
3161 json_object_int_add(
3162 json_vrf
, "postStartEnabledSecs",
3163 ospf
->stub_router_startup_time
);
3164 if (ospf
->stub_router_shutdown_time
3165 != OSPF_STUB_ROUTER_UNCONFIGURED
)
3166 json_object_int_add(
3167 json_vrf
, "preShutdownEnabledSecs",
3168 ospf
->stub_router_shutdown_time
);
3171 " Stub router advertisement is configured\n");
3172 if (ospf
->stub_router_startup_time
3173 != OSPF_STUB_ROUTER_UNCONFIGURED
)
3175 " Enabled for %us after start-up\n",
3176 ospf
->stub_router_startup_time
);
3177 if (ospf
->stub_router_shutdown_time
3178 != OSPF_STUB_ROUTER_UNCONFIGURED
)
3180 " Enabled for %us prior to full shutdown\n",
3181 ospf
->stub_router_shutdown_time
);
3185 /* Show SPF timers. */
3187 json_object_int_add(json_vrf
, "spfScheduleDelayMsecs",
3189 json_object_int_add(json_vrf
, "holdtimeMinMsecs",
3190 ospf
->spf_holdtime
);
3191 json_object_int_add(json_vrf
, "holdtimeMaxMsecs",
3192 ospf
->spf_max_holdtime
);
3193 json_object_int_add(json_vrf
, "holdtimeMultplier",
3194 ospf
->spf_hold_multiplier
);
3197 " Initial SPF scheduling delay %d millisec(s)\n"
3198 " Minimum hold time between consecutive SPFs %d millisec(s)\n"
3199 " Maximum hold time between consecutive SPFs %d millisec(s)\n"
3200 " Hold time multiplier is currently %d\n",
3201 ospf
->spf_delay
, ospf
->spf_holdtime
,
3202 ospf
->spf_max_holdtime
, ospf
->spf_hold_multiplier
);
3206 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
) {
3207 long time_store
= 0;
3210 monotime_since(&ospf
->ts_spf
, NULL
) / 1000LL;
3211 json_object_int_add(json_vrf
, "spfLastExecutedMsecs",
3214 time_store
= (1000 * ospf
->ts_spf_duration
.tv_sec
)
3215 + (ospf
->ts_spf_duration
.tv_usec
/ 1000);
3216 json_object_int_add(json_vrf
, "spfLastDurationMsecs",
3219 json_object_boolean_true_add(json_vrf
, "spfHasNotRun");
3221 vty_out(vty
, " SPF algorithm ");
3222 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
) {
3223 monotime_since(&ospf
->ts_spf
, &result
);
3224 vty_out(vty
, "last executed %s ago\n",
3225 ospf_timeval_dump(&result
, timebuf
,
3227 vty_out(vty
, " Last SPF duration %s\n",
3228 ospf_timeval_dump(&ospf
->ts_spf_duration
,
3229 timebuf
, sizeof(timebuf
)));
3231 vty_out(vty
, "has not been run\n");
3235 if (ospf
->t_spf_calc
) {
3238 monotime_until(&ospf
->t_spf_calc
->u
.sands
, NULL
)
3240 json_object_int_add(json_vrf
, "spfTimerDueInMsecs",
3244 json_object_int_add(json_vrf
, "lsaMinIntervalMsecs",
3245 ospf
->min_ls_interval
);
3246 json_object_int_add(json_vrf
, "lsaMinArrivalMsecs",
3247 ospf
->min_ls_arrival
);
3248 /* Show write multiplier values */
3249 json_object_int_add(json_vrf
, "writeMultiplier",
3250 ospf
->write_oi_count
);
3251 /* Show refresh parameters. */
3252 json_object_int_add(json_vrf
, "refreshTimerMsecs",
3253 ospf
->lsa_refresh_interval
* 1000);
3255 /* show max multipath */
3256 json_object_int_add(json_vrf
, "maximumPaths",
3257 ospf
->max_multipath
);
3259 /* show administrative distance */
3260 json_object_int_add(json_vrf
, "preference",
3262 ? ospf
->distance_all
3263 : ZEBRA_OSPF_DISTANCE_DEFAULT
);
3265 vty_out(vty
, " SPF timer %s%s\n",
3266 (ospf
->t_spf_calc
? "due in " : "is "),
3267 ospf_timer_dump(ospf
->t_spf_calc
, timebuf
,
3270 vty_out(vty
, " LSA minimum interval %d msecs\n",
3271 ospf
->min_ls_interval
);
3272 vty_out(vty
, " LSA minimum arrival %d msecs\n",
3273 ospf
->min_ls_arrival
);
3275 /* Show write multiplier values */
3276 vty_out(vty
, " Write Multiplier set to %d \n",
3277 ospf
->write_oi_count
);
3279 /* Show refresh parameters. */
3280 vty_out(vty
, " Refresh timer %d secs\n",
3281 ospf
->lsa_refresh_interval
);
3283 /* show max multipath */
3284 vty_out(vty
, " Maximum multiple paths(ECMP) supported %d\n",
3285 ospf
->max_multipath
);
3287 /* show administrative distance */
3288 vty_out(vty
, " Administrative distance %u\n",
3289 ospf
->distance_all
? ospf
->distance_all
3290 : ZEBRA_OSPF_DISTANCE_DEFAULT
);
3293 /* Show ABR/ASBR flags. */
3294 if (CHECK_FLAG(ospf
->flags
, OSPF_FLAG_ABR
)) {
3296 json_object_string_add(
3297 json_vrf
, "abrType",
3298 ospf_abr_type_descr_str
[ospf
->abr_type
]);
3301 " This router is an ABR, ABR type is: %s\n",
3302 ospf_abr_type_descr_str
[ospf
->abr_type
]);
3304 if (CHECK_FLAG(ospf
->flags
, OSPF_FLAG_ASBR
)) {
3306 json_object_string_add(
3307 json_vrf
, "asbrRouter",
3308 "injectingExternalRoutingInformation");
3311 " This router is an ASBR (injecting external routing information)\n");
3314 /* Show Number of AS-external-LSAs. */
3316 json_object_int_add(
3317 json_vrf
, "lsaExternalCounter",
3318 ospf_lsdb_count(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3319 json_object_int_add(
3320 json_vrf
, "lsaExternalChecksum",
3321 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3324 " Number of external LSA %ld. Checksum Sum 0x%08x\n",
3325 ospf_lsdb_count(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
),
3326 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3330 json_object_int_add(
3331 json_vrf
, "lsaAsopaqueCounter",
3332 ospf_lsdb_count(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3333 json_object_int_add(
3334 json_vrf
, "lsaAsOpaqueChecksum",
3335 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3338 " Number of opaque AS LSA %ld. Checksum Sum 0x%08x\n",
3339 ospf_lsdb_count(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
),
3340 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3343 /* Show number of areas attached. */
3345 json_object_int_add(json_vrf
, "attachedAreaCounter",
3346 listcount(ospf
->areas
));
3348 vty_out(vty
, " Number of areas attached to this router: %d\n",
3349 listcount(ospf
->areas
));
3351 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
)) {
3352 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
)) {
3354 json_object_boolean_true_add(
3355 json_vrf
, "adjacencyChangesLoggedAll");
3358 " All adjacency changes are logged\n");
3361 json_object_boolean_true_add(
3362 json_vrf
, "adjacencyChangesLogged");
3364 vty_out(vty
, " Adjacency changes are logged\n");
3368 /* show LDP-Sync status */
3369 ospf_ldp_sync_show_info(vty
, ospf
, json_vrf
, json
? 1 : 0);
3371 /* Show each area status. */
3372 for (ALL_LIST_ELEMENTS(ospf
->areas
, node
, nnode
, area
))
3373 show_ip_ospf_area(vty
, area
, json_areas
, json
? 1 : 0);
3377 json_object_object_add(json_vrf
, "areas", json_areas
);
3378 json_object_object_add(json
, ospf_get_name(ospf
),
3381 json_object_object_add(json
, "areas", json_areas
);
3389 DEFUN (show_ip_ospf
,
3391 "show ip ospf [vrf <NAME|all>] [json]",
3394 "OSPF information\n"
3400 bool uj
= use_json(argc
, argv
);
3401 struct listnode
*node
= NULL
;
3402 char *vrf_name
= NULL
;
3403 bool all_vrf
= false;
3404 int ret
= CMD_SUCCESS
;
3407 json_object
*json
= NULL
;
3408 uint8_t use_vrf
= 0;
3410 if (listcount(om
->ospf
) == 0)
3413 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
3416 json
= json_object_new_object();
3418 /* vrf input is provided could be all or specific vrf*/
3420 bool ospf_output
= false;
3425 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
3426 if (!ospf
->oi_running
)
3429 ret
= show_ip_ospf_common(vty
, ospf
, json
,
3433 vty_json(vty
, json
);
3434 else if (!ospf_output
)
3435 vty_out(vty
, "%% OSPF is not enabled\n");
3438 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
3439 if ((ospf
== NULL
) || !ospf
->oi_running
) {
3441 vty_json(vty
, json
);
3444 "%% OSPF is not enabled in vrf %s\n",
3450 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
3451 /* Display default ospf (instance 0) info */
3452 if (ospf
== NULL
|| !ospf
->oi_running
) {
3454 vty_json(vty
, json
);
3457 "%% OSPF is not enabled in vrf default\n");
3464 show_ip_ospf_common(vty
, ospf
, json
, use_vrf
);
3466 vty_out(vty
, "%s\n",
3467 json_object_to_json_string_ext(
3468 json
, JSON_C_TO_STRING_PRETTY
));
3472 json_object_free(json
);
3477 DEFUN (show_ip_ospf_instance
,
3478 show_ip_ospf_instance_cmd
,
3479 "show ip ospf (1-65535) [json]",
3482 "OSPF information\n"
3488 unsigned short instance
= 0;
3489 bool uj
= use_json(argc
, argv
);
3490 int ret
= CMD_SUCCESS
;
3491 json_object
*json
= NULL
;
3493 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3494 if (instance
!= ospf_instance
)
3495 return CMD_NOT_MY_INSTANCE
;
3497 ospf
= ospf_lookup_instance(instance
);
3498 if (!ospf
|| !ospf
->oi_running
)
3502 json
= json_object_new_object();
3504 ret
= show_ip_ospf_common(vty
, ospf
, json
, 0);
3507 vty_json(vty
, json
);
3512 static void ospf_interface_auth_show(struct vty
*vty
, struct ospf_interface
*oi
,
3513 json_object
*json
, bool use_json
)
3517 auth_type
= OSPF_IF_PARAM(oi
, auth_type
);
3519 switch (auth_type
) {
3520 case OSPF_AUTH_NULL
:
3522 json_object_string_add(json
, "authentication",
3523 "authenticationNone");
3525 vty_out(vty
, " Authentication NULL is enabled\n");
3527 case OSPF_AUTH_SIMPLE
: {
3529 json_object_string_add(json
, "authentication",
3530 "authenticationSimplePassword");
3533 " Simple password authentication enabled\n");
3536 case OSPF_AUTH_CRYPTOGRAPHIC
: {
3537 struct crypt_key
*ckey
;
3539 if (list_isempty(OSPF_IF_PARAM(oi
, auth_crypt
)))
3542 ckey
= listgetdata(listtail(OSPF_IF_PARAM(oi
, auth_crypt
)));
3545 json_object_string_add(json
, "authentication",
3546 "authenticationMessageDigest");
3549 " Cryptographic authentication enabled\n");
3550 vty_out(vty
, " Algorithm:MD5\n");
3560 static void show_ip_ospf_interface_sub(struct vty
*vty
, struct ospf
*ospf
,
3561 struct interface
*ifp
,
3562 json_object
*json_interface_sub
,
3566 struct ospf_neighbor
*nbr
;
3567 struct route_node
*rn
;
3568 uint32_t bandwidth
= ifp
->bandwidth
? ifp
->bandwidth
: ifp
->speed
;
3570 /* Is interface up? */
3572 is_up
= if_is_operative(ifp
);
3574 json_object_boolean_true_add(json_interface_sub
,
3577 json_object_boolean_false_add(json_interface_sub
,
3580 json_object_int_add(json_interface_sub
, "ifIndex",
3582 json_object_int_add(json_interface_sub
, "mtuBytes", ifp
->mtu
);
3583 json_object_int_add(json_interface_sub
, "bandwidthMbit",
3585 json_object_string_add(json_interface_sub
, "ifFlags",
3586 if_flag_dump(ifp
->flags
));
3588 vty_out(vty
, "%s is %s\n", ifp
->name
,
3589 ((is_up
= if_is_operative(ifp
)) ? "up" : "down"));
3590 vty_out(vty
, " ifindex %u, MTU %u bytes, BW %u Mbit %s\n",
3591 ifp
->ifindex
, ifp
->mtu
, bandwidth
,
3592 if_flag_dump(ifp
->flags
));
3595 /* Is interface OSPF enabled? */
3597 if (ospf_oi_count(ifp
) == 0) {
3598 json_object_boolean_false_add(json_interface_sub
,
3601 } else if (!is_up
) {
3602 json_object_boolean_false_add(json_interface_sub
,
3606 json_object_boolean_true_add(json_interface_sub
,
3609 if (ospf_oi_count(ifp
) == 0) {
3610 vty_out(vty
, " OSPF not enabled on this interface\n");
3612 } else if (!is_up
) {
3614 " OSPF is enabled, but not running on this interface\n");
3619 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
3620 struct ospf_interface
*oi
= rn
->info
;
3625 if (CHECK_FLAG(oi
->connected
->flags
, ZEBRA_IFA_UNNUMBERED
)) {
3627 json_object_boolean_true_add(json_interface_sub
,
3630 vty_out(vty
, " This interface is UNNUMBERED,");
3632 struct in_addr dest
;
3635 /* Show OSPF interface information. */
3637 json_object_string_addf(
3638 json_interface_sub
, "ipAddress", "%pI4",
3639 &oi
->address
->u
.prefix4
);
3640 json_object_int_add(json_interface_sub
,
3641 "ipAddressPrefixlen",
3642 oi
->address
->prefixlen
);
3644 vty_out(vty
, " Internet Address %pFX,",
3647 /* For Vlinks, showing the peer address is
3648 * probably more informative than the local
3649 * interface that is being used */
3650 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
) {
3652 dest
= oi
->vl_data
->peer_addr
;
3653 } else if (CONNECTED_PEER(oi
->connected
)
3654 && oi
->connected
->destination
) {
3656 dest
= oi
->connected
->destination
->u
.prefix4
;
3659 dest
.s_addr
= ipv4_broadcast_addr(
3660 oi
->connected
->address
->u
.prefix4
.s_addr
,
3661 oi
->connected
->address
->prefixlen
);
3665 json_object_string_add(
3667 "ospfIfType", dstr
);
3668 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3669 json_object_string_addf(
3670 json_interface_sub
, "vlinkPeer",
3673 json_object_string_addf(
3675 "localIfUsed", "%pI4", &dest
);
3677 vty_out(vty
, " %s %pI4,", dstr
,
3681 json_object_string_add(json_interface_sub
, "area",
3682 ospf_area_desc_string(oi
->area
));
3683 if (OSPF_IF_PARAM(oi
, mtu_ignore
))
3684 json_object_boolean_true_add(
3686 "mtuMismatchDetect");
3687 json_object_string_addf(json_interface_sub
, "routerId",
3688 "%pI4", &ospf
->router_id
);
3689 json_object_string_add(json_interface_sub
,
3691 ospf_network_type_str
[oi
->type
]);
3692 json_object_int_add(json_interface_sub
, "cost",
3694 json_object_int_add(
3695 json_interface_sub
, "transmitDelaySecs",
3696 OSPF_IF_PARAM(oi
, transmit_delay
));
3697 json_object_string_add(json_interface_sub
, "state",
3698 lookup_msg(ospf_ism_state_msg
,
3700 json_object_int_add(json_interface_sub
, "priority",
3703 vty_out(vty
, " Area %s\n",
3704 ospf_area_desc_string(oi
->area
));
3706 vty_out(vty
, " MTU mismatch detection: %s\n",
3707 OSPF_IF_PARAM(oi
, mtu_ignore
) ? "disabled"
3711 " Router ID %pI4, Network Type %s, Cost: %d\n",
3713 ospf_network_type_str
[oi
->type
],
3717 " Transmit Delay is %d sec, State %s, Priority %d\n",
3718 OSPF_IF_PARAM(oi
, transmit_delay
),
3719 lookup_msg(ospf_ism_state_msg
, oi
->state
, NULL
),
3723 /* Show DR information. */
3724 if (DR(oi
).s_addr
== INADDR_ANY
) {
3727 " No backup designated router on this network\n");
3729 nbr
= ospf_nbr_lookup_by_addr(oi
->nbrs
, &DR(oi
));
3732 json_object_string_addf(
3733 json_interface_sub
, "drId",
3734 "%pI4", &nbr
->router_id
);
3735 json_object_string_addf(
3736 json_interface_sub
, "drAddress",
3738 &nbr
->address
.u
.prefix4
);
3741 " Designated Router (ID) %pI4",
3744 " Interface Address %pFX\n",
3750 nbr
= ospf_nbr_lookup_by_addr(oi
->nbrs
, &BDR(oi
));
3754 " No backup designated router on this network\n");
3757 json_object_string_addf(
3758 json_interface_sub
, "bdrId",
3759 "%pI4", &nbr
->router_id
);
3760 json_object_string_addf(
3762 "bdrAddress", "%pI4",
3763 &nbr
->address
.u
.prefix4
);
3766 " Backup Designated Router (ID) %pI4,",
3768 vty_out(vty
, " Interface Address %pI4\n",
3769 &nbr
->address
.u
.prefix4
);
3774 /* Next network-LSA sequence number we'll use, if we're elected
3777 && ntohl(oi
->params
->network_lsa_seqnum
)
3778 != OSPF_INITIAL_SEQUENCE_NUMBER
) {
3780 json_object_int_add(
3782 "networkLsaSequence",
3783 ntohl(oi
->params
->network_lsa_seqnum
));
3786 " Saved Network-LSA sequence number 0x%x\n",
3787 ntohl(oi
->params
->network_lsa_seqnum
));
3791 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3792 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
)) {
3793 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3794 json_object_boolean_true_add(
3796 "mcastMemberOspfAllRouters");
3797 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3798 json_object_boolean_true_add(
3800 "mcastMemberOspfDesignatedRouters");
3803 vty_out(vty
, " Multicast group memberships:");
3804 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3805 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
)) {
3806 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3807 vty_out(vty
, " OSPFAllRouters");
3808 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3809 vty_out(vty
, " OSPFDesignatedRouters");
3811 vty_out(vty
, " <None>");
3816 if (OSPF_IF_PARAM(oi
, fast_hello
) == 0)
3817 json_object_int_add(
3818 json_interface_sub
, "timerMsecs",
3819 OSPF_IF_PARAM(oi
, v_hello
) * 1000);
3821 json_object_int_add(
3822 json_interface_sub
, "timerMsecs",
3823 1000 / OSPF_IF_PARAM(oi
, fast_hello
));
3824 json_object_int_add(json_interface_sub
,
3826 OSPF_IF_PARAM(oi
, v_wait
));
3827 json_object_int_add(json_interface_sub
,
3829 OSPF_IF_PARAM(oi
, v_wait
));
3830 json_object_int_add(
3831 json_interface_sub
, "timerRetransmitSecs",
3832 OSPF_IF_PARAM(oi
, retransmit_interval
));
3834 vty_out(vty
, " Timer intervals configured,");
3835 vty_out(vty
, " Hello ");
3836 if (OSPF_IF_PARAM(oi
, fast_hello
) == 0)
3837 vty_out(vty
, "%ds,",
3838 OSPF_IF_PARAM(oi
, v_hello
));
3840 vty_out(vty
, "%dms,",
3841 1000 / OSPF_IF_PARAM(oi
, fast_hello
));
3842 vty_out(vty
, " Dead %ds, Wait %ds, Retransmit %d\n",
3843 OSPF_IF_PARAM(oi
, v_wait
),
3844 OSPF_IF_PARAM(oi
, v_wait
),
3845 OSPF_IF_PARAM(oi
, retransmit_interval
));
3848 if (OSPF_IF_PASSIVE_STATUS(oi
) == OSPF_IF_ACTIVE
) {
3849 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3851 long time_store
= 0;
3855 &oi
->t_hello
->u
.sands
,
3858 json_object_int_add(json_interface_sub
,
3859 "timerHelloInMsecs",
3862 vty_out(vty
, " Hello due in %s\n",
3863 ospf_timer_dump(oi
->t_hello
, timebuf
,
3865 } else /* passive-interface is set */
3868 json_object_boolean_true_add(
3870 "timerPassiveIface");
3873 " No Hellos (Passive interface)\n");
3877 json_object_int_add(json_interface_sub
, "nbrCount",
3878 ospf_nbr_count(oi
, 0));
3879 json_object_int_add(json_interface_sub
,
3881 ospf_nbr_count(oi
, NSM_Full
));
3884 " Neighbor Count is %d, Adjacent neighbor count is %d\n",
3885 ospf_nbr_count(oi
, 0),
3886 ospf_nbr_count(oi
, NSM_Full
));
3888 ospf_interface_bfd_show(vty
, ifp
, json_interface_sub
);
3890 /* OSPF Authentication information */
3891 ospf_interface_auth_show(vty
, oi
, json_interface_sub
, use_json
);
3895 static int show_ip_ospf_interface_common(struct vty
*vty
, struct ospf
*ospf
,
3896 char *intf_name
, uint8_t use_vrf
,
3897 json_object
*json
, bool use_json
)
3899 struct interface
*ifp
;
3900 struct vrf
*vrf
= vrf_lookup_by_id(ospf
->vrf_id
);
3901 json_object
*json_vrf
= NULL
;
3902 json_object
*json_interface_sub
= NULL
, *json_interface
= NULL
;
3906 json_vrf
= json_object_new_object();
3909 json_interface
= json_object_new_object();
3912 if (ospf
->instance
) {
3914 json_object_int_add(json
, "ospfInstance",
3917 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
3920 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
3922 if (intf_name
== NULL
) {
3923 /* Show All Interfaces.*/
3924 FOR_ALL_INTERFACES (vrf
, ifp
) {
3925 if (ospf_oi_count(ifp
)) {
3927 json_interface_sub
=
3928 json_object_new_object();
3930 show_ip_ospf_interface_sub(vty
, ospf
, ifp
,
3935 json_object_object_add(
3936 json_interface
, ifp
->name
,
3937 json_interface_sub
);
3942 json_object_object_add(json_vrf
, "interfaces",
3945 /* Interface name is specified. */
3946 ifp
= if_lookup_by_name(intf_name
, ospf
->vrf_id
);
3949 json_object_boolean_true_add(json_vrf
,
3952 vty_out(vty
, "No such interface name\n");
3955 json_interface_sub
= json_object_new_object();
3956 json_interface
= json_object_new_object();
3959 show_ip_ospf_interface_sub(
3960 vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3963 json_object_object_add(json_interface
,
3965 json_interface_sub
);
3966 json_object_object_add(json_vrf
, "interfaces",
3974 json_object_object_add(json
, ospf_get_name(ospf
),
3983 static void show_ip_ospf_interface_traffic_sub(struct vty
*vty
,
3984 struct ospf_interface
*oi
,
3985 json_object
*json_interface_sub
,
3989 json_object_int_add(json_interface_sub
, "ifIndex",
3991 json_object_int_add(json_interface_sub
, "helloIn",
3993 json_object_int_add(json_interface_sub
, "helloOut",
3995 json_object_int_add(json_interface_sub
, "dbDescIn",
3997 json_object_int_add(json_interface_sub
, "dbDescOut",
3999 json_object_int_add(json_interface_sub
, "lsReqIn",
4001 json_object_int_add(json_interface_sub
, "lsReqOut",
4003 json_object_int_add(json_interface_sub
, "lsUpdIn",
4005 json_object_int_add(json_interface_sub
, "lsUpdOut",
4007 json_object_int_add(json_interface_sub
, "lsAckIn",
4009 json_object_int_add(json_interface_sub
, "lsAckOut",
4013 "%-10s %8u/%-8u %7u/%-7u %7u/%-7u %7u/%-7u %7u/%-7u\n",
4014 oi
->ifp
->name
, oi
->hello_in
, oi
->hello_out
,
4015 oi
->db_desc_in
, oi
->db_desc_out
, oi
->ls_req_in
,
4016 oi
->ls_req_out
, oi
->ls_upd_in
, oi
->ls_upd_out
,
4017 oi
->ls_ack_in
, oi
->ls_ack_out
);
4021 /* OSPFv2 Packet Counters */
4022 static int show_ip_ospf_interface_traffic_common(
4023 struct vty
*vty
, struct ospf
*ospf
, char *intf_name
, json_object
*json
,
4024 int display_once
, uint8_t use_vrf
, bool use_json
)
4026 struct vrf
*vrf
= NULL
;
4027 struct interface
*ifp
= NULL
;
4028 json_object
*json_vrf
= NULL
;
4029 json_object
*json_interface_sub
= NULL
;
4031 if (!use_json
&& !display_once
) {
4033 vty_out(vty
, "%-12s%-17s%-17s%-17s%-17s%-17s\n", "Interface",
4034 " HELLO", " DB-Desc", " LS-Req", " LS-Update",
4036 vty_out(vty
, "%-10s%-18s%-18s%-17s%-17s%-17s\n", "",
4037 " Rx/Tx", " Rx/Tx", " Rx/Tx", " Rx/Tx",
4040 "--------------------------------------------------------------------------------------------\n");
4041 } else if (use_json
) {
4043 json_vrf
= json_object_new_object();
4048 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
4050 if (intf_name
== NULL
) {
4051 vrf
= vrf_lookup_by_id(ospf
->vrf_id
);
4052 FOR_ALL_INTERFACES (vrf
, ifp
) {
4053 struct route_node
*rn
;
4054 struct ospf_interface
*oi
;
4056 if (ospf_oi_count(ifp
) == 0)
4059 for (rn
= route_top(IF_OIFS(ifp
)); rn
;
4060 rn
= route_next(rn
)) {
4067 json_interface_sub
=
4068 json_object_new_object();
4071 show_ip_ospf_interface_traffic_sub(
4072 vty
, oi
, json_interface_sub
, use_json
);
4074 json_object_object_add(
4075 json_vrf
, ifp
->name
,
4076 json_interface_sub
);
4081 /* Interface name is specified. */
4082 ifp
= if_lookup_by_name(intf_name
, ospf
->vrf_id
);
4084 struct route_node
*rn
;
4085 struct ospf_interface
*oi
;
4087 if (ospf_oi_count(ifp
) == 0) {
4089 " OSPF not enabled on this interface %s\n",
4094 for (rn
= route_top(IF_OIFS(ifp
)); rn
;
4095 rn
= route_next(rn
)) {
4099 json_interface_sub
=
4100 json_object_new_object();
4103 show_ip_ospf_interface_traffic_sub(
4104 vty
, oi
, json_interface_sub
, use_json
);
4106 json_object_object_add(
4107 json_vrf
, ifp
->name
,
4108 json_interface_sub
);
4116 json_object_object_add(json
, ospf_get_name(ospf
),
4124 DEFUN (show_ip_ospf_interface
,
4125 show_ip_ospf_interface_cmd
,
4126 "show ip ospf [vrf <NAME|all>] interface [INTERFACE] [json]",
4129 "OSPF information\n"
4132 "Interface information\n"
4137 bool uj
= use_json(argc
, argv
);
4138 struct listnode
*node
= NULL
;
4139 char *vrf_name
= NULL
, *intf_name
= NULL
;
4140 bool all_vrf
= false;
4141 int ret
= CMD_SUCCESS
;
4143 int idx_vrf
= 0, idx_intf
= 0;
4144 uint8_t use_vrf
= 0;
4145 json_object
*json
= NULL
;
4147 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
4149 if (argv_find(argv
, argc
, "INTERFACE", &idx_intf
))
4150 intf_name
= argv
[idx_intf
]->arg
;
4153 json
= json_object_new_object();
4155 /* vrf input is provided could be all or specific vrf*/
4159 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
4160 if (!ospf
->oi_running
)
4162 ret
= show_ip_ospf_interface_common(
4163 vty
, ospf
, intf_name
, use_vrf
, json
,
4168 vty_json(vty
, json
);
4170 vty_out(vty
, "%% OSPF is not enabled\n");
4174 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
4175 if (ospf
== NULL
|| !ospf
->oi_running
) {
4177 vty_json(vty
, json
);
4180 "%% OSPF is not enabled in vrf %s\n",
4185 ret
= show_ip_ospf_interface_common(vty
, ospf
, intf_name
,
4189 /* Display default ospf (instance 0) info */
4190 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
4191 if (ospf
== NULL
|| !ospf
->oi_running
) {
4193 vty_json(vty
, json
);
4196 "%% OSPF is not enabled in vrf default\n");
4200 ret
= show_ip_ospf_interface_common(vty
, ospf
, intf_name
,
4205 vty_json(vty
, json
);
4210 DEFUN (show_ip_ospf_instance_interface
,
4211 show_ip_ospf_instance_interface_cmd
,
4212 "show ip ospf (1-65535) interface [INTERFACE] [json]",
4215 "OSPF information\n"
4217 "Interface information\n"
4224 unsigned short instance
= 0;
4225 bool uj
= use_json(argc
, argv
);
4226 char *intf_name
= NULL
;
4227 int ret
= CMD_SUCCESS
;
4228 json_object
*json
= NULL
;
4230 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4231 if (instance
!= ospf_instance
)
4232 return CMD_NOT_MY_INSTANCE
;
4234 ospf
= ospf_lookup_instance(instance
);
4235 if (!ospf
|| !ospf
->oi_running
)
4239 json
= json_object_new_object();
4241 if (argv_find(argv
, argc
, "INTERFACE", &idx_intf
))
4242 intf_name
= argv
[idx_intf
]->arg
;
4244 ret
= show_ip_ospf_interface_common(vty
, ospf
, intf_name
, 0, json
, uj
);
4247 vty_json(vty
, json
);
4252 DEFUN (show_ip_ospf_interface_traffic
,
4253 show_ip_ospf_interface_traffic_cmd
,
4254 "show ip ospf [vrf <NAME|all>] interface traffic [INTERFACE] [json]",
4257 "OSPF information\n"
4260 "Interface information\n"
4261 "Protocol Packet counters\n"
4265 struct ospf
*ospf
= NULL
;
4266 struct listnode
*node
= NULL
;
4267 char *vrf_name
= NULL
, *intf_name
= NULL
;
4268 bool all_vrf
= false;
4270 int idx_vrf
= 0, idx_intf
= 0;
4271 bool uj
= use_json(argc
, argv
);
4272 json_object
*json
= NULL
;
4273 int ret
= CMD_SUCCESS
;
4274 int display_once
= 0;
4275 uint8_t use_vrf
= 0;
4277 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
4279 if (argv_find(argv
, argc
, "INTERFACE", &idx_intf
))
4280 intf_name
= argv
[idx_intf
]->arg
;
4283 json
= json_object_new_object();
4288 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
4289 if (!ospf
->oi_running
)
4292 ret
= show_ip_ospf_interface_traffic_common(
4293 vty
, ospf
, intf_name
, json
,
4294 display_once
, use_vrf
, uj
);
4299 vty_json(vty
, json
);
4303 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
4304 if (ospf
== NULL
|| !ospf
->oi_running
) {
4306 json_object_free(json
);
4310 ret
= show_ip_ospf_interface_traffic_common(
4311 vty
, ospf
, intf_name
, json
, display_once
, use_vrf
, uj
);
4313 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
4314 if (ospf
== NULL
|| !ospf
->oi_running
) {
4316 json_object_free(json
);
4320 ret
= show_ip_ospf_interface_traffic_common(
4321 vty
, ospf
, intf_name
, json
, display_once
, use_vrf
, uj
);
4325 vty_json(vty
, json
);
4331 static void show_ip_ospf_neighbour_header(struct vty
*vty
)
4333 vty_out(vty
, "\n%-15s %-3s %-15s %-15s %-9s %-15s %-32s %5s %5s %5s\n",
4334 "Neighbor ID", "Pri", "State", "Up Time", "Dead Time",
4335 "Address", "Interface", "RXmtL", "RqstL", "DBsmL");
4338 static void show_ip_ospf_neighbor_sub(struct vty
*vty
,
4339 struct ospf_interface
*oi
,
4340 json_object
*json
, bool use_json
)
4342 struct route_node
*rn
;
4343 struct ospf_neighbor
*nbr
, *prev_nbr
= NULL
;
4345 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4346 json_object
*json_neighbor
= NULL
, *json_neigh_array
= NULL
;
4347 struct timeval res
= {.tv_sec
= 0, .tv_usec
= 0};
4349 char uptime
[OSPF_TIME_DUMP_SIZE
];
4351 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
)) {
4352 if ((nbr
= rn
->info
)) {
4353 /* Do not show myself. */
4354 if (nbr
== oi
->nbr_self
)
4356 /* Down state is not shown. */
4357 if (nbr
->state
== NSM_Down
)
4360 if (nbr
->ts_last_progress
.tv_sec
4361 || nbr
->ts_last_progress
.tv_usec
)
4362 time_val
= monotime_since(
4363 &nbr
->ts_last_progress
, &res
)
4367 char neigh_str
[INET_ADDRSTRLEN
];
4370 && !IPV4_ADDR_SAME(&prev_nbr
->src
,
4372 /* Start new neigh list */
4373 json_neigh_array
= NULL
;
4376 if (nbr
->state
== NSM_Attempt
4377 && nbr
->router_id
.s_addr
== INADDR_ANY
)
4378 strlcpy(neigh_str
, "neighbor",
4381 inet_ntop(AF_INET
, &nbr
->router_id
,
4382 neigh_str
, sizeof(neigh_str
));
4384 json_object_object_get_ex(json
, neigh_str
,
4387 if (!json_neigh_array
) {
4389 json_object_new_array();
4390 json_object_object_add(
4395 json_neighbor
= json_object_new_object();
4397 ospf_nbr_ism_state_message(nbr
, msgbuf
, 16);
4399 json_object_int_add(json_neighbor
, "priority",
4401 json_object_string_add(json_neighbor
, "state",
4404 json_object_string_add(
4405 json_neighbor
, "converged",
4406 lookup_msg(ospf_nsm_state_msg
,
4408 json_object_string_add(
4409 json_neighbor
, "role",
4410 lookup_msg(ospf_ism_state_msg
,
4411 ospf_nbr_ism_state(nbr
),
4414 if (nbr
->t_inactivity
) {
4417 time_store
= monotime_until(
4422 json_object_int_add(json_neighbor
,
4425 json_object_int_add(json_neighbor
,
4428 json_object_string_add(
4429 json_neighbor
, "upTime",
4433 json_object_string_add(
4434 json_neighbor
, "deadTime",
4440 json_object_string_add(json_neighbor
,
4444 json_object_string_addf(json_neighbor
,
4447 json_object_string_add(json_neighbor
,
4450 json_object_int_add(
4451 json_neighbor
, "retransmitCounter",
4452 ospf_ls_retransmit_count(nbr
));
4453 json_object_int_add(json_neighbor
,
4455 ospf_ls_request_count(nbr
));
4456 json_object_int_add(json_neighbor
,
4458 ospf_db_summary_count(nbr
));
4460 json_object_array_add(json_neigh_array
,
4463 ospf_nbr_ism_state_message(nbr
, msgbuf
, 16);
4465 if (nbr
->state
== NSM_Attempt
4466 && nbr
->router_id
.s_addr
== INADDR_ANY
)
4467 vty_out(vty
, "%-15s %3d %-15s ", "-",
4468 nbr
->priority
, msgbuf
);
4470 vty_out(vty
, "%-15pI4 %3d %-15s ",
4471 &nbr
->router_id
, nbr
->priority
,
4474 vty_out(vty
, "%-15s ",
4475 ospf_timeval_dump(&res
, uptime
,
4478 vty_out(vty
, "%9s ",
4479 ospf_timer_dump(nbr
->t_inactivity
,
4482 vty_out(vty
, "%-15pI4 ", &nbr
->src
);
4483 vty_out(vty
, "%-32s %5ld %5ld %5d\n",
4485 ospf_ls_retransmit_count(nbr
),
4486 ospf_ls_request_count(nbr
),
4487 ospf_db_summary_count(nbr
));
4494 static int show_ip_ospf_neighbor_common(struct vty
*vty
, struct ospf
*ospf
,
4495 json_object
*json
, bool use_json
,
4498 struct ospf_interface
*oi
;
4499 struct listnode
*node
;
4500 json_object
*json_vrf
= NULL
;
4501 json_object
*json_nbr_sub
= NULL
;
4505 json_vrf
= json_object_new_object();
4508 json_nbr_sub
= json_object_new_object();
4511 if (ospf
->instance
) {
4513 json_object_int_add(json
, "ospfInstance",
4516 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
4519 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
4521 show_ip_ospf_neighbour_header(vty
);
4523 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
4524 if (ospf_interface_neighbor_count(oi
) == 0)
4526 show_ip_ospf_neighbor_sub(vty
, oi
, json_nbr_sub
, use_json
);
4530 json_object_object_add(json_vrf
, "neighbors", json_nbr_sub
);
4532 json_object_object_add(json
, ospf_get_name(ospf
),
4540 DEFUN (show_ip_ospf_neighbor
,
4541 show_ip_ospf_neighbor_cmd
,
4542 "show ip ospf [vrf <NAME|all>] neighbor [json]",
4545 "OSPF information\n"
4552 bool uj
= use_json(argc
, argv
);
4553 struct listnode
*node
= NULL
;
4554 char *vrf_name
= NULL
;
4555 bool all_vrf
= false;
4556 int ret
= CMD_SUCCESS
;
4559 uint8_t use_vrf
= 0;
4560 json_object
*json
= NULL
;
4562 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
4565 json
= json_object_new_object();
4567 /* vrf input is provided could be all or specific vrf*/
4571 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
4572 if (!ospf
->oi_running
)
4574 ret
= show_ip_ospf_neighbor_common(
4575 vty
, ospf
, json
, uj
, use_vrf
);
4579 vty_json(vty
, json
);
4581 vty_out(vty
, "OSPF is not enabled\n");
4586 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
4587 if (ospf
== NULL
|| !ospf
->oi_running
) {
4589 vty_json(vty
, json
);
4592 "%% OSPF is not enabled in vrf %s\n",
4598 /* Display default ospf (instance 0) info */
4599 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
4600 if (ospf
== NULL
|| !ospf
->oi_running
) {
4602 vty_json(vty
, json
);
4605 "%% OSPF is not enabled in vrf default\n");
4612 ret
= show_ip_ospf_neighbor_common(vty
, ospf
, json
, uj
,
4616 vty_out(vty
, "%s\n",
4617 json_object_to_json_string_ext(
4618 json
, JSON_C_TO_STRING_PRETTY
));
4623 json_object_free(json
);
4629 DEFUN (show_ip_ospf_instance_neighbor
,
4630 show_ip_ospf_instance_neighbor_cmd
,
4631 "show ip ospf (1-65535) neighbor [json]",
4634 "OSPF information\n"
4641 unsigned short instance
= 0;
4642 bool uj
= use_json(argc
, argv
);
4643 json_object
*json
= NULL
;
4644 int ret
= CMD_SUCCESS
;
4646 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4647 if (instance
!= ospf_instance
)
4648 return CMD_NOT_MY_INSTANCE
;
4650 ospf
= ospf_lookup_instance(instance
);
4651 if (!ospf
|| !ospf
->oi_running
)
4655 json
= json_object_new_object();
4657 ret
= show_ip_ospf_neighbor_common(vty
, ospf
, json
, uj
, 0);
4660 vty_json(vty
, json
);
4665 static int show_ip_ospf_neighbor_all_common(struct vty
*vty
, struct ospf
*ospf
,
4666 json_object
*json
, bool use_json
,
4669 struct listnode
*node
;
4670 struct ospf_interface
*oi
;
4671 char buf
[PREFIX_STRLEN
];
4672 json_object
*json_vrf
= NULL
;
4673 json_object
*json_neighbor_sub
= NULL
;
4677 json_vrf
= json_object_new_object();
4682 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
4684 show_ip_ospf_neighbour_header(vty
);
4686 if (ospf
->instance
) {
4688 json_object_int_add(json_vrf
, "ospfInstance",
4691 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
4694 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
4695 struct listnode
*nbr_node
;
4696 struct ospf_nbr_nbma
*nbr_nbma
;
4698 show_ip_ospf_neighbor_sub(vty
, oi
, json_vrf
, use_json
);
4700 /* print Down neighbor status */
4701 for (ALL_LIST_ELEMENTS_RO(oi
->nbr_nbma
, nbr_node
, nbr_nbma
)) {
4702 if (nbr_nbma
->nbr
== NULL
4703 || nbr_nbma
->nbr
->state
== NSM_Down
) {
4706 json_object_new_object();
4707 json_object_int_add(json_neighbor_sub
,
4709 nbr_nbma
->priority
);
4710 json_object_boolean_true_add(
4713 json_object_string_add(
4717 json_object_int_add(
4719 "nbrNbmaRetransmitCounter", 0);
4720 json_object_int_add(
4722 "nbrNbmaRequestCounter", 0);
4723 json_object_int_add(
4725 "nbrNbmaDbSummaryCounter", 0);
4726 json_object_object_add(
4729 &nbr_nbma
->addr
, buf
,
4733 vty_out(vty
, "%-15s %3d %-15s %9s ",
4734 "-", nbr_nbma
->priority
, "Down",
4737 "%-32pI4 %-20s %5d %5d %5d\n",
4739 IF_NAME(oi
), 0, 0, 0);
4747 json_object_object_add(json
, ospf_get_name(ospf
),
4755 DEFUN (show_ip_ospf_neighbor_all
,
4756 show_ip_ospf_neighbor_all_cmd
,
4757 "show ip ospf [vrf <NAME|all>] neighbor all [json]",
4760 "OSPF information\n"
4764 "include down status neighbor\n"
4768 bool uj
= use_json(argc
, argv
);
4769 struct listnode
*node
= NULL
;
4770 char *vrf_name
= NULL
;
4771 bool all_vrf
= false;
4772 int ret
= CMD_SUCCESS
;
4775 uint8_t use_vrf
= 0;
4776 json_object
*json
= NULL
;
4778 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
4781 json
= json_object_new_object();
4783 /* vrf input is provided could be all or specific vrf*/
4787 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
4788 if (!ospf
->oi_running
)
4790 ret
= show_ip_ospf_neighbor_all_common(
4791 vty
, ospf
, json
, uj
, use_vrf
);
4795 vty_json(vty
, json
);
4800 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
4801 if (ospf
== NULL
|| !ospf
->oi_running
) {
4803 json_object_free(json
);
4807 /* Display default ospf (instance 0) info */
4808 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
4809 if (ospf
== NULL
|| !ospf
->oi_running
) {
4811 json_object_free(json
);
4817 ret
= show_ip_ospf_neighbor_all_common(vty
, ospf
, json
, uj
,
4820 vty_out(vty
, "%s\n",
4821 json_object_to_json_string_ext(
4822 json
, JSON_C_TO_STRING_PRETTY
));
4827 json_object_free(json
);
4832 DEFUN (show_ip_ospf_instance_neighbor_all
,
4833 show_ip_ospf_instance_neighbor_all_cmd
,
4834 "show ip ospf (1-65535) neighbor all [json]",
4837 "OSPF information\n"
4840 "include down status neighbor\n"
4845 unsigned short instance
= 0;
4846 bool uj
= use_json(argc
, argv
);
4847 json_object
*json
= NULL
;
4848 int ret
= CMD_SUCCESS
;
4850 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4851 if (instance
!= ospf_instance
)
4852 return CMD_NOT_MY_INSTANCE
;
4854 ospf
= ospf_lookup_instance(instance
);
4855 if (!ospf
|| !ospf
->oi_running
)
4858 json
= json_object_new_object();
4860 ret
= show_ip_ospf_neighbor_all_common(vty
, ospf
, json
, uj
, 0);
4863 vty_json(vty
, json
);
4868 static int show_ip_ospf_neighbor_int_common(struct vty
*vty
, struct ospf
*ospf
,
4870 struct cmd_token
**argv
,
4871 bool use_json
, uint8_t use_vrf
)
4873 struct interface
*ifp
;
4874 struct route_node
*rn
;
4875 json_object
*json
= NULL
;
4878 json
= json_object_new_object();
4880 if (ospf
->instance
) {
4882 json_object_int_add(json
, "ospfInstance",
4885 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
4888 ospf_show_vrf_name(ospf
, vty
, json
, use_vrf
);
4890 ifp
= if_lookup_by_name(argv
[arg_base
]->arg
, ospf
->vrf_id
);
4893 json_object_boolean_true_add(json
, "noSuchIface");
4895 vty_out(vty
, "No such interface.\n");
4899 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
4900 struct ospf_interface
*oi
= rn
->info
;
4905 show_ip_ospf_neighbor_sub(vty
, oi
, json
, use_json
);
4909 vty_json(vty
, json
);
4916 DEFUN (show_ip_ospf_neighbor_int
,
4917 show_ip_ospf_neighbor_int_cmd
,
4918 "show ip ospf [vrf <NAME>] neighbor IFNAME [json]",
4921 "OSPF information\n"
4930 bool uj
= use_json(argc
, argv
);
4931 int ret
= CMD_SUCCESS
;
4932 struct interface
*ifp
= NULL
;
4933 char *vrf_name
= NULL
;
4934 vrf_id_t vrf_id
= VRF_DEFAULT
;
4935 struct vrf
*vrf
= NULL
;
4937 if (argv_find(argv
, argc
, "vrf", &idx_vrf
))
4938 vrf_name
= argv
[idx_vrf
+ 1]->arg
;
4939 if (vrf_name
&& strmatch(vrf_name
, VRF_DEFAULT_NAME
))
4942 vrf
= vrf_lookup_by_name(vrf_name
);
4944 vrf_id
= vrf
->vrf_id
;
4946 ospf
= ospf_lookup_by_vrf_id(vrf_id
);
4948 if (!ospf
|| !ospf
->oi_running
)
4952 show_ip_ospf_neighbour_header(vty
);
4954 argv_find(argv
, argc
, "IFNAME", &idx_ifname
);
4956 ifp
= if_lookup_by_name(argv
[idx_ifname
]->arg
, vrf_id
);
4960 ret
= show_ip_ospf_neighbor_int_common(vty
, ospf
, idx_ifname
,
4965 DEFUN (show_ip_ospf_instance_neighbor_int
,
4966 show_ip_ospf_instance_neighbor_int_cmd
,
4967 "show ip ospf (1-65535) neighbor IFNAME [json]",
4970 "OSPF information\n"
4979 unsigned short instance
= 0;
4980 bool uj
= use_json(argc
, argv
);
4983 show_ip_ospf_neighbour_header(vty
);
4985 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4986 if (instance
!= ospf_instance
)
4987 return CMD_NOT_MY_INSTANCE
;
4989 ospf
= ospf_lookup_instance(instance
);
4990 if (!ospf
|| !ospf
->oi_running
)
4994 show_ip_ospf_neighbour_header(vty
);
4996 return show_ip_ospf_neighbor_int_common(vty
, ospf
, idx_ifname
, argv
, uj
,
5000 static void show_ip_ospf_nbr_nbma_detail_sub(struct vty
*vty
,
5001 struct ospf_interface
*oi
,
5002 struct ospf_nbr_nbma
*nbr_nbma
,
5003 bool use_json
, json_object
*json
)
5005 char timebuf
[OSPF_TIME_DUMP_SIZE
];
5006 json_object
*json_sub
= NULL
;
5009 json_sub
= json_object_new_object();
5010 else /* Show neighbor ID. */
5011 vty_out(vty
, " Neighbor %s,", "-");
5013 /* Show interface address. */
5015 json_object_string_addf(json_sub
, "ifaceAddress", "%pI4",
5018 vty_out(vty
, " interface address %pI4\n",
5023 json_object_string_add(json_sub
, "areaId",
5024 ospf_area_desc_string(oi
->area
));
5025 json_object_string_add(json_sub
, "iface", IF_NAME(oi
));
5027 vty_out(vty
, " In the area %s via interface %s\n",
5028 ospf_area_desc_string(oi
->area
), IF_NAME(oi
));
5030 /* Show neighbor priority and state. */
5032 json_object_int_add(json_sub
, "nbrPriority",
5033 nbr_nbma
->priority
);
5034 json_object_string_add(json_sub
, "nbrState", "down");
5036 vty_out(vty
, " Neighbor priority is %d, State is %s,",
5037 nbr_nbma
->priority
, "Down");
5039 /* Show state changes. */
5041 json_object_int_add(json_sub
, "stateChangeCounter",
5042 nbr_nbma
->state_change
);
5044 vty_out(vty
, " %d state changes\n", nbr_nbma
->state_change
);
5046 /* Show PollInterval */
5048 json_object_int_add(json_sub
, "pollInterval", nbr_nbma
->v_poll
);
5050 vty_out(vty
, " Poll interval %d\n", nbr_nbma
->v_poll
);
5052 /* Show poll-interval timer. */
5053 if (nbr_nbma
->t_poll
) {
5056 time_store
= monotime_until(&nbr_nbma
->t_poll
->u
.sands
,
5058 json_object_int_add(json_sub
,
5059 "pollIntervalTimerDueMsec",
5062 vty_out(vty
, " Poll timer due in %s\n",
5063 ospf_timer_dump(nbr_nbma
->t_poll
, timebuf
,
5067 /* Show poll-interval timer thread. */
5069 if (nbr_nbma
->t_poll
!= NULL
)
5070 json_object_string_add(json_sub
,
5071 "pollIntervalTimerThread", "on");
5073 vty_out(vty
, " Thread Poll Timer %s\n",
5074 nbr_nbma
->t_poll
!= NULL
? "on" : "off");
5077 json_object_object_add(json
, "noNbrId", json_sub
);
5080 static void show_ip_ospf_neighbor_detail_sub(struct vty
*vty
,
5081 struct ospf_interface
*oi
,
5082 struct ospf_neighbor
*nbr
,
5083 struct ospf_neighbor
*prev_nbr
,
5084 json_object
*json
, bool use_json
)
5086 char timebuf
[OSPF_TIME_DUMP_SIZE
];
5087 json_object
*json_neigh
= NULL
, *json_neigh_array
= NULL
;
5088 char neigh_str
[INET_ADDRSTRLEN
] = {0};
5092 !IPV4_ADDR_SAME(&prev_nbr
->src
, &nbr
->src
)) {
5093 json_neigh_array
= NULL
;
5096 if (nbr
->state
== NSM_Attempt
5097 && nbr
->router_id
.s_addr
== INADDR_ANY
)
5098 strlcpy(neigh_str
, "noNbrId", sizeof(neigh_str
));
5100 inet_ntop(AF_INET
, &nbr
->router_id
,
5101 neigh_str
, sizeof(neigh_str
));
5103 json_object_object_get_ex(json
, neigh_str
, &json_neigh_array
);
5105 if (!json_neigh_array
) {
5106 json_neigh_array
= json_object_new_array();
5107 json_object_object_add(json
, neigh_str
,
5111 json_neigh
= json_object_new_object();
5114 /* Show neighbor ID. */
5115 if (nbr
->state
== NSM_Attempt
5116 && nbr
->router_id
.s_addr
== INADDR_ANY
)
5117 vty_out(vty
, " Neighbor %s,", "-");
5119 vty_out(vty
, " Neighbor %pI4,",
5123 /* Show interface address. */
5125 json_object_string_addf(json_neigh
, "ifaceAddress", "%pI4",
5126 &nbr
->address
.u
.prefix4
);
5128 vty_out(vty
, " interface address %pI4\n",
5129 &nbr
->address
.u
.prefix4
);
5133 json_object_string_add(json_neigh
, "areaId",
5134 ospf_area_desc_string(oi
->area
));
5135 json_object_string_add(json_neigh
, "ifaceName", oi
->ifp
->name
);
5137 vty_out(vty
, " In the area %s via interface %s\n",
5138 ospf_area_desc_string(oi
->area
), oi
->ifp
->name
);
5140 /* Show neighbor priority and state. */
5142 json_object_int_add(json_neigh
, "nbrPriority", nbr
->priority
);
5143 json_object_string_add(
5144 json_neigh
, "nbrState",
5145 lookup_msg(ospf_nsm_state_msg
, nbr
->state
, NULL
));
5147 vty_out(vty
, " Neighbor priority is %d, State is %s,",
5149 lookup_msg(ospf_nsm_state_msg
, nbr
->state
, NULL
));
5151 /* Show state changes. */
5153 json_object_int_add(json_neigh
, "stateChangeCounter",
5156 vty_out(vty
, " %d state changes\n", nbr
->state_change
);
5158 if (nbr
->ts_last_progress
.tv_sec
|| nbr
->ts_last_progress
.tv_usec
) {
5163 monotime_since(&nbr
->ts_last_progress
, &res
) / 1000LL;
5165 json_object_int_add(json_neigh
, "lastPrgrsvChangeMsec",
5169 " Most recent state change statistics:\n");
5170 vty_out(vty
, " Progressive change %s ago\n",
5171 ospf_timeval_dump(&res
, timebuf
,
5176 if (nbr
->ts_last_regress
.tv_sec
|| nbr
->ts_last_regress
.tv_usec
) {
5181 monotime_since(&nbr
->ts_last_regress
, &res
) / 1000LL;
5183 json_object_int_add(json_neigh
,
5184 "lastRegressiveChangeMsec",
5186 if (nbr
->last_regress_str
)
5187 json_object_string_add(
5189 "lastRegressiveChangeReason",
5190 nbr
->last_regress_str
);
5193 " Regressive change %s ago, due to %s\n",
5194 ospf_timeval_dump(&res
, timebuf
,
5196 (nbr
->last_regress_str
? nbr
->last_regress_str
5201 /* Show Designated Rotuer ID. */
5203 json_object_string_addf(json_neigh
, "routerDesignatedId",
5204 "%pI4", &nbr
->d_router
);
5206 vty_out(vty
, " DR is %pI4,", &nbr
->d_router
);
5208 /* Show Backup Designated Rotuer ID. */
5210 json_object_string_addf(json_neigh
, "routerDesignatedBackupId",
5211 "%pI4", &nbr
->bd_router
);
5213 vty_out(vty
, " BDR is %pI4\n", &nbr
->bd_router
);
5217 json_object_int_add(json_neigh
, "optionsCounter", nbr
->options
);
5218 json_object_string_add(json_neigh
, "optionsList",
5219 ospf_options_dump(nbr
->options
));
5221 vty_out(vty
, " Options %d %s\n", nbr
->options
,
5222 ospf_options_dump(nbr
->options
));
5224 /* Show Router Dead interval timer. */
5226 if (nbr
->t_inactivity
) {
5228 time_store
= monotime_until(&nbr
->t_inactivity
->u
.sands
,
5231 json_object_int_add(json_neigh
,
5232 "routerDeadIntervalTimerDueMsec",
5235 json_object_int_add(
5237 "routerDeadIntervalTimerDueMsec", -1);
5239 vty_out(vty
, " Dead timer due in %s\n",
5240 ospf_timer_dump(nbr
->t_inactivity
, timebuf
,
5243 /* Show Database Summary list. */
5245 json_object_int_add(json_neigh
, "databaseSummaryListCounter",
5246 ospf_db_summary_count(nbr
));
5248 vty_out(vty
, " Database Summary List %d\n",
5249 ospf_db_summary_count(nbr
));
5251 /* Show Link State Request list. */
5253 json_object_int_add(json_neigh
, "linkStateRequestListCounter",
5254 ospf_ls_request_count(nbr
));
5256 vty_out(vty
, " Link State Request List %ld\n",
5257 ospf_ls_request_count(nbr
));
5259 /* Show Link State Retransmission list. */
5261 json_object_int_add(json_neigh
,
5262 "linkStateRetransmissionListCounter",
5263 ospf_ls_retransmit_count(nbr
));
5265 vty_out(vty
, " Link State Retransmission List %ld\n",
5266 ospf_ls_retransmit_count(nbr
));
5268 /* Show inactivity timer thread. */
5270 if (nbr
->t_inactivity
!= NULL
)
5271 json_object_string_add(json_neigh
,
5272 "threadInactivityTimer", "on");
5274 vty_out(vty
, " Thread Inactivity Timer %s\n",
5275 nbr
->t_inactivity
!= NULL
? "on" : "off");
5277 /* Show Database Description retransmission thread. */
5279 if (nbr
->t_db_desc
!= NULL
)
5280 json_object_string_add(
5282 "threadDatabaseDescriptionRetransmission",
5286 " Thread Database Description Retransmision %s\n",
5287 nbr
->t_db_desc
!= NULL
? "on" : "off");
5289 /* Show Link State Request Retransmission thread. */
5291 if (nbr
->t_ls_req
!= NULL
)
5292 json_object_string_add(
5294 "threadLinkStateRequestRetransmission", "on");
5297 " Thread Link State Request Retransmission %s\n",
5298 nbr
->t_ls_req
!= NULL
? "on" : "off");
5300 /* Show Link State Update Retransmission thread. */
5302 if (nbr
->t_ls_upd
!= NULL
)
5303 json_object_string_add(
5305 "threadLinkStateUpdateRetransmission",
5309 " Thread Link State Update Retransmission %s\n\n",
5310 nbr
->t_ls_upd
!= NULL
? "on" : "off");
5313 vty_out(vty
, " Graceful restart Helper info:\n");
5315 if (OSPF_GR_IS_ACTIVE_HELPER(nbr
)) {
5317 " Graceful Restart HELPER Status : Inprogress.\n");
5320 " Graceful Restart grace period time: %d (seconds).\n",
5321 nbr
->gr_helper_info
.recvd_grace_period
);
5322 vty_out(vty
, " Graceful Restart reason: %s.\n",
5323 ospf_restart_reason2str(
5324 nbr
->gr_helper_info
.gr_restart_reason
));
5327 " Graceful Restart HELPER Status : None\n");
5330 if (nbr
->gr_helper_info
.rejected_reason
5331 != OSPF_HELPER_REJECTED_NONE
)
5332 vty_out(vty
, " Helper rejected reason: %s.\n",
5333 ospf_rejected_reason2str(
5334 nbr
->gr_helper_info
.rejected_reason
));
5336 if (nbr
->gr_helper_info
.helper_exit_reason
5337 != OSPF_GR_HELPER_EXIT_NONE
)
5338 vty_out(vty
, " Last helper exit reason: %s.\n\n",
5339 ospf_exit_reason2str(
5340 nbr
->gr_helper_info
.helper_exit_reason
));
5344 json_object_string_add(json_neigh
, "grHelperStatus",
5345 OSPF_GR_IS_ACTIVE_HELPER(nbr
) ?
5348 if (OSPF_GR_IS_ACTIVE_HELPER(nbr
)) {
5349 json_object_int_add(
5350 json_neigh
, "graceInterval",
5351 nbr
->gr_helper_info
.recvd_grace_period
);
5352 json_object_string_add(
5353 json_neigh
, "grRestartReason",
5354 ospf_restart_reason2str(
5355 nbr
->gr_helper_info
.gr_restart_reason
));
5358 if (nbr
->gr_helper_info
.rejected_reason
5359 != OSPF_HELPER_REJECTED_NONE
)
5360 json_object_string_add(
5361 json_neigh
, "helperRejectReason",
5362 ospf_rejected_reason2str(
5363 nbr
->gr_helper_info
.rejected_reason
));
5365 if (nbr
->gr_helper_info
.helper_exit_reason
5366 != OSPF_GR_HELPER_EXIT_NONE
)
5367 json_object_string_add(
5368 json_neigh
, "helperExitReason",
5369 ospf_exit_reason2str(
5371 .helper_exit_reason
));
5374 bfd_sess_show(vty
, json_neigh
, nbr
->bfd_session
);
5377 json_object_array_add(json_neigh_array
, json_neigh
);
5381 static int show_ip_ospf_neighbor_id_common(struct vty
*vty
, struct ospf
*ospf
,
5382 struct in_addr
*router_id
,
5383 bool use_json
, uint8_t use_vrf
)
5385 struct listnode
*node
;
5386 struct ospf_neighbor
*nbr
;
5387 struct ospf_interface
*oi
;
5388 json_object
*json
= NULL
;
5391 json
= json_object_new_object();
5393 if (ospf
->instance
) {
5395 json_object_int_add(json
, "ospfInstance",
5398 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
5401 ospf_show_vrf_name(ospf
, vty
, json
, use_vrf
);
5403 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
5404 if ((nbr
= ospf_nbr_lookup_by_routerid(oi
->nbrs
, router_id
))) {
5405 show_ip_ospf_neighbor_detail_sub(vty
, oi
, nbr
, NULL
,
5411 vty_json(vty
, json
);
5418 DEFPY (show_ip_ospf_neighbor_id
,
5419 show_ip_ospf_neighbor_id_cmd
,
5420 "show ip ospf neighbor A.B.C.D$router_id [json$json]",
5423 "OSPF information\n"
5429 struct listnode
*node
;
5430 int ret
= CMD_SUCCESS
;
5432 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
5433 if (!ospf
->oi_running
)
5435 ret
= show_ip_ospf_neighbor_id_common(vty
, ospf
, &router_id
,
5442 DEFPY (show_ip_ospf_instance_neighbor_id
,
5443 show_ip_ospf_instance_neighbor_id_cmd
,
5444 "show ip ospf (1-65535)$instance neighbor A.B.C.D$router_id [json$json]",
5447 "OSPF information\n"
5455 if (instance
!= ospf_instance
)
5456 return CMD_NOT_MY_INSTANCE
;
5458 ospf
= ospf_lookup_instance(instance
);
5459 if (!ospf
|| !ospf
->oi_running
)
5462 return show_ip_ospf_neighbor_id_common(vty
, ospf
, &router_id
, !!json
,
5466 static int show_ip_ospf_neighbor_detail_common(struct vty
*vty
,
5468 json_object
*json
, bool use_json
,
5471 struct ospf_interface
*oi
;
5472 struct listnode
*node
;
5473 json_object
*json_vrf
= NULL
;
5474 json_object
*json_nbr_sub
= NULL
;
5478 json_vrf
= json_object_new_object();
5482 json_nbr_sub
= json_object_new_object();
5485 if (ospf
->instance
) {
5487 json_object_int_add(json
, "ospfInstance",
5490 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
5493 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
5495 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
5496 struct route_node
*rn
;
5497 struct ospf_neighbor
*nbr
, *prev_nbr
= NULL
;
5499 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
)) {
5500 if ((nbr
= rn
->info
)) {
5501 if (nbr
!= oi
->nbr_self
) {
5502 if (nbr
->state
!= NSM_Down
) {
5503 show_ip_ospf_neighbor_detail_sub(
5504 vty
, oi
, nbr
, prev_nbr
,
5505 json_nbr_sub
, use_json
);
5514 json_object_object_add(json_vrf
, "neighbors",
5517 json_object_object_add(json
, ospf_get_name(ospf
),
5525 DEFUN (show_ip_ospf_neighbor_detail
,
5526 show_ip_ospf_neighbor_detail_cmd
,
5527 "show ip ospf [vrf <NAME|all>] neighbor detail [json]",
5530 "OSPF information\n"
5534 "detail of all neighbors\n"
5538 bool uj
= use_json(argc
, argv
);
5539 struct listnode
*node
= NULL
;
5540 char *vrf_name
= NULL
;
5541 bool all_vrf
= false;
5542 int ret
= CMD_SUCCESS
;
5545 uint8_t use_vrf
= 0;
5546 json_object
*json
= NULL
;
5548 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
5551 json
= json_object_new_object();
5553 /* vrf input is provided could be all or specific vrf*/
5557 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
5558 if (!ospf
->oi_running
)
5560 ret
= show_ip_ospf_neighbor_detail_common(
5561 vty
, ospf
, json
, uj
, use_vrf
);
5564 vty_json(vty
, json
);
5568 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
5569 if (ospf
== NULL
|| !ospf
->oi_running
) {
5571 json_object_free(json
);
5575 /* Display default ospf (instance 0) info */
5576 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
5577 if (ospf
== NULL
|| !ospf
->oi_running
) {
5579 json_object_free(json
);
5585 ret
= show_ip_ospf_neighbor_detail_common(vty
, ospf
, json
, uj
,
5588 vty_out(vty
, "%s\n",
5589 json_object_to_json_string_ext(
5590 json
, JSON_C_TO_STRING_PRETTY
));
5595 json_object_free(json
);
5600 DEFUN (show_ip_ospf_instance_neighbor_detail
,
5601 show_ip_ospf_instance_neighbor_detail_cmd
,
5602 "show ip ospf (1-65535) neighbor detail [json]",
5605 "OSPF information\n"
5608 "detail of all neighbors\n"
5613 unsigned short instance
= 0;
5614 bool uj
= use_json(argc
, argv
);
5615 json_object
*json
= NULL
;
5616 int ret
= CMD_SUCCESS
;
5618 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5619 if (instance
!= ospf_instance
)
5620 return CMD_NOT_MY_INSTANCE
;
5622 ospf
= ospf_lookup_instance(instance
);
5623 if (!ospf
|| !ospf
->oi_running
)
5627 json
= json_object_new_object();
5629 ret
= show_ip_ospf_neighbor_detail_common(vty
, ospf
, json
, uj
, 0);
5632 vty_json(vty
, json
);
5637 static int show_ip_ospf_neighbor_detail_all_common(struct vty
*vty
,
5643 struct listnode
*node
;
5644 struct ospf_interface
*oi
;
5645 json_object
*json_vrf
= NULL
;
5649 json_vrf
= json_object_new_object();
5654 if (ospf
->instance
) {
5656 json_object_int_add(json
, "ospfInstance",
5659 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
5662 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
5664 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
5665 struct route_node
*rn
;
5666 struct ospf_neighbor
*nbr
, *prev_nbr
= NULL
;
5667 struct ospf_nbr_nbma
*nbr_nbma
;
5669 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
)) {
5670 if ((nbr
= rn
->info
)) {
5671 if (nbr
!= oi
->nbr_self
)
5672 if (nbr
->state
!= NSM_Down
)
5673 show_ip_ospf_neighbor_detail_sub(
5676 json_vrf
, use_json
);
5681 if (oi
->type
== OSPF_IFTYPE_NBMA
) {
5682 struct listnode
*nd
;
5684 for (ALL_LIST_ELEMENTS_RO(oi
->nbr_nbma
, nd
, nbr_nbma
)) {
5685 if (nbr_nbma
->nbr
== NULL
5686 || nbr_nbma
->nbr
->state
== NSM_Down
)
5687 show_ip_ospf_nbr_nbma_detail_sub(
5688 vty
, oi
, nbr_nbma
, use_json
,
5696 json_object_object_add(json
, ospf_get_name(ospf
),
5705 DEFUN (show_ip_ospf_neighbor_detail_all
,
5706 show_ip_ospf_neighbor_detail_all_cmd
,
5707 "show ip ospf [vrf <NAME|all>] neighbor detail all [json]",
5710 "OSPF information\n"
5714 "detail of all neighbors\n"
5715 "include down status neighbor\n"
5719 bool uj
= use_json(argc
, argv
);
5720 struct listnode
*node
= NULL
;
5721 char *vrf_name
= NULL
;
5722 bool all_vrf
= false;
5723 int ret
= CMD_SUCCESS
;
5726 uint8_t use_vrf
= 0;
5727 json_object
*json
= NULL
;
5729 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
5732 json
= json_object_new_object();
5734 /* vrf input is provided could be all or specific vrf*/
5738 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
5739 if (!ospf
->oi_running
)
5741 ret
= show_ip_ospf_neighbor_detail_all_common(
5742 vty
, ospf
, json
, uj
, use_vrf
);
5746 vty_json(vty
, json
);
5750 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
5751 if (ospf
== NULL
|| !ospf
->oi_running
) {
5753 json_object_free(json
);
5757 /* Display default ospf (instance 0) info */
5758 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
5759 if (ospf
== NULL
|| !ospf
->oi_running
) {
5761 json_object_free(json
);
5767 ret
= show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, json
,
5770 vty_out(vty
, "%s\n",
5771 json_object_to_json_string_ext(
5772 json
, JSON_C_TO_STRING_PRETTY
));
5777 json_object_free(json
);
5782 DEFUN (show_ip_ospf_instance_neighbor_detail_all
,
5783 show_ip_ospf_instance_neighbor_detail_all_cmd
,
5784 "show ip ospf (1-65535) neighbor detail all [json]",
5787 "OSPF information\n"
5790 "detail of all neighbors\n"
5791 "include down status neighbor\n"
5796 unsigned short instance
= 0;
5797 bool uj
= use_json(argc
, argv
);
5798 json_object
*json
= NULL
;
5799 int ret
= CMD_SUCCESS
;
5801 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5802 if (instance
!= ospf_instance
)
5803 return CMD_NOT_MY_INSTANCE
;
5805 ospf
= ospf_lookup_instance(instance
);
5806 if (!ospf
|| !ospf
->oi_running
)
5810 json
= json_object_new_object();
5812 ret
= show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, json
, uj
, 0);
5815 vty_json(vty
, json
);
5820 static int show_ip_ospf_neighbor_int_detail_common(struct vty
*vty
,
5823 struct cmd_token
**argv
,
5826 struct ospf_interface
*oi
;
5827 struct interface
*ifp
;
5828 struct route_node
*rn
, *nrn
;
5829 struct ospf_neighbor
*nbr
;
5830 json_object
*json
= NULL
;
5833 json
= json_object_new_object();
5835 if (ospf
->instance
) {
5837 json_object_int_add(json
, "ospfInstance",
5840 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
5843 ifp
= if_lookup_by_name(argv
[arg_base
]->arg
, ospf
->vrf_id
);
5846 vty_out(vty
, "No such interface.\n");
5848 vty_out(vty
, "{}\n");
5849 json_object_free(json
);
5854 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
5855 if ((oi
= rn
->info
)) {
5856 for (nrn
= route_top(oi
->nbrs
); nrn
;
5857 nrn
= route_next(nrn
)) {
5858 if ((nbr
= nrn
->info
)) {
5859 if (nbr
!= oi
->nbr_self
) {
5860 if (nbr
->state
!= NSM_Down
)
5861 show_ip_ospf_neighbor_detail_sub(
5872 vty_json(vty
, json
);
5879 DEFUN (show_ip_ospf_neighbor_int_detail
,
5880 show_ip_ospf_neighbor_int_detail_cmd
,
5881 "show ip ospf neighbor IFNAME detail [json]",
5884 "OSPF information\n"
5887 "detail of all neighbors\n"
5891 bool uj
= use_json(argc
, argv
);
5892 struct listnode
*node
= NULL
;
5893 int ret
= CMD_SUCCESS
;
5894 bool ospf_output
= false;
5896 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
5897 if (!ospf
->oi_running
)
5900 ret
= show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 4,
5905 vty_out(vty
, "%% OSPF instance not found\n");
5910 DEFUN (show_ip_ospf_instance_neighbor_int_detail
,
5911 show_ip_ospf_instance_neighbor_int_detail_cmd
,
5912 "show ip ospf (1-65535) neighbor IFNAME detail [json]",
5915 "OSPF information\n"
5919 "detail of all neighbors\n"
5925 unsigned short instance
= 0;
5926 bool uj
= use_json(argc
, argv
);
5928 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5929 if (instance
!= ospf_instance
)
5930 return CMD_NOT_MY_INSTANCE
;
5932 ospf
= ospf_lookup_instance(instance
);
5933 if (!ospf
|| !ospf
->oi_running
)
5936 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, idx_ifname
,
5940 /* Show functions */
5941 static int show_lsa_summary(struct vty
*vty
, struct ospf_lsa
*lsa
, int self
,
5942 json_object
*json_lsa
)
5944 struct router_lsa
*rl
;
5945 struct summary_lsa
*sl
;
5946 struct as_external_lsa
*asel
;
5947 struct prefix_ipv4 p
;
5950 /* If self option is set, check LSA self flag. */
5951 if (self
== 0 || IS_LSA_SELF(lsa
)) {
5954 /* LSA common part show. */
5955 vty_out(vty
, "%-15pI4",
5957 vty_out(vty
, "%-15pI4 %4d 0x%08lx 0x%04x",
5958 &lsa
->data
->adv_router
, LS_AGE(lsa
),
5959 (unsigned long)ntohl(
5960 lsa
->data
->ls_seqnum
),
5961 ntohs(lsa
->data
->checksum
));
5966 snprintf(seqnum
, sizeof(seqnum
), "%x",
5967 ntohl(lsa
->data
->ls_seqnum
));
5968 snprintf(checksum
, sizeof(checksum
), "%x",
5969 ntohs(lsa
->data
->checksum
));
5970 json_object_string_addf(json_lsa
, "lsId",
5971 "%pI4", &lsa
->data
->id
);
5972 json_object_string_addf(
5973 json_lsa
, "advertisedRouter", "%pI4",
5974 &lsa
->data
->adv_router
);
5975 json_object_int_add(json_lsa
, "lsaAge",
5977 json_object_string_add(
5978 json_lsa
, "sequenceNumber", seqnum
);
5979 json_object_string_add(json_lsa
, "checksum",
5983 /* LSA specific part show. */
5984 switch (lsa
->data
->type
) {
5985 case OSPF_ROUTER_LSA
:
5986 rl
= (struct router_lsa
*)lsa
->data
;
5989 vty_out(vty
, " %-d", ntohs(rl
->links
));
5991 json_object_int_add(json_lsa
,
5995 case OSPF_SUMMARY_LSA
:
5996 sl
= (struct summary_lsa
*)lsa
->data
;
5999 p
.prefix
= sl
->header
.id
;
6000 p
.prefixlen
= ip_masklen(sl
->mask
);
6001 apply_mask_ipv4(&p
);
6004 vty_out(vty
, " %pFX", &p
);
6006 json_object_string_addf(
6007 json_lsa
, "summaryAddress",
6011 case OSPF_AS_EXTERNAL_LSA
:
6012 case OSPF_AS_NSSA_LSA
:
6013 asel
= (struct as_external_lsa
*)lsa
->data
;
6016 p
.prefix
= asel
->header
.id
;
6017 p
.prefixlen
= ip_masklen(asel
->mask
);
6018 apply_mask_ipv4(&p
);
6021 vty_out(vty
, " %s %pFX [0x%lx]",
6027 (unsigned long)ntohl(
6028 asel
->e
[0].route_tag
));
6030 json_object_string_add(
6031 json_lsa
, "metricType",
6036 json_object_string_addf(
6037 json_lsa
, "route", "%pFX", &p
);
6038 json_object_int_add(
6040 (unsigned long)ntohl(
6041 asel
->e
[0].route_tag
));
6044 case OSPF_NETWORK_LSA
:
6045 case OSPF_ASBR_SUMMARY_LSA
:
6046 case OSPF_OPAQUE_LINK_LSA
:
6047 case OSPF_OPAQUE_AREA_LSA
:
6048 case OSPF_OPAQUE_AS_LSA
:
6063 static const char *const show_database_desc
[] = {
6065 "Router Link States",
6067 "Summary Link States",
6068 "ASBR-Summary Link States",
6069 "AS External Link States",
6070 "Group Membership LSA",
6071 "NSSA-external Link States",
6073 "Link-Local Opaque-LSA",
6074 "Area-Local Opaque-LSA",
6075 "AS-external Opaque-LSA",
6078 static const char * const show_database_desc_json
[] = {
6081 "networkLinkStates",
6082 "summaryLinkStates",
6083 "asbrSummaryLinkStates",
6084 "asExternalLinkStates",
6085 "groupMembershipLsa",
6086 "nssaExternalLinkStates",
6088 "linkLocalOpaqueLsa",
6089 "areaLocalOpaqueLsa",
6090 "asExternalOpaqueLsa",
6093 static const char *const show_database_desc_count_json
[] = {
6095 "routerLinkStatesCount",
6096 "networkLinkStatesCount",
6097 "summaryLinkStatesCount",
6098 "asbrSummaryLinkStatesCount",
6099 "asExternalLinkStatesCount",
6100 "groupMembershipLsaCount",
6101 "nssaExternalLinkStatesCount",
6103 "linkLocalOpaqueLsaCount",
6104 "areaLocalOpaqueLsaCount",
6105 "asExternalOpaqueLsaCount",
6108 static const char *const show_database_header
[] = {
6110 "Link ID ADV Router Age Seq# CkSum Link count",
6111 "Link ID ADV Router Age Seq# CkSum",
6112 "Link ID ADV Router Age Seq# CkSum Route",
6113 "Link ID ADV Router Age Seq# CkSum",
6114 "Link ID ADV Router Age Seq# CkSum Route",
6115 " --- header for Group Member ----",
6116 "Link ID ADV Router Age Seq# CkSum Route",
6118 "Opaque-Type/Id ADV Router Age Seq# CkSum",
6119 "Opaque-Type/Id ADV Router Age Seq# CkSum",
6120 "Opaque-Type/Id ADV Router Age Seq# CkSum",
6123 static void show_ip_ospf_database_header(struct vty
*vty
, struct ospf_lsa
*lsa
,
6126 struct router_lsa
*rlsa
= (struct router_lsa
*)lsa
->data
;
6129 vty_out(vty
, " LS age: %d\n", LS_AGE(lsa
));
6130 vty_out(vty
, " Options: 0x%-2x : %s\n", lsa
->data
->options
,
6131 ospf_options_dump(lsa
->data
->options
));
6132 vty_out(vty
, " LS Flags: 0x%-2x %s\n", lsa
->flags
,
6133 ((lsa
->flags
& OSPF_LSA_LOCAL_XLT
)
6134 ? "(Translated from Type-7)"
6137 if (lsa
->data
->type
== OSPF_ROUTER_LSA
) {
6138 vty_out(vty
, " Flags: 0x%x", rlsa
->flags
);
6141 vty_out(vty
, " :%s%s%s%s",
6142 IS_ROUTER_LSA_BORDER(rlsa
) ? " ABR"
6144 IS_ROUTER_LSA_EXTERNAL(rlsa
) ? " ASBR"
6146 IS_ROUTER_LSA_VIRTUAL(rlsa
)
6149 IS_ROUTER_LSA_SHORTCUT(rlsa
)
6155 vty_out(vty
, " LS Type: %s\n",
6156 lookup_msg(ospf_lsa_type_msg
, lsa
->data
->type
, NULL
));
6157 vty_out(vty
, " Link State ID: %pI4 %s\n",
6159 lookup_msg(ospf_link_state_id_type_msg
, lsa
->data
->type
,
6161 vty_out(vty
, " Advertising Router: %pI4\n",
6162 &lsa
->data
->adv_router
);
6163 vty_out(vty
, " LS Seq Number: %08lx\n",
6164 (unsigned long)ntohl(lsa
->data
->ls_seqnum
));
6165 vty_out(vty
, " Checksum: 0x%04x\n",
6166 ntohs(lsa
->data
->checksum
));
6167 vty_out(vty
, " Length: %d\n\n", ntohs(lsa
->data
->length
));
6172 snprintf(seqnum
, 10, "%x", ntohl(lsa
->data
->ls_seqnum
));
6173 snprintf(checksum
, 10, "%x", ntohs(lsa
->data
->checksum
));
6175 json_object_int_add(json
, "lsaAge", LS_AGE(lsa
));
6176 json_object_string_add(json
, "options",
6177 ospf_options_dump(lsa
->data
->options
));
6178 json_object_int_add(json
, "lsaFlags", lsa
->flags
);
6180 if (lsa
->flags
& OSPF_LSA_LOCAL_XLT
)
6181 json_object_boolean_true_add(json
,
6182 "translatedFromType7");
6184 if (lsa
->data
->type
== OSPF_ROUTER_LSA
) {
6185 json_object_int_add(json
, "flags", rlsa
->flags
);
6188 if (IS_ROUTER_LSA_BORDER(rlsa
))
6189 json_object_boolean_true_add(json
,
6191 if (IS_ROUTER_LSA_EXTERNAL(rlsa
))
6192 json_object_boolean_true_add(json
,
6194 if (IS_ROUTER_LSA_VIRTUAL(rlsa
))
6195 json_object_boolean_true_add(
6196 json
, "vlEndpoint");
6197 if (IS_ROUTER_LSA_SHORTCUT(rlsa
))
6198 json_object_boolean_true_add(
6203 json_object_string_add(
6205 lookup_msg(ospf_lsa_type_msg
, lsa
->data
->type
, NULL
));
6206 json_object_string_addf(json
, "linkStateId", "%pI4",
6208 json_object_string_addf(json
, "advertisingRouter", "%pI4",
6209 &lsa
->data
->adv_router
);
6210 json_object_string_add(json
, "lsaSeqNumber", seqnum
);
6211 json_object_string_add(json
, "checksum", checksum
);
6212 json_object_int_add(json
, "length", ntohs(lsa
->data
->length
));
6216 static const char *const link_type_desc
[] = {
6218 "another Router (point-to-point)",
6219 "a Transit Network",
6224 static const char *const link_id_desc
[] = {
6225 "(null)", "Neighboring Router ID", "Designated Router address",
6226 "Net", "Neighboring Router ID",
6229 static const char *const link_data_desc
[] = {
6230 "(null)", "Router Interface address", "Router Interface address",
6231 "Network Mask", "Router Interface address",
6234 static const char *const link_id_desc_json
[] = {
6235 "null", "neighborRouterId", "designatedRouterAddress",
6236 "networkAddress", "neighborRouterId",
6239 static const char *const link_data_desc_json
[] = {
6240 "null", "routerInterfaceAddress", "routerInterfaceAddress",
6241 "networkMask", "routerInterfaceAddress",
6244 /* Show router-LSA each Link information. */
6245 static void show_ip_ospf_database_router_links(struct vty
*vty
,
6246 struct router_lsa
*rl
,
6251 json_object
*json_links
= NULL
;
6252 json_object
*json_link
= NULL
;
6254 char buf
[PREFIX_STRLEN
];
6257 json_links
= json_object_new_object();
6259 len
= ntohs(rl
->header
.length
) - 4;
6260 for (i
= 0; i
< ntohs(rl
->links
) && len
> 0; len
-= 12, i
++) {
6261 type
= rl
->link
[i
].type
;
6266 snprintf(link
, sizeof(link
), "link%u", i
);
6267 json_link
= json_object_new_object();
6268 json_object_string_add(json_link
, "linkType",
6269 link_type_desc
[type
]);
6270 json_object_string_add(json_link
,
6271 link_id_desc_json
[type
],
6273 &rl
->link
[i
].link_id
,
6275 json_object_string_add(
6276 json_link
, link_data_desc_json
[type
],
6277 inet_ntop(AF_INET
, &rl
->link
[i
].link_data
,
6279 json_object_int_add(json_link
, "numOfTosMetrics",
6281 json_object_int_add(json_link
, "tos0Metric",
6282 ntohs(rl
->link
[i
].metric
));
6283 json_object_object_add(json_links
, link
, json_link
);
6285 vty_out(vty
, " Link connected to: %s\n",
6286 link_type_desc
[type
]);
6287 vty_out(vty
, " (Link ID) %s: %pI4\n",
6289 &rl
->link
[i
].link_id
);
6290 vty_out(vty
, " (Link Data) %s: %pI4\n",
6291 link_data_desc
[type
],
6292 &rl
->link
[i
].link_data
);
6293 vty_out(vty
, " Number of TOS metrics: 0\n");
6294 vty_out(vty
, " TOS 0 Metric: %d\n",
6295 ntohs(rl
->link
[i
].metric
));
6300 json_object_object_add(json
, "routerLinks", json_links
);
6303 /* Show router-LSA detail information. */
6304 static int show_router_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
,
6308 struct router_lsa
*rl
= (struct router_lsa
*)lsa
->data
;
6310 show_ip_ospf_database_header(vty
, lsa
, json
);
6313 vty_out(vty
, " Number of Links: %d\n\n",
6316 json_object_int_add(json
, "numOfLinks",
6319 show_ip_ospf_database_router_links(vty
, rl
, json
);
6328 /* Show network-LSA detail information. */
6329 static int show_network_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
,
6333 char buf
[PREFIX_STRLEN
];
6334 json_object
*json_attached_rt
= NULL
;
6335 json_object
*json_router
= NULL
;
6338 json_attached_rt
= json_object_new_object();
6341 struct network_lsa
*nl
= (struct network_lsa
*)lsa
->data
;
6342 struct in_addr
*addr
;
6344 show_ip_ospf_database_header(vty
, lsa
, json
);
6347 vty_out(vty
, " Network Mask: /%d\n",
6348 ip_masklen(nl
->mask
));
6350 json_object_int_add(json
, "networkMask",
6351 ip_masklen(nl
->mask
));
6353 length
= lsa
->size
- OSPF_LSA_HEADER_SIZE
- 4;
6354 addr
= &nl
->routers
[0];
6355 for (i
= 0; length
> 0 && addr
;
6356 length
-= 4, addr
= &nl
->routers
[++i
])
6358 vty_out(vty
, " Attached Router: %pI4\n",
6362 json_router
= json_object_new_object();
6363 json_object_string_add(
6364 json_router
, "attachedRouterId",
6365 inet_ntop(AF_INET
, addr
, buf
,
6367 json_object_object_add(json_attached_rt
,
6368 inet_ntop(AF_INET
, addr
,
6376 json_object_object_add(json
, "attchedRouters",
6382 /* Show summary-LSA detail information. */
6383 static int show_summary_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
,
6387 struct summary_lsa
*sl
= (struct summary_lsa
*)lsa
->data
;
6389 show_ip_ospf_database_header(vty
, lsa
, json
);
6392 vty_out(vty
, " Network Mask: /%d\n",
6393 ip_masklen(sl
->mask
));
6394 vty_out(vty
, " TOS: 0 Metric: %d\n",
6395 GET_METRIC(sl
->metric
));
6398 json_object_int_add(json
, "networkMask",
6399 ip_masklen(sl
->mask
));
6400 json_object_int_add(json
, "tos0Metric",
6401 GET_METRIC(sl
->metric
));
6408 /* Show summary-ASBR-LSA detail information. */
6409 static int show_summary_asbr_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
,
6413 struct summary_lsa
*sl
= (struct summary_lsa
*)lsa
->data
;
6415 show_ip_ospf_database_header(vty
, lsa
, json
);
6418 vty_out(vty
, " Network Mask: /%d\n",
6419 ip_masklen(sl
->mask
));
6420 vty_out(vty
, " TOS: 0 Metric: %d\n",
6421 GET_METRIC(sl
->metric
));
6424 json_object_int_add(json
, "networkMask",
6425 ip_masklen(sl
->mask
));
6426 json_object_int_add(json
, "tos0Metric",
6427 GET_METRIC(sl
->metric
));
6434 /* Show AS-external-LSA detail information. */
6435 static int show_as_external_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
,
6441 struct as_external_lsa
*al
=
6442 (struct as_external_lsa
*)lsa
->data
;
6444 show_ip_ospf_database_header(vty
, lsa
, json
);
6447 vty_out(vty
, " Network Mask: /%d\n",
6448 ip_masklen(al
->mask
));
6449 vty_out(vty
, " Metric Type: %s\n",
6450 IS_EXTERNAL_METRIC(al
->e
[0].tos
)
6451 ? "2 (Larger than any link state path)"
6453 vty_out(vty
, " TOS: 0\n");
6454 vty_out(vty
, " Metric: %d\n",
6455 GET_METRIC(al
->e
[0].metric
));
6456 vty_out(vty
, " Forward Address: %pI4\n",
6457 &al
->e
[0].fwd_addr
);
6459 " External Route Tag: %" ROUTE_TAG_PRI
"\n\n",
6460 (route_tag_t
)ntohl(al
->e
[0].route_tag
));
6462 json_object_int_add(json
, "networkMask",
6463 ip_masklen(al
->mask
));
6464 json_object_string_add(
6466 IS_EXTERNAL_METRIC(al
->e
[0].tos
)
6467 ? "E2 (Larger than any link state path)"
6469 json_object_int_add(json
, "tos", tos
);
6470 json_object_int_add(json
, "metric",
6471 GET_METRIC(al
->e
[0].metric
));
6472 json_object_string_addf(json
, "forwardAddress", "%pI4",
6473 &(al
->e
[0].fwd_addr
));
6474 json_object_int_add(
6475 json
, "externalRouteTag",
6476 (route_tag_t
)ntohl(al
->e
[0].route_tag
));
6483 /* Show AS-NSSA-LSA detail information. */
6484 static int show_as_nssa_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
,
6490 struct as_external_lsa
*al
=
6491 (struct as_external_lsa
*)lsa
->data
;
6493 show_ip_ospf_database_header(vty
, lsa
, json
);
6496 vty_out(vty
, " Network Mask: /%d\n",
6497 ip_masklen(al
->mask
));
6498 vty_out(vty
, " Metric Type: %s\n",
6499 IS_EXTERNAL_METRIC(al
->e
[0].tos
)
6500 ? "2 (Larger than any link state path)"
6502 vty_out(vty
, " TOS: 0\n");
6503 vty_out(vty
, " Metric: %d\n",
6504 GET_METRIC(al
->e
[0].metric
));
6505 vty_out(vty
, " NSSA: Forward Address: %pI4\n",
6506 &al
->e
[0].fwd_addr
);
6508 " External Route Tag: %" ROUTE_TAG_PRI
6510 (route_tag_t
)ntohl(al
->e
[0].route_tag
));
6512 json_object_int_add(json
, "networkMask",
6513 ip_masklen(al
->mask
));
6514 json_object_string_add(
6516 IS_EXTERNAL_METRIC(al
->e
[0].tos
)
6517 ? "E2 (Larger than any link state path)"
6519 json_object_int_add(json
, "tos", tos
);
6520 json_object_int_add(json
, "metric",
6521 GET_METRIC(al
->e
[0].metric
));
6522 json_object_string_addf(json
, "nssaForwardAddress",
6523 "%pI4", &al
->e
[0].fwd_addr
);
6524 json_object_int_add(
6525 json
, "externalRouteTag",
6526 (route_tag_t
)ntohl(al
->e
[0].route_tag
));
6533 static int show_func_dummy(struct vty
*vty
, struct ospf_lsa
*lsa
,
6539 static int show_opaque_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
,
6543 show_ip_ospf_database_header(vty
, lsa
, json
);
6544 show_opaque_info_detail(vty
, lsa
, json
);
6551 int (*show_function
[])(struct vty
*, struct ospf_lsa
*, json_object
*) = {
6553 show_router_lsa_detail
,
6554 show_network_lsa_detail
,
6555 show_summary_lsa_detail
,
6556 show_summary_asbr_lsa_detail
,
6557 show_as_external_lsa_detail
,
6559 show_as_nssa_lsa_detail
, /* almost same as external */
6561 show_opaque_lsa_detail
,
6562 show_opaque_lsa_detail
,
6563 show_opaque_lsa_detail
,
6566 static void show_lsa_prefix_set(struct vty
*vty
, struct prefix_ls
*lp
,
6567 struct in_addr
*id
, struct in_addr
*adv_router
)
6569 memset(lp
, 0, sizeof(struct prefix_ls
));
6570 lp
->family
= AF_UNSPEC
;
6573 else if (adv_router
== NULL
) {
6574 lp
->prefixlen
= IPV4_MAX_BITLEN
;
6579 lp
->adv_router
= *adv_router
;
6583 static void show_lsa_detail_proc(struct vty
*vty
, struct route_table
*rt
,
6584 struct in_addr
*id
, struct in_addr
*adv_router
,
6587 struct prefix_ls lp
;
6588 struct route_node
*rn
, *start
;
6589 struct ospf_lsa
*lsa
;
6590 json_object
*json_lsa
= NULL
;
6592 show_lsa_prefix_set(vty
, &lp
, id
, adv_router
);
6593 start
= route_node_get(rt
, (struct prefix
*)&lp
);
6595 route_lock_node(start
);
6596 for (rn
= start
; rn
; rn
= route_next_until(rn
, start
))
6597 if ((lsa
= rn
->info
)) {
6599 json_lsa
= json_object_new_object();
6600 json_object_array_add(json
, json_lsa
);
6603 if (show_function
[lsa
->data
->type
] != NULL
)
6604 show_function
[lsa
->data
->type
](
6605 vty
, lsa
, json_lsa
);
6607 route_unlock_node(start
);
6611 /* Show detail LSA information
6612 -- if id is NULL then show all LSAs. */
6613 static void show_lsa_detail(struct vty
*vty
, struct ospf
*ospf
, int type
,
6614 struct in_addr
*id
, struct in_addr
*adv_router
,
6617 struct listnode
*node
;
6618 struct ospf_area
*area
;
6619 char buf
[PREFIX_STRLEN
];
6620 json_object
*json_lsa_type
= NULL
;
6621 json_object
*json_areas
= NULL
;
6622 json_object
*json_lsa_array
= NULL
;
6625 json_lsa_type
= json_object_new_object();
6628 case OSPF_AS_EXTERNAL_LSA
:
6629 case OSPF_OPAQUE_AS_LSA
:
6631 vty_out(vty
, " %s \n\n",
6632 show_database_desc
[type
]);
6634 json_lsa_array
= json_object_new_array();
6636 show_lsa_detail_proc(vty
, AS_LSDB(ospf
, type
), id
, adv_router
,
6639 json_object_object_add(json
,
6640 show_database_desc_json
[type
],
6646 json_areas
= json_object_new_object();
6648 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
6651 "\n %s (Area %s)\n\n",
6652 show_database_desc
[type
],
6653 ospf_area_desc_string(area
));
6655 json_lsa_array
= json_object_new_array();
6656 json_object_object_add(json_areas
,
6664 show_lsa_detail_proc(vty
, AREA_LSDB(area
, type
), id
,
6665 adv_router
, json_lsa_array
);
6669 json_object_object_add(json_lsa_type
, "areas",
6671 json_object_object_add(json
,
6672 show_database_desc_json
[type
],
6679 static void show_lsa_detail_adv_router_proc(struct vty
*vty
,
6680 struct route_table
*rt
,
6681 struct in_addr
*adv_router
,
6684 char buf
[PREFIX_STRLEN
];
6685 struct route_node
*rn
;
6686 struct ospf_lsa
*lsa
;
6688 for (rn
= route_top(rt
); rn
; rn
= route_next(rn
))
6689 if ((lsa
= rn
->info
)) {
6690 json_object
*json_lsa
= NULL
;
6692 if (IPV4_ADDR_SAME(adv_router
,
6693 &lsa
->data
->adv_router
)) {
6694 if (CHECK_FLAG(lsa
->flags
, OSPF_LSA_LOCAL_XLT
))
6697 json_lsa
= json_object_new_object();
6699 if (show_function
[lsa
->data
->type
] != NULL
)
6700 show_function
[lsa
->data
->type
](
6701 vty
, lsa
, json_lsa
);
6703 json_object_object_add(
6713 /* Show detail LSA information. */
6714 static void show_lsa_detail_adv_router(struct vty
*vty
, struct ospf
*ospf
,
6715 int type
, struct in_addr
*adv_router
,
6718 struct listnode
*node
;
6719 struct ospf_area
*area
;
6720 char buf
[PREFIX_STRLEN
];
6721 json_object
*json_lstype
= NULL
;
6722 json_object
*json_area
= NULL
;
6725 json_lstype
= json_object_new_object();
6728 case OSPF_AS_EXTERNAL_LSA
:
6729 case OSPF_OPAQUE_AS_LSA
:
6731 vty_out(vty
, " %s \n\n",
6732 show_database_desc
[type
]);
6734 show_lsa_detail_adv_router_proc(vty
, AS_LSDB(ospf
, type
),
6735 adv_router
, json_lstype
);
6739 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
6741 json_area
= json_object_new_object();
6744 "\n %s (Area %s)\n\n",
6745 show_database_desc
[type
],
6746 ospf_area_desc_string(area
));
6747 show_lsa_detail_adv_router_proc(vty
,
6748 AREA_LSDB(area
, type
),
6749 adv_router
, json_area
);
6752 json_object_object_add(json_lstype
,
6763 json_object_object_add(json
, show_database_desc
[type
],
6767 void show_ip_ospf_database_summary(struct vty
*vty
, struct ospf
*ospf
, int self
,
6770 struct ospf_lsa
*lsa
;
6771 struct route_node
*rn
;
6772 struct ospf_area
*area
;
6773 struct listnode
*node
;
6774 char buf
[PREFIX_STRLEN
];
6775 json_object
*json_areas
= NULL
;
6776 json_object
*json_area
= NULL
;
6777 json_object
*json_lsa
= NULL
;
6779 json_object
*json_lsa_array
= NULL
;
6783 json_areas
= json_object_new_object();
6785 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
6787 json_area
= json_object_new_object();
6789 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++) {
6792 case OSPF_AS_EXTERNAL_LSA
:
6793 case OSPF_OPAQUE_AS_LSA
:
6798 if (ospf_lsdb_count_self(area
->lsdb
, type
) > 0
6800 && ospf_lsdb_count(area
->lsdb
, type
) > 0)) {
6804 " %s (Area %s)\n\n",
6805 show_database_desc
[type
],
6806 ospf_area_desc_string(area
));
6807 vty_out(vty
, "%s\n",
6808 show_database_header
[type
]);
6811 json_object_new_array();
6812 json_object_object_add(
6814 show_database_desc_json
[type
],
6818 LSDB_LOOP (AREA_LSDB(area
, type
), rn
, lsa
) {
6821 json_object_new_object();
6822 json_object_array_add(
6827 count
+= show_lsa_summary(
6828 vty
, lsa
, self
, json_lsa
);
6834 json_object_int_add(
6837 show_database_desc_count_json
6843 json_object_object_add(json_areas
,
6851 json_object_object_add(json
, "areas", json_areas
);
6853 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++) {
6856 case OSPF_AS_EXTERNAL_LSA
:
6857 case OSPF_OPAQUE_AS_LSA
:
6862 if (ospf_lsdb_count_self(ospf
->lsdb
, type
)
6863 || (!self
&& ospf_lsdb_count(ospf
->lsdb
, type
))) {
6865 vty_out(vty
, " %s\n\n",
6866 show_database_desc
[type
]);
6867 vty_out(vty
, "%s\n",
6868 show_database_header
[type
]);
6870 json_lsa_array
= json_object_new_array();
6871 json_object_object_add(
6872 json
, show_database_desc_json
[type
],
6876 LSDB_LOOP (AS_LSDB(ospf
, type
), rn
, lsa
) {
6878 json_lsa
= json_object_new_object();
6879 json_object_array_add(json_lsa_array
,
6883 count
+= show_lsa_summary(vty
, lsa
, self
,
6890 json_object_int_add(
6892 show_database_desc_count_json
[type
],
6901 static void show_ip_ospf_database_maxage(struct vty
*vty
, struct ospf
*ospf
,
6904 struct route_node
*rn
;
6905 char buf
[PREFIX_STRLEN
];
6906 json_object
*json_maxage
= NULL
;
6909 vty_out(vty
, "\n MaxAge Link States:\n\n");
6911 json_maxage
= json_object_new_object();
6913 for (rn
= route_top(ospf
->maxage_lsa
); rn
; rn
= route_next(rn
)) {
6914 struct ospf_lsa
*lsa
;
6915 json_object
*json_lsa
= NULL
;
6917 if ((lsa
= rn
->info
) != NULL
) {
6919 vty_out(vty
, "Link type: %d\n",
6921 vty_out(vty
, "Link State ID: %pI4\n",
6923 vty_out(vty
, "Advertising Router: %pI4\n",
6924 &lsa
->data
->adv_router
);
6925 vty_out(vty
, "LSA lock count: %d\n", lsa
->lock
);
6928 json_lsa
= json_object_new_object();
6929 json_object_int_add(json_lsa
, "linkType",
6931 json_object_string_addf(json_lsa
, "linkStateId",
6932 "%pI4", &lsa
->data
->id
);
6933 json_object_string_addf(
6934 json_lsa
, "advertisingRouter", "%pI4",
6935 &lsa
->data
->adv_router
);
6936 json_object_int_add(json_lsa
, "lsaLockCount",
6938 json_object_object_add(
6948 json_object_object_add(json
, "maxAgeLinkStates", json_maxage
);
6951 #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
6952 #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
6954 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
6955 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
6956 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
6957 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
6959 #define OSPF_LSA_TYPES_DESC \
6960 "ASBR summary link states\n" \
6961 "External link states\n" \
6962 "Network link states\n" \
6963 "Router link states\n" \
6964 "Network summary link states\n" OSPF_LSA_TYPE_NSSA_DESC \
6965 OSPF_LSA_TYPE_OPAQUE_LINK_DESC OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
6966 OSPF_LSA_TYPE_OPAQUE_AS_DESC
6968 static int show_ip_ospf_database_common(struct vty
*vty
, struct ospf
*ospf
,
6969 int arg_base
, int argc
,
6970 struct cmd_token
**argv
,
6971 uint8_t use_vrf
, json_object
*json
,
6976 struct in_addr id
, adv_router
;
6977 json_object
*json_vrf
= NULL
;
6981 json_vrf
= json_object_new_object();
6986 if (ospf
->instance
) {
6988 json_object_int_add(json_vrf
, "ospfInstance",
6991 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
6994 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
6996 /* Show Router ID. */
6998 json_object_string_addf(json_vrf
, "routerId", "%pI4",
7001 vty_out(vty
, "\n OSPF Router with ID (%pI4)\n\n",
7006 if ((argc
== arg_base
+ 4) || (uj
&& (argc
== arg_base
+ 5))) {
7007 show_ip_ospf_database_summary(vty
, ospf
, 0, json_vrf
);
7010 json_object_object_add(
7011 json
, ospf_get_name(ospf
), json_vrf
);
7016 /* Set database type to show. */
7017 if (strncmp(argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
7018 type
= OSPF_ROUTER_LSA
;
7019 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
7020 type
= OSPF_NETWORK_LSA
;
7021 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
7022 type
= OSPF_AS_NSSA_LSA
;
7023 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "su", 2) == 0)
7024 type
= OSPF_SUMMARY_LSA
;
7025 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
7026 type
= OSPF_ASBR_SUMMARY_LSA
;
7027 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
7028 type
= OSPF_AS_EXTERNAL_LSA
;
7029 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "se", 2) == 0) {
7030 show_ip_ospf_database_summary(vty
, ospf
, 1, json_vrf
);
7033 json_object_object_add(
7034 json
, ospf_get_name(ospf
), json_vrf
);
7037 } else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "m", 1) == 0) {
7038 show_ip_ospf_database_maxage(vty
, ospf
, json_vrf
);
7041 json_object_object_add(
7042 json
, ospf_get_name(ospf
), json_vrf
);
7045 } else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
7046 type
= OSPF_OPAQUE_LINK_LSA
;
7047 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
7048 type
= OSPF_OPAQUE_AREA_LSA
;
7049 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
7050 type
= OSPF_OPAQUE_AS_LSA
;
7054 /* `show ip ospf database LSA'. */
7055 if ((argc
== arg_base
+ 5) || (uj
&& (argc
== arg_base
+ 6)))
7056 show_lsa_detail(vty
, ospf
, type
, NULL
, NULL
, json_vrf
);
7057 else if (argc
>= arg_base
+ 6) {
7058 ret
= inet_aton(argv
[arg_base
+ 5]->arg
, &id
);
7062 /* `show ip ospf database LSA ID'. */
7063 if ((argc
== arg_base
+ 6) || (uj
&& (argc
== arg_base
+ 7)))
7064 show_lsa_detail(vty
, ospf
, type
, &id
, NULL
, json_vrf
);
7065 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
7066 else if ((argc
== arg_base
+ 7)
7067 || (uj
&& (argc
== arg_base
+ 8))) {
7068 if (strncmp(argv
[arg_base
+ 6]->text
, "s", 1) == 0)
7069 adv_router
= ospf
->router_id
;
7071 ret
= inet_aton(argv
[arg_base
+ 7]->arg
,
7076 show_lsa_detail(vty
, ospf
, type
, &id
, &adv_router
,
7083 json_object_object_add(json
, ospf_get_name(ospf
),
7090 DEFUN (show_ip_ospf_database_max
,
7091 show_ip_ospf_database_max_cmd
,
7092 "show ip ospf [vrf <NAME|all>] database <max-age|self-originate> [json]",
7095 "OSPF information\n"
7098 "Database summary\n"
7099 "LSAs in MaxAge list\n"
7100 "Self-originated link states\n"
7103 struct ospf
*ospf
= NULL
;
7104 struct listnode
*node
= NULL
;
7105 char *vrf_name
= NULL
;
7106 bool all_vrf
= false;
7107 int ret
= CMD_SUCCESS
;
7110 uint8_t use_vrf
= 0;
7111 bool uj
= use_json(argc
, argv
);
7112 json_object
*json
= NULL
;
7115 json
= json_object_new_object();
7117 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
7120 bool ospf_output
= false;
7125 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
7126 if (!ospf
->oi_running
)
7129 ret
= show_ip_ospf_database_common(
7130 vty
, ospf
, idx_vrf
? 2 : 0, argc
, argv
,
7135 vty_out(vty
, "%% OSPF is not enabled\n");
7137 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
7138 if (ospf
== NULL
|| !ospf
->oi_running
) {
7140 "%% OSPF is not enabled in vrf %s\n",
7144 ret
= (show_ip_ospf_database_common(
7145 vty
, ospf
, idx_vrf
? 2 : 0, argc
, argv
, use_vrf
,
7149 /* Display default ospf (instance 0) info */
7150 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
7151 if (ospf
== NULL
|| !ospf
->oi_running
) {
7152 vty_out(vty
, "%% OSPF is not enabled in vrf default\n");
7156 ret
= show_ip_ospf_database_common(vty
, ospf
, 0, argc
, argv
,
7161 vty_out(vty
, "%s\n", json_object_to_json_string(json
));
7162 json_object_free(json
);
7168 ALIAS (show_ip_ospf_database_max
,
7169 show_ip_ospf_database_cmd
,
7170 "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]",
7173 "OSPF information\n"
7176 "Database summary\n"
7178 "Link State ID (as an IP address)\n"
7179 "Self-originated link states\n"
7180 "Advertising Router link states\n"
7181 "Advertising Router (as an IP address)\n"
7184 DEFUN (show_ip_ospf_instance_database_max
,
7185 show_ip_ospf_instance_database_max_cmd
,
7186 "show ip ospf (1-65535) database <max-age|self-originate> [json]",
7189 "OSPF information\n"
7191 "Database summary\n"
7192 "LSAs in MaxAge list\n"
7193 "Self-originated link states\n"
7198 unsigned short instance
= 0;
7199 bool uj
= use_json(argc
, argv
);
7200 json_object
*json
= NULL
;
7203 json
= json_object_new_object();
7205 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7206 if (instance
!= ospf_instance
)
7207 return CMD_NOT_MY_INSTANCE
;
7209 ospf
= ospf_lookup_instance(instance
);
7210 if (!ospf
|| !ospf
->oi_running
)
7213 show_ip_ospf_database_common(vty
, ospf
, 1, argc
, argv
, 0, json
, uj
);
7216 vty_json(vty
, json
);
7221 ALIAS (show_ip_ospf_instance_database_max
,
7222 show_ip_ospf_instance_database_cmd
,
7223 "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]",
7226 "OSPF information\n"
7228 "Database summary\n"
7230 "Link State ID (as an IP address)\n"
7231 "Self-originated link states\n"
7232 "Advertising Router link states\n"
7233 "Advertising Router (as an IP address)\n"
7236 static int show_ip_ospf_database_type_adv_router_common(struct vty
*vty
,
7238 int arg_base
, int argc
,
7239 struct cmd_token
**argv
,
7246 struct in_addr adv_router
;
7247 json_object
*json_vrf
= NULL
;
7251 json_vrf
= json_object_new_object();
7256 if (ospf
->instance
) {
7258 json_object_int_add(json
, "ospfInstance",
7261 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
7264 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
7266 /* Show Router ID. */
7268 json_object_string_addf(json_vrf
, "routerId", "%pI4",
7271 vty_out(vty
, "\n OSPF Router with ID (%pI4)\n\n",
7275 /* Set database type to show. */
7276 if (strncmp(argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
7277 type
= OSPF_ROUTER_LSA
;
7278 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
7279 type
= OSPF_NETWORK_LSA
;
7280 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
7281 type
= OSPF_AS_NSSA_LSA
;
7282 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "s", 1) == 0)
7283 type
= OSPF_SUMMARY_LSA
;
7284 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
7285 type
= OSPF_ASBR_SUMMARY_LSA
;
7286 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
7287 type
= OSPF_AS_EXTERNAL_LSA
;
7288 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
7289 type
= OSPF_OPAQUE_LINK_LSA
;
7290 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
7291 type
= OSPF_OPAQUE_AREA_LSA
;
7292 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
7293 type
= OSPF_OPAQUE_AS_LSA
;
7297 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
7298 if (strncmp(argv
[arg_base
+ 5]->text
, "s", 1) == 0)
7299 adv_router
= ospf
->router_id
;
7301 ret
= inet_aton(argv
[arg_base
+ 6]->arg
, &adv_router
);
7306 show_lsa_detail_adv_router(vty
, ospf
, type
, &adv_router
, json_vrf
);
7310 json_object_object_add(json
, ospf_get_name(ospf
),
7317 DEFUN (show_ip_ospf_database_type_adv_router
,
7318 show_ip_ospf_database_type_adv_router_cmd
,
7319 "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]",
7322 "OSPF information\n"
7325 "Database summary\n"
7327 "Advertising Router link states\n"
7328 "Advertising Router (as an IP address)\n"
7329 "Self-originated link states\n"
7332 struct ospf
*ospf
= NULL
;
7333 struct listnode
*node
= NULL
;
7334 char *vrf_name
= NULL
;
7335 bool all_vrf
= false;
7336 int ret
= CMD_SUCCESS
;
7339 uint8_t use_vrf
= 0;
7340 bool uj
= use_json(argc
, argv
);
7341 json_object
*json
= NULL
;
7344 json
= json_object_new_object();
7346 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
7349 bool ospf_output
= false;
7354 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
7355 if (!ospf
->oi_running
)
7358 ret
= show_ip_ospf_database_type_adv_router_common(
7359 vty
, ospf
, 2, argc
, argv
, use_vrf
, json
,
7363 vty_out(vty
, "%% OSPF is not enabled\n");
7365 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
7366 if ((ospf
== NULL
) || !ospf
->oi_running
) {
7368 "%% OSPF is not enabled in vrf %s\n",
7373 ret
= show_ip_ospf_database_type_adv_router_common(
7374 vty
, ospf
, 2, argc
, argv
, use_vrf
, json
, uj
);
7377 /* Display default ospf (instance 0) info */
7378 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
7379 if (ospf
== NULL
|| !ospf
->oi_running
) {
7380 vty_out(vty
, "%% OSPF is not enabled on vrf default\n");
7384 ret
= show_ip_ospf_database_type_adv_router_common(
7385 vty
, ospf
, 0, argc
, argv
, use_vrf
, json
, uj
);
7389 vty_out(vty
, "%s\n", json_object_to_json_string(json
));
7390 json_object_free(json
);
7396 DEFUN (show_ip_ospf_instance_database_type_adv_router
,
7397 show_ip_ospf_instance_database_type_adv_router_cmd
,
7398 "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]",
7401 "OSPF information\n"
7403 "Database summary\n"
7405 "Advertising Router link states\n"
7406 "Advertising Router (as an IP address)\n"
7407 "Self-originated link states\n"
7412 unsigned short instance
= 0;
7413 bool uj
= use_json(argc
, argv
);
7414 json_object
*json
= NULL
;
7417 json
= json_object_new_object();
7419 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7420 if (instance
!= ospf_instance
)
7421 return CMD_NOT_MY_INSTANCE
;
7423 ospf
= ospf_lookup_instance(instance
);
7424 if (!ospf
|| !ospf
->oi_running
)
7427 show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 1, argc
, argv
,
7431 vty_json(vty
, json
);
7436 DEFUN (ip_ospf_authentication_args
,
7437 ip_ospf_authentication_args_addr_cmd
,
7438 "ip ospf authentication <null|message-digest> [A.B.C.D]",
7440 "OSPF interface commands\n"
7441 "Enable authentication on this interface\n"
7442 "Use null authentication\n"
7443 "Use message-digest authentication\n"
7444 "Address of interface\n")
7446 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7447 int idx_encryption
= 3;
7449 struct in_addr addr
;
7451 struct ospf_if_params
*params
;
7453 params
= IF_DEF_PARAMS(ifp
);
7456 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7459 "Please specify interface address by A.B.C.D\n");
7460 return CMD_WARNING_CONFIG_FAILED
;
7463 params
= ospf_get_if_params(ifp
, addr
);
7464 ospf_if_update_params(ifp
, addr
);
7467 /* Handle null authentication */
7468 if (argv
[idx_encryption
]->arg
[0] == 'n') {
7469 SET_IF_PARAM(params
, auth_type
);
7470 params
->auth_type
= OSPF_AUTH_NULL
;
7474 /* Handle message-digest authentication */
7475 if (argv
[idx_encryption
]->arg
[0] == 'm') {
7476 SET_IF_PARAM(params
, auth_type
);
7477 params
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
7481 vty_out(vty
, "You shouldn't get here!\n");
7482 return CMD_WARNING_CONFIG_FAILED
;
7485 DEFUN (ip_ospf_authentication
,
7486 ip_ospf_authentication_addr_cmd
,
7487 "ip ospf authentication [A.B.C.D]",
7489 "OSPF interface commands\n"
7490 "Enable authentication on this interface\n"
7491 "Address of interface\n")
7493 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7495 struct in_addr addr
;
7497 struct ospf_if_params
*params
;
7499 params
= IF_DEF_PARAMS(ifp
);
7502 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7505 "Please specify interface address by A.B.C.D\n");
7506 return CMD_WARNING_CONFIG_FAILED
;
7509 params
= ospf_get_if_params(ifp
, addr
);
7510 ospf_if_update_params(ifp
, addr
);
7513 SET_IF_PARAM(params
, auth_type
);
7514 params
->auth_type
= OSPF_AUTH_SIMPLE
;
7519 DEFUN (no_ip_ospf_authentication_args
,
7520 no_ip_ospf_authentication_args_addr_cmd
,
7521 "no ip ospf authentication <null|message-digest> [A.B.C.D]",
7524 "OSPF interface commands\n"
7525 "Enable authentication on this interface\n"
7526 "Use null authentication\n"
7527 "Use message-digest authentication\n"
7528 "Address of interface\n")
7530 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7531 int idx_encryption
= 4;
7533 struct in_addr addr
;
7535 struct ospf_if_params
*params
;
7536 struct route_node
*rn
;
7539 params
= IF_DEF_PARAMS(ifp
);
7542 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7545 "Please specify interface address by A.B.C.D\n");
7546 return CMD_WARNING_CONFIG_FAILED
;
7549 params
= ospf_lookup_if_params(ifp
, addr
);
7550 if (params
== NULL
) {
7551 vty_out(vty
, "Ip Address specified is unknown\n");
7552 return CMD_WARNING_CONFIG_FAILED
;
7554 params
->auth_type
= OSPF_AUTH_NOTSET
;
7555 UNSET_IF_PARAM(params
, auth_type
);
7556 if (params
!= IF_DEF_PARAMS(ifp
)) {
7557 ospf_free_if_params(ifp
, addr
);
7558 ospf_if_update_params(ifp
, addr
);
7561 if (argv
[idx_encryption
]->arg
[0] == 'n') {
7562 auth_type
= OSPF_AUTH_NULL
;
7563 } else if (argv
[idx_encryption
]->arg
[0] == 'm') {
7564 auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
7566 vty_out(vty
, "Unexpected input encountered\n");
7567 return CMD_WARNING_CONFIG_FAILED
;
7570 * Here we have a case where the user has entered
7571 * 'no ip ospf authentication (null | message_digest )'
7572 * we need to find if we have any ip addresses underneath it
7574 * correspond to the associated type.
7576 if (params
->auth_type
== auth_type
) {
7577 params
->auth_type
= OSPF_AUTH_NOTSET
;
7578 UNSET_IF_PARAM(params
, auth_type
);
7581 for (rn
= route_top(IF_OIFS_PARAMS(ifp
)); rn
;
7582 rn
= route_next(rn
)) {
7583 if ((params
= rn
->info
)) {
7584 if (params
->auth_type
== auth_type
) {
7585 params
->auth_type
= OSPF_AUTH_NOTSET
;
7586 UNSET_IF_PARAM(params
, auth_type
);
7587 if (params
!= IF_DEF_PARAMS(ifp
)) {
7588 ospf_free_if_params(
7589 ifp
, rn
->p
.u
.prefix4
);
7590 ospf_if_update_params(
7591 ifp
, rn
->p
.u
.prefix4
);
7601 DEFUN (no_ip_ospf_authentication
,
7602 no_ip_ospf_authentication_addr_cmd
,
7603 "no ip ospf authentication [A.B.C.D]",
7606 "OSPF interface commands\n"
7607 "Enable authentication on this interface\n"
7608 "Address of interface\n")
7610 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7612 struct in_addr addr
;
7614 struct ospf_if_params
*params
;
7615 struct route_node
*rn
;
7617 params
= IF_DEF_PARAMS(ifp
);
7620 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7623 "Please specify interface address by A.B.C.D\n");
7624 return CMD_WARNING_CONFIG_FAILED
;
7627 params
= ospf_lookup_if_params(ifp
, addr
);
7628 if (params
== NULL
) {
7629 vty_out(vty
, "Ip Address specified is unknown\n");
7630 return CMD_WARNING_CONFIG_FAILED
;
7633 params
->auth_type
= OSPF_AUTH_NOTSET
;
7634 UNSET_IF_PARAM(params
, auth_type
);
7635 if (params
!= IF_DEF_PARAMS(ifp
)) {
7636 ospf_free_if_params(ifp
, addr
);
7637 ospf_if_update_params(ifp
, addr
);
7641 * When a user enters 'no ip ospf authentication'
7642 * We should remove all authentication types from
7645 if ((params
->auth_type
== OSPF_AUTH_NULL
)
7646 || (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
7647 || (params
->auth_type
== OSPF_AUTH_SIMPLE
)) {
7648 params
->auth_type
= OSPF_AUTH_NOTSET
;
7649 UNSET_IF_PARAM(params
, auth_type
);
7652 for (rn
= route_top(IF_OIFS_PARAMS(ifp
)); rn
;
7653 rn
= route_next(rn
)) {
7654 if ((params
= rn
->info
)) {
7656 if ((params
->auth_type
== OSPF_AUTH_NULL
)
7657 || (params
->auth_type
7658 == OSPF_AUTH_CRYPTOGRAPHIC
)
7659 || (params
->auth_type
7660 == OSPF_AUTH_SIMPLE
)) {
7661 params
->auth_type
= OSPF_AUTH_NOTSET
;
7662 UNSET_IF_PARAM(params
, auth_type
);
7663 if (params
!= IF_DEF_PARAMS(ifp
)) {
7664 ospf_free_if_params(
7665 ifp
, rn
->p
.u
.prefix4
);
7666 ospf_if_update_params(
7667 ifp
, rn
->p
.u
.prefix4
);
7678 DEFUN (ip_ospf_authentication_key
,
7679 ip_ospf_authentication_key_addr_cmd
,
7680 "ip ospf authentication-key AUTH_KEY [A.B.C.D]",
7682 "OSPF interface commands\n"
7683 "Authentication password (key)\n"
7684 "The OSPF password (key)\n"
7685 "Address of interface\n")
7687 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7689 struct in_addr addr
;
7690 struct ospf_if_params
*params
;
7692 params
= IF_DEF_PARAMS(ifp
);
7694 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7695 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7697 "Please specify interface address by A.B.C.D\n");
7698 return CMD_WARNING_CONFIG_FAILED
;
7701 params
= ospf_get_if_params(ifp
, addr
);
7702 ospf_if_update_params(ifp
, addr
);
7705 strlcpy((char *)params
->auth_simple
, argv
[3]->arg
,
7706 sizeof(params
->auth_simple
));
7707 SET_IF_PARAM(params
, auth_simple
);
7712 DEFUN_HIDDEN (ospf_authentication_key
,
7713 ospf_authentication_key_cmd
,
7714 "ospf authentication-key AUTH_KEY [A.B.C.D]",
7715 "OSPF interface commands\n"
7716 VLINK_HELPSTR_AUTH_SIMPLE
7717 "Address of interface\n")
7719 return ip_ospf_authentication_key(self
, vty
, argc
, argv
);
7722 DEFUN (no_ip_ospf_authentication_key
,
7723 no_ip_ospf_authentication_key_authkey_addr_cmd
,
7724 "no ip ospf authentication-key [AUTH_KEY [A.B.C.D]]",
7727 "OSPF interface commands\n"
7728 VLINK_HELPSTR_AUTH_SIMPLE
7729 "Address of interface\n")
7731 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7733 struct in_addr addr
;
7734 struct ospf_if_params
*params
;
7735 params
= IF_DEF_PARAMS(ifp
);
7737 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7738 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7740 "Please specify interface address by A.B.C.D\n");
7741 return CMD_WARNING_CONFIG_FAILED
;
7744 params
= ospf_lookup_if_params(ifp
, addr
);
7749 memset(params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
);
7750 UNSET_IF_PARAM(params
, auth_simple
);
7752 if (params
!= IF_DEF_PARAMS(ifp
)) {
7753 ospf_free_if_params(ifp
, addr
);
7754 ospf_if_update_params(ifp
, addr
);
7760 DEFUN_HIDDEN (no_ospf_authentication_key
,
7761 no_ospf_authentication_key_authkey_addr_cmd
,
7762 "no ospf authentication-key [AUTH_KEY [A.B.C.D]]",
7764 "OSPF interface commands\n"
7765 VLINK_HELPSTR_AUTH_SIMPLE
7766 "Address of interface\n")
7768 return no_ip_ospf_authentication_key(self
, vty
, argc
, argv
);
7771 DEFUN (ip_ospf_message_digest_key
,
7772 ip_ospf_message_digest_key_cmd
,
7773 "ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
7775 "OSPF interface commands\n"
7776 "Message digest authentication password (key)\n"
7778 "Use MD5 algorithm\n"
7779 "The OSPF password (key)\n"
7780 "Address of interface\n")
7782 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7783 struct crypt_key
*ck
;
7785 struct in_addr addr
;
7786 struct ospf_if_params
*params
;
7788 params
= IF_DEF_PARAMS(ifp
);
7791 argv_find(argv
, argc
, "(1-255)", &idx
);
7792 char *keyid
= argv
[idx
]->arg
;
7793 argv_find(argv
, argc
, "KEY", &idx
);
7794 char *cryptkey
= argv
[idx
]->arg
;
7796 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7797 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7799 "Please specify interface address by A.B.C.D\n");
7800 return CMD_WARNING_CONFIG_FAILED
;
7803 params
= ospf_get_if_params(ifp
, addr
);
7804 ospf_if_update_params(ifp
, addr
);
7807 key_id
= strtol(keyid
, NULL
, 10);
7809 /* Remove existing key, if any */
7810 ospf_crypt_key_delete(params
->auth_crypt
, key_id
);
7812 ck
= ospf_crypt_key_new();
7813 ck
->key_id
= (uint8_t)key_id
;
7814 strlcpy((char *)ck
->auth_key
, cryptkey
, sizeof(ck
->auth_key
));
7816 ospf_crypt_key_add(params
->auth_crypt
, ck
);
7817 SET_IF_PARAM(params
, auth_crypt
);
7822 DEFUN_HIDDEN (ospf_message_digest_key
,
7823 ospf_message_digest_key_cmd
,
7824 "ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
7825 "OSPF interface commands\n"
7826 "Message digest authentication password (key)\n"
7828 "Use MD5 algorithm\n"
7829 "The OSPF password (key)\n"
7830 "Address of interface\n")
7832 return ip_ospf_message_digest_key(self
, vty
, argc
, argv
);
7835 DEFUN (no_ip_ospf_message_digest_key
,
7836 no_ip_ospf_message_digest_key_cmd
,
7837 "no ip ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
7840 "OSPF interface commands\n"
7841 "Message digest authentication password (key)\n"
7843 "Use MD5 algorithm\n"
7844 "The OSPF password (key)\n"
7845 "Address of interface\n")
7847 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7849 struct crypt_key
*ck
;
7851 struct in_addr addr
;
7852 struct ospf_if_params
*params
;
7853 params
= IF_DEF_PARAMS(ifp
);
7855 argv_find(argv
, argc
, "(1-255)", &idx
);
7856 char *keyid
= argv
[idx
]->arg
;
7858 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7859 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7861 "Please specify interface address by A.B.C.D\n");
7862 return CMD_WARNING_CONFIG_FAILED
;
7865 params
= ospf_lookup_if_params(ifp
, addr
);
7870 key_id
= strtol(keyid
, NULL
, 10);
7871 ck
= ospf_crypt_key_lookup(params
->auth_crypt
, key_id
);
7873 vty_out(vty
, "OSPF: Key %d does not exist\n", key_id
);
7874 return CMD_WARNING_CONFIG_FAILED
;
7877 ospf_crypt_key_delete(params
->auth_crypt
, key_id
);
7879 if (params
!= IF_DEF_PARAMS(ifp
)) {
7880 ospf_free_if_params(ifp
, addr
);
7881 ospf_if_update_params(ifp
, addr
);
7887 DEFUN_HIDDEN (no_ospf_message_digest_key
,
7888 no_ospf_message_digest_key_cmd
,
7889 "no ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
7891 "OSPF interface commands\n"
7892 "Message digest authentication password (key)\n"
7894 "Use MD5 algorithm\n"
7895 "The OSPF password (key)\n"
7896 "Address of interface\n")
7898 return no_ip_ospf_message_digest_key(self
, vty
, argc
, argv
);
7901 DEFUN (ip_ospf_cost
,
7903 "ip ospf cost (1-65535) [A.B.C.D]",
7905 "OSPF interface commands\n"
7908 "Address of interface\n")
7910 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7912 uint32_t cost
= OSPF_OUTPUT_COST_DEFAULT
;
7913 struct in_addr addr
;
7914 struct ospf_if_params
*params
;
7915 params
= IF_DEF_PARAMS(ifp
);
7918 char *coststr
= NULL
, *ifaddr
= NULL
;
7920 argv_find(argv
, argc
, "(1-65535)", &idx
);
7921 coststr
= argv
[idx
]->arg
;
7922 cost
= strtol(coststr
, NULL
, 10);
7924 ifaddr
= argv_find(argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
7926 if (!inet_aton(ifaddr
, &addr
)) {
7928 "Please specify interface address by A.B.C.D\n");
7929 return CMD_WARNING_CONFIG_FAILED
;
7932 params
= ospf_get_if_params(ifp
, addr
);
7933 ospf_if_update_params(ifp
, addr
);
7936 SET_IF_PARAM(params
, output_cost_cmd
);
7937 params
->output_cost_cmd
= cost
;
7939 ospf_if_recalculate_output_cost(ifp
);
7944 DEFUN_HIDDEN (ospf_cost
,
7946 "ospf cost (1-65535) [A.B.C.D]",
7947 "OSPF interface commands\n"
7950 "Address of interface\n")
7952 return ip_ospf_cost(self
, vty
, argc
, argv
);
7955 DEFUN (no_ip_ospf_cost
,
7956 no_ip_ospf_cost_cmd
,
7957 "no ip ospf cost [(1-65535)] [A.B.C.D]",
7960 "OSPF interface commands\n"
7963 "Address of interface\n")
7965 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7967 struct in_addr addr
;
7968 struct ospf_if_params
*params
;
7970 params
= IF_DEF_PARAMS(ifp
);
7973 char *ifaddr
= NULL
;
7974 ifaddr
= argv_find(argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
7976 /* According to the semantics we are mimicking "no ip ospf cost N" is
7977 * always treated as "no ip ospf cost" regardless of the actual value
7978 * of N already configured for the interface. Thus ignore cost. */
7981 if (!inet_aton(ifaddr
, &addr
)) {
7983 "Please specify interface address by A.B.C.D\n");
7984 return CMD_WARNING_CONFIG_FAILED
;
7987 params
= ospf_lookup_if_params(ifp
, addr
);
7992 UNSET_IF_PARAM(params
, output_cost_cmd
);
7994 if (params
!= IF_DEF_PARAMS(ifp
)) {
7995 ospf_free_if_params(ifp
, addr
);
7996 ospf_if_update_params(ifp
, addr
);
7999 ospf_if_recalculate_output_cost(ifp
);
8004 DEFUN_HIDDEN (no_ospf_cost
,
8006 "no ospf cost [(1-65535)] [A.B.C.D]",
8008 "OSPF interface commands\n"
8011 "Address of interface\n")
8013 return no_ip_ospf_cost(self
, vty
, argc
, argv
);
8016 static void ospf_nbr_timer_update(struct ospf_interface
*oi
)
8018 struct route_node
*rn
;
8019 struct ospf_neighbor
*nbr
;
8021 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
))
8022 if ((nbr
= rn
->info
)) {
8023 nbr
->v_inactivity
= OSPF_IF_PARAM(oi
, v_wait
);
8024 nbr
->v_db_desc
= OSPF_IF_PARAM(oi
, retransmit_interval
);
8025 nbr
->v_ls_req
= OSPF_IF_PARAM(oi
, retransmit_interval
);
8026 nbr
->v_ls_upd
= OSPF_IF_PARAM(oi
, retransmit_interval
);
8030 static int ospf_vty_dead_interval_set(struct vty
*vty
, const char *interval_str
,
8031 const char *nbr_str
,
8032 const char *fast_hello_str
)
8034 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8037 struct in_addr addr
;
8039 struct ospf_if_params
*params
;
8040 struct ospf_interface
*oi
;
8041 struct route_node
*rn
;
8043 params
= IF_DEF_PARAMS(ifp
);
8046 ret
= inet_aton(nbr_str
, &addr
);
8049 "Please specify interface address by A.B.C.D\n");
8050 return CMD_WARNING_CONFIG_FAILED
;
8053 params
= ospf_get_if_params(ifp
, addr
);
8054 ospf_if_update_params(ifp
, addr
);
8058 seconds
= strtoul(interval_str
, NULL
, 10);
8060 /* reset fast_hello too, just to be sure */
8061 UNSET_IF_PARAM(params
, fast_hello
);
8062 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
8063 } else if (fast_hello_str
) {
8064 hellomult
= strtoul(fast_hello_str
, NULL
, 10);
8065 /* 1s dead-interval with sub-second hellos desired */
8066 seconds
= OSPF_ROUTER_DEAD_INTERVAL_MINIMAL
;
8067 SET_IF_PARAM(params
, fast_hello
);
8068 params
->fast_hello
= hellomult
;
8071 "Please specify dead-interval or hello-multiplier\n");
8072 return CMD_WARNING_CONFIG_FAILED
;
8075 SET_IF_PARAM(params
, v_wait
);
8076 params
->v_wait
= seconds
;
8077 params
->is_v_wait_set
= true;
8079 /* Update timer values in neighbor structure. */
8081 struct ospf
*ospf
= NULL
;
8083 ospf
= ifp
->vrf
->info
;
8085 oi
= ospf_if_lookup_by_local_addr(ospf
, ifp
, addr
);
8087 ospf_nbr_timer_update(oi
);
8090 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
))
8091 if ((oi
= rn
->info
))
8092 ospf_nbr_timer_update(oi
);
8098 DEFUN (ip_ospf_dead_interval
,
8099 ip_ospf_dead_interval_cmd
,
8100 "ip ospf dead-interval (1-65535) [A.B.C.D]",
8102 "OSPF interface commands\n"
8103 "Interval time after which a neighbor is declared down\n"
8105 "Address of interface\n")
8108 char *interval
= argv_find(argv
, argc
, "(1-65535)", &idx
)
8112 argv_find(argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
8113 return ospf_vty_dead_interval_set(vty
, interval
, ifaddr
, NULL
);
8117 DEFUN_HIDDEN (ospf_dead_interval
,
8118 ospf_dead_interval_cmd
,
8119 "ospf dead-interval (1-65535) [A.B.C.D]",
8120 "OSPF interface commands\n"
8121 "Interval time after which a neighbor is declared down\n"
8123 "Address of interface\n")
8125 return ip_ospf_dead_interval(self
, vty
, argc
, argv
);
8128 DEFUN (ip_ospf_dead_interval_minimal
,
8129 ip_ospf_dead_interval_minimal_addr_cmd
,
8130 "ip ospf dead-interval minimal hello-multiplier (1-10) [A.B.C.D]",
8132 "OSPF interface commands\n"
8133 "Interval time after which a neighbor is declared down\n"
8134 "Minimal 1s dead-interval with fast sub-second hellos\n"
8135 "Hello multiplier factor\n"
8136 "Number of Hellos to send each second\n"
8137 "Address of interface\n")
8142 return ospf_vty_dead_interval_set(
8143 vty
, NULL
, argv
[idx_ipv4
]->arg
, argv
[idx_number
]->arg
);
8145 return ospf_vty_dead_interval_set(vty
, NULL
, NULL
,
8146 argv
[idx_number
]->arg
);
8149 DEFUN (no_ip_ospf_dead_interval
,
8150 no_ip_ospf_dead_interval_cmd
,
8151 "no ip ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
8154 "OSPF interface commands\n"
8155 "Interval time after which a neighbor is declared down\n"
8157 "Minimal 1s dead-interval with fast sub-second hellos\n"
8158 "Hello multiplier factor\n"
8159 "Number of Hellos to send each second\n"
8160 "Address of interface\n")
8162 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8163 int idx_ipv4
= argc
- 1;
8164 struct in_addr addr
= {.s_addr
= 0L};
8166 struct ospf_if_params
*params
;
8167 struct ospf_interface
*oi
;
8168 struct route_node
*rn
;
8170 params
= IF_DEF_PARAMS(ifp
);
8172 if (argv
[idx_ipv4
]->type
== IPV4_TKN
) {
8173 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
8176 "Please specify interface address by A.B.C.D\n");
8177 return CMD_WARNING_CONFIG_FAILED
;
8180 params
= ospf_lookup_if_params(ifp
, addr
);
8185 UNSET_IF_PARAM(params
, v_wait
);
8186 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
8187 params
->is_v_wait_set
= false;
8189 UNSET_IF_PARAM(params
, fast_hello
);
8190 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
8192 if (params
!= IF_DEF_PARAMS(ifp
)) {
8193 ospf_free_if_params(ifp
, addr
);
8194 ospf_if_update_params(ifp
, addr
);
8197 /* Update timer values in neighbor structure. */
8199 struct ospf
*ospf
= NULL
;
8201 ospf
= ifp
->vrf
->info
;
8203 oi
= ospf_if_lookup_by_local_addr(ospf
, ifp
, addr
);
8205 ospf_nbr_timer_update(oi
);
8208 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
))
8209 if ((oi
= rn
->info
))
8210 ospf_nbr_timer_update(oi
);
8216 DEFUN_HIDDEN (no_ospf_dead_interval
,
8217 no_ospf_dead_interval_cmd
,
8218 "no ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
8220 "OSPF interface commands\n"
8221 "Interval time after which a neighbor is declared down\n"
8223 "Minimal 1s dead-interval with fast sub-second hellos\n"
8224 "Hello multiplier factor\n"
8225 "Number of Hellos to send each second\n"
8226 "Address of interface\n")
8228 return no_ip_ospf_dead_interval(self
, vty
, argc
, argv
);
8231 DEFUN (ip_ospf_hello_interval
,
8232 ip_ospf_hello_interval_cmd
,
8233 "ip ospf hello-interval (1-65535) [A.B.C.D]",
8235 "OSPF interface commands\n"
8236 "Time between HELLO packets\n"
8238 "Address of interface\n")
8240 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8242 struct in_addr addr
= {.s_addr
= 0L};
8243 struct ospf_if_params
*params
;
8244 params
= IF_DEF_PARAMS(ifp
);
8245 uint32_t seconds
= 0;
8246 bool is_addr
= false;
8247 uint32_t old_interval
= 0;
8249 argv_find(argv
, argc
, "(1-65535)", &idx
);
8250 seconds
= strtol(argv
[idx
]->arg
, NULL
, 10);
8252 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
8253 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
8255 "Please specify interface address by A.B.C.D\n");
8256 return CMD_WARNING_CONFIG_FAILED
;
8259 params
= ospf_get_if_params(ifp
, addr
);
8260 ospf_if_update_params(ifp
, addr
);
8264 old_interval
= params
->v_hello
;
8266 /* Return, if same interval is configured. */
8267 if (old_interval
== seconds
)
8270 SET_IF_PARAM(params
, v_hello
);
8271 params
->v_hello
= seconds
;
8273 if (!params
->is_v_wait_set
) {
8274 SET_IF_PARAM(params
, v_wait
);
8276 * The router dead interval should
8277 * be some multiple of the HelloInterval (perhaps 4 times the
8278 * hello interval) and must be the same for all routers
8279 * attached to a common network.
8281 params
->v_wait
= 4 * seconds
;
8284 ospf_reset_hello_timer(ifp
, addr
, is_addr
);
8289 DEFUN_HIDDEN (ospf_hello_interval
,
8290 ospf_hello_interval_cmd
,
8291 "ospf hello-interval (1-65535) [A.B.C.D]",
8292 "OSPF interface commands\n"
8293 "Time between HELLO packets\n"
8295 "Address of interface\n")
8297 return ip_ospf_hello_interval(self
, vty
, argc
, argv
);
8300 DEFUN (no_ip_ospf_hello_interval
,
8301 no_ip_ospf_hello_interval_cmd
,
8302 "no ip ospf hello-interval [(1-65535) [A.B.C.D]]",
8305 "OSPF interface commands\n"
8306 "Time between HELLO packets\n" // ignored
8308 "Address of interface\n")
8310 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8312 struct in_addr addr
= {.s_addr
= 0L};
8313 struct ospf_if_params
*params
;
8314 struct route_node
*rn
;
8316 params
= IF_DEF_PARAMS(ifp
);
8318 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
8319 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
8321 "Please specify interface address by A.B.C.D\n");
8322 return CMD_WARNING_CONFIG_FAILED
;
8325 params
= ospf_lookup_if_params(ifp
, addr
);
8330 UNSET_IF_PARAM(params
, v_hello
);
8331 params
->v_hello
= OSPF_HELLO_INTERVAL_DEFAULT
;
8333 if (!params
->is_v_wait_set
) {
8334 UNSET_IF_PARAM(params
, v_wait
);
8335 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
8338 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
8339 struct ospf_interface
*oi
= rn
->info
;
8344 oi
->type
= IF_DEF_PARAMS(ifp
)->type
;
8345 oi
->ptp_dmvpn
= IF_DEF_PARAMS(ifp
)->ptp_dmvpn
;
8347 if (oi
->state
> ISM_Down
) {
8348 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceDown
);
8349 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceUp
);
8353 if (params
!= IF_DEF_PARAMS(ifp
)) {
8354 ospf_free_if_params(ifp
, addr
);
8355 ospf_if_update_params(ifp
, addr
);
8361 DEFUN_HIDDEN (no_ospf_hello_interval
,
8362 no_ospf_hello_interval_cmd
,
8363 "no ospf hello-interval [(1-65535) [A.B.C.D]]",
8365 "OSPF interface commands\n"
8366 "Time between HELLO packets\n" // ignored
8368 "Address of interface\n")
8370 return no_ip_ospf_hello_interval(self
, vty
, argc
, argv
);
8373 DEFUN(ip_ospf_network
, ip_ospf_network_cmd
,
8374 "ip ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point [dmvpn]>",
8376 "OSPF interface commands\n"
8378 "Specify OSPF broadcast multi-access network\n"
8379 "Specify OSPF NBMA network\n"
8380 "Specify OSPF point-to-multipoint network\n"
8381 "Specify OSPF point-to-point network\n"
8382 "Specify OSPF point-to-point DMVPN network\n")
8384 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8386 int old_type
= IF_DEF_PARAMS(ifp
)->type
;
8387 uint8_t old_ptp_dmvpn
= IF_DEF_PARAMS(ifp
)->ptp_dmvpn
;
8388 struct route_node
*rn
;
8390 if (old_type
== OSPF_IFTYPE_LOOPBACK
) {
8392 "This is a loopback interface. Can't set network type.\n");
8393 return CMD_WARNING_CONFIG_FAILED
;
8396 IF_DEF_PARAMS(ifp
)->ptp_dmvpn
= 0;
8398 if (argv_find(argv
, argc
, "broadcast", &idx
))
8399 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_BROADCAST
;
8400 else if (argv_find(argv
, argc
, "non-broadcast", &idx
))
8401 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_NBMA
;
8402 else if (argv_find(argv
, argc
, "point-to-multipoint", &idx
))
8403 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_POINTOMULTIPOINT
;
8404 else if (argv_find(argv
, argc
, "point-to-point", &idx
)) {
8405 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_POINTOPOINT
;
8406 if (argv_find(argv
, argc
, "dmvpn", &idx
))
8407 IF_DEF_PARAMS(ifp
)->ptp_dmvpn
= 1;
8410 if (IF_DEF_PARAMS(ifp
)->type
== old_type
8411 && IF_DEF_PARAMS(ifp
)->ptp_dmvpn
== old_ptp_dmvpn
)
8414 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), type
);
8416 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
8417 struct ospf_interface
*oi
= rn
->info
;
8422 oi
->type
= IF_DEF_PARAMS(ifp
)->type
;
8424 if (oi
->state
> ISM_Down
) {
8425 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceDown
);
8426 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceUp
);
8433 DEFUN_HIDDEN (ospf_network
,
8435 "ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
8436 "OSPF interface commands\n"
8438 "Specify OSPF broadcast multi-access network\n"
8439 "Specify OSPF NBMA network\n"
8440 "Specify OSPF point-to-multipoint network\n"
8441 "Specify OSPF point-to-point network\n")
8443 return ip_ospf_network(self
, vty
, argc
, argv
);
8446 DEFUN (no_ip_ospf_network
,
8447 no_ip_ospf_network_cmd
,
8448 "no ip ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
8451 "OSPF interface commands\n"
8453 "Specify OSPF broadcast multi-access network\n"
8454 "Specify OSPF NBMA network\n"
8455 "Specify OSPF point-to-multipoint network\n"
8456 "Specify OSPF point-to-point network\n")
8458 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8459 int old_type
= IF_DEF_PARAMS(ifp
)->type
;
8460 struct route_node
*rn
;
8462 IF_DEF_PARAMS(ifp
)->type
= ospf_default_iftype(ifp
);
8463 IF_DEF_PARAMS(ifp
)->ptp_dmvpn
= 0;
8465 if (IF_DEF_PARAMS(ifp
)->type
== old_type
)
8468 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
8469 struct ospf_interface
*oi
= rn
->info
;
8474 oi
->type
= IF_DEF_PARAMS(ifp
)->type
;
8476 if (oi
->state
> ISM_Down
) {
8477 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceDown
);
8478 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceUp
);
8485 DEFUN_HIDDEN (no_ospf_network
,
8486 no_ospf_network_cmd
,
8487 "no ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
8489 "OSPF interface commands\n"
8491 "Specify OSPF broadcast multi-access network\n"
8492 "Specify OSPF NBMA network\n"
8493 "Specify OSPF point-to-multipoint network\n"
8494 "Specify OSPF point-to-point network\n")
8496 return no_ip_ospf_network(self
, vty
, argc
, argv
);
8499 DEFUN (ip_ospf_priority
,
8500 ip_ospf_priority_cmd
,
8501 "ip ospf priority (0-255) [A.B.C.D]",
8503 "OSPF interface commands\n"
8506 "Address of interface\n")
8508 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8511 struct route_node
*rn
;
8512 struct in_addr addr
;
8513 struct ospf_if_params
*params
;
8514 params
= IF_DEF_PARAMS(ifp
);
8516 argv_find(argv
, argc
, "(0-255)", &idx
);
8517 priority
= strtol(argv
[idx
]->arg
, NULL
, 10);
8519 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
8520 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
8522 "Please specify interface address by A.B.C.D\n");
8523 return CMD_WARNING_CONFIG_FAILED
;
8526 params
= ospf_get_if_params(ifp
, addr
);
8527 ospf_if_update_params(ifp
, addr
);
8530 SET_IF_PARAM(params
, priority
);
8531 params
->priority
= priority
;
8533 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
8534 struct ospf_interface
*oi
= rn
->info
;
8539 if (PRIORITY(oi
) != OSPF_IF_PARAM(oi
, priority
)) {
8540 PRIORITY(oi
) = OSPF_IF_PARAM(oi
, priority
);
8541 OSPF_ISM_EVENT_SCHEDULE(oi
, ISM_NeighborChange
);
8548 DEFUN_HIDDEN (ospf_priority
,
8550 "ospf priority (0-255) [A.B.C.D]",
8551 "OSPF interface commands\n"
8554 "Address of interface\n")
8556 return ip_ospf_priority(self
, vty
, argc
, argv
);
8559 DEFUN (no_ip_ospf_priority
,
8560 no_ip_ospf_priority_cmd
,
8561 "no ip ospf priority [(0-255) [A.B.C.D]]",
8564 "OSPF interface commands\n"
8565 "Router priority\n" // ignored
8567 "Address of interface\n")
8569 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8571 struct route_node
*rn
;
8572 struct in_addr addr
;
8573 struct ospf_if_params
*params
;
8575 params
= IF_DEF_PARAMS(ifp
);
8577 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
8578 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
8580 "Please specify interface address by A.B.C.D\n");
8581 return CMD_WARNING_CONFIG_FAILED
;
8584 params
= ospf_lookup_if_params(ifp
, addr
);
8589 UNSET_IF_PARAM(params
, priority
);
8590 params
->priority
= OSPF_ROUTER_PRIORITY_DEFAULT
;
8592 if (params
!= IF_DEF_PARAMS(ifp
)) {
8593 ospf_free_if_params(ifp
, addr
);
8594 ospf_if_update_params(ifp
, addr
);
8597 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
8598 struct ospf_interface
*oi
= rn
->info
;
8603 if (PRIORITY(oi
) != OSPF_IF_PARAM(oi
, priority
)) {
8604 PRIORITY(oi
) = OSPF_IF_PARAM(oi
, priority
);
8605 OSPF_ISM_EVENT_SCHEDULE(oi
, ISM_NeighborChange
);
8612 DEFUN_HIDDEN (no_ospf_priority
,
8613 no_ospf_priority_cmd
,
8614 "no ospf priority [(0-255) [A.B.C.D]]",
8616 "OSPF interface commands\n"
8619 "Address of interface\n")
8621 return no_ip_ospf_priority(self
, vty
, argc
, argv
);
8624 DEFUN (ip_ospf_retransmit_interval
,
8625 ip_ospf_retransmit_interval_addr_cmd
,
8626 "ip ospf retransmit-interval (1-65535) [A.B.C.D]",
8628 "OSPF interface commands\n"
8629 "Time between retransmitting lost link state advertisements\n"
8631 "Address of interface\n")
8633 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8636 struct in_addr addr
;
8637 struct ospf_if_params
*params
;
8638 params
= IF_DEF_PARAMS(ifp
);
8640 argv_find(argv
, argc
, "(1-65535)", &idx
);
8641 seconds
= strtol(argv
[idx
]->arg
, NULL
, 10);
8643 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
8644 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
8646 "Please specify interface address by A.B.C.D\n");
8647 return CMD_WARNING_CONFIG_FAILED
;
8650 params
= ospf_get_if_params(ifp
, addr
);
8651 ospf_if_update_params(ifp
, addr
);
8654 SET_IF_PARAM(params
, retransmit_interval
);
8655 params
->retransmit_interval
= seconds
;
8660 DEFUN_HIDDEN (ospf_retransmit_interval
,
8661 ospf_retransmit_interval_cmd
,
8662 "ospf retransmit-interval (1-65535) [A.B.C.D]",
8663 "OSPF interface commands\n"
8664 "Time between retransmitting lost link state advertisements\n"
8666 "Address of interface\n")
8668 return ip_ospf_retransmit_interval(self
, vty
, argc
, argv
);
8671 DEFUN (no_ip_ospf_retransmit_interval
,
8672 no_ip_ospf_retransmit_interval_addr_cmd
,
8673 "no ip ospf retransmit-interval [(1-65535)] [A.B.C.D]",
8676 "OSPF interface commands\n"
8677 "Time between retransmitting lost link state advertisements\n"
8679 "Address of interface\n")
8681 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8683 struct in_addr addr
;
8684 struct ospf_if_params
*params
;
8686 params
= IF_DEF_PARAMS(ifp
);
8688 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
8689 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
8691 "Please specify interface address by A.B.C.D\n");
8692 return CMD_WARNING_CONFIG_FAILED
;
8695 params
= ospf_lookup_if_params(ifp
, addr
);
8700 UNSET_IF_PARAM(params
, retransmit_interval
);
8701 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
8703 if (params
!= IF_DEF_PARAMS(ifp
)) {
8704 ospf_free_if_params(ifp
, addr
);
8705 ospf_if_update_params(ifp
, addr
);
8711 DEFUN_HIDDEN (no_ospf_retransmit_interval
,
8712 no_ospf_retransmit_interval_cmd
,
8713 "no ospf retransmit-interval [(1-65535)] [A.B.C.D]",
8715 "OSPF interface commands\n"
8716 "Time between retransmitting lost link state advertisements\n"
8718 "Address of interface\n")
8720 return no_ip_ospf_retransmit_interval(self
, vty
, argc
, argv
);
8723 DEFUN (ip_ospf_transmit_delay
,
8724 ip_ospf_transmit_delay_addr_cmd
,
8725 "ip ospf transmit-delay (1-65535) [A.B.C.D]",
8727 "OSPF interface commands\n"
8728 "Link state transmit delay\n"
8730 "Address of interface\n")
8732 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8735 struct in_addr addr
;
8736 struct ospf_if_params
*params
;
8738 params
= IF_DEF_PARAMS(ifp
);
8739 argv_find(argv
, argc
, "(1-65535)", &idx
);
8740 seconds
= strtol(argv
[idx
]->arg
, NULL
, 10);
8742 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
8743 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
8745 "Please specify interface address by A.B.C.D\n");
8746 return CMD_WARNING_CONFIG_FAILED
;
8749 params
= ospf_get_if_params(ifp
, addr
);
8750 ospf_if_update_params(ifp
, addr
);
8753 SET_IF_PARAM(params
, transmit_delay
);
8754 params
->transmit_delay
= seconds
;
8759 DEFUN_HIDDEN (ospf_transmit_delay
,
8760 ospf_transmit_delay_cmd
,
8761 "ospf transmit-delay (1-65535) [A.B.C.D]",
8762 "OSPF interface commands\n"
8763 "Link state transmit delay\n"
8765 "Address of interface\n")
8767 return ip_ospf_transmit_delay(self
, vty
, argc
, argv
);
8770 DEFUN (no_ip_ospf_transmit_delay
,
8771 no_ip_ospf_transmit_delay_addr_cmd
,
8772 "no ip ospf transmit-delay [(1-65535)] [A.B.C.D]",
8775 "OSPF interface commands\n"
8776 "Link state transmit delay\n"
8778 "Address of interface\n")
8780 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8782 struct in_addr addr
;
8783 struct ospf_if_params
*params
;
8785 params
= IF_DEF_PARAMS(ifp
);
8787 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
8788 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
8790 "Please specify interface address by A.B.C.D\n");
8791 return CMD_WARNING_CONFIG_FAILED
;
8794 params
= ospf_lookup_if_params(ifp
, addr
);
8799 UNSET_IF_PARAM(params
, transmit_delay
);
8800 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
8802 if (params
!= IF_DEF_PARAMS(ifp
)) {
8803 ospf_free_if_params(ifp
, addr
);
8804 ospf_if_update_params(ifp
, addr
);
8811 DEFUN_HIDDEN (no_ospf_transmit_delay
,
8812 no_ospf_transmit_delay_cmd
,
8813 "no ospf transmit-delay [(1-65535) [A.B.C.D]]",
8815 "OSPF interface commands\n"
8816 "Link state transmit delay\n"
8818 "Address of interface\n")
8820 return no_ip_ospf_transmit_delay(self
, vty
, argc
, argv
);
8823 DEFUN (ip_ospf_area
,
8825 "ip ospf [(1-65535)] area <A.B.C.D|(0-4294967295)> [A.B.C.D]",
8827 "OSPF interface commands\n"
8829 "Enable OSPF on this interface\n"
8830 "OSPF area ID in IP address format\n"
8831 "OSPF area ID as a decimal value\n"
8832 "Address of interface\n")
8834 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8837 struct in_addr area_id
;
8838 struct in_addr addr
;
8839 struct ospf_if_params
*params
= NULL
;
8840 struct route_node
*rn
;
8841 struct ospf
*ospf
= NULL
;
8842 unsigned short instance
= 0;
8846 if (argv_find(argv
, argc
, "(1-65535)", &idx
))
8847 instance
= strtol(argv
[idx
]->arg
, NULL
, 10);
8849 argv_find(argv
, argc
, "area", &idx
);
8850 areaid
= argv
[idx
+ 1]->arg
;
8853 ospf
= ifp
->vrf
->info
;
8855 ospf
= ospf_lookup_instance(instance
);
8857 if (instance
&& instance
!= ospf_instance
) {
8859 * At this point we know we have received
8860 * an instance and there is no ospf instance
8861 * associated with it. This means we are
8862 * in a situation where we have an
8863 * ospf command that is setup for a different
8864 * process(instance). We need to safely
8865 * remove the command from ourselves and
8866 * allow the other instance(process) handle
8867 * the configuration command.
8871 params
= IF_DEF_PARAMS(ifp
);
8872 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
8873 UNSET_IF_PARAM(params
, if_area
);
8877 for (rn
= route_top(IF_OIFS_PARAMS(ifp
)); rn
; rn
= route_next(rn
))
8878 if ((params
= rn
->info
) && OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
8879 UNSET_IF_PARAM(params
, if_area
);
8884 ospf
= ifp
->vrf
->info
;
8886 ospf_interface_area_unset(ospf
, ifp
);
8889 return CMD_NOT_MY_INSTANCE
;
8892 ret
= str2area_id(areaid
, &area_id
, &format
);
8894 vty_out(vty
, "Please specify area by A.B.C.D|<0-4294967295>\n");
8895 return CMD_WARNING_CONFIG_FAILED
;
8897 if (memcmp(ifp
->name
, "VLINK", 5) == 0) {
8898 vty_out(vty
, "Cannot enable OSPF on a virtual link.\n");
8899 return CMD_WARNING_CONFIG_FAILED
;
8903 for (rn
= route_top(ospf
->networks
); rn
; rn
= route_next(rn
)) {
8904 if (rn
->info
!= NULL
) {
8906 "Please remove all network commands first.\n");
8907 return CMD_WARNING_CONFIG_FAILED
;
8912 params
= IF_DEF_PARAMS(ifp
);
8913 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)
8914 && !IPV4_ADDR_SAME(¶ms
->if_area
, &area_id
)) {
8916 "Must remove previous area config before changing ospf area \n");
8917 return CMD_WARNING_CONFIG_FAILED
;
8920 // Check if we have an address arg and proccess it
8921 if (argc
== idx
+ 3) {
8922 if (!inet_aton(argv
[idx
+ 2]->arg
, &addr
)) {
8924 "Please specify Intf Address by A.B.C.D\n");
8925 return CMD_WARNING_CONFIG_FAILED
;
8927 // update/create address-level params
8928 params
= ospf_get_if_params((ifp
), (addr
));
8929 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
8930 if (!IPV4_ADDR_SAME(¶ms
->if_area
, &area_id
)) {
8932 "Must remove previous area/address config before changing ospf area\n");
8933 return CMD_WARNING_CONFIG_FAILED
;
8937 ospf_if_update_params((ifp
), (addr
));
8940 /* enable ospf on this interface with area_id */
8942 SET_IF_PARAM(params
, if_area
);
8943 params
->if_area
= area_id
;
8944 params
->if_area_id_fmt
= format
;
8948 ospf_interface_area_set(ospf
, ifp
);
8953 DEFUN (no_ip_ospf_area
,
8954 no_ip_ospf_area_cmd
,
8955 "no ip ospf [(1-65535)] area [<A.B.C.D|(0-4294967295)> [A.B.C.D]]",
8958 "OSPF interface commands\n"
8960 "Disable OSPF on this interface\n"
8961 "OSPF area ID in IP address format\n"
8962 "OSPF area ID as a decimal value\n"
8963 "Address of interface\n")
8965 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8968 struct ospf_if_params
*params
;
8969 unsigned short instance
= 0;
8970 struct in_addr addr
;
8971 struct in_addr area_id
;
8973 if (argv_find(argv
, argc
, "(1-65535)", &idx
))
8974 instance
= strtol(argv
[idx
]->arg
, NULL
, 10);
8977 ospf
= ifp
->vrf
->info
;
8979 ospf
= ospf_lookup_instance(instance
);
8981 if (instance
&& instance
!= ospf_instance
)
8982 return CMD_NOT_MY_INSTANCE
;
8984 argv_find(argv
, argc
, "area", &idx
);
8986 // Check if we have an address arg and proccess it
8987 if (argc
== idx
+ 3) {
8988 if (!inet_aton(argv
[idx
+ 2]->arg
, &addr
)) {
8990 "Please specify Intf Address by A.B.C.D\n");
8991 return CMD_WARNING_CONFIG_FAILED
;
8993 params
= ospf_lookup_if_params(ifp
, addr
);
8994 if ((params
) == NULL
)
8997 params
= IF_DEF_PARAMS(ifp
);
8999 area_id
= params
->if_area
;
9000 if (!OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
9002 "Can't find specified interface area configuration.\n");
9003 return CMD_WARNING_CONFIG_FAILED
;
9006 UNSET_IF_PARAM(params
, if_area
);
9007 if (params
!= IF_DEF_PARAMS((ifp
))) {
9008 ospf_free_if_params((ifp
), (addr
));
9009 ospf_if_update_params((ifp
), (addr
));
9013 ospf_interface_area_unset(ospf
, ifp
);
9014 ospf_area_check_free(ospf
, area_id
);
9020 DEFUN (ip_ospf_passive
,
9021 ip_ospf_passive_cmd
,
9022 "ip ospf passive [A.B.C.D]",
9024 "OSPF interface commands\n"
9025 "Suppress routing updates on an interface\n"
9026 "Address of interface\n")
9028 VTY_DECLVAR_CONTEXT(interface
, ifp
);
9030 struct in_addr addr
= {.s_addr
= INADDR_ANY
};
9031 struct ospf_if_params
*params
;
9035 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
9038 "Please specify interface address by A.B.C.D\n");
9039 return CMD_WARNING_CONFIG_FAILED
;
9041 params
= ospf_get_if_params(ifp
, addr
);
9042 ospf_if_update_params(ifp
, addr
);
9044 params
= IF_DEF_PARAMS(ifp
);
9047 ospf_passive_interface_update(ifp
, params
, addr
, OSPF_IF_PASSIVE
);
9052 DEFUN (no_ip_ospf_passive
,
9053 no_ip_ospf_passive_cmd
,
9054 "no ip ospf passive [A.B.C.D]",
9057 "OSPF interface commands\n"
9058 "Enable routing updates on an interface\n"
9059 "Address of interface\n")
9061 VTY_DECLVAR_CONTEXT(interface
, ifp
);
9063 struct in_addr addr
= {.s_addr
= INADDR_ANY
};
9064 struct ospf_if_params
*params
;
9068 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
9071 "Please specify interface address by A.B.C.D\n");
9072 return CMD_WARNING_CONFIG_FAILED
;
9074 params
= ospf_lookup_if_params(ifp
, addr
);
9078 params
= IF_DEF_PARAMS(ifp
);
9081 ospf_passive_interface_update(ifp
, params
, addr
, OSPF_IF_ACTIVE
);
9086 DEFUN (ospf_redistribute_source
,
9087 ospf_redistribute_source_cmd
,
9088 "redistribute " FRR_REDIST_STR_OSPFD
" [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
9090 FRR_REDIST_HELP_STR_OSPFD
9091 "Metric for redistributed routes\n"
9092 "OSPF default metric\n"
9093 "OSPF exterior metric type for redistributed routes\n"
9094 "Set OSPF External Type 1/2 metrics\n"
9095 "Route map reference\n"
9096 "Pointer to route-map entries\n")
9098 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9099 int idx_protocol
= 1;
9103 struct ospf_redist
*red
;
9105 bool update
= false;
9107 /* Get distribute source. */
9108 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
9110 return CMD_WARNING_CONFIG_FAILED
;
9112 /* Get metric value. */
9113 if (argv_find(argv
, argc
, "(0-16777214)", &idx
)) {
9114 if (!str2metric(argv
[idx
]->arg
, &metric
))
9115 return CMD_WARNING_CONFIG_FAILED
;
9118 /* Get metric type. */
9119 if (argv_find(argv
, argc
, "(1-2)", &idx
)) {
9120 if (!str2metric_type(argv
[idx
]->arg
, &type
))
9121 return CMD_WARNING_CONFIG_FAILED
;
9125 red
= ospf_redist_lookup(ospf
, source
, 0);
9127 red
= ospf_redist_add(ospf
, source
, 0);
9132 if (argv_find(argv
, argc
, "WORD", &idx
)) {
9133 ospf_routemap_set(red
, argv
[idx
]->arg
);
9135 ospf_routemap_unset(red
);
9138 return ospf_redistribute_update(ospf
, red
, source
, 0, type
,
9141 return ospf_redistribute_set(ospf
, red
, source
, 0, type
,
9145 DEFUN (no_ospf_redistribute_source
,
9146 no_ospf_redistribute_source_cmd
,
9147 "no redistribute " FRR_REDIST_STR_OSPFD
" [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
9150 FRR_REDIST_HELP_STR_OSPFD
9151 "Metric for redistributed routes\n"
9152 "OSPF default metric\n"
9153 "OSPF exterior metric type for redistributed routes\n"
9154 "Set OSPF External Type 1/2 metrics\n"
9155 "Route map reference\n"
9156 "Pointer to route-map entries\n")
9158 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9159 int idx_protocol
= 2;
9161 struct ospf_redist
*red
;
9163 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
9165 return CMD_WARNING_CONFIG_FAILED
;
9167 red
= ospf_redist_lookup(ospf
, source
, 0);
9171 ospf_routemap_unset(red
);
9172 ospf_redist_del(ospf
, source
, 0);
9174 return ospf_redistribute_unset(ospf
, source
, 0);
9177 DEFUN (ospf_redistribute_instance_source
,
9178 ospf_redistribute_instance_source_cmd
,
9179 "redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
9181 "Open Shortest Path First\n"
9182 "Non-main Kernel Routing Table\n"
9183 "Instance ID/Table ID\n"
9184 "Metric for redistributed routes\n"
9185 "OSPF default metric\n"
9186 "OSPF exterior metric type for redistributed routes\n"
9187 "Set OSPF External Type 1/2 metrics\n"
9188 "Route map reference\n"
9189 "Pointer to route-map entries\n")
9191 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9192 int idx_ospf_table
= 1;
9198 unsigned short instance
;
9199 struct ospf_redist
*red
;
9200 bool update
= false;
9202 source
= proto_redistnum(AFI_IP
, argv
[idx_ospf_table
]->text
);
9205 vty_out(vty
, "Unknown instance redistribution\n");
9206 return CMD_WARNING_CONFIG_FAILED
;
9209 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
9211 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
) {
9213 "Instance redistribution in non-instanced OSPF not allowed\n");
9214 return CMD_WARNING_CONFIG_FAILED
;
9217 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
)) {
9218 vty_out(vty
, "Same instance OSPF redistribution not allowed\n");
9219 return CMD_WARNING_CONFIG_FAILED
;
9222 /* Get metric value. */
9223 if (argv_find(argv
, argc
, "metric", &idx
))
9224 if (!str2metric(argv
[idx
+ 1]->arg
, &metric
))
9225 return CMD_WARNING_CONFIG_FAILED
;
9228 /* Get metric type. */
9229 if (argv_find(argv
, argc
, "metric-type", &idx
))
9230 if (!str2metric_type(argv
[idx
+ 1]->arg
, &type
))
9231 return CMD_WARNING_CONFIG_FAILED
;
9233 red
= ospf_redist_lookup(ospf
, source
, instance
);
9235 red
= ospf_redist_add(ospf
, source
, instance
);
9240 if (argv_find(argv
, argc
, "route-map", &idx
))
9241 ospf_routemap_set(red
, argv
[idx
+ 1]->arg
);
9243 ospf_routemap_unset(red
);
9246 return ospf_redistribute_update(ospf
, red
, source
, instance
,
9249 return ospf_redistribute_set(ospf
, red
, source
, instance
, type
,
9253 DEFUN (no_ospf_redistribute_instance_source
,
9254 no_ospf_redistribute_instance_source_cmd
,
9255 "no redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
9258 "Open Shortest Path First\n"
9259 "Non-main Kernel Routing Table\n"
9260 "Instance ID/Table Id\n"
9261 "Metric for redistributed routes\n"
9262 "OSPF default metric\n"
9263 "OSPF exterior metric type for redistributed routes\n"
9264 "Set OSPF External Type 1/2 metrics\n"
9265 "Route map reference\n"
9266 "Pointer to route-map entries\n")
9268 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9269 int idx_ospf_table
= 2;
9271 unsigned int instance
;
9272 struct ospf_redist
*red
;
9275 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
9276 source
= ZEBRA_ROUTE_OSPF
;
9278 source
= ZEBRA_ROUTE_TABLE
;
9280 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
9282 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
) {
9284 "Instance redistribution in non-instanced OSPF not allowed\n");
9285 return CMD_WARNING_CONFIG_FAILED
;
9288 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
)) {
9289 vty_out(vty
, "Same instance OSPF redistribution not allowed\n");
9290 return CMD_WARNING_CONFIG_FAILED
;
9293 red
= ospf_redist_lookup(ospf
, source
, instance
);
9297 ospf_routemap_unset(red
);
9298 ospf_redist_del(ospf
, source
, instance
);
9300 return ospf_redistribute_unset(ospf
, source
, instance
);
9303 DEFUN (ospf_distribute_list_out
,
9304 ospf_distribute_list_out_cmd
,
9305 "distribute-list ACCESSLIST4_NAME out " FRR_REDIST_STR_OSPFD
,
9306 "Filter networks in routing updates\n"
9307 "Access-list name\n"
9309 FRR_REDIST_HELP_STR_OSPFD
)
9311 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9315 char *proto
= argv
[argc
- 1]->text
;
9317 /* Get distribute source. */
9318 source
= proto_redistnum(AFI_IP
, proto
);
9320 return CMD_WARNING_CONFIG_FAILED
;
9322 return ospf_distribute_list_out_set(ospf
, source
, argv
[idx_word
]->arg
);
9325 DEFUN (no_ospf_distribute_list_out
,
9326 no_ospf_distribute_list_out_cmd
,
9327 "no distribute-list ACCESSLIST4_NAME out " FRR_REDIST_STR_OSPFD
,
9329 "Filter networks in routing updates\n"
9330 "Access-list name\n"
9332 FRR_REDIST_HELP_STR_OSPFD
)
9334 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9338 char *proto
= argv
[argc
- 1]->text
;
9339 source
= proto_redistnum(AFI_IP
, proto
);
9341 return CMD_WARNING_CONFIG_FAILED
;
9343 return ospf_distribute_list_out_unset(ospf
, source
,
9344 argv
[idx_word
]->arg
);
9347 /* Default information originate. */
9348 DEFUN (ospf_default_information_originate
,
9349 ospf_default_information_originate_cmd
,
9350 "default-information originate [{always|metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
9351 "Control distribution of default information\n"
9352 "Distribute a default route\n"
9353 "Always advertise default route\n"
9354 "OSPF default metric\n"
9356 "OSPF metric type for default routes\n"
9357 "Set OSPF External Type 1/2 metrics\n"
9358 "Route map reference\n"
9359 "Pointer to route-map entries\n")
9361 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9362 int default_originate
= DEFAULT_ORIGINATE_ZEBRA
;
9365 struct ospf_redist
*red
;
9367 int cur_originate
= ospf
->default_originate
;
9368 bool sameRtmap
= false;
9371 red
= ospf_redist_add(ospf
, DEFAULT_ROUTE
, 0);
9373 /* Check whether "always" was specified */
9374 if (argv_find(argv
, argc
, "always", &idx
))
9375 default_originate
= DEFAULT_ORIGINATE_ALWAYS
;
9377 /* Get metric value */
9378 if (argv_find(argv
, argc
, "(0-16777214)", &idx
)) {
9379 if (!str2metric(argv
[idx
]->arg
, &metric
))
9380 return CMD_WARNING_CONFIG_FAILED
;
9383 /* Get metric type. */
9384 if (argv_find(argv
, argc
, "(1-2)", &idx
)) {
9385 if (!str2metric_type(argv
[idx
]->arg
, &type
))
9386 return CMD_WARNING_CONFIG_FAILED
;
9390 if (argv_find(argv
, argc
, "WORD", &idx
))
9391 rtmap
= argv
[idx
]->arg
;
9393 /* To check if user is providing same route map */
9394 if ((!rtmap
&& !ROUTEMAP_NAME(red
)) ||
9395 (rtmap
&& ROUTEMAP_NAME(red
) &&
9396 (strcmp(rtmap
, ROUTEMAP_NAME(red
)) == 0)))
9399 /* Don't allow if the same lsa is already originated. */
9401 && (red
->dmetric
.type
== type
)
9402 && (red
->dmetric
.value
== metric
)
9403 && (cur_originate
== default_originate
))
9406 /* Updating Metric details */
9407 red
->dmetric
.type
= type
;
9408 red
->dmetric
.value
= metric
;
9410 /* updating route map details */
9412 ospf_routemap_set(red
, rtmap
);
9414 ospf_routemap_unset(red
);
9416 return ospf_redistribute_default_set(ospf
, default_originate
, type
,
9420 DEFUN (no_ospf_default_information_originate
,
9421 no_ospf_default_information_originate_cmd
,
9422 "no default-information originate [{always|metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
9424 "Control distribution of default information\n"
9425 "Distribute a default route\n"
9426 "Always advertise default route\n"
9427 "OSPF default metric\n"
9429 "OSPF metric type for default routes\n"
9430 "Set OSPF External Type 1/2 metrics\n"
9431 "Route map reference\n"
9432 "Pointer to route-map entries\n")
9434 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9435 struct ospf_redist
*red
;
9437 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
9441 ospf_routemap_unset(red
);
9442 ospf_redist_del(ospf
, DEFAULT_ROUTE
, 0);
9444 return ospf_redistribute_default_set(ospf
, DEFAULT_ORIGINATE_NONE
,
9448 DEFUN (ospf_default_metric
,
9449 ospf_default_metric_cmd
,
9450 "default-metric (0-16777214)",
9451 "Set metric of redistributed routes\n"
9454 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9458 if (!str2metric(argv
[idx_number
]->arg
, &metric
))
9459 return CMD_WARNING_CONFIG_FAILED
;
9461 ospf
->default_metric
= metric
;
9466 DEFUN (no_ospf_default_metric
,
9467 no_ospf_default_metric_cmd
,
9468 "no default-metric [(0-16777214)]",
9470 "Set metric of redistributed routes\n"
9473 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9475 ospf
->default_metric
= -1;
9481 DEFUN (ospf_distance
,
9484 "Administrative distance\n"
9485 "OSPF Administrative distance\n")
9487 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9491 distance
= atoi(argv
[idx_number
]->arg
);
9492 if (ospf
->distance_all
!= distance
) {
9493 ospf
->distance_all
= distance
;
9494 ospf_restart_spf(ospf
);
9500 DEFUN (no_ospf_distance
,
9501 no_ospf_distance_cmd
,
9502 "no distance (1-255)",
9504 "Administrative distance\n"
9505 "OSPF Administrative distance\n")
9507 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9509 if (ospf
->distance_all
) {
9510 ospf
->distance_all
= 0;
9511 ospf_restart_spf(ospf
);
9517 DEFUN (no_ospf_distance_ospf
,
9518 no_ospf_distance_ospf_cmd
,
9519 "no distance ospf [{intra-area [(1-255)]|inter-area [(1-255)]|external [(1-255)]}]",
9521 "Administrative distance\n"
9522 "OSPF administrative distance\n"
9523 "Intra-area routes\n"
9524 "Distance for intra-area routes\n"
9525 "Inter-area routes\n"
9526 "Distance for inter-area routes\n"
9528 "Distance for external routes\n")
9530 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9533 if (argv_find(argv
, argc
, "intra-area", &idx
) || argc
== 3)
9534 idx
= ospf
->distance_intra
= 0;
9535 if (argv_find(argv
, argc
, "inter-area", &idx
) || argc
== 3)
9536 idx
= ospf
->distance_inter
= 0;
9537 if (argv_find(argv
, argc
, "external", &idx
) || argc
== 3)
9538 ospf
->distance_external
= 0;
9543 DEFUN (ospf_distance_ospf
,
9544 ospf_distance_ospf_cmd
,
9545 "distance ospf {intra-area (1-255)|inter-area (1-255)|external (1-255)}",
9546 "Administrative distance\n"
9547 "OSPF administrative distance\n"
9548 "Intra-area routes\n"
9549 "Distance for intra-area routes\n"
9550 "Inter-area routes\n"
9551 "Distance for inter-area routes\n"
9553 "Distance for external routes\n")
9555 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9558 ospf
->distance_intra
= 0;
9559 ospf
->distance_inter
= 0;
9560 ospf
->distance_external
= 0;
9562 if (argv_find(argv
, argc
, "intra-area", &idx
))
9563 ospf
->distance_intra
= atoi(argv
[idx
+ 1]->arg
);
9565 if (argv_find(argv
, argc
, "inter-area", &idx
))
9566 ospf
->distance_inter
= atoi(argv
[idx
+ 1]->arg
);
9568 if (argv_find(argv
, argc
, "external", &idx
))
9569 ospf
->distance_external
= atoi(argv
[idx
+ 1]->arg
);
9574 DEFUN (ip_ospf_mtu_ignore
,
9575 ip_ospf_mtu_ignore_addr_cmd
,
9576 "ip ospf mtu-ignore [A.B.C.D]",
9578 "OSPF interface commands\n"
9579 "Disable MTU mismatch detection on this interface\n"
9580 "Address of interface\n")
9582 VTY_DECLVAR_CONTEXT(interface
, ifp
);
9584 struct in_addr addr
;
9587 struct ospf_if_params
*params
;
9588 params
= IF_DEF_PARAMS(ifp
);
9591 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
9594 "Please specify interface address by A.B.C.D\n");
9595 return CMD_WARNING_CONFIG_FAILED
;
9597 params
= ospf_get_if_params(ifp
, addr
);
9598 ospf_if_update_params(ifp
, addr
);
9600 params
->mtu_ignore
= 1;
9601 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
9602 SET_IF_PARAM(params
, mtu_ignore
);
9604 UNSET_IF_PARAM(params
, mtu_ignore
);
9605 if (params
!= IF_DEF_PARAMS(ifp
)) {
9606 ospf_free_if_params(ifp
, addr
);
9607 ospf_if_update_params(ifp
, addr
);
9613 DEFUN (no_ip_ospf_mtu_ignore
,
9614 no_ip_ospf_mtu_ignore_addr_cmd
,
9615 "no ip ospf mtu-ignore [A.B.C.D]",
9618 "OSPF interface commands\n"
9619 "Disable MTU mismatch detection on this interface\n"
9620 "Address of interface\n")
9622 VTY_DECLVAR_CONTEXT(interface
, ifp
);
9624 struct in_addr addr
;
9627 struct ospf_if_params
*params
;
9628 params
= IF_DEF_PARAMS(ifp
);
9631 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
9634 "Please specify interface address by A.B.C.D\n");
9635 return CMD_WARNING_CONFIG_FAILED
;
9637 params
= ospf_get_if_params(ifp
, addr
);
9638 ospf_if_update_params(ifp
, addr
);
9640 params
->mtu_ignore
= 0;
9641 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
9642 SET_IF_PARAM(params
, mtu_ignore
);
9644 UNSET_IF_PARAM(params
, mtu_ignore
);
9645 if (params
!= IF_DEF_PARAMS(ifp
)) {
9646 ospf_free_if_params(ifp
, addr
);
9647 ospf_if_update_params(ifp
, addr
);
9654 DEFUN (ospf_max_metric_router_lsa_admin
,
9655 ospf_max_metric_router_lsa_admin_cmd
,
9656 "max-metric router-lsa administrative",
9657 "OSPF maximum / infinite-distance metric\n"
9658 "Advertise own Router-LSA with infinite distance (stub router)\n"
9659 "Administratively applied, for an indefinite period\n")
9661 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9662 struct listnode
*ln
;
9663 struct ospf_area
*area
;
9665 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
9666 SET_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
9668 if (!CHECK_FLAG(area
->stub_router_state
,
9669 OSPF_AREA_IS_STUB_ROUTED
))
9670 ospf_router_lsa_update_area(area
);
9673 /* Allows for areas configured later to get the property */
9674 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_SET
;
9679 DEFUN (no_ospf_max_metric_router_lsa_admin
,
9680 no_ospf_max_metric_router_lsa_admin_cmd
,
9681 "no max-metric router-lsa administrative",
9683 "OSPF maximum / infinite-distance metric\n"
9684 "Advertise own Router-LSA with infinite distance (stub router)\n"
9685 "Administratively applied, for an indefinite period\n")
9687 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9688 struct listnode
*ln
;
9689 struct ospf_area
*area
;
9691 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
9692 UNSET_FLAG(area
->stub_router_state
,
9693 OSPF_AREA_ADMIN_STUB_ROUTED
);
9695 /* Don't trample on the start-up stub timer */
9696 if (CHECK_FLAG(area
->stub_router_state
,
9697 OSPF_AREA_IS_STUB_ROUTED
)
9698 && !area
->t_stub_router
) {
9699 UNSET_FLAG(area
->stub_router_state
,
9700 OSPF_AREA_IS_STUB_ROUTED
);
9701 ospf_router_lsa_update_area(area
);
9704 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET
;
9708 DEFUN (ospf_max_metric_router_lsa_startup
,
9709 ospf_max_metric_router_lsa_startup_cmd
,
9710 "max-metric router-lsa on-startup (5-86400)",
9711 "OSPF maximum / infinite-distance metric\n"
9712 "Advertise own Router-LSA with infinite distance (stub router)\n"
9713 "Automatically advertise stub Router-LSA on startup of OSPF\n"
9714 "Time (seconds) to advertise self as stub-router\n")
9716 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9718 unsigned int seconds
;
9721 vty_out(vty
, "%% Must supply stub-router period\n");
9722 return CMD_WARNING_CONFIG_FAILED
;
9725 seconds
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
9727 ospf
->stub_router_startup_time
= seconds
;
9732 DEFUN (no_ospf_max_metric_router_lsa_startup
,
9733 no_ospf_max_metric_router_lsa_startup_cmd
,
9734 "no max-metric router-lsa on-startup [(5-86400)]",
9736 "OSPF maximum / infinite-distance metric\n"
9737 "Advertise own Router-LSA with infinite distance (stub router)\n"
9738 "Automatically advertise stub Router-LSA on startup of OSPF\n"
9739 "Time (seconds) to advertise self as stub-router\n")
9741 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9742 struct listnode
*ln
;
9743 struct ospf_area
*area
;
9745 ospf
->stub_router_startup_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
9747 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
9748 SET_FLAG(area
->stub_router_state
,
9749 OSPF_AREA_WAS_START_STUB_ROUTED
);
9750 OSPF_TIMER_OFF(area
->t_stub_router
);
9752 /* Don't trample on admin stub routed */
9753 if (!CHECK_FLAG(area
->stub_router_state
,
9754 OSPF_AREA_ADMIN_STUB_ROUTED
)) {
9755 UNSET_FLAG(area
->stub_router_state
,
9756 OSPF_AREA_IS_STUB_ROUTED
);
9757 ospf_router_lsa_update_area(area
);
9764 DEFUN (ospf_max_metric_router_lsa_shutdown
,
9765 ospf_max_metric_router_lsa_shutdown_cmd
,
9766 "max-metric router-lsa on-shutdown (5-100)",
9767 "OSPF maximum / infinite-distance metric\n"
9768 "Advertise own Router-LSA with infinite distance (stub router)\n"
9769 "Advertise stub-router prior to full shutdown of OSPF\n"
9770 "Time (seconds) to wait till full shutdown\n")
9772 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9774 unsigned int seconds
;
9777 vty_out(vty
, "%% Must supply stub-router shutdown period\n");
9778 return CMD_WARNING_CONFIG_FAILED
;
9781 seconds
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
9783 ospf
->stub_router_shutdown_time
= seconds
;
9788 DEFUN (no_ospf_max_metric_router_lsa_shutdown
,
9789 no_ospf_max_metric_router_lsa_shutdown_cmd
,
9790 "no max-metric router-lsa on-shutdown [(5-100)]",
9792 "OSPF maximum / infinite-distance metric\n"
9793 "Advertise own Router-LSA with infinite distance (stub router)\n"
9794 "Advertise stub-router prior to full shutdown of OSPF\n"
9795 "Time (seconds) to wait till full shutdown\n")
9797 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9799 ospf
->stub_router_shutdown_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
9804 DEFUN (ospf_proactive_arp
,
9805 ospf_proactive_arp_cmd
,
9807 "Allow sending ARP requests proactively\n")
9809 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9811 ospf
->proactive_arp
= true;
9816 DEFUN (no_ospf_proactive_arp
,
9817 no_ospf_proactive_arp_cmd
,
9820 "Disallow sending ARP requests proactively\n")
9822 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9824 ospf
->proactive_arp
= false;
9829 /* Graceful Restart HELPER Commands */
9830 DEFPY(ospf_gr_helper_enable
, ospf_gr_helper_enable_cmd
,
9831 "graceful-restart helper enable [A.B.C.D$address]",
9832 "OSPF Graceful Restart\n"
9834 "Enable Helper support\n"
9835 "Advertising Router-ID\n")
9837 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9840 ospf_gr_helper_support_set_per_routerid(ospf
, &address
,
9845 ospf_gr_helper_support_set(ospf
, OSPF_GR_TRUE
);
9850 DEFPY(no_ospf_gr_helper_enable
,
9851 no_ospf_gr_helper_enable_cmd
,
9852 "no graceful-restart helper enable [A.B.C.D$address]",
9854 "OSPF Graceful Restart\n"
9856 "Enable Helper support\n"
9857 "Advertising Router-ID\n")
9859 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9862 ospf_gr_helper_support_set_per_routerid(ospf
, &address
,
9867 ospf_gr_helper_support_set(ospf
, OSPF_GR_FALSE
);
9871 #if CONFDATE > 20220921
9873 "Time to remove the deprecated \"[no] graceful-restart helper-only\" commands")
9876 DEFPY_HIDDEN(ospf_gr_helper_only
, ospf_gr_helper_only_cmd
,
9877 "graceful-restart helper-only [A.B.C.D]",
9878 "OSPF Graceful Restart\n"
9879 "Enable Helper support\n"
9880 "Advertising router id\n")
9882 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9883 struct in_addr addr
;
9887 "%% This command is deprecated. Please, use `graceful-restart helper enable` instead.\n");
9890 ret
= inet_aton(argv
[2]->arg
, &addr
);
9893 "Please specify the valid routerid address.\n");
9894 return CMD_WARNING_CONFIG_FAILED
;
9897 ospf_gr_helper_support_set_per_routerid(ospf
, &addr
, OSPF_GR_TRUE
);
9901 ospf_gr_helper_support_set(ospf
, OSPF_GR_TRUE
);
9906 ALIAS_HIDDEN(no_ospf_gr_helper_enable
,
9907 no_ospf_gr_helper_only_cmd
,
9908 "no graceful-restart helper-only [A.B.C.D]",
9910 "OSPF Graceful Restart\n"
9911 "Disable Helper support\n"
9912 "Advertising router id\n")
9914 DEFPY(ospf_gr_helper_enable_lsacheck
,
9915 ospf_gr_helper_enable_lsacheck_cmd
,
9916 "graceful-restart helper strict-lsa-checking",
9917 "OSPF Graceful Restart\n"
9919 "Enable strict LSA check\n")
9921 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9923 ospf_gr_helper_lsa_check_set(ospf
, OSPF_GR_TRUE
);
9927 DEFPY(no_ospf_gr_helper_enable_lsacheck
,
9928 no_ospf_gr_helper_enable_lsacheck_cmd
,
9929 "no graceful-restart helper strict-lsa-checking",
9931 "OSPF Graceful Restart\n"
9933 "Disable strict LSA check\n")
9935 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9937 ospf_gr_helper_lsa_check_set(ospf
, OSPF_GR_FALSE
);
9941 DEFPY(ospf_gr_helper_supported_grace_time
,
9942 ospf_gr_helper_supported_grace_time_cmd
,
9943 "graceful-restart helper supported-grace-time (10-1800)$interval",
9944 "OSPF Graceful Restart\n"
9946 "Supported grace timer\n"
9947 "Grace interval(in seconds)\n")
9949 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9951 ospf_gr_helper_supported_gracetime_set(ospf
, interval
);
9955 DEFPY(no_ospf_gr_helper_supported_grace_time
,
9956 no_ospf_gr_helper_supported_grace_time_cmd
,
9957 "no graceful-restart helper supported-grace-time (10-1800)$interval",
9959 "OSPF Graceful Restart\n"
9961 "Supported grace timer\n"
9962 "Grace interval(in seconds)\n")
9964 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9966 ospf_gr_helper_supported_gracetime_set(ospf
, OSPF_MAX_GRACE_INTERVAL
);
9970 DEFPY(ospf_gr_helper_planned_only
,
9971 ospf_gr_helper_planned_only_cmd
,
9972 "graceful-restart helper planned-only",
9973 "OSPF Graceful Restart\n"
9975 "Supported only planned restart\n")
9977 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9979 ospf_gr_helper_set_supported_planned_only_restart(ospf
, OSPF_GR_TRUE
);
9984 /* External Route Aggregation */
9985 DEFUN (ospf_external_route_aggregation
,
9986 ospf_external_route_aggregation_cmd
,
9987 "summary-address A.B.C.D/M [tag (1-4294967295)]",
9988 "External summary address\n"
9989 "Summary address prefix\n"
9991 "Router tag value\n")
9993 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9994 struct prefix_ipv4 p
;
9996 route_tag_t tag
= 0;
9997 int ret
= OSPF_SUCCESS
;
9999 str2prefix_ipv4(argv
[idx
]->arg
, &p
);
10001 if (is_default_prefix4(&p
)) {
10003 "Default address shouldn't be configured as summary address.\n");
10004 return CMD_SUCCESS
;
10007 /* Apply mask for given prefix. */
10008 apply_mask((struct prefix
*)&p
);
10010 if (!is_valid_summary_addr(&p
)) {
10011 vty_out(vty
, "Not a valid summary address.\n");
10012 return CMD_WARNING_CONFIG_FAILED
;
10016 tag
= strtoul(argv
[idx
+ 2]->arg
, NULL
, 10);
10018 ret
= ospf_asbr_external_aggregator_set(ospf
, &p
, tag
);
10019 if (ret
== OSPF_INVALID
)
10020 vty_out(vty
, "Invalid configuration!!\n");
10022 return CMD_SUCCESS
;
10025 DEFUN (no_ospf_external_route_aggregation
,
10026 no_ospf_external_route_aggregation_cmd
,
10027 "no summary-address A.B.C.D/M [tag (1-4294967295)]",
10029 "External summary address\n"
10030 "Summary address prefix\n"
10032 "Router tag value\n")
10034 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
10035 struct prefix_ipv4 p
;
10037 route_tag_t tag
= 0;
10038 int ret
= OSPF_SUCCESS
;
10040 str2prefix_ipv4(argv
[idx
]->arg
, &p
);
10042 if (is_default_prefix4(&p
)) {
10044 "Default address shouldn't be configured as summary address.\n");
10045 return CMD_SUCCESS
;
10048 /* Apply mask for given prefix. */
10049 apply_mask((struct prefix
*)&p
);
10051 if (!is_valid_summary_addr(&p
)) {
10052 vty_out(vty
, "Not a valid summary address.\n");
10053 return CMD_WARNING_CONFIG_FAILED
;
10057 tag
= strtoul(argv
[idx
+ 2]->arg
, NULL
, 10);
10059 ret
= ospf_asbr_external_aggregator_unset(ospf
, &p
, tag
);
10060 if (ret
== OSPF_INVALID
)
10061 vty_out(vty
, "Invalid configuration!!\n");
10063 return CMD_SUCCESS
;
10066 DEFPY(no_ospf_gr_helper_planned_only
,
10067 no_ospf_gr_helper_planned_only_cmd
,
10068 "no graceful-restart helper planned-only",
10070 "OSPF Graceful Restart\n"
10072 "Supported only for planned restart\n")
10074 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
10076 ospf_gr_helper_set_supported_planned_only_restart(ospf
, OSPF_GR_FALSE
);
10078 return CMD_SUCCESS
;
10081 static int ospf_print_vty_helper_dis_rtr_walkcb(struct hash_bucket
*bucket
,
10084 struct advRtr
*rtr
= bucket
->data
;
10085 struct vty
*vty
= (struct vty
*)arg
;
10086 static unsigned int count
;
10088 vty_out(vty
, "%-6pI4,", &rtr
->advRtrAddr
);
10091 if (count
% 5 == 0)
10092 vty_out(vty
, "\n");
10094 return HASHWALK_CONTINUE
;
10097 static int ospf_show_gr_helper_details(struct vty
*vty
, struct ospf
*ospf
,
10098 uint8_t use_vrf
, json_object
*json
,
10099 bool uj
, bool detail
)
10101 struct listnode
*node
;
10102 struct ospf_interface
*oi
;
10103 char buf
[PREFIX_STRLEN
];
10104 json_object
*json_vrf
= NULL
;
10108 json_vrf
= json_object_new_object();
10113 if (ospf
->instance
) {
10115 json_object_int_add(json
, "ospfInstance",
10118 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
10121 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
10125 json_object_object_add(json
, ospf_get_name(ospf
),
10128 vty_out(vty
, "\n");
10130 /* Show Router ID. */
10132 json_object_string_add(json_vrf
, "routerId",
10133 inet_ntop(AF_INET
, &ospf
->router_id
,
10134 buf
, sizeof(buf
)));
10136 vty_out(vty
, "\n OSPF Router with ID (%pI4)\n\n",
10142 if (ospf
->is_helper_supported
)
10144 " Graceful restart helper support enabled.\n");
10147 " Graceful restart helper support disabled.\n");
10149 if (ospf
->strict_lsa_check
)
10150 vty_out(vty
, " Strict LSA check is enabled.\n");
10152 vty_out(vty
, " Strict LSA check is disabled.\n");
10154 if (ospf
->only_planned_restart
)
10156 " Helper supported for planned restarts only.\n");
10159 " Helper supported for Planned and Unplanned Restarts.\n");
10162 " Supported Graceful restart interval: %d(in seconds).\n",
10163 ospf
->supported_grace_time
);
10165 if (OSPF_HELPER_ENABLE_RTR_COUNT(ospf
)) {
10166 vty_out(vty
, " Enable Router list:\n");
10168 hash_walk(ospf
->enable_rtr_list
,
10169 ospf_print_vty_helper_dis_rtr_walkcb
, vty
);
10170 vty_out(vty
, "\n\n");
10173 if (ospf
->last_exit_reason
!= OSPF_GR_HELPER_EXIT_NONE
) {
10174 vty_out(vty
, " Last Helper exit Reason :%s\n",
10175 ospf_exit_reason2str(ospf
->last_exit_reason
));
10178 if (ospf
->active_restarter_cnt
)
10180 " Number of Active neighbours in graceful restart: %d\n",
10181 ospf
->active_restarter_cnt
);
10183 vty_out(vty
, "\n");
10186 json_object_string_add(
10187 json_vrf
, "helperSupport",
10188 (ospf
->is_helper_supported
) ? "Enabled" : "Disabled");
10189 json_object_string_add(json_vrf
, "strictLsaCheck",
10190 (ospf
->strict_lsa_check
) ? "Enabled"
10192 json_object_string_add(
10193 json_vrf
, "restartSupoort",
10194 (ospf
->only_planned_restart
)
10195 ? "Planned Restart only"
10196 : "Planned and Unplanned Restarts");
10198 json_object_int_add(json_vrf
, "supportedGracePeriod",
10199 ospf
->supported_grace_time
);
10201 #if CONFDATE > 20230131
10202 CPP_NOTICE("Remove JSON object commands with keys starting with capital")
10204 if (ospf
->last_exit_reason
!= OSPF_GR_HELPER_EXIT_NONE
) {
10205 json_object_string_add(
10206 json_vrf
, "LastExitReason",
10207 ospf_exit_reason2str(ospf
->last_exit_reason
));
10208 json_object_string_add(
10209 json_vrf
, "lastExitReason",
10210 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 json_object_object_get_ex(json_vrf
, "neighbors",
10236 if (!json_neighbors
) {
10238 json_object_new_object();
10239 json_object_object_add(json_vrf
,
10242 json_object_object_add(json_vrf
,
10248 for (rn
= route_top(oi
->nbrs
); rn
;
10249 rn
= route_next(rn
)) {
10256 if (!OSPF_GR_IS_ACTIVE_HELPER(nbr
))
10260 vty_out(vty
, " Neighbour %d :\n", cnt
);
10261 vty_out(vty
, " Address : %pI4\n",
10262 &nbr
->address
.u
.prefix4
);
10263 vty_out(vty
, " Routerid : %pI4\n",
10266 " Received Grace period : %d(in seconds).\n",
10267 nbr
->gr_helper_info
10268 .recvd_grace_period
);
10270 " Actual Grace period : %d(in seconds)\n",
10271 nbr
->gr_helper_info
10272 .actual_grace_period
);
10274 " Remaining GraceTime:%ld(in seconds).\n",
10275 thread_timer_remain_second(
10276 nbr
->gr_helper_info
10279 " Graceful Restart reason: %s.\n\n",
10280 ospf_restart_reason2str(
10281 nbr
->gr_helper_info
10282 .gr_restart_reason
));
10285 json_neigh
= json_object_new_object();
10286 json_object_string_add(
10287 json_neigh
, "srcAddr",
10288 inet_ntop(AF_INET
, &nbr
->src
,
10289 buf
, sizeof(buf
)));
10291 json_object_string_add(
10292 json_neigh
, "routerid",
10295 buf
, sizeof(buf
)));
10296 json_object_int_add(
10298 "recvdGraceInterval",
10299 nbr
->gr_helper_info
10300 .recvd_grace_period
);
10301 json_object_int_add(
10303 "actualGraceInterval",
10304 nbr
->gr_helper_info
10305 .actual_grace_period
);
10306 json_object_int_add(
10307 json_neigh
, "remainGracetime",
10308 thread_timer_remain_second(
10309 nbr
->gr_helper_info
10311 json_object_string_add(
10312 json_neigh
, "restartReason",
10313 ospf_restart_reason2str(
10314 nbr
->gr_helper_info
10315 .gr_restart_reason
));
10316 json_object_object_add(
10318 inet_ntop(AF_INET
, &nbr
->src
,
10325 return CMD_SUCCESS
;
10328 DEFUN (ospf_external_route_aggregation_no_adrvertise
,
10329 ospf_external_route_aggregation_no_adrvertise_cmd
,
10330 "summary-address A.B.C.D/M no-advertise",
10331 "External summary address\n"
10332 "Summary address prefix\n"
10333 "Don't advertise summary route \n")
10335 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
10336 struct prefix_ipv4 p
;
10338 int ret
= OSPF_SUCCESS
;
10340 str2prefix_ipv4(argv
[idx
]->arg
, &p
);
10342 if (is_default_prefix4(&p
)) {
10344 "Default address shouldn't be configured as summary address.\n");
10345 return CMD_SUCCESS
;
10348 /* Apply mask for given prefix. */
10349 apply_mask((struct prefix
*)&p
);
10351 if (!is_valid_summary_addr(&p
)) {
10352 vty_out(vty
, "Not a valid summary address.\n");
10353 return CMD_WARNING_CONFIG_FAILED
;
10356 ret
= ospf_asbr_external_rt_no_advertise(ospf
, &p
);
10357 if (ret
== OSPF_INVALID
)
10358 vty_out(vty
, "Invalid configuration!!\n");
10360 return CMD_SUCCESS
;
10363 DEFUN (no_ospf_external_route_aggregation_no_adrvertise
,
10364 no_ospf_external_route_aggregation_no_adrvertise_cmd
,
10365 "no summary-address A.B.C.D/M no-advertise",
10367 "External summary address\n"
10368 "Summary address prefix\n"
10369 "Advertise summary route to the AS \n")
10371 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
10372 struct prefix_ipv4 p
;
10374 int ret
= OSPF_SUCCESS
;
10376 str2prefix_ipv4(argv
[idx
]->arg
, &p
);
10378 if (is_default_prefix4(&p
)) {
10380 "Default address shouldn't be configured as summary address.\n");
10381 return CMD_SUCCESS
;
10384 /* Apply mask for given prefix. */
10385 apply_mask((struct prefix
*)&p
);
10387 if (!is_valid_summary_addr(&p
)) {
10388 vty_out(vty
, "Not a valid summary address.\n");
10389 return CMD_WARNING_CONFIG_FAILED
;
10392 ret
= ospf_asbr_external_rt_advertise(ospf
, &p
);
10393 if (ret
== OSPF_INVALID
)
10394 vty_out(vty
, "Invalid configuration!!\n");
10396 return CMD_SUCCESS
;
10399 DEFUN (ospf_route_aggregation_timer
,
10400 ospf_route_aggregation_timer_cmd
,
10401 "aggregation timer (5-1800)",
10402 "External route aggregation\n"
10403 "Delay timer (in seconds)\n"
10404 "Timer interval(in seconds)\n")
10406 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
10407 uint16_t interval
= 0;
10409 interval
= strtoul(argv
[2]->arg
, NULL
, 10);
10411 ospf_external_aggregator_timer_set(ospf
, interval
);
10413 return CMD_SUCCESS
;
10416 DEFPY (show_ip_ospf_gr_helper
,
10417 show_ip_ospf_gr_helper_cmd
,
10418 "show ip ospf [vrf <NAME|all>] graceful-restart helper [detail] [json]",
10421 "OSPF information\n"
10424 "OSPF Graceful Restart\n"
10425 "Helper details in the router\n"
10426 "Detailed information\n"
10429 char *vrf_name
= NULL
;
10430 bool all_vrf
= false;
10431 int ret
= CMD_SUCCESS
;
10434 uint8_t use_vrf
= 0;
10435 bool uj
= use_json(argc
, argv
);
10436 struct ospf
*ospf
= NULL
;
10437 json_object
*json
= NULL
;
10438 struct listnode
*node
= NULL
;
10440 bool detail
= false;
10442 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
10444 if (argv_find(argv
, argc
, "detail", &idx
))
10448 json
= json_object_new_object();
10450 /* vrf input is provided */
10455 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
10456 if (!ospf
->oi_running
)
10459 ret
= ospf_show_gr_helper_details(
10460 vty
, ospf
, use_vrf
, json
, uj
, detail
);
10464 vty_json(vty
, json
);
10469 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
10471 if (ospf
== NULL
|| !ospf
->oi_running
) {
10474 vty_json(vty
, json
);
10477 "%% OSPF is not enabled in vrf %s\n",
10480 return CMD_SUCCESS
;
10485 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
10487 if (ospf
== NULL
|| !ospf
->oi_running
) {
10490 vty_json(vty
, json
);
10493 "%% OSPF is not enabled in vrf default\n");
10495 return CMD_SUCCESS
;
10498 ospf_show_gr_helper_details(vty
, ospf
, use_vrf
, json
, uj
,
10503 vty_json(vty
, json
);
10505 return CMD_SUCCESS
;
10507 /* Graceful Restart HELPER commands end */
10508 DEFUN (no_ospf_route_aggregation_timer
,
10509 no_ospf_route_aggregation_timer_cmd
,
10510 "no aggregation timer",
10512 "External route aggregation\n"
10515 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
10517 ospf_external_aggregator_timer_set(ospf
, OSPF_EXTL_AGGR_DEFAULT_DELAY
);
10519 return CMD_SUCCESS
;
10522 /* External Route Aggregation End */
10524 static void config_write_stub_router(struct vty
*vty
, struct ospf
*ospf
)
10526 struct listnode
*ln
;
10527 struct ospf_area
*area
;
10529 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
10530 vty_out(vty
, " max-metric router-lsa on-startup %u\n",
10531 ospf
->stub_router_startup_time
);
10532 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
10533 vty_out(vty
, " max-metric router-lsa on-shutdown %u\n",
10534 ospf
->stub_router_shutdown_time
);
10535 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
10536 if (CHECK_FLAG(area
->stub_router_state
,
10537 OSPF_AREA_ADMIN_STUB_ROUTED
)) {
10538 vty_out(vty
, " max-metric router-lsa administrative\n");
10545 #if CONFDATE > 20230131
10546 CPP_NOTICE("Remove JSON object commands with keys containing whitespaces")
10548 static void show_ip_ospf_route_network(struct vty
*vty
, struct ospf
*ospf
,
10549 struct route_table
*rt
,
10552 struct route_node
*rn
;
10553 struct ospf_route
* or ;
10554 struct listnode
*pnode
, *pnnode
;
10555 struct ospf_path
*path
;
10556 json_object
*json_route
= NULL
, *json_nexthop_array
= NULL
,
10557 *json_nexthop
= NULL
;
10561 "============ OSPF network routing table ============\n");
10563 for (rn
= route_top(rt
); rn
; rn
= route_next(rn
)) {
10564 char buf1
[PREFIX2STR_BUFFER
];
10566 if ((or = rn
->info
) == NULL
)
10569 prefix2str(&rn
->p
, buf1
, sizeof(buf1
));
10572 json_route
= json_object_new_object();
10573 json_object_object_add(json
, buf1
, json_route
);
10576 switch (or->path_type
) {
10577 case OSPF_PATH_INTER_AREA
:
10578 if (or->type
== OSPF_DESTINATION_NETWORK
) {
10580 json_object_string_add(json_route
,
10583 json_object_int_add(json_route
, "cost",
10585 json_object_string_addf(
10586 json_route
, "area", "%pI4",
10587 &or->u
.std
.area_id
);
10590 "N IA %-18s [%d] area: %pI4\n",
10592 &or->u
.std
.area_id
);
10594 } else if (or->type
== OSPF_DESTINATION_DISCARD
) {
10596 json_object_string_add(json_route
,
10601 "D IA %-18s Discard entry\n",
10606 case OSPF_PATH_INTRA_AREA
:
10608 json_object_string_add(json_route
, "routeType",
10610 json_object_int_add(json_route
, "cost",
10612 json_object_string_addf(json_route
, "area",
10614 &or->u
.std
.area_id
);
10616 vty_out(vty
, "N %-18s [%d] area: %pI4\n",
10618 &or->u
.std
.area_id
);
10625 if (or->type
== OSPF_DESTINATION_NETWORK
) {
10627 json_nexthop_array
= json_object_new_array();
10628 json_object_object_add(json_route
, "nexthops",
10629 json_nexthop_array
);
10632 for (ALL_LIST_ELEMENTS(or->paths
, pnode
, pnnode
,
10635 json_nexthop
= json_object_new_object();
10636 json_object_array_add(
10637 json_nexthop_array
,
10640 if (if_lookup_by_index(path
->ifindex
,
10643 if (path
->nexthop
.s_addr
10646 json_object_string_add(
10649 json_object_string_add(
10651 "directly attached to",
10655 json_object_string_add(
10657 "directlyAttachedTo",
10663 "%24s directly attached to %s\n",
10671 json_object_string_addf(
10675 json_object_string_add(
10683 "%24s via %pI4, %s\n",
10696 vty_out(vty
, "\n");
10699 static void show_ip_ospf_route_router(struct vty
*vty
, struct ospf
*ospf
,
10700 struct route_table
*rtrs
,
10703 struct route_node
*rn
;
10704 struct ospf_route
* or ;
10705 struct listnode
*pnode
;
10706 struct listnode
*node
;
10707 struct ospf_path
*path
;
10708 char buf
[PREFIX_STRLEN
];
10709 json_object
*json_route
= NULL
, *json_nexthop_array
= NULL
,
10710 *json_nexthop
= NULL
;
10714 "============ OSPF router routing table =============\n");
10716 for (rn
= route_top(rtrs
); rn
; rn
= route_next(rn
)) {
10717 if (rn
->info
== NULL
)
10722 json_route
= json_object_new_object();
10723 json_object_object_add(
10724 json
, inet_ntop(AF_INET
, &rn
->p
.u
.prefix4
,
10727 json_object_string_add(json_route
, "routeType", "R ");
10729 vty_out(vty
, "R %-15pI4 ",
10733 for (ALL_LIST_ELEMENTS_RO((struct list
*)rn
->info
, node
, or)) {
10736 vty_out(vty
, "%24s", "");
10741 json_object_int_add(json_route
, "cost",
10743 json_object_string_addf(json_route
, "area",
10745 &or->u
.std
.area_id
);
10746 if (or->path_type
== OSPF_PATH_INTER_AREA
) {
10747 json_object_boolean_true_add(json_route
,
10749 json_object_boolean_true_add(json_route
,
10752 if (or->u
.std
.flags
& ROUTER_LSA_BORDER
)
10753 json_object_string_add(json_route
,
10756 else if (or->u
.std
.flags
& ROUTER_LSA_EXTERNAL
)
10757 json_object_string_add(json_route
,
10761 vty_out(vty
, "%s [%d] area: %pI4",
10762 (or->path_type
== OSPF_PATH_INTER_AREA
10765 or->cost
, &or->u
.std
.area_id
);
10767 vty_out(vty
, "%s%s\n",
10768 (or->u
.std
.flags
& ROUTER_LSA_BORDER
10771 (or->u
.std
.flags
& ROUTER_LSA_EXTERNAL
10777 json_nexthop_array
= json_object_new_array();
10778 json_object_object_add(json_route
, "nexthops",
10779 json_nexthop_array
);
10782 for (ALL_LIST_ELEMENTS_RO(or->paths
, pnode
, path
)) {
10784 json_nexthop
= json_object_new_object();
10785 json_object_array_add(
10786 json_nexthop_array
,
10789 if (if_lookup_by_index(path
->ifindex
,
10791 if (path
->nexthop
.s_addr
10794 json_object_string_add(
10797 json_object_string_add(
10799 "directly attached to",
10803 json_object_string_add(
10805 "directlyAttachedTo",
10811 "%24s directly attached to %s\n",
10819 json_object_string_addf(
10823 json_object_string_add(
10831 "%24s via %pI4, %s\n",
10844 vty_out(vty
, "\n");
10847 static void show_ip_ospf_route_external(struct vty
*vty
, struct ospf
*ospf
,
10848 struct route_table
*rt
,
10851 struct route_node
*rn
;
10852 struct ospf_route
*er
;
10853 struct listnode
*pnode
, *pnnode
;
10854 struct ospf_path
*path
;
10855 json_object
*json_route
= NULL
, *json_nexthop_array
= NULL
,
10856 *json_nexthop
= NULL
;
10860 "============ OSPF external routing table ===========\n");
10862 for (rn
= route_top(rt
); rn
; rn
= route_next(rn
)) {
10863 if ((er
= rn
->info
) == NULL
)
10868 snprintfrr(buf1
, sizeof(buf1
), "%pFX", &rn
->p
);
10870 json_route
= json_object_new_object();
10871 json_object_object_add(json
, buf1
, json_route
);
10874 switch (er
->path_type
) {
10875 case OSPF_PATH_TYPE1_EXTERNAL
:
10877 json_object_string_add(json_route
, "routeType",
10879 json_object_int_add(json_route
, "cost",
10881 json_object_int_add(json_route
, "tag",
10885 "N E1 %-18s [%d] tag: %" ROUTE_TAG_PRI
10887 buf1
, er
->cost
, er
->u
.ext
.tag
);
10890 case OSPF_PATH_TYPE2_EXTERNAL
:
10892 json_object_string_add(json_route
, "routeType",
10894 json_object_int_add(json_route
, "cost",
10896 json_object_int_add(json_route
, "type2cost",
10897 er
->u
.ext
.type2_cost
);
10898 json_object_int_add(json_route
, "tag",
10902 "N E2 %-18s [%d/%d] tag: %" ROUTE_TAG_PRI
10904 buf1
, er
->cost
, er
->u
.ext
.type2_cost
,
10911 json_nexthop_array
= json_object_new_array();
10912 json_object_object_add(json_route
, "nexthops",
10913 json_nexthop_array
);
10916 for (ALL_LIST_ELEMENTS(er
->paths
, pnode
, pnnode
, path
)) {
10918 json_nexthop
= json_object_new_object();
10919 json_object_array_add(json_nexthop_array
,
10923 if (if_lookup_by_index(path
->ifindex
, ospf
->vrf_id
)) {
10924 if (path
->nexthop
.s_addr
== INADDR_ANY
) {
10926 json_object_string_add(
10927 json_nexthop
, "ip",
10929 json_object_string_add(
10931 "directly attached to",
10935 json_object_string_add(
10937 "directlyAttachedTo",
10943 "%24s directly attached to %s\n",
10951 json_object_string_addf(
10952 json_nexthop
, "ip",
10953 "%pI4", &path
->nexthop
);
10954 json_object_string_add(
10955 json_nexthop
, "via",
10961 "%24s via %pI4, %s\n",
10973 vty_out(vty
, "\n");
10976 static int show_ip_ospf_border_routers_common(struct vty
*vty
,
10980 if (ospf
->instance
)
10981 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
10983 ospf_show_vrf_name(ospf
, vty
, NULL
, use_vrf
);
10985 if (ospf
->new_table
== NULL
) {
10986 vty_out(vty
, "No OSPF routing information exist\n");
10987 return CMD_SUCCESS
;
10990 /* Show Network routes.
10991 show_ip_ospf_route_network (vty, ospf->new_table); */
10993 /* Show Router routes. */
10994 show_ip_ospf_route_router(vty
, ospf
, ospf
->new_rtrs
, NULL
);
10996 vty_out(vty
, "\n");
10998 return CMD_SUCCESS
;
11001 DEFUN (show_ip_ospf_border_routers
,
11002 show_ip_ospf_border_routers_cmd
,
11003 "show ip ospf [vrf <NAME|all>] border-routers",
11006 "OSPF information\n"
11009 "Show all the ABR's and ASBR's\n")
11011 struct ospf
*ospf
= NULL
;
11012 struct listnode
*node
= NULL
;
11013 char *vrf_name
= NULL
;
11014 bool all_vrf
= false;
11015 int ret
= CMD_SUCCESS
;
11018 uint8_t use_vrf
= 0;
11020 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
11023 bool ospf_output
= false;
11028 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
11029 if (!ospf
->oi_running
)
11032 ospf_output
= true;
11033 ret
= show_ip_ospf_border_routers_common(
11034 vty
, ospf
, use_vrf
);
11038 vty_out(vty
, "%% OSPF is not enabled\n");
11040 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
11041 if (ospf
== NULL
|| !ospf
->oi_running
) {
11043 "%% OSPF is not enabled in vrf %s\n",
11045 return CMD_SUCCESS
;
11048 ret
= show_ip_ospf_border_routers_common(vty
, ospf
,
11052 /* Display default ospf (instance 0) info */
11053 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
11054 if (ospf
== NULL
|| !ospf
->oi_running
) {
11055 vty_out(vty
, "%% OSPF is not enabled in vrf default\n");
11056 return CMD_SUCCESS
;
11059 ret
= show_ip_ospf_border_routers_common(vty
, ospf
, use_vrf
);
11065 DEFUN (show_ip_ospf_instance_border_routers
,
11066 show_ip_ospf_instance_border_routers_cmd
,
11067 "show ip ospf (1-65535) border-routers",
11070 "OSPF information\n"
11072 "Show all the ABR's and ASBR's\n")
11074 int idx_number
= 3;
11076 unsigned short instance
= 0;
11078 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11079 if (instance
!= ospf_instance
)
11080 return CMD_NOT_MY_INSTANCE
;
11082 ospf
= ospf_lookup_instance(instance
);
11083 if (!ospf
|| !ospf
->oi_running
)
11084 return CMD_SUCCESS
;
11086 return show_ip_ospf_border_routers_common(vty
, ospf
, 0);
11089 static int show_ip_ospf_route_common(struct vty
*vty
, struct ospf
*ospf
,
11090 json_object
*json
, uint8_t use_vrf
)
11092 json_object
*json_vrf
= NULL
;
11094 if (ospf
->instance
)
11095 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
11100 json_vrf
= json_object_new_object();
11105 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
11107 if (ospf
->new_table
== NULL
) {
11108 vty_out(vty
, "No OSPF routing information exist\n");
11109 return CMD_SUCCESS
;
11112 /* Show Network routes. */
11113 show_ip_ospf_route_network(vty
, ospf
, ospf
->new_table
, json_vrf
);
11115 /* Show Router routes. */
11116 show_ip_ospf_route_router(vty
, ospf
, ospf
->new_rtrs
, json_vrf
);
11118 /* Show AS External routes. */
11119 show_ip_ospf_route_external(vty
, ospf
, ospf
->old_external_route
,
11124 // json_object_object_add(json_vrf, "areas",
11126 json_object_object_add(json
, ospf_get_name(ospf
),
11130 vty_out(vty
, "\n");
11133 return CMD_SUCCESS
;
11136 DEFUN (show_ip_ospf_route
,
11137 show_ip_ospf_route_cmd
,
11138 "show ip ospf [vrf <NAME|all>] route [json]",
11141 "OSPF information\n"
11144 "OSPF routing table\n"
11147 struct ospf
*ospf
= NULL
;
11148 struct listnode
*node
= NULL
;
11149 char *vrf_name
= NULL
;
11150 bool all_vrf
= false;
11151 int ret
= CMD_SUCCESS
;
11154 uint8_t use_vrf
= 0;
11155 bool uj
= use_json(argc
, argv
);
11156 json_object
*json
= NULL
;
11159 json
= json_object_new_object();
11161 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
11163 /* vrf input is provided could be all or specific vrf*/
11165 bool ospf_output
= false;
11170 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
11171 if (!ospf
->oi_running
)
11173 ospf_output
= true;
11174 ret
= show_ip_ospf_route_common(vty
, ospf
, json
,
11179 /* Keep Non-pretty format */
11180 vty_json(vty
, json
);
11181 } else if (!ospf_output
)
11182 vty_out(vty
, "%% OSPF is not enabled\n");
11186 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
11187 if (ospf
== NULL
|| !ospf
->oi_running
) {
11189 vty_json(vty
, json
);
11192 "%% OSPF is not enabled in vrf %s\n",
11195 return CMD_SUCCESS
;
11198 /* Display default ospf (instance 0) info */
11199 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
11200 if (ospf
== NULL
|| !ospf
->oi_running
) {
11202 vty_json(vty
, json
);
11205 "%% OSPF is not enabled in vrf default\n");
11207 return CMD_SUCCESS
;
11212 ret
= show_ip_ospf_route_common(vty
, ospf
, json
, use_vrf
);
11213 /* Keep Non-pretty format */
11215 vty_out(vty
, "%s\n",
11216 json_object_to_json_string_ext(
11217 json
, JSON_C_TO_STRING_NOSLASHESCAPE
));
11221 json_object_free(json
);
11226 DEFUN (show_ip_ospf_instance_route
,
11227 show_ip_ospf_instance_route_cmd
,
11228 "show ip ospf (1-65535) route",
11231 "OSPF information\n"
11233 "OSPF routing table\n")
11235 int idx_number
= 3;
11237 unsigned short instance
= 0;
11239 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11240 if (instance
!= ospf_instance
)
11241 return CMD_NOT_MY_INSTANCE
;
11243 ospf
= ospf_lookup_instance(instance
);
11244 if (!ospf
|| !ospf
->oi_running
)
11245 return CMD_SUCCESS
;
11247 return show_ip_ospf_route_common(vty
, ospf
, NULL
, 0);
11251 DEFUN (show_ip_ospf_vrfs
,
11252 show_ip_ospf_vrfs_cmd
,
11253 "show ip ospf vrfs [json]",
11256 "OSPF information\n"
11257 "Show OSPF VRFs \n"
11260 bool uj
= use_json(argc
, argv
);
11261 json_object
*json
= NULL
;
11262 json_object
*json_vrfs
= NULL
;
11263 struct ospf
*ospf
= NULL
;
11264 struct listnode
*node
= NULL
;
11266 static const char header
[] = "Name Id RouterId ";
11269 json
= json_object_new_object();
11270 json_vrfs
= json_object_new_object();
11273 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
11274 json_object
*json_vrf
= NULL
;
11275 const char *name
= NULL
;
11276 int64_t vrf_id_ui
= 0;
11280 if (!uj
&& count
== 1)
11281 vty_out(vty
, "%s\n", header
);
11283 json_vrf
= json_object_new_object();
11285 name
= ospf_get_name(ospf
);
11287 vrf_id_ui
= (ospf
->vrf_id
== VRF_UNKNOWN
)
11289 : (int64_t)ospf
->vrf_id
;
11292 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
11293 json_object_string_addf(json_vrf
, "routerId", "%pI4",
11296 json_object_object_add(json_vrfs
, name
, json_vrf
);
11299 vty_out(vty
, "%-25s %-5d %-16pI4 \n", name
,
11300 ospf
->vrf_id
, &ospf
->router_id
);
11305 json_object_object_add(json
, "vrfs", json_vrfs
);
11306 json_object_int_add(json
, "totalVrfs", count
);
11308 vty_json(vty
, json
);
11311 vty_out(vty
, "\nTotal number of OSPF VRFs: %d\n",
11315 return CMD_SUCCESS
;
11317 DEFPY (clear_ip_ospf_neighbor
,
11318 clear_ip_ospf_neighbor_cmd
,
11319 "clear ip ospf [(1-65535)]$instance neighbor [A.B.C.D$nbr_id]",
11322 "OSPF information\n"
11324 "Reset OSPF Neighbor\n"
11327 struct listnode
*node
;
11328 struct ospf
*ospf
= NULL
;
11330 /* If user does not specify the arguments,
11331 * instance = 0 and nbr_id = 0.0.0.0
11333 if (instance
!= 0) {
11334 /* This means clear only the particular ospf process */
11335 if (instance
!= ospf_instance
)
11336 return CMD_NOT_MY_INSTANCE
;
11339 /* Clear all the ospf processes */
11340 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
11341 if (!ospf
->oi_running
)
11344 if (nbr_id_str
&& IPV4_ADDR_SAME(&ospf
->router_id
, &nbr_id
)) {
11345 vty_out(vty
, "Self router-id is not allowed.\r\n ");
11346 return CMD_SUCCESS
;
11349 ospf_neighbor_reset(ospf
, nbr_id
, nbr_id_str
);
11352 return CMD_SUCCESS
;
11355 DEFPY (clear_ip_ospf_process
,
11356 clear_ip_ospf_process_cmd
,
11357 "clear ip ospf [(1-65535)]$instance process",
11360 "OSPF information\n"
11362 "Reset OSPF Process\n")
11364 struct listnode
*node
;
11365 struct ospf
*ospf
= NULL
;
11367 /* Check if instance is not passed as an argument */
11368 if (instance
!= 0) {
11369 /* This means clear only the particular ospf process */
11370 if (instance
!= ospf_instance
)
11371 return CMD_NOT_MY_INSTANCE
;
11374 /* Clear all the ospf processes */
11375 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
11376 if (!ospf
->oi_running
)
11379 ospf_process_reset(ospf
);
11382 return CMD_SUCCESS
;
11385 static const char *const ospf_abr_type_str
[] = {
11386 "unknown", "standard", "ibm", "cisco", "shortcut"
11389 static const char *const ospf_shortcut_mode_str
[] = {
11390 "default", "enable", "disable"
11392 static int ospf_vty_external_rt_walkcb(struct hash_bucket
*bucket
,
11395 struct external_info
*ei
= bucket
->data
;
11396 struct vty
*vty
= (struct vty
*)arg
;
11397 static unsigned int count
;
11399 vty_out(vty
, "%-4pI4/%d, ", &ei
->p
.prefix
, ei
->p
.prefixlen
);
11402 if (count
% 5 == 0)
11403 vty_out(vty
, "\n");
11405 if (OSPF_EXTERNAL_RT_COUNT(ei
->aggr_route
) == count
)
11408 return HASHWALK_CONTINUE
;
11411 static int ospf_json_external_rt_walkcb(struct hash_bucket
*bucket
,
11414 struct external_info
*ei
= bucket
->data
;
11415 struct json_object
*json
= (struct json_object
*)arg
;
11416 char buf
[PREFIX2STR_BUFFER
];
11418 static unsigned int count
;
11420 prefix2str(&ei
->p
, buf
, sizeof(buf
));
11422 snprintf(exnalbuf
, 20, "Exnl Addr-%d", count
);
11424 json_object_string_add(json
, exnalbuf
, buf
);
11428 if (OSPF_EXTERNAL_RT_COUNT(ei
->aggr_route
) == count
)
11431 return HASHWALK_CONTINUE
;
11434 static int ospf_show_summary_address(struct vty
*vty
, struct ospf
*ospf
,
11435 uint8_t use_vrf
, json_object
*json
,
11436 bool uj
, bool detail
)
11438 struct route_node
*rn
;
11439 json_object
*json_vrf
= NULL
;
11442 static char header
[] =
11443 "Summary-address Metric-type Metric Tag External_Rt_count\n";
11445 mtype
= metric_type(ospf
, 0, ospf
->instance
);
11446 mval
= metric_value(ospf
, 0, ospf
->instance
);
11449 vty_out(vty
, "%s\n", header
);
11453 json_vrf
= json_object_new_object();
11458 if (ospf
->instance
) {
11460 json_object_int_add(json
, "ospfInstance",
11463 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
11466 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
11469 vty_out(vty
, "aggregation delay interval :%u(in seconds)\n\n",
11470 ospf
->aggr_delay_interval
);
11472 json_object_int_add(json_vrf
, "aggregation delay interval",
11473 ospf
->aggr_delay_interval
);
11474 json_object_int_add(json_vrf
, "aggregationDelayInterval",
11475 ospf
->aggr_delay_interval
);
11478 for (rn
= route_top(ospf
->rt_aggr_tbl
); rn
; rn
= route_next(rn
))
11480 struct ospf_external_aggr_rt
*aggr
= rn
->info
;
11481 json_object
*json_aggr
= NULL
;
11482 char buf
[PREFIX2STR_BUFFER
];
11484 prefix2str(&aggr
->p
, buf
, sizeof(buf
));
11488 json_aggr
= json_object_new_object();
11490 json_object_object_add(json_vrf
, buf
,
11493 json_object_string_add(json_aggr
,
11494 "Summary address", buf
);
11495 json_object_string_add(json_aggr
,
11496 "summaryAddress", buf
);
11498 json_object_string_add(
11499 json_aggr
, "Metric-type",
11500 (mtype
== EXTERNAL_METRIC_TYPE_1
)
11503 json_object_string_add(
11504 json_aggr
, "metricType",
11505 (mtype
== EXTERNAL_METRIC_TYPE_1
)
11509 #if CONFDATE > 20230131
11510 CPP_NOTICE("Remove JSON object commands with keys starting with capital")
11512 json_object_int_add(json_aggr
, "Metric", mval
);
11513 json_object_int_add(json_aggr
, "metric", mval
);
11515 json_object_int_add(json_aggr
, "Tag",
11517 json_object_int_add(json_aggr
, "tag",
11520 json_object_int_add(
11521 json_aggr
, "External route count",
11522 OSPF_EXTERNAL_RT_COUNT(aggr
));
11523 json_object_int_add(
11524 json_aggr
, "externalRouteCount",
11525 OSPF_EXTERNAL_RT_COUNT(aggr
));
11527 if (OSPF_EXTERNAL_RT_COUNT(aggr
) && detail
) {
11529 aggr
->match_extnl_hash
,
11530 ospf_json_external_rt_walkcb
,
11535 vty_out(vty
, "%-20s", buf
);
11537 (mtype
== EXTERNAL_METRIC_TYPE_1
)
11538 ? vty_out(vty
, "%-16s", "E1")
11539 : vty_out(vty
, "%-16s", "E2");
11540 vty_out(vty
, "%-11d", mval
);
11542 vty_out(vty
, "%-12u", aggr
->tag
);
11544 vty_out(vty
, "%-5ld\n",
11545 OSPF_EXTERNAL_RT_COUNT(aggr
));
11547 if (OSPF_EXTERNAL_RT_COUNT(aggr
) && detail
) {
11549 "Matched External routes:\n");
11551 aggr
->match_extnl_hash
,
11552 ospf_vty_external_rt_walkcb
,
11554 vty_out(vty
, "\n");
11557 vty_out(vty
, "\n");
11563 json_object_object_add(json
, ospf_get_name(ospf
),
11566 vty_out(vty
, "\n");
11568 return CMD_SUCCESS
;
11571 DEFUN (show_ip_ospf_external_aggregator
,
11572 show_ip_ospf_external_aggregator_cmd
,
11573 "show ip ospf [vrf <NAME|all>] summary-address [detail] [json]",
11575 "OSPF information\n"
11578 "Show external summary addresses\n"
11579 "Detailed information\n"
11582 char *vrf_name
= NULL
;
11583 bool all_vrf
= false;
11584 int ret
= CMD_SUCCESS
;
11587 uint8_t use_vrf
= 0;
11588 bool uj
= use_json(argc
, argv
);
11589 struct ospf
*ospf
= NULL
;
11590 json_object
*json
= NULL
;
11591 struct listnode
*node
= NULL
;
11593 bool detail
= false;
11595 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
11597 if (argv_find(argv
, argc
, "detail", &idx
))
11601 json
= json_object_new_object();
11603 /* vrf input is provided */
11607 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
11608 if (!ospf
->oi_running
)
11610 ret
= ospf_show_summary_address(
11611 vty
, ospf
, use_vrf
, json
, uj
, detail
);
11615 vty_json(vty
, json
);
11620 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
11622 if (ospf
== NULL
|| !ospf
->oi_running
) {
11624 vty_json(vty
, json
);
11627 "%% OSPF is not enabled in vrf %s\n",
11630 return CMD_SUCCESS
;
11632 ospf_show_summary_address(vty
, ospf
, use_vrf
, json
, uj
, detail
);
11636 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
11637 if (ospf
== NULL
|| !ospf
->oi_running
) {
11639 vty_json(vty
, json
);
11642 "%% OSPF is not enabled in vrf default\n");
11644 return CMD_SUCCESS
;
11647 ospf_show_summary_address(vty
, ospf
, use_vrf
, json
, uj
, detail
);
11651 vty_json(vty
, json
);
11652 return CMD_SUCCESS
;
11655 static const char *const ospf_int_type_str
[] = {
11656 "unknown", /* should never be used. */
11660 "point-to-multipoint",
11661 "virtual-link", /* should never be used. */
11665 static const char *interface_config_auth_str(struct ospf_if_params
*params
)
11667 if (!OSPF_IF_PARAM_CONFIGURED(params
, auth_type
)
11668 || params
->auth_type
== OSPF_AUTH_NOTSET
)
11671 /* Translation tables are not that much help
11672 * here due to syntax
11673 * of the simple option */
11674 switch (params
->auth_type
) {
11676 case OSPF_AUTH_NULL
:
11679 case OSPF_AUTH_SIMPLE
:
11682 case OSPF_AUTH_CRYPTOGRAPHIC
:
11683 return " message-digest";
11689 static int config_write_interface_one(struct vty
*vty
, struct vrf
*vrf
)
11691 struct listnode
*node
;
11692 struct interface
*ifp
;
11693 struct crypt_key
*ck
;
11694 struct route_node
*rn
= NULL
;
11695 struct ospf_if_params
*params
;
11696 const char *auth_str
;
11699 FOR_ALL_INTERFACES (vrf
, ifp
) {
11701 if (memcmp(ifp
->name
, "VLINK", 5) == 0)
11704 if_vty_config_start(vty
, ifp
);
11707 vty_out(vty
, " description %s\n", ifp
->desc
);
11711 params
= IF_DEF_PARAMS(ifp
);
11714 /* Interface Network print. */
11715 if (OSPF_IF_PARAM_CONFIGURED(params
, type
)
11716 && params
->type
!= OSPF_IFTYPE_LOOPBACK
) {
11717 if (params
->type
!= ospf_default_iftype(ifp
)) {
11718 vty_out(vty
, " ip ospf network %s",
11722 == OSPF_IFTYPE_POINTOPOINT
11723 && params
->ptp_dmvpn
)
11724 vty_out(vty
, " dmvpn");
11725 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11726 vty_out(vty
, " %pI4",
11728 vty_out(vty
, "\n");
11732 /* OSPF interface authentication print */
11733 auth_str
= interface_config_auth_str(params
);
11735 vty_out(vty
, " ip ospf authentication%s",
11737 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11738 vty_out(vty
, " %pI4",
11740 vty_out(vty
, "\n");
11743 /* Simple Authentication Password print. */
11744 if (OSPF_IF_PARAM_CONFIGURED(params
, auth_simple
)
11745 && params
->auth_simple
[0] != '\0') {
11746 vty_out(vty
, " ip ospf authentication-key %s",
11747 params
->auth_simple
);
11748 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11749 vty_out(vty
, " %pI4",
11751 vty_out(vty
, "\n");
11754 /* Cryptographic Authentication Key print. */
11755 if (params
&& params
->auth_crypt
) {
11756 for (ALL_LIST_ELEMENTS_RO(params
->auth_crypt
,
11759 " ip ospf message-digest-key %d md5 %s",
11760 ck
->key_id
, ck
->auth_key
);
11761 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11762 vty_out(vty
, " %pI4",
11764 vty_out(vty
, "\n");
11768 /* Interface Output Cost print. */
11769 if (OSPF_IF_PARAM_CONFIGURED(params
, output_cost_cmd
)) {
11770 vty_out(vty
, " ip ospf cost %u",
11771 params
->output_cost_cmd
);
11772 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11773 vty_out(vty
, " %pI4",
11775 vty_out(vty
, "\n");
11778 /* Hello Interval print. */
11779 if (OSPF_IF_PARAM_CONFIGURED(params
, v_hello
)
11780 && params
->v_hello
!= OSPF_HELLO_INTERVAL_DEFAULT
) {
11781 vty_out(vty
, " ip ospf hello-interval %u",
11783 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11784 vty_out(vty
, " %pI4",
11786 vty_out(vty
, "\n");
11790 /* Router Dead Interval print. */
11791 if (OSPF_IF_PARAM_CONFIGURED(params
, v_wait
)
11792 && params
->is_v_wait_set
) {
11793 vty_out(vty
, " ip ospf dead-interval ");
11796 if (OSPF_IF_PARAM_CONFIGURED(params
,
11799 "minimal hello-multiplier %d",
11800 params
->fast_hello
);
11802 vty_out(vty
, "%u", params
->v_wait
);
11804 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11805 vty_out(vty
, " %pI4",
11807 vty_out(vty
, "\n");
11810 /* Router Priority print. */
11811 if (OSPF_IF_PARAM_CONFIGURED(params
, priority
)
11812 && params
->priority
11813 != OSPF_ROUTER_PRIORITY_DEFAULT
) {
11814 vty_out(vty
, " ip ospf priority %u",
11816 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11817 vty_out(vty
, " %pI4",
11819 vty_out(vty
, "\n");
11822 /* Retransmit Interval print. */
11823 if (OSPF_IF_PARAM_CONFIGURED(params
,
11824 retransmit_interval
)
11825 && params
->retransmit_interval
11826 != OSPF_RETRANSMIT_INTERVAL_DEFAULT
) {
11827 vty_out(vty
, " ip ospf retransmit-interval %u",
11828 params
->retransmit_interval
);
11829 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11830 vty_out(vty
, " %pI4",
11832 vty_out(vty
, "\n");
11835 /* Transmit Delay print. */
11836 if (OSPF_IF_PARAM_CONFIGURED(params
, transmit_delay
)
11837 && params
->transmit_delay
11838 != OSPF_TRANSMIT_DELAY_DEFAULT
) {
11839 vty_out(vty
, " ip ospf transmit-delay %u",
11840 params
->transmit_delay
);
11841 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11842 vty_out(vty
, " %pI4",
11844 vty_out(vty
, "\n");
11848 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
11850 vty_out(vty
, " ip ospf %d",
11853 vty_out(vty
, " ip ospf");
11855 char buf
[INET_ADDRSTRLEN
];
11857 area_id2str(buf
, sizeof(buf
), ¶ms
->if_area
,
11858 params
->if_area_id_fmt
);
11859 vty_out(vty
, " area %s", buf
);
11860 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11861 vty_out(vty
, " %pI4",
11863 vty_out(vty
, "\n");
11867 if (params
&& params
->bfd_config
)
11868 ospf_bfd_write_config(vty
, params
);
11870 /* MTU ignore print. */
11871 if (OSPF_IF_PARAM_CONFIGURED(params
, mtu_ignore
)
11872 && params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
) {
11873 if (params
->mtu_ignore
== 0)
11874 vty_out(vty
, " no ip ospf mtu-ignore");
11876 vty_out(vty
, " ip ospf mtu-ignore");
11877 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11878 vty_out(vty
, " %pI4",
11880 vty_out(vty
, "\n");
11883 if (OSPF_IF_PARAM_CONFIGURED(params
,
11884 passive_interface
)) {
11885 vty_out(vty
, " %sip ospf passive",
11886 params
->passive_interface
11890 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11891 vty_out(vty
, " %pI4", &rn
->p
.u
.prefix4
);
11892 vty_out(vty
, "\n");
11895 /* LDP-Sync print */
11896 if (params
&& params
->ldp_sync_info
)
11897 ospf_ldp_sync_if_write_config(vty
, params
);
11901 rn
= route_top(IF_OIFS_PARAMS(ifp
));
11903 rn
= route_next(rn
);
11908 if (params
!= NULL
)
11913 ospf_opaque_config_write_if(vty
, ifp
);
11915 if_vty_config_end(vty
);
11921 /* Configuration write function for ospfd. */
11922 static int config_write_interface(struct vty
*vty
)
11925 struct vrf
*vrf
= NULL
;
11927 /* Display all VRF aware OSPF interface configuration */
11928 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
11929 write
+= config_write_interface_one(vty
, vrf
);
11935 static int config_write_network_area(struct vty
*vty
, struct ospf
*ospf
)
11937 struct route_node
*rn
;
11938 char buf
[INET_ADDRSTRLEN
];
11940 /* `network area' print. */
11941 for (rn
= route_top(ospf
->networks
); rn
; rn
= route_next(rn
))
11943 struct ospf_network
*n
= rn
->info
;
11945 /* Create Area ID string by specified Area ID format. */
11946 if (n
->area_id_fmt
== OSPF_AREA_ID_FMT_DOTTEDQUAD
)
11947 inet_ntop(AF_INET
, &n
->area_id
, buf
,
11950 snprintf(buf
, sizeof(buf
), "%lu",
11951 (unsigned long int)ntohl(
11952 n
->area_id
.s_addr
));
11954 /* Network print. */
11955 vty_out(vty
, " network %pFX area %s\n", &rn
->p
, buf
);
11961 static int config_write_ospf_area(struct vty
*vty
, struct ospf
*ospf
)
11963 struct listnode
*node
;
11964 struct ospf_area
*area
;
11965 char buf
[INET_ADDRSTRLEN
];
11967 /* Area configuration print. */
11968 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
11969 struct route_node
*rn1
;
11971 area_id2str(buf
, sizeof(buf
), &area
->area_id
,
11972 area
->area_id_fmt
);
11974 if (area
->auth_type
!= OSPF_AUTH_NULL
) {
11975 if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
11976 vty_out(vty
, " area %s authentication\n", buf
);
11979 " area %s authentication message-digest\n",
11983 if (area
->shortcut_configured
!= OSPF_SHORTCUT_DEFAULT
)
11984 vty_out(vty
, " area %s shortcut %s\n", buf
,
11985 ospf_shortcut_mode_str
11986 [area
->shortcut_configured
]);
11988 if ((area
->external_routing
== OSPF_AREA_STUB
)
11989 || (area
->external_routing
== OSPF_AREA_NSSA
)) {
11990 if (area
->external_routing
== OSPF_AREA_STUB
) {
11991 vty_out(vty
, " area %s stub", buf
);
11992 if (area
->no_summary
)
11993 vty_out(vty
, " no-summary\n");
11994 vty_out(vty
, "\n");
11995 } else if (area
->external_routing
== OSPF_AREA_NSSA
) {
11996 switch (area
->NSSATranslatorRole
) {
11997 case OSPF_NSSA_ROLE_NEVER
:
11999 " area %s nssa translate-never\n",
12002 case OSPF_NSSA_ROLE_ALWAYS
:
12004 " area %s nssa translate-always\n",
12007 case OSPF_NSSA_ROLE_CANDIDATE
:
12008 vty_out(vty
, " area %s nssa \n", buf
);
12011 if (area
->no_summary
)
12013 " area %s nssa no-summary\n",
12015 if (area
->suppress_fa
)
12017 " area %s nssa suppress-fa\n",
12021 if (area
->default_cost
!= 1)
12022 vty_out(vty
, " area %s default-cost %d\n", buf
,
12023 area
->default_cost
);
12026 for (rn1
= route_top(area
->ranges
); rn1
; rn1
= route_next(rn1
))
12028 struct ospf_area_range
*range
= rn1
->info
;
12030 vty_out(vty
, " area %s range %pFX", buf
,
12033 if (range
->cost_config
12034 != OSPF_AREA_RANGE_COST_UNSPEC
)
12035 vty_out(vty
, " cost %d",
12036 range
->cost_config
);
12038 if (!CHECK_FLAG(range
->flags
,
12039 OSPF_AREA_RANGE_ADVERTISE
))
12040 vty_out(vty
, " not-advertise");
12042 if (CHECK_FLAG(range
->flags
,
12043 OSPF_AREA_RANGE_SUBSTITUTE
))
12044 vty_out(vty
, " substitute %pI4/%d",
12045 &range
->subst_addr
,
12046 range
->subst_masklen
);
12048 vty_out(vty
, "\n");
12051 if (EXPORT_NAME(area
))
12052 vty_out(vty
, " area %s export-list %s\n", buf
,
12053 EXPORT_NAME(area
));
12055 if (IMPORT_NAME(area
))
12056 vty_out(vty
, " area %s import-list %s\n", buf
,
12057 IMPORT_NAME(area
));
12059 if (PREFIX_NAME_IN(area
))
12060 vty_out(vty
, " area %s filter-list prefix %s in\n", buf
,
12061 PREFIX_NAME_IN(area
));
12063 if (PREFIX_NAME_OUT(area
))
12064 vty_out(vty
, " area %s filter-list prefix %s out\n",
12065 buf
, PREFIX_NAME_OUT(area
));
12071 static int config_write_ospf_nbr_nbma(struct vty
*vty
, struct ospf
*ospf
)
12073 struct ospf_nbr_nbma
*nbr_nbma
;
12074 struct route_node
*rn
;
12076 /* Static Neighbor configuration print. */
12077 for (rn
= route_top(ospf
->nbr_nbma
); rn
; rn
= route_next(rn
))
12078 if ((nbr_nbma
= rn
->info
)) {
12079 vty_out(vty
, " neighbor %pI4", &nbr_nbma
->addr
);
12081 if (nbr_nbma
->priority
12082 != OSPF_NEIGHBOR_PRIORITY_DEFAULT
)
12083 vty_out(vty
, " priority %d",
12084 nbr_nbma
->priority
);
12086 if (nbr_nbma
->v_poll
!= OSPF_POLL_INTERVAL_DEFAULT
)
12087 vty_out(vty
, " poll-interval %d",
12090 vty_out(vty
, "\n");
12096 static int config_write_virtual_link(struct vty
*vty
, struct ospf
*ospf
)
12098 struct listnode
*node
;
12099 struct ospf_vl_data
*vl_data
;
12100 const char *auth_str
;
12101 char buf
[INET_ADDRSTRLEN
];
12103 /* Virtual-Link print */
12104 for (ALL_LIST_ELEMENTS_RO(ospf
->vlinks
, node
, vl_data
)) {
12105 struct listnode
*n2
;
12106 struct crypt_key
*ck
;
12107 struct ospf_interface
*oi
;
12109 if (vl_data
!= NULL
) {
12110 area_id2str(buf
, sizeof(buf
), &vl_data
->vl_area_id
,
12111 vl_data
->vl_area_id_fmt
);
12112 oi
= vl_data
->vl_oi
;
12115 if (OSPF_IF_PARAM(oi
, v_hello
)
12116 != OSPF_HELLO_INTERVAL_DEFAULT
12117 || OSPF_IF_PARAM(oi
, v_wait
)
12118 != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
12119 || OSPF_IF_PARAM(oi
, retransmit_interval
)
12120 != OSPF_RETRANSMIT_INTERVAL_DEFAULT
12121 || OSPF_IF_PARAM(oi
, transmit_delay
)
12122 != OSPF_TRANSMIT_DELAY_DEFAULT
)
12124 " area %s virtual-link %pI4 hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d\n",
12125 buf
, &vl_data
->vl_peer
,
12126 OSPF_IF_PARAM(oi
, v_hello
),
12127 OSPF_IF_PARAM(oi
, retransmit_interval
),
12128 OSPF_IF_PARAM(oi
, transmit_delay
),
12129 OSPF_IF_PARAM(oi
, v_wait
));
12131 vty_out(vty
, " area %s virtual-link %pI4\n", buf
,
12132 &vl_data
->vl_peer
);
12134 auth_str
= interface_config_auth_str(
12135 IF_DEF_PARAMS(oi
->ifp
));
12138 " area %s virtual-link %pI4 authentication%s\n",
12139 buf
, &vl_data
->vl_peer
, auth_str
);
12141 if (IF_DEF_PARAMS(vl_data
->vl_oi
->ifp
)->auth_simple
[0]
12144 " area %s virtual-link %pI4 authentication-key %s\n",
12145 buf
, &vl_data
->vl_peer
,
12146 IF_DEF_PARAMS(vl_data
->vl_oi
->ifp
)
12149 for (ALL_LIST_ELEMENTS_RO(
12150 IF_DEF_PARAMS(vl_data
->vl_oi
->ifp
)
12154 " area %s virtual-link %pI4 message-digest-key %d md5 %s\n",
12155 buf
, &vl_data
->vl_peer
,
12156 ck
->key_id
, ck
->auth_key
);
12164 static int config_write_ospf_redistribute(struct vty
*vty
, struct ospf
*ospf
)
12168 /* redistribute print. */
12169 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++) {
12170 struct list
*red_list
;
12171 struct listnode
*node
;
12172 struct ospf_redist
*red
;
12174 red_list
= ospf
->redist
[type
];
12178 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
12179 vty_out(vty
, " redistribute %s",
12180 zebra_route_string(type
));
12182 vty_out(vty
, " %d", red
->instance
);
12184 if (red
->dmetric
.value
>= 0)
12185 vty_out(vty
, " metric %d", red
->dmetric
.value
);
12187 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
12188 vty_out(vty
, " metric-type 1");
12190 if (ROUTEMAP_NAME(red
))
12191 vty_out(vty
, " route-map %s",
12192 ROUTEMAP_NAME(red
));
12194 vty_out(vty
, "\n");
12201 static int ospf_cfg_write_helper_dis_rtr_walkcb(struct hash_bucket
*bucket
,
12204 struct advRtr
*rtr
= bucket
->data
;
12205 struct vty
*vty
= (struct vty
*)arg
;
12207 vty_out(vty
, " graceful-restart helper enable %pI4\n",
12209 return HASHWALK_CONTINUE
;
12212 static void config_write_ospf_gr(struct vty
*vty
, struct ospf
*ospf
)
12214 if (!ospf
->gr_info
.restart_support
)
12217 if (ospf
->gr_info
.grace_period
== OSPF_DFLT_GRACE_INTERVAL
)
12218 vty_out(vty
, " graceful-restart\n");
12220 vty_out(vty
, " graceful-restart grace-period %u\n",
12221 ospf
->gr_info
.grace_period
);
12224 static int config_write_ospf_gr_helper(struct vty
*vty
, struct ospf
*ospf
)
12226 if (ospf
->is_helper_supported
)
12227 vty_out(vty
, " graceful-restart helper enable\n");
12229 if (!ospf
->strict_lsa_check
)
12231 " no graceful-restart helper strict-lsa-checking\n");
12233 if (ospf
->only_planned_restart
)
12234 vty_out(vty
, " graceful-restart helper planned-only\n");
12236 if (ospf
->supported_grace_time
!= OSPF_MAX_GRACE_INTERVAL
)
12238 " graceful-restart helper supported-grace-time %d\n",
12239 ospf
->supported_grace_time
);
12241 if (OSPF_HELPER_ENABLE_RTR_COUNT(ospf
)) {
12242 hash_walk(ospf
->enable_rtr_list
,
12243 ospf_cfg_write_helper_dis_rtr_walkcb
, vty
);
12248 static int config_write_ospf_external_aggregator(struct vty
*vty
,
12251 struct route_node
*rn
;
12253 if (ospf
->aggr_delay_interval
!= OSPF_EXTL_AGGR_DEFAULT_DELAY
)
12254 vty_out(vty
, " aggregation timer %u\n",
12255 ospf
->aggr_delay_interval
);
12257 /* print 'summary-address A.B.C.D/M' */
12258 for (rn
= route_top(ospf
->rt_aggr_tbl
); rn
; rn
= route_next(rn
))
12260 struct ospf_external_aggr_rt
*aggr
= rn
->info
;
12262 vty_out(vty
, " summary-address %pI4/%d",
12263 &aggr
->p
.prefix
, aggr
->p
.prefixlen
);
12265 vty_out(vty
, " tag %u", aggr
->tag
);
12267 if (CHECK_FLAG(aggr
->flags
,
12268 OSPF_EXTERNAL_AGGRT_NO_ADVERTISE
))
12269 vty_out(vty
, " no-advertise");
12271 vty_out(vty
, "\n");
12277 static int config_write_ospf_default_metric(struct vty
*vty
, struct ospf
*ospf
)
12279 if (ospf
->default_metric
!= -1)
12280 vty_out(vty
, " default-metric %d\n", ospf
->default_metric
);
12284 static int config_write_ospf_distribute(struct vty
*vty
, struct ospf
*ospf
)
12287 struct ospf_redist
*red
;
12290 /* distribute-list print. */
12291 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
12292 if (DISTRIBUTE_NAME(ospf
, type
))
12293 vty_out(vty
, " distribute-list %s out %s\n",
12294 DISTRIBUTE_NAME(ospf
, type
),
12295 zebra_route_string(type
));
12297 /* default-information print. */
12298 if (ospf
->default_originate
!= DEFAULT_ORIGINATE_NONE
) {
12299 vty_out(vty
, " default-information originate");
12300 if (ospf
->default_originate
== DEFAULT_ORIGINATE_ALWAYS
)
12301 vty_out(vty
, " always");
12303 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
12305 if (red
->dmetric
.value
>= 0)
12306 vty_out(vty
, " metric %d",
12307 red
->dmetric
.value
);
12309 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
12310 vty_out(vty
, " metric-type 1");
12312 if (ROUTEMAP_NAME(red
))
12313 vty_out(vty
, " route-map %s",
12314 ROUTEMAP_NAME(red
));
12317 vty_out(vty
, "\n");
12324 static int config_write_ospf_distance(struct vty
*vty
, struct ospf
*ospf
)
12326 struct route_node
*rn
;
12327 struct ospf_distance
*odistance
;
12329 if (ospf
->distance_all
)
12330 vty_out(vty
, " distance %d\n", ospf
->distance_all
);
12332 if (ospf
->distance_intra
|| ospf
->distance_inter
12333 || ospf
->distance_external
) {
12334 vty_out(vty
, " distance ospf");
12336 if (ospf
->distance_intra
)
12337 vty_out(vty
, " intra-area %d", ospf
->distance_intra
);
12338 if (ospf
->distance_inter
)
12339 vty_out(vty
, " inter-area %d", ospf
->distance_inter
);
12340 if (ospf
->distance_external
)
12341 vty_out(vty
, " external %d", ospf
->distance_external
);
12343 vty_out(vty
, "\n");
12346 for (rn
= route_top(ospf
->distance_table
); rn
; rn
= route_next(rn
))
12347 if ((odistance
= rn
->info
) != NULL
) {
12348 vty_out(vty
, " distance %d %pFX %s\n",
12349 odistance
->distance
, &rn
->p
,
12350 odistance
->access_list
? odistance
->access_list
12356 static int ospf_config_write_one(struct vty
*vty
, struct ospf
*ospf
)
12360 /* `router ospf' print. */
12361 if (ospf
->instance
&& strcmp(ospf
->name
, VRF_DEFAULT_NAME
)) {
12362 vty_out(vty
, "router ospf %d vrf %s\n", ospf
->instance
,
12364 } else if (ospf
->instance
) {
12365 vty_out(vty
, "router ospf %d\n", ospf
->instance
);
12366 } else if (strcmp(ospf
->name
, VRF_DEFAULT_NAME
)) {
12367 vty_out(vty
, "router ospf vrf %s\n", ospf
->name
);
12369 vty_out(vty
, "router ospf\n");
12371 if (!ospf
->networks
) {
12376 /* Router ID print. */
12377 if (ospf
->router_id_static
.s_addr
!= INADDR_ANY
)
12378 vty_out(vty
, " ospf router-id %pI4\n",
12379 &ospf
->router_id_static
);
12381 /* zebra opaque attributes configuration. */
12382 if (CHECK_FLAG(ospf
->config
, OSPF_SEND_EXTRA_DATA_TO_ZEBRA
))
12383 vty_out(vty
, " ospf send-extra-data zebra\n");
12385 /* ABR type print. */
12386 if (ospf
->abr_type
!= OSPF_ABR_DEFAULT
)
12387 vty_out(vty
, " ospf abr-type %s\n",
12388 ospf_abr_type_str
[ospf
->abr_type
]);
12390 /* log-adjacency-changes flag print. */
12391 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
)) {
12392 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
12393 vty_out(vty
, " log-adjacency-changes detail\n");
12394 else if (!SAVE_OSPF_LOG_ADJACENCY_CHANGES
)
12395 vty_out(vty
, " log-adjacency-changes\n");
12396 } else if (SAVE_OSPF_LOG_ADJACENCY_CHANGES
) {
12397 vty_out(vty
, " no log-adjacency-changes\n");
12400 /* RFC1583 compatibility flag print -- Compatible with CISCO
12402 if (CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
12403 vty_out(vty
, " compatible rfc1583\n");
12405 /* auto-cost reference-bandwidth configuration. */
12406 if (ospf
->ref_bandwidth
!= OSPF_DEFAULT_REF_BANDWIDTH
) {
12408 "! Important: ensure reference bandwidth is consistent across all routers\n");
12409 vty_out(vty
, " auto-cost reference-bandwidth %d\n",
12410 ospf
->ref_bandwidth
);
12413 /* SPF timers print. */
12414 if (ospf
->spf_delay
!= OSPF_SPF_DELAY_DEFAULT
12415 || ospf
->spf_holdtime
!= OSPF_SPF_HOLDTIME_DEFAULT
12416 || ospf
->spf_max_holdtime
!= OSPF_SPF_MAX_HOLDTIME_DEFAULT
)
12417 vty_out(vty
, " timers throttle spf %d %d %d\n", ospf
->spf_delay
,
12418 ospf
->spf_holdtime
, ospf
->spf_max_holdtime
);
12420 /* LSA timers print. */
12421 if (ospf
->min_ls_interval
!= OSPF_MIN_LS_INTERVAL
)
12422 vty_out(vty
, " timers throttle lsa all %d\n",
12423 ospf
->min_ls_interval
);
12424 if (ospf
->min_ls_arrival
!= OSPF_MIN_LS_ARRIVAL
)
12425 vty_out(vty
, " timers lsa min-arrival %d\n",
12426 ospf
->min_ls_arrival
);
12428 /* Write multiplier print. */
12429 if (ospf
->write_oi_count
!= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
)
12430 vty_out(vty
, " ospf write-multiplier %d\n",
12431 ospf
->write_oi_count
);
12433 if (ospf
->max_multipath
!= MULTIPATH_NUM
)
12434 vty_out(vty
, " maximum-paths %d\n", ospf
->max_multipath
);
12436 /* Max-metric router-lsa print */
12437 config_write_stub_router(vty
, ospf
);
12439 /* SPF refresh parameters print. */
12440 if (ospf
->lsa_refresh_interval
!= OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
12441 vty_out(vty
, " refresh timer %d\n", ospf
->lsa_refresh_interval
);
12443 /* Redistribute information print. */
12444 config_write_ospf_redistribute(vty
, ospf
);
12446 /* Graceful Restart print */
12447 config_write_ospf_gr(vty
, ospf
);
12448 config_write_ospf_gr_helper(vty
, ospf
);
12450 /* Print external route aggregation. */
12451 config_write_ospf_external_aggregator(vty
, ospf
);
12453 /* passive-interface print. */
12454 if (ospf
->passive_interface_default
== OSPF_IF_PASSIVE
)
12455 vty_out(vty
, " passive-interface default\n");
12457 /* proactive-arp print. */
12458 if (ospf
->proactive_arp
!= OSPF_PROACTIVE_ARP_DEFAULT
) {
12459 if (ospf
->proactive_arp
)
12460 vty_out(vty
, " proactive-arp\n");
12462 vty_out(vty
, " no proactive-arp\n");
12465 /* TI-LFA print. */
12466 if (ospf
->ti_lfa_enabled
) {
12467 if (ospf
->ti_lfa_protection_type
== OSPF_TI_LFA_NODE_PROTECTION
)
12468 vty_out(vty
, " fast-reroute ti-lfa node-protection\n");
12470 vty_out(vty
, " fast-reroute ti-lfa\n");
12473 /* Network area print. */
12474 config_write_network_area(vty
, ospf
);
12476 /* Area config print. */
12477 config_write_ospf_area(vty
, ospf
);
12479 /* static neighbor print. */
12480 config_write_ospf_nbr_nbma(vty
, ospf
);
12482 /* Virtual-Link print. */
12483 config_write_virtual_link(vty
, ospf
);
12485 /* Default metric configuration. */
12486 config_write_ospf_default_metric(vty
, ospf
);
12488 /* Distribute-list and default-information print. */
12489 config_write_ospf_distribute(vty
, ospf
);
12491 /* Distance configuration. */
12492 config_write_ospf_distance(vty
, ospf
);
12494 ospf_opaque_config_write_router(vty
, ospf
);
12496 /* LDP-Sync print */
12497 ospf_ldp_sync_write_config(vty
, ospf
);
12499 vty_out(vty
, "exit\n");
12505 /* OSPF configuration write function. */
12506 static int ospf_config_write(struct vty
*vty
)
12509 struct listnode
*ospf_node
= NULL
;
12512 if (listcount(om
->ospf
) == 0)
12515 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, ospf_node
, ospf
)) {
12516 /* VRF Default check if it is running.
12517 * Upon daemon start, there could be default instance
12518 * in absence of 'router ospf'/oi_running is disabled. */
12519 if (ospf
->vrf_id
== VRF_DEFAULT
&& ospf
->oi_running
)
12520 write
+= ospf_config_write_one(vty
, ospf
);
12521 /* For Non-Default VRF simply display the configuration,
12522 * even if it is not oi_running. */
12523 else if (ospf
->vrf_id
!= VRF_DEFAULT
)
12524 write
+= ospf_config_write_one(vty
, ospf
);
12529 void ospf_vty_show_init(void)
12531 /* "show ip ospf" commands. */
12532 install_element(VIEW_NODE
, &show_ip_ospf_cmd
);
12534 install_element(VIEW_NODE
, &show_ip_ospf_instance_cmd
);
12536 /* "show ip ospf database" commands. */
12537 install_element(VIEW_NODE
, &show_ip_ospf_database_cmd
);
12538 install_element(VIEW_NODE
, &show_ip_ospf_database_max_cmd
);
12539 install_element(VIEW_NODE
,
12540 &show_ip_ospf_database_type_adv_router_cmd
);
12541 install_element(VIEW_NODE
,
12542 &show_ip_ospf_instance_database_type_adv_router_cmd
);
12543 install_element(VIEW_NODE
, &show_ip_ospf_instance_database_cmd
);
12544 install_element(VIEW_NODE
, &show_ip_ospf_instance_database_max_cmd
);
12546 /* "show ip ospf interface" commands. */
12547 install_element(VIEW_NODE
, &show_ip_ospf_interface_cmd
);
12549 install_element(VIEW_NODE
, &show_ip_ospf_instance_interface_cmd
);
12550 /* "show ip ospf interface traffic */
12551 install_element(VIEW_NODE
, &show_ip_ospf_interface_traffic_cmd
);
12553 /* "show ip ospf neighbor" commands. */
12554 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_int_detail_cmd
);
12555 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_int_cmd
);
12556 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_id_cmd
);
12557 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_detail_all_cmd
);
12558 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_detail_cmd
);
12559 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_cmd
);
12560 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_all_cmd
);
12562 install_element(VIEW_NODE
,
12563 &show_ip_ospf_instance_neighbor_int_detail_cmd
);
12564 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_cmd
);
12565 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_id_cmd
);
12566 install_element(VIEW_NODE
,
12567 &show_ip_ospf_instance_neighbor_detail_all_cmd
);
12568 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_cmd
);
12569 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_cmd
);
12570 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_all_cmd
);
12572 /* "show ip ospf route" commands. */
12573 install_element(VIEW_NODE
, &show_ip_ospf_route_cmd
);
12574 install_element(VIEW_NODE
, &show_ip_ospf_border_routers_cmd
);
12576 install_element(VIEW_NODE
, &show_ip_ospf_instance_route_cmd
);
12577 install_element(VIEW_NODE
, &show_ip_ospf_instance_border_routers_cmd
);
12579 /* "show ip ospf vrfs" commands. */
12580 install_element(VIEW_NODE
, &show_ip_ospf_vrfs_cmd
);
12582 /* "show ip ospf gr-helper details" command */
12583 install_element(VIEW_NODE
, &show_ip_ospf_gr_helper_cmd
);
12585 /* "show ip ospf summary-address" command */
12586 install_element(VIEW_NODE
, &show_ip_ospf_external_aggregator_cmd
);
12589 /* Initialization of OSPF interface. */
12590 static void ospf_vty_if_init(void)
12592 /* Install interface node. */
12593 if_cmd_init(config_write_interface
);
12595 /* "ip ospf authentication" commands. */
12596 install_element(INTERFACE_NODE
, &ip_ospf_authentication_args_addr_cmd
);
12597 install_element(INTERFACE_NODE
, &ip_ospf_authentication_addr_cmd
);
12598 install_element(INTERFACE_NODE
,
12599 &no_ip_ospf_authentication_args_addr_cmd
);
12600 install_element(INTERFACE_NODE
, &no_ip_ospf_authentication_addr_cmd
);
12601 install_element(INTERFACE_NODE
, &ip_ospf_authentication_key_addr_cmd
);
12602 install_element(INTERFACE_NODE
,
12603 &no_ip_ospf_authentication_key_authkey_addr_cmd
);
12604 install_element(INTERFACE_NODE
,
12605 &no_ospf_authentication_key_authkey_addr_cmd
);
12607 /* "ip ospf message-digest-key" commands. */
12608 install_element(INTERFACE_NODE
, &ip_ospf_message_digest_key_cmd
);
12609 install_element(INTERFACE_NODE
, &no_ip_ospf_message_digest_key_cmd
);
12611 /* "ip ospf cost" commands. */
12612 install_element(INTERFACE_NODE
, &ip_ospf_cost_cmd
);
12613 install_element(INTERFACE_NODE
, &no_ip_ospf_cost_cmd
);
12615 /* "ip ospf mtu-ignore" commands. */
12616 install_element(INTERFACE_NODE
, &ip_ospf_mtu_ignore_addr_cmd
);
12617 install_element(INTERFACE_NODE
, &no_ip_ospf_mtu_ignore_addr_cmd
);
12619 /* "ip ospf dead-interval" commands. */
12620 install_element(INTERFACE_NODE
, &ip_ospf_dead_interval_cmd
);
12621 install_element(INTERFACE_NODE
,
12622 &ip_ospf_dead_interval_minimal_addr_cmd
);
12623 install_element(INTERFACE_NODE
, &no_ip_ospf_dead_interval_cmd
);
12625 /* "ip ospf hello-interval" commands. */
12626 install_element(INTERFACE_NODE
, &ip_ospf_hello_interval_cmd
);
12627 install_element(INTERFACE_NODE
, &no_ip_ospf_hello_interval_cmd
);
12629 /* "ip ospf network" commands. */
12630 install_element(INTERFACE_NODE
, &ip_ospf_network_cmd
);
12631 install_element(INTERFACE_NODE
, &no_ip_ospf_network_cmd
);
12633 /* "ip ospf priority" commands. */
12634 install_element(INTERFACE_NODE
, &ip_ospf_priority_cmd
);
12635 install_element(INTERFACE_NODE
, &no_ip_ospf_priority_cmd
);
12637 /* "ip ospf retransmit-interval" commands. */
12638 install_element(INTERFACE_NODE
, &ip_ospf_retransmit_interval_addr_cmd
);
12639 install_element(INTERFACE_NODE
,
12640 &no_ip_ospf_retransmit_interval_addr_cmd
);
12642 /* "ip ospf transmit-delay" commands. */
12643 install_element(INTERFACE_NODE
, &ip_ospf_transmit_delay_addr_cmd
);
12644 install_element(INTERFACE_NODE
, &no_ip_ospf_transmit_delay_addr_cmd
);
12646 /* "ip ospf area" commands. */
12647 install_element(INTERFACE_NODE
, &ip_ospf_area_cmd
);
12648 install_element(INTERFACE_NODE
, &no_ip_ospf_area_cmd
);
12650 /* "ip ospf passive" commands. */
12651 install_element(INTERFACE_NODE
, &ip_ospf_passive_cmd
);
12652 install_element(INTERFACE_NODE
, &no_ip_ospf_passive_cmd
);
12654 /* These commands are compatibitliy for previous version. */
12655 install_element(INTERFACE_NODE
, &ospf_authentication_key_cmd
);
12656 install_element(INTERFACE_NODE
, &ospf_message_digest_key_cmd
);
12657 install_element(INTERFACE_NODE
, &no_ospf_message_digest_key_cmd
);
12658 install_element(INTERFACE_NODE
, &ospf_dead_interval_cmd
);
12659 install_element(INTERFACE_NODE
, &no_ospf_dead_interval_cmd
);
12660 install_element(INTERFACE_NODE
, &ospf_hello_interval_cmd
);
12661 install_element(INTERFACE_NODE
, &no_ospf_hello_interval_cmd
);
12662 install_element(INTERFACE_NODE
, &ospf_cost_cmd
);
12663 install_element(INTERFACE_NODE
, &no_ospf_cost_cmd
);
12664 install_element(INTERFACE_NODE
, &ospf_network_cmd
);
12665 install_element(INTERFACE_NODE
, &no_ospf_network_cmd
);
12666 install_element(INTERFACE_NODE
, &ospf_priority_cmd
);
12667 install_element(INTERFACE_NODE
, &no_ospf_priority_cmd
);
12668 install_element(INTERFACE_NODE
, &ospf_retransmit_interval_cmd
);
12669 install_element(INTERFACE_NODE
, &no_ospf_retransmit_interval_cmd
);
12670 install_element(INTERFACE_NODE
, &ospf_transmit_delay_cmd
);
12671 install_element(INTERFACE_NODE
, &no_ospf_transmit_delay_cmd
);
12674 static void ospf_vty_zebra_init(void)
12676 install_element(OSPF_NODE
, &ospf_redistribute_source_cmd
);
12677 install_element(OSPF_NODE
, &no_ospf_redistribute_source_cmd
);
12678 install_element(OSPF_NODE
, &ospf_redistribute_instance_source_cmd
);
12679 install_element(OSPF_NODE
, &no_ospf_redistribute_instance_source_cmd
);
12681 install_element(OSPF_NODE
, &ospf_distribute_list_out_cmd
);
12682 install_element(OSPF_NODE
, &no_ospf_distribute_list_out_cmd
);
12684 install_element(OSPF_NODE
, &ospf_default_information_originate_cmd
);
12685 install_element(OSPF_NODE
, &no_ospf_default_information_originate_cmd
);
12687 install_element(OSPF_NODE
, &ospf_default_metric_cmd
);
12688 install_element(OSPF_NODE
, &no_ospf_default_metric_cmd
);
12690 install_element(OSPF_NODE
, &ospf_distance_cmd
);
12691 install_element(OSPF_NODE
, &no_ospf_distance_cmd
);
12692 install_element(OSPF_NODE
, &no_ospf_distance_ospf_cmd
);
12693 install_element(OSPF_NODE
, &ospf_distance_ospf_cmd
);
12695 /*Ospf garcefull restart helper configurations */
12696 install_element(OSPF_NODE
, &ospf_gr_helper_enable_cmd
);
12697 install_element(OSPF_NODE
, &no_ospf_gr_helper_enable_cmd
);
12698 install_element(OSPF_NODE
, &ospf_gr_helper_only_cmd
);
12699 install_element(OSPF_NODE
, &no_ospf_gr_helper_only_cmd
);
12700 install_element(OSPF_NODE
, &ospf_gr_helper_enable_lsacheck_cmd
);
12701 install_element(OSPF_NODE
, &no_ospf_gr_helper_enable_lsacheck_cmd
);
12702 install_element(OSPF_NODE
, &ospf_gr_helper_supported_grace_time_cmd
);
12703 install_element(OSPF_NODE
, &no_ospf_gr_helper_supported_grace_time_cmd
);
12704 install_element(OSPF_NODE
, &ospf_gr_helper_planned_only_cmd
);
12705 install_element(OSPF_NODE
, &no_ospf_gr_helper_planned_only_cmd
);
12707 /* External LSA summarisation config commands.*/
12708 install_element(OSPF_NODE
, &ospf_external_route_aggregation_cmd
);
12709 install_element(OSPF_NODE
, &no_ospf_external_route_aggregation_cmd
);
12710 install_element(OSPF_NODE
,
12711 &ospf_external_route_aggregation_no_adrvertise_cmd
);
12712 install_element(OSPF_NODE
,
12713 &no_ospf_external_route_aggregation_no_adrvertise_cmd
);
12714 install_element(OSPF_NODE
, &ospf_route_aggregation_timer_cmd
);
12715 install_element(OSPF_NODE
, &no_ospf_route_aggregation_timer_cmd
);
12718 static int ospf_config_write(struct vty
*vty
);
12719 static struct cmd_node ospf_node
= {
12722 .parent_node
= CONFIG_NODE
,
12723 .prompt
= "%s(config-router)# ",
12724 .config_write
= ospf_config_write
,
12727 static void ospf_interface_clear(struct interface
*ifp
)
12729 if (!if_is_operative(ifp
))
12732 if (IS_DEBUG_OSPF(ism
, ISM_EVENTS
))
12733 zlog_debug("ISM[%s]: clear by reset", ifp
->name
);
12735 ospf_if_reset(ifp
);
12738 DEFUN (clear_ip_ospf_interface
,
12739 clear_ip_ospf_interface_cmd
,
12740 "clear ip ospf [vrf NAME] interface [IFNAME]",
12743 "OSPF information\n"
12745 "Interface information\n"
12746 "Interface name\n")
12748 int idx_ifname
= 0;
12750 struct interface
*ifp
;
12751 struct listnode
*node
;
12752 struct ospf
*ospf
= NULL
;
12753 char *vrf_name
= NULL
;
12754 vrf_id_t vrf_id
= VRF_DEFAULT
;
12755 struct vrf
*vrf
= NULL
;
12757 if (argv_find(argv
, argc
, "vrf", &idx_vrf
))
12758 vrf_name
= argv
[idx_vrf
+ 1]->arg
;
12759 if (vrf_name
&& strmatch(vrf_name
, VRF_DEFAULT_NAME
))
12762 vrf
= vrf_lookup_by_name(vrf_name
);
12764 vrf_id
= vrf
->vrf_id
;
12766 if (!argv_find(argv
, argc
, "IFNAME", &idx_ifname
)) {
12767 /* Clear all the ospfv2 interfaces. */
12768 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
12769 if (vrf_id
!= ospf
->vrf_id
)
12772 vrf
= vrf_lookup_by_id(ospf
->vrf_id
);
12773 FOR_ALL_INTERFACES (vrf
, ifp
)
12774 ospf_interface_clear(ifp
);
12777 /* Interface name is specified. */
12778 ifp
= if_lookup_by_name(argv
[idx_ifname
]->arg
, vrf_id
);
12780 vty_out(vty
, "No such interface name\n");
12782 ospf_interface_clear(ifp
);
12785 return CMD_SUCCESS
;
12788 void ospf_vty_clear_init(void)
12790 install_element(ENABLE_NODE
, &clear_ip_ospf_interface_cmd
);
12791 install_element(ENABLE_NODE
, &clear_ip_ospf_process_cmd
);
12792 install_element(ENABLE_NODE
, &clear_ip_ospf_neighbor_cmd
);
12796 /* Install OSPF related vty commands. */
12797 void ospf_vty_init(void)
12799 /* Install ospf top node. */
12800 install_node(&ospf_node
);
12802 /* "router ospf" commands. */
12803 install_element(CONFIG_NODE
, &router_ospf_cmd
);
12804 install_element(CONFIG_NODE
, &no_router_ospf_cmd
);
12807 install_default(OSPF_NODE
);
12809 /* "ospf router-id" commands. */
12810 install_element(OSPF_NODE
, &ospf_router_id_cmd
);
12811 install_element(OSPF_NODE
, &ospf_router_id_old_cmd
);
12812 install_element(OSPF_NODE
, &no_ospf_router_id_cmd
);
12814 /* "passive-interface" commands. */
12815 install_element(OSPF_NODE
, &ospf_passive_interface_default_cmd
);
12816 install_element(OSPF_NODE
, &ospf_passive_interface_addr_cmd
);
12817 install_element(OSPF_NODE
, &no_ospf_passive_interface_default_cmd
);
12818 install_element(OSPF_NODE
, &no_ospf_passive_interface_addr_cmd
);
12820 /* "ospf abr-type" commands. */
12821 install_element(OSPF_NODE
, &ospf_abr_type_cmd
);
12822 install_element(OSPF_NODE
, &no_ospf_abr_type_cmd
);
12824 /* "ospf log-adjacency-changes" commands. */
12825 install_element(OSPF_NODE
, &ospf_log_adjacency_changes_cmd
);
12826 install_element(OSPF_NODE
, &ospf_log_adjacency_changes_detail_cmd
);
12827 install_element(OSPF_NODE
, &no_ospf_log_adjacency_changes_cmd
);
12828 install_element(OSPF_NODE
, &no_ospf_log_adjacency_changes_detail_cmd
);
12830 /* "ospf rfc1583-compatible" commands. */
12831 install_element(OSPF_NODE
, &ospf_compatible_rfc1583_cmd
);
12832 install_element(OSPF_NODE
, &no_ospf_compatible_rfc1583_cmd
);
12833 install_element(OSPF_NODE
, &ospf_rfc1583_flag_cmd
);
12834 install_element(OSPF_NODE
, &no_ospf_rfc1583_flag_cmd
);
12836 /* "ospf send-extra-data zebra" commands. */
12837 install_element(OSPF_NODE
, &ospf_send_extra_data_cmd
);
12839 /* "network area" commands. */
12840 install_element(OSPF_NODE
, &ospf_network_area_cmd
);
12841 install_element(OSPF_NODE
, &no_ospf_network_area_cmd
);
12843 /* "area authentication" commands. */
12844 install_element(OSPF_NODE
,
12845 &ospf_area_authentication_message_digest_cmd
);
12846 install_element(OSPF_NODE
, &ospf_area_authentication_cmd
);
12847 install_element(OSPF_NODE
, &no_ospf_area_authentication_cmd
);
12849 /* "area range" commands. */
12850 install_element(OSPF_NODE
, &ospf_area_range_cmd
);
12851 install_element(OSPF_NODE
, &ospf_area_range_cost_cmd
);
12852 install_element(OSPF_NODE
, &ospf_area_range_not_advertise_cmd
);
12853 install_element(OSPF_NODE
, &no_ospf_area_range_cmd
);
12854 install_element(OSPF_NODE
, &no_ospf_area_range_substitute_cmd
);
12856 /* "area virtual-link" commands. */
12857 install_element(OSPF_NODE
, &ospf_area_vlink_cmd
);
12858 install_element(OSPF_NODE
, &ospf_area_vlink_intervals_cmd
);
12859 install_element(OSPF_NODE
, &no_ospf_area_vlink_cmd
);
12860 install_element(OSPF_NODE
, &no_ospf_area_vlink_intervals_cmd
);
12863 /* "area stub" commands. */
12864 install_element(OSPF_NODE
, &ospf_area_stub_no_summary_cmd
);
12865 install_element(OSPF_NODE
, &ospf_area_stub_cmd
);
12866 install_element(OSPF_NODE
, &no_ospf_area_stub_no_summary_cmd
);
12867 install_element(OSPF_NODE
, &no_ospf_area_stub_cmd
);
12869 /* "area nssa" commands. */
12870 install_element(OSPF_NODE
, &ospf_area_nssa_cmd
);
12871 install_element(OSPF_NODE
, &ospf_area_nssa_translate_cmd
);
12872 install_element(OSPF_NODE
, &ospf_area_nssa_no_summary_cmd
);
12873 install_element(OSPF_NODE
, &no_ospf_area_nssa_no_summary_cmd
);
12874 install_element(OSPF_NODE
, &ospf_area_nssa_suppress_fa_cmd
);
12875 install_element(OSPF_NODE
, &no_ospf_area_nssa_suppress_fa_cmd
);
12876 install_element(OSPF_NODE
, &no_ospf_area_nssa_cmd
);
12878 install_element(OSPF_NODE
, &ospf_area_default_cost_cmd
);
12879 install_element(OSPF_NODE
, &no_ospf_area_default_cost_cmd
);
12881 install_element(OSPF_NODE
, &ospf_area_shortcut_cmd
);
12882 install_element(OSPF_NODE
, &no_ospf_area_shortcut_cmd
);
12884 install_element(OSPF_NODE
, &ospf_area_export_list_cmd
);
12885 install_element(OSPF_NODE
, &no_ospf_area_export_list_cmd
);
12887 install_element(OSPF_NODE
, &ospf_area_filter_list_cmd
);
12888 install_element(OSPF_NODE
, &no_ospf_area_filter_list_cmd
);
12890 install_element(OSPF_NODE
, &ospf_area_import_list_cmd
);
12891 install_element(OSPF_NODE
, &no_ospf_area_import_list_cmd
);
12893 /* SPF timer commands */
12894 install_element(OSPF_NODE
, &ospf_timers_throttle_spf_cmd
);
12895 install_element(OSPF_NODE
, &no_ospf_timers_throttle_spf_cmd
);
12897 /* LSA timers commands */
12898 install_element(OSPF_NODE
, &ospf_timers_min_ls_interval_cmd
);
12899 install_element(OSPF_NODE
, &no_ospf_timers_min_ls_interval_cmd
);
12900 install_element(OSPF_NODE
, &ospf_timers_lsa_min_arrival_cmd
);
12901 install_element(OSPF_NODE
, &no_ospf_timers_lsa_min_arrival_cmd
);
12903 /* refresh timer commands */
12904 install_element(OSPF_NODE
, &ospf_refresh_timer_cmd
);
12905 install_element(OSPF_NODE
, &no_ospf_refresh_timer_val_cmd
);
12907 /* max-metric commands */
12908 install_element(OSPF_NODE
, &ospf_max_metric_router_lsa_admin_cmd
);
12909 install_element(OSPF_NODE
, &no_ospf_max_metric_router_lsa_admin_cmd
);
12910 install_element(OSPF_NODE
, &ospf_max_metric_router_lsa_startup_cmd
);
12911 install_element(OSPF_NODE
, &no_ospf_max_metric_router_lsa_startup_cmd
);
12912 install_element(OSPF_NODE
, &ospf_max_metric_router_lsa_shutdown_cmd
);
12913 install_element(OSPF_NODE
, &no_ospf_max_metric_router_lsa_shutdown_cmd
);
12915 /* reference bandwidth commands */
12916 install_element(OSPF_NODE
, &ospf_auto_cost_reference_bandwidth_cmd
);
12917 install_element(OSPF_NODE
, &no_ospf_auto_cost_reference_bandwidth_cmd
);
12919 /* "neighbor" commands. */
12920 install_element(OSPF_NODE
, &ospf_neighbor_cmd
);
12921 install_element(OSPF_NODE
, &ospf_neighbor_poll_interval_cmd
);
12922 install_element(OSPF_NODE
, &no_ospf_neighbor_cmd
);
12923 install_element(OSPF_NODE
, &no_ospf_neighbor_poll_cmd
);
12925 /* write multiplier commands */
12926 install_element(OSPF_NODE
, &ospf_write_multiplier_cmd
);
12927 install_element(OSPF_NODE
, &write_multiplier_cmd
);
12928 install_element(OSPF_NODE
, &no_ospf_write_multiplier_cmd
);
12929 install_element(OSPF_NODE
, &no_write_multiplier_cmd
);
12931 /* "proactive-arp" commands. */
12932 install_element(OSPF_NODE
, &ospf_proactive_arp_cmd
);
12933 install_element(OSPF_NODE
, &no_ospf_proactive_arp_cmd
);
12935 /* TI-LFA commands */
12936 install_element(OSPF_NODE
, &ospf_ti_lfa_cmd
);
12937 install_element(OSPF_NODE
, &no_ospf_ti_lfa_cmd
);
12939 /* Max path configurations */
12940 install_element(OSPF_NODE
, &ospf_max_multipath_cmd
);
12941 install_element(OSPF_NODE
, &no_ospf_max_multipath_cmd
);
12943 vrf_cmd_init(NULL
);
12945 /* Init interface related vty commands. */
12946 ospf_vty_if_init();
12948 /* Init zebra related vty commands. */
12949 ospf_vty_zebra_init();