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 instance not found\n");
3438 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
3439 if ((ospf
== NULL
) || !ospf
->oi_running
) {
3441 vty_json(vty
, json
);
3443 vty_out(vty
, "%% OSPF instance not found\n");
3448 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
3449 /* Display default ospf (instance 0) info */
3450 if (ospf
== NULL
|| !ospf
->oi_running
) {
3452 vty_json(vty
, json
);
3454 vty_out(vty
, "%% OSPF instance not found\n");
3461 show_ip_ospf_common(vty
, ospf
, json
, use_vrf
);
3463 vty_out(vty
, "%s\n",
3464 json_object_to_json_string_ext(
3465 json
, JSON_C_TO_STRING_PRETTY
));
3469 json_object_free(json
);
3474 DEFUN (show_ip_ospf_instance
,
3475 show_ip_ospf_instance_cmd
,
3476 "show ip ospf (1-65535) [json]",
3479 "OSPF information\n"
3485 unsigned short instance
= 0;
3486 bool uj
= use_json(argc
, argv
);
3487 int ret
= CMD_SUCCESS
;
3488 json_object
*json
= NULL
;
3490 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3491 if (instance
!= ospf_instance
)
3492 return CMD_NOT_MY_INSTANCE
;
3494 ospf
= ospf_lookup_instance(instance
);
3495 if (!ospf
|| !ospf
->oi_running
)
3499 json
= json_object_new_object();
3501 ret
= show_ip_ospf_common(vty
, ospf
, json
, 0);
3504 vty_json(vty
, json
);
3509 static void ospf_interface_auth_show(struct vty
*vty
, struct ospf_interface
*oi
,
3510 json_object
*json
, bool use_json
)
3514 auth_type
= OSPF_IF_PARAM(oi
, auth_type
);
3516 switch (auth_type
) {
3517 case OSPF_AUTH_NULL
:
3519 json_object_string_add(json
, "authentication",
3520 "authenticationNone");
3522 vty_out(vty
, " Authentication NULL is enabled\n");
3524 case OSPF_AUTH_SIMPLE
: {
3526 json_object_string_add(json
, "authentication",
3527 "authenticationSimplePassword");
3530 " Simple password authentication enabled\n");
3533 case OSPF_AUTH_CRYPTOGRAPHIC
: {
3534 struct crypt_key
*ckey
;
3536 if (list_isempty(OSPF_IF_PARAM(oi
, auth_crypt
)))
3539 ckey
= listgetdata(listtail(OSPF_IF_PARAM(oi
, auth_crypt
)));
3542 json_object_string_add(json
, "authentication",
3543 "authenticationMessageDigest");
3546 " Cryptographic authentication enabled\n");
3547 vty_out(vty
, " Algorithm:MD5\n");
3557 static void show_ip_ospf_interface_sub(struct vty
*vty
, struct ospf
*ospf
,
3558 struct interface
*ifp
,
3559 json_object
*json_interface_sub
,
3563 struct ospf_neighbor
*nbr
;
3564 struct route_node
*rn
;
3565 uint32_t bandwidth
= ifp
->bandwidth
? ifp
->bandwidth
: ifp
->speed
;
3567 /* Is interface up? */
3569 is_up
= if_is_operative(ifp
);
3571 json_object_boolean_true_add(json_interface_sub
,
3574 json_object_boolean_false_add(json_interface_sub
,
3577 json_object_int_add(json_interface_sub
, "ifIndex",
3579 json_object_int_add(json_interface_sub
, "mtuBytes", ifp
->mtu
);
3580 json_object_int_add(json_interface_sub
, "bandwidthMbit",
3582 json_object_string_add(json_interface_sub
, "ifFlags",
3583 if_flag_dump(ifp
->flags
));
3585 vty_out(vty
, "%s is %s\n", ifp
->name
,
3586 ((is_up
= if_is_operative(ifp
)) ? "up" : "down"));
3587 vty_out(vty
, " ifindex %u, MTU %u bytes, BW %u Mbit %s\n",
3588 ifp
->ifindex
, ifp
->mtu
, bandwidth
,
3589 if_flag_dump(ifp
->flags
));
3592 /* Is interface OSPF enabled? */
3594 if (ospf_oi_count(ifp
) == 0) {
3595 json_object_boolean_false_add(json_interface_sub
,
3598 } else if (!is_up
) {
3599 json_object_boolean_false_add(json_interface_sub
,
3603 json_object_boolean_true_add(json_interface_sub
,
3606 if (ospf_oi_count(ifp
) == 0) {
3607 vty_out(vty
, " OSPF not enabled on this interface\n");
3609 } else if (!is_up
) {
3611 " OSPF is enabled, but not running on this interface\n");
3616 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
3617 struct ospf_interface
*oi
= rn
->info
;
3622 if (CHECK_FLAG(oi
->connected
->flags
, ZEBRA_IFA_UNNUMBERED
)) {
3624 json_object_boolean_true_add(json_interface_sub
,
3627 vty_out(vty
, " This interface is UNNUMBERED,");
3629 struct in_addr dest
;
3632 /* Show OSPF interface information. */
3634 json_object_string_addf(
3635 json_interface_sub
, "ipAddress", "%pI4",
3636 &oi
->address
->u
.prefix4
);
3637 json_object_int_add(json_interface_sub
,
3638 "ipAddressPrefixlen",
3639 oi
->address
->prefixlen
);
3641 vty_out(vty
, " Internet Address %pFX,",
3644 /* For Vlinks, showing the peer address is
3645 * probably more informative than the local
3646 * interface that is being used */
3647 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
) {
3649 dest
= oi
->vl_data
->peer_addr
;
3650 } else if (CONNECTED_PEER(oi
->connected
)
3651 && oi
->connected
->destination
) {
3653 dest
= oi
->connected
->destination
->u
.prefix4
;
3656 dest
.s_addr
= ipv4_broadcast_addr(
3657 oi
->connected
->address
->u
.prefix4
.s_addr
,
3658 oi
->connected
->address
->prefixlen
);
3662 json_object_string_add(
3664 "ospfIfType", dstr
);
3665 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3666 json_object_string_addf(
3667 json_interface_sub
, "vlinkPeer",
3670 json_object_string_addf(
3672 "localIfUsed", "%pI4", &dest
);
3674 vty_out(vty
, " %s %pI4,", dstr
,
3678 json_object_string_add(json_interface_sub
, "area",
3679 ospf_area_desc_string(oi
->area
));
3680 if (OSPF_IF_PARAM(oi
, mtu_ignore
))
3681 json_object_boolean_true_add(
3683 "mtuMismatchDetect");
3684 json_object_string_addf(json_interface_sub
, "routerId",
3685 "%pI4", &ospf
->router_id
);
3686 json_object_string_add(json_interface_sub
,
3688 ospf_network_type_str
[oi
->type
]);
3689 json_object_int_add(json_interface_sub
, "cost",
3691 json_object_int_add(
3692 json_interface_sub
, "transmitDelaySecs",
3693 OSPF_IF_PARAM(oi
, transmit_delay
));
3694 json_object_string_add(json_interface_sub
, "state",
3695 lookup_msg(ospf_ism_state_msg
,
3697 json_object_int_add(json_interface_sub
, "priority",
3700 vty_out(vty
, " Area %s\n",
3701 ospf_area_desc_string(oi
->area
));
3703 vty_out(vty
, " MTU mismatch detection: %s\n",
3704 OSPF_IF_PARAM(oi
, mtu_ignore
) ? "disabled"
3708 " Router ID %pI4, Network Type %s, Cost: %d\n",
3710 ospf_network_type_str
[oi
->type
],
3714 " Transmit Delay is %d sec, State %s, Priority %d\n",
3715 OSPF_IF_PARAM(oi
, transmit_delay
),
3716 lookup_msg(ospf_ism_state_msg
, oi
->state
, NULL
),
3720 /* Show DR information. */
3721 if (DR(oi
).s_addr
== INADDR_ANY
) {
3724 " No backup designated router on this network\n");
3726 nbr
= ospf_nbr_lookup_by_addr(oi
->nbrs
, &DR(oi
));
3729 json_object_string_addf(
3730 json_interface_sub
, "drId",
3731 "%pI4", &nbr
->router_id
);
3732 json_object_string_addf(
3733 json_interface_sub
, "drAddress",
3735 &nbr
->address
.u
.prefix4
);
3738 " Designated Router (ID) %pI4",
3741 " Interface Address %pFX\n",
3747 nbr
= ospf_nbr_lookup_by_addr(oi
->nbrs
, &BDR(oi
));
3751 " No backup designated router on this network\n");
3754 json_object_string_addf(
3755 json_interface_sub
, "bdrId",
3756 "%pI4", &nbr
->router_id
);
3757 json_object_string_addf(
3759 "bdrAddress", "%pI4",
3760 &nbr
->address
.u
.prefix4
);
3763 " Backup Designated Router (ID) %pI4,",
3765 vty_out(vty
, " Interface Address %pI4\n",
3766 &nbr
->address
.u
.prefix4
);
3771 /* Next network-LSA sequence number we'll use, if we're elected
3774 && ntohl(oi
->params
->network_lsa_seqnum
)
3775 != OSPF_INITIAL_SEQUENCE_NUMBER
) {
3777 json_object_int_add(
3779 "networkLsaSequence",
3780 ntohl(oi
->params
->network_lsa_seqnum
));
3783 " Saved Network-LSA sequence number 0x%x\n",
3784 ntohl(oi
->params
->network_lsa_seqnum
));
3788 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3789 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
)) {
3790 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3791 json_object_boolean_true_add(
3793 "mcastMemberOspfAllRouters");
3794 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3795 json_object_boolean_true_add(
3797 "mcastMemberOspfDesignatedRouters");
3800 vty_out(vty
, " Multicast group memberships:");
3801 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3802 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
)) {
3803 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3804 vty_out(vty
, " OSPFAllRouters");
3805 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3806 vty_out(vty
, " OSPFDesignatedRouters");
3808 vty_out(vty
, " <None>");
3813 if (OSPF_IF_PARAM(oi
, fast_hello
) == 0)
3814 json_object_int_add(
3815 json_interface_sub
, "timerMsecs",
3816 OSPF_IF_PARAM(oi
, v_hello
) * 1000);
3818 json_object_int_add(
3819 json_interface_sub
, "timerMsecs",
3820 1000 / OSPF_IF_PARAM(oi
, fast_hello
));
3821 json_object_int_add(json_interface_sub
,
3823 OSPF_IF_PARAM(oi
, v_wait
));
3824 json_object_int_add(json_interface_sub
,
3826 OSPF_IF_PARAM(oi
, v_wait
));
3827 json_object_int_add(
3828 json_interface_sub
, "timerRetransmitSecs",
3829 OSPF_IF_PARAM(oi
, retransmit_interval
));
3831 vty_out(vty
, " Timer intervals configured,");
3832 vty_out(vty
, " Hello ");
3833 if (OSPF_IF_PARAM(oi
, fast_hello
) == 0)
3834 vty_out(vty
, "%ds,",
3835 OSPF_IF_PARAM(oi
, v_hello
));
3837 vty_out(vty
, "%dms,",
3838 1000 / OSPF_IF_PARAM(oi
, fast_hello
));
3839 vty_out(vty
, " Dead %ds, Wait %ds, Retransmit %d\n",
3840 OSPF_IF_PARAM(oi
, v_wait
),
3841 OSPF_IF_PARAM(oi
, v_wait
),
3842 OSPF_IF_PARAM(oi
, retransmit_interval
));
3845 if (OSPF_IF_PASSIVE_STATUS(oi
) == OSPF_IF_ACTIVE
) {
3846 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3848 long time_store
= 0;
3852 &oi
->t_hello
->u
.sands
,
3855 json_object_int_add(json_interface_sub
,
3856 "timerHelloInMsecs",
3859 vty_out(vty
, " Hello due in %s\n",
3860 ospf_timer_dump(oi
->t_hello
, timebuf
,
3862 } else /* passive-interface is set */
3865 json_object_boolean_true_add(
3867 "timerPassiveIface");
3870 " No Hellos (Passive interface)\n");
3874 json_object_int_add(json_interface_sub
, "nbrCount",
3875 ospf_nbr_count(oi
, 0));
3876 json_object_int_add(json_interface_sub
,
3878 ospf_nbr_count(oi
, NSM_Full
));
3881 " Neighbor Count is %d, Adjacent neighbor count is %d\n",
3882 ospf_nbr_count(oi
, 0),
3883 ospf_nbr_count(oi
, NSM_Full
));
3885 ospf_interface_bfd_show(vty
, ifp
, json_interface_sub
);
3887 /* OSPF Authentication information */
3888 ospf_interface_auth_show(vty
, oi
, json_interface_sub
, use_json
);
3892 static int show_ip_ospf_interface_common(struct vty
*vty
, struct ospf
*ospf
,
3893 char *intf_name
, uint8_t use_vrf
,
3894 json_object
*json
, bool use_json
)
3896 struct interface
*ifp
;
3897 struct vrf
*vrf
= vrf_lookup_by_id(ospf
->vrf_id
);
3898 json_object
*json_vrf
= NULL
;
3899 json_object
*json_interface_sub
= NULL
, *json_interface
= NULL
;
3903 json_vrf
= json_object_new_object();
3906 json_interface
= json_object_new_object();
3909 if (ospf
->instance
) {
3911 json_object_int_add(json
, "ospfInstance",
3914 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
3917 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
3919 if (intf_name
== NULL
) {
3920 /* Show All Interfaces.*/
3921 FOR_ALL_INTERFACES (vrf
, ifp
) {
3922 if (ospf_oi_count(ifp
)) {
3924 json_interface_sub
=
3925 json_object_new_object();
3927 show_ip_ospf_interface_sub(vty
, ospf
, ifp
,
3932 json_object_object_add(
3933 json_interface
, ifp
->name
,
3934 json_interface_sub
);
3939 json_object_object_add(json_vrf
, "interfaces",
3942 /* Interface name is specified. */
3943 ifp
= if_lookup_by_name(intf_name
, ospf
->vrf_id
);
3946 json_object_boolean_true_add(json_vrf
,
3949 vty_out(vty
, "No such interface name\n");
3952 json_interface_sub
= json_object_new_object();
3953 json_interface
= json_object_new_object();
3956 show_ip_ospf_interface_sub(
3957 vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3960 json_object_object_add(json_interface
,
3962 json_interface_sub
);
3963 json_object_object_add(json_vrf
, "interfaces",
3971 json_object_object_add(json
, ospf_get_name(ospf
),
3980 static void show_ip_ospf_interface_traffic_sub(struct vty
*vty
,
3981 struct ospf_interface
*oi
,
3982 json_object
*json_interface_sub
,
3986 json_object_int_add(json_interface_sub
, "ifIndex",
3988 json_object_int_add(json_interface_sub
, "helloIn",
3990 json_object_int_add(json_interface_sub
, "helloOut",
3992 json_object_int_add(json_interface_sub
, "dbDescIn",
3994 json_object_int_add(json_interface_sub
, "dbDescOut",
3996 json_object_int_add(json_interface_sub
, "lsReqIn",
3998 json_object_int_add(json_interface_sub
, "lsReqOut",
4000 json_object_int_add(json_interface_sub
, "lsUpdIn",
4002 json_object_int_add(json_interface_sub
, "lsUpdOut",
4004 json_object_int_add(json_interface_sub
, "lsAckIn",
4006 json_object_int_add(json_interface_sub
, "lsAckOut",
4010 "%-10s %8u/%-8u %7u/%-7u %7u/%-7u %7u/%-7u %7u/%-7u\n",
4011 oi
->ifp
->name
, oi
->hello_in
, oi
->hello_out
,
4012 oi
->db_desc_in
, oi
->db_desc_out
, oi
->ls_req_in
,
4013 oi
->ls_req_out
, oi
->ls_upd_in
, oi
->ls_upd_out
,
4014 oi
->ls_ack_in
, oi
->ls_ack_out
);
4018 /* OSPFv2 Packet Counters */
4019 static int show_ip_ospf_interface_traffic_common(
4020 struct vty
*vty
, struct ospf
*ospf
, char *intf_name
, json_object
*json
,
4021 int display_once
, uint8_t use_vrf
, bool use_json
)
4023 struct vrf
*vrf
= NULL
;
4024 struct interface
*ifp
= NULL
;
4025 json_object
*json_vrf
= NULL
;
4026 json_object
*json_interface_sub
= NULL
;
4028 if (!use_json
&& !display_once
) {
4030 vty_out(vty
, "%-12s%-17s%-17s%-17s%-17s%-17s\n", "Interface",
4031 " HELLO", " DB-Desc", " LS-Req", " LS-Update",
4033 vty_out(vty
, "%-10s%-18s%-18s%-17s%-17s%-17s\n", "",
4034 " Rx/Tx", " Rx/Tx", " Rx/Tx", " Rx/Tx",
4037 "--------------------------------------------------------------------------------------------\n");
4038 } else if (use_json
) {
4040 json_vrf
= json_object_new_object();
4045 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
4047 if (intf_name
== NULL
) {
4048 vrf
= vrf_lookup_by_id(ospf
->vrf_id
);
4049 FOR_ALL_INTERFACES (vrf
, ifp
) {
4050 struct route_node
*rn
;
4051 struct ospf_interface
*oi
;
4053 if (ospf_oi_count(ifp
) == 0)
4056 for (rn
= route_top(IF_OIFS(ifp
)); rn
;
4057 rn
= route_next(rn
)) {
4064 json_interface_sub
=
4065 json_object_new_object();
4068 show_ip_ospf_interface_traffic_sub(
4069 vty
, oi
, json_interface_sub
, use_json
);
4071 json_object_object_add(
4072 json_vrf
, ifp
->name
,
4073 json_interface_sub
);
4078 /* Interface name is specified. */
4079 ifp
= if_lookup_by_name(intf_name
, ospf
->vrf_id
);
4081 struct route_node
*rn
;
4082 struct ospf_interface
*oi
;
4084 if (ospf_oi_count(ifp
) == 0) {
4086 " OSPF not enabled on this interface %s\n",
4091 for (rn
= route_top(IF_OIFS(ifp
)); rn
;
4092 rn
= route_next(rn
)) {
4096 json_interface_sub
=
4097 json_object_new_object();
4100 show_ip_ospf_interface_traffic_sub(
4101 vty
, oi
, json_interface_sub
, use_json
);
4103 json_object_object_add(
4104 json_vrf
, ifp
->name
,
4105 json_interface_sub
);
4113 json_object_object_add(json
, ospf_get_name(ospf
),
4121 DEFUN (show_ip_ospf_interface
,
4122 show_ip_ospf_interface_cmd
,
4123 "show ip ospf [vrf <NAME|all>] interface [INTERFACE] [json]",
4126 "OSPF information\n"
4129 "Interface information\n"
4134 bool uj
= use_json(argc
, argv
);
4135 struct listnode
*node
= NULL
;
4136 char *vrf_name
= NULL
, *intf_name
= NULL
;
4137 bool all_vrf
= false;
4138 int ret
= CMD_SUCCESS
;
4140 int idx_vrf
= 0, idx_intf
= 0;
4141 uint8_t use_vrf
= 0;
4142 json_object
*json
= NULL
;
4144 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
4146 if (argv_find(argv
, argc
, "INTERFACE", &idx_intf
))
4147 intf_name
= argv
[idx_intf
]->arg
;
4150 json
= json_object_new_object();
4152 /* vrf input is provided could be all or specific vrf*/
4156 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
4157 if (!ospf
->oi_running
)
4159 ret
= show_ip_ospf_interface_common(
4160 vty
, ospf
, intf_name
, use_vrf
, json
,
4165 vty_json(vty
, json
);
4167 vty_out(vty
, "%% OSPF instance not found\n");
4171 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
4172 if (ospf
== NULL
|| !ospf
->oi_running
) {
4174 vty_json(vty
, json
);
4176 vty_out(vty
, "%% OSPF instance not found\n");
4180 ret
= show_ip_ospf_interface_common(vty
, ospf
, intf_name
,
4184 /* Display default ospf (instance 0) info */
4185 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
4186 if (ospf
== NULL
|| !ospf
->oi_running
) {
4188 vty_json(vty
, json
);
4190 vty_out(vty
, "%% OSPF instance not found\n");
4194 ret
= show_ip_ospf_interface_common(vty
, ospf
, intf_name
,
4199 vty_json(vty
, json
);
4204 DEFUN (show_ip_ospf_instance_interface
,
4205 show_ip_ospf_instance_interface_cmd
,
4206 "show ip ospf (1-65535) interface [INTERFACE] [json]",
4209 "OSPF information\n"
4211 "Interface information\n"
4218 unsigned short instance
= 0;
4219 bool uj
= use_json(argc
, argv
);
4220 char *intf_name
= NULL
;
4221 int ret
= CMD_SUCCESS
;
4222 json_object
*json
= NULL
;
4224 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4225 if (instance
!= ospf_instance
)
4226 return CMD_NOT_MY_INSTANCE
;
4228 ospf
= ospf_lookup_instance(instance
);
4229 if (!ospf
|| !ospf
->oi_running
)
4233 json
= json_object_new_object();
4235 if (argv_find(argv
, argc
, "INTERFACE", &idx_intf
))
4236 intf_name
= argv
[idx_intf
]->arg
;
4238 ret
= show_ip_ospf_interface_common(vty
, ospf
, intf_name
, 0, json
, uj
);
4241 vty_json(vty
, json
);
4246 DEFUN (show_ip_ospf_interface_traffic
,
4247 show_ip_ospf_interface_traffic_cmd
,
4248 "show ip ospf [vrf <NAME|all>] interface traffic [INTERFACE] [json]",
4251 "OSPF information\n"
4254 "Interface information\n"
4255 "Protocol Packet counters\n"
4259 struct ospf
*ospf
= NULL
;
4260 struct listnode
*node
= NULL
;
4261 char *vrf_name
= NULL
, *intf_name
= NULL
;
4262 bool all_vrf
= false;
4264 int idx_vrf
= 0, idx_intf
= 0;
4265 bool uj
= use_json(argc
, argv
);
4266 json_object
*json
= NULL
;
4267 int ret
= CMD_SUCCESS
;
4268 int display_once
= 0;
4269 uint8_t use_vrf
= 0;
4271 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
4273 if (argv_find(argv
, argc
, "INTERFACE", &idx_intf
))
4274 intf_name
= argv
[idx_intf
]->arg
;
4277 json
= json_object_new_object();
4282 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
4283 if (!ospf
->oi_running
)
4286 ret
= show_ip_ospf_interface_traffic_common(
4287 vty
, ospf
, intf_name
, json
,
4288 display_once
, use_vrf
, uj
);
4293 vty_json(vty
, json
);
4297 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
4298 if (ospf
== NULL
|| !ospf
->oi_running
) {
4300 json_object_free(json
);
4304 ret
= show_ip_ospf_interface_traffic_common(
4305 vty
, ospf
, intf_name
, json
, display_once
, use_vrf
, uj
);
4307 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
4308 if (ospf
== NULL
|| !ospf
->oi_running
) {
4310 json_object_free(json
);
4314 ret
= show_ip_ospf_interface_traffic_common(
4315 vty
, ospf
, intf_name
, json
, display_once
, use_vrf
, uj
);
4319 vty_json(vty
, json
);
4325 static void show_ip_ospf_neighbour_header(struct vty
*vty
)
4327 vty_out(vty
, "\n%-15s %-3s %-15s %-15s %-9s %-15s %-32s %5s %5s %5s\n",
4328 "Neighbor ID", "Pri", "State", "Up Time", "Dead Time",
4329 "Address", "Interface", "RXmtL", "RqstL", "DBsmL");
4332 static void show_ip_ospf_neighbor_sub(struct vty
*vty
,
4333 struct ospf_interface
*oi
,
4334 json_object
*json
, bool use_json
)
4336 struct route_node
*rn
;
4337 struct ospf_neighbor
*nbr
, *prev_nbr
= NULL
;
4339 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4340 json_object
*json_neighbor
= NULL
, *json_neigh_array
= NULL
;
4341 struct timeval res
= {.tv_sec
= 0, .tv_usec
= 0};
4343 char uptime
[OSPF_TIME_DUMP_SIZE
];
4345 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
)) {
4346 if ((nbr
= rn
->info
)) {
4347 /* Do not show myself. */
4348 if (nbr
== oi
->nbr_self
)
4350 /* Down state is not shown. */
4351 if (nbr
->state
== NSM_Down
)
4354 if (nbr
->ts_last_progress
.tv_sec
4355 || nbr
->ts_last_progress
.tv_usec
)
4356 time_val
= monotime_since(
4357 &nbr
->ts_last_progress
, &res
)
4361 char neigh_str
[INET_ADDRSTRLEN
];
4364 && !IPV4_ADDR_SAME(&prev_nbr
->src
,
4366 /* Start new neigh list */
4367 json_neigh_array
= NULL
;
4370 if (nbr
->state
== NSM_Attempt
4371 && nbr
->router_id
.s_addr
== INADDR_ANY
)
4372 strlcpy(neigh_str
, "neighbor",
4375 inet_ntop(AF_INET
, &nbr
->router_id
,
4376 neigh_str
, sizeof(neigh_str
));
4378 json_object_object_get_ex(json
, neigh_str
,
4381 if (!json_neigh_array
) {
4383 json_object_new_array();
4384 json_object_object_add(
4389 json_neighbor
= json_object_new_object();
4391 ospf_nbr_ism_state_message(nbr
, msgbuf
, 16);
4393 json_object_int_add(json_neighbor
, "priority",
4395 json_object_string_add(json_neighbor
, "state",
4398 json_object_string_add(
4399 json_neighbor
, "converged",
4400 lookup_msg(ospf_nsm_state_msg
,
4402 json_object_string_add(
4403 json_neighbor
, "role",
4404 lookup_msg(ospf_ism_state_msg
,
4405 ospf_nbr_ism_state(nbr
),
4408 if (nbr
->t_inactivity
) {
4411 time_store
= monotime_until(
4416 json_object_int_add(json_neighbor
,
4419 json_object_int_add(json_neighbor
,
4422 json_object_string_add(
4423 json_neighbor
, "upTime",
4427 json_object_string_add(
4428 json_neighbor
, "deadTime",
4434 json_object_string_add(json_neighbor
,
4438 json_object_string_addf(json_neighbor
,
4441 json_object_string_add(json_neighbor
,
4444 json_object_int_add(
4445 json_neighbor
, "retransmitCounter",
4446 ospf_ls_retransmit_count(nbr
));
4447 json_object_int_add(json_neighbor
,
4449 ospf_ls_request_count(nbr
));
4450 json_object_int_add(json_neighbor
,
4452 ospf_db_summary_count(nbr
));
4454 json_object_array_add(json_neigh_array
,
4457 ospf_nbr_ism_state_message(nbr
, msgbuf
, 16);
4459 if (nbr
->state
== NSM_Attempt
4460 && nbr
->router_id
.s_addr
== INADDR_ANY
)
4461 vty_out(vty
, "%-15s %3d %-15s ", "-",
4462 nbr
->priority
, msgbuf
);
4464 vty_out(vty
, "%-15pI4 %3d %-15s ",
4465 &nbr
->router_id
, nbr
->priority
,
4468 vty_out(vty
, "%-15s ",
4469 ospf_timeval_dump(&res
, uptime
,
4472 vty_out(vty
, "%9s ",
4473 ospf_timer_dump(nbr
->t_inactivity
,
4476 vty_out(vty
, "%-15pI4 ", &nbr
->src
);
4477 vty_out(vty
, "%-32s %5ld %5ld %5d\n",
4479 ospf_ls_retransmit_count(nbr
),
4480 ospf_ls_request_count(nbr
),
4481 ospf_db_summary_count(nbr
));
4488 static int show_ip_ospf_neighbor_common(struct vty
*vty
, struct ospf
*ospf
,
4489 json_object
*json
, bool use_json
,
4492 struct ospf_interface
*oi
;
4493 struct listnode
*node
;
4494 json_object
*json_vrf
= NULL
;
4495 json_object
*json_nbr_sub
= NULL
;
4499 json_vrf
= json_object_new_object();
4502 json_nbr_sub
= json_object_new_object();
4505 if (ospf
->instance
) {
4507 json_object_int_add(json
, "ospfInstance",
4510 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
4513 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
4515 show_ip_ospf_neighbour_header(vty
);
4517 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
4518 if (ospf_interface_neighbor_count(oi
) == 0)
4520 show_ip_ospf_neighbor_sub(vty
, oi
, json_nbr_sub
, use_json
);
4524 json_object_object_add(json_vrf
, "neighbors", json_nbr_sub
);
4526 json_object_object_add(json
, ospf_get_name(ospf
),
4534 DEFUN (show_ip_ospf_neighbor
,
4535 show_ip_ospf_neighbor_cmd
,
4536 "show ip ospf [vrf <NAME|all>] neighbor [json]",
4539 "OSPF information\n"
4546 bool uj
= use_json(argc
, argv
);
4547 struct listnode
*node
= NULL
;
4548 char *vrf_name
= NULL
;
4549 bool all_vrf
= false;
4550 int ret
= CMD_SUCCESS
;
4553 uint8_t use_vrf
= 0;
4554 json_object
*json
= NULL
;
4556 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
4559 json
= json_object_new_object();
4561 /* vrf input is provided could be all or specific vrf*/
4565 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
4566 if (!ospf
->oi_running
)
4568 ret
= show_ip_ospf_neighbor_common(
4569 vty
, ospf
, json
, uj
, use_vrf
);
4573 vty_json(vty
, json
);
4575 vty_out(vty
, "OSPF instance not found\n");
4580 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
4581 if (ospf
== NULL
|| !ospf
->oi_running
) {
4583 vty_json(vty
, json
);
4585 vty_out(vty
, "%% OSPF instance not found\n");
4590 /* Display default ospf (instance 0) info */
4591 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
4592 if (ospf
== NULL
|| !ospf
->oi_running
) {
4594 vty_json(vty
, json
);
4596 vty_out(vty
, "%% OSPF instance not found\n");
4603 ret
= show_ip_ospf_neighbor_common(vty
, ospf
, json
, uj
,
4607 vty_out(vty
, "%s\n",
4608 json_object_to_json_string_ext(
4609 json
, JSON_C_TO_STRING_PRETTY
));
4614 json_object_free(json
);
4620 DEFUN (show_ip_ospf_instance_neighbor
,
4621 show_ip_ospf_instance_neighbor_cmd
,
4622 "show ip ospf (1-65535) neighbor [json]",
4625 "OSPF information\n"
4632 unsigned short instance
= 0;
4633 bool uj
= use_json(argc
, argv
);
4634 json_object
*json
= NULL
;
4635 int ret
= CMD_SUCCESS
;
4637 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4638 if (instance
!= ospf_instance
)
4639 return CMD_NOT_MY_INSTANCE
;
4641 ospf
= ospf_lookup_instance(instance
);
4642 if (!ospf
|| !ospf
->oi_running
)
4646 json
= json_object_new_object();
4648 ret
= show_ip_ospf_neighbor_common(vty
, ospf
, json
, uj
, 0);
4651 vty_json(vty
, json
);
4656 static int show_ip_ospf_neighbor_all_common(struct vty
*vty
, struct ospf
*ospf
,
4657 json_object
*json
, bool use_json
,
4660 struct listnode
*node
;
4661 struct ospf_interface
*oi
;
4662 char buf
[PREFIX_STRLEN
];
4663 json_object
*json_vrf
= NULL
;
4664 json_object
*json_neighbor_sub
= NULL
;
4668 json_vrf
= json_object_new_object();
4673 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
4675 show_ip_ospf_neighbour_header(vty
);
4677 if (ospf
->instance
) {
4679 json_object_int_add(json_vrf
, "ospfInstance",
4682 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
4685 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
4686 struct listnode
*nbr_node
;
4687 struct ospf_nbr_nbma
*nbr_nbma
;
4689 show_ip_ospf_neighbor_sub(vty
, oi
, json_vrf
, use_json
);
4691 /* print Down neighbor status */
4692 for (ALL_LIST_ELEMENTS_RO(oi
->nbr_nbma
, nbr_node
, nbr_nbma
)) {
4693 if (nbr_nbma
->nbr
== NULL
4694 || nbr_nbma
->nbr
->state
== NSM_Down
) {
4697 json_object_new_object();
4698 json_object_int_add(json_neighbor_sub
,
4700 nbr_nbma
->priority
);
4701 json_object_boolean_true_add(
4704 json_object_string_add(
4708 json_object_int_add(
4710 "nbrNbmaRetransmitCounter", 0);
4711 json_object_int_add(
4713 "nbrNbmaRequestCounter", 0);
4714 json_object_int_add(
4716 "nbrNbmaDbSummaryCounter", 0);
4717 json_object_object_add(
4720 &nbr_nbma
->addr
, buf
,
4724 vty_out(vty
, "%-15s %3d %-15s %9s ",
4725 "-", nbr_nbma
->priority
, "Down",
4728 "%-32pI4 %-20s %5d %5d %5d\n",
4730 IF_NAME(oi
), 0, 0, 0);
4738 json_object_object_add(json
, ospf_get_name(ospf
),
4746 DEFUN (show_ip_ospf_neighbor_all
,
4747 show_ip_ospf_neighbor_all_cmd
,
4748 "show ip ospf [vrf <NAME|all>] neighbor all [json]",
4751 "OSPF information\n"
4755 "include down status neighbor\n"
4759 bool uj
= use_json(argc
, argv
);
4760 struct listnode
*node
= NULL
;
4761 char *vrf_name
= NULL
;
4762 bool all_vrf
= false;
4763 int ret
= CMD_SUCCESS
;
4766 uint8_t use_vrf
= 0;
4767 json_object
*json
= NULL
;
4769 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
4772 json
= json_object_new_object();
4774 /* vrf input is provided could be all or specific vrf*/
4778 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
4779 if (!ospf
->oi_running
)
4781 ret
= show_ip_ospf_neighbor_all_common(
4782 vty
, ospf
, json
, uj
, use_vrf
);
4786 vty_json(vty
, json
);
4791 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
4792 if (ospf
== NULL
|| !ospf
->oi_running
) {
4794 json_object_free(json
);
4798 /* Display default ospf (instance 0) info */
4799 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
4800 if (ospf
== NULL
|| !ospf
->oi_running
) {
4802 json_object_free(json
);
4808 ret
= show_ip_ospf_neighbor_all_common(vty
, ospf
, json
, uj
,
4811 vty_out(vty
, "%s\n",
4812 json_object_to_json_string_ext(
4813 json
, JSON_C_TO_STRING_PRETTY
));
4818 json_object_free(json
);
4823 DEFUN (show_ip_ospf_instance_neighbor_all
,
4824 show_ip_ospf_instance_neighbor_all_cmd
,
4825 "show ip ospf (1-65535) neighbor all [json]",
4828 "OSPF information\n"
4831 "include down status neighbor\n"
4836 unsigned short instance
= 0;
4837 bool uj
= use_json(argc
, argv
);
4838 json_object
*json
= NULL
;
4839 int ret
= CMD_SUCCESS
;
4841 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4842 if (instance
!= ospf_instance
)
4843 return CMD_NOT_MY_INSTANCE
;
4845 ospf
= ospf_lookup_instance(instance
);
4846 if (!ospf
|| !ospf
->oi_running
)
4849 json
= json_object_new_object();
4851 ret
= show_ip_ospf_neighbor_all_common(vty
, ospf
, json
, uj
, 0);
4854 vty_json(vty
, json
);
4859 static int show_ip_ospf_neighbor_int_common(struct vty
*vty
, struct ospf
*ospf
,
4861 struct cmd_token
**argv
,
4862 bool use_json
, uint8_t use_vrf
)
4864 struct interface
*ifp
;
4865 struct route_node
*rn
;
4866 json_object
*json
= NULL
;
4869 json
= json_object_new_object();
4871 if (ospf
->instance
) {
4873 json_object_int_add(json
, "ospfInstance",
4876 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
4879 ospf_show_vrf_name(ospf
, vty
, json
, use_vrf
);
4881 ifp
= if_lookup_by_name(argv
[arg_base
]->arg
, ospf
->vrf_id
);
4884 json_object_boolean_true_add(json
, "noSuchIface");
4886 vty_out(vty
, "No such interface.\n");
4890 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
4891 struct ospf_interface
*oi
= rn
->info
;
4896 show_ip_ospf_neighbor_sub(vty
, oi
, json
, use_json
);
4900 vty_json(vty
, json
);
4907 DEFUN (show_ip_ospf_neighbor_int
,
4908 show_ip_ospf_neighbor_int_cmd
,
4909 "show ip ospf [vrf <NAME>] neighbor IFNAME [json]",
4912 "OSPF information\n"
4921 bool uj
= use_json(argc
, argv
);
4922 int ret
= CMD_SUCCESS
;
4923 struct interface
*ifp
= NULL
;
4924 char *vrf_name
= NULL
;
4925 vrf_id_t vrf_id
= VRF_DEFAULT
;
4926 struct vrf
*vrf
= NULL
;
4928 if (argv_find(argv
, argc
, "vrf", &idx_vrf
))
4929 vrf_name
= argv
[idx_vrf
+ 1]->arg
;
4930 if (vrf_name
&& strmatch(vrf_name
, VRF_DEFAULT_NAME
))
4933 vrf
= vrf_lookup_by_name(vrf_name
);
4935 vrf_id
= vrf
->vrf_id
;
4937 ospf
= ospf_lookup_by_vrf_id(vrf_id
);
4939 if (!ospf
|| !ospf
->oi_running
)
4943 show_ip_ospf_neighbour_header(vty
);
4945 argv_find(argv
, argc
, "IFNAME", &idx_ifname
);
4947 ifp
= if_lookup_by_name(argv
[idx_ifname
]->arg
, vrf_id
);
4951 ret
= show_ip_ospf_neighbor_int_common(vty
, ospf
, idx_ifname
,
4956 DEFUN (show_ip_ospf_instance_neighbor_int
,
4957 show_ip_ospf_instance_neighbor_int_cmd
,
4958 "show ip ospf (1-65535) neighbor IFNAME [json]",
4961 "OSPF information\n"
4970 unsigned short instance
= 0;
4971 bool uj
= use_json(argc
, argv
);
4974 show_ip_ospf_neighbour_header(vty
);
4976 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4977 if (instance
!= ospf_instance
)
4978 return CMD_NOT_MY_INSTANCE
;
4980 ospf
= ospf_lookup_instance(instance
);
4981 if (!ospf
|| !ospf
->oi_running
)
4985 show_ip_ospf_neighbour_header(vty
);
4987 return show_ip_ospf_neighbor_int_common(vty
, ospf
, idx_ifname
, argv
, uj
,
4991 static void show_ip_ospf_nbr_nbma_detail_sub(struct vty
*vty
,
4992 struct ospf_interface
*oi
,
4993 struct ospf_nbr_nbma
*nbr_nbma
,
4994 bool use_json
, json_object
*json
)
4996 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4997 json_object
*json_sub
= NULL
;
5000 json_sub
= json_object_new_object();
5001 else /* Show neighbor ID. */
5002 vty_out(vty
, " Neighbor %s,", "-");
5004 /* Show interface address. */
5006 json_object_string_addf(json_sub
, "ifaceAddress", "%pI4",
5009 vty_out(vty
, " interface address %pI4\n",
5014 json_object_string_add(json_sub
, "areaId",
5015 ospf_area_desc_string(oi
->area
));
5016 json_object_string_add(json_sub
, "iface", IF_NAME(oi
));
5018 vty_out(vty
, " In the area %s via interface %s\n",
5019 ospf_area_desc_string(oi
->area
), IF_NAME(oi
));
5021 /* Show neighbor priority and state. */
5023 json_object_int_add(json_sub
, "nbrPriority",
5024 nbr_nbma
->priority
);
5025 json_object_string_add(json_sub
, "nbrState", "down");
5027 vty_out(vty
, " Neighbor priority is %d, State is %s,",
5028 nbr_nbma
->priority
, "Down");
5030 /* Show state changes. */
5032 json_object_int_add(json_sub
, "stateChangeCounter",
5033 nbr_nbma
->state_change
);
5035 vty_out(vty
, " %d state changes\n", nbr_nbma
->state_change
);
5037 /* Show PollInterval */
5039 json_object_int_add(json_sub
, "pollInterval", nbr_nbma
->v_poll
);
5041 vty_out(vty
, " Poll interval %d\n", nbr_nbma
->v_poll
);
5043 /* Show poll-interval timer. */
5044 if (nbr_nbma
->t_poll
) {
5047 time_store
= monotime_until(&nbr_nbma
->t_poll
->u
.sands
,
5049 json_object_int_add(json_sub
,
5050 "pollIntervalTimerDueMsec",
5053 vty_out(vty
, " Poll timer due in %s\n",
5054 ospf_timer_dump(nbr_nbma
->t_poll
, timebuf
,
5058 /* Show poll-interval timer thread. */
5060 if (nbr_nbma
->t_poll
!= NULL
)
5061 json_object_string_add(json_sub
,
5062 "pollIntervalTimerThread", "on");
5064 vty_out(vty
, " Thread Poll Timer %s\n",
5065 nbr_nbma
->t_poll
!= NULL
? "on" : "off");
5068 json_object_object_add(json
, "noNbrId", json_sub
);
5071 static void show_ip_ospf_neighbor_detail_sub(struct vty
*vty
,
5072 struct ospf_interface
*oi
,
5073 struct ospf_neighbor
*nbr
,
5074 struct ospf_neighbor
*prev_nbr
,
5075 json_object
*json
, bool use_json
)
5077 char timebuf
[OSPF_TIME_DUMP_SIZE
];
5078 json_object
*json_neigh
= NULL
, *json_neigh_array
= NULL
;
5079 char neigh_str
[INET_ADDRSTRLEN
] = {0};
5083 !IPV4_ADDR_SAME(&prev_nbr
->src
, &nbr
->src
)) {
5084 json_neigh_array
= NULL
;
5087 if (nbr
->state
== NSM_Attempt
5088 && nbr
->router_id
.s_addr
== INADDR_ANY
)
5089 strlcpy(neigh_str
, "noNbrId", sizeof(neigh_str
));
5091 inet_ntop(AF_INET
, &nbr
->router_id
,
5092 neigh_str
, sizeof(neigh_str
));
5094 json_object_object_get_ex(json
, neigh_str
, &json_neigh_array
);
5096 if (!json_neigh_array
) {
5097 json_neigh_array
= json_object_new_array();
5098 json_object_object_add(json
, neigh_str
,
5102 json_neigh
= json_object_new_object();
5105 /* Show neighbor ID. */
5106 if (nbr
->state
== NSM_Attempt
5107 && nbr
->router_id
.s_addr
== INADDR_ANY
)
5108 vty_out(vty
, " Neighbor %s,", "-");
5110 vty_out(vty
, " Neighbor %pI4,",
5114 /* Show interface address. */
5116 json_object_string_addf(json_neigh
, "ifaceAddress", "%pI4",
5117 &nbr
->address
.u
.prefix4
);
5119 vty_out(vty
, " interface address %pI4\n",
5120 &nbr
->address
.u
.prefix4
);
5124 json_object_string_add(json_neigh
, "areaId",
5125 ospf_area_desc_string(oi
->area
));
5126 json_object_string_add(json_neigh
, "ifaceName", oi
->ifp
->name
);
5128 vty_out(vty
, " In the area %s via interface %s\n",
5129 ospf_area_desc_string(oi
->area
), oi
->ifp
->name
);
5131 /* Show neighbor priority and state. */
5133 json_object_int_add(json_neigh
, "nbrPriority", nbr
->priority
);
5134 json_object_string_add(
5135 json_neigh
, "nbrState",
5136 lookup_msg(ospf_nsm_state_msg
, nbr
->state
, NULL
));
5138 vty_out(vty
, " Neighbor priority is %d, State is %s,",
5140 lookup_msg(ospf_nsm_state_msg
, nbr
->state
, NULL
));
5142 /* Show state changes. */
5144 json_object_int_add(json_neigh
, "stateChangeCounter",
5147 vty_out(vty
, " %d state changes\n", nbr
->state_change
);
5149 if (nbr
->ts_last_progress
.tv_sec
|| nbr
->ts_last_progress
.tv_usec
) {
5154 monotime_since(&nbr
->ts_last_progress
, &res
) / 1000LL;
5156 json_object_int_add(json_neigh
, "lastPrgrsvChangeMsec",
5160 " Most recent state change statistics:\n");
5161 vty_out(vty
, " Progressive change %s ago\n",
5162 ospf_timeval_dump(&res
, timebuf
,
5167 if (nbr
->ts_last_regress
.tv_sec
|| nbr
->ts_last_regress
.tv_usec
) {
5172 monotime_since(&nbr
->ts_last_regress
, &res
) / 1000LL;
5174 json_object_int_add(json_neigh
,
5175 "lastRegressiveChangeMsec",
5177 if (nbr
->last_regress_str
)
5178 json_object_string_add(
5180 "lastRegressiveChangeReason",
5181 nbr
->last_regress_str
);
5184 " Regressive change %s ago, due to %s\n",
5185 ospf_timeval_dump(&res
, timebuf
,
5187 (nbr
->last_regress_str
? nbr
->last_regress_str
5192 /* Show Designated Rotuer ID. */
5194 json_object_string_addf(json_neigh
, "routerDesignatedId",
5195 "%pI4", &nbr
->d_router
);
5197 vty_out(vty
, " DR is %pI4,", &nbr
->d_router
);
5199 /* Show Backup Designated Rotuer ID. */
5201 json_object_string_addf(json_neigh
, "routerDesignatedBackupId",
5202 "%pI4", &nbr
->bd_router
);
5204 vty_out(vty
, " BDR is %pI4\n", &nbr
->bd_router
);
5208 json_object_int_add(json_neigh
, "optionsCounter", nbr
->options
);
5209 json_object_string_add(json_neigh
, "optionsList",
5210 ospf_options_dump(nbr
->options
));
5212 vty_out(vty
, " Options %d %s\n", nbr
->options
,
5213 ospf_options_dump(nbr
->options
));
5215 /* Show Router Dead interval timer. */
5217 if (nbr
->t_inactivity
) {
5219 time_store
= monotime_until(&nbr
->t_inactivity
->u
.sands
,
5222 json_object_int_add(json_neigh
,
5223 "routerDeadIntervalTimerDueMsec",
5226 json_object_int_add(
5228 "routerDeadIntervalTimerDueMsec", -1);
5230 vty_out(vty
, " Dead timer due in %s\n",
5231 ospf_timer_dump(nbr
->t_inactivity
, timebuf
,
5234 /* Show Database Summary list. */
5236 json_object_int_add(json_neigh
, "databaseSummaryListCounter",
5237 ospf_db_summary_count(nbr
));
5239 vty_out(vty
, " Database Summary List %d\n",
5240 ospf_db_summary_count(nbr
));
5242 /* Show Link State Request list. */
5244 json_object_int_add(json_neigh
, "linkStateRequestListCounter",
5245 ospf_ls_request_count(nbr
));
5247 vty_out(vty
, " Link State Request List %ld\n",
5248 ospf_ls_request_count(nbr
));
5250 /* Show Link State Retransmission list. */
5252 json_object_int_add(json_neigh
,
5253 "linkStateRetransmissionListCounter",
5254 ospf_ls_retransmit_count(nbr
));
5256 vty_out(vty
, " Link State Retransmission List %ld\n",
5257 ospf_ls_retransmit_count(nbr
));
5259 /* Show inactivity timer thread. */
5261 if (nbr
->t_inactivity
!= NULL
)
5262 json_object_string_add(json_neigh
,
5263 "threadInactivityTimer", "on");
5265 vty_out(vty
, " Thread Inactivity Timer %s\n",
5266 nbr
->t_inactivity
!= NULL
? "on" : "off");
5268 /* Show Database Description retransmission thread. */
5270 if (nbr
->t_db_desc
!= NULL
)
5271 json_object_string_add(
5273 "threadDatabaseDescriptionRetransmission",
5277 " Thread Database Description Retransmision %s\n",
5278 nbr
->t_db_desc
!= NULL
? "on" : "off");
5280 /* Show Link State Request Retransmission thread. */
5282 if (nbr
->t_ls_req
!= NULL
)
5283 json_object_string_add(
5285 "threadLinkStateRequestRetransmission", "on");
5288 " Thread Link State Request Retransmission %s\n",
5289 nbr
->t_ls_req
!= NULL
? "on" : "off");
5291 /* Show Link State Update Retransmission thread. */
5293 if (nbr
->t_ls_upd
!= NULL
)
5294 json_object_string_add(
5296 "threadLinkStateUpdateRetransmission",
5300 " Thread Link State Update Retransmission %s\n\n",
5301 nbr
->t_ls_upd
!= NULL
? "on" : "off");
5304 vty_out(vty
, " Graceful restart Helper info:\n");
5306 if (OSPF_GR_IS_ACTIVE_HELPER(nbr
)) {
5308 " Graceful Restart HELPER Status : Inprogress.\n");
5311 " Graceful Restart grace period time: %d (seconds).\n",
5312 nbr
->gr_helper_info
.recvd_grace_period
);
5313 vty_out(vty
, " Graceful Restart reason: %s.\n",
5314 ospf_restart_reason2str(
5315 nbr
->gr_helper_info
.gr_restart_reason
));
5318 " Graceful Restart HELPER Status : None\n");
5321 if (nbr
->gr_helper_info
.rejected_reason
5322 != OSPF_HELPER_REJECTED_NONE
)
5323 vty_out(vty
, " Helper rejected reason: %s.\n",
5324 ospf_rejected_reason2str(
5325 nbr
->gr_helper_info
.rejected_reason
));
5327 if (nbr
->gr_helper_info
.helper_exit_reason
5328 != OSPF_GR_HELPER_EXIT_NONE
)
5329 vty_out(vty
, " Last helper exit reason: %s.\n\n",
5330 ospf_exit_reason2str(
5331 nbr
->gr_helper_info
.helper_exit_reason
));
5335 json_object_string_add(json_neigh
, "grHelperStatus",
5336 OSPF_GR_IS_ACTIVE_HELPER(nbr
) ?
5339 if (OSPF_GR_IS_ACTIVE_HELPER(nbr
)) {
5340 json_object_int_add(
5341 json_neigh
, "graceInterval",
5342 nbr
->gr_helper_info
.recvd_grace_period
);
5343 json_object_string_add(
5344 json_neigh
, "grRestartReason",
5345 ospf_restart_reason2str(
5346 nbr
->gr_helper_info
.gr_restart_reason
));
5349 if (nbr
->gr_helper_info
.rejected_reason
5350 != OSPF_HELPER_REJECTED_NONE
)
5351 json_object_string_add(
5352 json_neigh
, "helperRejectReason",
5353 ospf_rejected_reason2str(
5354 nbr
->gr_helper_info
.rejected_reason
));
5356 if (nbr
->gr_helper_info
.helper_exit_reason
5357 != OSPF_GR_HELPER_EXIT_NONE
)
5358 json_object_string_add(
5359 json_neigh
, "helperExitReason",
5360 ospf_exit_reason2str(
5362 .helper_exit_reason
));
5365 bfd_sess_show(vty
, json_neigh
, nbr
->bfd_session
);
5368 json_object_array_add(json_neigh_array
, json_neigh
);
5372 static int show_ip_ospf_neighbor_id_common(struct vty
*vty
, struct ospf
*ospf
,
5373 struct in_addr
*router_id
,
5374 bool use_json
, uint8_t use_vrf
)
5376 struct listnode
*node
;
5377 struct ospf_neighbor
*nbr
;
5378 struct ospf_interface
*oi
;
5379 json_object
*json
= NULL
;
5382 json
= json_object_new_object();
5384 if (ospf
->instance
) {
5386 json_object_int_add(json
, "ospfInstance",
5389 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
5392 ospf_show_vrf_name(ospf
, vty
, json
, use_vrf
);
5394 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
5395 if ((nbr
= ospf_nbr_lookup_by_routerid(oi
->nbrs
, router_id
))) {
5396 show_ip_ospf_neighbor_detail_sub(vty
, oi
, nbr
, NULL
,
5402 vty_json(vty
, json
);
5409 DEFPY (show_ip_ospf_neighbor_id
,
5410 show_ip_ospf_neighbor_id_cmd
,
5411 "show ip ospf neighbor A.B.C.D$router_id [json$json]",
5414 "OSPF information\n"
5420 struct listnode
*node
;
5421 int ret
= CMD_SUCCESS
;
5423 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
5424 if (!ospf
->oi_running
)
5426 ret
= show_ip_ospf_neighbor_id_common(vty
, ospf
, &router_id
,
5433 DEFPY (show_ip_ospf_instance_neighbor_id
,
5434 show_ip_ospf_instance_neighbor_id_cmd
,
5435 "show ip ospf (1-65535)$instance neighbor A.B.C.D$router_id [json$json]",
5438 "OSPF information\n"
5446 if (instance
!= ospf_instance
)
5447 return CMD_NOT_MY_INSTANCE
;
5449 ospf
= ospf_lookup_instance(instance
);
5450 if (!ospf
|| !ospf
->oi_running
)
5453 return show_ip_ospf_neighbor_id_common(vty
, ospf
, &router_id
, !!json
,
5457 static int show_ip_ospf_neighbor_detail_common(struct vty
*vty
,
5459 json_object
*json
, bool use_json
,
5462 struct ospf_interface
*oi
;
5463 struct listnode
*node
;
5464 json_object
*json_vrf
= NULL
;
5465 json_object
*json_nbr_sub
= NULL
;
5469 json_vrf
= json_object_new_object();
5473 json_nbr_sub
= json_object_new_object();
5476 if (ospf
->instance
) {
5478 json_object_int_add(json
, "ospfInstance",
5481 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
5484 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
5486 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
5487 struct route_node
*rn
;
5488 struct ospf_neighbor
*nbr
, *prev_nbr
= NULL
;
5490 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
)) {
5491 if ((nbr
= rn
->info
)) {
5492 if (nbr
!= oi
->nbr_self
) {
5493 if (nbr
->state
!= NSM_Down
) {
5494 show_ip_ospf_neighbor_detail_sub(
5495 vty
, oi
, nbr
, prev_nbr
,
5496 json_nbr_sub
, use_json
);
5505 json_object_object_add(json_vrf
, "neighbors",
5508 json_object_object_add(json
, ospf_get_name(ospf
),
5516 DEFUN (show_ip_ospf_neighbor_detail
,
5517 show_ip_ospf_neighbor_detail_cmd
,
5518 "show ip ospf [vrf <NAME|all>] neighbor detail [json]",
5521 "OSPF information\n"
5525 "detail of all neighbors\n"
5529 bool uj
= use_json(argc
, argv
);
5530 struct listnode
*node
= NULL
;
5531 char *vrf_name
= NULL
;
5532 bool all_vrf
= false;
5533 int ret
= CMD_SUCCESS
;
5536 uint8_t use_vrf
= 0;
5537 json_object
*json
= NULL
;
5539 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
5542 json
= json_object_new_object();
5544 /* vrf input is provided could be all or specific vrf*/
5548 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
5549 if (!ospf
->oi_running
)
5551 ret
= show_ip_ospf_neighbor_detail_common(
5552 vty
, ospf
, json
, uj
, use_vrf
);
5555 vty_json(vty
, json
);
5559 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
5560 if (ospf
== NULL
|| !ospf
->oi_running
) {
5562 json_object_free(json
);
5566 /* Display default ospf (instance 0) info */
5567 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
5568 if (ospf
== NULL
|| !ospf
->oi_running
) {
5570 json_object_free(json
);
5576 ret
= show_ip_ospf_neighbor_detail_common(vty
, ospf
, json
, uj
,
5579 vty_out(vty
, "%s\n",
5580 json_object_to_json_string_ext(
5581 json
, JSON_C_TO_STRING_PRETTY
));
5586 json_object_free(json
);
5591 DEFUN (show_ip_ospf_instance_neighbor_detail
,
5592 show_ip_ospf_instance_neighbor_detail_cmd
,
5593 "show ip ospf (1-65535) neighbor detail [json]",
5596 "OSPF information\n"
5599 "detail of all neighbors\n"
5604 unsigned short instance
= 0;
5605 bool uj
= use_json(argc
, argv
);
5606 json_object
*json
= NULL
;
5607 int ret
= CMD_SUCCESS
;
5609 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5610 if (instance
!= ospf_instance
)
5611 return CMD_NOT_MY_INSTANCE
;
5613 ospf
= ospf_lookup_instance(instance
);
5614 if (!ospf
|| !ospf
->oi_running
)
5618 json
= json_object_new_object();
5620 ret
= show_ip_ospf_neighbor_detail_common(vty
, ospf
, json
, uj
, 0);
5623 vty_json(vty
, json
);
5628 static int show_ip_ospf_neighbor_detail_all_common(struct vty
*vty
,
5634 struct listnode
*node
;
5635 struct ospf_interface
*oi
;
5636 json_object
*json_vrf
= NULL
;
5640 json_vrf
= json_object_new_object();
5645 if (ospf
->instance
) {
5647 json_object_int_add(json
, "ospfInstance",
5650 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
5653 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
5655 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
5656 struct route_node
*rn
;
5657 struct ospf_neighbor
*nbr
, *prev_nbr
= NULL
;
5658 struct ospf_nbr_nbma
*nbr_nbma
;
5660 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
)) {
5661 if ((nbr
= rn
->info
)) {
5662 if (nbr
!= oi
->nbr_self
)
5663 if (nbr
->state
!= NSM_Down
)
5664 show_ip_ospf_neighbor_detail_sub(
5667 json_vrf
, use_json
);
5672 if (oi
->type
== OSPF_IFTYPE_NBMA
) {
5673 struct listnode
*nd
;
5675 for (ALL_LIST_ELEMENTS_RO(oi
->nbr_nbma
, nd
, nbr_nbma
)) {
5676 if (nbr_nbma
->nbr
== NULL
5677 || nbr_nbma
->nbr
->state
== NSM_Down
)
5678 show_ip_ospf_nbr_nbma_detail_sub(
5679 vty
, oi
, nbr_nbma
, use_json
,
5687 json_object_object_add(json
, ospf_get_name(ospf
),
5696 DEFUN (show_ip_ospf_neighbor_detail_all
,
5697 show_ip_ospf_neighbor_detail_all_cmd
,
5698 "show ip ospf [vrf <NAME|all>] neighbor detail all [json]",
5701 "OSPF information\n"
5705 "detail of all neighbors\n"
5706 "include down status neighbor\n"
5710 bool uj
= use_json(argc
, argv
);
5711 struct listnode
*node
= NULL
;
5712 char *vrf_name
= NULL
;
5713 bool all_vrf
= false;
5714 int ret
= CMD_SUCCESS
;
5717 uint8_t use_vrf
= 0;
5718 json_object
*json
= NULL
;
5720 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
5723 json
= json_object_new_object();
5725 /* vrf input is provided could be all or specific vrf*/
5729 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
5730 if (!ospf
->oi_running
)
5732 ret
= show_ip_ospf_neighbor_detail_all_common(
5733 vty
, ospf
, json
, uj
, use_vrf
);
5737 vty_json(vty
, json
);
5741 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
5742 if (ospf
== NULL
|| !ospf
->oi_running
) {
5744 json_object_free(json
);
5748 /* Display default ospf (instance 0) info */
5749 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
5750 if (ospf
== NULL
|| !ospf
->oi_running
) {
5752 json_object_free(json
);
5758 ret
= show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, json
,
5761 vty_out(vty
, "%s\n",
5762 json_object_to_json_string_ext(
5763 json
, JSON_C_TO_STRING_PRETTY
));
5768 json_object_free(json
);
5773 DEFUN (show_ip_ospf_instance_neighbor_detail_all
,
5774 show_ip_ospf_instance_neighbor_detail_all_cmd
,
5775 "show ip ospf (1-65535) neighbor detail all [json]",
5778 "OSPF information\n"
5781 "detail of all neighbors\n"
5782 "include down status neighbor\n"
5787 unsigned short instance
= 0;
5788 bool uj
= use_json(argc
, argv
);
5789 json_object
*json
= NULL
;
5790 int ret
= CMD_SUCCESS
;
5792 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5793 if (instance
!= ospf_instance
)
5794 return CMD_NOT_MY_INSTANCE
;
5796 ospf
= ospf_lookup_instance(instance
);
5797 if (!ospf
|| !ospf
->oi_running
)
5801 json
= json_object_new_object();
5803 ret
= show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, json
, uj
, 0);
5806 vty_json(vty
, json
);
5811 static int show_ip_ospf_neighbor_int_detail_common(struct vty
*vty
,
5814 struct cmd_token
**argv
,
5817 struct ospf_interface
*oi
;
5818 struct interface
*ifp
;
5819 struct route_node
*rn
, *nrn
;
5820 struct ospf_neighbor
*nbr
;
5821 json_object
*json
= NULL
;
5824 json
= json_object_new_object();
5826 if (ospf
->instance
) {
5828 json_object_int_add(json
, "ospfInstance",
5831 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
5834 ifp
= if_lookup_by_name(argv
[arg_base
]->arg
, ospf
->vrf_id
);
5837 vty_out(vty
, "No such interface.\n");
5839 vty_out(vty
, "{}\n");
5840 json_object_free(json
);
5845 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
5846 if ((oi
= rn
->info
)) {
5847 for (nrn
= route_top(oi
->nbrs
); nrn
;
5848 nrn
= route_next(nrn
)) {
5849 if ((nbr
= nrn
->info
)) {
5850 if (nbr
!= oi
->nbr_self
) {
5851 if (nbr
->state
!= NSM_Down
)
5852 show_ip_ospf_neighbor_detail_sub(
5863 vty_json(vty
, json
);
5870 DEFUN (show_ip_ospf_neighbor_int_detail
,
5871 show_ip_ospf_neighbor_int_detail_cmd
,
5872 "show ip ospf neighbor IFNAME detail [json]",
5875 "OSPF information\n"
5878 "detail of all neighbors\n"
5882 bool uj
= use_json(argc
, argv
);
5883 struct listnode
*node
= NULL
;
5884 int ret
= CMD_SUCCESS
;
5885 bool ospf_output
= false;
5887 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
5888 if (!ospf
->oi_running
)
5891 ret
= show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 4,
5896 vty_out(vty
, "%% OSPF instance not found\n");
5901 DEFUN (show_ip_ospf_instance_neighbor_int_detail
,
5902 show_ip_ospf_instance_neighbor_int_detail_cmd
,
5903 "show ip ospf (1-65535) neighbor IFNAME detail [json]",
5906 "OSPF information\n"
5910 "detail of all neighbors\n"
5916 unsigned short instance
= 0;
5917 bool uj
= use_json(argc
, argv
);
5919 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5920 if (instance
!= ospf_instance
)
5921 return CMD_NOT_MY_INSTANCE
;
5923 ospf
= ospf_lookup_instance(instance
);
5924 if (!ospf
|| !ospf
->oi_running
)
5927 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, idx_ifname
,
5931 /* Show functions */
5932 static int show_lsa_summary(struct vty
*vty
, struct ospf_lsa
*lsa
, int self
,
5933 json_object
*json_lsa
)
5935 struct router_lsa
*rl
;
5936 struct summary_lsa
*sl
;
5937 struct as_external_lsa
*asel
;
5938 struct prefix_ipv4 p
;
5941 /* If self option is set, check LSA self flag. */
5942 if (self
== 0 || IS_LSA_SELF(lsa
)) {
5945 /* LSA common part show. */
5946 vty_out(vty
, "%-15pI4",
5948 vty_out(vty
, "%-15pI4 %4d 0x%08lx 0x%04x",
5949 &lsa
->data
->adv_router
, LS_AGE(lsa
),
5950 (unsigned long)ntohl(
5951 lsa
->data
->ls_seqnum
),
5952 ntohs(lsa
->data
->checksum
));
5957 snprintf(seqnum
, sizeof(seqnum
), "%x",
5958 ntohl(lsa
->data
->ls_seqnum
));
5959 snprintf(checksum
, sizeof(checksum
), "%x",
5960 ntohs(lsa
->data
->checksum
));
5961 json_object_string_addf(json_lsa
, "lsId",
5962 "%pI4", &lsa
->data
->id
);
5963 json_object_string_addf(
5964 json_lsa
, "advertisedRouter", "%pI4",
5965 &lsa
->data
->adv_router
);
5966 json_object_int_add(json_lsa
, "lsaAge",
5968 json_object_string_add(
5969 json_lsa
, "sequenceNumber", seqnum
);
5970 json_object_string_add(json_lsa
, "checksum",
5974 /* LSA specific part show. */
5975 switch (lsa
->data
->type
) {
5976 case OSPF_ROUTER_LSA
:
5977 rl
= (struct router_lsa
*)lsa
->data
;
5980 vty_out(vty
, " %-d", ntohs(rl
->links
));
5982 json_object_int_add(json_lsa
,
5986 case OSPF_SUMMARY_LSA
:
5987 sl
= (struct summary_lsa
*)lsa
->data
;
5990 p
.prefix
= sl
->header
.id
;
5991 p
.prefixlen
= ip_masklen(sl
->mask
);
5992 apply_mask_ipv4(&p
);
5995 vty_out(vty
, " %pFX", &p
);
5997 json_object_string_addf(
5998 json_lsa
, "summaryAddress",
6002 case OSPF_AS_EXTERNAL_LSA
:
6003 case OSPF_AS_NSSA_LSA
:
6004 asel
= (struct as_external_lsa
*)lsa
->data
;
6007 p
.prefix
= asel
->header
.id
;
6008 p
.prefixlen
= ip_masklen(asel
->mask
);
6009 apply_mask_ipv4(&p
);
6012 vty_out(vty
, " %s %pFX [0x%lx]",
6018 (unsigned long)ntohl(
6019 asel
->e
[0].route_tag
));
6021 json_object_string_add(
6022 json_lsa
, "metricType",
6027 json_object_string_addf(
6028 json_lsa
, "route", "%pFX", &p
);
6029 json_object_int_add(
6031 (unsigned long)ntohl(
6032 asel
->e
[0].route_tag
));
6035 case OSPF_NETWORK_LSA
:
6036 case OSPF_ASBR_SUMMARY_LSA
:
6037 case OSPF_OPAQUE_LINK_LSA
:
6038 case OSPF_OPAQUE_AREA_LSA
:
6039 case OSPF_OPAQUE_AS_LSA
:
6054 static const char *const show_database_desc
[] = {
6056 "Router Link States",
6058 "Summary Link States",
6059 "ASBR-Summary Link States",
6060 "AS External Link States",
6061 "Group Membership LSA",
6062 "NSSA-external Link States",
6064 "Link-Local Opaque-LSA",
6065 "Area-Local Opaque-LSA",
6066 "AS-external Opaque-LSA",
6069 static const char * const show_database_desc_json
[] = {
6072 "networkLinkStates",
6073 "summaryLinkStates",
6074 "asbrSummaryLinkStates",
6075 "asExternalLinkStates",
6076 "groupMembershipLsa",
6077 "nssaExternalLinkStates",
6079 "linkLocalOpaqueLsa",
6080 "areaLocalOpaqueLsa",
6081 "asExternalOpaqueLsa",
6084 static const char *const show_database_desc_count_json
[] = {
6086 "routerLinkStatesCount",
6087 "networkLinkStatesCount",
6088 "summaryLinkStatesCount",
6089 "asbrSummaryLinkStatesCount",
6090 "asExternalLinkStatesCount",
6091 "groupMembershipLsaCount",
6092 "nssaExternalLinkStatesCount",
6094 "linkLocalOpaqueLsaCount",
6095 "areaLocalOpaqueLsaCount",
6096 "asExternalOpaqueLsaCount",
6099 static const char *const show_database_header
[] = {
6101 "Link ID ADV Router Age Seq# CkSum Link count",
6102 "Link ID ADV Router Age Seq# CkSum",
6103 "Link ID ADV Router Age Seq# CkSum Route",
6104 "Link ID ADV Router Age Seq# CkSum",
6105 "Link ID ADV Router Age Seq# CkSum Route",
6106 " --- header for Group Member ----",
6107 "Link ID ADV Router Age Seq# CkSum Route",
6109 "Opaque-Type/Id ADV Router Age Seq# CkSum",
6110 "Opaque-Type/Id ADV Router Age Seq# CkSum",
6111 "Opaque-Type/Id ADV Router Age Seq# CkSum",
6114 static void show_ip_ospf_database_header(struct vty
*vty
, struct ospf_lsa
*lsa
,
6117 struct router_lsa
*rlsa
= (struct router_lsa
*)lsa
->data
;
6120 vty_out(vty
, " LS age: %d\n", LS_AGE(lsa
));
6121 vty_out(vty
, " Options: 0x%-2x : %s\n", lsa
->data
->options
,
6122 ospf_options_dump(lsa
->data
->options
));
6123 vty_out(vty
, " LS Flags: 0x%-2x %s\n", lsa
->flags
,
6124 ((lsa
->flags
& OSPF_LSA_LOCAL_XLT
)
6125 ? "(Translated from Type-7)"
6128 if (lsa
->data
->type
== OSPF_ROUTER_LSA
) {
6129 vty_out(vty
, " Flags: 0x%x", rlsa
->flags
);
6132 vty_out(vty
, " :%s%s%s%s",
6133 IS_ROUTER_LSA_BORDER(rlsa
) ? " ABR"
6135 IS_ROUTER_LSA_EXTERNAL(rlsa
) ? " ASBR"
6137 IS_ROUTER_LSA_VIRTUAL(rlsa
)
6140 IS_ROUTER_LSA_SHORTCUT(rlsa
)
6146 vty_out(vty
, " LS Type: %s\n",
6147 lookup_msg(ospf_lsa_type_msg
, lsa
->data
->type
, NULL
));
6148 vty_out(vty
, " Link State ID: %pI4 %s\n",
6150 lookup_msg(ospf_link_state_id_type_msg
, lsa
->data
->type
,
6152 vty_out(vty
, " Advertising Router: %pI4\n",
6153 &lsa
->data
->adv_router
);
6154 vty_out(vty
, " LS Seq Number: %08lx\n",
6155 (unsigned long)ntohl(lsa
->data
->ls_seqnum
));
6156 vty_out(vty
, " Checksum: 0x%04x\n",
6157 ntohs(lsa
->data
->checksum
));
6158 vty_out(vty
, " Length: %d\n\n", ntohs(lsa
->data
->length
));
6163 snprintf(seqnum
, 10, "%x", ntohl(lsa
->data
->ls_seqnum
));
6164 snprintf(checksum
, 10, "%x", ntohs(lsa
->data
->checksum
));
6166 json_object_int_add(json
, "lsaAge", LS_AGE(lsa
));
6167 json_object_string_add(json
, "options",
6168 ospf_options_dump(lsa
->data
->options
));
6169 json_object_int_add(json
, "lsaFlags", lsa
->flags
);
6171 if (lsa
->flags
& OSPF_LSA_LOCAL_XLT
)
6172 json_object_boolean_true_add(json
,
6173 "translatedFromType7");
6175 if (lsa
->data
->type
== OSPF_ROUTER_LSA
) {
6176 json_object_int_add(json
, "flags", rlsa
->flags
);
6179 if (IS_ROUTER_LSA_BORDER(rlsa
))
6180 json_object_boolean_true_add(json
,
6182 if (IS_ROUTER_LSA_EXTERNAL(rlsa
))
6183 json_object_boolean_true_add(json
,
6185 if (IS_ROUTER_LSA_VIRTUAL(rlsa
))
6186 json_object_boolean_true_add(
6187 json
, "vlEndpoint");
6188 if (IS_ROUTER_LSA_SHORTCUT(rlsa
))
6189 json_object_boolean_true_add(
6194 json_object_string_add(
6196 lookup_msg(ospf_lsa_type_msg
, lsa
->data
->type
, NULL
));
6197 json_object_string_addf(json
, "linkStateId", "%pI4",
6199 json_object_string_addf(json
, "advertisingRouter", "%pI4",
6200 &lsa
->data
->adv_router
);
6201 json_object_string_add(json
, "lsaSeqNumber", seqnum
);
6202 json_object_string_add(json
, "checksum", checksum
);
6203 json_object_int_add(json
, "length", ntohs(lsa
->data
->length
));
6207 static const char *const link_type_desc
[] = {
6209 "another Router (point-to-point)",
6210 "a Transit Network",
6215 static const char *const link_id_desc
[] = {
6216 "(null)", "Neighboring Router ID", "Designated Router address",
6217 "Net", "Neighboring Router ID",
6220 static const char *const link_data_desc
[] = {
6221 "(null)", "Router Interface address", "Router Interface address",
6222 "Network Mask", "Router Interface address",
6225 static const char *const link_id_desc_json
[] = {
6226 "null", "neighborRouterId", "designatedRouterAddress",
6227 "networkAddress", "neighborRouterId",
6230 static const char *const link_data_desc_json
[] = {
6231 "null", "routerInterfaceAddress", "routerInterfaceAddress",
6232 "networkMask", "routerInterfaceAddress",
6235 /* Show router-LSA each Link information. */
6236 static void show_ip_ospf_database_router_links(struct vty
*vty
,
6237 struct router_lsa
*rl
,
6242 json_object
*json_links
= NULL
;
6243 json_object
*json_link
= NULL
;
6245 char buf
[PREFIX_STRLEN
];
6248 json_links
= json_object_new_object();
6250 len
= ntohs(rl
->header
.length
) - 4;
6251 for (i
= 0; i
< ntohs(rl
->links
) && len
> 0; len
-= 12, i
++) {
6252 type
= rl
->link
[i
].type
;
6257 snprintf(link
, sizeof(link
), "link%u", i
);
6258 json_link
= json_object_new_object();
6259 json_object_string_add(json_link
, "linkType",
6260 link_type_desc
[type
]);
6261 json_object_string_add(json_link
,
6262 link_id_desc_json
[type
],
6264 &rl
->link
[i
].link_id
,
6266 json_object_string_add(
6267 json_link
, link_data_desc_json
[type
],
6268 inet_ntop(AF_INET
, &rl
->link
[i
].link_data
,
6270 json_object_int_add(json_link
, "numOfTosMetrics",
6272 json_object_int_add(json_link
, "tos0Metric",
6273 ntohs(rl
->link
[i
].metric
));
6274 json_object_object_add(json_links
, link
, json_link
);
6276 vty_out(vty
, " Link connected to: %s\n",
6277 link_type_desc
[type
]);
6278 vty_out(vty
, " (Link ID) %s: %pI4\n",
6280 &rl
->link
[i
].link_id
);
6281 vty_out(vty
, " (Link Data) %s: %pI4\n",
6282 link_data_desc
[type
],
6283 &rl
->link
[i
].link_data
);
6284 vty_out(vty
, " Number of TOS metrics: 0\n");
6285 vty_out(vty
, " TOS 0 Metric: %d\n",
6286 ntohs(rl
->link
[i
].metric
));
6291 json_object_object_add(json
, "routerLinks", json_links
);
6294 /* Show router-LSA detail information. */
6295 static int show_router_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
,
6299 struct router_lsa
*rl
= (struct router_lsa
*)lsa
->data
;
6301 show_ip_ospf_database_header(vty
, lsa
, json
);
6304 vty_out(vty
, " Number of Links: %d\n\n",
6307 json_object_int_add(json
, "numOfLinks",
6310 show_ip_ospf_database_router_links(vty
, rl
, json
);
6319 /* Show network-LSA detail information. */
6320 static int show_network_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
,
6324 char buf
[PREFIX_STRLEN
];
6325 json_object
*json_attached_rt
= NULL
;
6326 json_object
*json_router
= NULL
;
6329 json_attached_rt
= json_object_new_object();
6332 struct network_lsa
*nl
= (struct network_lsa
*)lsa
->data
;
6333 struct in_addr
*addr
;
6335 show_ip_ospf_database_header(vty
, lsa
, json
);
6338 vty_out(vty
, " Network Mask: /%d\n",
6339 ip_masklen(nl
->mask
));
6341 json_object_int_add(json
, "networkMask",
6342 ip_masklen(nl
->mask
));
6344 length
= lsa
->size
- OSPF_LSA_HEADER_SIZE
- 4;
6345 addr
= &nl
->routers
[0];
6346 for (i
= 0; length
> 0 && addr
;
6347 length
-= 4, addr
= &nl
->routers
[++i
])
6349 vty_out(vty
, " Attached Router: %pI4\n",
6353 json_router
= json_object_new_object();
6354 json_object_string_add(
6355 json_router
, "attachedRouterId",
6356 inet_ntop(AF_INET
, addr
, buf
,
6358 json_object_object_add(json_attached_rt
,
6359 inet_ntop(AF_INET
, addr
,
6367 json_object_object_add(json
, "attchedRouters",
6373 /* Show summary-LSA detail information. */
6374 static int show_summary_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
,
6378 struct summary_lsa
*sl
= (struct summary_lsa
*)lsa
->data
;
6380 show_ip_ospf_database_header(vty
, lsa
, json
);
6383 vty_out(vty
, " Network Mask: /%d\n",
6384 ip_masklen(sl
->mask
));
6385 vty_out(vty
, " TOS: 0 Metric: %d\n",
6386 GET_METRIC(sl
->metric
));
6389 json_object_int_add(json
, "networkMask",
6390 ip_masklen(sl
->mask
));
6391 json_object_int_add(json
, "tos0Metric",
6392 GET_METRIC(sl
->metric
));
6399 /* Show summary-ASBR-LSA detail information. */
6400 static int show_summary_asbr_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
,
6404 struct summary_lsa
*sl
= (struct summary_lsa
*)lsa
->data
;
6406 show_ip_ospf_database_header(vty
, lsa
, json
);
6409 vty_out(vty
, " Network Mask: /%d\n",
6410 ip_masklen(sl
->mask
));
6411 vty_out(vty
, " TOS: 0 Metric: %d\n",
6412 GET_METRIC(sl
->metric
));
6415 json_object_int_add(json
, "networkMask",
6416 ip_masklen(sl
->mask
));
6417 json_object_int_add(json
, "tos0Metric",
6418 GET_METRIC(sl
->metric
));
6425 /* Show AS-external-LSA detail information. */
6426 static int show_as_external_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
,
6432 struct as_external_lsa
*al
=
6433 (struct as_external_lsa
*)lsa
->data
;
6435 show_ip_ospf_database_header(vty
, lsa
, json
);
6438 vty_out(vty
, " Network Mask: /%d\n",
6439 ip_masklen(al
->mask
));
6440 vty_out(vty
, " Metric Type: %s\n",
6441 IS_EXTERNAL_METRIC(al
->e
[0].tos
)
6442 ? "2 (Larger than any link state path)"
6444 vty_out(vty
, " TOS: 0\n");
6445 vty_out(vty
, " Metric: %d\n",
6446 GET_METRIC(al
->e
[0].metric
));
6447 vty_out(vty
, " Forward Address: %pI4\n",
6448 &al
->e
[0].fwd_addr
);
6450 " External Route Tag: %" ROUTE_TAG_PRI
"\n\n",
6451 (route_tag_t
)ntohl(al
->e
[0].route_tag
));
6453 json_object_int_add(json
, "networkMask",
6454 ip_masklen(al
->mask
));
6455 json_object_string_add(
6457 IS_EXTERNAL_METRIC(al
->e
[0].tos
)
6458 ? "E2 (Larger than any link state path)"
6460 json_object_int_add(json
, "tos", tos
);
6461 json_object_int_add(json
, "metric",
6462 GET_METRIC(al
->e
[0].metric
));
6463 json_object_string_addf(json
, "forwardAddress", "%pI4",
6464 &(al
->e
[0].fwd_addr
));
6465 json_object_int_add(
6466 json
, "externalRouteTag",
6467 (route_tag_t
)ntohl(al
->e
[0].route_tag
));
6474 /* Show AS-NSSA-LSA detail information. */
6475 static int show_as_nssa_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
,
6481 struct as_external_lsa
*al
=
6482 (struct as_external_lsa
*)lsa
->data
;
6484 show_ip_ospf_database_header(vty
, lsa
, json
);
6487 vty_out(vty
, " Network Mask: /%d\n",
6488 ip_masklen(al
->mask
));
6489 vty_out(vty
, " Metric Type: %s\n",
6490 IS_EXTERNAL_METRIC(al
->e
[0].tos
)
6491 ? "2 (Larger than any link state path)"
6493 vty_out(vty
, " TOS: 0\n");
6494 vty_out(vty
, " Metric: %d\n",
6495 GET_METRIC(al
->e
[0].metric
));
6496 vty_out(vty
, " NSSA: Forward Address: %pI4\n",
6497 &al
->e
[0].fwd_addr
);
6499 " External Route Tag: %" ROUTE_TAG_PRI
6501 (route_tag_t
)ntohl(al
->e
[0].route_tag
));
6503 json_object_int_add(json
, "networkMask",
6504 ip_masklen(al
->mask
));
6505 json_object_string_add(
6507 IS_EXTERNAL_METRIC(al
->e
[0].tos
)
6508 ? "E2 (Larger than any link state path)"
6510 json_object_int_add(json
, "tos", tos
);
6511 json_object_int_add(json
, "metric",
6512 GET_METRIC(al
->e
[0].metric
));
6513 json_object_string_addf(json
, "nssaForwardAddress",
6514 "%pI4", &al
->e
[0].fwd_addr
);
6515 json_object_int_add(
6516 json
, "externalRouteTag",
6517 (route_tag_t
)ntohl(al
->e
[0].route_tag
));
6524 static int show_func_dummy(struct vty
*vty
, struct ospf_lsa
*lsa
,
6530 static int show_opaque_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
,
6534 show_ip_ospf_database_header(vty
, lsa
, json
);
6535 show_opaque_info_detail(vty
, lsa
, json
);
6542 int (*show_function
[])(struct vty
*, struct ospf_lsa
*, json_object
*) = {
6544 show_router_lsa_detail
,
6545 show_network_lsa_detail
,
6546 show_summary_lsa_detail
,
6547 show_summary_asbr_lsa_detail
,
6548 show_as_external_lsa_detail
,
6550 show_as_nssa_lsa_detail
, /* almost same as external */
6552 show_opaque_lsa_detail
,
6553 show_opaque_lsa_detail
,
6554 show_opaque_lsa_detail
,
6557 static void show_lsa_prefix_set(struct vty
*vty
, struct prefix_ls
*lp
,
6558 struct in_addr
*id
, struct in_addr
*adv_router
)
6560 memset(lp
, 0, sizeof(struct prefix_ls
));
6561 lp
->family
= AF_UNSPEC
;
6564 else if (adv_router
== NULL
) {
6565 lp
->prefixlen
= IPV4_MAX_BITLEN
;
6570 lp
->adv_router
= *adv_router
;
6574 static void show_lsa_detail_proc(struct vty
*vty
, struct route_table
*rt
,
6575 struct in_addr
*id
, struct in_addr
*adv_router
,
6578 struct prefix_ls lp
;
6579 struct route_node
*rn
, *start
;
6580 struct ospf_lsa
*lsa
;
6581 json_object
*json_lsa
= NULL
;
6583 show_lsa_prefix_set(vty
, &lp
, id
, adv_router
);
6584 start
= route_node_get(rt
, (struct prefix
*)&lp
);
6586 route_lock_node(start
);
6587 for (rn
= start
; rn
; rn
= route_next_until(rn
, start
))
6588 if ((lsa
= rn
->info
)) {
6590 json_lsa
= json_object_new_object();
6591 json_object_array_add(json
, json_lsa
);
6594 if (show_function
[lsa
->data
->type
] != NULL
)
6595 show_function
[lsa
->data
->type
](
6596 vty
, lsa
, json_lsa
);
6598 route_unlock_node(start
);
6602 /* Show detail LSA information
6603 -- if id is NULL then show all LSAs. */
6604 static void show_lsa_detail(struct vty
*vty
, struct ospf
*ospf
, int type
,
6605 struct in_addr
*id
, struct in_addr
*adv_router
,
6608 struct listnode
*node
;
6609 struct ospf_area
*area
;
6610 char buf
[PREFIX_STRLEN
];
6611 json_object
*json_lsa_type
= NULL
;
6612 json_object
*json_areas
= NULL
;
6613 json_object
*json_lsa_array
= NULL
;
6616 json_lsa_type
= json_object_new_object();
6619 case OSPF_AS_EXTERNAL_LSA
:
6620 case OSPF_OPAQUE_AS_LSA
:
6622 vty_out(vty
, " %s \n\n",
6623 show_database_desc
[type
]);
6625 json_lsa_array
= json_object_new_array();
6627 show_lsa_detail_proc(vty
, AS_LSDB(ospf
, type
), id
, adv_router
,
6630 json_object_object_add(json
,
6631 show_database_desc_json
[type
],
6637 json_areas
= json_object_new_object();
6639 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
6642 "\n %s (Area %s)\n\n",
6643 show_database_desc
[type
],
6644 ospf_area_desc_string(area
));
6646 json_lsa_array
= json_object_new_array();
6647 json_object_object_add(json_areas
,
6655 show_lsa_detail_proc(vty
, AREA_LSDB(area
, type
), id
,
6656 adv_router
, json_lsa_array
);
6660 json_object_object_add(json_lsa_type
, "areas",
6662 json_object_object_add(json
,
6663 show_database_desc_json
[type
],
6670 static void show_lsa_detail_adv_router_proc(struct vty
*vty
,
6671 struct route_table
*rt
,
6672 struct in_addr
*adv_router
,
6675 char buf
[PREFIX_STRLEN
];
6676 struct route_node
*rn
;
6677 struct ospf_lsa
*lsa
;
6679 for (rn
= route_top(rt
); rn
; rn
= route_next(rn
))
6680 if ((lsa
= rn
->info
)) {
6681 json_object
*json_lsa
= NULL
;
6683 if (IPV4_ADDR_SAME(adv_router
,
6684 &lsa
->data
->adv_router
)) {
6685 if (CHECK_FLAG(lsa
->flags
, OSPF_LSA_LOCAL_XLT
))
6688 json_lsa
= json_object_new_object();
6690 if (show_function
[lsa
->data
->type
] != NULL
)
6691 show_function
[lsa
->data
->type
](
6692 vty
, lsa
, json_lsa
);
6694 json_object_object_add(
6704 /* Show detail LSA information. */
6705 static void show_lsa_detail_adv_router(struct vty
*vty
, struct ospf
*ospf
,
6706 int type
, struct in_addr
*adv_router
,
6709 struct listnode
*node
;
6710 struct ospf_area
*area
;
6711 char buf
[PREFIX_STRLEN
];
6712 json_object
*json_lstype
= NULL
;
6713 json_object
*json_area
= NULL
;
6716 json_lstype
= json_object_new_object();
6719 case OSPF_AS_EXTERNAL_LSA
:
6720 case OSPF_OPAQUE_AS_LSA
:
6722 vty_out(vty
, " %s \n\n",
6723 show_database_desc
[type
]);
6725 show_lsa_detail_adv_router_proc(vty
, AS_LSDB(ospf
, type
),
6726 adv_router
, json_lstype
);
6730 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
6732 json_area
= json_object_new_object();
6735 "\n %s (Area %s)\n\n",
6736 show_database_desc
[type
],
6737 ospf_area_desc_string(area
));
6738 show_lsa_detail_adv_router_proc(vty
,
6739 AREA_LSDB(area
, type
),
6740 adv_router
, json_area
);
6743 json_object_object_add(json_lstype
,
6754 json_object_object_add(json
, show_database_desc
[type
],
6758 void show_ip_ospf_database_summary(struct vty
*vty
, struct ospf
*ospf
, int self
,
6761 struct ospf_lsa
*lsa
;
6762 struct route_node
*rn
;
6763 struct ospf_area
*area
;
6764 struct listnode
*node
;
6765 char buf
[PREFIX_STRLEN
];
6766 json_object
*json_areas
= NULL
;
6767 json_object
*json_area
= NULL
;
6768 json_object
*json_lsa
= NULL
;
6770 json_object
*json_lsa_array
= NULL
;
6774 json_areas
= json_object_new_object();
6776 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
6778 json_area
= json_object_new_object();
6780 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++) {
6783 case OSPF_AS_EXTERNAL_LSA
:
6784 case OSPF_OPAQUE_AS_LSA
:
6789 if (ospf_lsdb_count_self(area
->lsdb
, type
) > 0
6791 && ospf_lsdb_count(area
->lsdb
, type
) > 0)) {
6795 " %s (Area %s)\n\n",
6796 show_database_desc
[type
],
6797 ospf_area_desc_string(area
));
6798 vty_out(vty
, "%s\n",
6799 show_database_header
[type
]);
6802 json_object_new_array();
6803 json_object_object_add(
6805 show_database_desc_json
[type
],
6809 LSDB_LOOP (AREA_LSDB(area
, type
), rn
, lsa
) {
6812 json_object_new_object();
6813 json_object_array_add(
6818 count
+= show_lsa_summary(
6819 vty
, lsa
, self
, json_lsa
);
6825 json_object_int_add(
6828 show_database_desc_count_json
6834 json_object_object_add(json_areas
,
6842 json_object_object_add(json
, "areas", json_areas
);
6844 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++) {
6847 case OSPF_AS_EXTERNAL_LSA
:
6848 case OSPF_OPAQUE_AS_LSA
:
6853 if (ospf_lsdb_count_self(ospf
->lsdb
, type
)
6854 || (!self
&& ospf_lsdb_count(ospf
->lsdb
, type
))) {
6856 vty_out(vty
, " %s\n\n",
6857 show_database_desc
[type
]);
6858 vty_out(vty
, "%s\n",
6859 show_database_header
[type
]);
6861 json_lsa_array
= json_object_new_array();
6862 json_object_object_add(
6863 json
, show_database_desc_json
[type
],
6867 LSDB_LOOP (AS_LSDB(ospf
, type
), rn
, lsa
) {
6869 json_lsa
= json_object_new_object();
6870 json_object_array_add(json_lsa_array
,
6874 count
+= show_lsa_summary(vty
, lsa
, self
,
6881 json_object_int_add(
6883 show_database_desc_count_json
[type
],
6892 static void show_ip_ospf_database_maxage(struct vty
*vty
, struct ospf
*ospf
,
6895 struct route_node
*rn
;
6896 char buf
[PREFIX_STRLEN
];
6897 json_object
*json_maxage
= NULL
;
6900 vty_out(vty
, "\n MaxAge Link States:\n\n");
6902 json_maxage
= json_object_new_object();
6904 for (rn
= route_top(ospf
->maxage_lsa
); rn
; rn
= route_next(rn
)) {
6905 struct ospf_lsa
*lsa
;
6906 json_object
*json_lsa
= NULL
;
6908 if ((lsa
= rn
->info
) != NULL
) {
6910 vty_out(vty
, "Link type: %d\n",
6912 vty_out(vty
, "Link State ID: %pI4\n",
6914 vty_out(vty
, "Advertising Router: %pI4\n",
6915 &lsa
->data
->adv_router
);
6916 vty_out(vty
, "LSA lock count: %d\n", lsa
->lock
);
6919 json_lsa
= json_object_new_object();
6920 json_object_int_add(json_lsa
, "linkType",
6922 json_object_string_addf(json_lsa
, "linkStateId",
6923 "%pI4", &lsa
->data
->id
);
6924 json_object_string_addf(
6925 json_lsa
, "advertisingRouter", "%pI4",
6926 &lsa
->data
->adv_router
);
6927 json_object_int_add(json_lsa
, "lsaLockCount",
6929 json_object_object_add(
6939 json_object_object_add(json
, "maxAgeLinkStates", json_maxage
);
6942 #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
6943 #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
6945 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
6946 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
6947 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
6948 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
6950 #define OSPF_LSA_TYPES_DESC \
6951 "ASBR summary link states\n" \
6952 "External link states\n" \
6953 "Network link states\n" \
6954 "Router link states\n" \
6955 "Network summary link states\n" OSPF_LSA_TYPE_NSSA_DESC \
6956 OSPF_LSA_TYPE_OPAQUE_LINK_DESC OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
6957 OSPF_LSA_TYPE_OPAQUE_AS_DESC
6959 static int show_ip_ospf_database_common(struct vty
*vty
, struct ospf
*ospf
,
6960 int arg_base
, int argc
,
6961 struct cmd_token
**argv
,
6962 uint8_t use_vrf
, json_object
*json
,
6967 struct in_addr id
, adv_router
;
6968 json_object
*json_vrf
= NULL
;
6972 json_vrf
= json_object_new_object();
6977 if (ospf
->instance
) {
6979 json_object_int_add(json_vrf
, "ospfInstance",
6982 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
6985 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
6987 /* Show Router ID. */
6989 json_object_string_addf(json_vrf
, "routerId", "%pI4",
6992 vty_out(vty
, "\n OSPF Router with ID (%pI4)\n\n",
6997 if ((argc
== arg_base
+ 4) || (uj
&& (argc
== arg_base
+ 5))) {
6998 show_ip_ospf_database_summary(vty
, ospf
, 0, json_vrf
);
7001 json_object_object_add(
7002 json
, ospf_get_name(ospf
), json_vrf
);
7007 /* Set database type to show. */
7008 if (strncmp(argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
7009 type
= OSPF_ROUTER_LSA
;
7010 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
7011 type
= OSPF_NETWORK_LSA
;
7012 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
7013 type
= OSPF_AS_NSSA_LSA
;
7014 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "su", 2) == 0)
7015 type
= OSPF_SUMMARY_LSA
;
7016 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
7017 type
= OSPF_ASBR_SUMMARY_LSA
;
7018 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
7019 type
= OSPF_AS_EXTERNAL_LSA
;
7020 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "se", 2) == 0) {
7021 show_ip_ospf_database_summary(vty
, ospf
, 1, json_vrf
);
7024 json_object_object_add(
7025 json
, ospf_get_name(ospf
), json_vrf
);
7028 } else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "m", 1) == 0) {
7029 show_ip_ospf_database_maxage(vty
, ospf
, json_vrf
);
7032 json_object_object_add(
7033 json
, ospf_get_name(ospf
), json_vrf
);
7036 } else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
7037 type
= OSPF_OPAQUE_LINK_LSA
;
7038 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
7039 type
= OSPF_OPAQUE_AREA_LSA
;
7040 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
7041 type
= OSPF_OPAQUE_AS_LSA
;
7045 /* `show ip ospf database LSA'. */
7046 if ((argc
== arg_base
+ 5) || (uj
&& (argc
== arg_base
+ 6)))
7047 show_lsa_detail(vty
, ospf
, type
, NULL
, NULL
, json_vrf
);
7048 else if (argc
>= arg_base
+ 6) {
7049 ret
= inet_aton(argv
[arg_base
+ 5]->arg
, &id
);
7053 /* `show ip ospf database LSA ID'. */
7054 if ((argc
== arg_base
+ 6) || (uj
&& (argc
== arg_base
+ 7)))
7055 show_lsa_detail(vty
, ospf
, type
, &id
, NULL
, json_vrf
);
7056 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
7057 else if ((argc
== arg_base
+ 7)
7058 || (uj
&& (argc
== arg_base
+ 8))) {
7059 if (strncmp(argv
[arg_base
+ 6]->text
, "s", 1) == 0)
7060 adv_router
= ospf
->router_id
;
7062 ret
= inet_aton(argv
[arg_base
+ 7]->arg
,
7067 show_lsa_detail(vty
, ospf
, type
, &id
, &adv_router
,
7074 json_object_object_add(json
, ospf_get_name(ospf
),
7081 DEFUN (show_ip_ospf_database_max
,
7082 show_ip_ospf_database_max_cmd
,
7083 "show ip ospf [vrf <NAME|all>] database <max-age|self-originate> [json]",
7086 "OSPF information\n"
7089 "Database summary\n"
7090 "LSAs in MaxAge list\n"
7091 "Self-originated link states\n"
7094 struct ospf
*ospf
= NULL
;
7095 struct listnode
*node
= NULL
;
7096 char *vrf_name
= NULL
;
7097 bool all_vrf
= false;
7098 int ret
= CMD_SUCCESS
;
7101 uint8_t use_vrf
= 0;
7102 bool uj
= use_json(argc
, argv
);
7103 json_object
*json
= NULL
;
7106 json
= json_object_new_object();
7108 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
7111 bool ospf_output
= false;
7116 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
7117 if (!ospf
->oi_running
)
7120 ret
= show_ip_ospf_database_common(
7121 vty
, ospf
, idx_vrf
? 2 : 0, argc
, argv
,
7126 vty_out(vty
, "%% OSPF instance not found\n");
7128 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
7129 if (ospf
== NULL
|| !ospf
->oi_running
) {
7130 vty_out(vty
, "%% OSPF instance not found\n");
7133 ret
= (show_ip_ospf_database_common(
7134 vty
, ospf
, idx_vrf
? 2 : 0, argc
, argv
, use_vrf
,
7138 /* Display default ospf (instance 0) info */
7139 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
7140 if (ospf
== NULL
|| !ospf
->oi_running
) {
7141 vty_out(vty
, "%% OSPF instance not found\n");
7145 ret
= show_ip_ospf_database_common(vty
, ospf
, 0, argc
, argv
,
7150 vty_out(vty
, "%s\n", json_object_to_json_string(json
));
7151 json_object_free(json
);
7157 ALIAS (show_ip_ospf_database_max
,
7158 show_ip_ospf_database_cmd
,
7159 "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]",
7162 "OSPF information\n"
7165 "Database summary\n"
7167 "Link State ID (as an IP address)\n"
7168 "Self-originated link states\n"
7169 "Advertising Router link states\n"
7170 "Advertising Router (as an IP address)\n"
7173 DEFUN (show_ip_ospf_instance_database_max
,
7174 show_ip_ospf_instance_database_max_cmd
,
7175 "show ip ospf (1-65535) database <max-age|self-originate> [json]",
7178 "OSPF information\n"
7180 "Database summary\n"
7181 "LSAs in MaxAge list\n"
7182 "Self-originated link states\n"
7187 unsigned short instance
= 0;
7188 bool uj
= use_json(argc
, argv
);
7189 json_object
*json
= NULL
;
7192 json
= json_object_new_object();
7194 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7195 if (instance
!= ospf_instance
)
7196 return CMD_NOT_MY_INSTANCE
;
7198 ospf
= ospf_lookup_instance(instance
);
7199 if (!ospf
|| !ospf
->oi_running
)
7202 show_ip_ospf_database_common(vty
, ospf
, 1, argc
, argv
, 0, json
, uj
);
7205 vty_json(vty
, json
);
7210 ALIAS (show_ip_ospf_instance_database_max
,
7211 show_ip_ospf_instance_database_cmd
,
7212 "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]",
7215 "OSPF information\n"
7217 "Database summary\n"
7219 "Link State ID (as an IP address)\n"
7220 "Self-originated link states\n"
7221 "Advertising Router link states\n"
7222 "Advertising Router (as an IP address)\n"
7225 static int show_ip_ospf_database_type_adv_router_common(struct vty
*vty
,
7227 int arg_base
, int argc
,
7228 struct cmd_token
**argv
,
7235 struct in_addr adv_router
;
7236 json_object
*json_vrf
= NULL
;
7240 json_vrf
= json_object_new_object();
7245 if (ospf
->instance
) {
7247 json_object_int_add(json
, "ospfInstance",
7250 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
7253 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
7255 /* Show Router ID. */
7257 json_object_string_addf(json_vrf
, "routerId", "%pI4",
7260 vty_out(vty
, "\n OSPF Router with ID (%pI4)\n\n",
7264 /* Set database type to show. */
7265 if (strncmp(argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
7266 type
= OSPF_ROUTER_LSA
;
7267 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
7268 type
= OSPF_NETWORK_LSA
;
7269 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
7270 type
= OSPF_AS_NSSA_LSA
;
7271 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "s", 1) == 0)
7272 type
= OSPF_SUMMARY_LSA
;
7273 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
7274 type
= OSPF_ASBR_SUMMARY_LSA
;
7275 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
7276 type
= OSPF_AS_EXTERNAL_LSA
;
7277 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
7278 type
= OSPF_OPAQUE_LINK_LSA
;
7279 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
7280 type
= OSPF_OPAQUE_AREA_LSA
;
7281 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
7282 type
= OSPF_OPAQUE_AS_LSA
;
7286 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
7287 if (strncmp(argv
[arg_base
+ 5]->text
, "s", 1) == 0)
7288 adv_router
= ospf
->router_id
;
7290 ret
= inet_aton(argv
[arg_base
+ 6]->arg
, &adv_router
);
7295 show_lsa_detail_adv_router(vty
, ospf
, type
, &adv_router
, json_vrf
);
7299 json_object_object_add(json
, ospf_get_name(ospf
),
7306 DEFUN (show_ip_ospf_database_type_adv_router
,
7307 show_ip_ospf_database_type_adv_router_cmd
,
7308 "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]",
7311 "OSPF information\n"
7314 "Database summary\n"
7316 "Advertising Router link states\n"
7317 "Advertising Router (as an IP address)\n"
7318 "Self-originated link states\n"
7321 struct ospf
*ospf
= NULL
;
7322 struct listnode
*node
= NULL
;
7323 char *vrf_name
= NULL
;
7324 bool all_vrf
= false;
7325 int ret
= CMD_SUCCESS
;
7328 uint8_t use_vrf
= 0;
7329 bool uj
= use_json(argc
, argv
);
7330 json_object
*json
= NULL
;
7333 json
= json_object_new_object();
7335 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
7338 bool ospf_output
= false;
7343 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
7344 if (!ospf
->oi_running
)
7347 ret
= show_ip_ospf_database_type_adv_router_common(
7348 vty
, ospf
, 2, argc
, argv
, use_vrf
, json
,
7352 vty_out(vty
, "%% OSPF instance not found\n");
7354 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
7355 if ((ospf
== NULL
) || !ospf
->oi_running
) {
7356 vty_out(vty
, "%% OSPF instance not found\n");
7360 ret
= show_ip_ospf_database_type_adv_router_common(
7361 vty
, ospf
, 2, argc
, argv
, use_vrf
, json
, uj
);
7364 /* Display default ospf (instance 0) info */
7365 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
7366 if (ospf
== NULL
|| !ospf
->oi_running
) {
7367 vty_out(vty
, "%% OSPF instance not found\n");
7371 ret
= show_ip_ospf_database_type_adv_router_common(
7372 vty
, ospf
, 0, argc
, argv
, use_vrf
, json
, uj
);
7376 vty_out(vty
, "%s\n", json_object_to_json_string(json
));
7377 json_object_free(json
);
7383 DEFUN (show_ip_ospf_instance_database_type_adv_router
,
7384 show_ip_ospf_instance_database_type_adv_router_cmd
,
7385 "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]",
7388 "OSPF information\n"
7390 "Database summary\n"
7392 "Advertising Router link states\n"
7393 "Advertising Router (as an IP address)\n"
7394 "Self-originated link states\n"
7399 unsigned short instance
= 0;
7400 bool uj
= use_json(argc
, argv
);
7401 json_object
*json
= NULL
;
7404 json
= json_object_new_object();
7406 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7407 if (instance
!= ospf_instance
)
7408 return CMD_NOT_MY_INSTANCE
;
7410 ospf
= ospf_lookup_instance(instance
);
7411 if (!ospf
|| !ospf
->oi_running
)
7414 show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 1, argc
, argv
,
7418 vty_json(vty
, json
);
7423 DEFUN (ip_ospf_authentication_args
,
7424 ip_ospf_authentication_args_addr_cmd
,
7425 "ip ospf authentication <null|message-digest> [A.B.C.D]",
7427 "OSPF interface commands\n"
7428 "Enable authentication on this interface\n"
7429 "Use null authentication\n"
7430 "Use message-digest authentication\n"
7431 "Address of interface\n")
7433 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7434 int idx_encryption
= 3;
7436 struct in_addr addr
;
7438 struct ospf_if_params
*params
;
7440 params
= IF_DEF_PARAMS(ifp
);
7443 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7446 "Please specify interface address by A.B.C.D\n");
7447 return CMD_WARNING_CONFIG_FAILED
;
7450 params
= ospf_get_if_params(ifp
, addr
);
7451 ospf_if_update_params(ifp
, addr
);
7454 /* Handle null authentication */
7455 if (argv
[idx_encryption
]->arg
[0] == 'n') {
7456 SET_IF_PARAM(params
, auth_type
);
7457 params
->auth_type
= OSPF_AUTH_NULL
;
7461 /* Handle message-digest authentication */
7462 if (argv
[idx_encryption
]->arg
[0] == 'm') {
7463 SET_IF_PARAM(params
, auth_type
);
7464 params
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
7468 vty_out(vty
, "You shouldn't get here!\n");
7469 return CMD_WARNING_CONFIG_FAILED
;
7472 DEFUN (ip_ospf_authentication
,
7473 ip_ospf_authentication_addr_cmd
,
7474 "ip ospf authentication [A.B.C.D]",
7476 "OSPF interface commands\n"
7477 "Enable authentication on this interface\n"
7478 "Address of interface\n")
7480 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7482 struct in_addr addr
;
7484 struct ospf_if_params
*params
;
7486 params
= IF_DEF_PARAMS(ifp
);
7489 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7492 "Please specify interface address by A.B.C.D\n");
7493 return CMD_WARNING_CONFIG_FAILED
;
7496 params
= ospf_get_if_params(ifp
, addr
);
7497 ospf_if_update_params(ifp
, addr
);
7500 SET_IF_PARAM(params
, auth_type
);
7501 params
->auth_type
= OSPF_AUTH_SIMPLE
;
7506 DEFUN (no_ip_ospf_authentication_args
,
7507 no_ip_ospf_authentication_args_addr_cmd
,
7508 "no ip ospf authentication <null|message-digest> [A.B.C.D]",
7511 "OSPF interface commands\n"
7512 "Enable authentication on this interface\n"
7513 "Use null authentication\n"
7514 "Use message-digest authentication\n"
7515 "Address of interface\n")
7517 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7518 int idx_encryption
= 4;
7520 struct in_addr addr
;
7522 struct ospf_if_params
*params
;
7523 struct route_node
*rn
;
7526 params
= IF_DEF_PARAMS(ifp
);
7529 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7532 "Please specify interface address by A.B.C.D\n");
7533 return CMD_WARNING_CONFIG_FAILED
;
7536 params
= ospf_lookup_if_params(ifp
, addr
);
7537 if (params
== NULL
) {
7538 vty_out(vty
, "Ip Address specified is unknown\n");
7539 return CMD_WARNING_CONFIG_FAILED
;
7541 params
->auth_type
= OSPF_AUTH_NOTSET
;
7542 UNSET_IF_PARAM(params
, auth_type
);
7543 if (params
!= IF_DEF_PARAMS(ifp
)) {
7544 ospf_free_if_params(ifp
, addr
);
7545 ospf_if_update_params(ifp
, addr
);
7548 if (argv
[idx_encryption
]->arg
[0] == 'n') {
7549 auth_type
= OSPF_AUTH_NULL
;
7550 } else if (argv
[idx_encryption
]->arg
[0] == 'm') {
7551 auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
7553 vty_out(vty
, "Unexpected input encountered\n");
7554 return CMD_WARNING_CONFIG_FAILED
;
7557 * Here we have a case where the user has entered
7558 * 'no ip ospf authentication (null | message_digest )'
7559 * we need to find if we have any ip addresses underneath it
7561 * correspond to the associated type.
7563 if (params
->auth_type
== auth_type
) {
7564 params
->auth_type
= OSPF_AUTH_NOTSET
;
7565 UNSET_IF_PARAM(params
, auth_type
);
7568 for (rn
= route_top(IF_OIFS_PARAMS(ifp
)); rn
;
7569 rn
= route_next(rn
)) {
7570 if ((params
= rn
->info
)) {
7571 if (params
->auth_type
== auth_type
) {
7572 params
->auth_type
= OSPF_AUTH_NOTSET
;
7573 UNSET_IF_PARAM(params
, auth_type
);
7574 if (params
!= IF_DEF_PARAMS(ifp
)) {
7575 ospf_free_if_params(
7576 ifp
, rn
->p
.u
.prefix4
);
7577 ospf_if_update_params(
7578 ifp
, rn
->p
.u
.prefix4
);
7588 DEFUN (no_ip_ospf_authentication
,
7589 no_ip_ospf_authentication_addr_cmd
,
7590 "no ip ospf authentication [A.B.C.D]",
7593 "OSPF interface commands\n"
7594 "Enable authentication on this interface\n"
7595 "Address of interface\n")
7597 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7599 struct in_addr addr
;
7601 struct ospf_if_params
*params
;
7602 struct route_node
*rn
;
7604 params
= IF_DEF_PARAMS(ifp
);
7607 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7610 "Please specify interface address by A.B.C.D\n");
7611 return CMD_WARNING_CONFIG_FAILED
;
7614 params
= ospf_lookup_if_params(ifp
, addr
);
7615 if (params
== NULL
) {
7616 vty_out(vty
, "Ip Address specified is unknown\n");
7617 return CMD_WARNING_CONFIG_FAILED
;
7620 params
->auth_type
= OSPF_AUTH_NOTSET
;
7621 UNSET_IF_PARAM(params
, auth_type
);
7622 if (params
!= IF_DEF_PARAMS(ifp
)) {
7623 ospf_free_if_params(ifp
, addr
);
7624 ospf_if_update_params(ifp
, addr
);
7628 * When a user enters 'no ip ospf authentication'
7629 * We should remove all authentication types from
7632 if ((params
->auth_type
== OSPF_AUTH_NULL
)
7633 || (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
7634 || (params
->auth_type
== OSPF_AUTH_SIMPLE
)) {
7635 params
->auth_type
= OSPF_AUTH_NOTSET
;
7636 UNSET_IF_PARAM(params
, auth_type
);
7639 for (rn
= route_top(IF_OIFS_PARAMS(ifp
)); rn
;
7640 rn
= route_next(rn
)) {
7641 if ((params
= rn
->info
)) {
7643 if ((params
->auth_type
== OSPF_AUTH_NULL
)
7644 || (params
->auth_type
7645 == OSPF_AUTH_CRYPTOGRAPHIC
)
7646 || (params
->auth_type
7647 == OSPF_AUTH_SIMPLE
)) {
7648 params
->auth_type
= OSPF_AUTH_NOTSET
;
7649 UNSET_IF_PARAM(params
, auth_type
);
7650 if (params
!= IF_DEF_PARAMS(ifp
)) {
7651 ospf_free_if_params(
7652 ifp
, rn
->p
.u
.prefix4
);
7653 ospf_if_update_params(
7654 ifp
, rn
->p
.u
.prefix4
);
7665 DEFUN (ip_ospf_authentication_key
,
7666 ip_ospf_authentication_key_addr_cmd
,
7667 "ip ospf authentication-key AUTH_KEY [A.B.C.D]",
7669 "OSPF interface commands\n"
7670 "Authentication password (key)\n"
7671 "The OSPF password (key)\n"
7672 "Address of interface\n")
7674 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7676 struct in_addr addr
;
7677 struct ospf_if_params
*params
;
7679 params
= IF_DEF_PARAMS(ifp
);
7681 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7682 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7684 "Please specify interface address by A.B.C.D\n");
7685 return CMD_WARNING_CONFIG_FAILED
;
7688 params
= ospf_get_if_params(ifp
, addr
);
7689 ospf_if_update_params(ifp
, addr
);
7692 strlcpy((char *)params
->auth_simple
, argv
[3]->arg
,
7693 sizeof(params
->auth_simple
));
7694 SET_IF_PARAM(params
, auth_simple
);
7699 DEFUN_HIDDEN (ospf_authentication_key
,
7700 ospf_authentication_key_cmd
,
7701 "ospf authentication-key AUTH_KEY [A.B.C.D]",
7702 "OSPF interface commands\n"
7703 VLINK_HELPSTR_AUTH_SIMPLE
7704 "Address of interface\n")
7706 return ip_ospf_authentication_key(self
, vty
, argc
, argv
);
7709 DEFUN (no_ip_ospf_authentication_key
,
7710 no_ip_ospf_authentication_key_authkey_addr_cmd
,
7711 "no ip ospf authentication-key [AUTH_KEY [A.B.C.D]]",
7714 "OSPF interface commands\n"
7715 VLINK_HELPSTR_AUTH_SIMPLE
7716 "Address of interface\n")
7718 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7720 struct in_addr addr
;
7721 struct ospf_if_params
*params
;
7722 params
= IF_DEF_PARAMS(ifp
);
7724 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7725 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7727 "Please specify interface address by A.B.C.D\n");
7728 return CMD_WARNING_CONFIG_FAILED
;
7731 params
= ospf_lookup_if_params(ifp
, addr
);
7736 memset(params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
);
7737 UNSET_IF_PARAM(params
, auth_simple
);
7739 if (params
!= IF_DEF_PARAMS(ifp
)) {
7740 ospf_free_if_params(ifp
, addr
);
7741 ospf_if_update_params(ifp
, addr
);
7747 DEFUN_HIDDEN (no_ospf_authentication_key
,
7748 no_ospf_authentication_key_authkey_addr_cmd
,
7749 "no ospf authentication-key [AUTH_KEY [A.B.C.D]]",
7751 "OSPF interface commands\n"
7752 VLINK_HELPSTR_AUTH_SIMPLE
7753 "Address of interface\n")
7755 return no_ip_ospf_authentication_key(self
, vty
, argc
, argv
);
7758 DEFUN (ip_ospf_message_digest_key
,
7759 ip_ospf_message_digest_key_cmd
,
7760 "ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
7762 "OSPF interface commands\n"
7763 "Message digest authentication password (key)\n"
7765 "Use MD5 algorithm\n"
7766 "The OSPF password (key)\n"
7767 "Address of interface\n")
7769 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7770 struct crypt_key
*ck
;
7772 struct in_addr addr
;
7773 struct ospf_if_params
*params
;
7775 params
= IF_DEF_PARAMS(ifp
);
7778 argv_find(argv
, argc
, "(1-255)", &idx
);
7779 char *keyid
= argv
[idx
]->arg
;
7780 argv_find(argv
, argc
, "KEY", &idx
);
7781 char *cryptkey
= argv
[idx
]->arg
;
7783 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7784 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7786 "Please specify interface address by A.B.C.D\n");
7787 return CMD_WARNING_CONFIG_FAILED
;
7790 params
= ospf_get_if_params(ifp
, addr
);
7791 ospf_if_update_params(ifp
, addr
);
7794 key_id
= strtol(keyid
, NULL
, 10);
7796 /* Remove existing key, if any */
7797 ospf_crypt_key_delete(params
->auth_crypt
, key_id
);
7799 ck
= ospf_crypt_key_new();
7800 ck
->key_id
= (uint8_t)key_id
;
7801 strlcpy((char *)ck
->auth_key
, cryptkey
, sizeof(ck
->auth_key
));
7803 ospf_crypt_key_add(params
->auth_crypt
, ck
);
7804 SET_IF_PARAM(params
, auth_crypt
);
7809 DEFUN_HIDDEN (ospf_message_digest_key
,
7810 ospf_message_digest_key_cmd
,
7811 "ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
7812 "OSPF interface commands\n"
7813 "Message digest authentication password (key)\n"
7815 "Use MD5 algorithm\n"
7816 "The OSPF password (key)\n"
7817 "Address of interface\n")
7819 return ip_ospf_message_digest_key(self
, vty
, argc
, argv
);
7822 DEFUN (no_ip_ospf_message_digest_key
,
7823 no_ip_ospf_message_digest_key_cmd
,
7824 "no ip ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
7827 "OSPF interface commands\n"
7828 "Message digest authentication password (key)\n"
7830 "Use MD5 algorithm\n"
7831 "The OSPF password (key)\n"
7832 "Address of interface\n")
7834 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7836 struct crypt_key
*ck
;
7838 struct in_addr addr
;
7839 struct ospf_if_params
*params
;
7840 params
= IF_DEF_PARAMS(ifp
);
7842 argv_find(argv
, argc
, "(1-255)", &idx
);
7843 char *keyid
= argv
[idx
]->arg
;
7845 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7846 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7848 "Please specify interface address by A.B.C.D\n");
7849 return CMD_WARNING_CONFIG_FAILED
;
7852 params
= ospf_lookup_if_params(ifp
, addr
);
7857 key_id
= strtol(keyid
, NULL
, 10);
7858 ck
= ospf_crypt_key_lookup(params
->auth_crypt
, key_id
);
7860 vty_out(vty
, "OSPF: Key %d does not exist\n", key_id
);
7861 return CMD_WARNING_CONFIG_FAILED
;
7864 ospf_crypt_key_delete(params
->auth_crypt
, key_id
);
7866 if (params
!= IF_DEF_PARAMS(ifp
)) {
7867 ospf_free_if_params(ifp
, addr
);
7868 ospf_if_update_params(ifp
, addr
);
7874 DEFUN_HIDDEN (no_ospf_message_digest_key
,
7875 no_ospf_message_digest_key_cmd
,
7876 "no ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
7878 "OSPF interface commands\n"
7879 "Message digest authentication password (key)\n"
7881 "Use MD5 algorithm\n"
7882 "The OSPF password (key)\n"
7883 "Address of interface\n")
7885 return no_ip_ospf_message_digest_key(self
, vty
, argc
, argv
);
7888 DEFUN (ip_ospf_cost
,
7890 "ip ospf cost (1-65535) [A.B.C.D]",
7892 "OSPF interface commands\n"
7895 "Address of interface\n")
7897 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7899 uint32_t cost
= OSPF_OUTPUT_COST_DEFAULT
;
7900 struct in_addr addr
;
7901 struct ospf_if_params
*params
;
7902 params
= IF_DEF_PARAMS(ifp
);
7905 char *coststr
= NULL
, *ifaddr
= NULL
;
7907 argv_find(argv
, argc
, "(1-65535)", &idx
);
7908 coststr
= argv
[idx
]->arg
;
7909 cost
= strtol(coststr
, NULL
, 10);
7911 ifaddr
= argv_find(argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
7913 if (!inet_aton(ifaddr
, &addr
)) {
7915 "Please specify interface address by A.B.C.D\n");
7916 return CMD_WARNING_CONFIG_FAILED
;
7919 params
= ospf_get_if_params(ifp
, addr
);
7920 ospf_if_update_params(ifp
, addr
);
7923 SET_IF_PARAM(params
, output_cost_cmd
);
7924 params
->output_cost_cmd
= cost
;
7926 ospf_if_recalculate_output_cost(ifp
);
7931 DEFUN_HIDDEN (ospf_cost
,
7933 "ospf cost (1-65535) [A.B.C.D]",
7934 "OSPF interface commands\n"
7937 "Address of interface\n")
7939 return ip_ospf_cost(self
, vty
, argc
, argv
);
7942 DEFUN (no_ip_ospf_cost
,
7943 no_ip_ospf_cost_cmd
,
7944 "no ip ospf cost [(1-65535)] [A.B.C.D]",
7947 "OSPF interface commands\n"
7950 "Address of interface\n")
7952 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7954 struct in_addr addr
;
7955 struct ospf_if_params
*params
;
7957 params
= IF_DEF_PARAMS(ifp
);
7960 char *ifaddr
= NULL
;
7961 ifaddr
= argv_find(argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
7963 /* According to the semantics we are mimicking "no ip ospf cost N" is
7964 * always treated as "no ip ospf cost" regardless of the actual value
7965 * of N already configured for the interface. Thus ignore cost. */
7968 if (!inet_aton(ifaddr
, &addr
)) {
7970 "Please specify interface address by A.B.C.D\n");
7971 return CMD_WARNING_CONFIG_FAILED
;
7974 params
= ospf_lookup_if_params(ifp
, addr
);
7979 UNSET_IF_PARAM(params
, output_cost_cmd
);
7981 if (params
!= IF_DEF_PARAMS(ifp
)) {
7982 ospf_free_if_params(ifp
, addr
);
7983 ospf_if_update_params(ifp
, addr
);
7986 ospf_if_recalculate_output_cost(ifp
);
7991 DEFUN_HIDDEN (no_ospf_cost
,
7993 "no ospf cost [(1-65535)] [A.B.C.D]",
7995 "OSPF interface commands\n"
7998 "Address of interface\n")
8000 return no_ip_ospf_cost(self
, vty
, argc
, argv
);
8003 static void ospf_nbr_timer_update(struct ospf_interface
*oi
)
8005 struct route_node
*rn
;
8006 struct ospf_neighbor
*nbr
;
8008 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
))
8009 if ((nbr
= rn
->info
)) {
8010 nbr
->v_inactivity
= OSPF_IF_PARAM(oi
, v_wait
);
8011 nbr
->v_db_desc
= OSPF_IF_PARAM(oi
, retransmit_interval
);
8012 nbr
->v_ls_req
= OSPF_IF_PARAM(oi
, retransmit_interval
);
8013 nbr
->v_ls_upd
= OSPF_IF_PARAM(oi
, retransmit_interval
);
8017 static int ospf_vty_dead_interval_set(struct vty
*vty
, const char *interval_str
,
8018 const char *nbr_str
,
8019 const char *fast_hello_str
)
8021 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8024 struct in_addr addr
;
8026 struct ospf_if_params
*params
;
8027 struct ospf_interface
*oi
;
8028 struct route_node
*rn
;
8030 params
= IF_DEF_PARAMS(ifp
);
8033 ret
= inet_aton(nbr_str
, &addr
);
8036 "Please specify interface address by A.B.C.D\n");
8037 return CMD_WARNING_CONFIG_FAILED
;
8040 params
= ospf_get_if_params(ifp
, addr
);
8041 ospf_if_update_params(ifp
, addr
);
8045 seconds
= strtoul(interval_str
, NULL
, 10);
8047 /* reset fast_hello too, just to be sure */
8048 UNSET_IF_PARAM(params
, fast_hello
);
8049 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
8050 } else if (fast_hello_str
) {
8051 hellomult
= strtoul(fast_hello_str
, NULL
, 10);
8052 /* 1s dead-interval with sub-second hellos desired */
8053 seconds
= OSPF_ROUTER_DEAD_INTERVAL_MINIMAL
;
8054 SET_IF_PARAM(params
, fast_hello
);
8055 params
->fast_hello
= hellomult
;
8058 "Please specify dead-interval or hello-multiplier\n");
8059 return CMD_WARNING_CONFIG_FAILED
;
8062 SET_IF_PARAM(params
, v_wait
);
8063 params
->v_wait
= seconds
;
8064 params
->is_v_wait_set
= true;
8066 /* Update timer values in neighbor structure. */
8068 struct ospf
*ospf
= NULL
;
8070 ospf
= ifp
->vrf
->info
;
8072 oi
= ospf_if_lookup_by_local_addr(ospf
, ifp
, addr
);
8074 ospf_nbr_timer_update(oi
);
8077 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
))
8078 if ((oi
= rn
->info
))
8079 ospf_nbr_timer_update(oi
);
8085 DEFUN (ip_ospf_dead_interval
,
8086 ip_ospf_dead_interval_cmd
,
8087 "ip ospf dead-interval (1-65535) [A.B.C.D]",
8089 "OSPF interface commands\n"
8090 "Interval time after which a neighbor is declared down\n"
8092 "Address of interface\n")
8095 char *interval
= argv_find(argv
, argc
, "(1-65535)", &idx
)
8099 argv_find(argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
8100 return ospf_vty_dead_interval_set(vty
, interval
, ifaddr
, NULL
);
8104 DEFUN_HIDDEN (ospf_dead_interval
,
8105 ospf_dead_interval_cmd
,
8106 "ospf dead-interval (1-65535) [A.B.C.D]",
8107 "OSPF interface commands\n"
8108 "Interval time after which a neighbor is declared down\n"
8110 "Address of interface\n")
8112 return ip_ospf_dead_interval(self
, vty
, argc
, argv
);
8115 DEFUN (ip_ospf_dead_interval_minimal
,
8116 ip_ospf_dead_interval_minimal_addr_cmd
,
8117 "ip ospf dead-interval minimal hello-multiplier (1-10) [A.B.C.D]",
8119 "OSPF interface commands\n"
8120 "Interval time after which a neighbor is declared down\n"
8121 "Minimal 1s dead-interval with fast sub-second hellos\n"
8122 "Hello multiplier factor\n"
8123 "Number of Hellos to send each second\n"
8124 "Address of interface\n")
8129 return ospf_vty_dead_interval_set(
8130 vty
, NULL
, argv
[idx_ipv4
]->arg
, argv
[idx_number
]->arg
);
8132 return ospf_vty_dead_interval_set(vty
, NULL
, NULL
,
8133 argv
[idx_number
]->arg
);
8136 DEFUN (no_ip_ospf_dead_interval
,
8137 no_ip_ospf_dead_interval_cmd
,
8138 "no ip ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
8141 "OSPF interface commands\n"
8142 "Interval time after which a neighbor is declared down\n"
8144 "Minimal 1s dead-interval with fast sub-second hellos\n"
8145 "Hello multiplier factor\n"
8146 "Number of Hellos to send each second\n"
8147 "Address of interface\n")
8149 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8150 int idx_ipv4
= argc
- 1;
8151 struct in_addr addr
= {.s_addr
= 0L};
8153 struct ospf_if_params
*params
;
8154 struct ospf_interface
*oi
;
8155 struct route_node
*rn
;
8157 params
= IF_DEF_PARAMS(ifp
);
8159 if (argv
[idx_ipv4
]->type
== IPV4_TKN
) {
8160 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
8163 "Please specify interface address by A.B.C.D\n");
8164 return CMD_WARNING_CONFIG_FAILED
;
8167 params
= ospf_lookup_if_params(ifp
, addr
);
8172 UNSET_IF_PARAM(params
, v_wait
);
8173 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
8174 params
->is_v_wait_set
= false;
8176 UNSET_IF_PARAM(params
, fast_hello
);
8177 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
8179 if (params
!= IF_DEF_PARAMS(ifp
)) {
8180 ospf_free_if_params(ifp
, addr
);
8181 ospf_if_update_params(ifp
, addr
);
8184 /* Update timer values in neighbor structure. */
8186 struct ospf
*ospf
= NULL
;
8188 ospf
= ifp
->vrf
->info
;
8190 oi
= ospf_if_lookup_by_local_addr(ospf
, ifp
, addr
);
8192 ospf_nbr_timer_update(oi
);
8195 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
))
8196 if ((oi
= rn
->info
))
8197 ospf_nbr_timer_update(oi
);
8203 DEFUN_HIDDEN (no_ospf_dead_interval
,
8204 no_ospf_dead_interval_cmd
,
8205 "no ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
8207 "OSPF interface commands\n"
8208 "Interval time after which a neighbor is declared down\n"
8210 "Minimal 1s dead-interval with fast sub-second hellos\n"
8211 "Hello multiplier factor\n"
8212 "Number of Hellos to send each second\n"
8213 "Address of interface\n")
8215 return no_ip_ospf_dead_interval(self
, vty
, argc
, argv
);
8218 DEFUN (ip_ospf_hello_interval
,
8219 ip_ospf_hello_interval_cmd
,
8220 "ip ospf hello-interval (1-65535) [A.B.C.D]",
8222 "OSPF interface commands\n"
8223 "Time between HELLO packets\n"
8225 "Address of interface\n")
8227 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8229 struct in_addr addr
= {.s_addr
= 0L};
8230 struct ospf_if_params
*params
;
8231 params
= IF_DEF_PARAMS(ifp
);
8232 uint32_t seconds
= 0;
8233 bool is_addr
= false;
8234 uint32_t old_interval
= 0;
8236 argv_find(argv
, argc
, "(1-65535)", &idx
);
8237 seconds
= strtol(argv
[idx
]->arg
, NULL
, 10);
8239 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
8240 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
8242 "Please specify interface address by A.B.C.D\n");
8243 return CMD_WARNING_CONFIG_FAILED
;
8246 params
= ospf_get_if_params(ifp
, addr
);
8247 ospf_if_update_params(ifp
, addr
);
8251 old_interval
= params
->v_hello
;
8253 /* Return, if same interval is configured. */
8254 if (old_interval
== seconds
)
8257 SET_IF_PARAM(params
, v_hello
);
8258 params
->v_hello
= seconds
;
8260 if (!params
->is_v_wait_set
) {
8261 SET_IF_PARAM(params
, v_wait
);
8263 * The router dead interval should
8264 * be some multiple of the HelloInterval (perhaps 4 times the
8265 * hello interval) and must be the same for all routers
8266 * attached to a common network.
8268 params
->v_wait
= 4 * seconds
;
8271 ospf_reset_hello_timer(ifp
, addr
, is_addr
);
8276 DEFUN_HIDDEN (ospf_hello_interval
,
8277 ospf_hello_interval_cmd
,
8278 "ospf hello-interval (1-65535) [A.B.C.D]",
8279 "OSPF interface commands\n"
8280 "Time between HELLO packets\n"
8282 "Address of interface\n")
8284 return ip_ospf_hello_interval(self
, vty
, argc
, argv
);
8287 DEFUN (no_ip_ospf_hello_interval
,
8288 no_ip_ospf_hello_interval_cmd
,
8289 "no ip ospf hello-interval [(1-65535) [A.B.C.D]]",
8292 "OSPF interface commands\n"
8293 "Time between HELLO packets\n" // ignored
8295 "Address of interface\n")
8297 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8299 struct in_addr addr
= {.s_addr
= 0L};
8300 struct ospf_if_params
*params
;
8301 struct route_node
*rn
;
8303 params
= IF_DEF_PARAMS(ifp
);
8305 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
8306 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
8308 "Please specify interface address by A.B.C.D\n");
8309 return CMD_WARNING_CONFIG_FAILED
;
8312 params
= ospf_lookup_if_params(ifp
, addr
);
8317 UNSET_IF_PARAM(params
, v_hello
);
8318 params
->v_hello
= OSPF_HELLO_INTERVAL_DEFAULT
;
8320 if (!params
->is_v_wait_set
) {
8321 UNSET_IF_PARAM(params
, v_wait
);
8322 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
8325 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
8326 struct ospf_interface
*oi
= rn
->info
;
8331 oi
->type
= IF_DEF_PARAMS(ifp
)->type
;
8332 oi
->ptp_dmvpn
= IF_DEF_PARAMS(ifp
)->ptp_dmvpn
;
8334 if (oi
->state
> ISM_Down
) {
8335 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceDown
);
8336 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceUp
);
8340 if (params
!= IF_DEF_PARAMS(ifp
)) {
8341 ospf_free_if_params(ifp
, addr
);
8342 ospf_if_update_params(ifp
, addr
);
8348 DEFUN_HIDDEN (no_ospf_hello_interval
,
8349 no_ospf_hello_interval_cmd
,
8350 "no ospf hello-interval [(1-65535) [A.B.C.D]]",
8352 "OSPF interface commands\n"
8353 "Time between HELLO packets\n" // ignored
8355 "Address of interface\n")
8357 return no_ip_ospf_hello_interval(self
, vty
, argc
, argv
);
8360 DEFUN(ip_ospf_network
, ip_ospf_network_cmd
,
8361 "ip ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point [dmvpn]>",
8363 "OSPF interface commands\n"
8365 "Specify OSPF broadcast multi-access network\n"
8366 "Specify OSPF NBMA network\n"
8367 "Specify OSPF point-to-multipoint network\n"
8368 "Specify OSPF point-to-point network\n"
8369 "Specify OSPF point-to-point DMVPN network\n")
8371 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8373 int old_type
= IF_DEF_PARAMS(ifp
)->type
;
8374 uint8_t old_ptp_dmvpn
= IF_DEF_PARAMS(ifp
)->ptp_dmvpn
;
8375 struct route_node
*rn
;
8377 if (old_type
== OSPF_IFTYPE_LOOPBACK
) {
8379 "This is a loopback interface. Can't set network type.\n");
8380 return CMD_WARNING_CONFIG_FAILED
;
8383 IF_DEF_PARAMS(ifp
)->ptp_dmvpn
= 0;
8385 if (argv_find(argv
, argc
, "broadcast", &idx
))
8386 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_BROADCAST
;
8387 else if (argv_find(argv
, argc
, "non-broadcast", &idx
))
8388 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_NBMA
;
8389 else if (argv_find(argv
, argc
, "point-to-multipoint", &idx
))
8390 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_POINTOMULTIPOINT
;
8391 else if (argv_find(argv
, argc
, "point-to-point", &idx
)) {
8392 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_POINTOPOINT
;
8393 if (argv_find(argv
, argc
, "dmvpn", &idx
))
8394 IF_DEF_PARAMS(ifp
)->ptp_dmvpn
= 1;
8397 if (IF_DEF_PARAMS(ifp
)->type
== old_type
8398 && IF_DEF_PARAMS(ifp
)->ptp_dmvpn
== old_ptp_dmvpn
)
8401 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), type
);
8403 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
8404 struct ospf_interface
*oi
= rn
->info
;
8409 oi
->type
= IF_DEF_PARAMS(ifp
)->type
;
8411 if (oi
->state
> ISM_Down
) {
8412 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceDown
);
8413 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceUp
);
8420 DEFUN_HIDDEN (ospf_network
,
8422 "ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
8423 "OSPF interface commands\n"
8425 "Specify OSPF broadcast multi-access network\n"
8426 "Specify OSPF NBMA network\n"
8427 "Specify OSPF point-to-multipoint network\n"
8428 "Specify OSPF point-to-point network\n")
8430 return ip_ospf_network(self
, vty
, argc
, argv
);
8433 DEFUN (no_ip_ospf_network
,
8434 no_ip_ospf_network_cmd
,
8435 "no ip ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
8438 "OSPF interface commands\n"
8440 "Specify OSPF broadcast multi-access network\n"
8441 "Specify OSPF NBMA network\n"
8442 "Specify OSPF point-to-multipoint network\n"
8443 "Specify OSPF point-to-point network\n")
8445 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8446 int old_type
= IF_DEF_PARAMS(ifp
)->type
;
8447 struct route_node
*rn
;
8449 IF_DEF_PARAMS(ifp
)->type
= ospf_default_iftype(ifp
);
8450 IF_DEF_PARAMS(ifp
)->ptp_dmvpn
= 0;
8452 if (IF_DEF_PARAMS(ifp
)->type
== old_type
)
8455 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
8456 struct ospf_interface
*oi
= rn
->info
;
8461 oi
->type
= IF_DEF_PARAMS(ifp
)->type
;
8463 if (oi
->state
> ISM_Down
) {
8464 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceDown
);
8465 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceUp
);
8472 DEFUN_HIDDEN (no_ospf_network
,
8473 no_ospf_network_cmd
,
8474 "no ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
8476 "OSPF interface commands\n"
8478 "Specify OSPF broadcast multi-access network\n"
8479 "Specify OSPF NBMA network\n"
8480 "Specify OSPF point-to-multipoint network\n"
8481 "Specify OSPF point-to-point network\n")
8483 return no_ip_ospf_network(self
, vty
, argc
, argv
);
8486 DEFUN (ip_ospf_priority
,
8487 ip_ospf_priority_cmd
,
8488 "ip ospf priority (0-255) [A.B.C.D]",
8490 "OSPF interface commands\n"
8493 "Address of interface\n")
8495 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8498 struct route_node
*rn
;
8499 struct in_addr addr
;
8500 struct ospf_if_params
*params
;
8501 params
= IF_DEF_PARAMS(ifp
);
8503 argv_find(argv
, argc
, "(0-255)", &idx
);
8504 priority
= strtol(argv
[idx
]->arg
, NULL
, 10);
8506 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
8507 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
8509 "Please specify interface address by A.B.C.D\n");
8510 return CMD_WARNING_CONFIG_FAILED
;
8513 params
= ospf_get_if_params(ifp
, addr
);
8514 ospf_if_update_params(ifp
, addr
);
8517 SET_IF_PARAM(params
, priority
);
8518 params
->priority
= priority
;
8520 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
8521 struct ospf_interface
*oi
= rn
->info
;
8526 if (PRIORITY(oi
) != OSPF_IF_PARAM(oi
, priority
)) {
8527 PRIORITY(oi
) = OSPF_IF_PARAM(oi
, priority
);
8528 OSPF_ISM_EVENT_SCHEDULE(oi
, ISM_NeighborChange
);
8535 DEFUN_HIDDEN (ospf_priority
,
8537 "ospf priority (0-255) [A.B.C.D]",
8538 "OSPF interface commands\n"
8541 "Address of interface\n")
8543 return ip_ospf_priority(self
, vty
, argc
, argv
);
8546 DEFUN (no_ip_ospf_priority
,
8547 no_ip_ospf_priority_cmd
,
8548 "no ip ospf priority [(0-255) [A.B.C.D]]",
8551 "OSPF interface commands\n"
8552 "Router priority\n" // ignored
8554 "Address of interface\n")
8556 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8558 struct route_node
*rn
;
8559 struct in_addr addr
;
8560 struct ospf_if_params
*params
;
8562 params
= IF_DEF_PARAMS(ifp
);
8564 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
8565 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
8567 "Please specify interface address by A.B.C.D\n");
8568 return CMD_WARNING_CONFIG_FAILED
;
8571 params
= ospf_lookup_if_params(ifp
, addr
);
8576 UNSET_IF_PARAM(params
, priority
);
8577 params
->priority
= OSPF_ROUTER_PRIORITY_DEFAULT
;
8579 if (params
!= IF_DEF_PARAMS(ifp
)) {
8580 ospf_free_if_params(ifp
, addr
);
8581 ospf_if_update_params(ifp
, addr
);
8584 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
8585 struct ospf_interface
*oi
= rn
->info
;
8590 if (PRIORITY(oi
) != OSPF_IF_PARAM(oi
, priority
)) {
8591 PRIORITY(oi
) = OSPF_IF_PARAM(oi
, priority
);
8592 OSPF_ISM_EVENT_SCHEDULE(oi
, ISM_NeighborChange
);
8599 DEFUN_HIDDEN (no_ospf_priority
,
8600 no_ospf_priority_cmd
,
8601 "no ospf priority [(0-255) [A.B.C.D]]",
8603 "OSPF interface commands\n"
8606 "Address of interface\n")
8608 return no_ip_ospf_priority(self
, vty
, argc
, argv
);
8611 DEFUN (ip_ospf_retransmit_interval
,
8612 ip_ospf_retransmit_interval_addr_cmd
,
8613 "ip ospf retransmit-interval (1-65535) [A.B.C.D]",
8615 "OSPF interface commands\n"
8616 "Time between retransmitting lost link state advertisements\n"
8618 "Address of interface\n")
8620 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8623 struct in_addr addr
;
8624 struct ospf_if_params
*params
;
8625 params
= IF_DEF_PARAMS(ifp
);
8627 argv_find(argv
, argc
, "(1-65535)", &idx
);
8628 seconds
= strtol(argv
[idx
]->arg
, NULL
, 10);
8630 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
8631 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
8633 "Please specify interface address by A.B.C.D\n");
8634 return CMD_WARNING_CONFIG_FAILED
;
8637 params
= ospf_get_if_params(ifp
, addr
);
8638 ospf_if_update_params(ifp
, addr
);
8641 SET_IF_PARAM(params
, retransmit_interval
);
8642 params
->retransmit_interval
= seconds
;
8647 DEFUN_HIDDEN (ospf_retransmit_interval
,
8648 ospf_retransmit_interval_cmd
,
8649 "ospf retransmit-interval (1-65535) [A.B.C.D]",
8650 "OSPF interface commands\n"
8651 "Time between retransmitting lost link state advertisements\n"
8653 "Address of interface\n")
8655 return ip_ospf_retransmit_interval(self
, vty
, argc
, argv
);
8658 DEFUN (no_ip_ospf_retransmit_interval
,
8659 no_ip_ospf_retransmit_interval_addr_cmd
,
8660 "no ip 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 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8670 struct in_addr addr
;
8671 struct ospf_if_params
*params
;
8673 params
= IF_DEF_PARAMS(ifp
);
8675 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
8676 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
8678 "Please specify interface address by A.B.C.D\n");
8679 return CMD_WARNING_CONFIG_FAILED
;
8682 params
= ospf_lookup_if_params(ifp
, addr
);
8687 UNSET_IF_PARAM(params
, retransmit_interval
);
8688 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
8690 if (params
!= IF_DEF_PARAMS(ifp
)) {
8691 ospf_free_if_params(ifp
, addr
);
8692 ospf_if_update_params(ifp
, addr
);
8698 DEFUN_HIDDEN (no_ospf_retransmit_interval
,
8699 no_ospf_retransmit_interval_cmd
,
8700 "no ospf retransmit-interval [(1-65535)] [A.B.C.D]",
8702 "OSPF interface commands\n"
8703 "Time between retransmitting lost link state advertisements\n"
8705 "Address of interface\n")
8707 return no_ip_ospf_retransmit_interval(self
, vty
, argc
, argv
);
8710 DEFUN (ip_ospf_transmit_delay
,
8711 ip_ospf_transmit_delay_addr_cmd
,
8712 "ip ospf transmit-delay (1-65535) [A.B.C.D]",
8714 "OSPF interface commands\n"
8715 "Link state transmit delay\n"
8717 "Address of interface\n")
8719 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8722 struct in_addr addr
;
8723 struct ospf_if_params
*params
;
8725 params
= IF_DEF_PARAMS(ifp
);
8726 argv_find(argv
, argc
, "(1-65535)", &idx
);
8727 seconds
= strtol(argv
[idx
]->arg
, NULL
, 10);
8729 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
8730 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
8732 "Please specify interface address by A.B.C.D\n");
8733 return CMD_WARNING_CONFIG_FAILED
;
8736 params
= ospf_get_if_params(ifp
, addr
);
8737 ospf_if_update_params(ifp
, addr
);
8740 SET_IF_PARAM(params
, transmit_delay
);
8741 params
->transmit_delay
= seconds
;
8746 DEFUN_HIDDEN (ospf_transmit_delay
,
8747 ospf_transmit_delay_cmd
,
8748 "ospf transmit-delay (1-65535) [A.B.C.D]",
8749 "OSPF interface commands\n"
8750 "Link state transmit delay\n"
8752 "Address of interface\n")
8754 return ip_ospf_transmit_delay(self
, vty
, argc
, argv
);
8757 DEFUN (no_ip_ospf_transmit_delay
,
8758 no_ip_ospf_transmit_delay_addr_cmd
,
8759 "no ip 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 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8769 struct in_addr addr
;
8770 struct ospf_if_params
*params
;
8772 params
= IF_DEF_PARAMS(ifp
);
8774 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
8775 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
8777 "Please specify interface address by A.B.C.D\n");
8778 return CMD_WARNING_CONFIG_FAILED
;
8781 params
= ospf_lookup_if_params(ifp
, addr
);
8786 UNSET_IF_PARAM(params
, transmit_delay
);
8787 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
8789 if (params
!= IF_DEF_PARAMS(ifp
)) {
8790 ospf_free_if_params(ifp
, addr
);
8791 ospf_if_update_params(ifp
, addr
);
8798 DEFUN_HIDDEN (no_ospf_transmit_delay
,
8799 no_ospf_transmit_delay_cmd
,
8800 "no ospf transmit-delay [(1-65535) [A.B.C.D]]",
8802 "OSPF interface commands\n"
8803 "Link state transmit delay\n"
8805 "Address of interface\n")
8807 return no_ip_ospf_transmit_delay(self
, vty
, argc
, argv
);
8810 DEFUN (ip_ospf_area
,
8812 "ip ospf [(1-65535)] area <A.B.C.D|(0-4294967295)> [A.B.C.D]",
8814 "OSPF interface commands\n"
8816 "Enable OSPF on this interface\n"
8817 "OSPF area ID in IP address format\n"
8818 "OSPF area ID as a decimal value\n"
8819 "Address of interface\n")
8821 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8824 struct in_addr area_id
;
8825 struct in_addr addr
;
8826 struct ospf_if_params
*params
= NULL
;
8827 struct route_node
*rn
;
8828 struct ospf
*ospf
= NULL
;
8829 unsigned short instance
= 0;
8833 if (argv_find(argv
, argc
, "(1-65535)", &idx
))
8834 instance
= strtol(argv
[idx
]->arg
, NULL
, 10);
8836 argv_find(argv
, argc
, "area", &idx
);
8837 areaid
= argv
[idx
+ 1]->arg
;
8840 ospf
= ifp
->vrf
->info
;
8842 ospf
= ospf_lookup_instance(instance
);
8844 if (instance
&& instance
!= ospf_instance
) {
8846 * At this point we know we have received
8847 * an instance and there is no ospf instance
8848 * associated with it. This means we are
8849 * in a situation where we have an
8850 * ospf command that is setup for a different
8851 * process(instance). We need to safely
8852 * remove the command from ourselves and
8853 * allow the other instance(process) handle
8854 * the configuration command.
8858 params
= IF_DEF_PARAMS(ifp
);
8859 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
8860 UNSET_IF_PARAM(params
, if_area
);
8864 for (rn
= route_top(IF_OIFS_PARAMS(ifp
)); rn
; rn
= route_next(rn
))
8865 if ((params
= rn
->info
) && OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
8866 UNSET_IF_PARAM(params
, if_area
);
8871 ospf
= ifp
->vrf
->info
;
8873 ospf_interface_area_unset(ospf
, ifp
);
8876 return CMD_NOT_MY_INSTANCE
;
8879 ret
= str2area_id(areaid
, &area_id
, &format
);
8881 vty_out(vty
, "Please specify area by A.B.C.D|<0-4294967295>\n");
8882 return CMD_WARNING_CONFIG_FAILED
;
8884 if (memcmp(ifp
->name
, "VLINK", 5) == 0) {
8885 vty_out(vty
, "Cannot enable OSPF on a virtual link.\n");
8886 return CMD_WARNING_CONFIG_FAILED
;
8890 for (rn
= route_top(ospf
->networks
); rn
; rn
= route_next(rn
)) {
8891 if (rn
->info
!= NULL
) {
8893 "Please remove all network commands first.\n");
8894 return CMD_WARNING_CONFIG_FAILED
;
8899 params
= IF_DEF_PARAMS(ifp
);
8900 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)
8901 && !IPV4_ADDR_SAME(¶ms
->if_area
, &area_id
)) {
8903 "Must remove previous area config before changing ospf area \n");
8904 return CMD_WARNING_CONFIG_FAILED
;
8907 // Check if we have an address arg and proccess it
8908 if (argc
== idx
+ 3) {
8909 if (!inet_aton(argv
[idx
+ 2]->arg
, &addr
)) {
8911 "Please specify Intf Address by A.B.C.D\n");
8912 return CMD_WARNING_CONFIG_FAILED
;
8914 // update/create address-level params
8915 params
= ospf_get_if_params((ifp
), (addr
));
8916 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
8917 if (!IPV4_ADDR_SAME(¶ms
->if_area
, &area_id
)) {
8919 "Must remove previous area/address config before changing ospf area\n");
8920 return CMD_WARNING_CONFIG_FAILED
;
8924 ospf_if_update_params((ifp
), (addr
));
8927 /* enable ospf on this interface with area_id */
8929 SET_IF_PARAM(params
, if_area
);
8930 params
->if_area
= area_id
;
8931 params
->if_area_id_fmt
= format
;
8935 ospf_interface_area_set(ospf
, ifp
);
8940 DEFUN (no_ip_ospf_area
,
8941 no_ip_ospf_area_cmd
,
8942 "no ip ospf [(1-65535)] area [<A.B.C.D|(0-4294967295)> [A.B.C.D]]",
8945 "OSPF interface commands\n"
8947 "Disable OSPF on this interface\n"
8948 "OSPF area ID in IP address format\n"
8949 "OSPF area ID as a decimal value\n"
8950 "Address of interface\n")
8952 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8955 struct ospf_if_params
*params
;
8956 unsigned short instance
= 0;
8957 struct in_addr addr
;
8958 struct in_addr area_id
;
8960 if (argv_find(argv
, argc
, "(1-65535)", &idx
))
8961 instance
= strtol(argv
[idx
]->arg
, NULL
, 10);
8964 ospf
= ifp
->vrf
->info
;
8966 ospf
= ospf_lookup_instance(instance
);
8968 if (instance
&& instance
!= ospf_instance
)
8969 return CMD_NOT_MY_INSTANCE
;
8971 argv_find(argv
, argc
, "area", &idx
);
8973 // Check if we have an address arg and proccess it
8974 if (argc
== idx
+ 3) {
8975 if (!inet_aton(argv
[idx
+ 2]->arg
, &addr
)) {
8977 "Please specify Intf Address by A.B.C.D\n");
8978 return CMD_WARNING_CONFIG_FAILED
;
8980 params
= ospf_lookup_if_params(ifp
, addr
);
8981 if ((params
) == NULL
)
8984 params
= IF_DEF_PARAMS(ifp
);
8986 area_id
= params
->if_area
;
8987 if (!OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
8989 "Can't find specified interface area configuration.\n");
8990 return CMD_WARNING_CONFIG_FAILED
;
8993 UNSET_IF_PARAM(params
, if_area
);
8994 if (params
!= IF_DEF_PARAMS((ifp
))) {
8995 ospf_free_if_params((ifp
), (addr
));
8996 ospf_if_update_params((ifp
), (addr
));
9000 ospf_interface_area_unset(ospf
, ifp
);
9001 ospf_area_check_free(ospf
, area_id
);
9007 DEFUN (ip_ospf_passive
,
9008 ip_ospf_passive_cmd
,
9009 "ip ospf passive [A.B.C.D]",
9011 "OSPF interface commands\n"
9012 "Suppress routing updates on an interface\n"
9013 "Address of interface\n")
9015 VTY_DECLVAR_CONTEXT(interface
, ifp
);
9017 struct in_addr addr
= {.s_addr
= INADDR_ANY
};
9018 struct ospf_if_params
*params
;
9022 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
9025 "Please specify interface address by A.B.C.D\n");
9026 return CMD_WARNING_CONFIG_FAILED
;
9028 params
= ospf_get_if_params(ifp
, addr
);
9029 ospf_if_update_params(ifp
, addr
);
9031 params
= IF_DEF_PARAMS(ifp
);
9034 ospf_passive_interface_update(ifp
, params
, addr
, OSPF_IF_PASSIVE
);
9039 DEFUN (no_ip_ospf_passive
,
9040 no_ip_ospf_passive_cmd
,
9041 "no ip ospf passive [A.B.C.D]",
9044 "OSPF interface commands\n"
9045 "Enable routing updates on an interface\n"
9046 "Address of interface\n")
9048 VTY_DECLVAR_CONTEXT(interface
, ifp
);
9050 struct in_addr addr
= {.s_addr
= INADDR_ANY
};
9051 struct ospf_if_params
*params
;
9055 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
9058 "Please specify interface address by A.B.C.D\n");
9059 return CMD_WARNING_CONFIG_FAILED
;
9061 params
= ospf_lookup_if_params(ifp
, addr
);
9065 params
= IF_DEF_PARAMS(ifp
);
9068 ospf_passive_interface_update(ifp
, params
, addr
, OSPF_IF_ACTIVE
);
9073 DEFUN (ospf_redistribute_source
,
9074 ospf_redistribute_source_cmd
,
9075 "redistribute " FRR_REDIST_STR_OSPFD
" [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
9077 FRR_REDIST_HELP_STR_OSPFD
9078 "Metric for redistributed routes\n"
9079 "OSPF default metric\n"
9080 "OSPF exterior metric type for redistributed routes\n"
9081 "Set OSPF External Type 1/2 metrics\n"
9082 "Route map reference\n"
9083 "Pointer to route-map entries\n")
9085 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9086 int idx_protocol
= 1;
9090 struct ospf_redist
*red
;
9092 bool update
= false;
9094 /* Get distribute source. */
9095 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
9097 return CMD_WARNING_CONFIG_FAILED
;
9099 /* Get metric value. */
9100 if (argv_find(argv
, argc
, "(0-16777214)", &idx
)) {
9101 if (!str2metric(argv
[idx
]->arg
, &metric
))
9102 return CMD_WARNING_CONFIG_FAILED
;
9105 /* Get metric type. */
9106 if (argv_find(argv
, argc
, "(1-2)", &idx
)) {
9107 if (!str2metric_type(argv
[idx
]->arg
, &type
))
9108 return CMD_WARNING_CONFIG_FAILED
;
9112 red
= ospf_redist_lookup(ospf
, source
, 0);
9114 red
= ospf_redist_add(ospf
, source
, 0);
9119 if (argv_find(argv
, argc
, "WORD", &idx
)) {
9120 ospf_routemap_set(red
, argv
[idx
]->arg
);
9122 ospf_routemap_unset(red
);
9125 return ospf_redistribute_update(ospf
, red
, source
, 0, type
,
9128 return ospf_redistribute_set(ospf
, red
, source
, 0, type
,
9132 DEFUN (no_ospf_redistribute_source
,
9133 no_ospf_redistribute_source_cmd
,
9134 "no redistribute " FRR_REDIST_STR_OSPFD
" [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
9137 FRR_REDIST_HELP_STR_OSPFD
9138 "Metric for redistributed routes\n"
9139 "OSPF default metric\n"
9140 "OSPF exterior metric type for redistributed routes\n"
9141 "Set OSPF External Type 1/2 metrics\n"
9142 "Route map reference\n"
9143 "Pointer to route-map entries\n")
9145 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9146 int idx_protocol
= 2;
9148 struct ospf_redist
*red
;
9150 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
9152 return CMD_WARNING_CONFIG_FAILED
;
9154 red
= ospf_redist_lookup(ospf
, source
, 0);
9158 ospf_routemap_unset(red
);
9159 ospf_redist_del(ospf
, source
, 0);
9161 return ospf_redistribute_unset(ospf
, source
, 0);
9164 DEFUN (ospf_redistribute_instance_source
,
9165 ospf_redistribute_instance_source_cmd
,
9166 "redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
9168 "Open Shortest Path First\n"
9169 "Non-main Kernel Routing Table\n"
9170 "Instance ID/Table ID\n"
9171 "Metric for redistributed routes\n"
9172 "OSPF default metric\n"
9173 "OSPF exterior metric type for redistributed routes\n"
9174 "Set OSPF External Type 1/2 metrics\n"
9175 "Route map reference\n"
9176 "Pointer to route-map entries\n")
9178 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9179 int idx_ospf_table
= 1;
9185 unsigned short instance
;
9186 struct ospf_redist
*red
;
9187 bool update
= false;
9189 source
= proto_redistnum(AFI_IP
, argv
[idx_ospf_table
]->text
);
9192 vty_out(vty
, "Unknown instance redistribution\n");
9193 return CMD_WARNING_CONFIG_FAILED
;
9196 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
9198 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
) {
9200 "Instance redistribution in non-instanced OSPF not allowed\n");
9201 return CMD_WARNING_CONFIG_FAILED
;
9204 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
)) {
9205 vty_out(vty
, "Same instance OSPF redistribution not allowed\n");
9206 return CMD_WARNING_CONFIG_FAILED
;
9209 /* Get metric value. */
9210 if (argv_find(argv
, argc
, "metric", &idx
))
9211 if (!str2metric(argv
[idx
+ 1]->arg
, &metric
))
9212 return CMD_WARNING_CONFIG_FAILED
;
9215 /* Get metric type. */
9216 if (argv_find(argv
, argc
, "metric-type", &idx
))
9217 if (!str2metric_type(argv
[idx
+ 1]->arg
, &type
))
9218 return CMD_WARNING_CONFIG_FAILED
;
9220 red
= ospf_redist_lookup(ospf
, source
, instance
);
9222 red
= ospf_redist_add(ospf
, source
, instance
);
9227 if (argv_find(argv
, argc
, "route-map", &idx
))
9228 ospf_routemap_set(red
, argv
[idx
+ 1]->arg
);
9230 ospf_routemap_unset(red
);
9233 return ospf_redistribute_update(ospf
, red
, source
, instance
,
9236 return ospf_redistribute_set(ospf
, red
, source
, instance
, type
,
9240 DEFUN (no_ospf_redistribute_instance_source
,
9241 no_ospf_redistribute_instance_source_cmd
,
9242 "no redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
9245 "Open Shortest Path First\n"
9246 "Non-main Kernel Routing Table\n"
9247 "Instance ID/Table Id\n"
9248 "Metric for redistributed routes\n"
9249 "OSPF default metric\n"
9250 "OSPF exterior metric type for redistributed routes\n"
9251 "Set OSPF External Type 1/2 metrics\n"
9252 "Route map reference\n"
9253 "Pointer to route-map entries\n")
9255 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9256 int idx_ospf_table
= 2;
9258 unsigned int instance
;
9259 struct ospf_redist
*red
;
9262 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
9263 source
= ZEBRA_ROUTE_OSPF
;
9265 source
= ZEBRA_ROUTE_TABLE
;
9267 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
9269 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
) {
9271 "Instance redistribution in non-instanced OSPF not allowed\n");
9272 return CMD_WARNING_CONFIG_FAILED
;
9275 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
)) {
9276 vty_out(vty
, "Same instance OSPF redistribution not allowed\n");
9277 return CMD_WARNING_CONFIG_FAILED
;
9280 red
= ospf_redist_lookup(ospf
, source
, instance
);
9284 ospf_routemap_unset(red
);
9285 ospf_redist_del(ospf
, source
, instance
);
9287 return ospf_redistribute_unset(ospf
, source
, instance
);
9290 DEFUN (ospf_distribute_list_out
,
9291 ospf_distribute_list_out_cmd
,
9292 "distribute-list ACCESSLIST4_NAME out " FRR_REDIST_STR_OSPFD
,
9293 "Filter networks in routing updates\n"
9294 "Access-list name\n"
9296 FRR_REDIST_HELP_STR_OSPFD
)
9298 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9302 char *proto
= argv
[argc
- 1]->text
;
9304 /* Get distribute source. */
9305 source
= proto_redistnum(AFI_IP
, proto
);
9307 return CMD_WARNING_CONFIG_FAILED
;
9309 return ospf_distribute_list_out_set(ospf
, source
, argv
[idx_word
]->arg
);
9312 DEFUN (no_ospf_distribute_list_out
,
9313 no_ospf_distribute_list_out_cmd
,
9314 "no distribute-list ACCESSLIST4_NAME out " FRR_REDIST_STR_OSPFD
,
9316 "Filter networks in routing updates\n"
9317 "Access-list name\n"
9319 FRR_REDIST_HELP_STR_OSPFD
)
9321 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9325 char *proto
= argv
[argc
- 1]->text
;
9326 source
= proto_redistnum(AFI_IP
, proto
);
9328 return CMD_WARNING_CONFIG_FAILED
;
9330 return ospf_distribute_list_out_unset(ospf
, source
,
9331 argv
[idx_word
]->arg
);
9334 /* Default information originate. */
9335 DEFUN (ospf_default_information_originate
,
9336 ospf_default_information_originate_cmd
,
9337 "default-information originate [{always|metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
9338 "Control distribution of default information\n"
9339 "Distribute a default route\n"
9340 "Always advertise default route\n"
9341 "OSPF default metric\n"
9343 "OSPF metric type for default routes\n"
9344 "Set OSPF External Type 1/2 metrics\n"
9345 "Route map reference\n"
9346 "Pointer to route-map entries\n")
9348 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9349 int default_originate
= DEFAULT_ORIGINATE_ZEBRA
;
9352 struct ospf_redist
*red
;
9354 int cur_originate
= ospf
->default_originate
;
9355 bool sameRtmap
= false;
9358 red
= ospf_redist_add(ospf
, DEFAULT_ROUTE
, 0);
9360 /* Check whether "always" was specified */
9361 if (argv_find(argv
, argc
, "always", &idx
))
9362 default_originate
= DEFAULT_ORIGINATE_ALWAYS
;
9364 /* Get metric value */
9365 if (argv_find(argv
, argc
, "(0-16777214)", &idx
)) {
9366 if (!str2metric(argv
[idx
]->arg
, &metric
))
9367 return CMD_WARNING_CONFIG_FAILED
;
9370 /* Get metric type. */
9371 if (argv_find(argv
, argc
, "(1-2)", &idx
)) {
9372 if (!str2metric_type(argv
[idx
]->arg
, &type
))
9373 return CMD_WARNING_CONFIG_FAILED
;
9377 if (argv_find(argv
, argc
, "WORD", &idx
))
9378 rtmap
= argv
[idx
]->arg
;
9380 /* To check if user is providing same route map */
9381 if ((!rtmap
&& !ROUTEMAP_NAME(red
)) ||
9382 (rtmap
&& ROUTEMAP_NAME(red
) &&
9383 (strcmp(rtmap
, ROUTEMAP_NAME(red
)) == 0)))
9386 /* Don't allow if the same lsa is already originated. */
9388 && (red
->dmetric
.type
== type
)
9389 && (red
->dmetric
.value
== metric
)
9390 && (cur_originate
== default_originate
))
9393 /* Updating Metric details */
9394 red
->dmetric
.type
= type
;
9395 red
->dmetric
.value
= metric
;
9397 /* updating route map details */
9399 ospf_routemap_set(red
, rtmap
);
9401 ospf_routemap_unset(red
);
9403 return ospf_redistribute_default_set(ospf
, default_originate
, type
,
9407 DEFUN (no_ospf_default_information_originate
,
9408 no_ospf_default_information_originate_cmd
,
9409 "no default-information originate [{always|metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
9411 "Control distribution of default information\n"
9412 "Distribute a default route\n"
9413 "Always advertise default route\n"
9414 "OSPF default metric\n"
9416 "OSPF metric type for default routes\n"
9417 "Set OSPF External Type 1/2 metrics\n"
9418 "Route map reference\n"
9419 "Pointer to route-map entries\n")
9421 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9422 struct ospf_redist
*red
;
9424 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
9428 ospf_routemap_unset(red
);
9429 ospf_redist_del(ospf
, DEFAULT_ROUTE
, 0);
9431 return ospf_redistribute_default_set(ospf
, DEFAULT_ORIGINATE_NONE
,
9435 DEFUN (ospf_default_metric
,
9436 ospf_default_metric_cmd
,
9437 "default-metric (0-16777214)",
9438 "Set metric of redistributed routes\n"
9441 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9445 if (!str2metric(argv
[idx_number
]->arg
, &metric
))
9446 return CMD_WARNING_CONFIG_FAILED
;
9448 ospf
->default_metric
= metric
;
9453 DEFUN (no_ospf_default_metric
,
9454 no_ospf_default_metric_cmd
,
9455 "no default-metric [(0-16777214)]",
9457 "Set metric of redistributed routes\n"
9460 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9462 ospf
->default_metric
= -1;
9468 DEFUN (ospf_distance
,
9471 "Administrative distance\n"
9472 "OSPF Administrative distance\n")
9474 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9478 distance
= atoi(argv
[idx_number
]->arg
);
9479 if (ospf
->distance_all
!= distance
) {
9480 ospf
->distance_all
= distance
;
9481 ospf_restart_spf(ospf
);
9487 DEFUN (no_ospf_distance
,
9488 no_ospf_distance_cmd
,
9489 "no distance (1-255)",
9491 "Administrative distance\n"
9492 "OSPF Administrative distance\n")
9494 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9496 if (ospf
->distance_all
) {
9497 ospf
->distance_all
= 0;
9498 ospf_restart_spf(ospf
);
9504 DEFUN (no_ospf_distance_ospf
,
9505 no_ospf_distance_ospf_cmd
,
9506 "no distance ospf [{intra-area [(1-255)]|inter-area [(1-255)]|external [(1-255)]}]",
9508 "Administrative distance\n"
9509 "OSPF administrative distance\n"
9510 "Intra-area routes\n"
9511 "Distance for intra-area routes\n"
9512 "Inter-area routes\n"
9513 "Distance for inter-area routes\n"
9515 "Distance for external routes\n")
9517 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9520 if (argv_find(argv
, argc
, "intra-area", &idx
) || argc
== 3)
9521 idx
= ospf
->distance_intra
= 0;
9522 if (argv_find(argv
, argc
, "inter-area", &idx
) || argc
== 3)
9523 idx
= ospf
->distance_inter
= 0;
9524 if (argv_find(argv
, argc
, "external", &idx
) || argc
== 3)
9525 ospf
->distance_external
= 0;
9530 DEFUN (ospf_distance_ospf
,
9531 ospf_distance_ospf_cmd
,
9532 "distance ospf {intra-area (1-255)|inter-area (1-255)|external (1-255)}",
9533 "Administrative distance\n"
9534 "OSPF administrative distance\n"
9535 "Intra-area routes\n"
9536 "Distance for intra-area routes\n"
9537 "Inter-area routes\n"
9538 "Distance for inter-area routes\n"
9540 "Distance for external routes\n")
9542 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9545 ospf
->distance_intra
= 0;
9546 ospf
->distance_inter
= 0;
9547 ospf
->distance_external
= 0;
9549 if (argv_find(argv
, argc
, "intra-area", &idx
))
9550 ospf
->distance_intra
= atoi(argv
[idx
+ 1]->arg
);
9552 if (argv_find(argv
, argc
, "inter-area", &idx
))
9553 ospf
->distance_inter
= atoi(argv
[idx
+ 1]->arg
);
9555 if (argv_find(argv
, argc
, "external", &idx
))
9556 ospf
->distance_external
= atoi(argv
[idx
+ 1]->arg
);
9561 DEFUN (ip_ospf_mtu_ignore
,
9562 ip_ospf_mtu_ignore_addr_cmd
,
9563 "ip ospf mtu-ignore [A.B.C.D]",
9565 "OSPF interface commands\n"
9566 "Disable MTU mismatch detection on this interface\n"
9567 "Address of interface\n")
9569 VTY_DECLVAR_CONTEXT(interface
, ifp
);
9571 struct in_addr addr
;
9574 struct ospf_if_params
*params
;
9575 params
= IF_DEF_PARAMS(ifp
);
9578 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
9581 "Please specify interface address by A.B.C.D\n");
9582 return CMD_WARNING_CONFIG_FAILED
;
9584 params
= ospf_get_if_params(ifp
, addr
);
9585 ospf_if_update_params(ifp
, addr
);
9587 params
->mtu_ignore
= 1;
9588 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
9589 SET_IF_PARAM(params
, mtu_ignore
);
9591 UNSET_IF_PARAM(params
, mtu_ignore
);
9592 if (params
!= IF_DEF_PARAMS(ifp
)) {
9593 ospf_free_if_params(ifp
, addr
);
9594 ospf_if_update_params(ifp
, addr
);
9600 DEFUN (no_ip_ospf_mtu_ignore
,
9601 no_ip_ospf_mtu_ignore_addr_cmd
,
9602 "no ip ospf mtu-ignore [A.B.C.D]",
9605 "OSPF interface commands\n"
9606 "Disable MTU mismatch detection on this interface\n"
9607 "Address of interface\n")
9609 VTY_DECLVAR_CONTEXT(interface
, ifp
);
9611 struct in_addr addr
;
9614 struct ospf_if_params
*params
;
9615 params
= IF_DEF_PARAMS(ifp
);
9618 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
9621 "Please specify interface address by A.B.C.D\n");
9622 return CMD_WARNING_CONFIG_FAILED
;
9624 params
= ospf_get_if_params(ifp
, addr
);
9625 ospf_if_update_params(ifp
, addr
);
9627 params
->mtu_ignore
= 0;
9628 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
9629 SET_IF_PARAM(params
, mtu_ignore
);
9631 UNSET_IF_PARAM(params
, mtu_ignore
);
9632 if (params
!= IF_DEF_PARAMS(ifp
)) {
9633 ospf_free_if_params(ifp
, addr
);
9634 ospf_if_update_params(ifp
, addr
);
9641 DEFUN (ospf_max_metric_router_lsa_admin
,
9642 ospf_max_metric_router_lsa_admin_cmd
,
9643 "max-metric router-lsa administrative",
9644 "OSPF maximum / infinite-distance metric\n"
9645 "Advertise own Router-LSA with infinite distance (stub router)\n"
9646 "Administratively applied, for an indefinite period\n")
9648 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9649 struct listnode
*ln
;
9650 struct ospf_area
*area
;
9652 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
9653 SET_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
9655 if (!CHECK_FLAG(area
->stub_router_state
,
9656 OSPF_AREA_IS_STUB_ROUTED
))
9657 ospf_router_lsa_update_area(area
);
9660 /* Allows for areas configured later to get the property */
9661 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_SET
;
9666 DEFUN (no_ospf_max_metric_router_lsa_admin
,
9667 no_ospf_max_metric_router_lsa_admin_cmd
,
9668 "no max-metric router-lsa administrative",
9670 "OSPF maximum / infinite-distance metric\n"
9671 "Advertise own Router-LSA with infinite distance (stub router)\n"
9672 "Administratively applied, for an indefinite period\n")
9674 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9675 struct listnode
*ln
;
9676 struct ospf_area
*area
;
9678 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
9679 UNSET_FLAG(area
->stub_router_state
,
9680 OSPF_AREA_ADMIN_STUB_ROUTED
);
9682 /* Don't trample on the start-up stub timer */
9683 if (CHECK_FLAG(area
->stub_router_state
,
9684 OSPF_AREA_IS_STUB_ROUTED
)
9685 && !area
->t_stub_router
) {
9686 UNSET_FLAG(area
->stub_router_state
,
9687 OSPF_AREA_IS_STUB_ROUTED
);
9688 ospf_router_lsa_update_area(area
);
9691 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET
;
9695 DEFUN (ospf_max_metric_router_lsa_startup
,
9696 ospf_max_metric_router_lsa_startup_cmd
,
9697 "max-metric router-lsa on-startup (5-86400)",
9698 "OSPF maximum / infinite-distance metric\n"
9699 "Advertise own Router-LSA with infinite distance (stub router)\n"
9700 "Automatically advertise stub Router-LSA on startup of OSPF\n"
9701 "Time (seconds) to advertise self as stub-router\n")
9703 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9705 unsigned int seconds
;
9708 vty_out(vty
, "%% Must supply stub-router period");
9709 return CMD_WARNING_CONFIG_FAILED
;
9712 seconds
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
9714 ospf
->stub_router_startup_time
= seconds
;
9719 DEFUN (no_ospf_max_metric_router_lsa_startup
,
9720 no_ospf_max_metric_router_lsa_startup_cmd
,
9721 "no max-metric router-lsa on-startup [(5-86400)]",
9723 "OSPF maximum / infinite-distance metric\n"
9724 "Advertise own Router-LSA with infinite distance (stub router)\n"
9725 "Automatically advertise stub Router-LSA on startup of OSPF\n"
9726 "Time (seconds) to advertise self as stub-router\n")
9728 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9729 struct listnode
*ln
;
9730 struct ospf_area
*area
;
9732 ospf
->stub_router_startup_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
9734 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
9735 SET_FLAG(area
->stub_router_state
,
9736 OSPF_AREA_WAS_START_STUB_ROUTED
);
9737 OSPF_TIMER_OFF(area
->t_stub_router
);
9739 /* Don't trample on admin stub routed */
9740 if (!CHECK_FLAG(area
->stub_router_state
,
9741 OSPF_AREA_ADMIN_STUB_ROUTED
)) {
9742 UNSET_FLAG(area
->stub_router_state
,
9743 OSPF_AREA_IS_STUB_ROUTED
);
9744 ospf_router_lsa_update_area(area
);
9751 DEFUN (ospf_max_metric_router_lsa_shutdown
,
9752 ospf_max_metric_router_lsa_shutdown_cmd
,
9753 "max-metric router-lsa on-shutdown (5-100)",
9754 "OSPF maximum / infinite-distance metric\n"
9755 "Advertise own Router-LSA with infinite distance (stub router)\n"
9756 "Advertise stub-router prior to full shutdown of OSPF\n"
9757 "Time (seconds) to wait till full shutdown\n")
9759 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9761 unsigned int seconds
;
9764 vty_out(vty
, "%% Must supply stub-router shutdown period");
9765 return CMD_WARNING_CONFIG_FAILED
;
9768 seconds
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
9770 ospf
->stub_router_shutdown_time
= seconds
;
9775 DEFUN (no_ospf_max_metric_router_lsa_shutdown
,
9776 no_ospf_max_metric_router_lsa_shutdown_cmd
,
9777 "no max-metric router-lsa on-shutdown [(5-100)]",
9779 "OSPF maximum / infinite-distance metric\n"
9780 "Advertise own Router-LSA with infinite distance (stub router)\n"
9781 "Advertise stub-router prior to full shutdown of OSPF\n"
9782 "Time (seconds) to wait till full shutdown\n")
9784 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9786 ospf
->stub_router_shutdown_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
9791 DEFUN (ospf_proactive_arp
,
9792 ospf_proactive_arp_cmd
,
9794 "Allow sending ARP requests proactively\n")
9796 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9798 ospf
->proactive_arp
= true;
9803 DEFUN (no_ospf_proactive_arp
,
9804 no_ospf_proactive_arp_cmd
,
9807 "Disallow sending ARP requests proactively\n")
9809 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9811 ospf
->proactive_arp
= false;
9816 /* Graceful Restart HELPER Commands */
9817 DEFPY(ospf_gr_helper_enable
, ospf_gr_helper_enable_cmd
,
9818 "graceful-restart helper enable [A.B.C.D$address]",
9819 "OSPF Graceful Restart\n"
9821 "Enable Helper support\n"
9822 "Advertising Router-ID\n")
9824 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9827 ospf_gr_helper_support_set_per_routerid(ospf
, &address
,
9832 ospf_gr_helper_support_set(ospf
, OSPF_GR_TRUE
);
9837 DEFPY(no_ospf_gr_helper_enable
,
9838 no_ospf_gr_helper_enable_cmd
,
9839 "no graceful-restart helper enable [A.B.C.D$address]",
9841 "OSPF Graceful Restart\n"
9843 "Enable Helper support\n"
9844 "Advertising Router-ID\n")
9846 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9849 ospf_gr_helper_support_set_per_routerid(ospf
, &address
,
9854 ospf_gr_helper_support_set(ospf
, OSPF_GR_FALSE
);
9858 #if CONFDATE > 20220921
9860 "Time to remove the deprecated \"[no] graceful-restart helper-only\" commands")
9863 DEFPY_HIDDEN(ospf_gr_helper_only
, ospf_gr_helper_only_cmd
,
9864 "graceful-restart helper-only [A.B.C.D]",
9865 "OSPF Graceful Restart\n"
9866 "Enable Helper support\n"
9867 "Advertising router id\n")
9869 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9870 struct in_addr addr
;
9874 "%% This command is deprecated. Please, use `graceful-restart helper enable` instead.\n");
9877 ret
= inet_aton(argv
[2]->arg
, &addr
);
9880 "Please specify the valid routerid address.\n");
9881 return CMD_WARNING_CONFIG_FAILED
;
9884 ospf_gr_helper_support_set_per_routerid(ospf
, &addr
, OSPF_GR_TRUE
);
9888 ospf_gr_helper_support_set(ospf
, OSPF_GR_TRUE
);
9893 ALIAS_HIDDEN(no_ospf_gr_helper_enable
,
9894 no_ospf_gr_helper_only_cmd
,
9895 "no graceful-restart helper-only [A.B.C.D]",
9897 "OSPF Graceful Restart\n"
9898 "Disable Helper support\n"
9899 "Advertising router id\n")
9901 DEFPY(ospf_gr_helper_enable_lsacheck
,
9902 ospf_gr_helper_enable_lsacheck_cmd
,
9903 "graceful-restart helper strict-lsa-checking",
9904 "OSPF Graceful Restart\n"
9906 "Enable strict LSA check\n")
9908 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9910 ospf_gr_helper_lsa_check_set(ospf
, OSPF_GR_TRUE
);
9914 DEFPY(no_ospf_gr_helper_enable_lsacheck
,
9915 no_ospf_gr_helper_enable_lsacheck_cmd
,
9916 "no graceful-restart helper strict-lsa-checking",
9918 "OSPF Graceful Restart\n"
9920 "Disable strict LSA check\n")
9922 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9924 ospf_gr_helper_lsa_check_set(ospf
, OSPF_GR_FALSE
);
9928 DEFPY(ospf_gr_helper_supported_grace_time
,
9929 ospf_gr_helper_supported_grace_time_cmd
,
9930 "graceful-restart helper supported-grace-time (10-1800)$interval",
9931 "OSPF Graceful Restart\n"
9933 "Supported grace timer\n"
9934 "Grace interval(in seconds)\n")
9936 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9938 ospf_gr_helper_supported_gracetime_set(ospf
, interval
);
9942 DEFPY(no_ospf_gr_helper_supported_grace_time
,
9943 no_ospf_gr_helper_supported_grace_time_cmd
,
9944 "no graceful-restart helper supported-grace-time (10-1800)$interval",
9946 "OSPF Graceful Restart\n"
9948 "Supported grace timer\n"
9949 "Grace interval(in seconds)\n")
9951 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9953 ospf_gr_helper_supported_gracetime_set(ospf
, OSPF_MAX_GRACE_INTERVAL
);
9957 DEFPY(ospf_gr_helper_planned_only
,
9958 ospf_gr_helper_planned_only_cmd
,
9959 "graceful-restart helper planned-only",
9960 "OSPF Graceful Restart\n"
9962 "Supported only planned restart\n")
9964 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9966 ospf_gr_helper_set_supported_planned_only_restart(ospf
, OSPF_GR_TRUE
);
9971 /* External Route Aggregation */
9972 DEFUN (ospf_external_route_aggregation
,
9973 ospf_external_route_aggregation_cmd
,
9974 "summary-address A.B.C.D/M [tag (1-4294967295)]",
9975 "External summary address\n"
9976 "Summary address prefix\n"
9978 "Router tag value\n")
9980 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9981 struct prefix_ipv4 p
;
9983 route_tag_t tag
= 0;
9984 int ret
= OSPF_SUCCESS
;
9986 str2prefix_ipv4(argv
[idx
]->arg
, &p
);
9988 if (is_default_prefix4(&p
)) {
9990 "Default address shouldn't be configured as summary address.\n");
9994 /* Apply mask for given prefix. */
9995 apply_mask((struct prefix
*)&p
);
9997 if (!is_valid_summary_addr(&p
)) {
9998 vty_out(vty
, "Not a valid summary address.\n");
9999 return CMD_WARNING_CONFIG_FAILED
;
10003 tag
= strtoul(argv
[idx
+ 2]->arg
, NULL
, 10);
10005 ret
= ospf_asbr_external_aggregator_set(ospf
, &p
, tag
);
10006 if (ret
== OSPF_INVALID
)
10007 vty_out(vty
, "Invalid configuration!!\n");
10009 return CMD_SUCCESS
;
10012 DEFUN (no_ospf_external_route_aggregation
,
10013 no_ospf_external_route_aggregation_cmd
,
10014 "no summary-address A.B.C.D/M [tag (1-4294967295)]",
10016 "External summary address\n"
10017 "Summary address prefix\n"
10019 "Router tag value\n")
10021 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
10022 struct prefix_ipv4 p
;
10024 route_tag_t tag
= 0;
10025 int ret
= OSPF_SUCCESS
;
10027 str2prefix_ipv4(argv
[idx
]->arg
, &p
);
10029 if (is_default_prefix4(&p
)) {
10031 "Default address shouldn't be configured as summary address.\n");
10032 return CMD_SUCCESS
;
10035 /* Apply mask for given prefix. */
10036 apply_mask((struct prefix
*)&p
);
10038 if (!is_valid_summary_addr(&p
)) {
10039 vty_out(vty
, "Not a valid summary address.\n");
10040 return CMD_WARNING_CONFIG_FAILED
;
10044 tag
= strtoul(argv
[idx
+ 2]->arg
, NULL
, 10);
10046 ret
= ospf_asbr_external_aggregator_unset(ospf
, &p
, tag
);
10047 if (ret
== OSPF_INVALID
)
10048 vty_out(vty
, "Invalid configuration!!\n");
10050 return CMD_SUCCESS
;
10053 DEFPY(no_ospf_gr_helper_planned_only
,
10054 no_ospf_gr_helper_planned_only_cmd
,
10055 "no graceful-restart helper planned-only",
10057 "OSPF Graceful Restart\n"
10059 "Supported only for planned restart\n")
10061 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
10063 ospf_gr_helper_set_supported_planned_only_restart(ospf
, OSPF_GR_FALSE
);
10065 return CMD_SUCCESS
;
10068 static int ospf_print_vty_helper_dis_rtr_walkcb(struct hash_bucket
*bucket
,
10071 struct advRtr
*rtr
= bucket
->data
;
10072 struct vty
*vty
= (struct vty
*)arg
;
10073 static unsigned int count
;
10075 vty_out(vty
, "%-6pI4,", &rtr
->advRtrAddr
);
10078 if (count
% 5 == 0)
10079 vty_out(vty
, "\n");
10081 return HASHWALK_CONTINUE
;
10084 static int ospf_show_gr_helper_details(struct vty
*vty
, struct ospf
*ospf
,
10085 uint8_t use_vrf
, json_object
*json
,
10086 bool uj
, bool detail
)
10088 struct listnode
*node
;
10089 struct ospf_interface
*oi
;
10090 char buf
[PREFIX_STRLEN
];
10091 json_object
*json_vrf
= NULL
;
10095 json_vrf
= json_object_new_object();
10100 if (ospf
->instance
) {
10102 json_object_int_add(json
, "ospfInstance",
10105 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
10108 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
10112 json_object_object_add(json
, ospf_get_name(ospf
),
10115 vty_out(vty
, "\n");
10117 /* Show Router ID. */
10119 json_object_string_add(json_vrf
, "routerId",
10120 inet_ntop(AF_INET
, &ospf
->router_id
,
10121 buf
, sizeof(buf
)));
10123 vty_out(vty
, "\n OSPF Router with ID (%pI4)\n\n",
10129 if (ospf
->is_helper_supported
)
10131 " Graceful restart helper support enabled.\n");
10134 " Graceful restart helper support disabled.\n");
10136 if (ospf
->strict_lsa_check
)
10137 vty_out(vty
, " Strict LSA check is enabled.\n");
10139 vty_out(vty
, " Strict LSA check is disabled.\n");
10141 if (ospf
->only_planned_restart
)
10143 " Helper supported for planned restarts only.\n");
10146 " Helper supported for Planned and Unplanned Restarts.\n");
10149 " Supported Graceful restart interval: %d(in seconds).\n",
10150 ospf
->supported_grace_time
);
10152 if (OSPF_HELPER_ENABLE_RTR_COUNT(ospf
)) {
10153 vty_out(vty
, " Enable Router list:\n");
10155 hash_walk(ospf
->enable_rtr_list
,
10156 ospf_print_vty_helper_dis_rtr_walkcb
, vty
);
10157 vty_out(vty
, "\n\n");
10160 if (ospf
->last_exit_reason
!= OSPF_GR_HELPER_EXIT_NONE
) {
10161 vty_out(vty
, " Last Helper exit Reason :%s\n",
10162 ospf_exit_reason2str(ospf
->last_exit_reason
));
10165 if (ospf
->active_restarter_cnt
)
10167 " Number of Active neighbours in graceful restart: %d\n",
10168 ospf
->active_restarter_cnt
);
10170 vty_out(vty
, "\n");
10173 json_object_string_add(
10174 json_vrf
, "helperSupport",
10175 (ospf
->is_helper_supported
) ? "Enabled" : "Disabled");
10176 json_object_string_add(json_vrf
, "strictLsaCheck",
10177 (ospf
->strict_lsa_check
) ? "Enabled"
10179 json_object_string_add(
10180 json_vrf
, "restartSupoort",
10181 (ospf
->only_planned_restart
)
10182 ? "Planned Restart only"
10183 : "Planned and Unplanned Restarts");
10185 json_object_int_add(json_vrf
, "supportedGracePeriod",
10186 ospf
->supported_grace_time
);
10188 if (ospf
->last_exit_reason
!= OSPF_GR_HELPER_EXIT_NONE
)
10189 json_object_string_add(
10190 json_vrf
, "LastExitReason",
10191 ospf_exit_reason2str(ospf
->last_exit_reason
));
10193 if (ospf
->active_restarter_cnt
)
10194 json_object_int_add(json_vrf
, "activeRestarterCnt",
10195 ospf
->active_restarter_cnt
);
10201 json_object
*json_neighbors
= NULL
;
10203 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
10204 struct route_node
*rn
;
10205 struct ospf_neighbor
*nbr
;
10206 json_object
*json_neigh
;
10208 if (ospf_interface_neighbor_count(oi
) == 0)
10212 json_object_object_get_ex(json_vrf
, "Neighbors",
10214 if (!json_neighbors
) {
10216 json_object_new_object();
10217 json_object_object_add(json_vrf
,
10223 for (rn
= route_top(oi
->nbrs
); rn
;
10224 rn
= route_next(rn
)) {
10231 if (!OSPF_GR_IS_ACTIVE_HELPER(nbr
))
10235 vty_out(vty
, " Neighbour %d :\n", cnt
);
10236 vty_out(vty
, " Address : %pI4\n",
10237 &nbr
->address
.u
.prefix4
);
10238 vty_out(vty
, " Routerid : %pI4\n",
10241 " Received Grace period : %d(in seconds).\n",
10242 nbr
->gr_helper_info
10243 .recvd_grace_period
);
10245 " Actual Grace period : %d(in seconds)\n",
10246 nbr
->gr_helper_info
10247 .actual_grace_period
);
10249 " Remaining GraceTime:%ld(in seconds).\n",
10250 thread_timer_remain_second(
10251 nbr
->gr_helper_info
10254 " Graceful Restart reason: %s.\n\n",
10255 ospf_restart_reason2str(
10256 nbr
->gr_helper_info
10257 .gr_restart_reason
));
10260 json_neigh
= json_object_new_object();
10261 json_object_string_add(
10262 json_neigh
, "srcAddr",
10263 inet_ntop(AF_INET
, &nbr
->src
,
10264 buf
, sizeof(buf
)));
10266 json_object_string_add(
10267 json_neigh
, "routerid",
10270 buf
, sizeof(buf
)));
10271 json_object_int_add(
10273 "recvdGraceInterval",
10274 nbr
->gr_helper_info
10275 .recvd_grace_period
);
10276 json_object_int_add(
10278 "actualGraceInterval",
10279 nbr
->gr_helper_info
10280 .actual_grace_period
);
10281 json_object_int_add(
10282 json_neigh
, "remainGracetime",
10283 thread_timer_remain_second(
10284 nbr
->gr_helper_info
10286 json_object_string_add(
10287 json_neigh
, "restartReason",
10288 ospf_restart_reason2str(
10289 nbr
->gr_helper_info
10290 .gr_restart_reason
));
10291 json_object_object_add(
10293 inet_ntop(AF_INET
, &nbr
->src
,
10300 return CMD_SUCCESS
;
10303 DEFUN (ospf_external_route_aggregation_no_adrvertise
,
10304 ospf_external_route_aggregation_no_adrvertise_cmd
,
10305 "summary-address A.B.C.D/M no-advertise",
10306 "External summary address\n"
10307 "Summary address prefix\n"
10308 "Don't advertise summary route \n")
10310 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
10311 struct prefix_ipv4 p
;
10313 int ret
= OSPF_SUCCESS
;
10315 str2prefix_ipv4(argv
[idx
]->arg
, &p
);
10317 if (is_default_prefix4(&p
)) {
10319 "Default address shouldn't be configured as summary address.\n");
10320 return CMD_SUCCESS
;
10323 /* Apply mask for given prefix. */
10324 apply_mask((struct prefix
*)&p
);
10326 if (!is_valid_summary_addr(&p
)) {
10327 vty_out(vty
, "Not a valid summary address.\n");
10328 return CMD_WARNING_CONFIG_FAILED
;
10331 ret
= ospf_asbr_external_rt_no_advertise(ospf
, &p
);
10332 if (ret
== OSPF_INVALID
)
10333 vty_out(vty
, "Invalid configuration!!\n");
10335 return CMD_SUCCESS
;
10338 DEFUN (no_ospf_external_route_aggregation_no_adrvertise
,
10339 no_ospf_external_route_aggregation_no_adrvertise_cmd
,
10340 "no summary-address A.B.C.D/M no-advertise",
10342 "External summary address\n"
10343 "Summary address prefix\n"
10344 "Advertise summary route to the AS \n")
10346 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
10347 struct prefix_ipv4 p
;
10349 int ret
= OSPF_SUCCESS
;
10351 str2prefix_ipv4(argv
[idx
]->arg
, &p
);
10353 if (is_default_prefix4(&p
)) {
10355 "Default address shouldn't be configured as summary address.\n");
10356 return CMD_SUCCESS
;
10359 /* Apply mask for given prefix. */
10360 apply_mask((struct prefix
*)&p
);
10362 if (!is_valid_summary_addr(&p
)) {
10363 vty_out(vty
, "Not a valid summary address.\n");
10364 return CMD_WARNING_CONFIG_FAILED
;
10367 ret
= ospf_asbr_external_rt_advertise(ospf
, &p
);
10368 if (ret
== OSPF_INVALID
)
10369 vty_out(vty
, "Invalid configuration!!\n");
10371 return CMD_SUCCESS
;
10374 DEFUN (ospf_route_aggregation_timer
,
10375 ospf_route_aggregation_timer_cmd
,
10376 "aggregation timer (5-1800)",
10377 "External route aggregation\n"
10378 "Delay timer (in seconds)\n"
10379 "Timer interval(in seconds)\n")
10381 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
10382 uint16_t interval
= 0;
10384 interval
= strtoul(argv
[2]->arg
, NULL
, 10);
10386 ospf_external_aggregator_timer_set(ospf
, interval
);
10388 return CMD_SUCCESS
;
10391 DEFPY (show_ip_ospf_gr_helper
,
10392 show_ip_ospf_gr_helper_cmd
,
10393 "show ip ospf [vrf <NAME|all>] graceful-restart helper [detail] [json]",
10396 "OSPF information\n"
10399 "OSPF Graceful Restart\n"
10400 "Helper details in the router\n"
10401 "Detailed information\n"
10404 char *vrf_name
= NULL
;
10405 bool all_vrf
= false;
10406 int ret
= CMD_SUCCESS
;
10409 uint8_t use_vrf
= 0;
10410 bool uj
= use_json(argc
, argv
);
10411 struct ospf
*ospf
= NULL
;
10412 json_object
*json
= NULL
;
10413 struct listnode
*node
= NULL
;
10415 bool detail
= false;
10417 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
10419 if (argv_find(argv
, argc
, "detail", &idx
))
10423 json
= json_object_new_object();
10425 /* vrf input is provided */
10430 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
10431 if (!ospf
->oi_running
)
10434 ret
= ospf_show_gr_helper_details(
10435 vty
, ospf
, use_vrf
, json
, uj
, detail
);
10439 vty_json(vty
, json
);
10444 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
10446 if (ospf
== NULL
|| !ospf
->oi_running
) {
10449 vty_json(vty
, json
);
10451 vty_out(vty
, "%% OSPF instance not found\n");
10453 return CMD_SUCCESS
;
10458 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
10460 if (ospf
== NULL
|| !ospf
->oi_running
) {
10463 vty_json(vty
, json
);
10465 vty_out(vty
, "%% OSPF instance not found\n");
10467 return CMD_SUCCESS
;
10470 ospf_show_gr_helper_details(vty
, ospf
, use_vrf
, json
, uj
,
10475 vty_json(vty
, json
);
10477 return CMD_SUCCESS
;
10479 /* Graceful Restart HELPER commands end */
10480 DEFUN (no_ospf_route_aggregation_timer
,
10481 no_ospf_route_aggregation_timer_cmd
,
10482 "no aggregation timer",
10484 "External route aggregation\n"
10487 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
10489 ospf_external_aggregator_timer_set(ospf
, OSPF_EXTL_AGGR_DEFAULT_DELAY
);
10491 return CMD_SUCCESS
;
10494 /* External Route Aggregation End */
10496 static void config_write_stub_router(struct vty
*vty
, struct ospf
*ospf
)
10498 struct listnode
*ln
;
10499 struct ospf_area
*area
;
10501 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
10502 vty_out(vty
, " max-metric router-lsa on-startup %u\n",
10503 ospf
->stub_router_startup_time
);
10504 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
10505 vty_out(vty
, " max-metric router-lsa on-shutdown %u\n",
10506 ospf
->stub_router_shutdown_time
);
10507 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
10508 if (CHECK_FLAG(area
->stub_router_state
,
10509 OSPF_AREA_ADMIN_STUB_ROUTED
)) {
10510 vty_out(vty
, " max-metric router-lsa administrative\n");
10517 static void show_ip_ospf_route_network(struct vty
*vty
, struct ospf
*ospf
,
10518 struct route_table
*rt
,
10521 struct route_node
*rn
;
10522 struct ospf_route
* or ;
10523 struct listnode
*pnode
, *pnnode
;
10524 struct ospf_path
*path
;
10525 json_object
*json_route
= NULL
, *json_nexthop_array
= NULL
,
10526 *json_nexthop
= NULL
;
10530 "============ OSPF network routing table ============\n");
10532 for (rn
= route_top(rt
); rn
; rn
= route_next(rn
)) {
10533 char buf1
[PREFIX2STR_BUFFER
];
10535 if ((or = rn
->info
) == NULL
)
10538 prefix2str(&rn
->p
, buf1
, sizeof(buf1
));
10541 json_route
= json_object_new_object();
10542 json_object_object_add(json
, buf1
, json_route
);
10545 switch (or->path_type
) {
10546 case OSPF_PATH_INTER_AREA
:
10547 if (or->type
== OSPF_DESTINATION_NETWORK
) {
10549 json_object_string_add(json_route
,
10552 json_object_int_add(json_route
, "cost",
10554 json_object_string_addf(
10555 json_route
, "area", "%pI4",
10556 &or->u
.std
.area_id
);
10559 "N IA %-18s [%d] area: %pI4\n",
10561 &or->u
.std
.area_id
);
10563 } else if (or->type
== OSPF_DESTINATION_DISCARD
) {
10565 json_object_string_add(json_route
,
10570 "D IA %-18s Discard entry\n",
10575 case OSPF_PATH_INTRA_AREA
:
10577 json_object_string_add(json_route
, "routeType",
10579 json_object_int_add(json_route
, "cost",
10581 json_object_string_addf(json_route
, "area",
10583 &or->u
.std
.area_id
);
10585 vty_out(vty
, "N %-18s [%d] area: %pI4\n",
10587 &or->u
.std
.area_id
);
10594 if (or->type
== OSPF_DESTINATION_NETWORK
) {
10596 json_nexthop_array
= json_object_new_array();
10597 json_object_object_add(json_route
, "nexthops",
10598 json_nexthop_array
);
10601 for (ALL_LIST_ELEMENTS(or->paths
, pnode
, pnnode
,
10604 json_nexthop
= json_object_new_object();
10605 json_object_array_add(
10606 json_nexthop_array
,
10609 if (if_lookup_by_index(path
->ifindex
,
10612 if (path
->nexthop
.s_addr
10615 json_object_string_add(
10618 json_object_string_add(
10620 "directly attached to",
10626 "%24s directly attached to %s\n",
10634 json_object_string_addf(
10638 json_object_string_add(
10646 "%24s via %pI4, %s\n",
10659 vty_out(vty
, "\n");
10662 static void show_ip_ospf_route_router(struct vty
*vty
, struct ospf
*ospf
,
10663 struct route_table
*rtrs
,
10666 struct route_node
*rn
;
10667 struct ospf_route
* or ;
10668 struct listnode
*pnode
;
10669 struct listnode
*node
;
10670 struct ospf_path
*path
;
10671 char buf
[PREFIX_STRLEN
];
10672 json_object
*json_route
= NULL
, *json_nexthop_array
= NULL
,
10673 *json_nexthop
= NULL
;
10677 "============ OSPF router routing table =============\n");
10679 for (rn
= route_top(rtrs
); rn
; rn
= route_next(rn
)) {
10680 if (rn
->info
== NULL
)
10685 json_route
= json_object_new_object();
10686 json_object_object_add(
10687 json
, inet_ntop(AF_INET
, &rn
->p
.u
.prefix4
,
10690 json_object_string_add(json_route
, "routeType", "R ");
10692 vty_out(vty
, "R %-15pI4 ",
10696 for (ALL_LIST_ELEMENTS_RO((struct list
*)rn
->info
, node
, or)) {
10699 vty_out(vty
, "%24s", "");
10704 json_object_int_add(json_route
, "cost",
10706 json_object_string_addf(json_route
, "area",
10708 &or->u
.std
.area_id
);
10709 if (or->path_type
== OSPF_PATH_INTER_AREA
)
10710 json_object_boolean_true_add(json_route
,
10712 if (or->u
.std
.flags
& ROUTER_LSA_BORDER
)
10713 json_object_string_add(json_route
,
10716 else if (or->u
.std
.flags
& ROUTER_LSA_EXTERNAL
)
10717 json_object_string_add(json_route
,
10721 vty_out(vty
, "%s [%d] area: %pI4",
10722 (or->path_type
== OSPF_PATH_INTER_AREA
10725 or->cost
, &or->u
.std
.area_id
);
10727 vty_out(vty
, "%s%s\n",
10728 (or->u
.std
.flags
& ROUTER_LSA_BORDER
10731 (or->u
.std
.flags
& ROUTER_LSA_EXTERNAL
10737 json_nexthop_array
= json_object_new_array();
10738 json_object_object_add(json_route
, "nexthops",
10739 json_nexthop_array
);
10742 for (ALL_LIST_ELEMENTS_RO(or->paths
, pnode
, path
)) {
10744 json_nexthop
= json_object_new_object();
10745 json_object_array_add(
10746 json_nexthop_array
,
10749 if (if_lookup_by_index(path
->ifindex
,
10751 if (path
->nexthop
.s_addr
10754 json_object_string_add(
10757 json_object_string_add(
10759 "directly attached to",
10765 "%24s directly attached to %s\n",
10773 json_object_string_addf(
10777 json_object_string_add(
10785 "%24s via %pI4, %s\n",
10798 vty_out(vty
, "\n");
10801 static void show_ip_ospf_route_external(struct vty
*vty
, struct ospf
*ospf
,
10802 struct route_table
*rt
,
10805 struct route_node
*rn
;
10806 struct ospf_route
*er
;
10807 struct listnode
*pnode
, *pnnode
;
10808 struct ospf_path
*path
;
10809 json_object
*json_route
= NULL
, *json_nexthop_array
= NULL
,
10810 *json_nexthop
= NULL
;
10814 "============ OSPF external routing table ===========\n");
10816 for (rn
= route_top(rt
); rn
; rn
= route_next(rn
)) {
10817 if ((er
= rn
->info
) == NULL
)
10822 snprintfrr(buf1
, sizeof(buf1
), "%pFX", &rn
->p
);
10824 json_route
= json_object_new_object();
10825 json_object_object_add(json
, buf1
, json_route
);
10828 switch (er
->path_type
) {
10829 case OSPF_PATH_TYPE1_EXTERNAL
:
10831 json_object_string_add(json_route
, "routeType",
10833 json_object_int_add(json_route
, "cost",
10835 json_object_int_add(json_route
, "tag",
10839 "N E1 %-18s [%d] tag: %" ROUTE_TAG_PRI
10841 buf1
, er
->cost
, er
->u
.ext
.tag
);
10844 case OSPF_PATH_TYPE2_EXTERNAL
:
10846 json_object_string_add(json_route
, "routeType",
10848 json_object_int_add(json_route
, "cost",
10850 json_object_int_add(json_route
, "type2cost",
10851 er
->u
.ext
.type2_cost
);
10852 json_object_int_add(json_route
, "tag",
10856 "N E2 %-18s [%d/%d] tag: %" ROUTE_TAG_PRI
10858 buf1
, er
->cost
, er
->u
.ext
.type2_cost
,
10865 json_nexthop_array
= json_object_new_array();
10866 json_object_object_add(json_route
, "nexthops",
10867 json_nexthop_array
);
10870 for (ALL_LIST_ELEMENTS(er
->paths
, pnode
, pnnode
, path
)) {
10872 json_nexthop
= json_object_new_object();
10873 json_object_array_add(json_nexthop_array
,
10877 if (if_lookup_by_index(path
->ifindex
, ospf
->vrf_id
)) {
10878 if (path
->nexthop
.s_addr
== INADDR_ANY
) {
10880 json_object_string_add(
10881 json_nexthop
, "ip",
10883 json_object_string_add(
10885 "directly attached to",
10891 "%24s directly attached to %s\n",
10899 json_object_string_addf(
10900 json_nexthop
, "ip",
10901 "%pI4", &path
->nexthop
);
10902 json_object_string_add(
10903 json_nexthop
, "via",
10909 "%24s via %pI4, %s\n",
10921 vty_out(vty
, "\n");
10924 static int show_ip_ospf_border_routers_common(struct vty
*vty
,
10928 if (ospf
->instance
)
10929 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
10931 ospf_show_vrf_name(ospf
, vty
, NULL
, use_vrf
);
10933 if (ospf
->new_table
== NULL
) {
10934 vty_out(vty
, "No OSPF routing information exist\n");
10935 return CMD_SUCCESS
;
10938 /* Show Network routes.
10939 show_ip_ospf_route_network (vty, ospf->new_table); */
10941 /* Show Router routes. */
10942 show_ip_ospf_route_router(vty
, ospf
, ospf
->new_rtrs
, NULL
);
10944 vty_out(vty
, "\n");
10946 return CMD_SUCCESS
;
10949 DEFUN (show_ip_ospf_border_routers
,
10950 show_ip_ospf_border_routers_cmd
,
10951 "show ip ospf [vrf <NAME|all>] border-routers",
10954 "OSPF information\n"
10957 "Show all the ABR's and ASBR's\n")
10959 struct ospf
*ospf
= NULL
;
10960 struct listnode
*node
= NULL
;
10961 char *vrf_name
= NULL
;
10962 bool all_vrf
= false;
10963 int ret
= CMD_SUCCESS
;
10966 uint8_t use_vrf
= 0;
10968 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
10971 bool ospf_output
= false;
10976 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
10977 if (!ospf
->oi_running
)
10980 ospf_output
= true;
10981 ret
= show_ip_ospf_border_routers_common(
10982 vty
, ospf
, use_vrf
);
10986 vty_out(vty
, "%% OSPF instance not found\n");
10988 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
10989 if (ospf
== NULL
|| !ospf
->oi_running
) {
10990 vty_out(vty
, "%% OSPF instance not found\n");
10991 return CMD_SUCCESS
;
10994 ret
= show_ip_ospf_border_routers_common(vty
, ospf
,
10998 /* Display default ospf (instance 0) info */
10999 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
11000 if (ospf
== NULL
|| !ospf
->oi_running
) {
11001 vty_out(vty
, "%% OSPF instance not found\n");
11002 return CMD_SUCCESS
;
11005 ret
= show_ip_ospf_border_routers_common(vty
, ospf
, use_vrf
);
11011 DEFUN (show_ip_ospf_instance_border_routers
,
11012 show_ip_ospf_instance_border_routers_cmd
,
11013 "show ip ospf (1-65535) border-routers",
11016 "OSPF information\n"
11018 "Show all the ABR's and ASBR's\n")
11020 int idx_number
= 3;
11022 unsigned short instance
= 0;
11024 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11025 if (instance
!= ospf_instance
)
11026 return CMD_NOT_MY_INSTANCE
;
11028 ospf
= ospf_lookup_instance(instance
);
11029 if (!ospf
|| !ospf
->oi_running
)
11030 return CMD_SUCCESS
;
11032 return show_ip_ospf_border_routers_common(vty
, ospf
, 0);
11035 static int show_ip_ospf_route_common(struct vty
*vty
, struct ospf
*ospf
,
11036 json_object
*json
, uint8_t use_vrf
)
11038 json_object
*json_vrf
= NULL
;
11040 if (ospf
->instance
)
11041 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
11046 json_vrf
= json_object_new_object();
11051 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
11053 if (ospf
->new_table
== NULL
) {
11054 vty_out(vty
, "No OSPF routing information exist\n");
11055 return CMD_SUCCESS
;
11058 /* Show Network routes. */
11059 show_ip_ospf_route_network(vty
, ospf
, ospf
->new_table
, json_vrf
);
11061 /* Show Router routes. */
11062 show_ip_ospf_route_router(vty
, ospf
, ospf
->new_rtrs
, json_vrf
);
11064 /* Show AS External routes. */
11065 show_ip_ospf_route_external(vty
, ospf
, ospf
->old_external_route
,
11070 // json_object_object_add(json_vrf, "areas",
11072 json_object_object_add(json
, ospf_get_name(ospf
),
11076 vty_out(vty
, "\n");
11079 return CMD_SUCCESS
;
11082 DEFUN (show_ip_ospf_route
,
11083 show_ip_ospf_route_cmd
,
11084 "show ip ospf [vrf <NAME|all>] route [json]",
11087 "OSPF information\n"
11090 "OSPF routing table\n"
11093 struct ospf
*ospf
= NULL
;
11094 struct listnode
*node
= NULL
;
11095 char *vrf_name
= NULL
;
11096 bool all_vrf
= false;
11097 int ret
= CMD_SUCCESS
;
11100 uint8_t use_vrf
= 0;
11101 bool uj
= use_json(argc
, argv
);
11102 json_object
*json
= NULL
;
11105 json
= json_object_new_object();
11107 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
11109 /* vrf input is provided could be all or specific vrf*/
11111 bool ospf_output
= false;
11116 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
11117 if (!ospf
->oi_running
)
11119 ospf_output
= true;
11120 ret
= show_ip_ospf_route_common(vty
, ospf
, json
,
11125 /* Keep Non-pretty format */
11126 vty_json(vty
, json
);
11127 } else if (!ospf_output
)
11128 vty_out(vty
, "%% OSPF instance not found\n");
11132 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
11133 if (ospf
== NULL
|| !ospf
->oi_running
) {
11135 vty_json(vty
, json
);
11137 vty_out(vty
, "%% OSPF instance not found\n");
11139 return CMD_SUCCESS
;
11142 /* Display default ospf (instance 0) info */
11143 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
11144 if (ospf
== NULL
|| !ospf
->oi_running
) {
11146 vty_json(vty
, json
);
11148 vty_out(vty
, "%% OSPF instance not found\n");
11150 return CMD_SUCCESS
;
11155 ret
= show_ip_ospf_route_common(vty
, ospf
, json
, use_vrf
);
11156 /* Keep Non-pretty format */
11158 vty_out(vty
, "%s\n",
11159 json_object_to_json_string_ext(
11160 json
, JSON_C_TO_STRING_NOSLASHESCAPE
));
11164 json_object_free(json
);
11169 DEFUN (show_ip_ospf_instance_route
,
11170 show_ip_ospf_instance_route_cmd
,
11171 "show ip ospf (1-65535) route",
11174 "OSPF information\n"
11176 "OSPF routing table\n")
11178 int idx_number
= 3;
11180 unsigned short instance
= 0;
11182 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11183 if (instance
!= ospf_instance
)
11184 return CMD_NOT_MY_INSTANCE
;
11186 ospf
= ospf_lookup_instance(instance
);
11187 if (!ospf
|| !ospf
->oi_running
)
11188 return CMD_SUCCESS
;
11190 return show_ip_ospf_route_common(vty
, ospf
, NULL
, 0);
11194 DEFUN (show_ip_ospf_vrfs
,
11195 show_ip_ospf_vrfs_cmd
,
11196 "show ip ospf vrfs [json]",
11199 "OSPF information\n"
11200 "Show OSPF VRFs \n"
11203 bool uj
= use_json(argc
, argv
);
11204 json_object
*json
= NULL
;
11205 json_object
*json_vrfs
= NULL
;
11206 struct ospf
*ospf
= NULL
;
11207 struct listnode
*node
= NULL
;
11209 static const char header
[] = "Name Id RouterId ";
11212 json
= json_object_new_object();
11213 json_vrfs
= json_object_new_object();
11216 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
11217 json_object
*json_vrf
= NULL
;
11218 const char *name
= NULL
;
11219 int64_t vrf_id_ui
= 0;
11223 if (!uj
&& count
== 1)
11224 vty_out(vty
, "%s\n", header
);
11226 json_vrf
= json_object_new_object();
11228 name
= ospf_get_name(ospf
);
11230 vrf_id_ui
= (ospf
->vrf_id
== VRF_UNKNOWN
)
11232 : (int64_t)ospf
->vrf_id
;
11235 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
11236 json_object_string_addf(json_vrf
, "routerId", "%pI4",
11239 json_object_object_add(json_vrfs
, name
, json_vrf
);
11242 vty_out(vty
, "%-25s %-5d %-16pI4 \n", name
,
11243 ospf
->vrf_id
, &ospf
->router_id
);
11248 json_object_object_add(json
, "vrfs", json_vrfs
);
11249 json_object_int_add(json
, "totalVrfs", count
);
11251 vty_json(vty
, json
);
11254 vty_out(vty
, "\nTotal number of OSPF VRFs: %d\n",
11258 return CMD_SUCCESS
;
11260 DEFPY (clear_ip_ospf_neighbor
,
11261 clear_ip_ospf_neighbor_cmd
,
11262 "clear ip ospf [(1-65535)]$instance neighbor [A.B.C.D$nbr_id]",
11265 "OSPF information\n"
11267 "Reset OSPF Neighbor\n"
11270 struct listnode
*node
;
11271 struct ospf
*ospf
= NULL
;
11273 /* If user does not specify the arguments,
11274 * instance = 0 and nbr_id = 0.0.0.0
11276 if (instance
!= 0) {
11277 /* This means clear only the particular ospf process */
11278 if (instance
!= ospf_instance
)
11279 return CMD_NOT_MY_INSTANCE
;
11282 /* Clear all the ospf processes */
11283 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
11284 if (!ospf
->oi_running
)
11287 if (nbr_id_str
&& IPV4_ADDR_SAME(&ospf
->router_id
, &nbr_id
)) {
11288 vty_out(vty
, "Self router-id is not allowed.\r\n ");
11289 return CMD_SUCCESS
;
11292 ospf_neighbor_reset(ospf
, nbr_id
, nbr_id_str
);
11295 return CMD_SUCCESS
;
11298 DEFPY (clear_ip_ospf_process
,
11299 clear_ip_ospf_process_cmd
,
11300 "clear ip ospf [(1-65535)]$instance process",
11303 "OSPF information\n"
11305 "Reset OSPF Process\n")
11307 struct listnode
*node
;
11308 struct ospf
*ospf
= NULL
;
11310 /* Check if instance is not passed as an argument */
11311 if (instance
!= 0) {
11312 /* This means clear only the particular ospf process */
11313 if (instance
!= ospf_instance
)
11314 return CMD_NOT_MY_INSTANCE
;
11317 /* Clear all the ospf processes */
11318 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
11319 if (!ospf
->oi_running
)
11322 ospf_process_reset(ospf
);
11325 return CMD_SUCCESS
;
11328 static const char *const ospf_abr_type_str
[] = {
11329 "unknown", "standard", "ibm", "cisco", "shortcut"
11332 static const char *const ospf_shortcut_mode_str
[] = {
11333 "default", "enable", "disable"
11335 static int ospf_vty_external_rt_walkcb(struct hash_bucket
*bucket
,
11338 struct external_info
*ei
= bucket
->data
;
11339 struct vty
*vty
= (struct vty
*)arg
;
11340 static unsigned int count
;
11342 vty_out(vty
, "%-4pI4/%d, ", &ei
->p
.prefix
, ei
->p
.prefixlen
);
11345 if (count
% 5 == 0)
11346 vty_out(vty
, "\n");
11348 if (OSPF_EXTERNAL_RT_COUNT(ei
->aggr_route
) == count
)
11351 return HASHWALK_CONTINUE
;
11354 static int ospf_json_external_rt_walkcb(struct hash_bucket
*bucket
,
11357 struct external_info
*ei
= bucket
->data
;
11358 struct json_object
*json
= (struct json_object
*)arg
;
11359 char buf
[PREFIX2STR_BUFFER
];
11361 static unsigned int count
;
11363 prefix2str(&ei
->p
, buf
, sizeof(buf
));
11365 snprintf(exnalbuf
, 20, "Exnl Addr-%d", count
);
11367 json_object_string_add(json
, exnalbuf
, buf
);
11371 if (OSPF_EXTERNAL_RT_COUNT(ei
->aggr_route
) == count
)
11374 return HASHWALK_CONTINUE
;
11377 static int ospf_show_summary_address(struct vty
*vty
, struct ospf
*ospf
,
11378 uint8_t use_vrf
, json_object
*json
,
11379 bool uj
, bool detail
)
11381 struct route_node
*rn
;
11382 json_object
*json_vrf
= NULL
;
11385 static char header
[] =
11386 "Summary-address Metric-type Metric Tag External_Rt_count\n";
11388 mtype
= metric_type(ospf
, 0, ospf
->instance
);
11389 mval
= metric_value(ospf
, 0, ospf
->instance
);
11392 vty_out(vty
, "%s\n", header
);
11396 json_vrf
= json_object_new_object();
11401 if (ospf
->instance
) {
11403 json_object_int_add(json
, "ospfInstance",
11406 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
11409 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
11412 vty_out(vty
, "aggregation delay interval :%u(in seconds)\n\n",
11413 ospf
->aggr_delay_interval
);
11415 json_object_int_add(json_vrf
, "aggregation delay interval",
11416 ospf
->aggr_delay_interval
);
11418 for (rn
= route_top(ospf
->rt_aggr_tbl
); rn
; rn
= route_next(rn
))
11420 struct ospf_external_aggr_rt
*aggr
= rn
->info
;
11421 json_object
*json_aggr
= NULL
;
11422 char buf
[PREFIX2STR_BUFFER
];
11424 prefix2str(&aggr
->p
, buf
, sizeof(buf
));
11428 json_aggr
= json_object_new_object();
11430 json_object_object_add(json_vrf
, buf
,
11433 json_object_string_add(json_aggr
,
11434 "Summary address", buf
);
11436 json_object_string_add(
11437 json_aggr
, "Metric-type",
11438 (mtype
== EXTERNAL_METRIC_TYPE_1
)
11442 json_object_int_add(json_aggr
, "Metric", mval
);
11444 json_object_int_add(json_aggr
, "Tag",
11447 json_object_int_add(
11448 json_aggr
, "External route count",
11449 OSPF_EXTERNAL_RT_COUNT(aggr
));
11451 if (OSPF_EXTERNAL_RT_COUNT(aggr
) && detail
) {
11453 aggr
->match_extnl_hash
,
11454 ospf_json_external_rt_walkcb
,
11459 vty_out(vty
, "%-20s", buf
);
11461 (mtype
== EXTERNAL_METRIC_TYPE_1
)
11462 ? vty_out(vty
, "%-16s", "E1")
11463 : vty_out(vty
, "%-16s", "E2");
11464 vty_out(vty
, "%-11d", mval
);
11466 vty_out(vty
, "%-12u", aggr
->tag
);
11468 vty_out(vty
, "%-5ld\n",
11469 OSPF_EXTERNAL_RT_COUNT(aggr
));
11471 if (OSPF_EXTERNAL_RT_COUNT(aggr
) && detail
) {
11473 "Matched External routes:\n");
11475 aggr
->match_extnl_hash
,
11476 ospf_vty_external_rt_walkcb
,
11478 vty_out(vty
, "\n");
11481 vty_out(vty
, "\n");
11487 json_object_object_add(json
, ospf_get_name(ospf
),
11490 vty_out(vty
, "\n");
11492 return CMD_SUCCESS
;
11495 DEFUN (show_ip_ospf_external_aggregator
,
11496 show_ip_ospf_external_aggregator_cmd
,
11497 "show ip ospf [vrf <NAME|all>] summary-address [detail] [json]",
11499 "OSPF information\n"
11502 "Show external summary addresses\n"
11503 "Detailed information\n"
11506 char *vrf_name
= NULL
;
11507 bool all_vrf
= false;
11508 int ret
= CMD_SUCCESS
;
11511 uint8_t use_vrf
= 0;
11512 bool uj
= use_json(argc
, argv
);
11513 struct ospf
*ospf
= NULL
;
11514 json_object
*json
= NULL
;
11515 struct listnode
*node
= NULL
;
11517 bool detail
= false;
11519 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
11521 if (argv_find(argv
, argc
, "detail", &idx
))
11525 json
= json_object_new_object();
11527 /* vrf input is provided */
11531 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
11532 if (!ospf
->oi_running
)
11534 ret
= ospf_show_summary_address(
11535 vty
, ospf
, use_vrf
, json
, uj
, detail
);
11539 vty_json(vty
, json
);
11544 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
11546 if (ospf
== NULL
|| !ospf
->oi_running
) {
11548 vty_json(vty
, json
);
11550 vty_out(vty
, "%% OSPF instance not found\n");
11552 return CMD_SUCCESS
;
11554 ospf_show_summary_address(vty
, ospf
, use_vrf
, json
, uj
, detail
);
11558 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
11559 if (ospf
== NULL
|| !ospf
->oi_running
) {
11561 vty_json(vty
, json
);
11563 vty_out(vty
, "%% OSPF instance not found\n");
11565 return CMD_SUCCESS
;
11568 ospf_show_summary_address(vty
, ospf
, use_vrf
, json
, uj
, detail
);
11572 vty_json(vty
, json
);
11573 return CMD_SUCCESS
;
11576 static const char *const ospf_int_type_str
[] = {
11577 "unknown", /* should never be used. */
11581 "point-to-multipoint",
11582 "virtual-link", /* should never be used. */
11586 static const char *interface_config_auth_str(struct ospf_if_params
*params
)
11588 if (!OSPF_IF_PARAM_CONFIGURED(params
, auth_type
)
11589 || params
->auth_type
== OSPF_AUTH_NOTSET
)
11592 /* Translation tables are not that much help
11593 * here due to syntax
11594 * of the simple option */
11595 switch (params
->auth_type
) {
11597 case OSPF_AUTH_NULL
:
11600 case OSPF_AUTH_SIMPLE
:
11603 case OSPF_AUTH_CRYPTOGRAPHIC
:
11604 return " message-digest";
11610 static int config_write_interface_one(struct vty
*vty
, struct vrf
*vrf
)
11612 struct listnode
*node
;
11613 struct interface
*ifp
;
11614 struct crypt_key
*ck
;
11615 struct route_node
*rn
= NULL
;
11616 struct ospf_if_params
*params
;
11617 const char *auth_str
;
11620 FOR_ALL_INTERFACES (vrf
, ifp
) {
11622 if (memcmp(ifp
->name
, "VLINK", 5) == 0)
11625 if_vty_config_start(vty
, ifp
);
11628 vty_out(vty
, " description %s\n", ifp
->desc
);
11632 params
= IF_DEF_PARAMS(ifp
);
11635 /* Interface Network print. */
11636 if (OSPF_IF_PARAM_CONFIGURED(params
, type
)
11637 && params
->type
!= OSPF_IFTYPE_LOOPBACK
) {
11638 if (params
->type
!= ospf_default_iftype(ifp
)) {
11639 vty_out(vty
, " ip ospf network %s",
11643 == OSPF_IFTYPE_POINTOPOINT
11644 && params
->ptp_dmvpn
)
11645 vty_out(vty
, " dmvpn");
11646 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11647 vty_out(vty
, " %pI4",
11649 vty_out(vty
, "\n");
11653 /* OSPF interface authentication print */
11654 auth_str
= interface_config_auth_str(params
);
11656 vty_out(vty
, " ip ospf authentication%s",
11658 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11659 vty_out(vty
, " %pI4",
11661 vty_out(vty
, "\n");
11664 /* Simple Authentication Password print. */
11665 if (OSPF_IF_PARAM_CONFIGURED(params
, auth_simple
)
11666 && params
->auth_simple
[0] != '\0') {
11667 vty_out(vty
, " ip ospf authentication-key %s",
11668 params
->auth_simple
);
11669 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11670 vty_out(vty
, " %pI4",
11672 vty_out(vty
, "\n");
11675 /* Cryptographic Authentication Key print. */
11676 if (params
&& params
->auth_crypt
) {
11677 for (ALL_LIST_ELEMENTS_RO(params
->auth_crypt
,
11680 " ip ospf message-digest-key %d md5 %s",
11681 ck
->key_id
, ck
->auth_key
);
11682 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11683 vty_out(vty
, " %pI4",
11685 vty_out(vty
, "\n");
11689 /* Interface Output Cost print. */
11690 if (OSPF_IF_PARAM_CONFIGURED(params
, output_cost_cmd
)) {
11691 vty_out(vty
, " ip ospf cost %u",
11692 params
->output_cost_cmd
);
11693 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11694 vty_out(vty
, " %pI4",
11696 vty_out(vty
, "\n");
11699 /* Hello Interval print. */
11700 if (OSPF_IF_PARAM_CONFIGURED(params
, v_hello
)
11701 && params
->v_hello
!= OSPF_HELLO_INTERVAL_DEFAULT
) {
11702 vty_out(vty
, " ip ospf hello-interval %u",
11704 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11705 vty_out(vty
, " %pI4",
11707 vty_out(vty
, "\n");
11711 /* Router Dead Interval print. */
11712 if (OSPF_IF_PARAM_CONFIGURED(params
, v_wait
)
11713 && params
->is_v_wait_set
) {
11714 vty_out(vty
, " ip ospf dead-interval ");
11717 if (OSPF_IF_PARAM_CONFIGURED(params
,
11720 "minimal hello-multiplier %d",
11721 params
->fast_hello
);
11723 vty_out(vty
, "%u", params
->v_wait
);
11725 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11726 vty_out(vty
, " %pI4",
11728 vty_out(vty
, "\n");
11731 /* Router Priority print. */
11732 if (OSPF_IF_PARAM_CONFIGURED(params
, priority
)
11733 && params
->priority
11734 != OSPF_ROUTER_PRIORITY_DEFAULT
) {
11735 vty_out(vty
, " ip ospf priority %u",
11737 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11738 vty_out(vty
, " %pI4",
11740 vty_out(vty
, "\n");
11743 /* Retransmit Interval print. */
11744 if (OSPF_IF_PARAM_CONFIGURED(params
,
11745 retransmit_interval
)
11746 && params
->retransmit_interval
11747 != OSPF_RETRANSMIT_INTERVAL_DEFAULT
) {
11748 vty_out(vty
, " ip ospf retransmit-interval %u",
11749 params
->retransmit_interval
);
11750 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11751 vty_out(vty
, " %pI4",
11753 vty_out(vty
, "\n");
11756 /* Transmit Delay print. */
11757 if (OSPF_IF_PARAM_CONFIGURED(params
, transmit_delay
)
11758 && params
->transmit_delay
11759 != OSPF_TRANSMIT_DELAY_DEFAULT
) {
11760 vty_out(vty
, " ip ospf transmit-delay %u",
11761 params
->transmit_delay
);
11762 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11763 vty_out(vty
, " %pI4",
11765 vty_out(vty
, "\n");
11769 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
11771 vty_out(vty
, " ip ospf %d",
11774 vty_out(vty
, " ip ospf");
11776 char buf
[INET_ADDRSTRLEN
];
11778 area_id2str(buf
, sizeof(buf
), ¶ms
->if_area
,
11779 params
->if_area_id_fmt
);
11780 vty_out(vty
, " area %s", buf
);
11781 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11782 vty_out(vty
, " %pI4",
11784 vty_out(vty
, "\n");
11788 if (params
&& params
->bfd_config
)
11789 ospf_bfd_write_config(vty
, params
);
11791 /* MTU ignore print. */
11792 if (OSPF_IF_PARAM_CONFIGURED(params
, mtu_ignore
)
11793 && params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
) {
11794 if (params
->mtu_ignore
== 0)
11795 vty_out(vty
, " no ip ospf mtu-ignore");
11797 vty_out(vty
, " ip ospf mtu-ignore");
11798 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11799 vty_out(vty
, " %pI4",
11801 vty_out(vty
, "\n");
11804 if (OSPF_IF_PARAM_CONFIGURED(params
,
11805 passive_interface
)) {
11806 vty_out(vty
, " %sip ospf passive",
11807 params
->passive_interface
11811 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11812 vty_out(vty
, " %pI4", &rn
->p
.u
.prefix4
);
11813 vty_out(vty
, "\n");
11816 /* LDP-Sync print */
11817 if (params
&& params
->ldp_sync_info
)
11818 ospf_ldp_sync_if_write_config(vty
, params
);
11822 rn
= route_top(IF_OIFS_PARAMS(ifp
));
11824 rn
= route_next(rn
);
11829 if (params
!= NULL
)
11834 ospf_opaque_config_write_if(vty
, ifp
);
11836 if_vty_config_end(vty
);
11842 /* Configuration write function for ospfd. */
11843 static int config_write_interface(struct vty
*vty
)
11846 struct vrf
*vrf
= NULL
;
11848 /* Display all VRF aware OSPF interface configuration */
11849 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
11850 write
+= config_write_interface_one(vty
, vrf
);
11856 static int config_write_network_area(struct vty
*vty
, struct ospf
*ospf
)
11858 struct route_node
*rn
;
11859 char buf
[INET_ADDRSTRLEN
];
11861 /* `network area' print. */
11862 for (rn
= route_top(ospf
->networks
); rn
; rn
= route_next(rn
))
11864 struct ospf_network
*n
= rn
->info
;
11866 /* Create Area ID string by specified Area ID format. */
11867 if (n
->area_id_fmt
== OSPF_AREA_ID_FMT_DOTTEDQUAD
)
11868 inet_ntop(AF_INET
, &n
->area_id
, buf
,
11871 snprintf(buf
, sizeof(buf
), "%lu",
11872 (unsigned long int)ntohl(
11873 n
->area_id
.s_addr
));
11875 /* Network print. */
11876 vty_out(vty
, " network %pFX area %s\n", &rn
->p
, buf
);
11882 static int config_write_ospf_area(struct vty
*vty
, struct ospf
*ospf
)
11884 struct listnode
*node
;
11885 struct ospf_area
*area
;
11886 char buf
[INET_ADDRSTRLEN
];
11888 /* Area configuration print. */
11889 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
11890 struct route_node
*rn1
;
11892 area_id2str(buf
, sizeof(buf
), &area
->area_id
,
11893 area
->area_id_fmt
);
11895 if (area
->auth_type
!= OSPF_AUTH_NULL
) {
11896 if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
11897 vty_out(vty
, " area %s authentication\n", buf
);
11900 " area %s authentication message-digest\n",
11904 if (area
->shortcut_configured
!= OSPF_SHORTCUT_DEFAULT
)
11905 vty_out(vty
, " area %s shortcut %s\n", buf
,
11906 ospf_shortcut_mode_str
11907 [area
->shortcut_configured
]);
11909 if ((area
->external_routing
== OSPF_AREA_STUB
)
11910 || (area
->external_routing
== OSPF_AREA_NSSA
)) {
11911 if (area
->external_routing
== OSPF_AREA_STUB
) {
11912 vty_out(vty
, " area %s stub", buf
);
11913 if (area
->no_summary
)
11914 vty_out(vty
, " no-summary\n");
11915 vty_out(vty
, "\n");
11916 } else if (area
->external_routing
== OSPF_AREA_NSSA
) {
11917 switch (area
->NSSATranslatorRole
) {
11918 case OSPF_NSSA_ROLE_NEVER
:
11920 " area %s nssa translate-never\n",
11923 case OSPF_NSSA_ROLE_ALWAYS
:
11925 " area %s nssa translate-always\n",
11928 case OSPF_NSSA_ROLE_CANDIDATE
:
11929 vty_out(vty
, " area %s nssa \n", buf
);
11932 if (area
->no_summary
)
11934 " area %s nssa no-summary\n",
11936 if (area
->suppress_fa
)
11938 " area %s nssa suppress-fa\n",
11942 if (area
->default_cost
!= 1)
11943 vty_out(vty
, " area %s default-cost %d\n", buf
,
11944 area
->default_cost
);
11947 for (rn1
= route_top(area
->ranges
); rn1
; rn1
= route_next(rn1
))
11949 struct ospf_area_range
*range
= rn1
->info
;
11951 vty_out(vty
, " area %s range %pFX", buf
,
11954 if (range
->cost_config
11955 != OSPF_AREA_RANGE_COST_UNSPEC
)
11956 vty_out(vty
, " cost %d",
11957 range
->cost_config
);
11959 if (!CHECK_FLAG(range
->flags
,
11960 OSPF_AREA_RANGE_ADVERTISE
))
11961 vty_out(vty
, " not-advertise");
11963 if (CHECK_FLAG(range
->flags
,
11964 OSPF_AREA_RANGE_SUBSTITUTE
))
11965 vty_out(vty
, " substitute %pI4/%d",
11966 &range
->subst_addr
,
11967 range
->subst_masklen
);
11969 vty_out(vty
, "\n");
11972 if (EXPORT_NAME(area
))
11973 vty_out(vty
, " area %s export-list %s\n", buf
,
11974 EXPORT_NAME(area
));
11976 if (IMPORT_NAME(area
))
11977 vty_out(vty
, " area %s import-list %s\n", buf
,
11978 IMPORT_NAME(area
));
11980 if (PREFIX_NAME_IN(area
))
11981 vty_out(vty
, " area %s filter-list prefix %s in\n", buf
,
11982 PREFIX_NAME_IN(area
));
11984 if (PREFIX_NAME_OUT(area
))
11985 vty_out(vty
, " area %s filter-list prefix %s out\n",
11986 buf
, PREFIX_NAME_OUT(area
));
11992 static int config_write_ospf_nbr_nbma(struct vty
*vty
, struct ospf
*ospf
)
11994 struct ospf_nbr_nbma
*nbr_nbma
;
11995 struct route_node
*rn
;
11997 /* Static Neighbor configuration print. */
11998 for (rn
= route_top(ospf
->nbr_nbma
); rn
; rn
= route_next(rn
))
11999 if ((nbr_nbma
= rn
->info
)) {
12000 vty_out(vty
, " neighbor %pI4", &nbr_nbma
->addr
);
12002 if (nbr_nbma
->priority
12003 != OSPF_NEIGHBOR_PRIORITY_DEFAULT
)
12004 vty_out(vty
, " priority %d",
12005 nbr_nbma
->priority
);
12007 if (nbr_nbma
->v_poll
!= OSPF_POLL_INTERVAL_DEFAULT
)
12008 vty_out(vty
, " poll-interval %d",
12011 vty_out(vty
, "\n");
12017 static int config_write_virtual_link(struct vty
*vty
, struct ospf
*ospf
)
12019 struct listnode
*node
;
12020 struct ospf_vl_data
*vl_data
;
12021 const char *auth_str
;
12022 char buf
[INET_ADDRSTRLEN
];
12024 /* Virtual-Link print */
12025 for (ALL_LIST_ELEMENTS_RO(ospf
->vlinks
, node
, vl_data
)) {
12026 struct listnode
*n2
;
12027 struct crypt_key
*ck
;
12028 struct ospf_interface
*oi
;
12030 if (vl_data
!= NULL
) {
12031 area_id2str(buf
, sizeof(buf
), &vl_data
->vl_area_id
,
12032 vl_data
->vl_area_id_fmt
);
12033 oi
= vl_data
->vl_oi
;
12036 if (OSPF_IF_PARAM(oi
, v_hello
)
12037 != OSPF_HELLO_INTERVAL_DEFAULT
12038 || OSPF_IF_PARAM(oi
, v_wait
)
12039 != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
12040 || OSPF_IF_PARAM(oi
, retransmit_interval
)
12041 != OSPF_RETRANSMIT_INTERVAL_DEFAULT
12042 || OSPF_IF_PARAM(oi
, transmit_delay
)
12043 != OSPF_TRANSMIT_DELAY_DEFAULT
)
12045 " area %s virtual-link %pI4 hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d\n",
12046 buf
, &vl_data
->vl_peer
,
12047 OSPF_IF_PARAM(oi
, v_hello
),
12048 OSPF_IF_PARAM(oi
, retransmit_interval
),
12049 OSPF_IF_PARAM(oi
, transmit_delay
),
12050 OSPF_IF_PARAM(oi
, v_wait
));
12052 vty_out(vty
, " area %s virtual-link %pI4\n", buf
,
12053 &vl_data
->vl_peer
);
12055 auth_str
= interface_config_auth_str(
12056 IF_DEF_PARAMS(oi
->ifp
));
12059 " area %s virtual-link %pI4 authentication%s\n",
12060 buf
, &vl_data
->vl_peer
, auth_str
);
12062 if (IF_DEF_PARAMS(vl_data
->vl_oi
->ifp
)->auth_simple
[0]
12065 " area %s virtual-link %pI4 authentication-key %s\n",
12066 buf
, &vl_data
->vl_peer
,
12067 IF_DEF_PARAMS(vl_data
->vl_oi
->ifp
)
12070 for (ALL_LIST_ELEMENTS_RO(
12071 IF_DEF_PARAMS(vl_data
->vl_oi
->ifp
)
12075 " area %s virtual-link %pI4 message-digest-key %d md5 %s\n",
12076 buf
, &vl_data
->vl_peer
,
12077 ck
->key_id
, ck
->auth_key
);
12085 static int config_write_ospf_redistribute(struct vty
*vty
, struct ospf
*ospf
)
12089 /* redistribute print. */
12090 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++) {
12091 struct list
*red_list
;
12092 struct listnode
*node
;
12093 struct ospf_redist
*red
;
12095 red_list
= ospf
->redist
[type
];
12099 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
12100 vty_out(vty
, " redistribute %s",
12101 zebra_route_string(type
));
12103 vty_out(vty
, " %d", red
->instance
);
12105 if (red
->dmetric
.value
>= 0)
12106 vty_out(vty
, " metric %d", red
->dmetric
.value
);
12108 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
12109 vty_out(vty
, " metric-type 1");
12111 if (ROUTEMAP_NAME(red
))
12112 vty_out(vty
, " route-map %s",
12113 ROUTEMAP_NAME(red
));
12115 vty_out(vty
, "\n");
12122 static int ospf_cfg_write_helper_dis_rtr_walkcb(struct hash_bucket
*bucket
,
12125 struct advRtr
*rtr
= bucket
->data
;
12126 struct vty
*vty
= (struct vty
*)arg
;
12128 vty_out(vty
, " graceful-restart helper enable %pI4\n",
12130 return HASHWALK_CONTINUE
;
12133 static void config_write_ospf_gr(struct vty
*vty
, struct ospf
*ospf
)
12135 if (!ospf
->gr_info
.restart_support
)
12138 if (ospf
->gr_info
.grace_period
== OSPF_DFLT_GRACE_INTERVAL
)
12139 vty_out(vty
, " graceful-restart\n");
12141 vty_out(vty
, " graceful-restart grace-period %u\n",
12142 ospf
->gr_info
.grace_period
);
12145 static int config_write_ospf_gr_helper(struct vty
*vty
, struct ospf
*ospf
)
12147 if (ospf
->is_helper_supported
)
12148 vty_out(vty
, " graceful-restart helper enable\n");
12150 if (!ospf
->strict_lsa_check
)
12152 " no graceful-restart helper strict-lsa-checking\n");
12154 if (ospf
->only_planned_restart
)
12155 vty_out(vty
, " graceful-restart helper planned-only\n");
12157 if (ospf
->supported_grace_time
!= OSPF_MAX_GRACE_INTERVAL
)
12159 " graceful-restart helper supported-grace-time %d\n",
12160 ospf
->supported_grace_time
);
12162 if (OSPF_HELPER_ENABLE_RTR_COUNT(ospf
)) {
12163 hash_walk(ospf
->enable_rtr_list
,
12164 ospf_cfg_write_helper_dis_rtr_walkcb
, vty
);
12169 static int config_write_ospf_external_aggregator(struct vty
*vty
,
12172 struct route_node
*rn
;
12174 if (ospf
->aggr_delay_interval
!= OSPF_EXTL_AGGR_DEFAULT_DELAY
)
12175 vty_out(vty
, " aggregation timer %u\n",
12176 ospf
->aggr_delay_interval
);
12178 /* print 'summary-address A.B.C.D/M' */
12179 for (rn
= route_top(ospf
->rt_aggr_tbl
); rn
; rn
= route_next(rn
))
12181 struct ospf_external_aggr_rt
*aggr
= rn
->info
;
12183 vty_out(vty
, " summary-address %pI4/%d",
12184 &aggr
->p
.prefix
, aggr
->p
.prefixlen
);
12186 vty_out(vty
, " tag %u", aggr
->tag
);
12188 if (CHECK_FLAG(aggr
->flags
,
12189 OSPF_EXTERNAL_AGGRT_NO_ADVERTISE
))
12190 vty_out(vty
, " no-advertise");
12192 vty_out(vty
, "\n");
12198 static int config_write_ospf_default_metric(struct vty
*vty
, struct ospf
*ospf
)
12200 if (ospf
->default_metric
!= -1)
12201 vty_out(vty
, " default-metric %d\n", ospf
->default_metric
);
12205 static int config_write_ospf_distribute(struct vty
*vty
, struct ospf
*ospf
)
12208 struct ospf_redist
*red
;
12211 /* distribute-list print. */
12212 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
12213 if (DISTRIBUTE_NAME(ospf
, type
))
12214 vty_out(vty
, " distribute-list %s out %s\n",
12215 DISTRIBUTE_NAME(ospf
, type
),
12216 zebra_route_string(type
));
12218 /* default-information print. */
12219 if (ospf
->default_originate
!= DEFAULT_ORIGINATE_NONE
) {
12220 vty_out(vty
, " default-information originate");
12221 if (ospf
->default_originate
== DEFAULT_ORIGINATE_ALWAYS
)
12222 vty_out(vty
, " always");
12224 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
12226 if (red
->dmetric
.value
>= 0)
12227 vty_out(vty
, " metric %d",
12228 red
->dmetric
.value
);
12230 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
12231 vty_out(vty
, " metric-type 1");
12233 if (ROUTEMAP_NAME(red
))
12234 vty_out(vty
, " route-map %s",
12235 ROUTEMAP_NAME(red
));
12238 vty_out(vty
, "\n");
12245 static int config_write_ospf_distance(struct vty
*vty
, struct ospf
*ospf
)
12247 struct route_node
*rn
;
12248 struct ospf_distance
*odistance
;
12250 if (ospf
->distance_all
)
12251 vty_out(vty
, " distance %d\n", ospf
->distance_all
);
12253 if (ospf
->distance_intra
|| ospf
->distance_inter
12254 || ospf
->distance_external
) {
12255 vty_out(vty
, " distance ospf");
12257 if (ospf
->distance_intra
)
12258 vty_out(vty
, " intra-area %d", ospf
->distance_intra
);
12259 if (ospf
->distance_inter
)
12260 vty_out(vty
, " inter-area %d", ospf
->distance_inter
);
12261 if (ospf
->distance_external
)
12262 vty_out(vty
, " external %d", ospf
->distance_external
);
12264 vty_out(vty
, "\n");
12267 for (rn
= route_top(ospf
->distance_table
); rn
; rn
= route_next(rn
))
12268 if ((odistance
= rn
->info
) != NULL
) {
12269 vty_out(vty
, " distance %d %pFX %s\n",
12270 odistance
->distance
, &rn
->p
,
12271 odistance
->access_list
? odistance
->access_list
12277 static int ospf_config_write_one(struct vty
*vty
, struct ospf
*ospf
)
12281 /* `router ospf' print. */
12282 if (ospf
->instance
&& strcmp(ospf
->name
, VRF_DEFAULT_NAME
)) {
12283 vty_out(vty
, "router ospf %d vrf %s\n", ospf
->instance
,
12285 } else if (ospf
->instance
) {
12286 vty_out(vty
, "router ospf %d\n", ospf
->instance
);
12287 } else if (strcmp(ospf
->name
, VRF_DEFAULT_NAME
)) {
12288 vty_out(vty
, "router ospf vrf %s\n", ospf
->name
);
12290 vty_out(vty
, "router ospf\n");
12292 if (!ospf
->networks
) {
12297 /* Router ID print. */
12298 if (ospf
->router_id_static
.s_addr
!= INADDR_ANY
)
12299 vty_out(vty
, " ospf router-id %pI4\n",
12300 &ospf
->router_id_static
);
12302 /* zebra opaque attributes configuration. */
12303 if (CHECK_FLAG(ospf
->config
, OSPF_SEND_EXTRA_DATA_TO_ZEBRA
))
12304 vty_out(vty
, " ospf send-extra-data zebra\n");
12306 /* ABR type print. */
12307 if (ospf
->abr_type
!= OSPF_ABR_DEFAULT
)
12308 vty_out(vty
, " ospf abr-type %s\n",
12309 ospf_abr_type_str
[ospf
->abr_type
]);
12311 /* log-adjacency-changes flag print. */
12312 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
)) {
12313 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
12314 vty_out(vty
, " log-adjacency-changes detail\n");
12315 else if (!SAVE_OSPF_LOG_ADJACENCY_CHANGES
)
12316 vty_out(vty
, " log-adjacency-changes\n");
12317 } else if (SAVE_OSPF_LOG_ADJACENCY_CHANGES
) {
12318 vty_out(vty
, " no log-adjacency-changes\n");
12321 /* RFC1583 compatibility flag print -- Compatible with CISCO
12323 if (CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
12324 vty_out(vty
, " compatible rfc1583\n");
12326 /* auto-cost reference-bandwidth configuration. */
12327 if (ospf
->ref_bandwidth
!= OSPF_DEFAULT_REF_BANDWIDTH
) {
12329 "! Important: ensure reference bandwidth is consistent across all routers\n");
12330 vty_out(vty
, " auto-cost reference-bandwidth %d\n",
12331 ospf
->ref_bandwidth
);
12334 /* SPF timers print. */
12335 if (ospf
->spf_delay
!= OSPF_SPF_DELAY_DEFAULT
12336 || ospf
->spf_holdtime
!= OSPF_SPF_HOLDTIME_DEFAULT
12337 || ospf
->spf_max_holdtime
!= OSPF_SPF_MAX_HOLDTIME_DEFAULT
)
12338 vty_out(vty
, " timers throttle spf %d %d %d\n", ospf
->spf_delay
,
12339 ospf
->spf_holdtime
, ospf
->spf_max_holdtime
);
12341 /* LSA timers print. */
12342 if (ospf
->min_ls_interval
!= OSPF_MIN_LS_INTERVAL
)
12343 vty_out(vty
, " timers throttle lsa all %d\n",
12344 ospf
->min_ls_interval
);
12345 if (ospf
->min_ls_arrival
!= OSPF_MIN_LS_ARRIVAL
)
12346 vty_out(vty
, " timers lsa min-arrival %d\n",
12347 ospf
->min_ls_arrival
);
12349 /* Write multiplier print. */
12350 if (ospf
->write_oi_count
!= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
)
12351 vty_out(vty
, " ospf write-multiplier %d\n",
12352 ospf
->write_oi_count
);
12354 if (ospf
->max_multipath
!= MULTIPATH_NUM
)
12355 vty_out(vty
, " maximum-paths %d\n", ospf
->max_multipath
);
12357 /* Max-metric router-lsa print */
12358 config_write_stub_router(vty
, ospf
);
12360 /* SPF refresh parameters print. */
12361 if (ospf
->lsa_refresh_interval
!= OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
12362 vty_out(vty
, " refresh timer %d\n", ospf
->lsa_refresh_interval
);
12364 /* Redistribute information print. */
12365 config_write_ospf_redistribute(vty
, ospf
);
12367 /* Graceful Restart print */
12368 config_write_ospf_gr(vty
, ospf
);
12369 config_write_ospf_gr_helper(vty
, ospf
);
12371 /* Print external route aggregation. */
12372 config_write_ospf_external_aggregator(vty
, ospf
);
12374 /* passive-interface print. */
12375 if (ospf
->passive_interface_default
== OSPF_IF_PASSIVE
)
12376 vty_out(vty
, " passive-interface default\n");
12378 /* proactive-arp print. */
12379 if (ospf
->proactive_arp
!= OSPF_PROACTIVE_ARP_DEFAULT
) {
12380 if (ospf
->proactive_arp
)
12381 vty_out(vty
, " proactive-arp\n");
12383 vty_out(vty
, " no proactive-arp\n");
12386 /* TI-LFA print. */
12387 if (ospf
->ti_lfa_enabled
) {
12388 if (ospf
->ti_lfa_protection_type
== OSPF_TI_LFA_NODE_PROTECTION
)
12389 vty_out(vty
, " fast-reroute ti-lfa node-protection\n");
12391 vty_out(vty
, " fast-reroute ti-lfa\n");
12394 /* Network area print. */
12395 config_write_network_area(vty
, ospf
);
12397 /* Area config print. */
12398 config_write_ospf_area(vty
, ospf
);
12400 /* static neighbor print. */
12401 config_write_ospf_nbr_nbma(vty
, ospf
);
12403 /* Virtual-Link print. */
12404 config_write_virtual_link(vty
, ospf
);
12406 /* Default metric configuration. */
12407 config_write_ospf_default_metric(vty
, ospf
);
12409 /* Distribute-list and default-information print. */
12410 config_write_ospf_distribute(vty
, ospf
);
12412 /* Distance configuration. */
12413 config_write_ospf_distance(vty
, ospf
);
12415 ospf_opaque_config_write_router(vty
, ospf
);
12417 /* LDP-Sync print */
12418 ospf_ldp_sync_write_config(vty
, ospf
);
12420 vty_out(vty
, "exit\n");
12426 /* OSPF configuration write function. */
12427 static int ospf_config_write(struct vty
*vty
)
12430 struct listnode
*ospf_node
= NULL
;
12433 if (listcount(om
->ospf
) == 0)
12436 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, ospf_node
, ospf
)) {
12437 /* VRF Default check if it is running.
12438 * Upon daemon start, there could be default instance
12439 * in absence of 'router ospf'/oi_running is disabled. */
12440 if (ospf
->vrf_id
== VRF_DEFAULT
&& ospf
->oi_running
)
12441 write
+= ospf_config_write_one(vty
, ospf
);
12442 /* For Non-Default VRF simply display the configuration,
12443 * even if it is not oi_running. */
12444 else if (ospf
->vrf_id
!= VRF_DEFAULT
)
12445 write
+= ospf_config_write_one(vty
, ospf
);
12450 void ospf_vty_show_init(void)
12452 /* "show ip ospf" commands. */
12453 install_element(VIEW_NODE
, &show_ip_ospf_cmd
);
12455 install_element(VIEW_NODE
, &show_ip_ospf_instance_cmd
);
12457 /* "show ip ospf database" commands. */
12458 install_element(VIEW_NODE
, &show_ip_ospf_database_cmd
);
12459 install_element(VIEW_NODE
, &show_ip_ospf_database_max_cmd
);
12460 install_element(VIEW_NODE
,
12461 &show_ip_ospf_database_type_adv_router_cmd
);
12462 install_element(VIEW_NODE
,
12463 &show_ip_ospf_instance_database_type_adv_router_cmd
);
12464 install_element(VIEW_NODE
, &show_ip_ospf_instance_database_cmd
);
12465 install_element(VIEW_NODE
, &show_ip_ospf_instance_database_max_cmd
);
12467 /* "show ip ospf interface" commands. */
12468 install_element(VIEW_NODE
, &show_ip_ospf_interface_cmd
);
12470 install_element(VIEW_NODE
, &show_ip_ospf_instance_interface_cmd
);
12471 /* "show ip ospf interface traffic */
12472 install_element(VIEW_NODE
, &show_ip_ospf_interface_traffic_cmd
);
12474 /* "show ip ospf neighbor" commands. */
12475 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_int_detail_cmd
);
12476 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_int_cmd
);
12477 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_id_cmd
);
12478 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_detail_all_cmd
);
12479 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_detail_cmd
);
12480 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_cmd
);
12481 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_all_cmd
);
12483 install_element(VIEW_NODE
,
12484 &show_ip_ospf_instance_neighbor_int_detail_cmd
);
12485 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_cmd
);
12486 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_id_cmd
);
12487 install_element(VIEW_NODE
,
12488 &show_ip_ospf_instance_neighbor_detail_all_cmd
);
12489 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_cmd
);
12490 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_cmd
);
12491 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_all_cmd
);
12493 /* "show ip ospf route" commands. */
12494 install_element(VIEW_NODE
, &show_ip_ospf_route_cmd
);
12495 install_element(VIEW_NODE
, &show_ip_ospf_border_routers_cmd
);
12497 install_element(VIEW_NODE
, &show_ip_ospf_instance_route_cmd
);
12498 install_element(VIEW_NODE
, &show_ip_ospf_instance_border_routers_cmd
);
12500 /* "show ip ospf vrfs" commands. */
12501 install_element(VIEW_NODE
, &show_ip_ospf_vrfs_cmd
);
12503 /* "show ip ospf gr-helper details" command */
12504 install_element(VIEW_NODE
, &show_ip_ospf_gr_helper_cmd
);
12506 /* "show ip ospf summary-address" command */
12507 install_element(VIEW_NODE
, &show_ip_ospf_external_aggregator_cmd
);
12510 /* Initialization of OSPF interface. */
12511 static void ospf_vty_if_init(void)
12513 /* Install interface node. */
12514 if_cmd_init(config_write_interface
);
12516 /* "ip ospf authentication" commands. */
12517 install_element(INTERFACE_NODE
, &ip_ospf_authentication_args_addr_cmd
);
12518 install_element(INTERFACE_NODE
, &ip_ospf_authentication_addr_cmd
);
12519 install_element(INTERFACE_NODE
,
12520 &no_ip_ospf_authentication_args_addr_cmd
);
12521 install_element(INTERFACE_NODE
, &no_ip_ospf_authentication_addr_cmd
);
12522 install_element(INTERFACE_NODE
, &ip_ospf_authentication_key_addr_cmd
);
12523 install_element(INTERFACE_NODE
,
12524 &no_ip_ospf_authentication_key_authkey_addr_cmd
);
12525 install_element(INTERFACE_NODE
,
12526 &no_ospf_authentication_key_authkey_addr_cmd
);
12528 /* "ip ospf message-digest-key" commands. */
12529 install_element(INTERFACE_NODE
, &ip_ospf_message_digest_key_cmd
);
12530 install_element(INTERFACE_NODE
, &no_ip_ospf_message_digest_key_cmd
);
12532 /* "ip ospf cost" commands. */
12533 install_element(INTERFACE_NODE
, &ip_ospf_cost_cmd
);
12534 install_element(INTERFACE_NODE
, &no_ip_ospf_cost_cmd
);
12536 /* "ip ospf mtu-ignore" commands. */
12537 install_element(INTERFACE_NODE
, &ip_ospf_mtu_ignore_addr_cmd
);
12538 install_element(INTERFACE_NODE
, &no_ip_ospf_mtu_ignore_addr_cmd
);
12540 /* "ip ospf dead-interval" commands. */
12541 install_element(INTERFACE_NODE
, &ip_ospf_dead_interval_cmd
);
12542 install_element(INTERFACE_NODE
,
12543 &ip_ospf_dead_interval_minimal_addr_cmd
);
12544 install_element(INTERFACE_NODE
, &no_ip_ospf_dead_interval_cmd
);
12546 /* "ip ospf hello-interval" commands. */
12547 install_element(INTERFACE_NODE
, &ip_ospf_hello_interval_cmd
);
12548 install_element(INTERFACE_NODE
, &no_ip_ospf_hello_interval_cmd
);
12550 /* "ip ospf network" commands. */
12551 install_element(INTERFACE_NODE
, &ip_ospf_network_cmd
);
12552 install_element(INTERFACE_NODE
, &no_ip_ospf_network_cmd
);
12554 /* "ip ospf priority" commands. */
12555 install_element(INTERFACE_NODE
, &ip_ospf_priority_cmd
);
12556 install_element(INTERFACE_NODE
, &no_ip_ospf_priority_cmd
);
12558 /* "ip ospf retransmit-interval" commands. */
12559 install_element(INTERFACE_NODE
, &ip_ospf_retransmit_interval_addr_cmd
);
12560 install_element(INTERFACE_NODE
,
12561 &no_ip_ospf_retransmit_interval_addr_cmd
);
12563 /* "ip ospf transmit-delay" commands. */
12564 install_element(INTERFACE_NODE
, &ip_ospf_transmit_delay_addr_cmd
);
12565 install_element(INTERFACE_NODE
, &no_ip_ospf_transmit_delay_addr_cmd
);
12567 /* "ip ospf area" commands. */
12568 install_element(INTERFACE_NODE
, &ip_ospf_area_cmd
);
12569 install_element(INTERFACE_NODE
, &no_ip_ospf_area_cmd
);
12571 /* "ip ospf passive" commands. */
12572 install_element(INTERFACE_NODE
, &ip_ospf_passive_cmd
);
12573 install_element(INTERFACE_NODE
, &no_ip_ospf_passive_cmd
);
12575 /* These commands are compatibitliy for previous version. */
12576 install_element(INTERFACE_NODE
, &ospf_authentication_key_cmd
);
12577 install_element(INTERFACE_NODE
, &ospf_message_digest_key_cmd
);
12578 install_element(INTERFACE_NODE
, &no_ospf_message_digest_key_cmd
);
12579 install_element(INTERFACE_NODE
, &ospf_dead_interval_cmd
);
12580 install_element(INTERFACE_NODE
, &no_ospf_dead_interval_cmd
);
12581 install_element(INTERFACE_NODE
, &ospf_hello_interval_cmd
);
12582 install_element(INTERFACE_NODE
, &no_ospf_hello_interval_cmd
);
12583 install_element(INTERFACE_NODE
, &ospf_cost_cmd
);
12584 install_element(INTERFACE_NODE
, &no_ospf_cost_cmd
);
12585 install_element(INTERFACE_NODE
, &ospf_network_cmd
);
12586 install_element(INTERFACE_NODE
, &no_ospf_network_cmd
);
12587 install_element(INTERFACE_NODE
, &ospf_priority_cmd
);
12588 install_element(INTERFACE_NODE
, &no_ospf_priority_cmd
);
12589 install_element(INTERFACE_NODE
, &ospf_retransmit_interval_cmd
);
12590 install_element(INTERFACE_NODE
, &no_ospf_retransmit_interval_cmd
);
12591 install_element(INTERFACE_NODE
, &ospf_transmit_delay_cmd
);
12592 install_element(INTERFACE_NODE
, &no_ospf_transmit_delay_cmd
);
12595 static void ospf_vty_zebra_init(void)
12597 install_element(OSPF_NODE
, &ospf_redistribute_source_cmd
);
12598 install_element(OSPF_NODE
, &no_ospf_redistribute_source_cmd
);
12599 install_element(OSPF_NODE
, &ospf_redistribute_instance_source_cmd
);
12600 install_element(OSPF_NODE
, &no_ospf_redistribute_instance_source_cmd
);
12602 install_element(OSPF_NODE
, &ospf_distribute_list_out_cmd
);
12603 install_element(OSPF_NODE
, &no_ospf_distribute_list_out_cmd
);
12605 install_element(OSPF_NODE
, &ospf_default_information_originate_cmd
);
12606 install_element(OSPF_NODE
, &no_ospf_default_information_originate_cmd
);
12608 install_element(OSPF_NODE
, &ospf_default_metric_cmd
);
12609 install_element(OSPF_NODE
, &no_ospf_default_metric_cmd
);
12611 install_element(OSPF_NODE
, &ospf_distance_cmd
);
12612 install_element(OSPF_NODE
, &no_ospf_distance_cmd
);
12613 install_element(OSPF_NODE
, &no_ospf_distance_ospf_cmd
);
12614 install_element(OSPF_NODE
, &ospf_distance_ospf_cmd
);
12616 /*Ospf garcefull restart helper configurations */
12617 install_element(OSPF_NODE
, &ospf_gr_helper_enable_cmd
);
12618 install_element(OSPF_NODE
, &no_ospf_gr_helper_enable_cmd
);
12619 install_element(OSPF_NODE
, &ospf_gr_helper_only_cmd
);
12620 install_element(OSPF_NODE
, &no_ospf_gr_helper_only_cmd
);
12621 install_element(OSPF_NODE
, &ospf_gr_helper_enable_lsacheck_cmd
);
12622 install_element(OSPF_NODE
, &no_ospf_gr_helper_enable_lsacheck_cmd
);
12623 install_element(OSPF_NODE
, &ospf_gr_helper_supported_grace_time_cmd
);
12624 install_element(OSPF_NODE
, &no_ospf_gr_helper_supported_grace_time_cmd
);
12625 install_element(OSPF_NODE
, &ospf_gr_helper_planned_only_cmd
);
12626 install_element(OSPF_NODE
, &no_ospf_gr_helper_planned_only_cmd
);
12628 /* External LSA summarisation config commands.*/
12629 install_element(OSPF_NODE
, &ospf_external_route_aggregation_cmd
);
12630 install_element(OSPF_NODE
, &no_ospf_external_route_aggregation_cmd
);
12631 install_element(OSPF_NODE
,
12632 &ospf_external_route_aggregation_no_adrvertise_cmd
);
12633 install_element(OSPF_NODE
,
12634 &no_ospf_external_route_aggregation_no_adrvertise_cmd
);
12635 install_element(OSPF_NODE
, &ospf_route_aggregation_timer_cmd
);
12636 install_element(OSPF_NODE
, &no_ospf_route_aggregation_timer_cmd
);
12639 static int ospf_config_write(struct vty
*vty
);
12640 static struct cmd_node ospf_node
= {
12643 .parent_node
= CONFIG_NODE
,
12644 .prompt
= "%s(config-router)# ",
12645 .config_write
= ospf_config_write
,
12648 static void ospf_interface_clear(struct interface
*ifp
)
12650 if (!if_is_operative(ifp
))
12653 if (IS_DEBUG_OSPF(ism
, ISM_EVENTS
))
12654 zlog_debug("ISM[%s]: clear by reset", ifp
->name
);
12656 ospf_if_reset(ifp
);
12659 DEFUN (clear_ip_ospf_interface
,
12660 clear_ip_ospf_interface_cmd
,
12661 "clear ip ospf [vrf NAME] interface [IFNAME]",
12664 "OSPF information\n"
12666 "Interface information\n"
12667 "Interface name\n")
12669 int idx_ifname
= 0;
12671 struct interface
*ifp
;
12672 struct listnode
*node
;
12673 struct ospf
*ospf
= NULL
;
12674 char *vrf_name
= NULL
;
12675 vrf_id_t vrf_id
= VRF_DEFAULT
;
12676 struct vrf
*vrf
= NULL
;
12678 if (argv_find(argv
, argc
, "vrf", &idx_vrf
))
12679 vrf_name
= argv
[idx_vrf
+ 1]->arg
;
12680 if (vrf_name
&& strmatch(vrf_name
, VRF_DEFAULT_NAME
))
12683 vrf
= vrf_lookup_by_name(vrf_name
);
12685 vrf_id
= vrf
->vrf_id
;
12687 if (!argv_find(argv
, argc
, "IFNAME", &idx_ifname
)) {
12688 /* Clear all the ospfv2 interfaces. */
12689 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
12690 if (vrf_id
!= ospf
->vrf_id
)
12693 vrf
= vrf_lookup_by_id(ospf
->vrf_id
);
12694 FOR_ALL_INTERFACES (vrf
, ifp
)
12695 ospf_interface_clear(ifp
);
12698 /* Interface name is specified. */
12699 ifp
= if_lookup_by_name(argv
[idx_ifname
]->arg
, vrf_id
);
12701 vty_out(vty
, "No such interface name\n");
12703 ospf_interface_clear(ifp
);
12706 return CMD_SUCCESS
;
12709 void ospf_vty_clear_init(void)
12711 install_element(ENABLE_NODE
, &clear_ip_ospf_interface_cmd
);
12712 install_element(ENABLE_NODE
, &clear_ip_ospf_process_cmd
);
12713 install_element(ENABLE_NODE
, &clear_ip_ospf_neighbor_cmd
);
12717 /* Install OSPF related vty commands. */
12718 void ospf_vty_init(void)
12720 /* Install ospf top node. */
12721 install_node(&ospf_node
);
12723 /* "router ospf" commands. */
12724 install_element(CONFIG_NODE
, &router_ospf_cmd
);
12725 install_element(CONFIG_NODE
, &no_router_ospf_cmd
);
12728 install_default(OSPF_NODE
);
12730 /* "ospf router-id" commands. */
12731 install_element(OSPF_NODE
, &ospf_router_id_cmd
);
12732 install_element(OSPF_NODE
, &ospf_router_id_old_cmd
);
12733 install_element(OSPF_NODE
, &no_ospf_router_id_cmd
);
12735 /* "passive-interface" commands. */
12736 install_element(OSPF_NODE
, &ospf_passive_interface_default_cmd
);
12737 install_element(OSPF_NODE
, &ospf_passive_interface_addr_cmd
);
12738 install_element(OSPF_NODE
, &no_ospf_passive_interface_default_cmd
);
12739 install_element(OSPF_NODE
, &no_ospf_passive_interface_addr_cmd
);
12741 /* "ospf abr-type" commands. */
12742 install_element(OSPF_NODE
, &ospf_abr_type_cmd
);
12743 install_element(OSPF_NODE
, &no_ospf_abr_type_cmd
);
12745 /* "ospf log-adjacency-changes" commands. */
12746 install_element(OSPF_NODE
, &ospf_log_adjacency_changes_cmd
);
12747 install_element(OSPF_NODE
, &ospf_log_adjacency_changes_detail_cmd
);
12748 install_element(OSPF_NODE
, &no_ospf_log_adjacency_changes_cmd
);
12749 install_element(OSPF_NODE
, &no_ospf_log_adjacency_changes_detail_cmd
);
12751 /* "ospf rfc1583-compatible" commands. */
12752 install_element(OSPF_NODE
, &ospf_compatible_rfc1583_cmd
);
12753 install_element(OSPF_NODE
, &no_ospf_compatible_rfc1583_cmd
);
12754 install_element(OSPF_NODE
, &ospf_rfc1583_flag_cmd
);
12755 install_element(OSPF_NODE
, &no_ospf_rfc1583_flag_cmd
);
12757 /* "ospf send-extra-data zebra" commands. */
12758 install_element(OSPF_NODE
, &ospf_send_extra_data_cmd
);
12760 /* "network area" commands. */
12761 install_element(OSPF_NODE
, &ospf_network_area_cmd
);
12762 install_element(OSPF_NODE
, &no_ospf_network_area_cmd
);
12764 /* "area authentication" commands. */
12765 install_element(OSPF_NODE
,
12766 &ospf_area_authentication_message_digest_cmd
);
12767 install_element(OSPF_NODE
, &ospf_area_authentication_cmd
);
12768 install_element(OSPF_NODE
, &no_ospf_area_authentication_cmd
);
12770 /* "area range" commands. */
12771 install_element(OSPF_NODE
, &ospf_area_range_cmd
);
12772 install_element(OSPF_NODE
, &ospf_area_range_cost_cmd
);
12773 install_element(OSPF_NODE
, &ospf_area_range_not_advertise_cmd
);
12774 install_element(OSPF_NODE
, &no_ospf_area_range_cmd
);
12775 install_element(OSPF_NODE
, &no_ospf_area_range_substitute_cmd
);
12777 /* "area virtual-link" commands. */
12778 install_element(OSPF_NODE
, &ospf_area_vlink_cmd
);
12779 install_element(OSPF_NODE
, &ospf_area_vlink_intervals_cmd
);
12780 install_element(OSPF_NODE
, &no_ospf_area_vlink_cmd
);
12781 install_element(OSPF_NODE
, &no_ospf_area_vlink_intervals_cmd
);
12784 /* "area stub" commands. */
12785 install_element(OSPF_NODE
, &ospf_area_stub_no_summary_cmd
);
12786 install_element(OSPF_NODE
, &ospf_area_stub_cmd
);
12787 install_element(OSPF_NODE
, &no_ospf_area_stub_no_summary_cmd
);
12788 install_element(OSPF_NODE
, &no_ospf_area_stub_cmd
);
12790 /* "area nssa" commands. */
12791 install_element(OSPF_NODE
, &ospf_area_nssa_cmd
);
12792 install_element(OSPF_NODE
, &ospf_area_nssa_translate_cmd
);
12793 install_element(OSPF_NODE
, &ospf_area_nssa_no_summary_cmd
);
12794 install_element(OSPF_NODE
, &no_ospf_area_nssa_no_summary_cmd
);
12795 install_element(OSPF_NODE
, &ospf_area_nssa_suppress_fa_cmd
);
12796 install_element(OSPF_NODE
, &no_ospf_area_nssa_suppress_fa_cmd
);
12797 install_element(OSPF_NODE
, &no_ospf_area_nssa_cmd
);
12799 install_element(OSPF_NODE
, &ospf_area_default_cost_cmd
);
12800 install_element(OSPF_NODE
, &no_ospf_area_default_cost_cmd
);
12802 install_element(OSPF_NODE
, &ospf_area_shortcut_cmd
);
12803 install_element(OSPF_NODE
, &no_ospf_area_shortcut_cmd
);
12805 install_element(OSPF_NODE
, &ospf_area_export_list_cmd
);
12806 install_element(OSPF_NODE
, &no_ospf_area_export_list_cmd
);
12808 install_element(OSPF_NODE
, &ospf_area_filter_list_cmd
);
12809 install_element(OSPF_NODE
, &no_ospf_area_filter_list_cmd
);
12811 install_element(OSPF_NODE
, &ospf_area_import_list_cmd
);
12812 install_element(OSPF_NODE
, &no_ospf_area_import_list_cmd
);
12814 /* SPF timer commands */
12815 install_element(OSPF_NODE
, &ospf_timers_throttle_spf_cmd
);
12816 install_element(OSPF_NODE
, &no_ospf_timers_throttle_spf_cmd
);
12818 /* LSA timers commands */
12819 install_element(OSPF_NODE
, &ospf_timers_min_ls_interval_cmd
);
12820 install_element(OSPF_NODE
, &no_ospf_timers_min_ls_interval_cmd
);
12821 install_element(OSPF_NODE
, &ospf_timers_lsa_min_arrival_cmd
);
12822 install_element(OSPF_NODE
, &no_ospf_timers_lsa_min_arrival_cmd
);
12824 /* refresh timer commands */
12825 install_element(OSPF_NODE
, &ospf_refresh_timer_cmd
);
12826 install_element(OSPF_NODE
, &no_ospf_refresh_timer_val_cmd
);
12828 /* max-metric commands */
12829 install_element(OSPF_NODE
, &ospf_max_metric_router_lsa_admin_cmd
);
12830 install_element(OSPF_NODE
, &no_ospf_max_metric_router_lsa_admin_cmd
);
12831 install_element(OSPF_NODE
, &ospf_max_metric_router_lsa_startup_cmd
);
12832 install_element(OSPF_NODE
, &no_ospf_max_metric_router_lsa_startup_cmd
);
12833 install_element(OSPF_NODE
, &ospf_max_metric_router_lsa_shutdown_cmd
);
12834 install_element(OSPF_NODE
, &no_ospf_max_metric_router_lsa_shutdown_cmd
);
12836 /* reference bandwidth commands */
12837 install_element(OSPF_NODE
, &ospf_auto_cost_reference_bandwidth_cmd
);
12838 install_element(OSPF_NODE
, &no_ospf_auto_cost_reference_bandwidth_cmd
);
12840 /* "neighbor" commands. */
12841 install_element(OSPF_NODE
, &ospf_neighbor_cmd
);
12842 install_element(OSPF_NODE
, &ospf_neighbor_poll_interval_cmd
);
12843 install_element(OSPF_NODE
, &no_ospf_neighbor_cmd
);
12844 install_element(OSPF_NODE
, &no_ospf_neighbor_poll_cmd
);
12846 /* write multiplier commands */
12847 install_element(OSPF_NODE
, &ospf_write_multiplier_cmd
);
12848 install_element(OSPF_NODE
, &write_multiplier_cmd
);
12849 install_element(OSPF_NODE
, &no_ospf_write_multiplier_cmd
);
12850 install_element(OSPF_NODE
, &no_write_multiplier_cmd
);
12852 /* "proactive-arp" commands. */
12853 install_element(OSPF_NODE
, &ospf_proactive_arp_cmd
);
12854 install_element(OSPF_NODE
, &no_ospf_proactive_arp_cmd
);
12856 /* TI-LFA commands */
12857 install_element(OSPF_NODE
, &ospf_ti_lfa_cmd
);
12858 install_element(OSPF_NODE
, &no_ospf_ti_lfa_cmd
);
12860 /* Max path configurations */
12861 install_element(OSPF_NODE
, &ospf_max_multipath_cmd
);
12862 install_element(OSPF_NODE
, &no_ospf_max_multipath_cmd
);
12864 vrf_cmd_init(NULL
);
12866 /* Init interface related vty commands. */
12867 ospf_vty_if_init();
12869 /* Init zebra related vty commands. */
12870 ospf_vty_zebra_init();