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);
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
;
169 if (*vrf_name
&& strmatch(*vrf_name
, VRF_DEFAULT_NAME
))
176 static void ospf_show_vrf_name(struct ospf
*ospf
, struct vty
*vty
,
177 json_object
*json
, uint8_t use_vrf
)
181 if (ospf
->vrf_id
== VRF_DEFAULT
)
182 json_object_string_add(json
, "vrfName",
185 json_object_string_add(json
, "vrfName",
187 json_object_int_add(json
, "vrfId", ospf
->vrf_id
);
189 if (ospf
->vrf_id
== VRF_DEFAULT
)
190 vty_out(vty
, "VRF Name: %s\n", "default");
192 vty_out(vty
, "VRF Name: %s\n", ospf
->name
);
197 #ifndef VTYSH_EXTRACT_PL
198 #include "ospfd/ospf_vty_clippy.c"
201 DEFUN_NOSH (router_ospf
,
203 "router ospf [{(1-65535)|vrf NAME}]",
204 "Enable a routing process\n"
205 "Start OSPF configuration\n"
209 unsigned short instance
;
210 const char *vrf_name
;
211 bool created
= false;
215 ret
= ospf_router_cmd_parse(vty
, argv
, argc
, &instance
, &vrf_name
);
216 if (ret
!= CMD_SUCCESS
)
219 if (instance
!= ospf_instance
) {
220 VTY_PUSH_CONTEXT_NULL(OSPF_NODE
);
221 return CMD_NOT_MY_INSTANCE
;
224 ospf
= ospf_get(instance
, vrf_name
, &created
);
227 if (DFLT_OSPF_LOG_ADJACENCY_CHANGES
)
228 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
230 if (IS_DEBUG_OSPF_EVENT
)
232 "Config command 'router ospf %d' received, vrf %s id %u oi_running %u",
233 ospf
->instance
, ospf
->name
? ospf
->name
: "NIL",
234 ospf
->vrf_id
, ospf
->oi_running
);
236 VTY_PUSH_CONTEXT(OSPF_NODE
, ospf
);
241 DEFUN (no_router_ospf
,
243 "no router ospf [{(1-65535)|vrf NAME}]",
245 "Enable a routing process\n"
246 "Start OSPF configuration\n"
250 unsigned short instance
;
251 const char *vrf_name
;
255 ret
= ospf_router_cmd_parse(vty
, argv
, argc
, &instance
, &vrf_name
);
256 if (ret
!= CMD_SUCCESS
)
259 if (instance
!= ospf_instance
)
260 return CMD_NOT_MY_INSTANCE
;
262 ospf
= ospf_lookup(instance
, vrf_name
);
266 ret
= CMD_WARNING_CONFIG_FAILED
;
272 DEFPY (ospf_router_id
,
274 "ospf router-id A.B.C.D",
275 "OSPF specific commands\n"
276 "router-id for the OSPF process\n"
277 "OSPF router-id in IP address format\n")
279 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
281 struct listnode
*node
;
282 struct ospf_area
*area
;
284 ospf
->router_id_static
= router_id
;
286 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
))
287 if (area
->full_nbrs
) {
289 "For this router-id change to take effect, use “clear ip ospf process” command\n");
293 ospf_router_id_update(ospf
);
298 DEFUN_HIDDEN (ospf_router_id_old
,
299 ospf_router_id_old_cmd
,
301 "router-id for the OSPF process\n"
302 "OSPF router-id in IP address format\n")
304 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
306 struct listnode
*node
;
307 struct ospf_area
*area
;
308 struct in_addr router_id
;
311 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &router_id
);
313 vty_out(vty
, "Please specify Router ID by A.B.C.D\n");
314 return CMD_WARNING_CONFIG_FAILED
;
317 ospf
->router_id_static
= router_id
;
319 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
))
320 if (area
->full_nbrs
) {
322 "For this router-id change to take effect, use “clear ip ospf process” command\n");
326 ospf_router_id_update(ospf
);
331 DEFPY (no_ospf_router_id
,
332 no_ospf_router_id_cmd
,
333 "no ospf router-id [A.B.C.D]",
335 "OSPF specific commands\n"
336 "router-id for the OSPF process\n"
337 "OSPF router-id in IP address format\n")
339 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
340 struct listnode
*node
;
341 struct ospf_area
*area
;
344 if (!IPV4_ADDR_SAME(&ospf
->router_id_static
, &router_id
)) {
345 vty_out(vty
, "%% OSPF router-id doesn't match\n");
346 return CMD_WARNING_CONFIG_FAILED
;
350 ospf
->router_id_static
.s_addr
= 0;
352 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
))
353 if (area
->full_nbrs
) {
355 "For this router-id change to take effect, use “clear ip ospf process” command\n");
359 ospf_router_id_update(ospf
);
365 static void ospf_passive_interface_default(struct ospf
*ospf
, uint8_t newval
)
367 struct vrf
*vrf
= vrf_lookup_by_id(ospf
->vrf_id
);
369 struct interface
*ifp
;
370 struct ospf_interface
*oi
;
372 ospf
->passive_interface_default
= newval
;
374 FOR_ALL_INTERFACES (vrf
, ifp
) {
375 if (ifp
&& OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp
),
377 UNSET_IF_PARAM(IF_DEF_PARAMS(ifp
), passive_interface
);
379 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, ln
, oi
)) {
380 if (OSPF_IF_PARAM_CONFIGURED(oi
->params
, passive_interface
))
381 UNSET_IF_PARAM(oi
->params
, passive_interface
);
382 /* update multicast memberships */
383 ospf_if_set_multicast(oi
);
387 static void ospf_passive_interface_update_addr(struct ospf
*ospf
,
388 struct interface
*ifp
,
389 struct ospf_if_params
*params
,
395 params
->passive_interface
= value
;
396 if (params
!= IF_DEF_PARAMS(ifp
)) {
397 if (OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp
),
399 dflt
= IF_DEF_PARAMS(ifp
)->passive_interface
;
401 dflt
= ospf
->passive_interface_default
;
404 SET_IF_PARAM(params
, passive_interface
);
406 UNSET_IF_PARAM(params
, passive_interface
);
408 ospf_free_if_params(ifp
, addr
);
409 ospf_if_update_params(ifp
, addr
);
413 static void ospf_passive_interface_update(struct ospf
*ospf
,
414 struct interface
*ifp
,
415 struct ospf_if_params
*params
,
418 params
->passive_interface
= value
;
419 if (params
== IF_DEF_PARAMS(ifp
)) {
420 if (value
!= ospf
->passive_interface_default
)
421 SET_IF_PARAM(params
, passive_interface
);
423 UNSET_IF_PARAM(params
, passive_interface
);
427 DEFUN (ospf_passive_interface
,
428 ospf_passive_interface_addr_cmd
,
429 "passive-interface <IFNAME [A.B.C.D]|default>",
430 "Suppress routing updates on an interface\n"
433 "Suppress routing updates on interfaces by default\n")
435 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
437 struct interface
*ifp
= NULL
;
438 struct in_addr addr
= {.s_addr
= INADDR_ANY
};
440 struct ospf_if_params
*params
;
441 struct route_node
*rn
;
443 if (strmatch(argv
[1]->text
, "default")) {
444 ospf_passive_interface_default(ospf
, OSPF_IF_PASSIVE
);
447 if (ospf
->vrf_id
!= VRF_UNKNOWN
)
448 ifp
= if_get_by_name(argv
[1]->arg
, ospf
->vrf_id
);
451 vty_out(vty
, "interface %s not found.\n", (char *)argv
[1]->arg
);
452 return CMD_WARNING_CONFIG_FAILED
;
455 params
= IF_DEF_PARAMS(ifp
);
458 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
461 "Please specify interface address by A.B.C.D\n");
462 return CMD_WARNING_CONFIG_FAILED
;
465 params
= ospf_get_if_params(ifp
, addr
);
466 ospf_if_update_params(ifp
, addr
);
467 ospf_passive_interface_update_addr(ospf
, ifp
, params
,
468 OSPF_IF_PASSIVE
, addr
);
471 ospf_passive_interface_update(ospf
, ifp
, params
, OSPF_IF_PASSIVE
);
473 /* XXX We should call ospf_if_set_multicast on exactly those
474 * interfaces for which the passive property changed. It is too much
475 * work to determine this set, so we do this for every interface.
476 * This is safe and reasonable because ospf_if_set_multicast uses a
477 * record of joined groups to avoid systems calls if the desired
478 * memberships match the current memership.
481 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
482 struct ospf_interface
*oi
= rn
->info
;
484 if (oi
&& (OSPF_IF_PARAM(oi
, passive_interface
)
486 ospf_if_set_multicast(oi
);
489 * XXX It is not clear what state transitions the interface needs to
490 * undergo when going from active to passive. Fixing this will
491 * require precise identification of interfaces having such a
498 DEFUN (no_ospf_passive_interface
,
499 no_ospf_passive_interface_addr_cmd
,
500 "no passive-interface <IFNAME [A.B.C.D]|default>",
502 "Allow routing updates on an interface\n"
505 "Allow routing updates on interfaces by default\n")
507 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
509 struct interface
*ifp
= NULL
;
510 struct in_addr addr
= {.s_addr
= INADDR_ANY
};
511 struct ospf_if_params
*params
;
513 struct route_node
*rn
;
515 if (strmatch(argv
[2]->text
, "default")) {
516 ospf_passive_interface_default(ospf
, OSPF_IF_ACTIVE
);
520 if (ospf
->vrf_id
!= VRF_UNKNOWN
)
521 ifp
= if_get_by_name(argv
[2]->arg
, ospf
->vrf_id
);
524 vty_out(vty
, "interface %s not found.\n", (char *)argv
[2]->arg
);
525 return CMD_WARNING_CONFIG_FAILED
;
528 params
= IF_DEF_PARAMS(ifp
);
531 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
534 "Please specify interface address by A.B.C.D\n");
535 return CMD_WARNING_CONFIG_FAILED
;
538 params
= ospf_lookup_if_params(ifp
, addr
);
541 ospf_passive_interface_update_addr(ospf
, ifp
, params
,
542 OSPF_IF_ACTIVE
, addr
);
544 ospf_passive_interface_update(ospf
, ifp
, params
, OSPF_IF_ACTIVE
);
546 /* XXX We should call ospf_if_set_multicast on exactly those
547 * interfaces for which the passive property changed. It is too much
548 * work to determine this set, so we do this for every interface.
549 * This is safe and reasonable because ospf_if_set_multicast uses a
550 * record of joined groups to avoid systems calls if the desired
551 * memberships match the current memership.
553 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
554 struct ospf_interface
*oi
= rn
->info
;
557 && (OSPF_IF_PARAM(oi
, passive_interface
) == OSPF_IF_ACTIVE
))
558 ospf_if_set_multicast(oi
);
565 DEFUN (ospf_network_area
,
566 ospf_network_area_cmd
,
567 "network A.B.C.D/M area <A.B.C.D|(0-4294967295)>",
568 "Enable routing on an IP network\n"
569 "OSPF network prefix\n"
570 "Set the OSPF area ID\n"
571 "OSPF area ID in IP address format\n"
572 "OSPF area ID as a decimal value\n")
574 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
575 int idx_ipv4_prefixlen
= 1;
576 int idx_ipv4_number
= 3;
577 struct prefix_ipv4 p
;
578 struct in_addr area_id
;
582 if (ospf
->instance
) {
584 "The network command is not supported in multi-instance ospf\n");
585 return CMD_WARNING_CONFIG_FAILED
;
588 count
= ospf_count_area_params(ospf
);
591 "Please remove all ip ospf area x.x.x.x commands first.\n");
592 if (IS_DEBUG_OSPF_EVENT
)
594 "%s ospf vrf %s num of %u ip ospf area x config",
595 __func__
, ospf
->name
? ospf
->name
: "NIL",
597 return CMD_WARNING_CONFIG_FAILED
;
600 /* Get network prefix and Area ID. */
601 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
602 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
604 ret
= ospf_network_set(ospf
, &p
, area_id
, format
);
606 vty_out(vty
, "There is already same network statement.\n");
607 return CMD_WARNING_CONFIG_FAILED
;
613 DEFUN (no_ospf_network_area
,
614 no_ospf_network_area_cmd
,
615 "no network A.B.C.D/M area <A.B.C.D|(0-4294967295)>",
617 "Enable routing on an IP network\n"
618 "OSPF network prefix\n"
619 "Set the OSPF area ID\n"
620 "OSPF area ID in IP address format\n"
621 "OSPF area ID as a decimal value\n")
623 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
624 int idx_ipv4_prefixlen
= 2;
625 int idx_ipv4_number
= 4;
626 struct prefix_ipv4 p
;
627 struct in_addr area_id
;
630 if (ospf
->instance
) {
632 "The network command is not supported in multi-instance ospf\n");
633 return CMD_WARNING_CONFIG_FAILED
;
636 /* Get network prefix and Area ID. */
637 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
638 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
640 ret
= ospf_network_unset(ospf
, &p
, area_id
);
643 "Can't find specified network area configuration.\n");
644 return CMD_WARNING_CONFIG_FAILED
;
650 DEFUN (ospf_area_range
,
652 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [advertise [cost (0-16777215)]]",
653 "OSPF area parameters\n"
654 "OSPF area ID in IP address format\n"
655 "OSPF area ID as a decimal value\n"
656 "Summarize routes matching address/mask (border routers only)\n"
657 "Area range prefix\n"
658 "Advertise this range (default)\n"
659 "User specified metric for this range\n"
660 "Advertised metric for this range\n")
662 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
663 int idx_ipv4_number
= 1;
664 int idx_ipv4_prefixlen
= 3;
666 struct prefix_ipv4 p
;
667 struct in_addr area_id
;
671 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
672 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
674 ospf_area_range_set(ospf
, area_id
, &p
, OSPF_AREA_RANGE_ADVERTISE
);
675 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
678 cost
= strtoul(argv
[idx_cost
]->arg
, NULL
, 10);
679 ospf_area_range_cost_set(ospf
, area_id
, &p
, cost
);
685 DEFUN (ospf_area_range_cost
,
686 ospf_area_range_cost_cmd
,
687 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M cost (0-16777215)",
688 "OSPF area parameters\n"
689 "OSPF area ID in IP address format\n"
690 "OSPF area ID as a decimal value\n"
691 "Summarize routes matching address/mask (border routers only)\n"
692 "Area range prefix\n"
693 "User specified metric for this range\n"
694 "Advertised metric for this range\n")
696 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
697 int idx_ipv4_number
= 1;
698 int idx_ipv4_prefixlen
= 3;
700 struct prefix_ipv4 p
;
701 struct in_addr area_id
;
705 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
706 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
708 ospf_area_range_set(ospf
, area_id
, &p
, OSPF_AREA_RANGE_ADVERTISE
);
709 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
712 cost
= strtoul(argv
[idx_cost
]->arg
, NULL
, 10);
713 ospf_area_range_cost_set(ospf
, area_id
, &p
, cost
);
718 DEFUN (ospf_area_range_not_advertise
,
719 ospf_area_range_not_advertise_cmd
,
720 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M not-advertise",
721 "OSPF area parameters\n"
722 "OSPF area ID in IP address format\n"
723 "OSPF area ID as a decimal value\n"
724 "Summarize routes matching address/mask (border routers only)\n"
725 "Area range prefix\n"
726 "DoNotAdvertise this range\n")
728 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
729 int idx_ipv4_number
= 1;
730 int idx_ipv4_prefixlen
= 3;
731 struct prefix_ipv4 p
;
732 struct in_addr area_id
;
735 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
736 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
738 ospf_area_range_set(ospf
, area_id
, &p
, 0);
739 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
741 ospf_area_range_substitute_unset(ospf
, area_id
, &p
);
746 DEFUN (no_ospf_area_range
,
747 no_ospf_area_range_cmd
,
748 "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [<cost (0-16777215)|advertise [cost (0-16777215)]|not-advertise>]",
750 "OSPF area parameters\n"
751 "OSPF area ID in IP address format\n"
752 "OSPF area ID as a decimal value\n"
753 "Summarize routes matching address/mask (border routers only)\n"
754 "Area range prefix\n"
755 "User specified metric for this range\n"
756 "Advertised metric for this range\n"
757 "Advertise this range (default)\n"
758 "User specified metric for this range\n"
759 "Advertised metric for this range\n"
760 "DoNotAdvertise this range\n")
762 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
763 int idx_ipv4_number
= 2;
764 int idx_ipv4_prefixlen
= 4;
765 struct prefix_ipv4 p
;
766 struct in_addr area_id
;
769 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
770 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
772 ospf_area_range_unset(ospf
, area_id
, &p
);
777 DEFUN (ospf_area_range_substitute
,
778 ospf_area_range_substitute_cmd
,
779 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M",
780 "OSPF area parameters\n"
781 "OSPF area ID in IP address format\n"
782 "OSPF area ID as a decimal value\n"
783 "Summarize routes matching address/mask (border routers only)\n"
784 "Area range prefix\n"
785 "Announce area range as another prefix\n"
786 "Network prefix to be announced instead of range\n")
788 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
789 int idx_ipv4_number
= 1;
790 int idx_ipv4_prefixlen
= 3;
791 int idx_ipv4_prefixlen_2
= 5;
792 struct prefix_ipv4 p
, s
;
793 struct in_addr area_id
;
796 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
797 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
798 str2prefix_ipv4(argv
[idx_ipv4_prefixlen_2
]->arg
, &s
);
800 ospf_area_range_substitute_set(ospf
, area_id
, &p
, &s
);
801 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
807 DEFUN (no_ospf_area_range_substitute
,
808 no_ospf_area_range_substitute_cmd
,
809 "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M",
811 "OSPF area parameters\n"
812 "OSPF area ID in IP address format\n"
813 "OSPF area ID as a decimal value\n"
814 "Summarize routes matching address/mask (border routers only)\n"
815 "Area range prefix\n"
816 "Announce area range as another prefix\n"
817 "Network prefix to be announced instead of range\n")
819 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
820 int idx_ipv4_number
= 2;
821 int idx_ipv4_prefixlen
= 4;
822 int idx_ipv4_prefixlen_2
= 6;
823 struct prefix_ipv4 p
, s
;
824 struct in_addr area_id
;
827 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
828 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
829 str2prefix_ipv4(argv
[idx_ipv4_prefixlen_2
]->arg
, &s
);
831 ospf_area_range_substitute_unset(ospf
, area_id
, &p
);
837 /* Command Handler Logic in VLink stuff is delicate!!
839 ALTER AT YOUR OWN RISK!!!!
841 Various dummy values are used to represent 'NoChange' state for
842 VLink configuration NOT being changed by a VLink command, and
843 special syntax is used within the command strings so that the
844 typed in command verbs can be seen in the configuration command
845 bacckend handler. This is to drastically reduce the verbeage
846 required to coe up with a reasonably compatible Cisco VLink command
848 - Matthew Grant <grantma@anathoth.gen.nz>
849 Wed, 21 Feb 2001 15:13:52 +1300
852 /* Configuration data for virtual links
854 struct ospf_vl_config_data
{
855 struct vty
*vty
; /* vty stuff */
856 struct in_addr area_id
; /* area ID from command line */
857 int area_id_fmt
; /* command line area ID format */
858 struct in_addr vl_peer
; /* command line vl_peer */
859 int auth_type
; /* Authehntication type, if given */
860 char *auth_key
; /* simple password if present */
861 int crypto_key_id
; /* Cryptographic key ID */
862 char *md5_key
; /* MD5 authentication key */
863 int hello_interval
; /* Obvious what these are... */
864 int retransmit_interval
;
869 static void ospf_vl_config_data_init(struct ospf_vl_config_data
*vl_config
,
872 memset(vl_config
, 0, sizeof(struct ospf_vl_config_data
));
873 vl_config
->auth_type
= OSPF_AUTH_CMD_NOTSEEN
;
874 vl_config
->vty
= vty
;
877 static struct ospf_vl_data
*
878 ospf_find_vl_data(struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
880 struct ospf_area
*area
;
881 struct ospf_vl_data
*vl_data
;
883 struct in_addr area_id
;
885 vty
= vl_config
->vty
;
886 area_id
= vl_config
->area_id
;
888 if (area_id
.s_addr
== OSPF_AREA_BACKBONE
) {
890 "Configuring VLs over the backbone is not allowed\n");
893 area
= ospf_area_get(ospf
, area_id
);
894 ospf_area_display_format_set(ospf
, area
, vl_config
->area_id_fmt
);
896 if (area
->external_routing
!= OSPF_AREA_DEFAULT
) {
897 if (vl_config
->area_id_fmt
== OSPF_AREA_ID_FMT_DOTTEDQUAD
)
898 vty_out(vty
, "Area %pI4 is %s\n", &area_id
,
899 area
->external_routing
== OSPF_AREA_NSSA
903 vty_out(vty
, "Area %ld is %s\n",
904 (unsigned long)ntohl(area_id
.s_addr
),
905 area
->external_routing
== OSPF_AREA_NSSA
911 if ((vl_data
= ospf_vl_lookup(ospf
, area
, vl_config
->vl_peer
))
913 vl_data
= ospf_vl_data_new(area
, vl_config
->vl_peer
);
914 if (vl_data
->vl_oi
== NULL
) {
915 vl_data
->vl_oi
= ospf_vl_new(ospf
, vl_data
);
916 ospf_vl_add(ospf
, vl_data
);
917 ospf_spf_calculate_schedule(ospf
,
918 SPF_FLAG_CONFIG_CHANGE
);
925 static int ospf_vl_set_security(struct ospf_vl_data
*vl_data
,
926 struct ospf_vl_config_data
*vl_config
)
928 struct crypt_key
*ck
;
930 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
932 vty
= vl_config
->vty
;
934 if (vl_config
->auth_type
!= OSPF_AUTH_CMD_NOTSEEN
) {
935 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), auth_type
);
936 IF_DEF_PARAMS(ifp
)->auth_type
= vl_config
->auth_type
;
939 if (vl_config
->auth_key
) {
940 memset(IF_DEF_PARAMS(ifp
)->auth_simple
, 0,
941 OSPF_AUTH_SIMPLE_SIZE
+ 1);
942 strlcpy((char *)IF_DEF_PARAMS(ifp
)->auth_simple
,
944 sizeof(IF_DEF_PARAMS(ifp
)->auth_simple
));
945 } else if (vl_config
->md5_key
) {
946 if (ospf_crypt_key_lookup(IF_DEF_PARAMS(ifp
)->auth_crypt
,
947 vl_config
->crypto_key_id
)
949 vty_out(vty
, "OSPF: Key %d already exists\n",
950 vl_config
->crypto_key_id
);
953 ck
= ospf_crypt_key_new();
954 ck
->key_id
= vl_config
->crypto_key_id
;
955 memset(ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+ 1);
956 strlcpy((char *)ck
->auth_key
, vl_config
->md5_key
,
957 sizeof(ck
->auth_key
));
959 ospf_crypt_key_add(IF_DEF_PARAMS(ifp
)->auth_crypt
, ck
);
960 } else if (vl_config
->crypto_key_id
!= 0) {
963 if (ospf_crypt_key_lookup(IF_DEF_PARAMS(ifp
)->auth_crypt
,
964 vl_config
->crypto_key_id
)
966 vty_out(vty
, "OSPF: Key %d does not exist\n",
967 vl_config
->crypto_key_id
);
968 return CMD_WARNING_CONFIG_FAILED
;
971 ospf_crypt_key_delete(IF_DEF_PARAMS(ifp
)->auth_crypt
,
972 vl_config
->crypto_key_id
);
978 static int ospf_vl_set_timers(struct ospf_vl_data
*vl_data
,
979 struct ospf_vl_config_data
*vl_config
)
981 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
982 /* Virtual Link data initialised to defaults, so only set
984 if (vl_config
->hello_interval
) {
985 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), v_hello
);
986 IF_DEF_PARAMS(ifp
)->v_hello
= vl_config
->hello_interval
;
989 if (vl_config
->dead_interval
) {
990 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), v_wait
);
991 IF_DEF_PARAMS(ifp
)->v_wait
= vl_config
->dead_interval
;
994 if (vl_config
->retransmit_interval
) {
995 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), retransmit_interval
);
996 IF_DEF_PARAMS(ifp
)->retransmit_interval
=
997 vl_config
->retransmit_interval
;
1000 if (vl_config
->transmit_delay
) {
1001 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), transmit_delay
);
1002 IF_DEF_PARAMS(ifp
)->transmit_delay
= vl_config
->transmit_delay
;
1009 /* The business end of all of the above */
1010 static int ospf_vl_set(struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
1012 struct ospf_vl_data
*vl_data
;
1015 vl_data
= ospf_find_vl_data(ospf
, vl_config
);
1017 return CMD_WARNING_CONFIG_FAILED
;
1019 /* Process this one first as it can have a fatal result, which can
1020 only logically occur if the virtual link exists already
1021 Thus a command error does not result in a change to the
1022 running configuration such as unexpectedly altered timer
1024 ret
= ospf_vl_set_security(vl_data
, vl_config
);
1025 if (ret
!= CMD_SUCCESS
)
1028 /* Set any time based parameters, these area already range checked */
1030 ret
= ospf_vl_set_timers(vl_data
, vl_config
);
1031 if (ret
!= CMD_SUCCESS
)
1037 /* This stuff exists to make specifying all the alias commands A LOT simpler
1039 #define VLINK_HELPSTR_IPADDR \
1040 "OSPF area parameters\n" \
1041 "OSPF area ID in IP address format\n" \
1042 "OSPF area ID as a decimal value\n" \
1043 "Configure a virtual link\n" \
1044 "Router ID of the remote ABR\n"
1046 #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
1047 "Enable authentication on this virtual link\n" \
1050 #define VLINK_HELPSTR_AUTHTYPE_ALL \
1051 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
1052 "Use null authentication\n" \
1053 "Use message-digest authentication\n"
1055 #define VLINK_HELPSTR_TIME_PARAM \
1056 "Time between HELLO packets\n" \
1058 "Time between retransmitting lost link state advertisements\n" \
1060 "Link state transmit delay\n" \
1062 "Interval time after which a neighbor is declared down\n" \
1065 #define VLINK_HELPSTR_AUTH_SIMPLE \
1066 "Authentication password (key)\n" \
1067 "The OSPF password (key)\n"
1069 #define VLINK_HELPSTR_AUTH_MD5 \
1070 "Message digest authentication password (key)\n" \
1072 "Use MD5 algorithm\n" \
1073 "The OSPF password (key)\n"
1075 DEFUN (ospf_area_vlink
,
1076 ospf_area_vlink_cmd
,
1077 "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>]",
1078 VLINK_HELPSTR_IPADDR
1079 "Enable authentication on this virtual link\n"
1080 "Use message-digest authentication\n"
1081 "Use null authentication\n"
1082 VLINK_HELPSTR_AUTH_MD5
1083 VLINK_HELPSTR_AUTH_SIMPLE
)
1085 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1086 int idx_ipv4_number
= 1;
1088 struct ospf_vl_config_data vl_config
;
1089 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+ 1];
1090 char md5_key
[OSPF_AUTH_MD5_SIZE
+ 1];
1094 ospf_vl_config_data_init(&vl_config
, vty
);
1096 /* Read off first 2 parameters and check them */
1097 ret
= str2area_id(argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
,
1098 &vl_config
.area_id_fmt
);
1100 vty_out(vty
, "OSPF area ID is invalid\n");
1101 return CMD_WARNING_CONFIG_FAILED
;
1104 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1106 vty_out(vty
, "Please specify valid Router ID as a.b.c.d\n");
1107 return CMD_WARNING_CONFIG_FAILED
;
1111 /* Thats all folks! - BUGS B. strikes again!!!*/
1113 return ospf_vl_set(ospf
, &vl_config
);
1116 if (argv_find(argv
, argc
, "authentication", &idx
)) {
1117 /* authentication - this option can only occur
1118 at start of command line */
1119 vl_config
.auth_type
= OSPF_AUTH_SIMPLE
;
1122 if (argv_find(argv
, argc
, "message-digest", &idx
)) {
1123 /* authentication message-digest */
1124 vl_config
.auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
1125 } else if (argv_find(argv
, argc
, "null", &idx
)) {
1126 /* "authentication null" */
1127 vl_config
.auth_type
= OSPF_AUTH_NULL
;
1130 if (argv_find(argv
, argc
, "message-digest-key", &idx
)) {
1131 vl_config
.md5_key
= NULL
;
1132 vl_config
.crypto_key_id
= strtol(argv
[idx
+ 1]->arg
, NULL
, 10);
1133 if (vl_config
.crypto_key_id
< 0)
1134 return CMD_WARNING_CONFIG_FAILED
;
1136 strlcpy(md5_key
, argv
[idx
+ 3]->arg
, sizeof(md5_key
));
1137 vl_config
.md5_key
= md5_key
;
1140 if (argv_find(argv
, argc
, "authentication-key", &idx
)) {
1141 strlcpy(auth_key
, argv
[idx
+ 1]->arg
, sizeof(auth_key
));
1142 vl_config
.auth_key
= auth_key
;
1145 /* Action configuration */
1147 return ospf_vl_set(ospf
, &vl_config
);
1150 DEFUN (no_ospf_area_vlink
,
1151 no_ospf_area_vlink_cmd
,
1152 "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>]",
1154 VLINK_HELPSTR_IPADDR
1155 "Enable authentication on this virtual link\n"
1156 "Use message-digest authentication\n"
1157 "Use null authentication\n"
1158 VLINK_HELPSTR_AUTH_MD5
1159 VLINK_HELPSTR_AUTH_SIMPLE
)
1161 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1162 int idx_ipv4_number
= 2;
1164 struct ospf_area
*area
;
1165 struct ospf_vl_config_data vl_config
;
1166 struct ospf_vl_data
*vl_data
= NULL
;
1167 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+ 1];
1171 ospf_vl_config_data_init(&vl_config
, vty
);
1173 ret
= str2area_id(argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
,
1176 vty_out(vty
, "OSPF area ID is invalid\n");
1177 return CMD_WARNING_CONFIG_FAILED
;
1180 area
= ospf_area_lookup_by_area_id(ospf
, vl_config
.area_id
);
1182 vty_out(vty
, "Area does not exist\n");
1183 return CMD_WARNING_CONFIG_FAILED
;
1186 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1188 vty_out(vty
, "Please specify valid Router ID as a.b.c.d\n");
1189 return CMD_WARNING_CONFIG_FAILED
;
1192 vl_data
= ospf_vl_lookup(ospf
, area
, vl_config
.vl_peer
);
1194 vty_out(vty
, "Virtual link does not exist\n");
1195 return CMD_WARNING_CONFIG_FAILED
;
1199 /* Basic VLink no command */
1200 /* Thats all folks! - BUGS B. strikes again!!!*/
1201 ospf_vl_delete(ospf
, vl_data
);
1202 ospf_area_check_free(ospf
, vl_config
.area_id
);
1206 /* If we are down here, we are reseting parameters */
1207 /* Deal with other parameters */
1209 if (argv_find(argv
, argc
, "authentication", &idx
)) {
1210 /* authentication - this option can only occur
1211 at start of command line */
1212 vl_config
.auth_type
= OSPF_AUTH_NOTSET
;
1215 if (argv_find(argv
, argc
, "message-digest-key", &idx
)) {
1216 vl_config
.md5_key
= NULL
;
1217 vl_config
.crypto_key_id
= strtol(argv
[idx
+ 1]->arg
, NULL
, 10);
1218 if (vl_config
.crypto_key_id
< 0)
1219 return CMD_WARNING_CONFIG_FAILED
;
1222 if (argv_find(argv
, argc
, "authentication-key", &idx
)) {
1223 /* Reset authentication-key to 0 */
1224 memset(auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1225 vl_config
.auth_key
= auth_key
;
1228 /* Action configuration */
1230 return ospf_vl_set(ospf
, &vl_config
);
1233 DEFUN (ospf_area_vlink_intervals
,
1234 ospf_area_vlink_intervals_cmd
,
1235 "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)}",
1236 VLINK_HELPSTR_IPADDR
1237 VLINK_HELPSTR_TIME_PARAM
)
1239 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1240 struct ospf_vl_config_data vl_config
;
1243 ospf_vl_config_data_init(&vl_config
, vty
);
1245 char *area_id
= argv
[1]->arg
;
1246 char *router_id
= argv
[3]->arg
;
1248 ret
= str2area_id(area_id
, &vl_config
.area_id
, &vl_config
.area_id_fmt
);
1250 vty_out(vty
, "OSPF area ID is invalid\n");
1251 return CMD_WARNING_CONFIG_FAILED
;
1254 ret
= inet_aton(router_id
, &vl_config
.vl_peer
);
1256 vty_out(vty
, "Please specify valid Router ID as a.b.c.d\n");
1257 return CMD_WARNING_CONFIG_FAILED
;
1260 for (int idx
= 4; idx
< argc
; idx
++) {
1261 if (strmatch(argv
[idx
]->text
, "hello-interval"))
1262 vl_config
.hello_interval
=
1263 strtol(argv
[++idx
]->arg
, NULL
, 10);
1264 else if (strmatch(argv
[idx
]->text
, "retransmit-interval"))
1265 vl_config
.retransmit_interval
=
1266 strtol(argv
[++idx
]->arg
, NULL
, 10);
1267 else if (strmatch(argv
[idx
]->text
, "transmit-delay"))
1268 vl_config
.transmit_delay
=
1269 strtol(argv
[++idx
]->arg
, NULL
, 10);
1270 else if (strmatch(argv
[idx
]->text
, "dead-interval"))
1271 vl_config
.dead_interval
=
1272 strtol(argv
[++idx
]->arg
, NULL
, 10);
1275 /* Action configuration */
1276 return ospf_vl_set(ospf
, &vl_config
);
1279 DEFUN (no_ospf_area_vlink_intervals
,
1280 no_ospf_area_vlink_intervals_cmd
,
1281 "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)}",
1283 VLINK_HELPSTR_IPADDR
1284 VLINK_HELPSTR_TIME_PARAM
)
1286 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1287 struct ospf_vl_config_data vl_config
;
1290 ospf_vl_config_data_init(&vl_config
, vty
);
1292 char *area_id
= argv
[2]->arg
;
1293 char *router_id
= argv
[4]->arg
;
1295 ret
= str2area_id(area_id
, &vl_config
.area_id
, &vl_config
.area_id_fmt
);
1297 vty_out(vty
, "OSPF area ID is invalid\n");
1298 return CMD_WARNING_CONFIG_FAILED
;
1301 ret
= inet_aton(router_id
, &vl_config
.vl_peer
);
1303 vty_out(vty
, "Please specify valid Router ID as a.b.c.d\n");
1304 return CMD_WARNING_CONFIG_FAILED
;
1307 for (int idx
= 5; idx
< argc
; idx
++) {
1308 if (strmatch(argv
[idx
]->text
, "hello-interval"))
1309 vl_config
.hello_interval
= OSPF_HELLO_INTERVAL_DEFAULT
;
1310 else if (strmatch(argv
[idx
]->text
, "retransmit-interval"))
1311 vl_config
.retransmit_interval
=
1312 OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
1313 else if (strmatch(argv
[idx
]->text
, "transmit-delay"))
1314 vl_config
.transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
1315 else if (strmatch(argv
[idx
]->text
, "dead-interval"))
1316 vl_config
.dead_interval
=
1317 OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
1320 /* Action configuration */
1321 return ospf_vl_set(ospf
, &vl_config
);
1324 DEFUN (ospf_area_shortcut
,
1325 ospf_area_shortcut_cmd
,
1326 "area <A.B.C.D|(0-4294967295)> shortcut <default|enable|disable>",
1327 "OSPF area parameters\n"
1328 "OSPF area ID in IP address format\n"
1329 "OSPF area ID as a decimal value\n"
1330 "Configure the area's shortcutting mode\n"
1331 "Set default shortcutting behavior\n"
1332 "Enable shortcutting through the area\n"
1333 "Disable shortcutting through the area\n")
1335 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1336 int idx_ipv4_number
= 1;
1337 int idx_enable_disable
= 3;
1338 struct ospf_area
*area
;
1339 struct in_addr area_id
;
1343 VTY_GET_OSPF_AREA_ID_NO_BB("shortcut", area_id
, format
,
1344 argv
[idx_ipv4_number
]->arg
);
1346 area
= ospf_area_get(ospf
, area_id
);
1347 ospf_area_display_format_set(ospf
, area
, format
);
1349 if (strncmp(argv
[idx_enable_disable
]->arg
, "de", 2) == 0)
1350 mode
= OSPF_SHORTCUT_DEFAULT
;
1351 else if (strncmp(argv
[idx_enable_disable
]->arg
, "di", 2) == 0)
1352 mode
= OSPF_SHORTCUT_DISABLE
;
1353 else if (strncmp(argv
[idx_enable_disable
]->arg
, "e", 1) == 0)
1354 mode
= OSPF_SHORTCUT_ENABLE
;
1356 return CMD_WARNING_CONFIG_FAILED
;
1358 ospf_area_shortcut_set(ospf
, area
, mode
);
1360 if (ospf
->abr_type
!= OSPF_ABR_SHORTCUT
)
1362 "Shortcut area setting will take effect only when the router is configured as Shortcut ABR\n");
1367 DEFUN (no_ospf_area_shortcut
,
1368 no_ospf_area_shortcut_cmd
,
1369 "no area <A.B.C.D|(0-4294967295)> shortcut <enable|disable>",
1371 "OSPF area parameters\n"
1372 "OSPF area ID in IP address format\n"
1373 "OSPF area ID as a decimal value\n"
1374 "Deconfigure the area's shortcutting mode\n"
1375 "Deconfigure enabled shortcutting through the area\n"
1376 "Deconfigure disabled shortcutting through the area\n")
1378 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1379 int idx_ipv4_number
= 2;
1380 struct ospf_area
*area
;
1381 struct in_addr area_id
;
1384 VTY_GET_OSPF_AREA_ID_NO_BB("shortcut", area_id
, format
,
1385 argv
[idx_ipv4_number
]->arg
);
1387 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1391 ospf_area_shortcut_unset(ospf
, area
);
1397 DEFUN (ospf_area_stub
,
1399 "area <A.B.C.D|(0-4294967295)> stub",
1400 "OSPF area parameters\n"
1401 "OSPF area ID in IP address format\n"
1402 "OSPF area ID as a decimal value\n"
1403 "Configure OSPF area as stub\n")
1405 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1406 int idx_ipv4_number
= 1;
1407 struct in_addr area_id
;
1410 VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id
, format
,
1411 argv
[idx_ipv4_number
]->arg
);
1413 ret
= ospf_area_stub_set(ospf
, area_id
);
1414 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1418 "First deconfigure all virtual link through this area\n");
1419 return CMD_WARNING_CONFIG_FAILED
;
1422 /* Flush the external LSAs from the specified area */
1423 ospf_flush_lsa_from_area(ospf
, area_id
, OSPF_AS_EXTERNAL_LSA
);
1424 ospf_area_no_summary_unset(ospf
, area_id
);
1429 DEFUN (ospf_area_stub_no_summary
,
1430 ospf_area_stub_no_summary_cmd
,
1431 "area <A.B.C.D|(0-4294967295)> stub no-summary",
1432 "OSPF stub parameters\n"
1433 "OSPF area ID in IP address format\n"
1434 "OSPF area ID as a decimal value\n"
1435 "Configure OSPF area as stub\n"
1436 "Do not inject inter-area routes into stub\n")
1438 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1439 int idx_ipv4_number
= 1;
1440 struct in_addr area_id
;
1443 VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id
, format
,
1444 argv
[idx_ipv4_number
]->arg
);
1446 ret
= ospf_area_stub_set(ospf
, area_id
);
1447 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1451 "%% Area cannot be stub as it contains a virtual link\n");
1452 return CMD_WARNING_CONFIG_FAILED
;
1455 ospf_area_no_summary_set(ospf
, area_id
);
1460 DEFUN (no_ospf_area_stub
,
1461 no_ospf_area_stub_cmd
,
1462 "no area <A.B.C.D|(0-4294967295)> stub",
1464 "OSPF area parameters\n"
1465 "OSPF area ID in IP address format\n"
1466 "OSPF area ID as a decimal value\n"
1467 "Configure OSPF area as stub\n")
1469 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1470 int idx_ipv4_number
= 2;
1471 struct in_addr area_id
;
1474 VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id
, format
,
1475 argv
[idx_ipv4_number
]->arg
);
1477 ospf_area_stub_unset(ospf
, area_id
);
1478 ospf_area_no_summary_unset(ospf
, area_id
);
1483 DEFUN (no_ospf_area_stub_no_summary
,
1484 no_ospf_area_stub_no_summary_cmd
,
1485 "no area <A.B.C.D|(0-4294967295)> stub no-summary",
1487 "OSPF area parameters\n"
1488 "OSPF area ID in IP address format\n"
1489 "OSPF area ID as a decimal value\n"
1490 "Configure OSPF area as stub\n"
1491 "Do not inject inter-area routes into area\n")
1493 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1494 int idx_ipv4_number
= 2;
1495 struct in_addr area_id
;
1498 VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id
, format
,
1499 argv
[idx_ipv4_number
]->arg
);
1500 ospf_area_no_summary_unset(ospf
, area_id
);
1505 static int ospf_area_nssa_cmd_handler(struct vty
*vty
, int argc
,
1506 struct cmd_token
**argv
, int cfg_nosum
,
1509 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1510 struct in_addr area_id
;
1513 VTY_GET_OSPF_AREA_ID_NO_BB("NSSA", area_id
, format
, argv
[1]->arg
);
1515 ret
= ospf_area_nssa_set(ospf
, area_id
);
1516 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1520 "%% Area cannot be nssa as it contains a virtual link\n");
1521 return CMD_WARNING_CONFIG_FAILED
;
1525 if (strncmp(argv
[3]->text
, "translate-c", 11) == 0)
1526 ospf_area_nssa_translator_role_set(
1527 ospf
, area_id
, OSPF_NSSA_ROLE_CANDIDATE
);
1528 else if (strncmp(argv
[3]->text
, "translate-n", 11) == 0)
1529 ospf_area_nssa_translator_role_set(
1530 ospf
, area_id
, OSPF_NSSA_ROLE_NEVER
);
1531 else if (strncmp(argv
[3]->text
, "translate-a", 11) == 0)
1532 ospf_area_nssa_translator_role_set(
1533 ospf
, area_id
, OSPF_NSSA_ROLE_ALWAYS
);
1535 ospf_area_nssa_translator_role_set(ospf
, area_id
,
1536 OSPF_NSSA_ROLE_CANDIDATE
);
1541 ospf_area_no_summary_set(ospf
, area_id
);
1543 ospf_area_no_summary_unset(ospf
, area_id
);
1546 /* Flush the external LSA for the specified area */
1547 ospf_flush_lsa_from_area(ospf
, area_id
, OSPF_AS_EXTERNAL_LSA
);
1548 ospf_schedule_abr_task(ospf
);
1554 DEFUN (ospf_area_nssa_translate
,
1555 ospf_area_nssa_translate_cmd
,
1556 "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always>",
1557 "OSPF area parameters\n"
1558 "OSPF area ID in IP address format\n"
1559 "OSPF area ID as a decimal value\n"
1560 "Configure OSPF area as nssa\n"
1561 "Configure NSSA-ABR for translate election (default)\n"
1562 "Configure NSSA-ABR to never translate\n"
1563 "Configure NSSA-ABR to always translate\n")
1565 return ospf_area_nssa_cmd_handler(vty
, argc
, argv
, 0, 0);
1568 DEFUN (ospf_area_nssa
,
1570 "area <A.B.C.D|(0-4294967295)> nssa",
1571 "OSPF area parameters\n"
1572 "OSPF area ID in IP address format\n"
1573 "OSPF area ID as a decimal value\n"
1574 "Configure OSPF area as nssa\n")
1576 return ospf_area_nssa_cmd_handler(vty
, argc
, argv
, 0, 0);
1579 DEFUN(ospf_area_nssa_suppress_fa
, ospf_area_nssa_suppress_fa_cmd
,
1580 "area <A.B.C.D|(0-4294967295)> nssa suppress-fa",
1581 "OSPF area parameters\n"
1582 "OSPF area ID in IP address format\n"
1583 "OSPF area ID as a decimal value\n"
1584 "Configure OSPF area as nssa\n"
1585 "Suppress forwarding address\n")
1587 int idx_ipv4_number
= 1;
1588 struct in_addr area_id
;
1591 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1592 VTY_GET_OSPF_AREA_ID_NO_BB("NSSA", area_id
, format
,
1593 argv
[idx_ipv4_number
]->arg
);
1595 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1597 ospf_area_nssa_suppress_fa_set(ospf
, area_id
);
1599 ospf_schedule_abr_task(ospf
);
1604 DEFUN(no_ospf_area_nssa_suppress_fa
, no_ospf_area_nssa_suppress_fa_cmd
,
1605 "no area <A.B.C.D|(0-4294967295)> nssa suppress-fa",
1607 "OSPF area parameters\n"
1608 "OSPF area ID in IP address format\n"
1609 "OSPF area ID as a decimal value\n"
1610 "Configure OSPF area as nssa\n"
1611 "Suppress forwarding address\n")
1613 int idx_ipv4_number
= 2;
1614 struct in_addr area_id
;
1617 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1619 VTY_GET_OSPF_AREA_ID_NO_BB("nssa", area_id
, format
,
1620 argv
[idx_ipv4_number
]->arg
);
1622 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1624 ospf_area_nssa_suppress_fa_unset(ospf
, area_id
);
1626 ospf_schedule_abr_task(ospf
);
1631 DEFUN (ospf_area_nssa_no_summary
,
1632 ospf_area_nssa_no_summary_cmd
,
1633 "area <A.B.C.D|(0-4294967295)> nssa no-summary",
1634 "OSPF area parameters\n"
1635 "OSPF area ID in IP address format\n"
1636 "OSPF area ID as a decimal value\n"
1637 "Configure OSPF area as nssa\n"
1638 "Do not inject inter-area routes into nssa\n")
1640 int idx_ipv4_number
= 1;
1641 struct in_addr area_id
;
1644 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1645 VTY_GET_OSPF_AREA_ID_NO_BB("NSSA", area_id
, format
,
1646 argv
[idx_ipv4_number
]->arg
);
1648 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1650 ospf_area_nssa_no_summary_set(ospf
, area_id
);
1652 ospf_schedule_abr_task(ospf
);
1657 DEFUN (no_ospf_area_nssa_no_summary
,
1658 no_ospf_area_nssa_no_summary_cmd
,
1659 "no area <A.B.C.D|(0-4294967295)> nssa no-summary",
1661 "OSPF area parameters\n"
1662 "OSPF area ID in IP address format\n"
1663 "OSPF area ID as a decimal value\n"
1664 "Configure OSPF area as nssa\n"
1665 "Do not inject inter-area routes into nssa\n")
1667 int idx_ipv4_number
= 2;
1668 struct in_addr area_id
;
1671 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1673 VTY_GET_OSPF_AREA_ID_NO_BB("nssa", area_id
, format
,
1674 argv
[idx_ipv4_number
]->arg
);
1676 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1678 ospf_area_no_summary_unset(ospf
, area_id
);
1680 ospf_schedule_abr_task(ospf
);
1685 DEFUN (no_ospf_area_nssa
,
1686 no_ospf_area_nssa_cmd
,
1687 "no area <A.B.C.D|(0-4294967295)> nssa [<translate-candidate|translate-never|translate-always>]",
1689 "OSPF area parameters\n"
1690 "OSPF area ID in IP address format\n"
1691 "OSPF area ID as a decimal value\n"
1692 "Configure OSPF area as nssa\n"
1693 "Configure NSSA-ABR for translate election (default)\n"
1694 "Configure NSSA-ABR to never translate\n"
1695 "Configure NSSA-ABR to always translate\n")
1697 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1698 int idx_ipv4_number
= 2;
1699 struct in_addr area_id
;
1702 VTY_GET_OSPF_AREA_ID_NO_BB("NSSA", area_id
, format
,
1703 argv
[idx_ipv4_number
]->arg
);
1705 /* Flush the NSSA LSA for the specified area */
1706 ospf_flush_lsa_from_area(ospf
, area_id
, OSPF_AS_NSSA_LSA
);
1707 ospf_area_nssa_unset(ospf
, area_id
, argc
);
1709 ospf_schedule_abr_task(ospf
);
1715 DEFUN (ospf_area_default_cost
,
1716 ospf_area_default_cost_cmd
,
1717 "area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1718 "OSPF area parameters\n"
1719 "OSPF area ID in IP address format\n"
1720 "OSPF area ID as a decimal value\n"
1721 "Set the summary-default cost of a NSSA or stub area\n"
1722 "Stub's advertised default summary cost\n")
1724 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1725 int idx_ipv4_number
= 1;
1727 struct ospf_area
*area
;
1728 struct in_addr area_id
;
1731 struct prefix_ipv4 p
;
1733 VTY_GET_OSPF_AREA_ID_NO_BB("default-cost", area_id
, format
,
1734 argv
[idx_ipv4_number
]->arg
);
1735 cost
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1737 area
= ospf_area_get(ospf
, area_id
);
1738 ospf_area_display_format_set(ospf
, area
, format
);
1740 if (area
->external_routing
== OSPF_AREA_DEFAULT
) {
1741 vty_out(vty
, "The area is neither stub, nor NSSA\n");
1742 return CMD_WARNING_CONFIG_FAILED
;
1745 area
->default_cost
= cost
;
1748 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1750 if (IS_DEBUG_OSPF_EVENT
)
1752 "ospf_abr_announce_stub_defaults(): announcing 0.0.0.0/0 to area %pI4",
1754 ospf_abr_announce_network_to_area(&p
, area
->default_cost
, area
);
1759 DEFUN (no_ospf_area_default_cost
,
1760 no_ospf_area_default_cost_cmd
,
1761 "no area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1763 "OSPF area parameters\n"
1764 "OSPF area ID in IP address format\n"
1765 "OSPF area ID as a decimal value\n"
1766 "Set the summary-default cost of a NSSA or stub area\n"
1767 "Stub's advertised default summary cost\n")
1769 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1770 int idx_ipv4_number
= 2;
1771 struct ospf_area
*area
;
1772 struct in_addr area_id
;
1774 struct prefix_ipv4 p
;
1776 VTY_GET_OSPF_AREA_ID_NO_BB("default-cost", area_id
, format
,
1777 argv
[idx_ipv4_number
]->arg
);
1779 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1783 if (area
->external_routing
== OSPF_AREA_DEFAULT
) {
1784 vty_out(vty
, "The area is neither stub, nor NSSA\n");
1785 return CMD_WARNING_CONFIG_FAILED
;
1788 area
->default_cost
= 1;
1791 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1793 if (IS_DEBUG_OSPF_EVENT
)
1795 "ospf_abr_announce_stub_defaults(): announcing 0.0.0.0/0 to area %pI4",
1797 ospf_abr_announce_network_to_area(&p
, area
->default_cost
, area
);
1800 ospf_area_check_free(ospf
, area_id
);
1805 DEFUN (ospf_area_export_list
,
1806 ospf_area_export_list_cmd
,
1807 "area <A.B.C.D|(0-4294967295)> export-list NAME",
1808 "OSPF area parameters\n"
1809 "OSPF area ID in IP address format\n"
1810 "OSPF area ID as a decimal value\n"
1811 "Set the filter for networks announced to other areas\n"
1812 "Name of the access-list\n")
1814 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1815 int idx_ipv4_number
= 1;
1816 struct ospf_area
*area
;
1817 struct in_addr area_id
;
1820 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1822 area
= ospf_area_get(ospf
, area_id
);
1823 ospf_area_display_format_set(ospf
, area
, format
);
1824 ospf_area_export_list_set(ospf
, area
, argv
[3]->arg
);
1829 DEFUN (no_ospf_area_export_list
,
1830 no_ospf_area_export_list_cmd
,
1831 "no area <A.B.C.D|(0-4294967295)> export-list NAME",
1833 "OSPF area parameters\n"
1834 "OSPF area ID in IP address format\n"
1835 "OSPF area ID as a decimal value\n"
1836 "Unset the filter for networks announced to other areas\n"
1837 "Name of the access-list\n")
1839 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1840 int idx_ipv4_number
= 2;
1841 struct ospf_area
*area
;
1842 struct in_addr area_id
;
1845 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1847 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1851 ospf_area_export_list_unset(ospf
, area
);
1857 DEFUN (ospf_area_import_list
,
1858 ospf_area_import_list_cmd
,
1859 "area <A.B.C.D|(0-4294967295)> import-list NAME",
1860 "OSPF area parameters\n"
1861 "OSPF area ID in IP address format\n"
1862 "OSPF area ID as a decimal value\n"
1863 "Set the filter for networks from other areas announced to the specified one\n"
1864 "Name of the access-list\n")
1866 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1867 int idx_ipv4_number
= 1;
1868 struct ospf_area
*area
;
1869 struct in_addr area_id
;
1872 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1874 area
= ospf_area_get(ospf
, area_id
);
1875 ospf_area_display_format_set(ospf
, area
, format
);
1876 ospf_area_import_list_set(ospf
, area
, argv
[3]->arg
);
1881 DEFUN (no_ospf_area_import_list
,
1882 no_ospf_area_import_list_cmd
,
1883 "no area <A.B.C.D|(0-4294967295)> import-list NAME",
1885 "OSPF area parameters\n"
1886 "OSPF area ID in IP address format\n"
1887 "OSPF area ID as a decimal value\n"
1888 "Unset the filter for networks announced to other areas\n"
1889 "Name of the access-list\n")
1891 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1892 int idx_ipv4_number
= 2;
1893 struct ospf_area
*area
;
1894 struct in_addr area_id
;
1897 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1899 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1903 ospf_area_import_list_unset(ospf
, area
);
1908 DEFUN (ospf_area_filter_list
,
1909 ospf_area_filter_list_cmd
,
1910 "area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>",
1911 "OSPF area parameters\n"
1912 "OSPF area ID in IP address format\n"
1913 "OSPF area ID as a decimal value\n"
1914 "Filter networks between OSPF areas\n"
1915 "Filter prefixes between OSPF areas\n"
1916 "Name of an IP prefix-list\n"
1917 "Filter networks sent to this area\n"
1918 "Filter networks sent from this area\n")
1920 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1921 int idx_ipv4_number
= 1;
1924 struct ospf_area
*area
;
1925 struct in_addr area_id
;
1926 struct prefix_list
*plist
;
1929 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1931 area
= ospf_area_get(ospf
, area_id
);
1932 ospf_area_display_format_set(ospf
, area
, format
);
1933 plist
= prefix_list_lookup(AFI_IP
, argv
[idx_word
]->arg
);
1934 if (strncmp(argv
[idx_in_out
]->arg
, "in", 2) == 0) {
1935 PREFIX_LIST_IN(area
) = plist
;
1936 if (PREFIX_NAME_IN(area
))
1937 free(PREFIX_NAME_IN(area
));
1939 PREFIX_NAME_IN(area
) = strdup(argv
[idx_word
]->arg
);
1940 ospf_schedule_abr_task(ospf
);
1942 PREFIX_LIST_OUT(area
) = plist
;
1943 if (PREFIX_NAME_OUT(area
))
1944 free(PREFIX_NAME_OUT(area
));
1946 PREFIX_NAME_OUT(area
) = strdup(argv
[idx_word
]->arg
);
1947 ospf_schedule_abr_task(ospf
);
1953 DEFUN (no_ospf_area_filter_list
,
1954 no_ospf_area_filter_list_cmd
,
1955 "no area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>",
1957 "OSPF area parameters\n"
1958 "OSPF area ID in IP address format\n"
1959 "OSPF area ID as a decimal value\n"
1960 "Filter networks between OSPF areas\n"
1961 "Filter prefixes between OSPF areas\n"
1962 "Name of an IP prefix-list\n"
1963 "Filter networks sent to this area\n"
1964 "Filter networks sent from this area\n")
1966 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1967 int idx_ipv4_number
= 2;
1970 struct ospf_area
*area
;
1971 struct in_addr area_id
;
1974 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1976 if ((area
= ospf_area_lookup_by_area_id(ospf
, area_id
)) == NULL
)
1979 if (strncmp(argv
[idx_in_out
]->arg
, "in", 2) == 0) {
1980 if (PREFIX_NAME_IN(area
))
1981 if (strcmp(PREFIX_NAME_IN(area
), argv
[idx_word
]->arg
)
1985 PREFIX_LIST_IN(area
) = NULL
;
1986 if (PREFIX_NAME_IN(area
))
1987 free(PREFIX_NAME_IN(area
));
1989 PREFIX_NAME_IN(area
) = NULL
;
1991 ospf_schedule_abr_task(ospf
);
1993 if (PREFIX_NAME_OUT(area
))
1994 if (strcmp(PREFIX_NAME_OUT(area
), argv
[idx_word
]->arg
)
1998 PREFIX_LIST_OUT(area
) = NULL
;
1999 if (PREFIX_NAME_OUT(area
))
2000 free(PREFIX_NAME_OUT(area
));
2002 PREFIX_NAME_OUT(area
) = NULL
;
2004 ospf_schedule_abr_task(ospf
);
2011 DEFUN (ospf_area_authentication_message_digest
,
2012 ospf_area_authentication_message_digest_cmd
,
2013 "[no] area <A.B.C.D|(0-4294967295)> authentication message-digest",
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"
2019 "Use message-digest authentication\n")
2021 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2023 struct ospf_area
*area
;
2024 struct in_addr area_id
;
2027 argv_find(argv
, argc
, "area", &idx
);
2028 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx
+ 1]->arg
);
2030 area
= ospf_area_get(ospf
, area_id
);
2031 ospf_area_display_format_set(ospf
, area
, format
);
2032 area
->auth_type
= strmatch(argv
[0]->text
, "no")
2034 : OSPF_AUTH_CRYPTOGRAPHIC
;
2039 DEFUN (ospf_area_authentication
,
2040 ospf_area_authentication_cmd
,
2041 "area <A.B.C.D|(0-4294967295)> authentication",
2042 "OSPF area parameters\n"
2043 "OSPF area ID in IP address format\n"
2044 "OSPF area ID as a decimal value\n"
2045 "Enable authentication\n")
2047 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2048 int idx_ipv4_number
= 1;
2049 struct ospf_area
*area
;
2050 struct in_addr area_id
;
2053 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
2055 area
= ospf_area_get(ospf
, area_id
);
2056 ospf_area_display_format_set(ospf
, area
, format
);
2057 area
->auth_type
= OSPF_AUTH_SIMPLE
;
2062 DEFUN (no_ospf_area_authentication
,
2063 no_ospf_area_authentication_cmd
,
2064 "no area <A.B.C.D|(0-4294967295)> authentication",
2066 "OSPF area parameters\n"
2067 "OSPF area ID in IP address format\n"
2068 "OSPF area ID as a decimal value\n"
2069 "Enable authentication\n")
2071 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2072 int idx_ipv4_number
= 2;
2073 struct ospf_area
*area
;
2074 struct in_addr area_id
;
2077 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
2079 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
2083 area
->auth_type
= OSPF_AUTH_NULL
;
2085 ospf_area_check_free(ospf
, area_id
);
2091 DEFUN (ospf_abr_type
,
2093 "ospf abr-type <cisco|ibm|shortcut|standard>",
2094 "OSPF specific commands\n"
2095 "Set OSPF ABR type\n"
2096 "Alternative ABR, cisco implementation\n"
2097 "Alternative ABR, IBM implementation\n"
2099 "Standard behavior (RFC2328)\n")
2101 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2103 uint8_t abr_type
= OSPF_ABR_UNKNOWN
;
2105 if (strncmp(argv
[idx_vendor
]->arg
, "c", 1) == 0)
2106 abr_type
= OSPF_ABR_CISCO
;
2107 else if (strncmp(argv
[idx_vendor
]->arg
, "i", 1) == 0)
2108 abr_type
= OSPF_ABR_IBM
;
2109 else if (strncmp(argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2110 abr_type
= OSPF_ABR_SHORTCUT
;
2111 else if (strncmp(argv
[idx_vendor
]->arg
, "st", 2) == 0)
2112 abr_type
= OSPF_ABR_STAND
;
2114 return CMD_WARNING_CONFIG_FAILED
;
2116 /* If ABR type value is changed, schedule ABR task. */
2117 if (ospf
->abr_type
!= abr_type
) {
2118 ospf
->abr_type
= abr_type
;
2119 ospf_schedule_abr_task(ospf
);
2125 DEFUN (no_ospf_abr_type
,
2126 no_ospf_abr_type_cmd
,
2127 "no ospf abr-type <cisco|ibm|shortcut|standard>",
2129 "OSPF specific commands\n"
2130 "Set OSPF ABR type\n"
2131 "Alternative ABR, cisco implementation\n"
2132 "Alternative ABR, IBM implementation\n"
2136 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2138 uint8_t abr_type
= OSPF_ABR_UNKNOWN
;
2140 if (strncmp(argv
[idx_vendor
]->arg
, "c", 1) == 0)
2141 abr_type
= OSPF_ABR_CISCO
;
2142 else if (strncmp(argv
[idx_vendor
]->arg
, "i", 1) == 0)
2143 abr_type
= OSPF_ABR_IBM
;
2144 else if (strncmp(argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2145 abr_type
= OSPF_ABR_SHORTCUT
;
2146 else if (strncmp(argv
[idx_vendor
]->arg
, "st", 2) == 0)
2147 abr_type
= OSPF_ABR_STAND
;
2149 return CMD_WARNING_CONFIG_FAILED
;
2151 /* If ABR type value is changed, schedule ABR task. */
2152 if (ospf
->abr_type
== abr_type
) {
2153 ospf
->abr_type
= OSPF_ABR_DEFAULT
;
2154 ospf_schedule_abr_task(ospf
);
2160 DEFUN (ospf_log_adjacency_changes
,
2161 ospf_log_adjacency_changes_cmd
,
2162 "log-adjacency-changes",
2163 "Log changes in adjacency state\n")
2165 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2167 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2168 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2172 DEFUN (ospf_log_adjacency_changes_detail
,
2173 ospf_log_adjacency_changes_detail_cmd
,
2174 "log-adjacency-changes detail",
2175 "Log changes in adjacency state\n"
2176 "Log all state changes\n")
2178 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2180 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2181 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2185 DEFUN (no_ospf_log_adjacency_changes
,
2186 no_ospf_log_adjacency_changes_cmd
,
2187 "no log-adjacency-changes",
2189 "Log changes in adjacency state\n")
2191 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2193 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2194 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2198 DEFUN (no_ospf_log_adjacency_changes_detail
,
2199 no_ospf_log_adjacency_changes_detail_cmd
,
2200 "no log-adjacency-changes detail",
2202 "Log changes in adjacency state\n"
2203 "Log all state changes\n")
2205 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2207 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2211 DEFUN (ospf_compatible_rfc1583
,
2212 ospf_compatible_rfc1583_cmd
,
2213 "compatible rfc1583",
2214 "OSPF compatibility list\n"
2215 "compatible with RFC 1583\n")
2217 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2219 if (!CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)) {
2220 SET_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2221 ospf_spf_calculate_schedule(ospf
, SPF_FLAG_CONFIG_CHANGE
);
2226 DEFUN (no_ospf_compatible_rfc1583
,
2227 no_ospf_compatible_rfc1583_cmd
,
2228 "no compatible rfc1583",
2230 "OSPF compatibility list\n"
2231 "compatible with RFC 1583\n")
2233 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2235 if (CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)) {
2236 UNSET_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2237 ospf_spf_calculate_schedule(ospf
, SPF_FLAG_CONFIG_CHANGE
);
2242 ALIAS(ospf_compatible_rfc1583
, ospf_rfc1583_flag_cmd
,
2243 "ospf rfc1583compatibility",
2244 "OSPF specific commands\n"
2245 "Enable the RFC1583Compatibility flag\n")
2247 ALIAS(no_ospf_compatible_rfc1583
, no_ospf_rfc1583_flag_cmd
,
2248 "no ospf rfc1583compatibility", NO_STR
2249 "OSPF specific commands\n"
2250 "Disable the RFC1583Compatibility flag\n")
2252 static int ospf_timers_spf_set(struct vty
*vty
, unsigned int delay
,
2253 unsigned int hold
, unsigned int max
)
2255 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2257 ospf
->spf_delay
= delay
;
2258 ospf
->spf_holdtime
= hold
;
2259 ospf
->spf_max_holdtime
= max
;
2264 DEFUN (ospf_timers_min_ls_interval
,
2265 ospf_timers_min_ls_interval_cmd
,
2266 "timers throttle lsa all (0-5000)",
2267 "Adjust routing timers\n"
2268 "Throttling adaptive timer\n"
2269 "LSA delay between transmissions\n"
2271 "Delay (msec) between sending LSAs\n")
2273 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2275 unsigned int interval
;
2278 vty_out(vty
, "Insufficient arguments\n");
2279 return CMD_WARNING_CONFIG_FAILED
;
2282 interval
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2284 ospf
->min_ls_interval
= interval
;
2289 DEFUN (no_ospf_timers_min_ls_interval
,
2290 no_ospf_timers_min_ls_interval_cmd
,
2291 "no timers throttle lsa all [(0-5000)]",
2293 "Adjust routing timers\n"
2294 "Throttling adaptive timer\n"
2295 "LSA delay between transmissions\n"
2297 "Delay (msec) between sending LSAs\n")
2299 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2300 ospf
->min_ls_interval
= OSPF_MIN_LS_INTERVAL
;
2305 DEFUN (ospf_timers_throttle_spf
,
2306 ospf_timers_throttle_spf_cmd
,
2307 "timers throttle spf (0-600000) (0-600000) (0-600000)",
2308 "Adjust routing timers\n"
2309 "Throttling adaptive timer\n"
2311 "Delay (msec) from first change received till SPF calculation\n"
2312 "Initial hold time (msec) between consecutive SPF calculations\n"
2313 "Maximum hold time (msec)\n")
2316 int idx_number_2
= 4;
2317 int idx_number_3
= 5;
2318 unsigned int delay
, hold
, max
;
2321 vty_out(vty
, "Insufficient arguments\n");
2322 return CMD_WARNING_CONFIG_FAILED
;
2325 delay
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2326 hold
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
2327 max
= strtoul(argv
[idx_number_3
]->arg
, NULL
, 10);
2329 return ospf_timers_spf_set(vty
, delay
, hold
, max
);
2332 DEFUN (no_ospf_timers_throttle_spf
,
2333 no_ospf_timers_throttle_spf_cmd
,
2334 "no timers throttle spf [(0-600000)(0-600000)(0-600000)]",
2336 "Adjust routing timers\n"
2337 "Throttling adaptive timer\n"
2339 "Delay (msec) from first change received till SPF calculation\n"
2340 "Initial hold time (msec) between consecutive SPF calculations\n"
2341 "Maximum hold time (msec)\n")
2343 return ospf_timers_spf_set(vty
, OSPF_SPF_DELAY_DEFAULT
,
2344 OSPF_SPF_HOLDTIME_DEFAULT
,
2345 OSPF_SPF_MAX_HOLDTIME_DEFAULT
);
2349 DEFUN (ospf_timers_lsa_min_arrival
,
2350 ospf_timers_lsa_min_arrival_cmd
,
2351 "timers lsa min-arrival (0-600000)",
2352 "Adjust routing timers\n"
2354 "Minimum delay in receiving new version of a LSA\n"
2355 "Delay in milliseconds\n")
2357 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2358 ospf
->min_ls_arrival
= strtoul(argv
[argc
- 1]->arg
, NULL
, 10);
2362 DEFUN (no_ospf_timers_lsa_min_arrival
,
2363 no_ospf_timers_lsa_min_arrival_cmd
,
2364 "no timers lsa min-arrival [(0-600000)]",
2366 "Adjust routing timers\n"
2368 "Minimum delay in receiving new version of a LSA\n"
2369 "Delay in milliseconds\n")
2371 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2372 unsigned int minarrival
;
2375 minarrival
= strtoul(argv
[argc
- 1]->arg
, NULL
, 10);
2377 if (ospf
->min_ls_arrival
!= minarrival
2378 || minarrival
== OSPF_MIN_LS_ARRIVAL
)
2382 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2387 DEFUN (ospf_neighbor
,
2389 "neighbor A.B.C.D [priority (0-255) [poll-interval (1-65535)]]",
2391 "Neighbor IP address\n"
2392 "Neighbor Priority\n"
2394 "Dead Neighbor Polling interval\n"
2397 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2401 struct in_addr nbr_addr
;
2402 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2403 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2405 if (!inet_aton(argv
[idx_ipv4
]->arg
, &nbr_addr
)) {
2406 vty_out(vty
, "Please specify Neighbor ID by A.B.C.D\n");
2407 return CMD_WARNING_CONFIG_FAILED
;
2411 priority
= strtoul(argv
[idx_pri
]->arg
, NULL
, 10);
2414 interval
= strtoul(argv
[idx_poll
]->arg
, NULL
, 10);
2416 ospf_nbr_nbma_set(ospf
, nbr_addr
);
2419 ospf_nbr_nbma_priority_set(ospf
, nbr_addr
, priority
);
2422 ospf_nbr_nbma_poll_interval_set(ospf
, nbr_addr
, interval
);
2427 DEFUN (ospf_neighbor_poll_interval
,
2428 ospf_neighbor_poll_interval_cmd
,
2429 "neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2431 "Neighbor IP address\n"
2432 "Dead Neighbor Polling interval\n"
2434 "OSPF priority of non-broadcast neighbor\n"
2437 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2441 struct in_addr nbr_addr
;
2442 unsigned int priority
;
2443 unsigned int interval
;
2445 if (!inet_aton(argv
[idx_ipv4
]->arg
, &nbr_addr
)) {
2446 vty_out(vty
, "Please specify Neighbor ID by A.B.C.D\n");
2447 return CMD_WARNING_CONFIG_FAILED
;
2450 interval
= strtoul(argv
[idx_poll
]->arg
, NULL
, 10);
2452 priority
= argc
> 4 ? strtoul(argv
[idx_pri
]->arg
, NULL
, 10)
2453 : OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2455 ospf_nbr_nbma_set(ospf
, nbr_addr
);
2456 ospf_nbr_nbma_poll_interval_set(ospf
, nbr_addr
, interval
);
2459 ospf_nbr_nbma_priority_set(ospf
, nbr_addr
, priority
);
2464 DEFUN (no_ospf_neighbor
,
2465 no_ospf_neighbor_cmd
,
2466 "no neighbor A.B.C.D [priority (0-255) [poll-interval (1-65525)]]",
2469 "Neighbor IP address\n"
2470 "Neighbor Priority\n"
2472 "Dead Neighbor Polling interval\n"
2475 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2477 struct in_addr nbr_addr
;
2479 if (!inet_aton(argv
[idx_ipv4
]->arg
, &nbr_addr
)) {
2480 vty_out(vty
, "Please specify Neighbor ID by A.B.C.D\n");
2481 return CMD_WARNING_CONFIG_FAILED
;
2484 (void)ospf_nbr_nbma_unset(ospf
, nbr_addr
);
2489 DEFUN (no_ospf_neighbor_poll
,
2490 no_ospf_neighbor_poll_cmd
,
2491 "no neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2494 "Neighbor IP address\n"
2495 "Dead Neighbor Polling interval\n"
2497 "Neighbor Priority\n"
2500 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2502 struct in_addr nbr_addr
;
2504 if (!inet_aton(argv
[idx_ipv4
]->arg
, &nbr_addr
)) {
2505 vty_out(vty
, "Please specify Neighbor ID by A.B.C.D\n");
2506 return CMD_WARNING_CONFIG_FAILED
;
2509 (void)ospf_nbr_nbma_unset(ospf
, nbr_addr
);
2514 DEFUN (ospf_refresh_timer
,
2515 ospf_refresh_timer_cmd
,
2516 "refresh timer (10-1800)",
2517 "Adjust refresh parameters\n"
2518 "Set refresh timer\n"
2519 "Timer value in seconds\n")
2521 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2523 unsigned int interval
;
2525 interval
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2526 interval
= (interval
/ OSPF_LSA_REFRESHER_GRANULARITY
)
2527 * OSPF_LSA_REFRESHER_GRANULARITY
;
2529 ospf_timers_refresh_set(ospf
, interval
);
2534 DEFUN (no_ospf_refresh_timer
,
2535 no_ospf_refresh_timer_val_cmd
,
2536 "no refresh timer [(10-1800)]",
2538 "Adjust refresh parameters\n"
2539 "Unset refresh timer\n"
2540 "Timer value in seconds\n")
2542 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2544 unsigned int interval
;
2547 interval
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2549 if (ospf
->lsa_refresh_interval
!= interval
2550 || interval
== OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
2554 ospf_timers_refresh_unset(ospf
);
2560 DEFUN (ospf_auto_cost_reference_bandwidth
,
2561 ospf_auto_cost_reference_bandwidth_cmd
,
2562 "auto-cost reference-bandwidth (1-4294967)",
2563 "Calculate OSPF interface cost according to bandwidth\n"
2564 "Use reference bandwidth method to assign OSPF cost\n"
2565 "The reference bandwidth in terms of Mbits per second\n")
2567 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2568 struct vrf
*vrf
= vrf_lookup_by_id(ospf
->vrf_id
);
2571 struct interface
*ifp
;
2573 refbw
= strtol(argv
[idx_number
]->arg
, NULL
, 10);
2574 if (refbw
< 1 || refbw
> 4294967) {
2575 vty_out(vty
, "reference-bandwidth value is invalid\n");
2576 return CMD_WARNING_CONFIG_FAILED
;
2579 /* If reference bandwidth is changed. */
2580 if ((refbw
) == ospf
->ref_bandwidth
)
2583 ospf
->ref_bandwidth
= refbw
;
2584 FOR_ALL_INTERFACES (vrf
, ifp
)
2585 ospf_if_recalculate_output_cost(ifp
);
2590 DEFUN (no_ospf_auto_cost_reference_bandwidth
,
2591 no_ospf_auto_cost_reference_bandwidth_cmd
,
2592 "no auto-cost reference-bandwidth [(1-4294967)]",
2594 "Calculate OSPF interface cost according to bandwidth\n"
2595 "Use reference bandwidth method to assign OSPF cost\n"
2596 "The reference bandwidth in terms of Mbits per second\n")
2598 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2599 struct vrf
*vrf
= vrf_lookup_by_id(ospf
->vrf_id
);
2600 struct interface
*ifp
;
2602 if (ospf
->ref_bandwidth
== OSPF_DEFAULT_REF_BANDWIDTH
)
2605 ospf
->ref_bandwidth
= OSPF_DEFAULT_REF_BANDWIDTH
;
2606 vty_out(vty
, "%% OSPF: Reference bandwidth is changed.\n");
2608 " Please ensure reference bandwidth is consistent across all routers\n");
2610 FOR_ALL_INTERFACES (vrf
, ifp
)
2611 ospf_if_recalculate_output_cost(ifp
);
2616 DEFUN (ospf_write_multiplier
,
2617 ospf_write_multiplier_cmd
,
2618 "ospf write-multiplier (1-100)",
2619 "OSPF specific commands\n"
2620 "Write multiplier\n"
2621 "Maximum number of interface serviced per write\n")
2623 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2625 uint32_t write_oi_count
;
2632 write_oi_count
= strtol(argv
[idx_number
]->arg
, NULL
, 10);
2633 if (write_oi_count
< 1 || write_oi_count
> 100) {
2634 vty_out(vty
, "write-multiplier value is invalid\n");
2635 return CMD_WARNING_CONFIG_FAILED
;
2638 ospf
->write_oi_count
= write_oi_count
;
2642 ALIAS(ospf_write_multiplier
, write_multiplier_cmd
, "write-multiplier (1-100)",
2643 "Write multiplier\n"
2644 "Maximum number of interface serviced per write\n")
2646 DEFUN (no_ospf_write_multiplier
,
2647 no_ospf_write_multiplier_cmd
,
2648 "no ospf write-multiplier (1-100)",
2650 "OSPF specific commands\n"
2651 "Write multiplier\n"
2652 "Maximum number of interface serviced per write\n")
2654 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2656 ospf
->write_oi_count
= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
;
2660 ALIAS(no_ospf_write_multiplier
, no_write_multiplier_cmd
,
2661 "no write-multiplier (1-100)", NO_STR
2662 "Write multiplier\n"
2663 "Maximum number of interface serviced per write\n")
2665 DEFUN(ospf_ti_lfa
, ospf_ti_lfa_cmd
, "fast-reroute ti-lfa [node-protection]",
2666 "Fast Reroute for MPLS and IP resilience\n"
2667 "Topology Independent LFA (Loop-Free Alternate)\n"
2668 "TI-LFA node protection (default is link protection)\n")
2670 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2672 ospf
->ti_lfa_enabled
= true;
2675 ospf
->ti_lfa_protection_type
= OSPF_TI_LFA_NODE_PROTECTION
;
2677 ospf
->ti_lfa_protection_type
= OSPF_TI_LFA_LINK_PROTECTION
;
2679 ospf_spf_calculate_schedule(ospf
, SPF_FLAG_CONFIG_CHANGE
);
2684 DEFUN(no_ospf_ti_lfa
, no_ospf_ti_lfa_cmd
,
2685 "no fast-reroute ti-lfa [node-protection]",
2687 "Fast Reroute for MPLS and IP resilience\n"
2688 "Topology Independent LFA (Loop-Free Alternate)\n"
2689 "TI-LFA node protection (default is link protection)\n")
2691 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2693 ospf
->ti_lfa_enabled
= false;
2695 ospf
->ti_lfa_protection_type
= OSPF_TI_LFA_UNDEFINED_PROTECTION
;
2697 ospf_spf_calculate_schedule(ospf
, SPF_FLAG_CONFIG_CHANGE
);
2702 static void ospf_maxpath_set(struct vty
*vty
, struct ospf
*ospf
, uint16_t paths
)
2704 if (ospf
->max_multipath
== paths
)
2707 ospf
->max_multipath
= paths
;
2709 /* Send deletion notification to zebra to delete all
2710 * ospf specific routes and reinitiat SPF to reflect
2711 * the new max multipath.
2713 ospf_restart_spf(ospf
);
2716 /* Ospf Maximum multiple paths config support */
2717 DEFUN (ospf_max_multipath
,
2718 ospf_max_multipath_cmd
,
2719 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2720 "Max no of multiple paths for ECMP support\n"
2721 "Number of paths\n")
2723 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2727 maxpaths
= strtol(argv
[idx_number
]->arg
, NULL
, 10);
2729 ospf_maxpath_set(vty
, ospf
, maxpaths
);
2733 DEFUN (no_ospf_max_multipath
,
2734 no_ospf_max_multipath_cmd
,
2737 "Max no of multiple paths for ECMP support\n")
2739 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2740 uint16_t maxpaths
= MULTIPATH_NUM
;
2742 ospf_maxpath_set(vty
, ospf
, maxpaths
);
2746 static const char *const ospf_abr_type_descr_str
[] = {
2747 "Unknown", "Standard (RFC2328)", "Alternative IBM",
2748 "Alternative Cisco", "Alternative Shortcut"
2751 static const char *const ospf_shortcut_mode_descr_str
[] = {
2752 "Default", "Enabled", "Disabled"
2755 static void show_ip_ospf_area(struct vty
*vty
, struct ospf_area
*area
,
2756 json_object
*json_areas
, bool use_json
)
2758 json_object
*json_area
= NULL
;
2759 char buf
[PREFIX_STRLEN
];
2762 json_area
= json_object_new_object();
2766 vty_out(vty
, " Area ID: %pI4", &area
->area_id
);
2768 /* Show Area type/mode. */
2769 if (OSPF_IS_AREA_BACKBONE(area
)) {
2771 json_object_boolean_true_add(json_area
, "backbone");
2773 vty_out(vty
, " (Backbone)\n");
2776 if (area
->external_routing
== OSPF_AREA_STUB
) {
2777 if (area
->no_summary
)
2778 json_object_boolean_true_add(
2779 json_area
, "stubNoSummary");
2780 if (area
->shortcut_configured
)
2781 json_object_boolean_true_add(
2782 json_area
, "stubShortcut");
2783 } else if (area
->external_routing
== OSPF_AREA_NSSA
) {
2784 if (area
->no_summary
)
2785 json_object_boolean_true_add(
2786 json_area
, "nssaNoSummary");
2787 if (area
->shortcut_configured
)
2788 json_object_boolean_true_add(
2789 json_area
, "nssaShortcut");
2792 json_object_string_add(
2793 json_area
, "shortcuttingMode",
2794 ospf_shortcut_mode_descr_str
2795 [area
->shortcut_configured
]);
2796 if (area
->shortcut_capability
)
2797 json_object_boolean_true_add(json_area
,
2800 if (area
->external_routing
== OSPF_AREA_STUB
)
2801 vty_out(vty
, " (Stub%s%s)",
2802 area
->no_summary
? ", no summary" : "",
2803 area
->shortcut_configured
? "; " : "");
2804 else if (area
->external_routing
== OSPF_AREA_NSSA
)
2805 vty_out(vty
, " (NSSA%s%s)",
2806 area
->no_summary
? ", no summary" : "",
2807 area
->shortcut_configured
? "; " : "");
2810 vty_out(vty
, " Shortcutting mode: %s",
2811 ospf_shortcut_mode_descr_str
2812 [area
->shortcut_configured
]);
2813 vty_out(vty
, ", S-bit consensus: %s\n",
2814 area
->shortcut_capability
? "ok" : "no");
2818 /* Show number of interfaces */
2820 json_object_int_add(json_area
, "areaIfTotalCounter",
2821 listcount(area
->oiflist
));
2822 json_object_int_add(json_area
, "areaIfActiveCounter",
2826 " Number of interfaces in this area: Total: %d, Active: %d\n",
2827 listcount(area
->oiflist
), area
->act_ints
);
2829 if (area
->external_routing
== OSPF_AREA_NSSA
) {
2831 json_object_boolean_true_add(json_area
, "nssa");
2832 if (!IS_OSPF_ABR(area
->ospf
))
2833 json_object_boolean_false_add(json_area
, "abr");
2834 else if (area
->NSSATranslatorState
) {
2835 json_object_boolean_true_add(json_area
, "abr");
2836 if (area
->NSSATranslatorRole
2837 == OSPF_NSSA_ROLE_CANDIDATE
)
2838 json_object_boolean_true_add(
2840 "nssaTranslatorElected");
2841 else if (area
->NSSATranslatorRole
2842 == OSPF_NSSA_ROLE_ALWAYS
)
2843 json_object_boolean_true_add(
2845 "nssaTranslatorAlways");
2847 json_object_boolean_true_add(
2849 "nssaTranslatorNever");
2851 json_object_boolean_true_add(json_area
, "abr");
2852 if (area
->NSSATranslatorRole
2853 == OSPF_NSSA_ROLE_CANDIDATE
)
2854 json_object_boolean_false_add(
2856 "nssaTranslatorElected");
2858 json_object_boolean_true_add(
2860 "nssaTranslatorNever");
2864 " It is an NSSA configuration.\n Elected NSSA/ABR performs type-7/type-5 LSA translation.\n");
2865 if (!IS_OSPF_ABR(area
->ospf
))
2867 " It is not ABR, therefore not Translator.\n");
2868 else if (area
->NSSATranslatorState
) {
2869 vty_out(vty
, " We are an ABR and ");
2870 if (area
->NSSATranslatorRole
2871 == OSPF_NSSA_ROLE_CANDIDATE
)
2873 "the NSSA Elected Translator.\n");
2874 else if (area
->NSSATranslatorRole
2875 == OSPF_NSSA_ROLE_ALWAYS
)
2877 "always an NSSA Translator.\n");
2880 "never an NSSA Translator.\n");
2882 vty_out(vty
, " We are an ABR, but ");
2883 if (area
->NSSATranslatorRole
2884 == OSPF_NSSA_ROLE_CANDIDATE
)
2886 "not the NSSA Elected Translator.\n");
2889 "never an NSSA Translator.\n");
2894 /* Stub-router state for this area */
2895 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
)) {
2896 char timebuf
[OSPF_TIME_DUMP_SIZE
];
2899 json_object_boolean_true_add(
2900 json_area
, "originStubMaxDistRouterLsa");
2901 if (CHECK_FLAG(area
->stub_router_state
,
2902 OSPF_AREA_ADMIN_STUB_ROUTED
))
2903 json_object_boolean_true_add(
2904 json_area
, "indefiniteActiveAdmin");
2905 if (area
->t_stub_router
) {
2909 &area
->t_stub_router
->u
.sands
,
2912 json_object_int_add(
2914 "activeStartupRemainderMsecs",
2919 " Originating stub / maximum-distance Router-LSA\n");
2920 if (CHECK_FLAG(area
->stub_router_state
,
2921 OSPF_AREA_ADMIN_STUB_ROUTED
))
2923 " Administratively activated (indefinitely)\n");
2924 if (area
->t_stub_router
)
2926 " Active from startup, %s remaining\n",
2927 ospf_timer_dump(area
->t_stub_router
,
2934 /* Show number of fully adjacent neighbors. */
2935 json_object_int_add(json_area
, "nbrFullAdjacentCounter",
2938 /* Show authentication type. */
2939 if (area
->auth_type
== OSPF_AUTH_NULL
)
2940 json_object_string_add(json_area
, "authentication",
2941 "authenticationNone");
2942 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
2943 json_object_string_add(json_area
, "authentication",
2944 "authenticationSimplePassword");
2945 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
2946 json_object_string_add(json_area
, "authentication",
2947 "authenticationMessageDigest");
2949 if (!OSPF_IS_AREA_BACKBONE(area
))
2950 json_object_int_add(json_area
,
2951 "virtualAdjacenciesPassingCounter",
2954 /* Show SPF calculation times. */
2955 json_object_int_add(json_area
, "spfExecutedCounter",
2956 area
->spf_calculation
);
2957 json_object_int_add(json_area
, "lsaNumber", area
->lsdb
->total
);
2958 json_object_int_add(
2959 json_area
, "lsaRouterNumber",
2960 ospf_lsdb_count(area
->lsdb
, OSPF_ROUTER_LSA
));
2961 json_object_int_add(
2962 json_area
, "lsaRouterChecksum",
2963 ospf_lsdb_checksum(area
->lsdb
, OSPF_ROUTER_LSA
));
2964 json_object_int_add(
2965 json_area
, "lsaNetworkNumber",
2966 ospf_lsdb_count(area
->lsdb
, OSPF_NETWORK_LSA
));
2967 json_object_int_add(
2968 json_area
, "lsaNetworkChecksum",
2969 ospf_lsdb_checksum(area
->lsdb
, OSPF_NETWORK_LSA
));
2970 json_object_int_add(
2971 json_area
, "lsaSummaryNumber",
2972 ospf_lsdb_count(area
->lsdb
, OSPF_SUMMARY_LSA
));
2973 json_object_int_add(
2974 json_area
, "lsaSummaryChecksum",
2975 ospf_lsdb_checksum(area
->lsdb
, OSPF_SUMMARY_LSA
));
2976 json_object_int_add(
2977 json_area
, "lsaAsbrNumber",
2978 ospf_lsdb_count(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2979 json_object_int_add(
2980 json_area
, "lsaAsbrChecksum",
2981 ospf_lsdb_checksum(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2982 json_object_int_add(
2983 json_area
, "lsaNssaNumber",
2984 ospf_lsdb_count(area
->lsdb
, OSPF_AS_NSSA_LSA
));
2985 json_object_int_add(
2986 json_area
, "lsaNssaChecksum",
2987 ospf_lsdb_checksum(area
->lsdb
, OSPF_AS_NSSA_LSA
));
2989 /* Show number of fully adjacent neighbors. */
2991 " Number of fully adjacent neighbors in this area: %d\n",
2994 /* Show authentication type. */
2995 vty_out(vty
, " Area has ");
2996 if (area
->auth_type
== OSPF_AUTH_NULL
)
2997 vty_out(vty
, "no authentication\n");
2998 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
2999 vty_out(vty
, "simple password authentication\n");
3000 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
3001 vty_out(vty
, "message digest authentication\n");
3003 if (!OSPF_IS_AREA_BACKBONE(area
))
3005 " Number of full virtual adjacencies going through this area: %d\n",
3008 /* Show SPF calculation times. */
3009 vty_out(vty
, " SPF algorithm executed %d times\n",
3010 area
->spf_calculation
);
3012 /* Show number of LSA. */
3013 vty_out(vty
, " Number of LSA %ld\n", area
->lsdb
->total
);
3015 " Number of router LSA %ld. Checksum Sum 0x%08x\n",
3016 ospf_lsdb_count(area
->lsdb
, OSPF_ROUTER_LSA
),
3017 ospf_lsdb_checksum(area
->lsdb
, OSPF_ROUTER_LSA
));
3019 " Number of network LSA %ld. Checksum Sum 0x%08x\n",
3020 ospf_lsdb_count(area
->lsdb
, OSPF_NETWORK_LSA
),
3021 ospf_lsdb_checksum(area
->lsdb
, OSPF_NETWORK_LSA
));
3023 " Number of summary LSA %ld. Checksum Sum 0x%08x\n",
3024 ospf_lsdb_count(area
->lsdb
, OSPF_SUMMARY_LSA
),
3025 ospf_lsdb_checksum(area
->lsdb
, OSPF_SUMMARY_LSA
));
3027 " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x\n",
3028 ospf_lsdb_count(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
),
3029 ospf_lsdb_checksum(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
3030 vty_out(vty
, " Number of NSSA LSA %ld. Checksum Sum 0x%08x\n",
3031 ospf_lsdb_count(area
->lsdb
, OSPF_AS_NSSA_LSA
),
3032 ospf_lsdb_checksum(area
->lsdb
, OSPF_AS_NSSA_LSA
));
3036 json_object_int_add(
3037 json_area
, "lsaOpaqueLinkNumber",
3038 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
3039 json_object_int_add(
3040 json_area
, "lsaOpaqueLinkChecksum",
3041 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
3042 json_object_int_add(
3043 json_area
, "lsaOpaqueAreaNumber",
3044 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
3045 json_object_int_add(
3046 json_area
, "lsaOpaqueAreaChecksum",
3047 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
3050 " Number of opaque link LSA %ld. Checksum Sum 0x%08x\n",
3051 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
),
3052 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
3054 " Number of opaque area LSA %ld. Checksum Sum 0x%08x\n",
3055 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
),
3056 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
3060 json_object_object_add(json_areas
,
3061 inet_ntop(AF_INET
, &area
->area_id
,
3068 static int show_ip_ospf_common(struct vty
*vty
, struct ospf
*ospf
,
3069 json_object
*json
, uint8_t use_vrf
)
3071 struct listnode
*node
, *nnode
;
3072 struct ospf_area
*area
;
3073 struct timeval result
;
3074 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3075 char buf
[PREFIX_STRLEN
];
3076 json_object
*json_vrf
= NULL
;
3077 json_object
*json_areas
= NULL
;
3081 json_vrf
= json_object_new_object();
3084 json_areas
= json_object_new_object();
3087 if (ospf
->instance
) {
3089 json_object_int_add(json
, "ospfInstance",
3092 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
3096 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
3098 /* Show Router ID. */
3100 json_object_string_add(json_vrf
, "routerId",
3101 inet_ntop(AF_INET
, &ospf
->router_id
,
3104 vty_out(vty
, " OSPF Routing Process, Router ID: %pI4\n",
3108 /* Graceful shutdown */
3109 if (ospf
->t_deferred_shutdown
) {
3114 &ospf
->t_deferred_shutdown
->u
.sands
,
3117 json_object_int_add(json_vrf
, "deferredShutdownMsecs",
3121 " Deferred shutdown in progress, %s remaining\n",
3122 ospf_timer_dump(ospf
->t_deferred_shutdown
,
3123 timebuf
, sizeof(timebuf
)));
3127 /* Show capability. */
3129 json_object_boolean_true_add(json_vrf
, "tosRoutesOnly");
3130 json_object_boolean_true_add(json_vrf
, "rfc2328Conform");
3131 if (CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)) {
3132 json_object_boolean_true_add(json_vrf
,
3133 "rfc1583Compatibility");
3136 vty_out(vty
, " Supports only single TOS (TOS0) routes\n");
3137 vty_out(vty
, " This implementation conforms to RFC2328\n");
3138 vty_out(vty
, " RFC1583Compatibility flag is %s\n",
3139 CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)
3145 if (CHECK_FLAG(ospf
->config
, OSPF_OPAQUE_CAPABLE
)) {
3146 json_object_boolean_true_add(json_vrf
, "opaqueCapable");
3149 vty_out(vty
, " OpaqueCapability flag is %s\n",
3150 CHECK_FLAG(ospf
->config
, OSPF_OPAQUE_CAPABLE
)
3155 /* Show stub-router configuration */
3156 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
3157 || ospf
->stub_router_shutdown_time
3158 != OSPF_STUB_ROUTER_UNCONFIGURED
) {
3160 json_object_boolean_true_add(json_vrf
,
3161 "stubAdvertisement");
3162 if (ospf
->stub_router_startup_time
3163 != OSPF_STUB_ROUTER_UNCONFIGURED
)
3164 json_object_int_add(
3165 json_vrf
, "postStartEnabledSecs",
3166 ospf
->stub_router_startup_time
);
3167 if (ospf
->stub_router_shutdown_time
3168 != OSPF_STUB_ROUTER_UNCONFIGURED
)
3169 json_object_int_add(
3170 json_vrf
, "preShutdownEnabledSecs",
3171 ospf
->stub_router_shutdown_time
);
3174 " Stub router advertisement is configured\n");
3175 if (ospf
->stub_router_startup_time
3176 != OSPF_STUB_ROUTER_UNCONFIGURED
)
3178 " Enabled for %us after start-up\n",
3179 ospf
->stub_router_startup_time
);
3180 if (ospf
->stub_router_shutdown_time
3181 != OSPF_STUB_ROUTER_UNCONFIGURED
)
3183 " Enabled for %us prior to full shutdown\n",
3184 ospf
->stub_router_shutdown_time
);
3188 /* Show SPF timers. */
3190 json_object_int_add(json_vrf
, "spfScheduleDelayMsecs",
3192 json_object_int_add(json_vrf
, "holdtimeMinMsecs",
3193 ospf
->spf_holdtime
);
3194 json_object_int_add(json_vrf
, "holdtimeMaxMsecs",
3195 ospf
->spf_max_holdtime
);
3196 json_object_int_add(json_vrf
, "holdtimeMultplier",
3197 ospf
->spf_hold_multiplier
);
3200 " Initial SPF scheduling delay %d millisec(s)\n"
3201 " Minimum hold time between consecutive SPFs %d millisec(s)\n"
3202 " Maximum hold time between consecutive SPFs %d millisec(s)\n"
3203 " Hold time multiplier is currently %d\n",
3204 ospf
->spf_delay
, ospf
->spf_holdtime
,
3205 ospf
->spf_max_holdtime
, ospf
->spf_hold_multiplier
);
3209 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
) {
3210 long time_store
= 0;
3213 monotime_since(&ospf
->ts_spf
, NULL
) / 1000LL;
3214 json_object_int_add(json_vrf
, "spfLastExecutedMsecs",
3217 time_store
= (1000 * ospf
->ts_spf_duration
.tv_sec
)
3218 + (ospf
->ts_spf_duration
.tv_usec
/ 1000);
3219 json_object_int_add(json_vrf
, "spfLastDurationMsecs",
3222 json_object_boolean_true_add(json_vrf
, "spfHasNotRun");
3224 vty_out(vty
, " SPF algorithm ");
3225 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
) {
3226 monotime_since(&ospf
->ts_spf
, &result
);
3227 vty_out(vty
, "last executed %s ago\n",
3228 ospf_timeval_dump(&result
, timebuf
,
3230 vty_out(vty
, " Last SPF duration %s\n",
3231 ospf_timeval_dump(&ospf
->ts_spf_duration
,
3232 timebuf
, sizeof(timebuf
)));
3234 vty_out(vty
, "has not been run\n");
3238 if (ospf
->t_spf_calc
) {
3241 monotime_until(&ospf
->t_spf_calc
->u
.sands
, NULL
)
3243 json_object_int_add(json_vrf
, "spfTimerDueInMsecs",
3247 json_object_int_add(json_vrf
, "lsaMinIntervalMsecs",
3248 ospf
->min_ls_interval
);
3249 json_object_int_add(json_vrf
, "lsaMinArrivalMsecs",
3250 ospf
->min_ls_arrival
);
3251 /* Show write multiplier values */
3252 json_object_int_add(json_vrf
, "writeMultiplier",
3253 ospf
->write_oi_count
);
3254 /* Show refresh parameters. */
3255 json_object_int_add(json_vrf
, "refreshTimerMsecs",
3256 ospf
->lsa_refresh_interval
* 1000);
3258 vty_out(vty
, " SPF timer %s%s\n",
3259 (ospf
->t_spf_calc
? "due in " : "is "),
3260 ospf_timer_dump(ospf
->t_spf_calc
, timebuf
,
3263 vty_out(vty
, " LSA minimum interval %d msecs\n",
3264 ospf
->min_ls_interval
);
3265 vty_out(vty
, " LSA minimum arrival %d msecs\n",
3266 ospf
->min_ls_arrival
);
3268 /* Show write multiplier values */
3269 vty_out(vty
, " Write Multiplier set to %d \n",
3270 ospf
->write_oi_count
);
3272 /* Show refresh parameters. */
3273 vty_out(vty
, " Refresh timer %d secs\n",
3274 ospf
->lsa_refresh_interval
);
3276 /* show max multipath */
3277 vty_out(vty
, " Maximum multiple paths(ECMP) supported %d\n",
3278 ospf
->max_multipath
);
3281 /* Show ABR/ASBR flags. */
3282 if (CHECK_FLAG(ospf
->flags
, OSPF_FLAG_ABR
)) {
3284 json_object_string_add(
3285 json_vrf
, "abrType",
3286 ospf_abr_type_descr_str
[ospf
->abr_type
]);
3289 " This router is an ABR, ABR type is: %s\n",
3290 ospf_abr_type_descr_str
[ospf
->abr_type
]);
3292 if (CHECK_FLAG(ospf
->flags
, OSPF_FLAG_ASBR
)) {
3294 json_object_string_add(
3295 json_vrf
, "asbrRouter",
3296 "injectingExternalRoutingInformation");
3299 " This router is an ASBR (injecting external routing information)\n");
3302 /* Show Number of AS-external-LSAs. */
3304 json_object_int_add(
3305 json_vrf
, "lsaExternalCounter",
3306 ospf_lsdb_count(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3307 json_object_int_add(
3308 json_vrf
, "lsaExternalChecksum",
3309 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3312 " Number of external LSA %ld. Checksum Sum 0x%08x\n",
3313 ospf_lsdb_count(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
),
3314 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3318 json_object_int_add(
3319 json_vrf
, "lsaAsopaqueCounter",
3320 ospf_lsdb_count(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3321 json_object_int_add(
3322 json_vrf
, "lsaAsOpaqueChecksum",
3323 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3326 " Number of opaque AS LSA %ld. Checksum Sum 0x%08x\n",
3327 ospf_lsdb_count(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
),
3328 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3331 /* Show number of areas attached. */
3333 json_object_int_add(json_vrf
, "attachedAreaCounter",
3334 listcount(ospf
->areas
));
3336 vty_out(vty
, " Number of areas attached to this router: %d\n",
3337 listcount(ospf
->areas
));
3339 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
)) {
3340 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
)) {
3342 json_object_boolean_true_add(
3343 json_vrf
, "adjacencyChangesLoggedAll");
3346 " All adjacency changes are logged\n");
3349 json_object_boolean_true_add(
3350 json_vrf
, "adjacencyChangesLogged");
3352 vty_out(vty
, " Adjacency changes are logged\n");
3356 /* show LDP-Sync status */
3357 ospf_ldp_sync_show_info(vty
, ospf
, json_vrf
, json
? 1 : 0);
3359 /* Show each area status. */
3360 for (ALL_LIST_ELEMENTS(ospf
->areas
, node
, nnode
, area
))
3361 show_ip_ospf_area(vty
, area
, json_areas
, json
? 1 : 0);
3365 json_object_object_add(json_vrf
, "areas", json_areas
);
3366 if (ospf
->vrf_id
== VRF_DEFAULT
)
3367 json_object_object_add(json
, "default",
3370 json_object_object_add(json
, ospf
->name
,
3373 json_object_object_add(json
, "areas", json_areas
);
3381 DEFUN (show_ip_ospf
,
3383 "show ip ospf [vrf <NAME|all>] [json]",
3386 "OSPF information\n"
3392 bool uj
= use_json(argc
, argv
);
3393 struct listnode
*node
= NULL
;
3394 char *vrf_name
= NULL
;
3395 bool all_vrf
= false;
3396 int ret
= CMD_SUCCESS
;
3399 json_object
*json
= NULL
;
3400 uint8_t use_vrf
= 0;
3402 if (listcount(om
->ospf
) == 0)
3405 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
3408 json
= json_object_new_object();
3410 /* vrf input is provided could be all or specific vrf*/
3412 bool ospf_output
= false;
3417 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
3418 if (!ospf
->oi_running
)
3421 ret
= show_ip_ospf_common(vty
, ospf
, json
,
3425 vty_out(vty
, "%s\n",
3426 json_object_to_json_string_ext(
3427 json
, JSON_C_TO_STRING_PRETTY
));
3428 json_object_free(json
);
3429 } else if (!ospf_output
)
3430 vty_out(vty
, "%% OSPF instance not found\n");
3433 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
3434 if ((ospf
== NULL
) || !ospf
->oi_running
) {
3436 vty_out(vty
, "%s\n",
3437 json_object_to_json_string_ext(
3438 json
, JSON_C_TO_STRING_PRETTY
));
3439 json_object_free(json
);
3441 vty_out(vty
, "%% OSPF instance not found\n");
3446 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
3447 /* Display default ospf (instance 0) info */
3448 if (ospf
== NULL
|| !ospf
->oi_running
) {
3450 vty_out(vty
, "%s\n",
3451 json_object_to_json_string_ext(
3452 json
, JSON_C_TO_STRING_PRETTY
));
3453 json_object_free(json
);
3455 vty_out(vty
, "%% OSPF instance not found\n");
3462 show_ip_ospf_common(vty
, ospf
, json
, use_vrf
);
3464 vty_out(vty
, "%s\n",
3465 json_object_to_json_string_ext(
3466 json
, JSON_C_TO_STRING_PRETTY
));
3470 json_object_free(json
);
3475 DEFUN (show_ip_ospf_instance
,
3476 show_ip_ospf_instance_cmd
,
3477 "show ip ospf (1-65535) [json]",
3480 "OSPF information\n"
3486 unsigned short instance
= 0;
3487 bool uj
= use_json(argc
, argv
);
3488 int ret
= CMD_SUCCESS
;
3489 json_object
*json
= NULL
;
3491 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3492 if (instance
!= ospf_instance
)
3493 return CMD_NOT_MY_INSTANCE
;
3495 ospf
= ospf_lookup_instance(instance
);
3496 if (!ospf
|| !ospf
->oi_running
)
3500 json
= json_object_new_object();
3502 ret
= show_ip_ospf_common(vty
, ospf
, json
, 0);
3505 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
3506 json
, JSON_C_TO_STRING_PRETTY
));
3507 json_object_free(json
);
3513 static void ospf_interface_auth_show(struct vty
*vty
, struct ospf_interface
*oi
,
3514 json_object
*json
, bool use_json
)
3518 auth_type
= OSPF_IF_PARAM(oi
, auth_type
);
3520 switch (auth_type
) {
3521 case OSPF_AUTH_NULL
:
3523 json_object_string_add(json
, "authentication",
3524 "authenticationNone");
3526 vty_out(vty
, " Authentication NULL is enabled\n");
3528 case OSPF_AUTH_SIMPLE
: {
3530 json_object_string_add(json
, "authentication",
3531 "authenticationSimplePassword");
3534 " Simple password authentication enabled\n");
3537 case OSPF_AUTH_CRYPTOGRAPHIC
: {
3538 struct crypt_key
*ckey
;
3540 if (list_isempty(OSPF_IF_PARAM(oi
, auth_crypt
)))
3543 ckey
= listgetdata(listtail(OSPF_IF_PARAM(oi
, auth_crypt
)));
3546 json_object_string_add(json
, "authentication",
3547 "authenticationMessageDigest");
3550 " Cryptographic authentication enabled\n");
3551 vty_out(vty
, " Algorithm:MD5\n");
3561 static void show_ip_ospf_interface_sub(struct vty
*vty
, struct ospf
*ospf
,
3562 struct interface
*ifp
,
3563 json_object
*json_interface_sub
,
3567 struct ospf_neighbor
*nbr
;
3568 struct route_node
*rn
;
3569 char buf
[PREFIX_STRLEN
];
3570 uint32_t bandwidth
= ifp
->bandwidth
? ifp
->bandwidth
: ifp
->speed
;
3572 /* Is interface up? */
3574 is_up
= if_is_operative(ifp
);
3576 json_object_boolean_true_add(json_interface_sub
,
3579 json_object_boolean_false_add(json_interface_sub
,
3582 json_object_int_add(json_interface_sub
, "ifIndex",
3584 json_object_int_add(json_interface_sub
, "mtuBytes", ifp
->mtu
);
3585 json_object_int_add(json_interface_sub
, "bandwidthMbit",
3587 json_object_string_add(json_interface_sub
, "ifFlags",
3588 if_flag_dump(ifp
->flags
));
3590 vty_out(vty
, "%s is %s\n", ifp
->name
,
3591 ((is_up
= if_is_operative(ifp
)) ? "up" : "down"));
3592 vty_out(vty
, " ifindex %u, MTU %u bytes, BW %u Mbit %s\n",
3593 ifp
->ifindex
, ifp
->mtu
, bandwidth
,
3594 if_flag_dump(ifp
->flags
));
3597 /* Is interface OSPF enabled? */
3599 if (ospf_oi_count(ifp
) == 0) {
3600 json_object_boolean_false_add(json_interface_sub
,
3603 } else if (!is_up
) {
3604 json_object_boolean_false_add(json_interface_sub
,
3608 json_object_boolean_true_add(json_interface_sub
,
3611 if (ospf_oi_count(ifp
) == 0) {
3612 vty_out(vty
, " OSPF not enabled on this interface\n");
3614 } else if (!is_up
) {
3616 " OSPF is enabled, but not running on this interface\n");
3621 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
3622 struct ospf_interface
*oi
= rn
->info
;
3627 if (CHECK_FLAG(oi
->connected
->flags
, ZEBRA_IFA_UNNUMBERED
)) {
3629 json_object_boolean_true_add(json_interface_sub
,
3632 vty_out(vty
, " This interface is UNNUMBERED,");
3634 struct in_addr dest
;
3637 /* Show OSPF interface information. */
3639 json_object_string_add(
3640 json_interface_sub
, "ipAddress",
3642 &oi
->address
->u
.prefix4
,
3644 json_object_int_add(json_interface_sub
,
3645 "ipAddressPrefixlen",
3646 oi
->address
->prefixlen
);
3648 vty_out(vty
, " Internet Address %pFX,",
3651 /* For Vlinks, showing the peer address is
3652 * probably more informative than the local
3653 * interface that is being used */
3654 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
) {
3656 dest
= oi
->vl_data
->peer_addr
;
3657 } else if (CONNECTED_PEER(oi
->connected
)
3658 && oi
->connected
->destination
) {
3660 dest
= oi
->connected
->destination
->u
.prefix4
;
3663 dest
.s_addr
= ipv4_broadcast_addr(
3664 oi
->connected
->address
->u
.prefix4
.s_addr
,
3665 oi
->connected
->address
->prefixlen
);
3669 json_object_string_add(
3671 "ospfIfType", dstr
);
3672 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3673 json_object_string_add(
3676 inet_ntop(AF_INET
, &dest
,
3679 json_object_string_add(
3682 inet_ntop(AF_INET
, &dest
,
3685 vty_out(vty
, " %s %pI4,", dstr
,
3689 json_object_string_add(json_interface_sub
, "area",
3690 ospf_area_desc_string(oi
->area
));
3691 if (OSPF_IF_PARAM(oi
, mtu_ignore
))
3692 json_object_boolean_true_add(
3694 "mtuMismatchDetect");
3695 json_object_string_add(
3696 json_interface_sub
, "routerId",
3697 inet_ntop(AF_INET
, &ospf
->router_id
,
3699 json_object_string_add(json_interface_sub
,
3701 ospf_network_type_str
[oi
->type
]);
3702 json_object_int_add(json_interface_sub
, "cost",
3704 json_object_int_add(
3705 json_interface_sub
, "transmitDelaySecs",
3706 OSPF_IF_PARAM(oi
, transmit_delay
));
3707 json_object_string_add(json_interface_sub
, "state",
3708 lookup_msg(ospf_ism_state_msg
,
3710 json_object_int_add(json_interface_sub
, "priority",
3713 vty_out(vty
, " Area %s\n",
3714 ospf_area_desc_string(oi
->area
));
3716 vty_out(vty
, " MTU mismatch detection: %s\n",
3717 OSPF_IF_PARAM(oi
, mtu_ignore
) ? "disabled"
3721 " Router ID %pI4, Network Type %s, Cost: %d\n",
3723 ospf_network_type_str
[oi
->type
],
3727 " Transmit Delay is %d sec, State %s, Priority %d\n",
3728 OSPF_IF_PARAM(oi
, transmit_delay
),
3729 lookup_msg(ospf_ism_state_msg
, oi
->state
, NULL
),
3733 /* Show DR information. */
3734 if (DR(oi
).s_addr
== INADDR_ANY
) {
3737 " No backup designated router on this network\n");
3739 nbr
= ospf_nbr_lookup_by_addr(oi
->nbrs
, &BDR(oi
));
3743 " No backup designated router on this network\n");
3746 json_object_string_add(
3747 json_interface_sub
, "bdrId",
3751 json_object_string_add(
3760 " Backup Designated Router (ID) %pI4,",
3762 vty_out(vty
, " Interface Address %pI4\n",
3763 &nbr
->address
.u
.prefix4
);
3768 /* Next network-LSA sequence number we'll use, if we're elected
3771 && ntohl(oi
->params
->network_lsa_seqnum
)
3772 != OSPF_INITIAL_SEQUENCE_NUMBER
) {
3774 json_object_int_add(
3776 "networkLsaSequence",
3777 ntohl(oi
->params
->network_lsa_seqnum
));
3780 " Saved Network-LSA sequence number 0x%x\n",
3781 ntohl(oi
->params
->network_lsa_seqnum
));
3785 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3786 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
)) {
3787 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3788 json_object_boolean_true_add(
3790 "mcastMemberOspfAllRouters");
3791 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3792 json_object_boolean_true_add(
3794 "mcastMemberOspfDesignatedRouters");
3797 vty_out(vty
, " Multicast group memberships:");
3798 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3799 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
)) {
3800 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3801 vty_out(vty
, " OSPFAllRouters");
3802 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3803 vty_out(vty
, " OSPFDesignatedRouters");
3805 vty_out(vty
, " <None>");
3810 if (OSPF_IF_PARAM(oi
, fast_hello
) == 0)
3811 json_object_int_add(
3812 json_interface_sub
, "timerMsecs",
3813 OSPF_IF_PARAM(oi
, v_hello
) * 1000);
3815 json_object_int_add(
3816 json_interface_sub
, "timerMsecs",
3817 1000 / OSPF_IF_PARAM(oi
, fast_hello
));
3818 json_object_int_add(json_interface_sub
,
3820 OSPF_IF_PARAM(oi
, v_wait
));
3821 json_object_int_add(json_interface_sub
,
3823 OSPF_IF_PARAM(oi
, v_wait
));
3824 json_object_int_add(
3825 json_interface_sub
, "timerRetransmitSecs",
3826 OSPF_IF_PARAM(oi
, retransmit_interval
));
3828 vty_out(vty
, " Timer intervals configured,");
3829 vty_out(vty
, " Hello ");
3830 if (OSPF_IF_PARAM(oi
, fast_hello
) == 0)
3831 vty_out(vty
, "%ds,",
3832 OSPF_IF_PARAM(oi
, v_hello
));
3834 vty_out(vty
, "%dms,",
3835 1000 / OSPF_IF_PARAM(oi
, fast_hello
));
3836 vty_out(vty
, " Dead %ds, Wait %ds, Retransmit %d\n",
3837 OSPF_IF_PARAM(oi
, v_wait
),
3838 OSPF_IF_PARAM(oi
, v_wait
),
3839 OSPF_IF_PARAM(oi
, retransmit_interval
));
3842 if (OSPF_IF_PASSIVE_STATUS(oi
) == OSPF_IF_ACTIVE
) {
3843 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3845 long time_store
= 0;
3849 &oi
->t_hello
->u
.sands
,
3852 json_object_int_add(json_interface_sub
,
3853 "timerHelloInMsecs",
3856 vty_out(vty
, " Hello due in %s\n",
3857 ospf_timer_dump(oi
->t_hello
, timebuf
,
3859 } else /* passive-interface is set */
3862 json_object_boolean_true_add(
3864 "timerPassiveIface");
3867 " No Hellos (Passive interface)\n");
3871 json_object_int_add(json_interface_sub
, "nbrCount",
3872 ospf_nbr_count(oi
, 0));
3873 json_object_int_add(json_interface_sub
,
3875 ospf_nbr_count(oi
, NSM_Full
));
3878 " Neighbor Count is %d, Adjacent neighbor count is %d\n",
3879 ospf_nbr_count(oi
, 0),
3880 ospf_nbr_count(oi
, NSM_Full
));
3882 ospf_interface_bfd_show(vty
, ifp
, json_interface_sub
);
3884 /* OSPF Authentication information */
3885 ospf_interface_auth_show(vty
, oi
, json_interface_sub
, use_json
);
3889 static int show_ip_ospf_interface_common(struct vty
*vty
, struct ospf
*ospf
,
3890 char *intf_name
, uint8_t use_vrf
,
3891 json_object
*json
, bool use_json
)
3893 struct interface
*ifp
;
3894 struct vrf
*vrf
= vrf_lookup_by_id(ospf
->vrf_id
);
3895 json_object
*json_vrf
= NULL
;
3896 json_object
*json_interface_sub
= NULL
, *json_interface
= NULL
;
3900 json_vrf
= json_object_new_object();
3903 json_interface
= json_object_new_object();
3906 if (ospf
->instance
) {
3908 json_object_int_add(json
, "ospfInstance",
3911 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
3914 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
3916 if (intf_name
== NULL
) {
3917 /* Show All Interfaces.*/
3918 FOR_ALL_INTERFACES (vrf
, ifp
) {
3919 if (ospf_oi_count(ifp
)) {
3921 json_interface_sub
=
3922 json_object_new_object();
3924 show_ip_ospf_interface_sub(vty
, ospf
, ifp
,
3929 json_object_object_add(
3930 json_interface
, ifp
->name
,
3931 json_interface_sub
);
3936 json_object_object_add(json_vrf
, "interfaces",
3939 /* Interface name is specified. */
3940 ifp
= if_lookup_by_name(intf_name
, ospf
->vrf_id
);
3943 json_object_boolean_true_add(json_vrf
,
3946 vty_out(vty
, "No such interface name\n");
3949 json_interface_sub
= json_object_new_object();
3950 json_interface
= json_object_new_object();
3953 show_ip_ospf_interface_sub(
3954 vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3957 json_object_object_add(json_interface
,
3959 json_interface_sub
);
3960 json_object_object_add(json_vrf
, "interfaces",
3968 if (ospf
->vrf_id
== VRF_DEFAULT
)
3969 json_object_object_add(json
, "default",
3972 json_object_object_add(json
, ospf
->name
,
3981 static void show_ip_ospf_interface_traffic_sub(struct vty
*vty
,
3982 struct ospf_interface
*oi
,
3983 json_object
*json_interface_sub
,
3987 json_object_int_add(json_interface_sub
, "ifIndex",
3989 json_object_int_add(json_interface_sub
, "helloIn",
3991 json_object_int_add(json_interface_sub
, "helloOut",
3993 json_object_int_add(json_interface_sub
, "dbDescIn",
3995 json_object_int_add(json_interface_sub
, "dbDescOut",
3997 json_object_int_add(json_interface_sub
, "lsReqIn",
3999 json_object_int_add(json_interface_sub
, "lsReqOut",
4001 json_object_int_add(json_interface_sub
, "lsUpdIn",
4003 json_object_int_add(json_interface_sub
, "lsUpdOut",
4005 json_object_int_add(json_interface_sub
, "lsAckIn",
4007 json_object_int_add(json_interface_sub
, "lsAckOut",
4011 "%-10s %8u/%-8u %7u/%-7u %7u/%-7u %7u/%-7u %7u/%-7u\n",
4012 oi
->ifp
->name
, oi
->hello_in
, oi
->hello_out
,
4013 oi
->db_desc_in
, oi
->db_desc_out
, oi
->ls_req_in
,
4014 oi
->ls_req_out
, oi
->ls_upd_in
, oi
->ls_upd_out
,
4015 oi
->ls_ack_in
, oi
->ls_ack_out
);
4019 /* OSPFv2 Packet Counters */
4020 static int show_ip_ospf_interface_traffic_common(
4021 struct vty
*vty
, struct ospf
*ospf
, char *intf_name
, json_object
*json
,
4022 int display_once
, uint8_t use_vrf
, bool use_json
)
4024 struct vrf
*vrf
= NULL
;
4025 struct interface
*ifp
= NULL
;
4026 json_object
*json_vrf
= NULL
;
4027 json_object
*json_interface_sub
= NULL
;
4029 if (!use_json
&& !display_once
) {
4031 vty_out(vty
, "%-12s%-17s%-17s%-17s%-17s%-17s\n", "Interface",
4032 " HELLO", " DB-Desc", " LS-Req", " LS-Update",
4034 vty_out(vty
, "%-10s%-18s%-18s%-17s%-17s%-17s\n", "",
4035 " Rx/Tx", " Rx/Tx", " Rx/Tx", " Rx/Tx",
4038 "--------------------------------------------------------------------------------------------\n");
4039 } else if (use_json
) {
4041 json_vrf
= json_object_new_object();
4046 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
4048 if (intf_name
== NULL
) {
4049 vrf
= vrf_lookup_by_id(ospf
->vrf_id
);
4050 FOR_ALL_INTERFACES (vrf
, ifp
) {
4051 struct route_node
*rn
;
4052 struct ospf_interface
*oi
;
4054 if (ospf_oi_count(ifp
) == 0)
4057 for (rn
= route_top(IF_OIFS(ifp
)); rn
;
4058 rn
= route_next(rn
)) {
4065 json_interface_sub
=
4066 json_object_new_object();
4069 show_ip_ospf_interface_traffic_sub(
4070 vty
, oi
, json_interface_sub
, use_json
);
4072 json_object_object_add(
4073 json_vrf
, ifp
->name
,
4074 json_interface_sub
);
4079 /* Interface name is specified. */
4080 ifp
= if_lookup_by_name(intf_name
, ospf
->vrf_id
);
4082 struct route_node
*rn
;
4083 struct ospf_interface
*oi
;
4085 if (ospf_oi_count(ifp
) == 0) {
4087 " OSPF not enabled on this interface %s\n",
4092 for (rn
= route_top(IF_OIFS(ifp
)); rn
;
4093 rn
= route_next(rn
)) {
4097 json_interface_sub
=
4098 json_object_new_object();
4101 show_ip_ospf_interface_traffic_sub(
4102 vty
, oi
, json_interface_sub
, use_json
);
4104 json_object_object_add(
4105 json_vrf
, ifp
->name
,
4106 json_interface_sub
);
4114 if (ospf
->vrf_id
== VRF_DEFAULT
)
4115 json_object_object_add(json
, "default",
4118 json_object_object_add(json
, ospf
->name
,
4127 DEFUN (show_ip_ospf_interface
,
4128 show_ip_ospf_interface_cmd
,
4129 "show ip ospf [vrf <NAME|all>] interface [INTERFACE] [json]",
4132 "OSPF information\n"
4135 "Interface information\n"
4140 bool uj
= use_json(argc
, argv
);
4141 struct listnode
*node
= NULL
;
4142 char *vrf_name
= NULL
, *intf_name
= NULL
;
4143 bool all_vrf
= false;
4144 int ret
= CMD_SUCCESS
;
4146 int idx_vrf
= 0, idx_intf
= 0;
4147 uint8_t use_vrf
= 0;
4148 json_object
*json
= NULL
;
4150 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
4152 if (argv_find(argv
, argc
, "INTERFACE", &idx_intf
))
4153 intf_name
= argv
[idx_intf
]->arg
;
4156 json
= json_object_new_object();
4158 /* vrf input is provided could be all or specific vrf*/
4162 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
4163 if (!ospf
->oi_running
)
4165 ret
= show_ip_ospf_interface_common(
4166 vty
, ospf
, intf_name
, use_vrf
, json
,
4171 vty_out(vty
, "%s\n",
4172 json_object_to_json_string_ext(
4173 json
, JSON_C_TO_STRING_PRETTY
));
4174 json_object_free(json
);
4176 vty_out(vty
, "%% OSPF instance not found\n");
4180 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
4181 if (ospf
== NULL
|| !ospf
->oi_running
) {
4183 vty_out(vty
, "%s\n",
4184 json_object_to_json_string_ext(
4185 json
, JSON_C_TO_STRING_PRETTY
));
4186 json_object_free(json
);
4188 vty_out(vty
, "%% OSPF instance not found\n");
4192 ret
= show_ip_ospf_interface_common(vty
, ospf
, intf_name
,
4196 /* Display default ospf (instance 0) info */
4197 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
4198 if (ospf
== NULL
|| !ospf
->oi_running
) {
4200 vty_out(vty
, "%s\n",
4201 json_object_to_json_string_ext(
4202 json
, JSON_C_TO_STRING_PRETTY
));
4203 json_object_free(json
);
4205 vty_out(vty
, "%% OSPF instance not found\n");
4209 ret
= show_ip_ospf_interface_common(vty
, ospf
, intf_name
,
4214 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
4215 json
, JSON_C_TO_STRING_PRETTY
));
4216 json_object_free(json
);
4222 DEFUN (show_ip_ospf_instance_interface
,
4223 show_ip_ospf_instance_interface_cmd
,
4224 "show ip ospf (1-65535) interface [INTERFACE] [json]",
4227 "OSPF information\n"
4229 "Interface information\n"
4236 unsigned short instance
= 0;
4237 bool uj
= use_json(argc
, argv
);
4238 char *intf_name
= NULL
;
4239 int ret
= CMD_SUCCESS
;
4240 json_object
*json
= NULL
;
4242 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4243 if (instance
!= ospf_instance
)
4244 return CMD_NOT_MY_INSTANCE
;
4246 ospf
= ospf_lookup_instance(instance
);
4247 if (!ospf
|| !ospf
->oi_running
)
4251 json
= json_object_new_object();
4253 if (argv_find(argv
, argc
, "INTERFACE", &idx_intf
))
4254 intf_name
= argv
[idx_intf
]->arg
;
4256 ret
= show_ip_ospf_interface_common(vty
, ospf
, intf_name
, 0, json
, uj
);
4259 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
4260 json
, JSON_C_TO_STRING_PRETTY
));
4261 json_object_free(json
);
4267 DEFUN (show_ip_ospf_interface_traffic
,
4268 show_ip_ospf_interface_traffic_cmd
,
4269 "show ip ospf [vrf <NAME|all>] interface traffic [INTERFACE] [json]",
4272 "OSPF information\n"
4275 "Interface information\n"
4276 "Protocol Packet counters\n"
4280 struct ospf
*ospf
= NULL
;
4281 struct listnode
*node
= NULL
;
4282 char *vrf_name
= NULL
, *intf_name
= NULL
;
4283 bool all_vrf
= false;
4285 int idx_vrf
= 0, idx_intf
= 0;
4286 bool uj
= use_json(argc
, argv
);
4287 json_object
*json
= NULL
;
4288 int ret
= CMD_SUCCESS
;
4289 int display_once
= 0;
4290 uint8_t use_vrf
= 0;
4292 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
4294 if (argv_find(argv
, argc
, "INTERFACE", &idx_intf
))
4295 intf_name
= argv
[idx_intf
]->arg
;
4298 json
= json_object_new_object();
4303 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
4304 if (!ospf
->oi_running
)
4307 ret
= show_ip_ospf_interface_traffic_common(
4308 vty
, ospf
, intf_name
, json
,
4309 display_once
, use_vrf
, uj
);
4314 vty_out(vty
, "%s\n",
4315 json_object_to_json_string_ext(
4316 json
, JSON_C_TO_STRING_PRETTY
));
4317 json_object_free(json
);
4322 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
4323 if (ospf
== NULL
|| !ospf
->oi_running
) {
4325 json_object_free(json
);
4329 ret
= show_ip_ospf_interface_traffic_common(
4330 vty
, ospf
, intf_name
, json
, display_once
, use_vrf
, uj
);
4332 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
4333 if (ospf
== NULL
|| !ospf
->oi_running
) {
4335 json_object_free(json
);
4339 ret
= show_ip_ospf_interface_traffic_common(
4340 vty
, ospf
, intf_name
, json
, display_once
, use_vrf
, uj
);
4344 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
4345 json
, JSON_C_TO_STRING_PRETTY
));
4346 json_object_free(json
);
4353 static void show_ip_ospf_neighbour_header(struct vty
*vty
)
4355 vty_out(vty
, "\n%-15s %3s %-15s %9s %-15s %-32s %5s %5s %5s\n",
4356 "Neighbor ID", "Pri", "State", "Dead Time", "Address",
4357 "Interface", "RXmtL", "RqstL", "DBsmL");
4360 static void show_ip_ospf_neighbor_sub(struct vty
*vty
,
4361 struct ospf_interface
*oi
,
4362 json_object
*json
, bool use_json
)
4364 struct route_node
*rn
;
4365 struct ospf_neighbor
*nbr
, *prev_nbr
= NULL
;
4367 char buf
[PREFIX_STRLEN
];
4368 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4369 json_object
*json_neighbor
= NULL
, *json_neigh_array
= NULL
;
4371 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
)) {
4372 if ((nbr
= rn
->info
)) {
4373 /* Do not show myself. */
4374 if (nbr
== oi
->nbr_self
)
4376 /* Down state is not shown. */
4377 if (nbr
->state
== NSM_Down
)
4380 char neigh_str
[INET_ADDRSTRLEN
];
4383 && !IPV4_ADDR_SAME(&prev_nbr
->src
,
4385 /* Start new neigh list */
4386 json_neigh_array
= NULL
;
4389 if (nbr
->state
== NSM_Attempt
4390 && nbr
->router_id
.s_addr
== INADDR_ANY
)
4391 strlcpy(neigh_str
, "neighbor",
4394 inet_ntop(AF_INET
, &nbr
->router_id
,
4395 neigh_str
, sizeof(neigh_str
));
4397 json_object_object_get_ex(json
, neigh_str
,
4400 if (!json_neigh_array
) {
4402 json_object_new_array();
4403 json_object_object_add(
4408 json_neighbor
= json_object_new_object();
4410 ospf_nbr_state_message(nbr
, msgbuf
, 16);
4416 &nbr
->t_inactivity
->u
.sands
,
4420 json_object_int_add(json_neighbor
, "priority",
4422 json_object_string_add(json_neighbor
, "state",
4424 json_object_int_add(json_neighbor
,
4427 json_object_string_add(
4428 json_neighbor
, "address",
4429 inet_ntop(AF_INET
, &nbr
->src
,
4431 json_object_string_add(json_neighbor
,
4434 json_object_int_add(
4435 json_neighbor
, "retransmitCounter",
4436 ospf_ls_retransmit_count(nbr
));
4437 json_object_int_add(json_neighbor
,
4439 ospf_ls_request_count(nbr
));
4440 json_object_int_add(json_neighbor
,
4442 ospf_db_summary_count(nbr
));
4444 json_object_array_add(json_neigh_array
,
4447 ospf_nbr_state_message(nbr
, msgbuf
, 16);
4449 if (nbr
->state
== NSM_Attempt
4450 && nbr
->router_id
.s_addr
== INADDR_ANY
)
4451 vty_out(vty
, "%-15s %3d %-15s ", "-",
4452 nbr
->priority
, msgbuf
);
4454 vty_out(vty
, "%-15pI4 %3d %-15s ",
4456 nbr
->priority
, msgbuf
);
4458 vty_out(vty
, "%9s ",
4459 ospf_timer_dump(nbr
->t_inactivity
,
4462 vty_out(vty
, "%-15pI4 ", &nbr
->src
);
4463 vty_out(vty
, "%-32s %5ld %5ld %5d\n",
4465 ospf_ls_retransmit_count(nbr
),
4466 ospf_ls_request_count(nbr
),
4467 ospf_db_summary_count(nbr
));
4474 static int show_ip_ospf_neighbor_common(struct vty
*vty
, struct ospf
*ospf
,
4475 json_object
*json
, bool use_json
,
4478 struct ospf_interface
*oi
;
4479 struct listnode
*node
;
4480 json_object
*json_vrf
= NULL
;
4481 json_object
*json_nbr_sub
= NULL
;
4485 json_vrf
= json_object_new_object();
4488 json_nbr_sub
= json_object_new_object();
4491 if (ospf
->instance
) {
4493 json_object_int_add(json
, "ospfInstance",
4496 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
4499 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
4501 show_ip_ospf_neighbour_header(vty
);
4503 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
4504 if (ospf_interface_neighbor_count(oi
) == 0)
4506 show_ip_ospf_neighbor_sub(vty
, oi
, json_nbr_sub
, use_json
);
4510 json_object_object_add(json_vrf
, "neighbors", json_nbr_sub
);
4512 if (ospf
->vrf_id
== VRF_DEFAULT
)
4513 json_object_object_add(json
, "default",
4516 json_object_object_add(json
, ospf
->name
,
4525 DEFUN (show_ip_ospf_neighbor
,
4526 show_ip_ospf_neighbor_cmd
,
4527 "show ip ospf [vrf <NAME|all>] neighbor [json]",
4530 "OSPF information\n"
4537 bool uj
= use_json(argc
, argv
);
4538 struct listnode
*node
= NULL
;
4539 char *vrf_name
= NULL
;
4540 bool all_vrf
= false;
4541 int ret
= CMD_SUCCESS
;
4544 uint8_t use_vrf
= 0;
4545 json_object
*json
= NULL
;
4547 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
4550 json
= json_object_new_object();
4552 /* vrf input is provided could be all or specific vrf*/
4556 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
4557 if (!ospf
->oi_running
)
4559 ret
= show_ip_ospf_neighbor_common(
4560 vty
, ospf
, json
, uj
, use_vrf
);
4564 vty_out(vty
, "%s\n",
4565 json_object_to_json_string_ext(
4566 json
, JSON_C_TO_STRING_PRETTY
));
4567 json_object_free(json
);
4569 vty_out(vty
, "OSPF instance not found\n");
4574 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
4575 if (ospf
== NULL
|| !ospf
->oi_running
) {
4577 vty_out(vty
, "%s\n",
4578 json_object_to_json_string_ext(
4579 json
, JSON_C_TO_STRING_PRETTY
));
4580 json_object_free(json
);
4582 vty_out(vty
, "%% OSPF instance not found\n");
4587 /* Display default ospf (instance 0) info */
4588 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
4589 if (ospf
== NULL
|| !ospf
->oi_running
) {
4591 vty_out(vty
, "%s\n",
4592 json_object_to_json_string_ext(
4593 json
, JSON_C_TO_STRING_PRETTY
));
4594 json_object_free(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_out(vty
, "%s\n", json_object_to_json_string_ext(
4652 json
, JSON_C_TO_STRING_PRETTY
));
4653 json_object_free(json
);
4659 static int show_ip_ospf_neighbor_all_common(struct vty
*vty
, struct ospf
*ospf
,
4660 json_object
*json
, bool use_json
,
4663 struct listnode
*node
;
4664 struct ospf_interface
*oi
;
4665 char buf
[PREFIX_STRLEN
];
4666 json_object
*json_vrf
= NULL
;
4667 json_object
*json_neighbor_sub
= NULL
;
4671 json_vrf
= json_object_new_object();
4674 json_neighbor_sub
= json_object_new_object();
4677 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
4679 show_ip_ospf_neighbour_header(vty
);
4681 if (ospf
->instance
) {
4683 json_object_int_add(json_vrf
, "ospfInstance",
4686 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
4689 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
4690 struct listnode
*nbr_node
;
4691 struct ospf_nbr_nbma
*nbr_nbma
;
4693 show_ip_ospf_neighbor_sub(vty
, oi
, json_vrf
, use_json
);
4695 /* print Down neighbor status */
4696 for (ALL_LIST_ELEMENTS_RO(oi
->nbr_nbma
, nbr_node
, nbr_nbma
)) {
4697 if (nbr_nbma
->nbr
== NULL
4698 || nbr_nbma
->nbr
->state
== NSM_Down
) {
4700 json_object_int_add(json_neighbor_sub
,
4702 nbr_nbma
->priority
);
4703 json_object_boolean_true_add(
4706 json_object_string_add(
4710 json_object_int_add(
4712 "nbrNbmaRetransmitCounter", 0);
4713 json_object_int_add(
4715 "nbrNbmaRequestCounter", 0);
4716 json_object_int_add(
4718 "nbrNbmaDbSummaryCounter", 0);
4719 json_object_object_add(
4722 &nbr_nbma
->addr
, buf
,
4726 vty_out(vty
, "%-15s %3d %-15s %9s ",
4727 "-", nbr_nbma
->priority
, "Down",
4730 "%-32pI4 %-20s %5d %5d %5d\n",
4732 IF_NAME(oi
), 0, 0, 0);
4740 if (ospf
->vrf_id
== VRF_DEFAULT
)
4741 json_object_object_add(json
, "default",
4744 json_object_object_add(json
, ospf
->name
,
4753 DEFUN (show_ip_ospf_neighbor_all
,
4754 show_ip_ospf_neighbor_all_cmd
,
4755 "show ip ospf [vrf <NAME|all>] neighbor all [json]",
4758 "OSPF information\n"
4762 "include down status neighbor\n"
4766 bool uj
= use_json(argc
, argv
);
4767 struct listnode
*node
= NULL
;
4768 char *vrf_name
= NULL
;
4769 bool all_vrf
= false;
4770 int ret
= CMD_SUCCESS
;
4773 uint8_t use_vrf
= 0;
4774 json_object
*json
= NULL
;
4776 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
4779 json
= json_object_new_object();
4781 /* vrf input is provided could be all or specific vrf*/
4785 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
4786 if (!ospf
->oi_running
)
4788 ret
= show_ip_ospf_neighbor_all_common(
4789 vty
, ospf
, json
, uj
, use_vrf
);
4793 vty_out(vty
, "%s\n",
4794 json_object_to_json_string_ext(
4795 json
, JSON_C_TO_STRING_PRETTY
));
4796 json_object_free(json
);
4802 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
4803 if (ospf
== NULL
|| !ospf
->oi_running
) {
4805 json_object_free(json
);
4809 /* Display default ospf (instance 0) info */
4810 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
4811 if (ospf
== NULL
|| !ospf
->oi_running
) {
4813 json_object_free(json
);
4819 ret
= show_ip_ospf_neighbor_all_common(vty
, ospf
, json
, uj
,
4822 vty_out(vty
, "%s\n",
4823 json_object_to_json_string_ext(
4824 json
, JSON_C_TO_STRING_PRETTY
));
4829 json_object_free(json
);
4834 DEFUN (show_ip_ospf_instance_neighbor_all
,
4835 show_ip_ospf_instance_neighbor_all_cmd
,
4836 "show ip ospf (1-65535) neighbor all [json]",
4839 "OSPF information\n"
4842 "include down status neighbor\n"
4847 unsigned short instance
= 0;
4848 bool uj
= use_json(argc
, argv
);
4849 json_object
*json
= NULL
;
4850 int ret
= CMD_SUCCESS
;
4852 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4853 if (instance
!= ospf_instance
)
4854 return CMD_NOT_MY_INSTANCE
;
4856 ospf
= ospf_lookup_instance(instance
);
4857 if (!ospf
|| !ospf
->oi_running
)
4860 json
= json_object_new_object();
4862 ret
= show_ip_ospf_neighbor_all_common(vty
, ospf
, json
, uj
, 0);
4865 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
4866 json
, JSON_C_TO_STRING_PRETTY
));
4867 json_object_free(json
);
4873 static int show_ip_ospf_neighbor_int_common(struct vty
*vty
, struct ospf
*ospf
,
4875 struct cmd_token
**argv
,
4876 bool use_json
, uint8_t use_vrf
)
4878 struct interface
*ifp
;
4879 struct route_node
*rn
;
4880 json_object
*json
= NULL
;
4883 json
= json_object_new_object();
4885 if (ospf
->instance
) {
4887 json_object_int_add(json
, "ospfInstance",
4890 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
4893 ospf_show_vrf_name(ospf
, vty
, json
, use_vrf
);
4895 ifp
= if_lookup_by_name(argv
[arg_base
]->arg
, ospf
->vrf_id
);
4898 json_object_boolean_true_add(json
, "noSuchIface");
4900 vty_out(vty
, "No such interface.\n");
4904 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
4905 struct ospf_interface
*oi
= rn
->info
;
4910 show_ip_ospf_neighbor_sub(vty
, oi
, json
, use_json
);
4914 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
4915 json
, JSON_C_TO_STRING_PRETTY
));
4916 json_object_free(json
);
4923 DEFUN (show_ip_ospf_neighbor_int
,
4924 show_ip_ospf_neighbor_int_cmd
,
4925 "show ip ospf [vrf <NAME>] neighbor IFNAME [json]",
4928 "OSPF information\n"
4937 bool uj
= use_json(argc
, argv
);
4938 int ret
= CMD_SUCCESS
;
4939 struct interface
*ifp
= NULL
;
4940 char *vrf_name
= NULL
;
4941 vrf_id_t vrf_id
= VRF_DEFAULT
;
4942 struct vrf
*vrf
= NULL
;
4944 if (argv_find(argv
, argc
, "vrf", &idx_vrf
))
4945 vrf_name
= argv
[idx_vrf
+ 1]->arg
;
4946 if (vrf_name
&& strmatch(vrf_name
, VRF_DEFAULT_NAME
))
4949 vrf
= vrf_lookup_by_name(vrf_name
);
4951 vrf_id
= vrf
->vrf_id
;
4953 ospf
= ospf_lookup_by_vrf_id(vrf_id
);
4955 if (!ospf
|| !ospf
->oi_running
)
4959 show_ip_ospf_neighbour_header(vty
);
4961 argv_find(argv
, argc
, "IFNAME", &idx_ifname
);
4963 ifp
= if_lookup_by_name(argv
[idx_ifname
]->arg
, vrf_id
);
4967 ret
= show_ip_ospf_neighbor_int_common(vty
, ospf
, idx_ifname
,
4972 DEFUN (show_ip_ospf_instance_neighbor_int
,
4973 show_ip_ospf_instance_neighbor_int_cmd
,
4974 "show ip ospf (1-65535) neighbor IFNAME [json]",
4977 "OSPF information\n"
4986 unsigned short instance
= 0;
4987 bool uj
= use_json(argc
, argv
);
4990 show_ip_ospf_neighbour_header(vty
);
4992 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4993 if (instance
!= ospf_instance
)
4994 return CMD_NOT_MY_INSTANCE
;
4996 ospf
= ospf_lookup_instance(instance
);
4997 if (!ospf
|| !ospf
->oi_running
)
5001 show_ip_ospf_neighbour_header(vty
);
5003 return show_ip_ospf_neighbor_int_common(vty
, ospf
, idx_ifname
, argv
, uj
,
5007 static void show_ip_ospf_nbr_nbma_detail_sub(struct vty
*vty
,
5008 struct ospf_interface
*oi
,
5009 struct ospf_nbr_nbma
*nbr_nbma
,
5010 bool use_json
, json_object
*json
)
5012 char timebuf
[OSPF_TIME_DUMP_SIZE
];
5013 char buf
[PREFIX_STRLEN
];
5014 json_object
*json_sub
= NULL
;
5017 json_sub
= json_object_new_object();
5018 else /* Show neighbor ID. */
5019 vty_out(vty
, " Neighbor %s,", "-");
5021 /* Show interface address. */
5023 json_object_string_add(json_sub
, "ifaceAddress",
5024 inet_ntop(AF_INET
, &nbr_nbma
->addr
,
5027 vty_out(vty
, " interface address %pI4\n",
5032 json_object_string_add(json_sub
, "areaId",
5033 ospf_area_desc_string(oi
->area
));
5034 json_object_string_add(json_sub
, "iface", IF_NAME(oi
));
5036 vty_out(vty
, " In the area %s via interface %s\n",
5037 ospf_area_desc_string(oi
->area
), IF_NAME(oi
));
5039 /* Show neighbor priority and state. */
5041 json_object_int_add(json_sub
, "nbrPriority",
5042 nbr_nbma
->priority
);
5043 json_object_string_add(json_sub
, "nbrState", "down");
5045 vty_out(vty
, " Neighbor priority is %d, State is %s,",
5046 nbr_nbma
->priority
, "Down");
5048 /* Show state changes. */
5050 json_object_int_add(json_sub
, "stateChangeCounter",
5051 nbr_nbma
->state_change
);
5053 vty_out(vty
, " %d state changes\n", nbr_nbma
->state_change
);
5055 /* Show PollInterval */
5057 json_object_int_add(json_sub
, "pollInterval", nbr_nbma
->v_poll
);
5059 vty_out(vty
, " Poll interval %d\n", nbr_nbma
->v_poll
);
5061 /* Show poll-interval timer. */
5062 if (nbr_nbma
->t_poll
) {
5065 time_store
= monotime_until(&nbr_nbma
->t_poll
->u
.sands
,
5067 json_object_int_add(json_sub
,
5068 "pollIntervalTimerDueMsec",
5071 vty_out(vty
, " Poll timer due in %s\n",
5072 ospf_timer_dump(nbr_nbma
->t_poll
, timebuf
,
5076 /* Show poll-interval timer thread. */
5078 if (nbr_nbma
->t_poll
!= NULL
)
5079 json_object_string_add(json_sub
,
5080 "pollIntervalTimerThread", "on");
5082 vty_out(vty
, " Thread Poll Timer %s\n",
5083 nbr_nbma
->t_poll
!= NULL
? "on" : "off");
5086 json_object_object_add(json
, "noNbrId", json_sub
);
5089 static void show_ip_ospf_neighbor_detail_sub(struct vty
*vty
,
5090 struct ospf_interface
*oi
,
5091 struct ospf_neighbor
*nbr
,
5092 struct ospf_neighbor
*prev_nbr
,
5093 json_object
*json
, bool use_json
)
5095 char timebuf
[OSPF_TIME_DUMP_SIZE
];
5096 json_object
*json_neigh
= NULL
, *json_neigh_array
= NULL
;
5097 char neigh_str
[INET_ADDRSTRLEN
] = {0};
5098 char buf
[PREFIX_STRLEN
];
5102 !IPV4_ADDR_SAME(&prev_nbr
->src
, &nbr
->src
)) {
5103 json_neigh_array
= NULL
;
5106 if (nbr
->state
== NSM_Attempt
5107 && nbr
->router_id
.s_addr
== INADDR_ANY
)
5108 strlcpy(neigh_str
, "noNbrId", sizeof(neigh_str
));
5110 inet_ntop(AF_INET
, &nbr
->router_id
,
5111 neigh_str
, sizeof(neigh_str
));
5113 json_object_object_get_ex(json
, neigh_str
, &json_neigh_array
);
5115 if (!json_neigh_array
) {
5116 json_neigh_array
= json_object_new_array();
5117 json_object_object_add(json
, neigh_str
,
5121 json_neigh
= json_object_new_object();
5124 /* Show neighbor ID. */
5125 if (nbr
->state
== NSM_Attempt
5126 && nbr
->router_id
.s_addr
== INADDR_ANY
)
5127 vty_out(vty
, " Neighbor %s,", "-");
5129 vty_out(vty
, " Neighbor %pI4,",
5133 /* Show interface address. */
5135 json_object_string_add(json_neigh
, "ifaceAddress",
5137 &nbr
->address
.u
.prefix4
,
5140 vty_out(vty
, " interface address %pI4\n",
5141 &nbr
->address
.u
.prefix4
);
5145 json_object_string_add(json_neigh
, "areaId",
5146 ospf_area_desc_string(oi
->area
));
5147 json_object_string_add(json_neigh
, "ifaceName", oi
->ifp
->name
);
5149 vty_out(vty
, " In the area %s via interface %s\n",
5150 ospf_area_desc_string(oi
->area
), oi
->ifp
->name
);
5152 /* Show neighbor priority and state. */
5154 json_object_int_add(json_neigh
, "nbrPriority", nbr
->priority
);
5155 json_object_string_add(
5156 json_neigh
, "nbrState",
5157 lookup_msg(ospf_nsm_state_msg
, nbr
->state
, NULL
));
5159 vty_out(vty
, " Neighbor priority is %d, State is %s,",
5161 lookup_msg(ospf_nsm_state_msg
, nbr
->state
, NULL
));
5163 /* Show state changes. */
5165 json_object_int_add(json_neigh
, "stateChangeCounter",
5168 vty_out(vty
, " %d state changes\n", nbr
->state_change
);
5170 if (nbr
->ts_last_progress
.tv_sec
|| nbr
->ts_last_progress
.tv_usec
) {
5175 monotime_since(&nbr
->ts_last_progress
, &res
) / 1000LL;
5177 json_object_int_add(json_neigh
, "lastPrgrsvChangeMsec",
5181 " Most recent state change statistics:\n");
5182 vty_out(vty
, " Progressive change %s ago\n",
5183 ospf_timeval_dump(&res
, timebuf
,
5188 if (nbr
->ts_last_regress
.tv_sec
|| nbr
->ts_last_regress
.tv_usec
) {
5193 monotime_since(&nbr
->ts_last_regress
, &res
) / 1000LL;
5195 json_object_int_add(json_neigh
,
5196 "lastRegressiveChangeMsec",
5198 if (nbr
->last_regress_str
)
5199 json_object_string_add(
5201 "lastRegressiveChangeReason",
5202 nbr
->last_regress_str
);
5205 " Regressive change %s ago, due to %s\n",
5206 ospf_timeval_dump(&res
, timebuf
,
5208 (nbr
->last_regress_str
? nbr
->last_regress_str
5213 /* Show Designated Rotuer ID. */
5215 json_object_string_add(json_neigh
, "routerDesignatedId",
5216 inet_ntop(AF_INET
, &nbr
->d_router
,
5219 vty_out(vty
, " DR is %pI4,", &nbr
->d_router
);
5221 /* Show Backup Designated Rotuer ID. */
5223 json_object_string_add(json_neigh
, "routerDesignatedBackupId",
5224 inet_ntop(AF_INET
, &nbr
->bd_router
,
5227 vty_out(vty
, " BDR is %pI4\n", &nbr
->bd_router
);
5231 json_object_int_add(json_neigh
, "optionsCounter", nbr
->options
);
5232 json_object_string_add(json_neigh
, "optionsList",
5233 ospf_options_dump(nbr
->options
));
5235 vty_out(vty
, " Options %d %s\n", nbr
->options
,
5236 ospf_options_dump(nbr
->options
));
5238 /* Show Router Dead interval timer. */
5240 if (nbr
->t_inactivity
) {
5242 time_store
= monotime_until(&nbr
->t_inactivity
->u
.sands
,
5245 json_object_int_add(json_neigh
,
5246 "routerDeadIntervalTimerDueMsec",
5249 json_object_int_add(
5251 "routerDeadIntervalTimerDueMsec", -1);
5253 vty_out(vty
, " Dead timer due in %s\n",
5254 ospf_timer_dump(nbr
->t_inactivity
, timebuf
,
5257 /* Show Database Summary list. */
5259 json_object_int_add(json_neigh
, "databaseSummaryListCounter",
5260 ospf_db_summary_count(nbr
));
5262 vty_out(vty
, " Database Summary List %d\n",
5263 ospf_db_summary_count(nbr
));
5265 /* Show Link State Request list. */
5267 json_object_int_add(json_neigh
, "linkStateRequestListCounter",
5268 ospf_ls_request_count(nbr
));
5270 vty_out(vty
, " Link State Request List %ld\n",
5271 ospf_ls_request_count(nbr
));
5273 /* Show Link State Retransmission list. */
5275 json_object_int_add(json_neigh
,
5276 "linkStateRetransmissionListCounter",
5277 ospf_ls_retransmit_count(nbr
));
5279 vty_out(vty
, " Link State Retransmission List %ld\n",
5280 ospf_ls_retransmit_count(nbr
));
5282 /* Show inactivity timer thread. */
5284 if (nbr
->t_inactivity
!= NULL
)
5285 json_object_string_add(json_neigh
,
5286 "threadInactivityTimer", "on");
5288 vty_out(vty
, " Thread Inactivity Timer %s\n",
5289 nbr
->t_inactivity
!= NULL
? "on" : "off");
5291 /* Show Database Description retransmission thread. */
5293 if (nbr
->t_db_desc
!= NULL
)
5294 json_object_string_add(
5296 "threadDatabaseDescriptionRetransmission",
5300 " Thread Database Description Retransmision %s\n",
5301 nbr
->t_db_desc
!= NULL
? "on" : "off");
5303 /* Show Link State Request Retransmission thread. */
5305 if (nbr
->t_ls_req
!= NULL
)
5306 json_object_string_add(
5308 "threadLinkStateRequestRetransmission", "on");
5311 " Thread Link State Request Retransmission %s\n",
5312 nbr
->t_ls_req
!= NULL
? "on" : "off");
5314 /* Show Link State Update Retransmission thread. */
5316 if (nbr
->t_ls_upd
!= NULL
)
5317 json_object_string_add(
5319 "threadLinkStateUpdateRetransmission",
5323 " Thread Link State Update Retransmission %s\n\n",
5324 nbr
->t_ls_upd
!= NULL
? "on" : "off");
5327 vty_out(vty
, " Graceful restart Helper info:\n");
5329 if (OSPF_GR_IS_ACTIVE_HELPER(nbr
)) {
5331 " Graceful Restart HELPER Status : Inprogress.\n");
5334 " Graceful Restart grace period time: %d (seconds).\n",
5335 nbr
->gr_helper_info
.recvd_grace_period
);
5336 vty_out(vty
, " Graceful Restart reason: %s.\n",
5337 ospf_restart_reason2str(
5338 nbr
->gr_helper_info
.gr_restart_reason
));
5341 " Graceful Restart HELPER Status : None\n");
5344 if (nbr
->gr_helper_info
.rejected_reason
5345 != OSPF_HELPER_REJECTED_NONE
)
5346 vty_out(vty
, " Helper rejected reason: %s.\n",
5347 ospf_rejected_reason2str(
5348 nbr
->gr_helper_info
.rejected_reason
));
5350 if (nbr
->gr_helper_info
.helper_exit_reason
5351 != OSPF_GR_HELPER_EXIT_NONE
)
5352 vty_out(vty
, " Last helper exit reason: %s.\n\n",
5353 ospf_exit_reason2str(
5354 nbr
->gr_helper_info
.helper_exit_reason
));
5358 json_object_string_add(json_neigh
, "grHelperStatus",
5359 OSPF_GR_IS_ACTIVE_HELPER(nbr
) ?
5362 if (OSPF_GR_IS_ACTIVE_HELPER(nbr
)) {
5363 json_object_int_add(
5364 json_neigh
, "graceInterval",
5365 nbr
->gr_helper_info
.recvd_grace_period
);
5366 json_object_string_add(
5367 json_neigh
, "grRestartReason",
5368 ospf_restart_reason2str(
5369 nbr
->gr_helper_info
.gr_restart_reason
));
5372 if (nbr
->gr_helper_info
.rejected_reason
5373 != OSPF_HELPER_REJECTED_NONE
)
5374 json_object_string_add(
5375 json_neigh
, "helperRejectReason",
5376 ospf_rejected_reason2str(
5377 nbr
->gr_helper_info
.rejected_reason
));
5379 if (nbr
->gr_helper_info
.helper_exit_reason
5380 != OSPF_GR_HELPER_EXIT_NONE
)
5381 json_object_string_add(
5382 json_neigh
, "helperExitReason",
5383 ospf_exit_reason2str(
5385 .helper_exit_reason
));
5388 bfd_sess_show(vty
, json_neigh
, nbr
->bfd_session
);
5391 json_object_array_add(json_neigh_array
, json_neigh
);
5395 static int show_ip_ospf_neighbor_id_common(struct vty
*vty
, struct ospf
*ospf
,
5396 struct in_addr
*router_id
,
5397 bool use_json
, uint8_t use_vrf
)
5399 struct listnode
*node
;
5400 struct ospf_neighbor
*nbr
;
5401 struct ospf_interface
*oi
;
5402 json_object
*json
= NULL
;
5405 json
= json_object_new_object();
5407 if (ospf
->instance
) {
5409 json_object_int_add(json
, "ospfInstance",
5412 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
5415 ospf_show_vrf_name(ospf
, vty
, json
, use_vrf
);
5417 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
5418 if ((nbr
= ospf_nbr_lookup_by_routerid(oi
->nbrs
, router_id
))) {
5419 show_ip_ospf_neighbor_detail_sub(vty
, oi
, nbr
, NULL
,
5425 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
5426 json
, JSON_C_TO_STRING_PRETTY
));
5427 json_object_free(json
);
5434 DEFPY (show_ip_ospf_neighbor_id
,
5435 show_ip_ospf_neighbor_id_cmd
,
5436 "show ip ospf neighbor A.B.C.D$router_id [json$json]",
5439 "OSPF information\n"
5445 struct listnode
*node
;
5446 int ret
= CMD_SUCCESS
;
5448 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
5449 if (!ospf
->oi_running
)
5451 ret
= show_ip_ospf_neighbor_id_common(vty
, ospf
, &router_id
,
5458 DEFPY (show_ip_ospf_instance_neighbor_id
,
5459 show_ip_ospf_instance_neighbor_id_cmd
,
5460 "show ip ospf (1-65535)$instance neighbor A.B.C.D$router_id [json$json]",
5463 "OSPF information\n"
5471 if (instance
!= ospf_instance
)
5472 return CMD_NOT_MY_INSTANCE
;
5474 ospf
= ospf_lookup_instance(instance
);
5475 if (!ospf
|| !ospf
->oi_running
)
5478 return show_ip_ospf_neighbor_id_common(vty
, ospf
, &router_id
, !!json
,
5482 static int show_ip_ospf_neighbor_detail_common(struct vty
*vty
,
5484 json_object
*json
, bool use_json
,
5487 struct ospf_interface
*oi
;
5488 struct listnode
*node
;
5489 json_object
*json_vrf
= NULL
;
5490 json_object
*json_nbr_sub
= NULL
;
5494 json_vrf
= json_object_new_object();
5498 json_nbr_sub
= json_object_new_object();
5501 if (ospf
->instance
) {
5503 json_object_int_add(json
, "ospfInstance",
5506 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
5509 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
5511 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
5512 struct route_node
*rn
;
5513 struct ospf_neighbor
*nbr
, *prev_nbr
= NULL
;
5515 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
)) {
5516 if ((nbr
= rn
->info
)) {
5517 if (nbr
!= oi
->nbr_self
) {
5518 if (nbr
->state
!= NSM_Down
) {
5519 show_ip_ospf_neighbor_detail_sub(
5520 vty
, oi
, nbr
, prev_nbr
,
5521 json_nbr_sub
, use_json
);
5530 json_object_object_add(json_vrf
, "neighbors",
5533 if (ospf
->vrf_id
== VRF_DEFAULT
)
5534 json_object_object_add(json
, "default",
5537 json_object_object_add(json
, ospf
->name
,
5546 DEFUN (show_ip_ospf_neighbor_detail
,
5547 show_ip_ospf_neighbor_detail_cmd
,
5548 "show ip ospf [vrf <NAME|all>] neighbor detail [json]",
5551 "OSPF information\n"
5555 "detail of all neighbors\n"
5559 bool uj
= use_json(argc
, argv
);
5560 struct listnode
*node
= NULL
;
5561 char *vrf_name
= NULL
;
5562 bool all_vrf
= false;
5563 int ret
= CMD_SUCCESS
;
5566 uint8_t use_vrf
= 0;
5567 json_object
*json
= NULL
;
5569 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
5572 json
= json_object_new_object();
5574 /* vrf input is provided could be all or specific vrf*/
5578 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
5579 if (!ospf
->oi_running
)
5581 ret
= show_ip_ospf_neighbor_detail_common(
5582 vty
, ospf
, json
, uj
, use_vrf
);
5585 vty_out(vty
, "%s\n",
5586 json_object_to_json_string_ext(
5587 json
, JSON_C_TO_STRING_PRETTY
));
5588 json_object_free(json
);
5593 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
5594 if (ospf
== NULL
|| !ospf
->oi_running
) {
5596 json_object_free(json
);
5600 /* Display default ospf (instance 0) info */
5601 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
5602 if (ospf
== NULL
|| !ospf
->oi_running
) {
5604 json_object_free(json
);
5610 ret
= show_ip_ospf_neighbor_detail_common(vty
, ospf
, json
, uj
,
5613 vty_out(vty
, "%s\n",
5614 json_object_to_json_string_ext(
5615 json
, JSON_C_TO_STRING_PRETTY
));
5620 json_object_free(json
);
5625 DEFUN (show_ip_ospf_instance_neighbor_detail
,
5626 show_ip_ospf_instance_neighbor_detail_cmd
,
5627 "show ip ospf (1-65535) neighbor detail [json]",
5630 "OSPF information\n"
5633 "detail of all neighbors\n"
5638 unsigned short instance
= 0;
5639 bool uj
= use_json(argc
, argv
);
5640 json_object
*json
= NULL
;
5641 int ret
= CMD_SUCCESS
;
5643 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5644 if (instance
!= ospf_instance
)
5645 return CMD_NOT_MY_INSTANCE
;
5647 ospf
= ospf_lookup_instance(instance
);
5648 if (!ospf
|| !ospf
->oi_running
)
5652 json
= json_object_new_object();
5654 ret
= show_ip_ospf_neighbor_detail_common(vty
, ospf
, json
, uj
, 0);
5657 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
5658 json
, JSON_C_TO_STRING_PRETTY
));
5659 json_object_free(json
);
5665 static int show_ip_ospf_neighbor_detail_all_common(struct vty
*vty
,
5671 struct listnode
*node
;
5672 struct ospf_interface
*oi
;
5673 json_object
*json_vrf
= NULL
;
5677 json_vrf
= json_object_new_object();
5682 if (ospf
->instance
) {
5684 json_object_int_add(json
, "ospfInstance",
5687 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
5690 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
5692 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
5693 struct route_node
*rn
;
5694 struct ospf_neighbor
*nbr
, *prev_nbr
= NULL
;
5695 struct ospf_nbr_nbma
*nbr_nbma
;
5697 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
)) {
5698 if ((nbr
= rn
->info
)) {
5699 if (nbr
!= oi
->nbr_self
)
5700 if (nbr
->state
!= NSM_Down
)
5701 show_ip_ospf_neighbor_detail_sub(
5704 json_vrf
, use_json
);
5709 if (oi
->type
== OSPF_IFTYPE_NBMA
) {
5710 struct listnode
*nd
;
5712 for (ALL_LIST_ELEMENTS_RO(oi
->nbr_nbma
, nd
, nbr_nbma
)) {
5713 if (nbr_nbma
->nbr
== NULL
5714 || nbr_nbma
->nbr
->state
== NSM_Down
)
5715 show_ip_ospf_nbr_nbma_detail_sub(
5716 vty
, oi
, nbr_nbma
, use_json
,
5724 if (ospf
->vrf_id
== VRF_DEFAULT
)
5725 json_object_object_add(json
, "default",
5728 json_object_object_add(json
, ospf
->name
,
5738 DEFUN (show_ip_ospf_neighbor_detail_all
,
5739 show_ip_ospf_neighbor_detail_all_cmd
,
5740 "show ip ospf [vrf <NAME|all>] neighbor detail all [json]",
5743 "OSPF information\n"
5747 "detail of all neighbors\n"
5748 "include down status neighbor\n"
5752 bool uj
= use_json(argc
, argv
);
5753 struct listnode
*node
= NULL
;
5754 char *vrf_name
= NULL
;
5755 bool all_vrf
= false;
5756 int ret
= CMD_SUCCESS
;
5759 uint8_t use_vrf
= 0;
5760 json_object
*json
= NULL
;
5762 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
5765 json
= json_object_new_object();
5767 /* vrf input is provided could be all or specific vrf*/
5771 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
5772 if (!ospf
->oi_running
)
5774 ret
= show_ip_ospf_neighbor_detail_all_common(
5775 vty
, ospf
, json
, uj
, use_vrf
);
5779 vty_out(vty
, "%s\n",
5780 json_object_to_json_string_ext(
5781 json
, JSON_C_TO_STRING_PRETTY
));
5782 json_object_free(json
);
5787 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
5788 if (ospf
== NULL
|| !ospf
->oi_running
) {
5790 json_object_free(json
);
5794 /* Display default ospf (instance 0) info */
5795 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
5796 if (ospf
== NULL
|| !ospf
->oi_running
) {
5798 json_object_free(json
);
5804 ret
= show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, json
,
5807 vty_out(vty
, "%s\n",
5808 json_object_to_json_string_ext(
5809 json
, JSON_C_TO_STRING_PRETTY
));
5814 json_object_free(json
);
5819 DEFUN (show_ip_ospf_instance_neighbor_detail_all
,
5820 show_ip_ospf_instance_neighbor_detail_all_cmd
,
5821 "show ip ospf (1-65535) neighbor detail all [json]",
5824 "OSPF information\n"
5827 "detail of all neighbors\n"
5828 "include down status neighbor\n"
5833 unsigned short instance
= 0;
5834 bool uj
= use_json(argc
, argv
);
5835 json_object
*json
= NULL
;
5836 int ret
= CMD_SUCCESS
;
5838 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5839 if (instance
!= ospf_instance
)
5840 return CMD_NOT_MY_INSTANCE
;
5842 ospf
= ospf_lookup_instance(instance
);
5843 if (!ospf
|| !ospf
->oi_running
)
5847 json
= json_object_new_object();
5849 ret
= show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, json
, uj
, 0);
5852 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
5853 json
, JSON_C_TO_STRING_PRETTY
));
5854 json_object_free(json
);
5860 static int show_ip_ospf_neighbor_int_detail_common(struct vty
*vty
,
5863 struct cmd_token
**argv
,
5866 struct ospf_interface
*oi
;
5867 struct interface
*ifp
;
5868 struct route_node
*rn
, *nrn
;
5869 struct ospf_neighbor
*nbr
;
5870 json_object
*json
= NULL
;
5873 json
= json_object_new_object();
5875 if (ospf
->instance
) {
5877 json_object_int_add(json
, "ospfInstance",
5880 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
5883 ifp
= if_lookup_by_name(argv
[arg_base
]->arg
, ospf
->vrf_id
);
5886 vty_out(vty
, "No such interface.\n");
5888 vty_out(vty
, "{}\n");
5889 json_object_free(json
);
5894 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
5895 if ((oi
= rn
->info
)) {
5896 for (nrn
= route_top(oi
->nbrs
); nrn
;
5897 nrn
= route_next(nrn
)) {
5898 if ((nbr
= nrn
->info
)) {
5899 if (nbr
!= oi
->nbr_self
) {
5900 if (nbr
->state
!= NSM_Down
)
5901 show_ip_ospf_neighbor_detail_sub(
5912 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
5913 json
, JSON_C_TO_STRING_PRETTY
));
5914 json_object_free(json
);
5921 DEFUN (show_ip_ospf_neighbor_int_detail
,
5922 show_ip_ospf_neighbor_int_detail_cmd
,
5923 "show ip ospf neighbor IFNAME detail [json]",
5926 "OSPF information\n"
5929 "detail of all neighbors\n"
5933 bool uj
= use_json(argc
, argv
);
5934 struct listnode
*node
= NULL
;
5935 int ret
= CMD_SUCCESS
;
5936 bool ospf_output
= false;
5938 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
5939 if (!ospf
->oi_running
)
5942 ret
= show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 4,
5947 vty_out(vty
, "%% OSPF instance not found\n");
5952 DEFUN (show_ip_ospf_instance_neighbor_int_detail
,
5953 show_ip_ospf_instance_neighbor_int_detail_cmd
,
5954 "show ip ospf (1-65535) neighbor IFNAME detail [json]",
5957 "OSPF information\n"
5961 "detail of all neighbors\n"
5967 unsigned short instance
= 0;
5968 bool uj
= use_json(argc
, argv
);
5970 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5971 if (instance
!= ospf_instance
)
5972 return CMD_NOT_MY_INSTANCE
;
5974 ospf
= ospf_lookup_instance(instance
);
5975 if (!ospf
|| !ospf
->oi_running
)
5978 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, idx_ifname
,
5982 /* Show functions */
5983 static int show_lsa_summary(struct vty
*vty
, struct ospf_lsa
*lsa
, int self
,
5984 json_object
*json_lsa
)
5986 struct router_lsa
*rl
;
5987 struct summary_lsa
*sl
;
5988 struct as_external_lsa
*asel
;
5989 struct prefix_ipv4 p
;
5990 char buf
[PREFIX2STR_BUFFER
];
5993 /* If self option is set, check LSA self flag. */
5994 if (self
== 0 || IS_LSA_SELF(lsa
)) {
5997 /* LSA common part show. */
5998 vty_out(vty
, "%-15pI4",
6000 vty_out(vty
, "%-15pI4 %4d 0x%08lx 0x%04x",
6001 &lsa
->data
->adv_router
, LS_AGE(lsa
),
6002 (unsigned long)ntohl(
6003 lsa
->data
->ls_seqnum
),
6004 ntohs(lsa
->data
->checksum
));
6009 snprintf(seqnum
, sizeof(seqnum
), "%x",
6010 ntohl(lsa
->data
->ls_seqnum
));
6011 snprintf(checksum
, sizeof(checksum
), "%x",
6012 ntohs(lsa
->data
->checksum
));
6013 json_object_string_add(
6015 inet_ntop(AF_INET
, &lsa
->data
->id
,
6017 json_object_string_add(
6018 json_lsa
, "advertisedRouter",
6020 &lsa
->data
->adv_router
,
6022 json_object_int_add(json_lsa
, "lsaAge",
6024 json_object_string_add(
6025 json_lsa
, "sequenceNumber", seqnum
);
6026 json_object_string_add(json_lsa
, "checksum",
6030 /* LSA specific part show. */
6031 switch (lsa
->data
->type
) {
6032 case OSPF_ROUTER_LSA
:
6033 rl
= (struct router_lsa
*)lsa
->data
;
6036 vty_out(vty
, " %-d", ntohs(rl
->links
));
6038 json_object_int_add(json_lsa
,
6042 case OSPF_SUMMARY_LSA
:
6043 sl
= (struct summary_lsa
*)lsa
->data
;
6046 p
.prefix
= sl
->header
.id
;
6047 p
.prefixlen
= ip_masklen(sl
->mask
);
6048 apply_mask_ipv4(&p
);
6051 vty_out(vty
, " %pFX", &p
);
6053 prefix2str(&p
, buf
, sizeof(buf
));
6054 json_object_string_add(json_lsa
,
6059 case OSPF_AS_EXTERNAL_LSA
:
6060 case OSPF_AS_NSSA_LSA
:
6061 asel
= (struct as_external_lsa
*)lsa
->data
;
6064 p
.prefix
= asel
->header
.id
;
6065 p
.prefixlen
= ip_masklen(asel
->mask
);
6066 apply_mask_ipv4(&p
);
6069 vty_out(vty
, " %s %pFX [0x%lx]",
6075 (unsigned long)ntohl(
6076 asel
->e
[0].route_tag
));
6078 prefix2str(&p
, buf
, sizeof(buf
));
6079 json_object_string_add(
6080 json_lsa
, "metricType",
6085 json_object_string_add(json_lsa
,
6087 json_object_int_add(
6089 (unsigned long)ntohl(
6090 asel
->e
[0].route_tag
));
6093 case OSPF_NETWORK_LSA
:
6094 case OSPF_ASBR_SUMMARY_LSA
:
6095 case OSPF_OPAQUE_LINK_LSA
:
6096 case OSPF_OPAQUE_AREA_LSA
:
6097 case OSPF_OPAQUE_AS_LSA
:
6109 static const char *const show_database_desc
[] = {
6111 "Router Link States",
6113 "Summary Link States",
6114 "ASBR-Summary Link States",
6115 "AS External Link States",
6116 "Group Membership LSA",
6117 "NSSA-external Link States",
6119 "Link-Local Opaque-LSA",
6120 "Area-Local Opaque-LSA",
6121 "AS-external Opaque-LSA",
6124 static const char * const show_database_desc_json
[] = {
6127 "networkLinkStates",
6128 "summaryLinkStates",
6129 "asbrSummaryLinkStates",
6130 "asExternalLinkStates",
6131 "groupMembershipLsa",
6132 "nssaExternalLinkStates",
6134 "linkLocalOpaqueLsa",
6135 "areaLocalOpaqueLsa",
6136 "asExternalOpaqueLsa",
6139 static const char *const show_database_header
[] = {
6141 "Link ID ADV Router Age Seq# CkSum Link count",
6142 "Link ID ADV Router Age Seq# CkSum",
6143 "Link ID ADV Router Age Seq# CkSum Route",
6144 "Link ID ADV Router Age Seq# CkSum",
6145 "Link ID ADV Router Age Seq# CkSum Route",
6146 " --- header for Group Member ----",
6147 "Link ID ADV Router Age Seq# CkSum Route",
6149 "Opaque-Type/Id ADV Router Age Seq# CkSum",
6150 "Opaque-Type/Id ADV Router Age Seq# CkSum",
6151 "Opaque-Type/Id ADV Router Age Seq# CkSum",
6154 static void show_ip_ospf_database_header(struct vty
*vty
, struct ospf_lsa
*lsa
,
6157 char buf
[PREFIX_STRLEN
];
6158 struct router_lsa
*rlsa
= (struct router_lsa
*)lsa
->data
;
6161 vty_out(vty
, " LS age: %d\n", LS_AGE(lsa
));
6162 vty_out(vty
, " Options: 0x%-2x : %s\n", lsa
->data
->options
,
6163 ospf_options_dump(lsa
->data
->options
));
6164 vty_out(vty
, " LS Flags: 0x%-2x %s\n", lsa
->flags
,
6165 ((lsa
->flags
& OSPF_LSA_LOCAL_XLT
)
6166 ? "(Translated from Type-7)"
6169 if (lsa
->data
->type
== OSPF_ROUTER_LSA
) {
6170 vty_out(vty
, " Flags: 0x%x", rlsa
->flags
);
6173 vty_out(vty
, " :%s%s%s%s",
6174 IS_ROUTER_LSA_BORDER(rlsa
) ? " ABR"
6176 IS_ROUTER_LSA_EXTERNAL(rlsa
) ? " ASBR"
6178 IS_ROUTER_LSA_VIRTUAL(rlsa
)
6181 IS_ROUTER_LSA_SHORTCUT(rlsa
)
6187 vty_out(vty
, " LS Type: %s\n",
6188 lookup_msg(ospf_lsa_type_msg
, lsa
->data
->type
, NULL
));
6189 vty_out(vty
, " Link State ID: %pI4 %s\n",
6191 lookup_msg(ospf_link_state_id_type_msg
, lsa
->data
->type
,
6193 vty_out(vty
, " Advertising Router: %pI4\n",
6194 &lsa
->data
->adv_router
);
6195 vty_out(vty
, " LS Seq Number: %08lx\n",
6196 (unsigned long)ntohl(lsa
->data
->ls_seqnum
));
6197 vty_out(vty
, " Checksum: 0x%04x\n",
6198 ntohs(lsa
->data
->checksum
));
6199 vty_out(vty
, " Length: %d\n\n", ntohs(lsa
->data
->length
));
6204 snprintf(seqnum
, 10, "%x", ntohl(lsa
->data
->ls_seqnum
));
6205 snprintf(checksum
, 10, "%x", ntohs(lsa
->data
->checksum
));
6207 json_object_int_add(json
, "lsaAge", LS_AGE(lsa
));
6208 json_object_string_add(json
, "options",
6209 ospf_options_dump(lsa
->data
->options
));
6210 json_object_int_add(json
, "lsaFlags", lsa
->flags
);
6212 if (lsa
->flags
& OSPF_LSA_LOCAL_XLT
)
6213 json_object_boolean_true_add(json
,
6214 "translatedFromType7");
6216 if (lsa
->data
->type
== OSPF_ROUTER_LSA
) {
6217 json_object_int_add(json
, "flags", rlsa
->flags
);
6220 if (IS_ROUTER_LSA_BORDER(rlsa
))
6221 json_object_boolean_true_add(json
,
6223 if (IS_ROUTER_LSA_EXTERNAL(rlsa
))
6224 json_object_boolean_true_add(json
,
6226 if (IS_ROUTER_LSA_VIRTUAL(rlsa
))
6227 json_object_boolean_true_add(
6228 json
, "vlEndpoint");
6229 if (IS_ROUTER_LSA_SHORTCUT(rlsa
))
6230 json_object_boolean_true_add(
6235 json_object_string_add(
6237 lookup_msg(ospf_lsa_type_msg
, lsa
->data
->type
, NULL
));
6238 json_object_string_add(json
, "linkStateId",
6239 inet_ntop(AF_INET
, &lsa
->data
->id
,
6241 json_object_string_add(json
, "advertisingRouter",
6243 &lsa
->data
->adv_router
,
6245 json_object_string_add(json
, "lsaSeqNumber", seqnum
);
6246 json_object_string_add(json
, "checksum", checksum
);
6247 json_object_int_add(json
, "length", ntohs(lsa
->data
->length
));
6251 static const char *const link_type_desc
[] = {
6253 "another Router (point-to-point)",
6254 "a Transit Network",
6259 static const char *const link_id_desc
[] = {
6260 "(null)", "Neighboring Router ID", "Designated Router address",
6261 "Net", "Neighboring Router ID",
6264 static const char *const link_data_desc
[] = {
6265 "(null)", "Router Interface address", "Router Interface address",
6266 "Network Mask", "Router Interface address",
6269 static const char *const link_id_desc_json
[] = {
6270 "null", "neighborRouterId", "designatedRouterAddress",
6271 "networkAddress", "neighborRouterId",
6274 static const char *const link_data_desc_json
[] = {
6275 "null", "routerInterfaceAddress", "routerInterfaceAddress",
6276 "networkMask", "routerInterfaceAddress",
6279 /* Show router-LSA each Link information. */
6280 static void show_ip_ospf_database_router_links(struct vty
*vty
,
6281 struct router_lsa
*rl
,
6286 json_object
*json_links
= NULL
;
6287 json_object
*json_link
= NULL
;
6289 char buf
[PREFIX_STRLEN
];
6292 json_links
= json_object_new_object();
6294 len
= ntohs(rl
->header
.length
) - 4;
6295 for (i
= 0; i
< ntohs(rl
->links
) && len
> 0; len
-= 12, i
++) {
6296 type
= rl
->link
[i
].type
;
6301 snprintf(link
, sizeof(link
), "link%u", i
);
6302 json_link
= json_object_new_object();
6303 json_object_string_add(json_link
, "linkType",
6304 link_type_desc
[type
]);
6305 json_object_string_add(json_link
,
6306 link_id_desc_json
[type
],
6308 &rl
->link
[i
].link_id
,
6310 json_object_string_add(
6311 json_link
, link_data_desc_json
[type
],
6312 inet_ntop(AF_INET
, &rl
->link
[i
].link_data
,
6314 json_object_int_add(json_link
, "numOfTosMetrics",
6316 json_object_int_add(json_link
, "tos0Metric",
6317 ntohs(rl
->link
[i
].metric
));
6318 json_object_object_add(json_links
, link
, json_link
);
6320 vty_out(vty
, " Link connected to: %s\n",
6321 link_type_desc
[type
]);
6322 vty_out(vty
, " (Link ID) %s: %pI4\n",
6324 &rl
->link
[i
].link_id
);
6325 vty_out(vty
, " (Link Data) %s: %pI4\n",
6326 link_data_desc
[type
],
6327 &rl
->link
[i
].link_data
);
6328 vty_out(vty
, " Number of TOS metrics: 0\n");
6329 vty_out(vty
, " TOS 0 Metric: %d\n",
6330 ntohs(rl
->link
[i
].metric
));
6335 json_object_object_add(json
, "routerLinks", json_links
);
6338 /* Show router-LSA detail information. */
6339 static int show_router_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
,
6343 struct router_lsa
*rl
= (struct router_lsa
*)lsa
->data
;
6345 show_ip_ospf_database_header(vty
, lsa
, json
);
6348 vty_out(vty
, " Number of Links: %d\n\n",
6351 json_object_int_add(json
, "numOfLinks",
6354 show_ip_ospf_database_router_links(vty
, rl
, json
);
6363 /* Show network-LSA detail information. */
6364 static int show_network_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
,
6368 char buf
[PREFIX_STRLEN
];
6369 json_object
*json_attached_rt
= NULL
;
6370 json_object
*json_router
= NULL
;
6373 json_attached_rt
= json_object_new_object();
6376 struct network_lsa
*nl
= (struct network_lsa
*)lsa
->data
;
6378 show_ip_ospf_database_header(vty
, lsa
, json
);
6381 vty_out(vty
, " Network Mask: /%d\n",
6382 ip_masklen(nl
->mask
));
6384 json_object_int_add(json
, "networkMask",
6385 ip_masklen(nl
->mask
));
6387 length
= ntohs(lsa
->data
->length
) - OSPF_LSA_HEADER_SIZE
- 4;
6389 for (i
= 0; length
> 0; i
++, length
-= 4)
6391 vty_out(vty
, " Attached Router: %pI4\n",
6395 json_router
= json_object_new_object();
6396 json_object_string_add(
6397 json_router
, "attachedRouterId",
6398 inet_ntop(AF_INET
, &nl
->routers
[i
],
6400 json_object_object_add(
6402 inet_ntop(AF_INET
, &(nl
->routers
[i
]),
6409 json_object_object_add(json
, "attchedRouters",
6415 /* Show summary-LSA detail information. */
6416 static int show_summary_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
,
6420 struct summary_lsa
*sl
= (struct summary_lsa
*)lsa
->data
;
6422 show_ip_ospf_database_header(vty
, lsa
, json
);
6425 vty_out(vty
, " Network Mask: /%d\n",
6426 ip_masklen(sl
->mask
));
6427 vty_out(vty
, " TOS: 0 Metric: %d\n",
6428 GET_METRIC(sl
->metric
));
6431 json_object_int_add(json
, "networkMask",
6432 ip_masklen(sl
->mask
));
6433 json_object_int_add(json
, "tos0Metric",
6434 GET_METRIC(sl
->metric
));
6441 /* Show summary-ASBR-LSA detail information. */
6442 static int show_summary_asbr_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
,
6446 struct summary_lsa
*sl
= (struct summary_lsa
*)lsa
->data
;
6448 show_ip_ospf_database_header(vty
, lsa
, json
);
6451 vty_out(vty
, " Network Mask: /%d\n",
6452 ip_masklen(sl
->mask
));
6453 vty_out(vty
, " TOS: 0 Metric: %d\n",
6454 GET_METRIC(sl
->metric
));
6457 json_object_int_add(json
, "networkMask",
6458 ip_masklen(sl
->mask
));
6459 json_object_int_add(json
, "tos0Metric",
6460 GET_METRIC(sl
->metric
));
6467 /* Show AS-external-LSA detail information. */
6468 static int show_as_external_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
,
6471 char buf
[PREFIX_STRLEN
];
6475 struct as_external_lsa
*al
=
6476 (struct as_external_lsa
*)lsa
->data
;
6478 show_ip_ospf_database_header(vty
, lsa
, json
);
6481 vty_out(vty
, " Network Mask: /%d\n",
6482 ip_masklen(al
->mask
));
6483 vty_out(vty
, " Metric Type: %s\n",
6484 IS_EXTERNAL_METRIC(al
->e
[0].tos
)
6485 ? "2 (Larger than any link state path)"
6487 vty_out(vty
, " TOS: 0\n");
6488 vty_out(vty
, " Metric: %d\n",
6489 GET_METRIC(al
->e
[0].metric
));
6490 vty_out(vty
, " Forward Address: %pI4\n",
6491 &al
->e
[0].fwd_addr
);
6493 " External Route Tag: %" ROUTE_TAG_PRI
"\n\n",
6494 (route_tag_t
)ntohl(al
->e
[0].route_tag
));
6496 json_object_int_add(json
, "networkMask",
6497 ip_masklen(al
->mask
));
6498 json_object_string_add(
6500 IS_EXTERNAL_METRIC(al
->e
[0].tos
)
6501 ? "E2 (Larger than any link state path)"
6503 json_object_int_add(json
, "tos", tos
);
6504 json_object_int_add(json
, "metric",
6505 GET_METRIC(al
->e
[0].metric
));
6506 json_object_string_add(json
, "forwardAddress",
6508 &(al
->e
[0].fwd_addr
),
6510 json_object_int_add(
6511 json
, "externalRouteTag",
6512 (route_tag_t
)ntohl(al
->e
[0].route_tag
));
6519 /* Show AS-NSSA-LSA detail information. */
6520 static int show_as_nssa_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
,
6523 char buf
[PREFIX_STRLEN
];
6527 struct as_external_lsa
*al
=
6528 (struct as_external_lsa
*)lsa
->data
;
6530 show_ip_ospf_database_header(vty
, lsa
, json
);
6533 vty_out(vty
, " Network Mask: /%d\n",
6534 ip_masklen(al
->mask
));
6535 vty_out(vty
, " Metric Type: %s\n",
6536 IS_EXTERNAL_METRIC(al
->e
[0].tos
)
6537 ? "2 (Larger than any link state path)"
6539 vty_out(vty
, " TOS: 0\n");
6540 vty_out(vty
, " Metric: %d\n",
6541 GET_METRIC(al
->e
[0].metric
));
6542 vty_out(vty
, " NSSA: Forward Address: %pI4\n",
6543 &al
->e
[0].fwd_addr
);
6545 " External Route Tag: %" ROUTE_TAG_PRI
6547 (route_tag_t
)ntohl(al
->e
[0].route_tag
));
6549 json_object_int_add(json
, "networkMask",
6550 ip_masklen(al
->mask
));
6551 json_object_string_add(
6553 IS_EXTERNAL_METRIC(al
->e
[0].tos
)
6554 ? "E2 (Larger than any link state path)"
6556 json_object_int_add(json
, "tos", tos
);
6557 json_object_int_add(json
, "metric",
6558 GET_METRIC(al
->e
[0].metric
));
6559 json_object_string_add(json
, "nssaForwardAddress",
6563 json_object_int_add(
6564 json
, "externalRouteTag",
6565 (route_tag_t
)ntohl(al
->e
[0].route_tag
));
6572 static int show_func_dummy(struct vty
*vty
, struct ospf_lsa
*lsa
,
6578 static int show_opaque_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
,
6582 show_ip_ospf_database_header(vty
, lsa
, json
);
6583 show_opaque_info_detail(vty
, lsa
, json
);
6590 int (*show_function
[])(struct vty
*, struct ospf_lsa
*, json_object
*) = {
6592 show_router_lsa_detail
,
6593 show_network_lsa_detail
,
6594 show_summary_lsa_detail
,
6595 show_summary_asbr_lsa_detail
,
6596 show_as_external_lsa_detail
,
6598 show_as_nssa_lsa_detail
, /* almost same as external */
6600 show_opaque_lsa_detail
,
6601 show_opaque_lsa_detail
,
6602 show_opaque_lsa_detail
,
6605 static void show_lsa_prefix_set(struct vty
*vty
, struct prefix_ls
*lp
,
6606 struct in_addr
*id
, struct in_addr
*adv_router
)
6608 memset(lp
, 0, sizeof(struct prefix_ls
));
6612 else if (adv_router
== NULL
) {
6618 lp
->adv_router
= *adv_router
;
6622 static void show_lsa_detail_proc(struct vty
*vty
, struct route_table
*rt
,
6623 struct in_addr
*id
, struct in_addr
*adv_router
,
6626 struct prefix_ls lp
;
6627 struct route_node
*rn
, *start
;
6628 struct ospf_lsa
*lsa
;
6629 json_object
*json_lsa
= NULL
;
6631 show_lsa_prefix_set(vty
, &lp
, id
, adv_router
);
6632 start
= route_node_get(rt
, (struct prefix
*)&lp
);
6634 route_lock_node(start
);
6635 for (rn
= start
; rn
; rn
= route_next_until(rn
, start
))
6636 if ((lsa
= rn
->info
)) {
6638 json_lsa
= json_object_new_object();
6639 json_object_array_add(json
, json_lsa
);
6642 if (show_function
[lsa
->data
->type
] != NULL
)
6643 show_function
[lsa
->data
->type
](
6644 vty
, lsa
, json_lsa
);
6646 route_unlock_node(start
);
6650 /* Show detail LSA information
6651 -- if id is NULL then show all LSAs. */
6652 static void show_lsa_detail(struct vty
*vty
, struct ospf
*ospf
, int type
,
6653 struct in_addr
*id
, struct in_addr
*adv_router
,
6656 struct listnode
*node
;
6657 struct ospf_area
*area
;
6658 char buf
[PREFIX_STRLEN
];
6659 json_object
*json_lsa_type
= NULL
;
6660 json_object
*json_areas
= NULL
;
6661 json_object
*json_lsa_array
= NULL
;
6664 json_lsa_type
= json_object_new_object();
6667 case OSPF_AS_EXTERNAL_LSA
:
6668 case OSPF_OPAQUE_AS_LSA
:
6670 vty_out(vty
, " %s \n\n",
6671 show_database_desc
[type
]);
6673 json_lsa_array
= json_object_new_array();
6675 show_lsa_detail_proc(vty
, AS_LSDB(ospf
, type
), id
, adv_router
,
6678 json_object_object_add(json
,
6679 show_database_desc_json
[type
],
6685 json_areas
= json_object_new_object();
6687 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
6690 "\n %s (Area %s)\n\n",
6691 show_database_desc
[type
],
6692 ospf_area_desc_string(area
));
6694 json_lsa_array
= json_object_new_array();
6695 json_object_object_add(json_areas
,
6703 show_lsa_detail_proc(vty
, AREA_LSDB(area
, type
), id
,
6704 adv_router
, json_lsa_array
);
6708 json_object_object_add(json_lsa_type
, "areas",
6710 json_object_object_add(json
,
6711 show_database_desc_json
[type
],
6718 static void show_lsa_detail_adv_router_proc(struct vty
*vty
,
6719 struct route_table
*rt
,
6720 struct in_addr
*adv_router
,
6723 char buf
[PREFIX_STRLEN
];
6724 struct route_node
*rn
;
6725 struct ospf_lsa
*lsa
;
6727 for (rn
= route_top(rt
); rn
; rn
= route_next(rn
))
6728 if ((lsa
= rn
->info
)) {
6729 json_object
*json_lsa
= NULL
;
6731 if (IPV4_ADDR_SAME(adv_router
,
6732 &lsa
->data
->adv_router
)) {
6733 if (CHECK_FLAG(lsa
->flags
, OSPF_LSA_LOCAL_XLT
))
6736 json_lsa
= json_object_new_object();
6738 if (show_function
[lsa
->data
->type
] != NULL
)
6739 show_function
[lsa
->data
->type
](
6740 vty
, lsa
, json_lsa
);
6742 json_object_object_add(
6752 /* Show detail LSA information. */
6753 static void show_lsa_detail_adv_router(struct vty
*vty
, struct ospf
*ospf
,
6754 int type
, struct in_addr
*adv_router
,
6757 struct listnode
*node
;
6758 struct ospf_area
*area
;
6759 char buf
[PREFIX_STRLEN
];
6760 json_object
*json_lstype
= NULL
;
6761 json_object
*json_area
= NULL
;
6764 json_lstype
= json_object_new_object();
6767 case OSPF_AS_EXTERNAL_LSA
:
6768 case OSPF_OPAQUE_AS_LSA
:
6770 vty_out(vty
, " %s \n\n",
6771 show_database_desc
[type
]);
6773 show_lsa_detail_adv_router_proc(vty
, AS_LSDB(ospf
, type
),
6774 adv_router
, json_lstype
);
6778 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
6780 json_area
= json_object_new_object();
6783 "\n %s (Area %s)\n\n",
6784 show_database_desc
[type
],
6785 ospf_area_desc_string(area
));
6786 show_lsa_detail_adv_router_proc(vty
,
6787 AREA_LSDB(area
, type
),
6788 adv_router
, json_area
);
6791 json_object_object_add(json_lstype
,
6802 json_object_object_add(json
, show_database_desc
[type
],
6806 void show_ip_ospf_database_summary(struct vty
*vty
, struct ospf
*ospf
, int self
,
6809 struct ospf_lsa
*lsa
;
6810 struct route_node
*rn
;
6811 struct ospf_area
*area
;
6812 struct listnode
*node
;
6813 char buf
[PREFIX_STRLEN
];
6814 json_object
*json_areas
= NULL
;
6815 json_object
*json_area
= NULL
;
6816 json_object
*json_lsa
= NULL
;
6818 json_object
*json_lsa_array
= NULL
;
6821 json_areas
= json_object_new_object();
6823 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
6825 json_area
= json_object_new_object();
6827 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++) {
6829 case OSPF_AS_EXTERNAL_LSA
:
6830 case OSPF_OPAQUE_AS_LSA
:
6835 if (ospf_lsdb_count_self(area
->lsdb
, type
) > 0
6837 && ospf_lsdb_count(area
->lsdb
, type
) > 0)) {
6841 " %s (Area %s)\n\n",
6842 show_database_desc
[type
],
6843 ospf_area_desc_string(area
));
6844 vty_out(vty
, "%s\n",
6845 show_database_header
[type
]);
6848 json_object_new_array();
6849 json_object_object_add(
6851 show_database_desc_json
[type
],
6855 LSDB_LOOP (AREA_LSDB(area
, type
), rn
, lsa
) {
6858 json_object_new_object();
6859 json_object_array_add(
6864 show_lsa_summary(vty
, lsa
, self
,
6873 json_object_object_add(json_areas
,
6881 json_object_object_add(json
, "areas", json_areas
);
6883 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++) {
6885 case OSPF_AS_EXTERNAL_LSA
:
6886 case OSPF_OPAQUE_AS_LSA
:
6891 if (ospf_lsdb_count_self(ospf
->lsdb
, type
)
6892 || (!self
&& ospf_lsdb_count(ospf
->lsdb
, type
))) {
6894 vty_out(vty
, " %s\n\n",
6895 show_database_desc
[type
]);
6896 vty_out(vty
, "%s\n",
6897 show_database_header
[type
]);
6899 json_lsa_array
= json_object_new_array();
6900 json_object_object_add(
6901 json
, show_database_desc_json
[type
],
6905 LSDB_LOOP (AS_LSDB(ospf
, type
), rn
, lsa
) {
6907 json_lsa
= json_object_new_object();
6908 json_object_array_add(json_lsa_array
,
6912 show_lsa_summary(vty
, lsa
, self
, json_lsa
);
6924 static void show_ip_ospf_database_maxage(struct vty
*vty
, struct ospf
*ospf
,
6927 struct route_node
*rn
;
6928 char buf
[PREFIX_STRLEN
];
6929 json_object
*json_maxage
= NULL
;
6932 vty_out(vty
, "\n MaxAge Link States:\n\n");
6934 json_maxage
= json_object_new_object();
6936 for (rn
= route_top(ospf
->maxage_lsa
); rn
; rn
= route_next(rn
)) {
6937 struct ospf_lsa
*lsa
;
6938 json_object
*json_lsa
= NULL
;
6940 if ((lsa
= rn
->info
) != NULL
) {
6942 vty_out(vty
, "Link type: %d\n",
6944 vty_out(vty
, "Link State ID: %pI4\n",
6946 vty_out(vty
, "Advertising Router: %pI4\n",
6947 &lsa
->data
->adv_router
);
6948 vty_out(vty
, "LSA lock count: %d\n", lsa
->lock
);
6951 json_lsa
= json_object_new_object();
6952 json_object_int_add(json_lsa
, "linkType",
6954 json_object_string_add(
6955 json_lsa
, "linkStateId",
6956 inet_ntop(AF_INET
, &lsa
->data
->id
,
6958 json_object_string_add(
6959 json_lsa
, "advertisingRouter",
6961 &lsa
->data
->adv_router
,
6963 json_object_int_add(json_lsa
, "lsaLockCount",
6965 json_object_object_add(
6975 json_object_object_add(json
, "maxAgeLinkStates", json_maxage
);
6978 #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
6979 #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
6981 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
6982 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
6983 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
6984 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
6986 #define OSPF_LSA_TYPES_DESC \
6987 "ASBR summary link states\n" \
6988 "External link states\n" \
6989 "Network link states\n" \
6990 "Router link states\n" \
6991 "Network summary link states\n" OSPF_LSA_TYPE_NSSA_DESC \
6992 OSPF_LSA_TYPE_OPAQUE_LINK_DESC OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
6993 OSPF_LSA_TYPE_OPAQUE_AS_DESC
6995 static int show_ip_ospf_database_common(struct vty
*vty
, struct ospf
*ospf
,
6996 int arg_base
, int argc
,
6997 struct cmd_token
**argv
,
6998 uint8_t use_vrf
, json_object
*json
,
7003 struct in_addr id
, adv_router
;
7004 char buf
[PREFIX_STRLEN
];
7005 json_object
*json_vrf
= NULL
;
7009 json_vrf
= json_object_new_object();
7014 if (ospf
->instance
) {
7016 json_object_int_add(json_vrf
, "ospfInstance",
7019 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
7022 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
7024 /* Show Router ID. */
7026 json_object_string_add(json_vrf
, "routerId",
7027 inet_ntop(AF_INET
, &ospf
->router_id
,
7030 vty_out(vty
, "\n OSPF Router with ID (%pI4)\n\n",
7035 if ((argc
== arg_base
+ 4) || (uj
&& (argc
== arg_base
+ 5))) {
7036 show_ip_ospf_database_summary(vty
, ospf
, 0, json_vrf
);
7039 if (ospf
->vrf_id
== VRF_DEFAULT
)
7040 json_object_object_add(json
, "default",
7043 json_object_object_add(json
, ospf
->name
,
7050 /* Set database type to show. */
7051 if (strncmp(argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
7052 type
= OSPF_ROUTER_LSA
;
7053 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
7054 type
= OSPF_NETWORK_LSA
;
7055 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
7056 type
= OSPF_AS_NSSA_LSA
;
7057 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "su", 2) == 0)
7058 type
= OSPF_SUMMARY_LSA
;
7059 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
7060 type
= OSPF_ASBR_SUMMARY_LSA
;
7061 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
7062 type
= OSPF_AS_EXTERNAL_LSA
;
7063 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "se", 2) == 0) {
7064 show_ip_ospf_database_summary(vty
, ospf
, 1, json_vrf
);
7067 if (ospf
->vrf_id
== VRF_DEFAULT
)
7068 json_object_object_add(json
, "default",
7071 json_object_object_add(json
, ospf
->name
,
7076 } else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "m", 1) == 0) {
7077 show_ip_ospf_database_maxage(vty
, ospf
, json_vrf
);
7080 if (ospf
->vrf_id
== VRF_DEFAULT
)
7081 json_object_object_add(json
, "default",
7084 json_object_object_add(json
, ospf
->name
,
7089 } else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
7090 type
= OSPF_OPAQUE_LINK_LSA
;
7091 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
7092 type
= OSPF_OPAQUE_AREA_LSA
;
7093 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
7094 type
= OSPF_OPAQUE_AS_LSA
;
7098 /* `show ip ospf database LSA'. */
7099 if ((argc
== arg_base
+ 5) || (uj
&& (argc
== arg_base
+ 6)))
7100 show_lsa_detail(vty
, ospf
, type
, NULL
, NULL
, json_vrf
);
7101 else if (argc
>= arg_base
+ 6) {
7102 ret
= inet_aton(argv
[arg_base
+ 5]->arg
, &id
);
7106 /* `show ip ospf database LSA ID'. */
7107 if ((argc
== arg_base
+ 6) || (uj
&& (argc
== arg_base
+ 7)))
7108 show_lsa_detail(vty
, ospf
, type
, &id
, NULL
, json_vrf
);
7109 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
7110 else if ((argc
== arg_base
+ 7)
7111 || (uj
&& (argc
== arg_base
+ 8))) {
7112 if (strncmp(argv
[arg_base
+ 6]->text
, "s", 1) == 0)
7113 adv_router
= ospf
->router_id
;
7115 ret
= inet_aton(argv
[arg_base
+ 7]->arg
,
7120 show_lsa_detail(vty
, ospf
, type
, &id
, &adv_router
,
7127 if (ospf
->vrf_id
== VRF_DEFAULT
)
7128 json_object_object_add(json
, "default",
7131 json_object_object_add(json
, ospf
->name
,
7139 DEFUN (show_ip_ospf_database_max
,
7140 show_ip_ospf_database_max_cmd
,
7141 "show ip ospf [vrf <NAME|all>] database <max-age|self-originate> [json]",
7144 "OSPF information\n"
7147 "Database summary\n"
7148 "LSAs in MaxAge list\n"
7149 "Self-originated link states\n"
7152 struct ospf
*ospf
= NULL
;
7153 struct listnode
*node
= NULL
;
7154 char *vrf_name
= NULL
;
7155 bool all_vrf
= false;
7156 int ret
= CMD_SUCCESS
;
7159 uint8_t use_vrf
= 0;
7160 bool uj
= use_json(argc
, argv
);
7161 json_object
*json
= NULL
;
7164 json
= json_object_new_object();
7166 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
7169 bool ospf_output
= false;
7174 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
7175 if (!ospf
->oi_running
)
7178 ret
= show_ip_ospf_database_common(
7179 vty
, ospf
, idx_vrf
? 2 : 0, argc
, argv
,
7184 vty_out(vty
, "%% OSPF instance not found\n");
7186 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
7187 if (ospf
== NULL
|| !ospf
->oi_running
) {
7188 vty_out(vty
, "%% OSPF instance not found\n");
7191 ret
= (show_ip_ospf_database_common(
7192 vty
, ospf
, idx_vrf
? 2 : 0, argc
, argv
, use_vrf
,
7196 /* Display default ospf (instance 0) info */
7197 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
7198 if (ospf
== NULL
|| !ospf
->oi_running
) {
7199 vty_out(vty
, "%% OSPF instance not found\n");
7203 ret
= show_ip_ospf_database_common(vty
, ospf
, 0, argc
, argv
,
7208 vty_out(vty
, "%s\n", json_object_to_json_string(json
));
7209 json_object_free(json
);
7215 ALIAS (show_ip_ospf_database_max
,
7216 show_ip_ospf_database_cmd
,
7217 "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]",
7220 "OSPF information\n"
7223 "Database summary\n"
7225 "Link State ID (as an IP address)\n"
7226 "Self-originated link states\n"
7227 "Advertising Router link states\n"
7228 "Advertising Router (as an IP address)\n"
7231 DEFUN (show_ip_ospf_instance_database_max
,
7232 show_ip_ospf_instance_database_max_cmd
,
7233 "show ip ospf (1-65535) database <max-age|self-originate> [json]",
7236 "OSPF information\n"
7238 "Database summary\n"
7239 "LSAs in MaxAge list\n"
7240 "Self-originated link states\n"
7245 unsigned short instance
= 0;
7246 bool uj
= use_json(argc
, argv
);
7247 json_object
*json
= NULL
;
7250 json
= json_object_new_object();
7252 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7253 if (instance
!= ospf_instance
)
7254 return CMD_NOT_MY_INSTANCE
;
7256 ospf
= ospf_lookup_instance(instance
);
7257 if (!ospf
|| !ospf
->oi_running
)
7260 show_ip_ospf_database_common(vty
, ospf
, 1, argc
, argv
, 0, json
, uj
);
7263 vty_out(vty
, "%s\n",
7264 json_object_to_json_string_ext(
7265 json
, JSON_C_TO_STRING_PRETTY
));
7266 json_object_free(json
);
7272 ALIAS (show_ip_ospf_instance_database_max
,
7273 show_ip_ospf_instance_database_cmd
,
7274 "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]",
7277 "OSPF information\n"
7279 "Database summary\n"
7281 "Link State ID (as an IP address)\n"
7282 "Self-originated link states\n"
7283 "Advertising Router link states\n"
7284 "Advertising Router (as an IP address)\n"
7287 static int show_ip_ospf_database_type_adv_router_common(struct vty
*vty
,
7289 int arg_base
, int argc
,
7290 struct cmd_token
**argv
,
7297 struct in_addr adv_router
;
7298 char buf
[PREFIX_STRLEN
];
7299 json_object
*json_vrf
= NULL
;
7303 json_vrf
= json_object_new_object();
7308 if (ospf
->instance
) {
7310 json_object_int_add(json
, "ospfInstance",
7313 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
7316 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
7318 /* Show Router ID. */
7320 json_object_string_add(json_vrf
, "routerId",
7321 inet_ntop(AF_INET
, &ospf
->router_id
,
7324 vty_out(vty
, "\n OSPF Router with ID (%pI4)\n\n",
7328 /* Set database type to show. */
7329 if (strncmp(argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
7330 type
= OSPF_ROUTER_LSA
;
7331 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
7332 type
= OSPF_NETWORK_LSA
;
7333 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
7334 type
= OSPF_AS_NSSA_LSA
;
7335 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "s", 1) == 0)
7336 type
= OSPF_SUMMARY_LSA
;
7337 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
7338 type
= OSPF_ASBR_SUMMARY_LSA
;
7339 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
7340 type
= OSPF_AS_EXTERNAL_LSA
;
7341 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
7342 type
= OSPF_OPAQUE_LINK_LSA
;
7343 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
7344 type
= OSPF_OPAQUE_AREA_LSA
;
7345 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
7346 type
= OSPF_OPAQUE_AS_LSA
;
7350 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
7351 if (strncmp(argv
[arg_base
+ 5]->text
, "s", 1) == 0)
7352 adv_router
= ospf
->router_id
;
7354 ret
= inet_aton(argv
[arg_base
+ 6]->arg
, &adv_router
);
7359 show_lsa_detail_adv_router(vty
, ospf
, type
, &adv_router
, json_vrf
);
7363 if (ospf
->vrf_id
== VRF_DEFAULT
)
7364 json_object_object_add(json
, "default",
7367 json_object_object_add(json
, ospf
->name
,
7375 DEFUN (show_ip_ospf_database_type_adv_router
,
7376 show_ip_ospf_database_type_adv_router_cmd
,
7377 "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]",
7380 "OSPF information\n"
7383 "Database summary\n"
7385 "Advertising Router link states\n"
7386 "Advertising Router (as an IP address)\n"
7387 "Self-originated link states\n"
7390 struct ospf
*ospf
= NULL
;
7391 struct listnode
*node
= NULL
;
7392 char *vrf_name
= NULL
;
7393 bool all_vrf
= false;
7394 int ret
= CMD_SUCCESS
;
7397 uint8_t use_vrf
= 0;
7398 bool uj
= use_json(argc
, argv
);
7399 json_object
*json
= NULL
;
7402 json
= json_object_new_object();
7404 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
7407 bool ospf_output
= false;
7412 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
7413 if (!ospf
->oi_running
)
7416 ret
= show_ip_ospf_database_type_adv_router_common(
7417 vty
, ospf
, 2, argc
, argv
, use_vrf
, json
,
7421 vty_out(vty
, "%% OSPF instance not found\n");
7423 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
7424 if ((ospf
== NULL
) || !ospf
->oi_running
) {
7425 vty_out(vty
, "%% OSPF instance not found\n");
7429 ret
= show_ip_ospf_database_type_adv_router_common(
7430 vty
, ospf
, 2, argc
, argv
, use_vrf
, json
, uj
);
7433 /* Display default ospf (instance 0) info */
7434 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
7435 if (ospf
== NULL
|| !ospf
->oi_running
) {
7436 vty_out(vty
, "%% OSPF instance not found\n");
7440 ret
= show_ip_ospf_database_type_adv_router_common(
7441 vty
, ospf
, 0, argc
, argv
, use_vrf
, json
, uj
);
7445 vty_out(vty
, "%s\n", json_object_to_json_string(json
));
7446 json_object_free(json
);
7452 DEFUN (show_ip_ospf_instance_database_type_adv_router
,
7453 show_ip_ospf_instance_database_type_adv_router_cmd
,
7454 "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]",
7457 "OSPF information\n"
7459 "Database summary\n"
7461 "Advertising Router link states\n"
7462 "Advertising Router (as an IP address)\n"
7463 "Self-originated link states\n"
7468 unsigned short instance
= 0;
7469 bool uj
= use_json(argc
, argv
);
7470 json_object
*json
= NULL
;
7473 json
= json_object_new_object();
7475 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7476 if (instance
!= ospf_instance
)
7477 return CMD_NOT_MY_INSTANCE
;
7479 ospf
= ospf_lookup_instance(instance
);
7480 if (!ospf
|| !ospf
->oi_running
)
7483 show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 1, argc
, argv
,
7487 vty_out(vty
, "%s\n",
7488 json_object_to_json_string_ext(
7489 json
, JSON_C_TO_STRING_PRETTY
));
7490 json_object_free(json
);
7496 DEFUN (ip_ospf_authentication_args
,
7497 ip_ospf_authentication_args_addr_cmd
,
7498 "ip ospf authentication <null|message-digest> [A.B.C.D]",
7500 "OSPF interface commands\n"
7501 "Enable authentication on this interface\n"
7502 "Use null authentication\n"
7503 "Use message-digest authentication\n"
7504 "Address of interface\n")
7506 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7507 int idx_encryption
= 3;
7509 struct in_addr addr
;
7511 struct ospf_if_params
*params
;
7513 params
= IF_DEF_PARAMS(ifp
);
7516 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7519 "Please specify interface address by A.B.C.D\n");
7520 return CMD_WARNING_CONFIG_FAILED
;
7523 params
= ospf_get_if_params(ifp
, addr
);
7524 ospf_if_update_params(ifp
, addr
);
7527 /* Handle null authentication */
7528 if (argv
[idx_encryption
]->arg
[0] == 'n') {
7529 SET_IF_PARAM(params
, auth_type
);
7530 params
->auth_type
= OSPF_AUTH_NULL
;
7534 /* Handle message-digest authentication */
7535 if (argv
[idx_encryption
]->arg
[0] == 'm') {
7536 SET_IF_PARAM(params
, auth_type
);
7537 params
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
7541 vty_out(vty
, "You shouldn't get here!\n");
7542 return CMD_WARNING_CONFIG_FAILED
;
7545 DEFUN (ip_ospf_authentication
,
7546 ip_ospf_authentication_addr_cmd
,
7547 "ip ospf authentication [A.B.C.D]",
7549 "OSPF interface commands\n"
7550 "Enable authentication on this interface\n"
7551 "Address of interface\n")
7553 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7555 struct in_addr addr
;
7557 struct ospf_if_params
*params
;
7559 params
= IF_DEF_PARAMS(ifp
);
7562 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7565 "Please specify interface address by A.B.C.D\n");
7566 return CMD_WARNING_CONFIG_FAILED
;
7569 params
= ospf_get_if_params(ifp
, addr
);
7570 ospf_if_update_params(ifp
, addr
);
7573 SET_IF_PARAM(params
, auth_type
);
7574 params
->auth_type
= OSPF_AUTH_SIMPLE
;
7579 DEFUN (no_ip_ospf_authentication_args
,
7580 no_ip_ospf_authentication_args_addr_cmd
,
7581 "no ip ospf authentication <null|message-digest> [A.B.C.D]",
7584 "OSPF interface commands\n"
7585 "Enable authentication on this interface\n"
7586 "Use null authentication\n"
7587 "Use message-digest authentication\n"
7588 "Address of interface\n")
7590 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7591 int idx_encryption
= 4;
7593 struct in_addr addr
;
7595 struct ospf_if_params
*params
;
7596 struct route_node
*rn
;
7599 params
= IF_DEF_PARAMS(ifp
);
7602 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7605 "Please specify interface address by A.B.C.D\n");
7606 return CMD_WARNING_CONFIG_FAILED
;
7609 params
= ospf_lookup_if_params(ifp
, addr
);
7610 if (params
== NULL
) {
7611 vty_out(vty
, "Ip Address specified is unknown\n");
7612 return CMD_WARNING_CONFIG_FAILED
;
7614 params
->auth_type
= OSPF_AUTH_NOTSET
;
7615 UNSET_IF_PARAM(params
, auth_type
);
7616 if (params
!= IF_DEF_PARAMS(ifp
)) {
7617 ospf_free_if_params(ifp
, addr
);
7618 ospf_if_update_params(ifp
, addr
);
7621 if (argv
[idx_encryption
]->arg
[0] == 'n') {
7622 auth_type
= OSPF_AUTH_NULL
;
7623 } else if (argv
[idx_encryption
]->arg
[0] == 'm') {
7624 auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
7626 vty_out(vty
, "Unexpected input encountered\n");
7627 return CMD_WARNING_CONFIG_FAILED
;
7630 * Here we have a case where the user has entered
7631 * 'no ip ospf authentication (null | message_digest )'
7632 * we need to find if we have any ip addresses underneath it
7634 * correspond to the associated type.
7636 if (params
->auth_type
== auth_type
) {
7637 params
->auth_type
= OSPF_AUTH_NOTSET
;
7638 UNSET_IF_PARAM(params
, auth_type
);
7641 for (rn
= route_top(IF_OIFS_PARAMS(ifp
)); rn
;
7642 rn
= route_next(rn
)) {
7643 if ((params
= rn
->info
)) {
7644 if (params
->auth_type
== auth_type
) {
7645 params
->auth_type
= OSPF_AUTH_NOTSET
;
7646 UNSET_IF_PARAM(params
, auth_type
);
7647 if (params
!= IF_DEF_PARAMS(ifp
)) {
7648 ospf_free_if_params(
7649 ifp
, rn
->p
.u
.prefix4
);
7650 ospf_if_update_params(
7651 ifp
, rn
->p
.u
.prefix4
);
7661 DEFUN (no_ip_ospf_authentication
,
7662 no_ip_ospf_authentication_addr_cmd
,
7663 "no ip ospf authentication [A.B.C.D]",
7666 "OSPF interface commands\n"
7667 "Enable authentication on this interface\n"
7668 "Address of interface\n")
7670 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7672 struct in_addr addr
;
7674 struct ospf_if_params
*params
;
7675 struct route_node
*rn
;
7677 params
= IF_DEF_PARAMS(ifp
);
7680 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7683 "Please specify interface address by A.B.C.D\n");
7684 return CMD_WARNING_CONFIG_FAILED
;
7687 params
= ospf_lookup_if_params(ifp
, addr
);
7688 if (params
== NULL
) {
7689 vty_out(vty
, "Ip Address specified is unknown\n");
7690 return CMD_WARNING_CONFIG_FAILED
;
7693 params
->auth_type
= OSPF_AUTH_NOTSET
;
7694 UNSET_IF_PARAM(params
, auth_type
);
7695 if (params
!= IF_DEF_PARAMS(ifp
)) {
7696 ospf_free_if_params(ifp
, addr
);
7697 ospf_if_update_params(ifp
, addr
);
7701 * When a user enters 'no ip ospf authentication'
7702 * We should remove all authentication types from
7705 if ((params
->auth_type
== OSPF_AUTH_NULL
)
7706 || (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
7707 || (params
->auth_type
== OSPF_AUTH_SIMPLE
)) {
7708 params
->auth_type
= OSPF_AUTH_NOTSET
;
7709 UNSET_IF_PARAM(params
, auth_type
);
7712 for (rn
= route_top(IF_OIFS_PARAMS(ifp
)); rn
;
7713 rn
= route_next(rn
)) {
7714 if ((params
= rn
->info
)) {
7716 if ((params
->auth_type
== OSPF_AUTH_NULL
)
7717 || (params
->auth_type
7718 == OSPF_AUTH_CRYPTOGRAPHIC
)
7719 || (params
->auth_type
7720 == OSPF_AUTH_SIMPLE
)) {
7721 params
->auth_type
= OSPF_AUTH_NOTSET
;
7722 UNSET_IF_PARAM(params
, auth_type
);
7723 if (params
!= IF_DEF_PARAMS(ifp
)) {
7724 ospf_free_if_params(
7725 ifp
, rn
->p
.u
.prefix4
);
7726 ospf_if_update_params(
7727 ifp
, rn
->p
.u
.prefix4
);
7738 DEFUN (ip_ospf_authentication_key
,
7739 ip_ospf_authentication_key_addr_cmd
,
7740 "ip ospf authentication-key AUTH_KEY [A.B.C.D]",
7742 "OSPF interface commands\n"
7743 "Authentication password (key)\n"
7744 "The OSPF password (key)\n"
7745 "Address of interface\n")
7747 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7749 struct in_addr addr
;
7750 struct ospf_if_params
*params
;
7752 params
= IF_DEF_PARAMS(ifp
);
7754 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7755 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7757 "Please specify interface address by A.B.C.D\n");
7758 return CMD_WARNING_CONFIG_FAILED
;
7761 params
= ospf_get_if_params(ifp
, addr
);
7762 ospf_if_update_params(ifp
, addr
);
7765 strlcpy((char *)params
->auth_simple
, argv
[3]->arg
,
7766 sizeof(params
->auth_simple
));
7767 SET_IF_PARAM(params
, auth_simple
);
7772 DEFUN_HIDDEN (ospf_authentication_key
,
7773 ospf_authentication_key_cmd
,
7774 "ospf authentication-key AUTH_KEY [A.B.C.D]",
7775 "OSPF interface commands\n"
7776 VLINK_HELPSTR_AUTH_SIMPLE
7777 "Address of interface\n")
7779 return ip_ospf_authentication_key(self
, vty
, argc
, argv
);
7782 DEFUN (no_ip_ospf_authentication_key
,
7783 no_ip_ospf_authentication_key_authkey_addr_cmd
,
7784 "no ip ospf authentication-key [AUTH_KEY [A.B.C.D]]",
7787 "OSPF interface commands\n"
7788 VLINK_HELPSTR_AUTH_SIMPLE
7789 "Address of interface\n")
7791 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7793 struct in_addr addr
;
7794 struct ospf_if_params
*params
;
7795 params
= IF_DEF_PARAMS(ifp
);
7797 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7798 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7800 "Please specify interface address by A.B.C.D\n");
7801 return CMD_WARNING_CONFIG_FAILED
;
7804 params
= ospf_lookup_if_params(ifp
, addr
);
7809 memset(params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
);
7810 UNSET_IF_PARAM(params
, auth_simple
);
7812 if (params
!= IF_DEF_PARAMS(ifp
)) {
7813 ospf_free_if_params(ifp
, addr
);
7814 ospf_if_update_params(ifp
, addr
);
7820 DEFUN_HIDDEN (no_ospf_authentication_key
,
7821 no_ospf_authentication_key_authkey_addr_cmd
,
7822 "no ospf authentication-key [AUTH_KEY [A.B.C.D]]",
7824 "OSPF interface commands\n"
7825 VLINK_HELPSTR_AUTH_SIMPLE
7826 "Address of interface\n")
7828 return no_ip_ospf_authentication_key(self
, vty
, argc
, argv
);
7831 DEFUN (ip_ospf_message_digest_key
,
7832 ip_ospf_message_digest_key_cmd
,
7833 "ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
7835 "OSPF interface commands\n"
7836 "Message digest authentication password (key)\n"
7838 "Use MD5 algorithm\n"
7839 "The OSPF password (key)\n"
7840 "Address of interface\n")
7842 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7843 struct crypt_key
*ck
;
7845 struct in_addr addr
;
7846 struct ospf_if_params
*params
;
7848 params
= IF_DEF_PARAMS(ifp
);
7851 argv_find(argv
, argc
, "(1-255)", &idx
);
7852 char *keyid
= argv
[idx
]->arg
;
7853 argv_find(argv
, argc
, "KEY", &idx
);
7854 char *cryptkey
= argv
[idx
]->arg
;
7856 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7857 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7859 "Please specify interface address by A.B.C.D\n");
7860 return CMD_WARNING_CONFIG_FAILED
;
7863 params
= ospf_get_if_params(ifp
, addr
);
7864 ospf_if_update_params(ifp
, addr
);
7867 key_id
= strtol(keyid
, NULL
, 10);
7869 /* Remove existing key, if any */
7870 ospf_crypt_key_delete(params
->auth_crypt
, key_id
);
7872 ck
= ospf_crypt_key_new();
7873 ck
->key_id
= (uint8_t)key_id
;
7874 strlcpy((char *)ck
->auth_key
, cryptkey
, sizeof(ck
->auth_key
));
7876 ospf_crypt_key_add(params
->auth_crypt
, ck
);
7877 SET_IF_PARAM(params
, auth_crypt
);
7882 DEFUN_HIDDEN (ospf_message_digest_key
,
7883 ospf_message_digest_key_cmd
,
7884 "ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
7885 "OSPF interface commands\n"
7886 "Message digest authentication password (key)\n"
7888 "Use MD5 algorithm\n"
7889 "The OSPF password (key)\n"
7890 "Address of interface\n")
7892 return ip_ospf_message_digest_key(self
, vty
, argc
, argv
);
7895 DEFUN (no_ip_ospf_message_digest_key
,
7896 no_ip_ospf_message_digest_key_cmd
,
7897 "no ip ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
7900 "OSPF interface commands\n"
7901 "Message digest authentication password (key)\n"
7903 "Use MD5 algorithm\n"
7904 "The OSPF password (key)\n"
7905 "Address of interface\n")
7907 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7909 struct crypt_key
*ck
;
7911 struct in_addr addr
;
7912 struct ospf_if_params
*params
;
7913 params
= IF_DEF_PARAMS(ifp
);
7915 argv_find(argv
, argc
, "(1-255)", &idx
);
7916 char *keyid
= argv
[idx
]->arg
;
7918 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7919 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7921 "Please specify interface address by A.B.C.D\n");
7922 return CMD_WARNING_CONFIG_FAILED
;
7925 params
= ospf_lookup_if_params(ifp
, addr
);
7930 key_id
= strtol(keyid
, NULL
, 10);
7931 ck
= ospf_crypt_key_lookup(params
->auth_crypt
, key_id
);
7933 vty_out(vty
, "OSPF: Key %d does not exist\n", key_id
);
7934 return CMD_WARNING_CONFIG_FAILED
;
7937 ospf_crypt_key_delete(params
->auth_crypt
, key_id
);
7939 if (params
!= IF_DEF_PARAMS(ifp
)) {
7940 ospf_free_if_params(ifp
, addr
);
7941 ospf_if_update_params(ifp
, addr
);
7947 DEFUN_HIDDEN (no_ospf_message_digest_key
,
7948 no_ospf_message_digest_key_cmd
,
7949 "no ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
7951 "OSPF interface commands\n"
7952 "Message digest authentication password (key)\n"
7954 "Use MD5 algorithm\n"
7955 "The OSPF password (key)\n"
7956 "Address of interface\n")
7958 return no_ip_ospf_message_digest_key(self
, vty
, argc
, argv
);
7961 DEFUN (ip_ospf_cost
,
7963 "ip ospf cost (1-65535) [A.B.C.D]",
7965 "OSPF interface commands\n"
7968 "Address of interface\n")
7970 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7972 uint32_t cost
= OSPF_OUTPUT_COST_DEFAULT
;
7973 struct in_addr addr
;
7974 struct ospf_if_params
*params
;
7975 params
= IF_DEF_PARAMS(ifp
);
7978 char *coststr
= NULL
, *ifaddr
= NULL
;
7980 argv_find(argv
, argc
, "(1-65535)", &idx
);
7981 coststr
= argv
[idx
]->arg
;
7982 cost
= strtol(coststr
, NULL
, 10);
7984 ifaddr
= argv_find(argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
7986 if (!inet_aton(ifaddr
, &addr
)) {
7988 "Please specify interface address by A.B.C.D\n");
7989 return CMD_WARNING_CONFIG_FAILED
;
7992 params
= ospf_get_if_params(ifp
, addr
);
7993 ospf_if_update_params(ifp
, addr
);
7996 SET_IF_PARAM(params
, output_cost_cmd
);
7997 params
->output_cost_cmd
= cost
;
7999 ospf_if_recalculate_output_cost(ifp
);
8004 DEFUN_HIDDEN (ospf_cost
,
8006 "ospf cost (1-65535) [A.B.C.D]",
8007 "OSPF interface commands\n"
8010 "Address of interface\n")
8012 return ip_ospf_cost(self
, vty
, argc
, argv
);
8015 DEFUN (no_ip_ospf_cost
,
8016 no_ip_ospf_cost_cmd
,
8017 "no ip ospf cost [(1-65535)] [A.B.C.D]",
8020 "OSPF interface commands\n"
8023 "Address of interface\n")
8025 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8027 struct in_addr addr
;
8028 struct ospf_if_params
*params
;
8030 params
= IF_DEF_PARAMS(ifp
);
8033 char *ifaddr
= NULL
;
8034 ifaddr
= argv_find(argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
8036 /* According to the semantics we are mimicking "no ip ospf cost N" is
8037 * always treated as "no ip ospf cost" regardless of the actual value
8038 * of N already configured for the interface. Thus ignore cost. */
8041 if (!inet_aton(ifaddr
, &addr
)) {
8043 "Please specify interface address by A.B.C.D\n");
8044 return CMD_WARNING_CONFIG_FAILED
;
8047 params
= ospf_lookup_if_params(ifp
, addr
);
8052 UNSET_IF_PARAM(params
, output_cost_cmd
);
8054 if (params
!= IF_DEF_PARAMS(ifp
)) {
8055 ospf_free_if_params(ifp
, addr
);
8056 ospf_if_update_params(ifp
, addr
);
8059 ospf_if_recalculate_output_cost(ifp
);
8064 DEFUN_HIDDEN (no_ospf_cost
,
8066 "no ospf cost [(1-65535)] [A.B.C.D]",
8068 "OSPF interface commands\n"
8071 "Address of interface\n")
8073 return no_ip_ospf_cost(self
, vty
, argc
, argv
);
8076 static void ospf_nbr_timer_update(struct ospf_interface
*oi
)
8078 struct route_node
*rn
;
8079 struct ospf_neighbor
*nbr
;
8081 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
))
8082 if ((nbr
= rn
->info
)) {
8083 nbr
->v_inactivity
= OSPF_IF_PARAM(oi
, v_wait
);
8084 nbr
->v_db_desc
= OSPF_IF_PARAM(oi
, retransmit_interval
);
8085 nbr
->v_ls_req
= OSPF_IF_PARAM(oi
, retransmit_interval
);
8086 nbr
->v_ls_upd
= OSPF_IF_PARAM(oi
, retransmit_interval
);
8090 static int ospf_vty_dead_interval_set(struct vty
*vty
, const char *interval_str
,
8091 const char *nbr_str
,
8092 const char *fast_hello_str
)
8094 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8097 struct in_addr addr
;
8099 struct ospf_if_params
*params
;
8100 struct ospf_interface
*oi
;
8101 struct route_node
*rn
;
8103 params
= IF_DEF_PARAMS(ifp
);
8106 ret
= inet_aton(nbr_str
, &addr
);
8109 "Please specify interface address by A.B.C.D\n");
8110 return CMD_WARNING_CONFIG_FAILED
;
8113 params
= ospf_get_if_params(ifp
, addr
);
8114 ospf_if_update_params(ifp
, addr
);
8118 seconds
= strtoul(interval_str
, NULL
, 10);
8120 /* reset fast_hello too, just to be sure */
8121 UNSET_IF_PARAM(params
, fast_hello
);
8122 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
8123 } else if (fast_hello_str
) {
8124 hellomult
= strtoul(fast_hello_str
, NULL
, 10);
8125 /* 1s dead-interval with sub-second hellos desired */
8126 seconds
= OSPF_ROUTER_DEAD_INTERVAL_MINIMAL
;
8127 SET_IF_PARAM(params
, fast_hello
);
8128 params
->fast_hello
= hellomult
;
8131 "Please specify dead-interval or hello-multiplier\n");
8132 return CMD_WARNING_CONFIG_FAILED
;
8135 SET_IF_PARAM(params
, v_wait
);
8136 params
->v_wait
= seconds
;
8137 params
->is_v_wait_set
= true;
8139 /* Update timer values in neighbor structure. */
8141 struct ospf
*ospf
= NULL
;
8143 ospf
= ospf_lookup_by_vrf_id(ifp
->vrf_id
);
8145 oi
= ospf_if_lookup_by_local_addr(ospf
, ifp
, addr
);
8147 ospf_nbr_timer_update(oi
);
8150 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
))
8151 if ((oi
= rn
->info
))
8152 ospf_nbr_timer_update(oi
);
8158 DEFUN (ip_ospf_dead_interval
,
8159 ip_ospf_dead_interval_cmd
,
8160 "ip ospf dead-interval (1-65535) [A.B.C.D]",
8162 "OSPF interface commands\n"
8163 "Interval time after which a neighbor is declared down\n"
8165 "Address of interface\n")
8168 char *interval
= argv_find(argv
, argc
, "(1-65535)", &idx
)
8172 argv_find(argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
8173 return ospf_vty_dead_interval_set(vty
, interval
, ifaddr
, NULL
);
8177 DEFUN_HIDDEN (ospf_dead_interval
,
8178 ospf_dead_interval_cmd
,
8179 "ospf dead-interval (1-65535) [A.B.C.D]",
8180 "OSPF interface commands\n"
8181 "Interval time after which a neighbor is declared down\n"
8183 "Address of interface\n")
8185 return ip_ospf_dead_interval(self
, vty
, argc
, argv
);
8188 DEFUN (ip_ospf_dead_interval_minimal
,
8189 ip_ospf_dead_interval_minimal_addr_cmd
,
8190 "ip ospf dead-interval minimal hello-multiplier (1-10) [A.B.C.D]",
8192 "OSPF interface commands\n"
8193 "Interval time after which a neighbor is declared down\n"
8194 "Minimal 1s dead-interval with fast sub-second hellos\n"
8195 "Hello multiplier factor\n"
8196 "Number of Hellos to send each second\n"
8197 "Address of interface\n")
8202 return ospf_vty_dead_interval_set(
8203 vty
, NULL
, argv
[idx_ipv4
]->arg
, argv
[idx_number
]->arg
);
8205 return ospf_vty_dead_interval_set(vty
, NULL
, NULL
,
8206 argv
[idx_number
]->arg
);
8209 DEFUN (no_ip_ospf_dead_interval
,
8210 no_ip_ospf_dead_interval_cmd
,
8211 "no ip ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
8214 "OSPF interface commands\n"
8215 "Interval time after which a neighbor is declared down\n"
8217 "Minimal 1s dead-interval with fast sub-second hellos\n"
8218 "Hello multiplier factor\n"
8219 "Number of Hellos to send each second\n"
8220 "Address of interface\n")
8222 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8223 int idx_ipv4
= argc
- 1;
8224 struct in_addr addr
= {.s_addr
= 0L};
8226 struct ospf_if_params
*params
;
8227 struct ospf_interface
*oi
;
8228 struct route_node
*rn
;
8230 params
= IF_DEF_PARAMS(ifp
);
8232 if (argv
[idx_ipv4
]->type
== IPV4_TKN
) {
8233 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
8236 "Please specify interface address by A.B.C.D\n");
8237 return CMD_WARNING_CONFIG_FAILED
;
8240 params
= ospf_lookup_if_params(ifp
, addr
);
8245 UNSET_IF_PARAM(params
, v_wait
);
8246 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
8247 params
->is_v_wait_set
= false;
8249 UNSET_IF_PARAM(params
, fast_hello
);
8250 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
8252 if (params
!= IF_DEF_PARAMS(ifp
)) {
8253 ospf_free_if_params(ifp
, addr
);
8254 ospf_if_update_params(ifp
, addr
);
8257 /* Update timer values in neighbor structure. */
8259 struct ospf
*ospf
= NULL
;
8261 ospf
= ospf_lookup_by_vrf_id(ifp
->vrf_id
);
8263 oi
= ospf_if_lookup_by_local_addr(ospf
, ifp
, addr
);
8265 ospf_nbr_timer_update(oi
);
8268 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
))
8269 if ((oi
= rn
->info
))
8270 ospf_nbr_timer_update(oi
);
8276 DEFUN_HIDDEN (no_ospf_dead_interval
,
8277 no_ospf_dead_interval_cmd
,
8278 "no ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
8280 "OSPF interface commands\n"
8281 "Interval time after which a neighbor is declared down\n"
8283 "Minimal 1s dead-interval with fast sub-second hellos\n"
8284 "Hello multiplier factor\n"
8285 "Number of Hellos to send each second\n"
8286 "Address of interface\n")
8288 return no_ip_ospf_dead_interval(self
, vty
, argc
, argv
);
8291 DEFUN (ip_ospf_hello_interval
,
8292 ip_ospf_hello_interval_cmd
,
8293 "ip ospf hello-interval (1-65535) [A.B.C.D]",
8295 "OSPF interface commands\n"
8296 "Time between HELLO packets\n"
8298 "Address of interface\n")
8300 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8302 struct in_addr addr
;
8303 struct ospf_if_params
*params
;
8304 params
= IF_DEF_PARAMS(ifp
);
8305 uint32_t seconds
= 0;
8307 argv_find(argv
, argc
, "(1-65535)", &idx
);
8308 seconds
= strtol(argv
[idx
]->arg
, NULL
, 10);
8310 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
8311 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
8313 "Please specify interface address by A.B.C.D\n");
8314 return CMD_WARNING_CONFIG_FAILED
;
8317 params
= ospf_get_if_params(ifp
, addr
);
8318 ospf_if_update_params(ifp
, addr
);
8321 SET_IF_PARAM(params
, v_hello
);
8322 params
->v_hello
= seconds
;
8324 if (!params
->is_v_wait_set
) {
8325 SET_IF_PARAM(params
, v_wait
);
8327 * The router dead interval should
8328 * be some multiple of the HelloInterval (perhaps 4 times the
8329 * hello interval) and must be the same for all routers
8330 * attached to a common network.
8332 params
->v_wait
= 4 * seconds
;
8338 DEFUN_HIDDEN (ospf_hello_interval
,
8339 ospf_hello_interval_cmd
,
8340 "ospf hello-interval (1-65535) [A.B.C.D]",
8341 "OSPF interface commands\n"
8342 "Time between HELLO packets\n"
8344 "Address of interface\n")
8346 return ip_ospf_hello_interval(self
, vty
, argc
, argv
);
8349 DEFUN (no_ip_ospf_hello_interval
,
8350 no_ip_ospf_hello_interval_cmd
,
8351 "no ip ospf hello-interval [(1-65535) [A.B.C.D]]",
8354 "OSPF interface commands\n"
8355 "Time between HELLO packets\n" // ignored
8357 "Address of interface\n")
8359 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8361 struct in_addr addr
;
8362 struct ospf_if_params
*params
;
8363 struct route_node
*rn
;
8365 params
= IF_DEF_PARAMS(ifp
);
8367 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
8368 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
8370 "Please specify interface address by A.B.C.D\n");
8371 return CMD_WARNING_CONFIG_FAILED
;
8374 params
= ospf_lookup_if_params(ifp
, addr
);
8379 UNSET_IF_PARAM(params
, v_hello
);
8380 params
->v_hello
= OSPF_HELLO_INTERVAL_DEFAULT
;
8382 if (!params
->is_v_wait_set
) {
8383 UNSET_IF_PARAM(params
, v_wait
);
8384 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
8387 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
8388 struct ospf_interface
*oi
= rn
->info
;
8393 oi
->type
= IF_DEF_PARAMS(ifp
)->type
;
8394 oi
->ptp_dmvpn
= IF_DEF_PARAMS(ifp
)->ptp_dmvpn
;
8396 if (oi
->state
> ISM_Down
) {
8397 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceDown
);
8398 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceUp
);
8402 if (params
!= IF_DEF_PARAMS(ifp
)) {
8403 ospf_free_if_params(ifp
, addr
);
8404 ospf_if_update_params(ifp
, addr
);
8410 DEFUN_HIDDEN (no_ospf_hello_interval
,
8411 no_ospf_hello_interval_cmd
,
8412 "no ospf hello-interval [(1-65535) [A.B.C.D]]",
8414 "OSPF interface commands\n"
8415 "Time between HELLO packets\n" // ignored
8417 "Address of interface\n")
8419 return no_ip_ospf_hello_interval(self
, vty
, argc
, argv
);
8422 DEFUN(ip_ospf_network
, ip_ospf_network_cmd
,
8423 "ip ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point [dmvpn]>",
8425 "OSPF interface commands\n"
8427 "Specify OSPF broadcast multi-access network\n"
8428 "Specify OSPF NBMA network\n"
8429 "Specify OSPF point-to-multipoint network\n"
8430 "Specify OSPF point-to-point network\n"
8431 "Specify OSPF point-to-point DMVPN network\n")
8433 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8435 int old_type
= IF_DEF_PARAMS(ifp
)->type
;
8436 uint8_t old_ptp_dmvpn
= IF_DEF_PARAMS(ifp
)->ptp_dmvpn
;
8437 struct route_node
*rn
;
8439 if (old_type
== OSPF_IFTYPE_LOOPBACK
) {
8441 "This is a loopback interface. Can't set network type.\n");
8442 return CMD_WARNING_CONFIG_FAILED
;
8445 IF_DEF_PARAMS(ifp
)->ptp_dmvpn
= 0;
8447 if (argv_find(argv
, argc
, "broadcast", &idx
))
8448 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_BROADCAST
;
8449 else if (argv_find(argv
, argc
, "non-broadcast", &idx
))
8450 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_NBMA
;
8451 else if (argv_find(argv
, argc
, "point-to-multipoint", &idx
))
8452 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_POINTOMULTIPOINT
;
8453 else if (argv_find(argv
, argc
, "point-to-point", &idx
)) {
8454 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_POINTOPOINT
;
8455 if (argv_find(argv
, argc
, "dmvpn", &idx
))
8456 IF_DEF_PARAMS(ifp
)->ptp_dmvpn
= 1;
8459 if (IF_DEF_PARAMS(ifp
)->type
== old_type
8460 && IF_DEF_PARAMS(ifp
)->ptp_dmvpn
== old_ptp_dmvpn
)
8463 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), type
);
8465 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
8466 struct ospf_interface
*oi
= rn
->info
;
8471 oi
->type
= IF_DEF_PARAMS(ifp
)->type
;
8473 if (oi
->state
> ISM_Down
) {
8474 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceDown
);
8475 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceUp
);
8482 DEFUN_HIDDEN (ospf_network
,
8484 "ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
8485 "OSPF interface commands\n"
8487 "Specify OSPF broadcast multi-access network\n"
8488 "Specify OSPF NBMA network\n"
8489 "Specify OSPF point-to-multipoint network\n"
8490 "Specify OSPF point-to-point network\n")
8492 return ip_ospf_network(self
, vty
, argc
, argv
);
8495 DEFUN (no_ip_ospf_network
,
8496 no_ip_ospf_network_cmd
,
8497 "no ip ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
8500 "OSPF interface commands\n"
8502 "Specify OSPF broadcast multi-access network\n"
8503 "Specify OSPF NBMA network\n"
8504 "Specify OSPF point-to-multipoint network\n"
8505 "Specify OSPF point-to-point network\n")
8507 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8508 int old_type
= IF_DEF_PARAMS(ifp
)->type
;
8509 struct route_node
*rn
;
8511 IF_DEF_PARAMS(ifp
)->type
= ospf_default_iftype(ifp
);
8512 IF_DEF_PARAMS(ifp
)->ptp_dmvpn
= 0;
8514 if (IF_DEF_PARAMS(ifp
)->type
== old_type
)
8517 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
8518 struct ospf_interface
*oi
= rn
->info
;
8523 oi
->type
= IF_DEF_PARAMS(ifp
)->type
;
8525 if (oi
->state
> ISM_Down
) {
8526 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceDown
);
8527 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceUp
);
8534 DEFUN_HIDDEN (no_ospf_network
,
8535 no_ospf_network_cmd
,
8536 "no ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
8538 "OSPF interface commands\n"
8540 "Specify OSPF broadcast multi-access network\n"
8541 "Specify OSPF NBMA network\n"
8542 "Specify OSPF point-to-multipoint network\n"
8543 "Specify OSPF point-to-point network\n")
8545 return no_ip_ospf_network(self
, vty
, argc
, argv
);
8548 DEFUN (ip_ospf_priority
,
8549 ip_ospf_priority_cmd
,
8550 "ip ospf priority (0-255) [A.B.C.D]",
8552 "OSPF interface commands\n"
8555 "Address of interface\n")
8557 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8560 struct route_node
*rn
;
8561 struct in_addr addr
;
8562 struct ospf_if_params
*params
;
8563 params
= IF_DEF_PARAMS(ifp
);
8565 argv_find(argv
, argc
, "(0-255)", &idx
);
8566 priority
= strtol(argv
[idx
]->arg
, NULL
, 10);
8568 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
8569 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
8571 "Please specify interface address by A.B.C.D\n");
8572 return CMD_WARNING_CONFIG_FAILED
;
8575 params
= ospf_get_if_params(ifp
, addr
);
8576 ospf_if_update_params(ifp
, addr
);
8579 SET_IF_PARAM(params
, priority
);
8580 params
->priority
= priority
;
8582 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
8583 struct ospf_interface
*oi
= rn
->info
;
8588 if (PRIORITY(oi
) != OSPF_IF_PARAM(oi
, priority
)) {
8589 PRIORITY(oi
) = OSPF_IF_PARAM(oi
, priority
);
8590 OSPF_ISM_EVENT_SCHEDULE(oi
, ISM_NeighborChange
);
8597 DEFUN_HIDDEN (ospf_priority
,
8599 "ospf priority (0-255) [A.B.C.D]",
8600 "OSPF interface commands\n"
8603 "Address of interface\n")
8605 return ip_ospf_priority(self
, vty
, argc
, argv
);
8608 DEFUN (no_ip_ospf_priority
,
8609 no_ip_ospf_priority_cmd
,
8610 "no ip ospf priority [(0-255) [A.B.C.D]]",
8613 "OSPF interface commands\n"
8614 "Router priority\n" // ignored
8616 "Address of interface\n")
8618 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8620 struct route_node
*rn
;
8621 struct in_addr addr
;
8622 struct ospf_if_params
*params
;
8624 params
= IF_DEF_PARAMS(ifp
);
8626 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
8627 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
8629 "Please specify interface address by A.B.C.D\n");
8630 return CMD_WARNING_CONFIG_FAILED
;
8633 params
= ospf_lookup_if_params(ifp
, addr
);
8638 UNSET_IF_PARAM(params
, priority
);
8639 params
->priority
= OSPF_ROUTER_PRIORITY_DEFAULT
;
8641 if (params
!= IF_DEF_PARAMS(ifp
)) {
8642 ospf_free_if_params(ifp
, addr
);
8643 ospf_if_update_params(ifp
, addr
);
8646 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
8647 struct ospf_interface
*oi
= rn
->info
;
8652 if (PRIORITY(oi
) != OSPF_IF_PARAM(oi
, priority
)) {
8653 PRIORITY(oi
) = OSPF_IF_PARAM(oi
, priority
);
8654 OSPF_ISM_EVENT_SCHEDULE(oi
, ISM_NeighborChange
);
8661 DEFUN_HIDDEN (no_ospf_priority
,
8662 no_ospf_priority_cmd
,
8663 "no ospf priority [(0-255) [A.B.C.D]]",
8665 "OSPF interface commands\n"
8668 "Address of interface\n")
8670 return no_ip_ospf_priority(self
, vty
, argc
, argv
);
8673 DEFUN (ip_ospf_retransmit_interval
,
8674 ip_ospf_retransmit_interval_addr_cmd
,
8675 "ip ospf retransmit-interval (1-65535) [A.B.C.D]",
8677 "OSPF interface commands\n"
8678 "Time between retransmitting lost link state advertisements\n"
8680 "Address of interface\n")
8682 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8685 struct in_addr addr
;
8686 struct ospf_if_params
*params
;
8687 params
= IF_DEF_PARAMS(ifp
);
8689 argv_find(argv
, argc
, "(1-65535)", &idx
);
8690 seconds
= strtol(argv
[idx
]->arg
, NULL
, 10);
8692 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
8693 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
8695 "Please specify interface address by A.B.C.D\n");
8696 return CMD_WARNING_CONFIG_FAILED
;
8699 params
= ospf_get_if_params(ifp
, addr
);
8700 ospf_if_update_params(ifp
, addr
);
8703 SET_IF_PARAM(params
, retransmit_interval
);
8704 params
->retransmit_interval
= seconds
;
8709 DEFUN_HIDDEN (ospf_retransmit_interval
,
8710 ospf_retransmit_interval_cmd
,
8711 "ospf retransmit-interval (1-65535) [A.B.C.D]",
8712 "OSPF interface commands\n"
8713 "Time between retransmitting lost link state advertisements\n"
8715 "Address of interface\n")
8717 return ip_ospf_retransmit_interval(self
, vty
, argc
, argv
);
8720 DEFUN (no_ip_ospf_retransmit_interval
,
8721 no_ip_ospf_retransmit_interval_addr_cmd
,
8722 "no ip ospf retransmit-interval [(1-65535)] [A.B.C.D]",
8725 "OSPF interface commands\n"
8726 "Time between retransmitting lost link state advertisements\n"
8728 "Address of interface\n")
8730 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8732 struct in_addr addr
;
8733 struct ospf_if_params
*params
;
8735 params
= IF_DEF_PARAMS(ifp
);
8737 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
8738 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
8740 "Please specify interface address by A.B.C.D\n");
8741 return CMD_WARNING_CONFIG_FAILED
;
8744 params
= ospf_lookup_if_params(ifp
, addr
);
8749 UNSET_IF_PARAM(params
, retransmit_interval
);
8750 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
8752 if (params
!= IF_DEF_PARAMS(ifp
)) {
8753 ospf_free_if_params(ifp
, addr
);
8754 ospf_if_update_params(ifp
, addr
);
8760 DEFUN_HIDDEN (no_ospf_retransmit_interval
,
8761 no_ospf_retransmit_interval_cmd
,
8762 "no ospf retransmit-interval [(1-65535)] [A.B.C.D]",
8764 "OSPF interface commands\n"
8765 "Time between retransmitting lost link state advertisements\n"
8767 "Address of interface\n")
8769 return no_ip_ospf_retransmit_interval(self
, vty
, argc
, argv
);
8772 DEFUN (ip_ospf_transmit_delay
,
8773 ip_ospf_transmit_delay_addr_cmd
,
8774 "ip ospf transmit-delay (1-65535) [A.B.C.D]",
8776 "OSPF interface commands\n"
8777 "Link state transmit delay\n"
8779 "Address of interface\n")
8781 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8784 struct in_addr addr
;
8785 struct ospf_if_params
*params
;
8787 params
= IF_DEF_PARAMS(ifp
);
8788 argv_find(argv
, argc
, "(1-65535)", &idx
);
8789 seconds
= strtol(argv
[idx
]->arg
, NULL
, 10);
8791 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
8792 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
8794 "Please specify interface address by A.B.C.D\n");
8795 return CMD_WARNING_CONFIG_FAILED
;
8798 params
= ospf_get_if_params(ifp
, addr
);
8799 ospf_if_update_params(ifp
, addr
);
8802 SET_IF_PARAM(params
, transmit_delay
);
8803 params
->transmit_delay
= seconds
;
8808 DEFUN_HIDDEN (ospf_transmit_delay
,
8809 ospf_transmit_delay_cmd
,
8810 "ospf transmit-delay (1-65535) [A.B.C.D]",
8811 "OSPF interface commands\n"
8812 "Link state transmit delay\n"
8814 "Address of interface\n")
8816 return ip_ospf_transmit_delay(self
, vty
, argc
, argv
);
8819 DEFUN (no_ip_ospf_transmit_delay
,
8820 no_ip_ospf_transmit_delay_addr_cmd
,
8821 "no ip ospf transmit-delay [(1-65535)] [A.B.C.D]",
8824 "OSPF interface commands\n"
8825 "Link state transmit delay\n"
8827 "Address of interface\n")
8829 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8831 struct in_addr addr
;
8832 struct ospf_if_params
*params
;
8834 params
= IF_DEF_PARAMS(ifp
);
8836 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
8837 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
8839 "Please specify interface address by A.B.C.D\n");
8840 return CMD_WARNING_CONFIG_FAILED
;
8843 params
= ospf_lookup_if_params(ifp
, addr
);
8848 UNSET_IF_PARAM(params
, transmit_delay
);
8849 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
8851 if (params
!= IF_DEF_PARAMS(ifp
)) {
8852 ospf_free_if_params(ifp
, addr
);
8853 ospf_if_update_params(ifp
, addr
);
8860 DEFUN_HIDDEN (no_ospf_transmit_delay
,
8861 no_ospf_transmit_delay_cmd
,
8862 "no ospf transmit-delay [(1-65535) [A.B.C.D]]",
8864 "OSPF interface commands\n"
8865 "Link state transmit delay\n"
8867 "Address of interface\n")
8869 return no_ip_ospf_transmit_delay(self
, vty
, argc
, argv
);
8872 DEFUN (ip_ospf_area
,
8874 "ip ospf [(1-65535)] area <A.B.C.D|(0-4294967295)> [A.B.C.D]",
8876 "OSPF interface commands\n"
8878 "Enable OSPF on this interface\n"
8879 "OSPF area ID in IP address format\n"
8880 "OSPF area ID as a decimal value\n"
8881 "Address of interface\n")
8883 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8886 struct in_addr area_id
;
8887 struct in_addr addr
;
8888 struct ospf_if_params
*params
= NULL
;
8889 struct route_node
*rn
;
8890 struct ospf
*ospf
= NULL
;
8891 unsigned short instance
= 0;
8895 if (argv_find(argv
, argc
, "(1-65535)", &idx
))
8896 instance
= strtol(argv
[idx
]->arg
, NULL
, 10);
8898 argv_find(argv
, argc
, "area", &idx
);
8899 areaid
= argv
[idx
+ 1]->arg
;
8901 if (ifp
->vrf_id
&& !instance
)
8902 ospf
= ospf_lookup_by_vrf_id(ifp
->vrf_id
);
8904 ospf
= ospf_lookup_instance(instance
);
8906 if (instance
&& instance
!= ospf_instance
) {
8908 * At this point we know we have received
8909 * an instance and there is no ospf instance
8910 * associated with it. This means we are
8911 * in a situation where we have an
8912 * ospf command that is setup for a different
8913 * process(instance). We need to safely
8914 * remove the command from ourselves and
8915 * allow the other instance(process) handle
8916 * the configuration command.
8920 params
= IF_DEF_PARAMS(ifp
);
8921 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
8922 UNSET_IF_PARAM(params
, if_area
);
8926 for (rn
= route_top(IF_OIFS_PARAMS(ifp
)); rn
; rn
= route_next(rn
))
8927 if ((params
= rn
->info
) && OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
8928 UNSET_IF_PARAM(params
, if_area
);
8933 ospf
= ospf_lookup_by_vrf_id(ifp
->vrf_id
);
8935 ospf_interface_area_unset(ospf
, ifp
);
8938 return CMD_NOT_MY_INSTANCE
;
8941 ret
= str2area_id(areaid
, &area_id
, &format
);
8943 vty_out(vty
, "Please specify area by A.B.C.D|<0-4294967295>\n");
8944 return CMD_WARNING_CONFIG_FAILED
;
8946 if (memcmp(ifp
->name
, "VLINK", 5) == 0) {
8947 vty_out(vty
, "Cannot enable OSPF on a virtual link.\n");
8948 return CMD_WARNING_CONFIG_FAILED
;
8952 for (rn
= route_top(ospf
->networks
); rn
; rn
= route_next(rn
)) {
8953 if (rn
->info
!= NULL
) {
8955 "Please remove all network commands first.\n");
8956 return CMD_WARNING_CONFIG_FAILED
;
8961 params
= IF_DEF_PARAMS(ifp
);
8962 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)
8963 && !IPV4_ADDR_SAME(¶ms
->if_area
, &area_id
)) {
8965 "Must remove previous area config before changing ospf area \n");
8966 return CMD_WARNING_CONFIG_FAILED
;
8969 // Check if we have an address arg and proccess it
8970 if (argc
== idx
+ 3) {
8971 if (!inet_aton(argv
[idx
+ 2]->arg
, &addr
)) {
8973 "Please specify Intf Address by A.B.C.D\n");
8974 return CMD_WARNING_CONFIG_FAILED
;
8976 // update/create address-level params
8977 params
= ospf_get_if_params((ifp
), (addr
));
8978 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
8979 if (!IPV4_ADDR_SAME(¶ms
->if_area
, &area_id
)) {
8981 "Must remove previous area/address config before changing ospf area\n");
8982 return CMD_WARNING_CONFIG_FAILED
;
8986 ospf_if_update_params((ifp
), (addr
));
8989 /* enable ospf on this interface with area_id */
8991 SET_IF_PARAM(params
, if_area
);
8992 params
->if_area
= area_id
;
8993 params
->if_area_id_fmt
= format
;
8997 ospf_interface_area_set(ospf
, ifp
);
9002 DEFUN (no_ip_ospf_area
,
9003 no_ip_ospf_area_cmd
,
9004 "no ip ospf [(1-65535)] area [<A.B.C.D|(0-4294967295)> [A.B.C.D]]",
9007 "OSPF interface commands\n"
9009 "Disable OSPF on this interface\n"
9010 "OSPF area ID in IP address format\n"
9011 "OSPF area ID as a decimal value\n"
9012 "Address of interface\n")
9014 VTY_DECLVAR_CONTEXT(interface
, ifp
);
9017 struct ospf_if_params
*params
;
9018 unsigned short instance
= 0;
9019 struct in_addr addr
;
9020 struct in_addr area_id
;
9022 if (argv_find(argv
, argc
, "(1-65535)", &idx
))
9023 instance
= strtol(argv
[idx
]->arg
, NULL
, 10);
9025 if (ifp
->vrf_id
&& !instance
)
9026 ospf
= ospf_lookup_by_vrf_id(ifp
->vrf_id
);
9028 ospf
= ospf_lookup_instance(instance
);
9030 if (instance
&& instance
!= ospf_instance
)
9031 return CMD_NOT_MY_INSTANCE
;
9033 argv_find(argv
, argc
, "area", &idx
);
9035 // Check if we have an address arg and proccess it
9036 if (argc
== idx
+ 3) {
9037 if (!inet_aton(argv
[idx
+ 2]->arg
, &addr
)) {
9039 "Please specify Intf Address by A.B.C.D\n");
9040 return CMD_WARNING_CONFIG_FAILED
;
9042 params
= ospf_lookup_if_params(ifp
, addr
);
9043 if ((params
) == NULL
)
9046 params
= IF_DEF_PARAMS(ifp
);
9048 area_id
= params
->if_area
;
9049 if (!OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
9051 "Can't find specified interface area configuration.\n");
9052 return CMD_WARNING_CONFIG_FAILED
;
9055 UNSET_IF_PARAM(params
, if_area
);
9056 if (params
!= IF_DEF_PARAMS((ifp
))) {
9057 ospf_free_if_params((ifp
), (addr
));
9058 ospf_if_update_params((ifp
), (addr
));
9062 ospf_interface_area_unset(ospf
, ifp
);
9063 ospf_area_check_free(ospf
, area_id
);
9069 DEFUN (ospf_redistribute_source
,
9070 ospf_redistribute_source_cmd
,
9071 "redistribute " FRR_REDIST_STR_OSPFD
" [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
9073 FRR_REDIST_HELP_STR_OSPFD
9074 "Metric for redistributed routes\n"
9075 "OSPF default metric\n"
9076 "OSPF exterior metric type for redistributed routes\n"
9077 "Set OSPF External Type 1/2 metrics\n"
9078 "Route map reference\n"
9079 "Pointer to route-map entries\n")
9081 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9082 int idx_protocol
= 1;
9086 struct ospf_redist
*red
;
9089 /* Get distribute source. */
9090 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
9092 return CMD_WARNING_CONFIG_FAILED
;
9094 red
= ospf_redist_add(ospf
, source
, 0);
9096 /* Get metric value. */
9097 if (argv_find(argv
, argc
, "(0-16777214)", &idx
)) {
9098 if (!str2metric(argv
[idx
]->arg
, &metric
))
9099 return CMD_WARNING_CONFIG_FAILED
;
9102 /* Get metric type. */
9103 if (argv_find(argv
, argc
, "(1-2)", &idx
)) {
9104 if (!str2metric_type(argv
[idx
]->arg
, &type
))
9105 return CMD_WARNING_CONFIG_FAILED
;
9109 if (argv_find(argv
, argc
, "WORD", &idx
)) {
9110 ospf_routemap_set(red
, argv
[idx
]->arg
);
9112 ospf_routemap_unset(red
);
9114 return ospf_redistribute_set(ospf
, source
, 0, type
, metric
);
9117 DEFUN (no_ospf_redistribute_source
,
9118 no_ospf_redistribute_source_cmd
,
9119 "no redistribute " FRR_REDIST_STR_OSPFD
" [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
9122 FRR_REDIST_HELP_STR_OSPFD
9123 "Metric for redistributed routes\n"
9124 "OSPF default metric\n"
9125 "OSPF exterior metric type for redistributed routes\n"
9126 "Set OSPF External Type 1/2 metrics\n"
9127 "Route map reference\n"
9128 "Pointer to route-map entries\n")
9130 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9131 int idx_protocol
= 2;
9133 struct ospf_redist
*red
;
9135 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
9137 return CMD_WARNING_CONFIG_FAILED
;
9139 red
= ospf_redist_lookup(ospf
, source
, 0);
9143 ospf_routemap_unset(red
);
9144 ospf_redist_del(ospf
, source
, 0);
9146 return ospf_redistribute_unset(ospf
, source
, 0);
9149 DEFUN (ospf_redistribute_instance_source
,
9150 ospf_redistribute_instance_source_cmd
,
9151 "redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
9153 "Open Shortest Path First\n"
9154 "Non-main Kernel Routing Table\n"
9155 "Instance ID/Table ID\n"
9156 "Metric for redistributed routes\n"
9157 "OSPF default metric\n"
9158 "OSPF exterior metric type for redistributed routes\n"
9159 "Set OSPF External Type 1/2 metrics\n"
9160 "Route map reference\n"
9161 "Pointer to route-map entries\n")
9163 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9164 int idx_ospf_table
= 1;
9170 unsigned short instance
;
9171 struct ospf_redist
*red
;
9173 source
= proto_redistnum(AFI_IP
, argv
[idx_ospf_table
]->text
);
9176 vty_out(vty
, "Unknown instance redistribution\n");
9177 return CMD_WARNING_CONFIG_FAILED
;
9180 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
9182 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
) {
9184 "Instance redistribution in non-instanced OSPF not allowed\n");
9185 return CMD_WARNING_CONFIG_FAILED
;
9188 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
)) {
9189 vty_out(vty
, "Same instance OSPF redistribution not allowed\n");
9190 return CMD_WARNING_CONFIG_FAILED
;
9193 /* Get metric value. */
9194 if (argv_find(argv
, argc
, "metric", &idx
))
9195 if (!str2metric(argv
[idx
+ 1]->arg
, &metric
))
9196 return CMD_WARNING_CONFIG_FAILED
;
9199 /* Get metric type. */
9200 if (argv_find(argv
, argc
, "metric-type", &idx
))
9201 if (!str2metric_type(argv
[idx
+ 1]->arg
, &type
))
9202 return CMD_WARNING_CONFIG_FAILED
;
9204 red
= ospf_redist_add(ospf
, source
, instance
);
9207 if (argv_find(argv
, argc
, "route-map", &idx
))
9208 ospf_routemap_set(red
, argv
[idx
+ 1]->arg
);
9210 ospf_routemap_unset(red
);
9212 return ospf_redistribute_set(ospf
, source
, instance
, type
, metric
);
9215 DEFUN (no_ospf_redistribute_instance_source
,
9216 no_ospf_redistribute_instance_source_cmd
,
9217 "no redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
9220 "Open Shortest Path First\n"
9221 "Non-main Kernel Routing Table\n"
9222 "Instance ID/Table Id\n"
9223 "Metric for redistributed routes\n"
9224 "OSPF default metric\n"
9225 "OSPF exterior metric type for redistributed routes\n"
9226 "Set OSPF External Type 1/2 metrics\n"
9227 "Route map reference\n"
9228 "Pointer to route-map entries\n")
9230 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9231 int idx_ospf_table
= 2;
9233 unsigned int instance
;
9234 struct ospf_redist
*red
;
9237 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
9238 source
= ZEBRA_ROUTE_OSPF
;
9240 source
= ZEBRA_ROUTE_TABLE
;
9242 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
9244 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
) {
9246 "Instance redistribution in non-instanced OSPF not allowed\n");
9247 return CMD_WARNING_CONFIG_FAILED
;
9250 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
)) {
9251 vty_out(vty
, "Same instance OSPF redistribution not allowed\n");
9252 return CMD_WARNING_CONFIG_FAILED
;
9255 red
= ospf_redist_lookup(ospf
, source
, instance
);
9259 ospf_routemap_unset(red
);
9260 ospf_redist_del(ospf
, source
, instance
);
9262 return ospf_redistribute_unset(ospf
, source
, instance
);
9265 DEFUN (ospf_distribute_list_out
,
9266 ospf_distribute_list_out_cmd
,
9267 "distribute-list WORD out " FRR_REDIST_STR_OSPFD
,
9268 "Filter networks in routing updates\n"
9269 "Access-list name\n"
9271 FRR_REDIST_HELP_STR_OSPFD
)
9273 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9277 char *proto
= argv
[argc
- 1]->text
;
9279 /* Get distribute source. */
9280 source
= proto_redistnum(AFI_IP
, proto
);
9282 return CMD_WARNING_CONFIG_FAILED
;
9284 return ospf_distribute_list_out_set(ospf
, source
, argv
[idx_word
]->arg
);
9287 DEFUN (no_ospf_distribute_list_out
,
9288 no_ospf_distribute_list_out_cmd
,
9289 "no distribute-list WORD out " FRR_REDIST_STR_OSPFD
,
9291 "Filter networks in routing updates\n"
9292 "Access-list name\n"
9294 FRR_REDIST_HELP_STR_OSPFD
)
9296 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9300 char *proto
= argv
[argc
- 1]->text
;
9301 source
= proto_redistnum(AFI_IP
, proto
);
9303 return CMD_WARNING_CONFIG_FAILED
;
9305 return ospf_distribute_list_out_unset(ospf
, source
,
9306 argv
[idx_word
]->arg
);
9309 /* Default information originate. */
9310 DEFUN (ospf_default_information_originate
,
9311 ospf_default_information_originate_cmd
,
9312 "default-information originate [{always|metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
9313 "Control distribution of default information\n"
9314 "Distribute a default route\n"
9315 "Always advertise default route\n"
9316 "OSPF default metric\n"
9318 "OSPF metric type for default routes\n"
9319 "Set OSPF External Type 1/2 metrics\n"
9320 "Route map reference\n"
9321 "Pointer to route-map entries\n")
9323 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9324 int default_originate
= DEFAULT_ORIGINATE_ZEBRA
;
9327 struct ospf_redist
*red
;
9329 int cur_originate
= ospf
->default_originate
;
9333 red
= ospf_redist_add(ospf
, DEFAULT_ROUTE
, 0);
9335 /* Check whether "always" was specified */
9336 if (argv_find(argv
, argc
, "always", &idx
))
9337 default_originate
= DEFAULT_ORIGINATE_ALWAYS
;
9339 /* Get metric value */
9340 if (argv_find(argv
, argc
, "(0-16777214)", &idx
)) {
9341 if (!str2metric(argv
[idx
]->arg
, &metric
))
9342 return CMD_WARNING_CONFIG_FAILED
;
9345 /* Get metric type. */
9346 if (argv_find(argv
, argc
, "(1-2)", &idx
)) {
9347 if (!str2metric_type(argv
[idx
]->arg
, &type
))
9348 return CMD_WARNING_CONFIG_FAILED
;
9352 if (argv_find(argv
, argc
, "WORD", &idx
))
9353 rtmap
= argv
[idx
]->arg
;
9355 /* To check ,if user is providing same route map */
9356 if ((rtmap
== ROUTEMAP_NAME(red
)) ||
9357 (rtmap
&& ROUTEMAP_NAME(red
)
9358 && (strcmp(rtmap
, ROUTEMAP_NAME(red
)) == 0)))
9361 /* Don't allow if the same lsa is aleardy originated. */
9363 && (red
->dmetric
.type
== type
)
9364 && (red
->dmetric
.value
== metric
)
9365 && (cur_originate
== default_originate
))
9368 /* Updating Metric details */
9369 red
->dmetric
.type
= type
;
9370 red
->dmetric
.value
= metric
;
9372 /* updating route map details */
9374 ospf_routemap_set(red
, rtmap
);
9376 ospf_routemap_unset(red
);
9378 return ospf_redistribute_default_set(ospf
, default_originate
, type
,
9382 DEFUN (no_ospf_default_information_originate
,
9383 no_ospf_default_information_originate_cmd
,
9384 "no default-information originate [{always|metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
9386 "Control distribution of default information\n"
9387 "Distribute a default route\n"
9388 "Always advertise default route\n"
9389 "OSPF default metric\n"
9391 "OSPF metric type for default routes\n"
9392 "Set OSPF External Type 1/2 metrics\n"
9393 "Route map reference\n"
9394 "Pointer to route-map entries\n")
9396 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9397 struct ospf_redist
*red
;
9399 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
9403 ospf_routemap_unset(red
);
9404 ospf_redist_del(ospf
, DEFAULT_ROUTE
, 0);
9406 return ospf_redistribute_default_set(ospf
, DEFAULT_ORIGINATE_NONE
,
9410 DEFUN (ospf_default_metric
,
9411 ospf_default_metric_cmd
,
9412 "default-metric (0-16777214)",
9413 "Set metric of redistributed routes\n"
9416 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9420 if (!str2metric(argv
[idx_number
]->arg
, &metric
))
9421 return CMD_WARNING_CONFIG_FAILED
;
9423 ospf
->default_metric
= metric
;
9428 DEFUN (no_ospf_default_metric
,
9429 no_ospf_default_metric_cmd
,
9430 "no default-metric [(0-16777214)]",
9432 "Set metric of redistributed routes\n"
9435 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9437 ospf
->default_metric
= -1;
9443 DEFUN (ospf_distance
,
9446 "Administrative distance\n"
9447 "OSPF Administrative distance\n")
9449 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9452 ospf
->distance_all
= atoi(argv
[idx_number
]->arg
);
9457 DEFUN (no_ospf_distance
,
9458 no_ospf_distance_cmd
,
9459 "no distance (1-255)",
9461 "Administrative distance\n"
9462 "OSPF Administrative distance\n")
9464 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9466 ospf
->distance_all
= 0;
9471 DEFUN (no_ospf_distance_ospf
,
9472 no_ospf_distance_ospf_cmd
,
9473 "no distance ospf [{intra-area [(1-255)]|inter-area [(1-255)]|external [(1-255)]}]",
9475 "Administrative distance\n"
9476 "OSPF administrative distance\n"
9477 "Intra-area routes\n"
9478 "Distance for intra-area routes\n"
9479 "Inter-area routes\n"
9480 "Distance for inter-area routes\n"
9482 "Distance for external routes\n")
9484 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9487 if (argv_find(argv
, argc
, "intra-area", &idx
) || argc
== 3)
9488 idx
= ospf
->distance_intra
= 0;
9489 if (argv_find(argv
, argc
, "inter-area", &idx
) || argc
== 3)
9490 idx
= ospf
->distance_inter
= 0;
9491 if (argv_find(argv
, argc
, "external", &idx
) || argc
== 3)
9492 ospf
->distance_external
= 0;
9497 DEFUN (ospf_distance_ospf
,
9498 ospf_distance_ospf_cmd
,
9499 "distance ospf {intra-area (1-255)|inter-area (1-255)|external (1-255)}",
9500 "Administrative distance\n"
9501 "OSPF administrative distance\n"
9502 "Intra-area routes\n"
9503 "Distance for intra-area routes\n"
9504 "Inter-area routes\n"
9505 "Distance for inter-area routes\n"
9507 "Distance for external routes\n")
9509 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9512 ospf
->distance_intra
= 0;
9513 ospf
->distance_inter
= 0;
9514 ospf
->distance_external
= 0;
9516 if (argv_find(argv
, argc
, "intra-area", &idx
))
9517 ospf
->distance_intra
= atoi(argv
[idx
+ 1]->arg
);
9519 if (argv_find(argv
, argc
, "inter-area", &idx
))
9520 ospf
->distance_inter
= atoi(argv
[idx
+ 1]->arg
);
9522 if (argv_find(argv
, argc
, "external", &idx
))
9523 ospf
->distance_external
= atoi(argv
[idx
+ 1]->arg
);
9528 DEFUN (ip_ospf_mtu_ignore
,
9529 ip_ospf_mtu_ignore_addr_cmd
,
9530 "ip ospf mtu-ignore [A.B.C.D]",
9532 "OSPF interface commands\n"
9533 "Disable MTU mismatch detection on this interface\n"
9534 "Address of interface\n")
9536 VTY_DECLVAR_CONTEXT(interface
, ifp
);
9538 struct in_addr addr
;
9541 struct ospf_if_params
*params
;
9542 params
= IF_DEF_PARAMS(ifp
);
9545 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
9548 "Please specify interface address by A.B.C.D\n");
9549 return CMD_WARNING_CONFIG_FAILED
;
9551 params
= ospf_get_if_params(ifp
, addr
);
9552 ospf_if_update_params(ifp
, addr
);
9554 params
->mtu_ignore
= 1;
9555 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
9556 SET_IF_PARAM(params
, mtu_ignore
);
9558 UNSET_IF_PARAM(params
, mtu_ignore
);
9559 if (params
!= IF_DEF_PARAMS(ifp
)) {
9560 ospf_free_if_params(ifp
, addr
);
9561 ospf_if_update_params(ifp
, addr
);
9567 DEFUN (no_ip_ospf_mtu_ignore
,
9568 no_ip_ospf_mtu_ignore_addr_cmd
,
9569 "no ip ospf mtu-ignore [A.B.C.D]",
9572 "OSPF interface commands\n"
9573 "Disable MTU mismatch detection on this interface\n"
9574 "Address of interface\n")
9576 VTY_DECLVAR_CONTEXT(interface
, ifp
);
9578 struct in_addr addr
;
9581 struct ospf_if_params
*params
;
9582 params
= IF_DEF_PARAMS(ifp
);
9585 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
9588 "Please specify interface address by A.B.C.D\n");
9589 return CMD_WARNING_CONFIG_FAILED
;
9591 params
= ospf_get_if_params(ifp
, addr
);
9592 ospf_if_update_params(ifp
, addr
);
9594 params
->mtu_ignore
= 0;
9595 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
9596 SET_IF_PARAM(params
, mtu_ignore
);
9598 UNSET_IF_PARAM(params
, mtu_ignore
);
9599 if (params
!= IF_DEF_PARAMS(ifp
)) {
9600 ospf_free_if_params(ifp
, addr
);
9601 ospf_if_update_params(ifp
, addr
);
9608 DEFUN (ospf_max_metric_router_lsa_admin
,
9609 ospf_max_metric_router_lsa_admin_cmd
,
9610 "max-metric router-lsa administrative",
9611 "OSPF maximum / infinite-distance metric\n"
9612 "Advertise own Router-LSA with infinite distance (stub router)\n"
9613 "Administratively applied, for an indefinite period\n")
9615 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9616 struct listnode
*ln
;
9617 struct ospf_area
*area
;
9619 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
9620 SET_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
9622 if (!CHECK_FLAG(area
->stub_router_state
,
9623 OSPF_AREA_IS_STUB_ROUTED
))
9624 ospf_router_lsa_update_area(area
);
9627 /* Allows for areas configured later to get the property */
9628 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_SET
;
9633 DEFUN (no_ospf_max_metric_router_lsa_admin
,
9634 no_ospf_max_metric_router_lsa_admin_cmd
,
9635 "no max-metric router-lsa administrative",
9637 "OSPF maximum / infinite-distance metric\n"
9638 "Advertise own Router-LSA with infinite distance (stub router)\n"
9639 "Administratively applied, for an indefinite period\n")
9641 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9642 struct listnode
*ln
;
9643 struct ospf_area
*area
;
9645 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
9646 UNSET_FLAG(area
->stub_router_state
,
9647 OSPF_AREA_ADMIN_STUB_ROUTED
);
9649 /* Don't trample on the start-up stub timer */
9650 if (CHECK_FLAG(area
->stub_router_state
,
9651 OSPF_AREA_IS_STUB_ROUTED
)
9652 && !area
->t_stub_router
) {
9653 UNSET_FLAG(area
->stub_router_state
,
9654 OSPF_AREA_IS_STUB_ROUTED
);
9655 ospf_router_lsa_update_area(area
);
9658 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET
;
9662 DEFUN (ospf_max_metric_router_lsa_startup
,
9663 ospf_max_metric_router_lsa_startup_cmd
,
9664 "max-metric router-lsa on-startup (5-86400)",
9665 "OSPF maximum / infinite-distance metric\n"
9666 "Advertise own Router-LSA with infinite distance (stub router)\n"
9667 "Automatically advertise stub Router-LSA on startup of OSPF\n"
9668 "Time (seconds) to advertise self as stub-router\n")
9670 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9672 unsigned int seconds
;
9675 vty_out(vty
, "%% Must supply stub-router period");
9676 return CMD_WARNING_CONFIG_FAILED
;
9679 seconds
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
9681 ospf
->stub_router_startup_time
= seconds
;
9686 DEFUN (no_ospf_max_metric_router_lsa_startup
,
9687 no_ospf_max_metric_router_lsa_startup_cmd
,
9688 "no max-metric router-lsa on-startup [(5-86400)]",
9690 "OSPF maximum / infinite-distance metric\n"
9691 "Advertise own Router-LSA with infinite distance (stub router)\n"
9692 "Automatically advertise stub Router-LSA on startup of OSPF\n"
9693 "Time (seconds) to advertise self as stub-router\n")
9695 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9696 struct listnode
*ln
;
9697 struct ospf_area
*area
;
9699 ospf
->stub_router_startup_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
9701 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
9702 SET_FLAG(area
->stub_router_state
,
9703 OSPF_AREA_WAS_START_STUB_ROUTED
);
9704 OSPF_TIMER_OFF(area
->t_stub_router
);
9706 /* Don't trample on admin stub routed */
9707 if (!CHECK_FLAG(area
->stub_router_state
,
9708 OSPF_AREA_ADMIN_STUB_ROUTED
)) {
9709 UNSET_FLAG(area
->stub_router_state
,
9710 OSPF_AREA_IS_STUB_ROUTED
);
9711 ospf_router_lsa_update_area(area
);
9718 DEFUN (ospf_max_metric_router_lsa_shutdown
,
9719 ospf_max_metric_router_lsa_shutdown_cmd
,
9720 "max-metric router-lsa on-shutdown (5-100)",
9721 "OSPF maximum / infinite-distance metric\n"
9722 "Advertise own Router-LSA with infinite distance (stub router)\n"
9723 "Advertise stub-router prior to full shutdown of OSPF\n"
9724 "Time (seconds) to wait till full shutdown\n")
9726 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9728 unsigned int seconds
;
9731 vty_out(vty
, "%% Must supply stub-router shutdown period");
9732 return CMD_WARNING_CONFIG_FAILED
;
9735 seconds
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
9737 ospf
->stub_router_shutdown_time
= seconds
;
9742 DEFUN (no_ospf_max_metric_router_lsa_shutdown
,
9743 no_ospf_max_metric_router_lsa_shutdown_cmd
,
9744 "no max-metric router-lsa on-shutdown [(5-100)]",
9746 "OSPF maximum / infinite-distance metric\n"
9747 "Advertise own Router-LSA with infinite distance (stub router)\n"
9748 "Advertise stub-router prior to full shutdown of OSPF\n"
9749 "Time (seconds) to wait till full shutdown\n")
9751 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9753 ospf
->stub_router_shutdown_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
9758 DEFUN (ospf_proactive_arp
,
9759 ospf_proactive_arp_cmd
,
9761 "Allow sending ARP requests proactively\n")
9763 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9765 ospf
->proactive_arp
= true;
9770 DEFUN (no_ospf_proactive_arp
,
9771 no_ospf_proactive_arp_cmd
,
9774 "Disallow sending ARP requests proactively\n")
9776 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9778 ospf
->proactive_arp
= false;
9783 /* Graceful Restart HELPER Commands */
9784 DEFPY(ospf_gr_helper_enable
, ospf_gr_helper_enable_cmd
,
9785 "graceful-restart helper-only [A.B.C.D]",
9786 "OSPF Graceful Restart\n"
9787 "Enable Helper support\n"
9788 "Advertising router id\n")
9790 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9791 struct in_addr addr
;
9795 ret
= inet_aton(argv
[2]->arg
, &addr
);
9798 "Please specify the valid routerid address.\n");
9799 return CMD_WARNING_CONFIG_FAILED
;
9802 ospf_gr_helper_support_set_per_routerid(ospf
, &addr
, OSPF_GR_TRUE
);
9806 ospf_gr_helper_support_set(ospf
, OSPF_GR_TRUE
);
9811 DEFPY(no_ospf_gr_helper_enable
,
9812 no_ospf_gr_helper_enable_cmd
,
9813 "no graceful-restart helper-only [A.B.C.D]",
9815 "OSPF Graceful Restart\n"
9816 "Disable Helper support\n"
9817 "Advertising router id\n")
9819 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9820 struct in_addr addr
;
9824 ret
= inet_aton(argv
[3]->arg
, &addr
);
9827 "Please specify the valid routerid address.\n");
9828 return CMD_WARNING_CONFIG_FAILED
;
9831 ospf_gr_helper_support_set_per_routerid(ospf
, &addr
,
9836 ospf_gr_helper_support_set(ospf
, OSPF_GR_FALSE
);
9840 DEFPY(ospf_gr_helper_enable_lsacheck
,
9841 ospf_gr_helper_enable_lsacheck_cmd
,
9842 "graceful-restart helper strict-lsa-checking",
9843 "OSPF Graceful Restart\n"
9845 "Enable strict LSA check\n")
9847 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9849 ospf_gr_helper_lsa_check_set(ospf
, OSPF_GR_TRUE
);
9853 DEFPY(no_ospf_gr_helper_enable_lsacheck
,
9854 no_ospf_gr_helper_enable_lsacheck_cmd
,
9855 "no graceful-restart helper strict-lsa-checking",
9857 "OSPF Graceful Restart\n"
9859 "Disable strict LSA check\n")
9861 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9863 ospf_gr_helper_lsa_check_set(ospf
, OSPF_GR_FALSE
);
9867 DEFPY(ospf_gr_helper_supported_grace_time
,
9868 ospf_gr_helper_supported_grace_time_cmd
,
9869 "graceful-restart helper supported-grace-time (10-1800)$interval",
9870 "OSPF Graceful Restart\n"
9872 "Supported grace timer\n"
9873 "Grace interval(in seconds)\n")
9875 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9877 ospf_gr_helper_supported_gracetime_set(ospf
, interval
);
9881 DEFPY(no_ospf_gr_helper_supported_grace_time
,
9882 no_ospf_gr_helper_supported_grace_time_cmd
,
9883 "no graceful-restart helper supported-grace-time (10-1800)$interval",
9885 "OSPF Graceful Restart\n"
9887 "Supported grace timer\n"
9888 "Grace interval(in seconds)\n")
9890 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9892 ospf_gr_helper_supported_gracetime_set(ospf
, OSPF_MAX_GRACE_INTERVAL
);
9896 DEFPY(ospf_gr_helper_planned_only
,
9897 ospf_gr_helper_planned_only_cmd
,
9898 "graceful-restart helper planned-only",
9899 "OSPF Graceful Restart\n"
9901 "Supported only planned restart\n")
9903 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9905 ospf_gr_helper_set_supported_planned_only_restart(ospf
, OSPF_GR_TRUE
);
9910 /* External Route Aggregation */
9911 DEFUN (ospf_external_route_aggregation
,
9912 ospf_external_route_aggregation_cmd
,
9913 "summary-address A.B.C.D/M [tag (1-4294967295)]",
9914 "External summary address\n"
9915 "Summary address prefix (a.b.c.d/m) \n"
9917 "Router tag value\n")
9919 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9920 struct prefix_ipv4 p
;
9922 route_tag_t tag
= 0;
9923 int ret
= OSPF_SUCCESS
;
9925 str2prefix_ipv4(argv
[idx
]->arg
, &p
);
9927 if (is_prefix_default(&p
)) {
9929 "Default address shouldn't be configured as summary address.\n");
9933 /* Apply mask for given prefix. */
9934 apply_mask((struct prefix
*)&p
);
9936 if (!is_valid_summary_addr(&p
)) {
9937 vty_out(vty
, "Not a valid summary address.\n");
9938 return CMD_WARNING_CONFIG_FAILED
;
9942 tag
= strtoul(argv
[idx
+ 2]->arg
, NULL
, 10);
9944 ret
= ospf_asbr_external_aggregator_set(ospf
, &p
, tag
);
9945 if (ret
== OSPF_INVALID
)
9946 vty_out(vty
, "Inavlid configuration!!\n");
9951 DEFUN (no_ospf_external_route_aggregation
,
9952 no_ospf_external_route_aggregation_cmd
,
9953 "no summary-address A.B.C.D/M [tag (1-4294967295)]",
9955 "External summary address\n"
9956 "Summary address prefix (a.b.c.d/m)\n"
9958 "Router tag value\n")
9960 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
9961 struct prefix_ipv4 p
;
9963 route_tag_t tag
= 0;
9964 int ret
= OSPF_SUCCESS
;
9966 str2prefix_ipv4(argv
[idx
]->arg
, &p
);
9968 if (is_prefix_default(&p
)) {
9970 "Default address shouldn't be configured as summary address.\n");
9974 /* Apply mask for given prefix. */
9975 apply_mask((struct prefix
*)&p
);
9977 if (!is_valid_summary_addr(&p
)) {
9978 vty_out(vty
, "Not a valid summary address.\n");
9979 return CMD_WARNING_CONFIG_FAILED
;
9983 tag
= strtoul(argv
[idx
+ 2]->arg
, NULL
, 10);
9985 ret
= ospf_asbr_external_aggregator_unset(ospf
, &p
, tag
);
9986 if (ret
== OSPF_INVALID
)
9987 vty_out(vty
, "Inavlid configuration!!\n");
9992 DEFPY(no_ospf_gr_helper_planned_only
,
9993 no_ospf_gr_helper_planned_only_cmd
,
9994 "no graceful-restart helper planned-only",
9996 "OSPF Graceful Restart\n"
9998 "Supported only for planned restart\n")
10000 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
10002 ospf_gr_helper_set_supported_planned_only_restart(ospf
, OSPF_GR_FALSE
);
10004 return CMD_SUCCESS
;
10007 static int ospf_print_vty_helper_dis_rtr_walkcb(struct hash_bucket
*bucket
,
10010 struct advRtr
*rtr
= bucket
->data
;
10011 struct vty
*vty
= (struct vty
*)arg
;
10012 static unsigned int count
;
10014 vty_out(vty
, "%-6pI4,", &rtr
->advRtrAddr
);
10017 if (count
% 5 == 0)
10018 vty_out(vty
, "\n");
10020 return HASHWALK_CONTINUE
;
10023 static int ospf_show_gr_helper_details(struct vty
*vty
, struct ospf
*ospf
,
10024 uint8_t use_vrf
, json_object
*json
,
10025 bool uj
, bool detail
)
10027 struct listnode
*node
;
10028 struct ospf_interface
*oi
;
10029 char buf
[PREFIX_STRLEN
];
10030 json_object
*json_vrf
= NULL
;
10034 json_vrf
= json_object_new_object();
10039 if (ospf
->instance
) {
10041 json_object_int_add(json
, "ospfInstance",
10044 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
10047 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
10051 if (ospf
->vrf_id
== VRF_DEFAULT
)
10052 json_object_object_add(json
, "default",
10055 json_object_object_add(json
, ospf
->name
,
10059 vty_out(vty
, "\n");
10061 /* Show Router ID. */
10063 json_object_string_add(json_vrf
, "routerId",
10064 inet_ntop(AF_INET
, &ospf
->router_id
,
10065 buf
, sizeof(buf
)));
10067 vty_out(vty
, "\n OSPF Router with ID (%pI4)\n\n",
10073 if (ospf
->is_helper_supported
)
10075 " Graceful restart helper support enabled.\n");
10078 " Graceful restart helper support disabled.\n");
10080 if (ospf
->strict_lsa_check
)
10081 vty_out(vty
, " Strict LSA check is enabled.\n");
10083 vty_out(vty
, " Strict LSA check is disabled.\n");
10085 if (ospf
->only_planned_restart
)
10087 " Helper supported for planned restarts only.\n");
10090 " Helper supported for Planned and Unplanned Restarts.\n");
10093 " Supported Graceful restart interval: %d(in seconds).\n",
10094 ospf
->supported_grace_time
);
10096 if (OSPF_HELPER_ENABLE_RTR_COUNT(ospf
)) {
10097 vty_out(vty
, " Enable Router list:\n");
10099 hash_walk(ospf
->enable_rtr_list
,
10100 ospf_print_vty_helper_dis_rtr_walkcb
, vty
);
10101 vty_out(vty
, "\n\n");
10104 if (ospf
->last_exit_reason
!= OSPF_GR_HELPER_EXIT_NONE
) {
10105 vty_out(vty
, " Last Helper exit Reason :%s\n",
10106 ospf_exit_reason2str(ospf
->last_exit_reason
));
10109 if (ospf
->active_restarter_cnt
)
10111 " Number of Active neighbours in graceful restart: %d\n",
10112 ospf
->active_restarter_cnt
);
10114 vty_out(vty
, "\n");
10117 json_object_string_add(
10118 json_vrf
, "helperSupport",
10119 (ospf
->is_helper_supported
) ? "Enabled" : "Disabled");
10120 json_object_string_add(json_vrf
, "strictLsaCheck",
10121 (ospf
->strict_lsa_check
) ? "Enabled"
10123 json_object_string_add(
10124 json_vrf
, "restartSupoort",
10125 (ospf
->only_planned_restart
)
10126 ? "Planned Restart only"
10127 : "Planned and Unplanned Restarts");
10129 json_object_int_add(json_vrf
, "supportedGracePeriod",
10130 ospf
->supported_grace_time
);
10132 if (ospf
->last_exit_reason
!= OSPF_GR_HELPER_EXIT_NONE
)
10133 json_object_string_add(
10134 json_vrf
, "LastExitReason",
10135 ospf_exit_reason2str(ospf
->last_exit_reason
));
10137 if (ospf
->active_restarter_cnt
)
10138 json_object_int_add(json_vrf
, "activeRestarterCnt",
10139 ospf
->active_restarter_cnt
);
10145 json_object
*json_neighbors
= NULL
;
10147 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
10148 struct route_node
*rn
;
10149 struct ospf_neighbor
*nbr
;
10150 json_object
*json_neigh
;
10152 if (ospf_interface_neighbor_count(oi
) == 0)
10156 json_object_object_get_ex(json_vrf
, "Neighbors",
10158 if (!json_neighbors
) {
10160 json_object_new_object();
10161 json_object_object_add(json_vrf
,
10167 for (rn
= route_top(oi
->nbrs
); rn
;
10168 rn
= route_next(rn
)) {
10175 if (!OSPF_GR_IS_ACTIVE_HELPER(nbr
))
10179 vty_out(vty
, " Neighbour %d :\n", cnt
);
10180 vty_out(vty
, " Address : %pI4\n",
10181 &nbr
->address
.u
.prefix4
);
10182 vty_out(vty
, " Routerid : %pI4\n",
10185 " Received Grace period : %d(in seconds).\n",
10186 nbr
->gr_helper_info
10187 .recvd_grace_period
);
10189 " Actual Grace period : %d(in seconds)\n",
10190 nbr
->gr_helper_info
10191 .actual_grace_period
);
10193 " Remaining GraceTime:%ld(in seconds).\n",
10194 thread_timer_remain_second(
10195 nbr
->gr_helper_info
10198 " Graceful Restart reason: %s.\n\n",
10199 ospf_restart_reason2str(
10200 nbr
->gr_helper_info
10201 .gr_restart_reason
));
10204 json_neigh
= json_object_new_object();
10205 json_object_string_add(
10206 json_neigh
, "srcAddr",
10207 inet_ntop(AF_INET
, &nbr
->src
,
10208 buf
, sizeof(buf
)));
10210 json_object_string_add(
10211 json_neigh
, "routerid",
10214 buf
, sizeof(buf
)));
10215 json_object_int_add(
10217 "recvdGraceInterval",
10218 nbr
->gr_helper_info
10219 .recvd_grace_period
);
10220 json_object_int_add(
10222 "actualGraceInterval",
10223 nbr
->gr_helper_info
10224 .actual_grace_period
);
10225 json_object_int_add(
10226 json_neigh
, "remainGracetime",
10227 thread_timer_remain_second(
10228 nbr
->gr_helper_info
10230 json_object_string_add(
10231 json_neigh
, "restartReason",
10232 ospf_restart_reason2str(
10233 nbr
->gr_helper_info
10234 .gr_restart_reason
));
10235 json_object_object_add(
10237 inet_ntop(AF_INET
, &nbr
->src
,
10244 return CMD_SUCCESS
;
10247 DEFUN (ospf_external_route_aggregation_no_adrvertise
,
10248 ospf_external_route_aggregation_no_adrvertise_cmd
,
10249 "summary-address A.B.C.D/M no-advertise",
10250 "External summary address\n"
10251 "Summary address prefix (a.b.c.d/m) \n"
10252 "Don't advertise summary route \n")
10254 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
10255 struct prefix_ipv4 p
;
10257 int ret
= OSPF_SUCCESS
;
10259 str2prefix_ipv4(argv
[idx
]->arg
, &p
);
10261 if (is_prefix_default(&p
)) {
10263 "Default address shouldn't be configured as summary address.\n");
10264 return CMD_SUCCESS
;
10267 /* Apply mask for given prefix. */
10268 apply_mask((struct prefix
*)&p
);
10270 if (!is_valid_summary_addr(&p
)) {
10271 vty_out(vty
, "Not a valid summary address.\n");
10272 return CMD_WARNING_CONFIG_FAILED
;
10275 ret
= ospf_asbr_external_rt_no_advertise(ospf
, &p
);
10276 if (ret
== OSPF_INVALID
)
10277 vty_out(vty
, "Inavlid configuration!!\n");
10279 return CMD_SUCCESS
;
10282 DEFUN (no_ospf_external_route_aggregation_no_adrvertise
,
10283 no_ospf_external_route_aggregation_no_adrvertise_cmd
,
10284 "no summary-address A.B.C.D/M no-advertise",
10286 "External summary address\n"
10287 "Summary address prefix (a.b.c.d/m)\n"
10288 "Advertise summary route to the AS \n")
10290 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
10291 struct prefix_ipv4 p
;
10293 int ret
= OSPF_SUCCESS
;
10295 str2prefix_ipv4(argv
[idx
]->arg
, &p
);
10297 if (is_prefix_default(&p
)) {
10299 "Default address shouldn't be configured as summary address.\n");
10300 return CMD_SUCCESS
;
10303 /* Apply mask for given prefix. */
10304 apply_mask((struct prefix
*)&p
);
10306 if (!is_valid_summary_addr(&p
)) {
10307 vty_out(vty
, "Not a valid summary address.\n");
10308 return CMD_WARNING_CONFIG_FAILED
;
10311 ret
= ospf_asbr_external_rt_advertise(ospf
, &p
);
10312 if (ret
== OSPF_INVALID
)
10313 vty_out(vty
, "Inavlid configuration!!\n");
10315 return CMD_SUCCESS
;
10318 DEFUN (ospf_route_aggregation_timer
,
10319 ospf_route_aggregation_timer_cmd
,
10320 "aggregation timer (5-1800)",
10321 "External route aggregation\n"
10322 "Delay timer (in seconds)\n"
10323 "Timer interval(in seconds)\n")
10325 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
10326 unsigned int interval
= 0;
10328 interval
= strtoul(argv
[2]->arg
, NULL
, 10);
10330 ospf_external_aggregator_timer_set(ospf
, interval
);
10332 return CMD_SUCCESS
;
10335 DEFPY (show_ip_ospf_gr_helper
,
10336 show_ip_ospf_gr_helper_cmd
,
10337 "show ip ospf [vrf <NAME|all>] graceful-restart helper [detail] [json]",
10340 "OSPF information\n"
10343 "OSPF Graceful Restart\n"
10344 "Helper details in the router\n"
10345 "Detailed informtion\n"
10348 char *vrf_name
= NULL
;
10349 bool all_vrf
= false;
10350 int ret
= CMD_SUCCESS
;
10353 uint8_t use_vrf
= 0;
10354 bool uj
= use_json(argc
, argv
);
10355 struct ospf
*ospf
= NULL
;
10356 json_object
*json
= NULL
;
10357 struct listnode
*node
= NULL
;
10359 bool detail
= false;
10361 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
10363 if (argv_find(argv
, argc
, "detail", &idx
))
10367 json
= json_object_new_object();
10369 /* vrf input is provided */
10374 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
10375 if (!ospf
->oi_running
)
10378 ret
= ospf_show_gr_helper_details(
10379 vty
, ospf
, use_vrf
, json
, uj
, detail
);
10383 vty_out(vty
, "%s\n",
10384 json_object_to_json_string_ext(
10385 json
, JSON_C_TO_STRING_PRETTY
));
10386 json_object_free(json
);
10392 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
10394 if (ospf
== NULL
|| !ospf
->oi_running
) {
10397 vty_out(vty
, "%s\n",
10398 json_object_to_json_string_ext(
10399 json
, JSON_C_TO_STRING_PRETTY
));
10400 json_object_free(json
);
10402 vty_out(vty
, "%% OSPF instance not found\n");
10404 return CMD_SUCCESS
;
10409 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
10411 if (ospf
== NULL
|| !ospf
->oi_running
) {
10414 vty_out(vty
, "%s\n",
10415 json_object_to_json_string_ext(
10416 json
, JSON_C_TO_STRING_PRETTY
));
10417 json_object_free(json
);
10419 vty_out(vty
, "%% OSPF instance not found\n");
10421 return CMD_SUCCESS
;
10424 ospf_show_gr_helper_details(vty
, ospf
, use_vrf
, json
, uj
,
10429 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10430 json
, JSON_C_TO_STRING_PRETTY
));
10431 json_object_free(json
);
10434 return CMD_SUCCESS
;
10436 /* Graceful Restart HELPER commands end */
10437 DEFUN (no_ospf_route_aggregation_timer
,
10438 no_ospf_route_aggregation_timer_cmd
,
10439 "no aggregation timer",
10441 "External route aggregation\n"
10444 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
10446 ospf_external_aggregator_timer_set(ospf
, OSPF_EXTL_AGGR_DEFAULT_DELAY
);
10448 return CMD_SUCCESS
;
10451 /* External Route Aggregation End */
10453 static void config_write_stub_router(struct vty
*vty
, struct ospf
*ospf
)
10455 struct listnode
*ln
;
10456 struct ospf_area
*area
;
10458 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
10459 vty_out(vty
, " max-metric router-lsa on-startup %u\n",
10460 ospf
->stub_router_startup_time
);
10461 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
10462 vty_out(vty
, " max-metric router-lsa on-shutdown %u\n",
10463 ospf
->stub_router_shutdown_time
);
10464 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
10465 if (CHECK_FLAG(area
->stub_router_state
,
10466 OSPF_AREA_ADMIN_STUB_ROUTED
)) {
10467 vty_out(vty
, " max-metric router-lsa administrative\n");
10474 static void show_ip_ospf_route_network(struct vty
*vty
, struct ospf
*ospf
,
10475 struct route_table
*rt
,
10478 struct route_node
*rn
;
10479 struct ospf_route
* or ;
10480 struct listnode
*pnode
, *pnnode
;
10481 struct ospf_path
*path
;
10482 char buf
[PREFIX_STRLEN
];
10483 json_object
*json_route
= NULL
, *json_nexthop_array
= NULL
,
10484 *json_nexthop
= NULL
;
10488 "============ OSPF network routing table ============\n");
10490 for (rn
= route_top(rt
); rn
; rn
= route_next(rn
)) {
10491 char buf1
[PREFIX2STR_BUFFER
];
10493 if ((or = rn
->info
) == NULL
)
10496 prefix2str(&rn
->p
, buf1
, sizeof(buf1
));
10498 json_route
= json_object_new_object();
10500 json_object_object_add(json
, buf1
, json_route
);
10501 json_object_to_json_string_ext(
10502 json
, JSON_C_TO_STRING_NOSLASHESCAPE
);
10505 switch (or->path_type
) {
10506 case OSPF_PATH_INTER_AREA
:
10507 if (or->type
== OSPF_DESTINATION_NETWORK
) {
10509 json_object_string_add(json_route
,
10512 json_object_int_add(json_route
, "cost",
10514 json_object_string_add(
10515 json_route
, "area",
10517 &or->u
.std
.area_id
,
10518 buf1
, sizeof(buf1
)));
10521 "N IA %-18s [%d] area: %pI4\n",
10523 &or->u
.std
.area_id
);
10525 } else if (or->type
== OSPF_DESTINATION_DISCARD
) {
10527 json_object_string_add(json_route
,
10532 "D IA %-18s Discard entry\n",
10537 case OSPF_PATH_INTRA_AREA
:
10539 json_object_string_add(json_route
, "routeType",
10541 json_object_int_add(json_route
, "cost",
10543 json_object_string_add(
10544 json_route
, "area",
10545 inet_ntop(AF_INET
, &or->u
.std
.area_id
,
10546 buf1
, sizeof(buf1
)));
10548 vty_out(vty
, "N %-18s [%d] area: %pI4\n",
10550 &or->u
.std
.area_id
);
10557 if (or->type
== OSPF_DESTINATION_NETWORK
) {
10559 json_nexthop_array
= json_object_new_array();
10560 json_object_object_add(json_route
, "nexthops",
10561 json_nexthop_array
);
10564 for (ALL_LIST_ELEMENTS(or->paths
, pnode
, pnnode
,
10567 json_nexthop
= json_object_new_object();
10568 json_object_array_add(
10569 json_nexthop_array
,
10572 if (if_lookup_by_index(path
->ifindex
,
10575 if (path
->nexthop
.s_addr
10578 json_object_string_add(
10581 json_object_string_add(
10583 "directly attached to",
10589 "%24s directly attached to %s\n",
10597 json_object_string_add(
10605 json_object_string_add(
10613 "%24s via %pI4, %s\n",
10625 json_object_free(json_route
);
10628 vty_out(vty
, "\n");
10631 static void show_ip_ospf_route_router(struct vty
*vty
, struct ospf
*ospf
,
10632 struct route_table
*rtrs
,
10635 struct route_node
*rn
;
10636 struct ospf_route
* or ;
10637 struct listnode
*pnode
;
10638 struct listnode
*node
;
10639 struct ospf_path
*path
;
10640 char buf
[PREFIX_STRLEN
];
10641 json_object
*json_route
= NULL
, *json_nexthop_array
= NULL
,
10642 *json_nexthop
= NULL
;
10646 "============ OSPF router routing table =============\n");
10648 for (rn
= route_top(rtrs
); rn
; rn
= route_next(rn
)) {
10649 if (rn
->info
== NULL
)
10653 json_route
= json_object_new_object();
10655 json_object_object_add(
10656 json
, inet_ntop(AF_INET
, &rn
->p
.u
.prefix4
,
10659 json_object_string_add(json_route
, "routeType", "R ");
10661 vty_out(vty
, "R %-15pI4 ",
10665 for (ALL_LIST_ELEMENTS_RO((struct list
*)rn
->info
, node
, or)) {
10668 vty_out(vty
, "%24s", "");
10673 json_object_int_add(json_route
, "cost",
10675 json_object_string_add(
10676 json_route
, "area",
10677 inet_ntop(AF_INET
, &or->u
.std
.area_id
,
10678 buf
, sizeof(buf
)));
10679 if (or->path_type
== OSPF_PATH_INTER_AREA
)
10680 json_object_boolean_true_add(json_route
,
10682 if (or->u
.std
.flags
& ROUTER_LSA_BORDER
)
10683 json_object_string_add(json_route
,
10686 else if (or->u
.std
.flags
& ROUTER_LSA_EXTERNAL
)
10687 json_object_string_add(json_route
,
10691 vty_out(vty
, "%s [%d] area: %pI4",
10692 (or->path_type
== OSPF_PATH_INTER_AREA
10695 or->cost
, &or->u
.std
.area_id
);
10697 vty_out(vty
, "%s%s\n",
10698 (or->u
.std
.flags
& ROUTER_LSA_BORDER
10701 (or->u
.std
.flags
& ROUTER_LSA_EXTERNAL
10707 json_nexthop_array
= json_object_new_array();
10708 json_object_object_add(json_route
, "nexthops",
10709 json_nexthop_array
);
10712 for (ALL_LIST_ELEMENTS_RO(or->paths
, pnode
, path
)) {
10714 json_nexthop
= json_object_new_object();
10715 json_object_array_add(
10716 json_nexthop_array
,
10719 if (if_lookup_by_index(path
->ifindex
,
10721 if (path
->nexthop
.s_addr
10724 json_object_string_add(
10727 json_object_string_add(
10729 "directly attached to",
10735 "%24s directly attached to %s\n",
10743 json_object_string_add(
10749 buf
, sizeof(buf
)));
10750 json_object_string_add(
10758 "%24s via %pI4, %s\n",
10770 json_object_free(json_route
);
10773 vty_out(vty
, "\n");
10776 static void show_ip_ospf_route_external(struct vty
*vty
, struct ospf
*ospf
,
10777 struct route_table
*rt
,
10780 struct route_node
*rn
;
10781 struct ospf_route
*er
;
10782 struct listnode
*pnode
, *pnnode
;
10783 struct ospf_path
*path
;
10784 char buf
[PREFIX_STRLEN
];
10785 json_object
*json_route
= NULL
, *json_nexthop_array
= NULL
,
10786 *json_nexthop
= NULL
;
10790 "============ OSPF external routing table ===========\n");
10792 for (rn
= route_top(rt
); rn
; rn
= route_next(rn
)) {
10793 if ((er
= rn
->info
) == NULL
)
10798 snprintfrr(buf1
, sizeof(buf1
), "%pFX", &rn
->p
);
10799 json_route
= json_object_new_object();
10801 json_object_object_add(json
, buf1
, json_route
);
10802 json_object_to_json_string_ext(
10803 json
, JSON_C_TO_STRING_NOSLASHESCAPE
);
10806 switch (er
->path_type
) {
10807 case OSPF_PATH_TYPE1_EXTERNAL
:
10809 json_object_string_add(json_route
, "routeType",
10811 json_object_int_add(json_route
, "cost",
10815 "N E1 %-18s [%d] tag: %" ROUTE_TAG_PRI
10817 buf1
, er
->cost
, er
->u
.ext
.tag
);
10820 case OSPF_PATH_TYPE2_EXTERNAL
:
10822 json_object_string_add(json_route
, "routeType",
10824 json_object_int_add(json_route
, "cost",
10828 "N E2 %-18s [%d/%d] tag: %" ROUTE_TAG_PRI
10830 buf1
, er
->cost
, er
->u
.ext
.type2_cost
,
10837 json_nexthop_array
= json_object_new_array();
10838 json_object_object_add(json_route
, "nexthops",
10839 json_nexthop_array
);
10842 for (ALL_LIST_ELEMENTS(er
->paths
, pnode
, pnnode
, path
)) {
10844 json_nexthop
= json_object_new_object();
10845 json_object_array_add(json_nexthop_array
,
10849 if (if_lookup_by_index(path
->ifindex
, ospf
->vrf_id
)) {
10850 if (path
->nexthop
.s_addr
== INADDR_ANY
) {
10852 json_object_string_add(
10853 json_nexthop
, "ip",
10855 json_object_string_add(
10857 "directly attached to",
10863 "%24s directly attached to %s\n",
10871 json_object_string_add(
10872 json_nexthop
, "ip",
10878 json_object_string_add(
10879 json_nexthop
, "via",
10885 "%24s via %pI4, %s\n",
10896 json_object_free(json_route
);
10899 vty_out(vty
, "\n");
10902 static int show_ip_ospf_border_routers_common(struct vty
*vty
,
10906 if (ospf
->instance
)
10907 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
10909 ospf_show_vrf_name(ospf
, vty
, NULL
, use_vrf
);
10911 if (ospf
->new_table
== NULL
) {
10912 vty_out(vty
, "No OSPF routing information exist\n");
10913 return CMD_SUCCESS
;
10916 /* Show Network routes.
10917 show_ip_ospf_route_network (vty, ospf->new_table); */
10919 /* Show Router routes. */
10920 show_ip_ospf_route_router(vty
, ospf
, ospf
->new_rtrs
, NULL
);
10922 vty_out(vty
, "\n");
10924 return CMD_SUCCESS
;
10927 DEFUN (show_ip_ospf_border_routers
,
10928 show_ip_ospf_border_routers_cmd
,
10929 "show ip ospf [vrf <NAME|all>] border-routers",
10932 "OSPF information\n"
10935 "Show all the ABR's and ASBR's\n")
10937 struct ospf
*ospf
= NULL
;
10938 struct listnode
*node
= NULL
;
10939 char *vrf_name
= NULL
;
10940 bool all_vrf
= false;
10941 int ret
= CMD_SUCCESS
;
10944 uint8_t use_vrf
= 0;
10946 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
10949 bool ospf_output
= false;
10954 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
10955 if (!ospf
->oi_running
)
10958 ospf_output
= true;
10959 ret
= show_ip_ospf_border_routers_common(
10960 vty
, ospf
, use_vrf
);
10964 vty_out(vty
, "%% OSPF instance not found\n");
10966 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
10967 if (ospf
== NULL
|| !ospf
->oi_running
) {
10968 vty_out(vty
, "%% OSPF instance not found\n");
10969 return CMD_SUCCESS
;
10972 ret
= show_ip_ospf_border_routers_common(vty
, ospf
,
10976 /* Display default ospf (instance 0) info */
10977 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
10978 if (ospf
== NULL
|| !ospf
->oi_running
) {
10979 vty_out(vty
, "%% OSPF instance not found\n");
10980 return CMD_SUCCESS
;
10983 ret
= show_ip_ospf_border_routers_common(vty
, ospf
, use_vrf
);
10989 DEFUN (show_ip_ospf_instance_border_routers
,
10990 show_ip_ospf_instance_border_routers_cmd
,
10991 "show ip ospf (1-65535) border-routers",
10994 "OSPF information\n"
10996 "Show all the ABR's and ASBR's\n")
10998 int idx_number
= 3;
11000 unsigned short instance
= 0;
11002 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11003 if (instance
!= ospf_instance
)
11004 return CMD_NOT_MY_INSTANCE
;
11006 ospf
= ospf_lookup_instance(instance
);
11007 if (!ospf
|| !ospf
->oi_running
)
11008 return CMD_SUCCESS
;
11010 return show_ip_ospf_border_routers_common(vty
, ospf
, 0);
11013 static int show_ip_ospf_route_common(struct vty
*vty
, struct ospf
*ospf
,
11014 json_object
*json
, uint8_t use_vrf
)
11016 json_object
*json_vrf
= NULL
;
11018 if (ospf
->instance
)
11019 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
11024 json_vrf
= json_object_new_object();
11029 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
11031 if (ospf
->new_table
== NULL
) {
11032 vty_out(vty
, "No OSPF routing information exist\n");
11033 return CMD_SUCCESS
;
11036 /* Show Network routes. */
11037 show_ip_ospf_route_network(vty
, ospf
, ospf
->new_table
, json_vrf
);
11039 /* Show Router routes. */
11040 show_ip_ospf_route_router(vty
, ospf
, ospf
->new_rtrs
, json_vrf
);
11042 /* Show AS External routes. */
11043 show_ip_ospf_route_external(vty
, ospf
, ospf
->old_external_route
,
11048 // json_object_object_add(json_vrf, "areas",
11050 if (ospf
->vrf_id
== VRF_DEFAULT
)
11051 json_object_object_add(json
, "default",
11054 json_object_object_add(json
, ospf
->name
,
11058 vty_out(vty
, "\n");
11061 return CMD_SUCCESS
;
11064 DEFUN (show_ip_ospf_route
,
11065 show_ip_ospf_route_cmd
,
11066 "show ip ospf [vrf <NAME|all>] route [json]",
11069 "OSPF information\n"
11072 "OSPF routing table\n"
11075 struct ospf
*ospf
= NULL
;
11076 struct listnode
*node
= NULL
;
11077 char *vrf_name
= NULL
;
11078 bool all_vrf
= false;
11079 int ret
= CMD_SUCCESS
;
11082 uint8_t use_vrf
= 0;
11083 bool uj
= use_json(argc
, argv
);
11084 json_object
*json
= NULL
;
11087 json
= json_object_new_object();
11089 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
11091 /* vrf input is provided could be all or specific vrf*/
11093 bool ospf_output
= false;
11098 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
11099 if (!ospf
->oi_running
)
11101 ospf_output
= true;
11102 ret
= show_ip_ospf_route_common(vty
, ospf
, json
,
11107 /* Keep Non-pretty format */
11108 vty_out(vty
, "%s\n",
11109 json_object_to_json_string(json
));
11110 json_object_free(json
);
11111 } else if (!ospf_output
)
11112 vty_out(vty
, "%% OSPF instance not found\n");
11116 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
11117 if (ospf
== NULL
|| !ospf
->oi_running
) {
11119 vty_out(vty
, "%s\n",
11120 json_object_to_json_string_ext(
11121 json
, JSON_C_TO_STRING_PRETTY
));
11122 json_object_free(json
);
11124 vty_out(vty
, "%% OSPF instance not found\n");
11126 return CMD_SUCCESS
;
11129 /* Display default ospf (instance 0) info */
11130 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
11131 if (ospf
== NULL
|| !ospf
->oi_running
) {
11133 vty_out(vty
, "%s\n",
11134 json_object_to_json_string_ext(
11135 json
, JSON_C_TO_STRING_PRETTY
));
11136 json_object_free(json
);
11138 vty_out(vty
, "%% OSPF instance not found\n");
11140 return CMD_SUCCESS
;
11145 ret
= show_ip_ospf_route_common(vty
, ospf
, json
, use_vrf
);
11146 /* Keep Non-pretty format */
11148 vty_out(vty
, "%s\n", json_object_to_json_string(json
));
11152 json_object_free(json
);
11157 DEFUN (show_ip_ospf_instance_route
,
11158 show_ip_ospf_instance_route_cmd
,
11159 "show ip ospf (1-65535) route",
11162 "OSPF information\n"
11164 "OSPF routing table\n")
11166 int idx_number
= 3;
11168 unsigned short instance
= 0;
11170 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11171 if (instance
!= ospf_instance
)
11172 return CMD_NOT_MY_INSTANCE
;
11174 ospf
= ospf_lookup_instance(instance
);
11175 if (!ospf
|| !ospf
->oi_running
)
11176 return CMD_SUCCESS
;
11178 return show_ip_ospf_route_common(vty
, ospf
, NULL
, 0);
11182 DEFUN (show_ip_ospf_vrfs
,
11183 show_ip_ospf_vrfs_cmd
,
11184 "show ip ospf vrfs [json]",
11187 "OSPF information\n"
11188 "Show OSPF VRFs \n"
11191 bool uj
= use_json(argc
, argv
);
11192 json_object
*json
= NULL
;
11193 json_object
*json_vrfs
= NULL
;
11194 struct ospf
*ospf
= NULL
;
11195 struct listnode
*node
= NULL
;
11197 char buf
[PREFIX_STRLEN
];
11198 static const char header
[] = "Name Id RouterId ";
11201 json
= json_object_new_object();
11202 json_vrfs
= json_object_new_object();
11205 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
11206 json_object
*json_vrf
= NULL
;
11207 const char *name
= NULL
;
11208 int64_t vrf_id_ui
= 0;
11212 if (!uj
&& count
== 1)
11213 vty_out(vty
, "%s\n", header
);
11215 json_vrf
= json_object_new_object();
11217 if (ospf
->vrf_id
== VRF_DEFAULT
)
11218 name
= VRF_DEFAULT_NAME
;
11222 vrf_id_ui
= (ospf
->vrf_id
== VRF_UNKNOWN
)
11224 : (int64_t)ospf
->vrf_id
;
11227 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
11228 json_object_string_add(
11229 json_vrf
, "routerId",
11230 inet_ntop(AF_INET
, &ospf
->router_id
,
11231 buf
, sizeof(buf
)));
11233 json_object_object_add(json_vrfs
, name
, json_vrf
);
11236 vty_out(vty
, "%-25s %-5d %-16pI4 \n", name
,
11237 ospf
->vrf_id
, &ospf
->router_id
);
11242 json_object_object_add(json
, "vrfs", json_vrfs
);
11243 json_object_int_add(json
, "totalVrfs", count
);
11245 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
11246 json
, JSON_C_TO_STRING_PRETTY
));
11247 json_object_free(json
);
11250 vty_out(vty
, "\nTotal number of OSPF VRFs: %d\n",
11254 return CMD_SUCCESS
;
11256 DEFPY (clear_ip_ospf_neighbor
,
11257 clear_ip_ospf_neighbor_cmd
,
11258 "clear ip ospf [(1-65535)]$instance neighbor [A.B.C.D$nbr_id]",
11261 "OSPF information\n"
11263 "Reset OSPF Neighbor\n"
11266 struct listnode
*node
;
11267 struct ospf
*ospf
= NULL
;
11269 /* If user does not specify the arguments,
11270 * instance = 0 and nbr_id = 0.0.0.0
11272 if (instance
!= 0) {
11273 /* This means clear only the particular ospf process */
11274 if (instance
!= ospf_instance
)
11275 return CMD_NOT_MY_INSTANCE
;
11278 /* Clear all the ospf processes */
11279 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
11280 if (!ospf
->oi_running
)
11283 ospf_neighbor_reset(ospf
, nbr_id
, nbr_id_str
);
11286 return CMD_SUCCESS
;
11289 DEFPY (clear_ip_ospf_process
,
11290 clear_ip_ospf_process_cmd
,
11291 "clear ip ospf [(1-65535)]$instance process",
11294 "OSPF information\n"
11296 "Reset OSPF Process\n")
11298 struct listnode
*node
;
11299 struct ospf
*ospf
= NULL
;
11301 /* Check if instance is not passed as an argument */
11302 if (instance
!= 0) {
11303 /* This means clear only the particular ospf process */
11304 if (instance
!= ospf_instance
)
11305 return CMD_NOT_MY_INSTANCE
;
11308 /* Clear all the ospf processes */
11309 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
11310 if (!ospf
->oi_running
)
11313 ospf_process_reset(ospf
);
11316 return CMD_SUCCESS
;
11319 static const char *const ospf_abr_type_str
[] = {
11320 "unknown", "standard", "ibm", "cisco", "shortcut"
11323 static const char *const ospf_shortcut_mode_str
[] = {
11324 "default", "enable", "disable"
11326 static int ospf_vty_external_rt_walkcb(struct hash_bucket
*bucket
,
11329 struct external_info
*ei
= bucket
->data
;
11330 struct vty
*vty
= (struct vty
*)arg
;
11331 static unsigned int count
;
11333 vty_out(vty
, "%-4pI4/%d, ", &ei
->p
.prefix
, ei
->p
.prefixlen
);
11336 if (count
% 5 == 0)
11337 vty_out(vty
, "\n");
11339 if (OSPF_EXTERNAL_RT_COUNT(ei
->aggr_route
) == count
)
11342 return HASHWALK_CONTINUE
;
11345 static int ospf_json_external_rt_walkcb(struct hash_bucket
*bucket
,
11348 struct external_info
*ei
= bucket
->data
;
11349 struct json_object
*json
= (struct json_object
*)arg
;
11350 char buf
[PREFIX2STR_BUFFER
];
11352 static unsigned int count
;
11354 prefix2str(&ei
->p
, buf
, sizeof(buf
));
11356 snprintf(exnalbuf
, 20, "Exnl Addr-%d", count
);
11358 json_object_string_add(json
, exnalbuf
, buf
);
11362 if (OSPF_EXTERNAL_RT_COUNT(ei
->aggr_route
) == count
)
11365 return HASHWALK_CONTINUE
;
11368 static int ospf_show_summary_address(struct vty
*vty
, struct ospf
*ospf
,
11369 uint8_t use_vrf
, json_object
*json
,
11370 bool uj
, bool detail
)
11372 struct route_node
*rn
;
11373 json_object
*json_vrf
= NULL
;
11376 static char header
[] =
11377 "Summary-address Metric-type Metric Tag External_Rt_count\n";
11379 mtype
= metric_type(ospf
, 0, ospf
->instance
);
11380 mval
= metric_value(ospf
, 0, ospf
->instance
);
11383 vty_out(vty
, "%s\n", header
);
11387 json_vrf
= json_object_new_object();
11392 if (ospf
->instance
) {
11394 json_object_int_add(json
, "ospfInstance",
11397 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
11400 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
11403 vty_out(vty
, "aggregation delay interval :%d(in seconds)\n\n",
11404 ospf
->aggr_delay_interval
);
11406 json_object_int_add(json_vrf
, "aggregation delay interval",
11407 ospf
->aggr_delay_interval
);
11409 for (rn
= route_top(ospf
->rt_aggr_tbl
); rn
; rn
= route_next(rn
))
11411 struct ospf_external_aggr_rt
*aggr
= rn
->info
;
11412 json_object
*json_aggr
= NULL
;
11413 char buf
[PREFIX2STR_BUFFER
];
11415 prefix2str(&aggr
->p
, buf
, sizeof(buf
));
11419 json_aggr
= json_object_new_object();
11421 json_object_object_add(json_vrf
, buf
,
11424 json_object_string_add(json_aggr
,
11425 "Summary address", buf
);
11427 json_object_string_add(
11428 json_aggr
, "Metric-type",
11429 (mtype
== EXTERNAL_METRIC_TYPE_1
)
11433 json_object_int_add(json_aggr
, "Metric", mval
);
11435 json_object_int_add(json_aggr
, "Tag",
11438 json_object_int_add(
11439 json_aggr
, "External route count",
11440 OSPF_EXTERNAL_RT_COUNT(aggr
));
11442 if (OSPF_EXTERNAL_RT_COUNT(aggr
) && detail
) {
11444 aggr
->match_extnl_hash
,
11445 ospf_json_external_rt_walkcb
,
11450 vty_out(vty
, "%-20s", buf
);
11452 (mtype
== EXTERNAL_METRIC_TYPE_1
)
11453 ? vty_out(vty
, "%-16s", "E1")
11454 : vty_out(vty
, "%-16s", "E2");
11455 vty_out(vty
, "%-11d", mval
);
11457 vty_out(vty
, "%-12u", aggr
->tag
);
11459 vty_out(vty
, "%-5ld\n",
11460 OSPF_EXTERNAL_RT_COUNT(aggr
));
11462 if (OSPF_EXTERNAL_RT_COUNT(aggr
) && detail
) {
11464 "Matched External routes:\n");
11466 aggr
->match_extnl_hash
,
11467 ospf_vty_external_rt_walkcb
,
11469 vty_out(vty
, "\n");
11472 vty_out(vty
, "\n");
11478 if (ospf
->vrf_id
== VRF_DEFAULT
)
11479 json_object_object_add(json
, "default",
11482 json_object_object_add(json
, ospf
->name
,
11486 vty_out(vty
, "\n");
11488 return CMD_SUCCESS
;
11491 DEFUN (show_ip_ospf_external_aggregator
,
11492 show_ip_ospf_external_aggregator_cmd
,
11493 "show ip ospf [vrf <NAME|all>] summary-address [detail] [json]",
11495 "OSPF information\n"
11498 "Show external summary addresses\n"
11499 "Detailed informtion\n"
11502 char *vrf_name
= NULL
;
11503 bool all_vrf
= false;
11504 int ret
= CMD_SUCCESS
;
11507 uint8_t use_vrf
= 0;
11508 bool uj
= use_json(argc
, argv
);
11509 struct ospf
*ospf
= NULL
;
11510 json_object
*json
= NULL
;
11511 struct listnode
*node
= NULL
;
11513 bool detail
= false;
11515 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
11517 if (argv_find(argv
, argc
, "detail", &idx
))
11521 json
= json_object_new_object();
11523 /* vrf input is provided */
11527 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
11528 if (!ospf
->oi_running
)
11530 ret
= ospf_show_summary_address(
11531 vty
, ospf
, use_vrf
, json
, uj
, detail
);
11535 vty_out(vty
, "%s\n",
11536 json_object_to_json_string_ext(
11537 json
, JSON_C_TO_STRING_PRETTY
));
11538 json_object_free(json
);
11544 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
11546 if (ospf
== NULL
|| !ospf
->oi_running
) {
11548 vty_out(vty
, "%s\n",
11549 json_object_to_json_string_ext(
11550 json
, JSON_C_TO_STRING_PRETTY
));
11551 json_object_free(json
);
11553 vty_out(vty
, "%% OSPF instance not found\n");
11555 return CMD_SUCCESS
;
11557 ospf_show_summary_address(vty
, ospf
, use_vrf
, json
, uj
, detail
);
11561 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
11562 if (ospf
== NULL
|| !ospf
->oi_running
) {
11564 vty_out(vty
, "%s\n",
11565 json_object_to_json_string_ext(
11566 json
, JSON_C_TO_STRING_PRETTY
));
11567 json_object_free(json
);
11569 vty_out(vty
, "%% OSPF instance not found\n");
11571 return CMD_SUCCESS
;
11574 ospf_show_summary_address(vty
, ospf
, use_vrf
, json
, uj
, detail
);
11578 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
11579 json
, JSON_C_TO_STRING_PRETTY
));
11580 json_object_free(json
);
11582 return CMD_SUCCESS
;
11585 static const char *const ospf_int_type_str
[] = {
11586 "unknown", /* should never be used. */
11590 "point-to-multipoint",
11591 "virtual-link", /* should never be used. */
11595 static const char *interface_config_auth_str(struct ospf_if_params
*params
)
11597 if (!OSPF_IF_PARAM_CONFIGURED(params
, auth_type
)
11598 || params
->auth_type
== OSPF_AUTH_NOTSET
)
11601 /* Translation tables are not that much help
11602 * here due to syntax
11603 * of the simple option */
11604 switch (params
->auth_type
) {
11606 case OSPF_AUTH_NULL
:
11609 case OSPF_AUTH_SIMPLE
:
11612 case OSPF_AUTH_CRYPTOGRAPHIC
:
11613 return " message-digest";
11619 static int config_write_interface_one(struct vty
*vty
, struct vrf
*vrf
)
11621 struct listnode
*node
;
11622 struct interface
*ifp
;
11623 struct crypt_key
*ck
;
11624 struct route_node
*rn
= NULL
;
11625 struct ospf_if_params
*params
;
11626 const char *auth_str
;
11629 FOR_ALL_INTERFACES (vrf
, ifp
) {
11631 if (memcmp(ifp
->name
, "VLINK", 5) == 0)
11634 vty_frame(vty
, "!\n");
11635 if (ifp
->vrf_id
== VRF_DEFAULT
)
11636 vty_frame(vty
, "interface %s\n", ifp
->name
);
11638 vty_frame(vty
, "interface %s vrf %s\n", ifp
->name
,
11641 vty_out(vty
, " description %s\n", ifp
->desc
);
11645 params
= IF_DEF_PARAMS(ifp
);
11648 /* Interface Network print. */
11649 if (OSPF_IF_PARAM_CONFIGURED(params
, type
)
11650 && params
->type
!= OSPF_IFTYPE_LOOPBACK
) {
11651 if (params
->type
!= ospf_default_iftype(ifp
)) {
11652 vty_out(vty
, " ip ospf network %s",
11656 == OSPF_IFTYPE_POINTOPOINT
11657 && params
->ptp_dmvpn
)
11658 vty_out(vty
, " dmvpn");
11659 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11660 vty_out(vty
, " %pI4",
11662 vty_out(vty
, "\n");
11666 /* OSPF interface authentication print */
11667 auth_str
= interface_config_auth_str(params
);
11669 vty_out(vty
, " ip ospf authentication%s",
11671 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11672 vty_out(vty
, " %pI4",
11674 vty_out(vty
, "\n");
11677 /* Simple Authentication Password print. */
11678 if (OSPF_IF_PARAM_CONFIGURED(params
, auth_simple
)
11679 && params
->auth_simple
[0] != '\0') {
11680 vty_out(vty
, " ip ospf authentication-key %s",
11681 params
->auth_simple
);
11682 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11683 vty_out(vty
, " %pI4",
11685 vty_out(vty
, "\n");
11688 /* Cryptographic Authentication Key print. */
11689 if (params
&& params
->auth_crypt
) {
11690 for (ALL_LIST_ELEMENTS_RO(params
->auth_crypt
,
11693 " ip ospf message-digest-key %d md5 %s",
11694 ck
->key_id
, ck
->auth_key
);
11695 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11696 vty_out(vty
, " %pI4",
11698 vty_out(vty
, "\n");
11702 /* Interface Output Cost print. */
11703 if (OSPF_IF_PARAM_CONFIGURED(params
, output_cost_cmd
)) {
11704 vty_out(vty
, " ip ospf cost %u",
11705 params
->output_cost_cmd
);
11706 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11707 vty_out(vty
, " %pI4",
11709 vty_out(vty
, "\n");
11712 /* Hello Interval print. */
11713 if (OSPF_IF_PARAM_CONFIGURED(params
, v_hello
)
11714 && params
->v_hello
!= OSPF_HELLO_INTERVAL_DEFAULT
) {
11715 vty_out(vty
, " ip ospf hello-interval %u",
11717 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11718 vty_out(vty
, " %pI4",
11720 vty_out(vty
, "\n");
11724 /* Router Dead Interval print. */
11725 if (OSPF_IF_PARAM_CONFIGURED(params
, v_wait
)
11726 && params
->is_v_wait_set
11728 != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
) {
11729 vty_out(vty
, " ip ospf dead-interval ");
11732 if (OSPF_IF_PARAM_CONFIGURED(params
,
11735 "minimal hello-multiplier %d",
11736 params
->fast_hello
);
11738 vty_out(vty
, "%u", params
->v_wait
);
11740 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11741 vty_out(vty
, " %pI4",
11743 vty_out(vty
, "\n");
11746 /* Router Priority print. */
11747 if (OSPF_IF_PARAM_CONFIGURED(params
, priority
)
11748 && params
->priority
11749 != OSPF_ROUTER_PRIORITY_DEFAULT
) {
11750 vty_out(vty
, " ip ospf priority %u",
11752 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11753 vty_out(vty
, " %pI4",
11755 vty_out(vty
, "\n");
11758 /* Retransmit Interval print. */
11759 if (OSPF_IF_PARAM_CONFIGURED(params
,
11760 retransmit_interval
)
11761 && params
->retransmit_interval
11762 != OSPF_RETRANSMIT_INTERVAL_DEFAULT
) {
11763 vty_out(vty
, " ip ospf retransmit-interval %u",
11764 params
->retransmit_interval
);
11765 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11766 vty_out(vty
, " %pI4",
11768 vty_out(vty
, "\n");
11771 /* Transmit Delay print. */
11772 if (OSPF_IF_PARAM_CONFIGURED(params
, transmit_delay
)
11773 && params
->transmit_delay
11774 != OSPF_TRANSMIT_DELAY_DEFAULT
) {
11775 vty_out(vty
, " ip ospf transmit-delay %u",
11776 params
->transmit_delay
);
11777 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11778 vty_out(vty
, " %pI4",
11780 vty_out(vty
, "\n");
11784 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
11786 vty_out(vty
, " ip ospf %d",
11789 vty_out(vty
, " ip ospf");
11791 char buf
[INET_ADDRSTRLEN
];
11793 area_id2str(buf
, sizeof(buf
), ¶ms
->if_area
,
11794 params
->if_area_id_fmt
);
11795 vty_out(vty
, " area %s", buf
);
11796 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11797 vty_out(vty
, " %pI4",
11799 vty_out(vty
, "\n");
11803 if (params
&& params
->bfd_config
)
11804 ospf_bfd_write_config(vty
, params
);
11806 /* MTU ignore print. */
11807 if (OSPF_IF_PARAM_CONFIGURED(params
, mtu_ignore
)
11808 && params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
) {
11809 if (params
->mtu_ignore
== 0)
11810 vty_out(vty
, " no ip ospf mtu-ignore");
11812 vty_out(vty
, " ip ospf mtu-ignore");
11813 if (params
!= IF_DEF_PARAMS(ifp
) && rn
)
11814 vty_out(vty
, " %pI4",
11816 vty_out(vty
, "\n");
11819 /* LDP-Sync print */
11820 if (params
&& params
->ldp_sync_info
)
11821 ospf_ldp_sync_if_write_config(vty
, params
);
11825 rn
= route_top(IF_OIFS_PARAMS(ifp
));
11827 rn
= route_next(rn
);
11832 if (params
!= NULL
)
11837 ospf_opaque_config_write_if(vty
, ifp
);
11839 vty_endframe(vty
, NULL
);
11845 /* Configuration write function for ospfd. */
11846 static int config_write_interface(struct vty
*vty
)
11849 struct vrf
*vrf
= NULL
;
11851 /* Display all VRF aware OSPF interface configuration */
11852 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
11853 write
+= config_write_interface_one(vty
, vrf
);
11859 static int config_write_network_area(struct vty
*vty
, struct ospf
*ospf
)
11861 struct route_node
*rn
;
11862 char buf
[INET_ADDRSTRLEN
];
11864 /* `network area' print. */
11865 for (rn
= route_top(ospf
->networks
); rn
; rn
= route_next(rn
))
11867 struct ospf_network
*n
= rn
->info
;
11869 /* Create Area ID string by specified Area ID format. */
11870 if (n
->area_id_fmt
== OSPF_AREA_ID_FMT_DOTTEDQUAD
)
11871 inet_ntop(AF_INET
, &n
->area_id
, buf
,
11874 snprintf(buf
, sizeof(buf
), "%lu",
11875 (unsigned long int)ntohl(
11876 n
->area_id
.s_addr
));
11878 /* Network print. */
11879 vty_out(vty
, " network %pFX area %s\n", &rn
->p
, buf
);
11885 static int config_write_ospf_area(struct vty
*vty
, struct ospf
*ospf
)
11887 struct listnode
*node
;
11888 struct ospf_area
*area
;
11889 char buf
[INET_ADDRSTRLEN
];
11891 /* Area configuration print. */
11892 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
11893 struct route_node
*rn1
;
11895 area_id2str(buf
, sizeof(buf
), &area
->area_id
,
11896 area
->area_id_fmt
);
11898 if (area
->auth_type
!= OSPF_AUTH_NULL
) {
11899 if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
11900 vty_out(vty
, " area %s authentication\n", buf
);
11903 " area %s authentication message-digest\n",
11907 if (area
->shortcut_configured
!= OSPF_SHORTCUT_DEFAULT
)
11908 vty_out(vty
, " area %s shortcut %s\n", buf
,
11909 ospf_shortcut_mode_str
11910 [area
->shortcut_configured
]);
11912 if ((area
->external_routing
== OSPF_AREA_STUB
)
11913 || (area
->external_routing
== OSPF_AREA_NSSA
)) {
11914 if (area
->external_routing
== OSPF_AREA_STUB
) {
11915 vty_out(vty
, " area %s stub", buf
);
11916 if (area
->no_summary
)
11917 vty_out(vty
, " no-summary\n");
11918 vty_out(vty
, "\n");
11919 } else if (area
->external_routing
== OSPF_AREA_NSSA
) {
11920 switch (area
->NSSATranslatorRole
) {
11921 case OSPF_NSSA_ROLE_NEVER
:
11923 " area %s nssa translate-never\n",
11926 case OSPF_NSSA_ROLE_ALWAYS
:
11928 " area %s nssa translate-always\n",
11931 case OSPF_NSSA_ROLE_CANDIDATE
:
11932 vty_out(vty
, " area %s nssa \n", buf
);
11935 if (area
->no_summary
)
11937 " area %s nssa no-summary\n",
11939 if (area
->suppress_fa
)
11941 " area %s nssa suppress-fa\n",
11945 if (area
->default_cost
!= 1)
11946 vty_out(vty
, " area %s default-cost %d\n", buf
,
11947 area
->default_cost
);
11950 for (rn1
= route_top(area
->ranges
); rn1
; rn1
= route_next(rn1
))
11952 struct ospf_area_range
*range
= rn1
->info
;
11954 vty_out(vty
, " area %s range %pFX", buf
,
11957 if (range
->cost_config
11958 != OSPF_AREA_RANGE_COST_UNSPEC
)
11959 vty_out(vty
, " cost %d",
11960 range
->cost_config
);
11962 if (!CHECK_FLAG(range
->flags
,
11963 OSPF_AREA_RANGE_ADVERTISE
))
11964 vty_out(vty
, " not-advertise");
11966 if (CHECK_FLAG(range
->flags
,
11967 OSPF_AREA_RANGE_SUBSTITUTE
))
11968 vty_out(vty
, " substitute %pI4/%d",
11969 &range
->subst_addr
,
11970 range
->subst_masklen
);
11972 vty_out(vty
, "\n");
11975 if (EXPORT_NAME(area
))
11976 vty_out(vty
, " area %s export-list %s\n", buf
,
11977 EXPORT_NAME(area
));
11979 if (IMPORT_NAME(area
))
11980 vty_out(vty
, " area %s import-list %s\n", buf
,
11981 IMPORT_NAME(area
));
11983 if (PREFIX_NAME_IN(area
))
11984 vty_out(vty
, " area %s filter-list prefix %s in\n", buf
,
11985 PREFIX_NAME_IN(area
));
11987 if (PREFIX_NAME_OUT(area
))
11988 vty_out(vty
, " area %s filter-list prefix %s out\n",
11989 buf
, PREFIX_NAME_OUT(area
));
11995 static int config_write_ospf_nbr_nbma(struct vty
*vty
, struct ospf
*ospf
)
11997 struct ospf_nbr_nbma
*nbr_nbma
;
11998 struct route_node
*rn
;
12000 /* Static Neighbor configuration print. */
12001 for (rn
= route_top(ospf
->nbr_nbma
); rn
; rn
= route_next(rn
))
12002 if ((nbr_nbma
= rn
->info
)) {
12003 vty_out(vty
, " neighbor %pI4", &nbr_nbma
->addr
);
12005 if (nbr_nbma
->priority
12006 != OSPF_NEIGHBOR_PRIORITY_DEFAULT
)
12007 vty_out(vty
, " priority %d",
12008 nbr_nbma
->priority
);
12010 if (nbr_nbma
->v_poll
!= OSPF_POLL_INTERVAL_DEFAULT
)
12011 vty_out(vty
, " poll-interval %d",
12014 vty_out(vty
, "\n");
12020 static int config_write_virtual_link(struct vty
*vty
, struct ospf
*ospf
)
12022 struct listnode
*node
;
12023 struct ospf_vl_data
*vl_data
;
12024 const char *auth_str
;
12025 char buf
[INET_ADDRSTRLEN
];
12027 /* Virtual-Link print */
12028 for (ALL_LIST_ELEMENTS_RO(ospf
->vlinks
, node
, vl_data
)) {
12029 struct listnode
*n2
;
12030 struct crypt_key
*ck
;
12031 struct ospf_interface
*oi
;
12033 if (vl_data
!= NULL
) {
12034 area_id2str(buf
, sizeof(buf
), &vl_data
->vl_area_id
,
12035 vl_data
->vl_area_id_fmt
);
12036 oi
= vl_data
->vl_oi
;
12039 if (OSPF_IF_PARAM(oi
, v_hello
)
12040 != OSPF_HELLO_INTERVAL_DEFAULT
12041 || OSPF_IF_PARAM(oi
, v_wait
)
12042 != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
12043 || OSPF_IF_PARAM(oi
, retransmit_interval
)
12044 != OSPF_RETRANSMIT_INTERVAL_DEFAULT
12045 || OSPF_IF_PARAM(oi
, transmit_delay
)
12046 != OSPF_TRANSMIT_DELAY_DEFAULT
)
12048 " area %s virtual-link %pI4 hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d\n",
12049 buf
, &vl_data
->vl_peer
,
12050 OSPF_IF_PARAM(oi
, v_hello
),
12051 OSPF_IF_PARAM(oi
, retransmit_interval
),
12052 OSPF_IF_PARAM(oi
, transmit_delay
),
12053 OSPF_IF_PARAM(oi
, v_wait
));
12055 vty_out(vty
, " area %s virtual-link %pI4\n", buf
,
12056 &vl_data
->vl_peer
);
12058 auth_str
= interface_config_auth_str(
12059 IF_DEF_PARAMS(oi
->ifp
));
12062 " area %s virtual-link %pI4 authentication%s\n",
12063 buf
, &vl_data
->vl_peer
, auth_str
);
12065 if (IF_DEF_PARAMS(vl_data
->vl_oi
->ifp
)->auth_simple
[0]
12068 " area %s virtual-link %pI4 authentication-key %s\n",
12069 buf
, &vl_data
->vl_peer
,
12070 IF_DEF_PARAMS(vl_data
->vl_oi
->ifp
)
12073 for (ALL_LIST_ELEMENTS_RO(
12074 IF_DEF_PARAMS(vl_data
->vl_oi
->ifp
)
12078 " area %s virtual-link %pI4 message-digest-key %d md5 %s\n",
12079 buf
, &vl_data
->vl_peer
,
12080 ck
->key_id
, ck
->auth_key
);
12088 static int config_write_ospf_redistribute(struct vty
*vty
, struct ospf
*ospf
)
12092 /* redistribute print. */
12093 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++) {
12094 struct list
*red_list
;
12095 struct listnode
*node
;
12096 struct ospf_redist
*red
;
12098 red_list
= ospf
->redist
[type
];
12102 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
12103 vty_out(vty
, " redistribute %s",
12104 zebra_route_string(type
));
12106 vty_out(vty
, " %d", red
->instance
);
12108 if (red
->dmetric
.value
>= 0)
12109 vty_out(vty
, " metric %d", red
->dmetric
.value
);
12111 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
12112 vty_out(vty
, " metric-type 1");
12114 if (ROUTEMAP_NAME(red
))
12115 vty_out(vty
, " route-map %s",
12116 ROUTEMAP_NAME(red
));
12118 vty_out(vty
, "\n");
12125 static int ospf_cfg_write_helper_dis_rtr_walkcb(struct hash_bucket
*bucket
,
12128 struct advRtr
*rtr
= bucket
->data
;
12129 struct vty
*vty
= (struct vty
*)arg
;
12131 vty_out(vty
, " graceful-restart helper-only %pI4\n",
12133 return HASHWALK_CONTINUE
;
12136 static int config_write_ospf_gr_helper(struct vty
*vty
, struct ospf
*ospf
)
12138 if (ospf
->is_helper_supported
)
12139 vty_out(vty
, " graceful-restart helper-only\n");
12141 if (!ospf
->strict_lsa_check
)
12143 " no graceful-restart helper strict-lsa-checking\n");
12145 if (ospf
->only_planned_restart
)
12146 vty_out(vty
, " graceful-restart helper planned-only\n");
12148 if (ospf
->supported_grace_time
!= OSPF_MAX_GRACE_INTERVAL
)
12150 " graceful-restart helper supported-grace-time %d\n",
12151 ospf
->supported_grace_time
);
12153 if (OSPF_HELPER_ENABLE_RTR_COUNT(ospf
)) {
12154 hash_walk(ospf
->enable_rtr_list
,
12155 ospf_cfg_write_helper_dis_rtr_walkcb
, vty
);
12160 static int config_write_ospf_external_aggregator(struct vty
*vty
,
12163 struct route_node
*rn
;
12165 /* print 'summary-address A.B.C.D/M' */
12166 for (rn
= route_top(ospf
->rt_aggr_tbl
); rn
; rn
= route_next(rn
))
12168 struct ospf_external_aggr_rt
*aggr
= rn
->info
;
12170 vty_out(vty
, " summary-address %pI4/%d ",
12171 &aggr
->p
.prefix
, aggr
->p
.prefixlen
);
12173 vty_out(vty
, " tag %u ", aggr
->tag
);
12175 if (CHECK_FLAG(aggr
->flags
,
12176 OSPF_EXTERNAL_AGGRT_NO_ADVERTISE
))
12177 vty_out(vty
, " no-advertise");
12179 vty_out(vty
, "\n");
12185 static int config_write_ospf_default_metric(struct vty
*vty
, struct ospf
*ospf
)
12187 if (ospf
->default_metric
!= -1)
12188 vty_out(vty
, " default-metric %d\n", ospf
->default_metric
);
12192 static int config_write_ospf_distribute(struct vty
*vty
, struct ospf
*ospf
)
12195 struct ospf_redist
*red
;
12198 /* distribute-list print. */
12199 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
12200 if (DISTRIBUTE_NAME(ospf
, type
))
12201 vty_out(vty
, " distribute-list %s out %s\n",
12202 DISTRIBUTE_NAME(ospf
, type
),
12203 zebra_route_string(type
));
12205 /* default-information print. */
12206 if (ospf
->default_originate
!= DEFAULT_ORIGINATE_NONE
) {
12207 vty_out(vty
, " default-information originate");
12208 if (ospf
->default_originate
== DEFAULT_ORIGINATE_ALWAYS
)
12209 vty_out(vty
, " always");
12211 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
12213 if (red
->dmetric
.value
>= 0)
12214 vty_out(vty
, " metric %d",
12215 red
->dmetric
.value
);
12217 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
12218 vty_out(vty
, " metric-type 1");
12220 if (ROUTEMAP_NAME(red
))
12221 vty_out(vty
, " route-map %s",
12222 ROUTEMAP_NAME(red
));
12225 vty_out(vty
, "\n");
12232 static int config_write_ospf_distance(struct vty
*vty
, struct ospf
*ospf
)
12234 struct route_node
*rn
;
12235 struct ospf_distance
*odistance
;
12237 if (ospf
->distance_all
)
12238 vty_out(vty
, " distance %d\n", ospf
->distance_all
);
12240 if (ospf
->distance_intra
|| ospf
->distance_inter
12241 || ospf
->distance_external
) {
12242 vty_out(vty
, " distance ospf");
12244 if (ospf
->distance_intra
)
12245 vty_out(vty
, " intra-area %d", ospf
->distance_intra
);
12246 if (ospf
->distance_inter
)
12247 vty_out(vty
, " inter-area %d", ospf
->distance_inter
);
12248 if (ospf
->distance_external
)
12249 vty_out(vty
, " external %d", ospf
->distance_external
);
12251 vty_out(vty
, "\n");
12254 for (rn
= route_top(ospf
->distance_table
); rn
; rn
= route_next(rn
))
12255 if ((odistance
= rn
->info
) != NULL
) {
12256 vty_out(vty
, " distance %d %pFX %s\n",
12257 odistance
->distance
, &rn
->p
,
12258 odistance
->access_list
? odistance
->access_list
12264 static int ospf_config_write_one(struct vty
*vty
, struct ospf
*ospf
)
12266 struct vrf
*vrf
= vrf_lookup_by_id(ospf
->vrf_id
);
12267 struct interface
*ifp
;
12268 struct ospf_interface
*oi
;
12269 struct listnode
*node
= NULL
;
12272 /* `router ospf' print. */
12273 if (ospf
->instance
&& ospf
->name
) {
12274 vty_out(vty
, "router ospf %d vrf %s\n", ospf
->instance
,
12276 } else if (ospf
->instance
) {
12277 vty_out(vty
, "router ospf %d\n", ospf
->instance
);
12278 } else if (ospf
->name
) {
12279 vty_out(vty
, "router ospf vrf %s\n", ospf
->name
);
12281 vty_out(vty
, "router ospf\n");
12283 if (!ospf
->networks
) {
12288 /* Router ID print. */
12289 if (ospf
->router_id_static
.s_addr
!= INADDR_ANY
)
12290 vty_out(vty
, " ospf router-id %pI4\n",
12291 &ospf
->router_id_static
);
12293 /* ABR type print. */
12294 if (ospf
->abr_type
!= OSPF_ABR_DEFAULT
)
12295 vty_out(vty
, " ospf abr-type %s\n",
12296 ospf_abr_type_str
[ospf
->abr_type
]);
12298 /* log-adjacency-changes flag print. */
12299 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
)) {
12300 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
12301 vty_out(vty
, " log-adjacency-changes detail\n");
12302 else if (!SAVE_OSPF_LOG_ADJACENCY_CHANGES
)
12303 vty_out(vty
, " log-adjacency-changes\n");
12304 } else if (SAVE_OSPF_LOG_ADJACENCY_CHANGES
) {
12305 vty_out(vty
, " no log-adjacency-changes\n");
12308 /* RFC1583 compatibility flag print -- Compatible with CISCO
12310 if (CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
12311 vty_out(vty
, " compatible rfc1583\n");
12313 /* auto-cost reference-bandwidth configuration. */
12314 if (ospf
->ref_bandwidth
!= OSPF_DEFAULT_REF_BANDWIDTH
) {
12316 "! Important: ensure reference bandwidth is consistent across all routers\n");
12317 vty_out(vty
, " auto-cost reference-bandwidth %d\n",
12318 ospf
->ref_bandwidth
);
12321 /* SPF timers print. */
12322 if (ospf
->spf_delay
!= OSPF_SPF_DELAY_DEFAULT
12323 || ospf
->spf_holdtime
!= OSPF_SPF_HOLDTIME_DEFAULT
12324 || ospf
->spf_max_holdtime
!= OSPF_SPF_MAX_HOLDTIME_DEFAULT
)
12325 vty_out(vty
, " timers throttle spf %d %d %d\n", ospf
->spf_delay
,
12326 ospf
->spf_holdtime
, ospf
->spf_max_holdtime
);
12328 /* LSA timers print. */
12329 if (ospf
->min_ls_interval
!= OSPF_MIN_LS_INTERVAL
)
12330 vty_out(vty
, " timers throttle lsa all %d\n",
12331 ospf
->min_ls_interval
);
12332 if (ospf
->min_ls_arrival
!= OSPF_MIN_LS_ARRIVAL
)
12333 vty_out(vty
, " timers lsa min-arrival %d\n",
12334 ospf
->min_ls_arrival
);
12336 /* Write multiplier print. */
12337 if (ospf
->write_oi_count
!= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
)
12338 vty_out(vty
, " ospf write-multiplier %d\n",
12339 ospf
->write_oi_count
);
12341 if (ospf
->max_multipath
!= MULTIPATH_NUM
)
12342 vty_out(vty
, " maximum-paths %d\n", ospf
->max_multipath
);
12344 /* Max-metric router-lsa print */
12345 config_write_stub_router(vty
, ospf
);
12347 /* SPF refresh parameters print. */
12348 if (ospf
->lsa_refresh_interval
!= OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
12349 vty_out(vty
, " refresh timer %d\n", ospf
->lsa_refresh_interval
);
12351 /* Redistribute information print. */
12352 config_write_ospf_redistribute(vty
, ospf
);
12354 /* Print gr helper configs */
12355 config_write_ospf_gr_helper(vty
, ospf
);
12357 /* Print external route aggregation. */
12358 config_write_ospf_external_aggregator(vty
, ospf
);
12360 /* passive-interface print. */
12361 if (ospf
->passive_interface_default
== OSPF_IF_PASSIVE
)
12362 vty_out(vty
, " passive-interface default\n");
12364 /* proactive-arp print. */
12365 if (ospf
->proactive_arp
!= OSPF_PROACTIVE_ARP_DEFAULT
) {
12366 if (ospf
->proactive_arp
)
12367 vty_out(vty
, " proactive-arp\n");
12369 vty_out(vty
, " no proactive-arp\n");
12372 FOR_ALL_INTERFACES (vrf
, ifp
)
12373 if (OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp
),
12375 && IF_DEF_PARAMS(ifp
)->passive_interface
12376 != ospf
->passive_interface_default
) {
12377 vty_out(vty
, " %spassive-interface %s\n",
12378 IF_DEF_PARAMS(ifp
)->passive_interface
? ""
12382 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
12383 if (!OSPF_IF_PARAM_CONFIGURED(oi
->params
, passive_interface
))
12385 if (OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(oi
->ifp
),
12386 passive_interface
)) {
12387 if (oi
->params
->passive_interface
12388 == IF_DEF_PARAMS(oi
->ifp
)->passive_interface
)
12390 } else if (oi
->params
->passive_interface
12391 == ospf
->passive_interface_default
)
12394 vty_out(vty
, " %spassive-interface %s %pI4\n",
12395 oi
->params
->passive_interface
? "" : "no ",
12396 oi
->ifp
->name
, &oi
->address
->u
.prefix4
);
12399 /* TI-LFA print. */
12400 if (ospf
->ti_lfa_enabled
) {
12401 if (ospf
->ti_lfa_protection_type
== OSPF_TI_LFA_NODE_PROTECTION
)
12402 vty_out(vty
, " fast-reroute ti-lfa node-protection\n");
12404 vty_out(vty
, " fast-reroute ti-lfa\n");
12407 /* Network area print. */
12408 config_write_network_area(vty
, ospf
);
12410 /* Area config print. */
12411 config_write_ospf_area(vty
, ospf
);
12413 /* static neighbor print. */
12414 config_write_ospf_nbr_nbma(vty
, ospf
);
12416 /* Virtual-Link print. */
12417 config_write_virtual_link(vty
, ospf
);
12419 /* Default metric configuration. */
12420 config_write_ospf_default_metric(vty
, ospf
);
12422 /* Distribute-list and default-information print. */
12423 config_write_ospf_distribute(vty
, ospf
);
12425 /* Distance configuration. */
12426 config_write_ospf_distance(vty
, ospf
);
12428 ospf_opaque_config_write_router(vty
, ospf
);
12430 /* LDP-Sync print */
12431 ospf_ldp_sync_write_config(vty
, ospf
);
12437 /* OSPF configuration write function. */
12438 static int ospf_config_write(struct vty
*vty
)
12441 struct listnode
*ospf_node
= NULL
;
12444 if (listcount(om
->ospf
) == 0)
12447 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, ospf_node
, ospf
)) {
12448 /* VRF Default check if it is running.
12449 * Upon daemon start, there could be default instance
12450 * in absence of 'router ospf'/oi_running is disabled. */
12451 if (ospf
->vrf_id
== VRF_DEFAULT
&& ospf
->oi_running
)
12452 write
+= ospf_config_write_one(vty
, ospf
);
12453 /* For Non-Default VRF simply display the configuration,
12454 * even if it is not oi_running. */
12455 else if (ospf
->vrf_id
!= VRF_DEFAULT
)
12456 write
+= ospf_config_write_one(vty
, ospf
);
12461 void ospf_vty_show_init(void)
12463 /* "show ip ospf" commands. */
12464 install_element(VIEW_NODE
, &show_ip_ospf_cmd
);
12466 install_element(VIEW_NODE
, &show_ip_ospf_instance_cmd
);
12468 /* "show ip ospf database" commands. */
12469 install_element(VIEW_NODE
, &show_ip_ospf_database_cmd
);
12470 install_element(VIEW_NODE
, &show_ip_ospf_database_max_cmd
);
12471 install_element(VIEW_NODE
,
12472 &show_ip_ospf_database_type_adv_router_cmd
);
12473 install_element(VIEW_NODE
,
12474 &show_ip_ospf_instance_database_type_adv_router_cmd
);
12475 install_element(VIEW_NODE
, &show_ip_ospf_instance_database_cmd
);
12476 install_element(VIEW_NODE
, &show_ip_ospf_instance_database_max_cmd
);
12478 /* "show ip ospf interface" commands. */
12479 install_element(VIEW_NODE
, &show_ip_ospf_interface_cmd
);
12481 install_element(VIEW_NODE
, &show_ip_ospf_instance_interface_cmd
);
12482 /* "show ip ospf interface traffic */
12483 install_element(VIEW_NODE
, &show_ip_ospf_interface_traffic_cmd
);
12485 /* "show ip ospf neighbor" commands. */
12486 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_int_detail_cmd
);
12487 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_int_cmd
);
12488 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_id_cmd
);
12489 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_detail_all_cmd
);
12490 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_detail_cmd
);
12491 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_cmd
);
12492 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_all_cmd
);
12494 install_element(VIEW_NODE
,
12495 &show_ip_ospf_instance_neighbor_int_detail_cmd
);
12496 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_cmd
);
12497 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_id_cmd
);
12498 install_element(VIEW_NODE
,
12499 &show_ip_ospf_instance_neighbor_detail_all_cmd
);
12500 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_cmd
);
12501 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_cmd
);
12502 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_all_cmd
);
12504 /* "show ip ospf route" commands. */
12505 install_element(VIEW_NODE
, &show_ip_ospf_route_cmd
);
12506 install_element(VIEW_NODE
, &show_ip_ospf_border_routers_cmd
);
12508 install_element(VIEW_NODE
, &show_ip_ospf_instance_route_cmd
);
12509 install_element(VIEW_NODE
, &show_ip_ospf_instance_border_routers_cmd
);
12511 /* "show ip ospf vrfs" commands. */
12512 install_element(VIEW_NODE
, &show_ip_ospf_vrfs_cmd
);
12514 /* "show ip ospf gr-helper details" command */
12515 install_element(VIEW_NODE
, &show_ip_ospf_gr_helper_cmd
);
12517 /* "show ip ospf summary-address" command */
12518 install_element(VIEW_NODE
, &show_ip_ospf_external_aggregator_cmd
);
12521 static int config_write_interface(struct vty
*vty
);
12522 /* ospfd's interface node. */
12523 static struct cmd_node interface_node
= {
12524 .name
= "interface",
12525 .node
= INTERFACE_NODE
,
12526 .parent_node
= CONFIG_NODE
,
12527 .prompt
= "%s(config-if)# ",
12528 .config_write
= config_write_interface
,
12531 /* Initialization of OSPF interface. */
12532 static void ospf_vty_if_init(void)
12534 /* Install interface node. */
12535 install_node(&interface_node
);
12538 /* "ip ospf authentication" commands. */
12539 install_element(INTERFACE_NODE
, &ip_ospf_authentication_args_addr_cmd
);
12540 install_element(INTERFACE_NODE
, &ip_ospf_authentication_addr_cmd
);
12541 install_element(INTERFACE_NODE
,
12542 &no_ip_ospf_authentication_args_addr_cmd
);
12543 install_element(INTERFACE_NODE
, &no_ip_ospf_authentication_addr_cmd
);
12544 install_element(INTERFACE_NODE
, &ip_ospf_authentication_key_addr_cmd
);
12545 install_element(INTERFACE_NODE
,
12546 &no_ip_ospf_authentication_key_authkey_addr_cmd
);
12547 install_element(INTERFACE_NODE
,
12548 &no_ospf_authentication_key_authkey_addr_cmd
);
12550 /* "ip ospf message-digest-key" commands. */
12551 install_element(INTERFACE_NODE
, &ip_ospf_message_digest_key_cmd
);
12552 install_element(INTERFACE_NODE
, &no_ip_ospf_message_digest_key_cmd
);
12554 /* "ip ospf cost" commands. */
12555 install_element(INTERFACE_NODE
, &ip_ospf_cost_cmd
);
12556 install_element(INTERFACE_NODE
, &no_ip_ospf_cost_cmd
);
12558 /* "ip ospf mtu-ignore" commands. */
12559 install_element(INTERFACE_NODE
, &ip_ospf_mtu_ignore_addr_cmd
);
12560 install_element(INTERFACE_NODE
, &no_ip_ospf_mtu_ignore_addr_cmd
);
12562 /* "ip ospf dead-interval" commands. */
12563 install_element(INTERFACE_NODE
, &ip_ospf_dead_interval_cmd
);
12564 install_element(INTERFACE_NODE
,
12565 &ip_ospf_dead_interval_minimal_addr_cmd
);
12566 install_element(INTERFACE_NODE
, &no_ip_ospf_dead_interval_cmd
);
12568 /* "ip ospf hello-interval" commands. */
12569 install_element(INTERFACE_NODE
, &ip_ospf_hello_interval_cmd
);
12570 install_element(INTERFACE_NODE
, &no_ip_ospf_hello_interval_cmd
);
12572 /* "ip ospf network" commands. */
12573 install_element(INTERFACE_NODE
, &ip_ospf_network_cmd
);
12574 install_element(INTERFACE_NODE
, &no_ip_ospf_network_cmd
);
12576 /* "ip ospf priority" commands. */
12577 install_element(INTERFACE_NODE
, &ip_ospf_priority_cmd
);
12578 install_element(INTERFACE_NODE
, &no_ip_ospf_priority_cmd
);
12580 /* "ip ospf retransmit-interval" commands. */
12581 install_element(INTERFACE_NODE
, &ip_ospf_retransmit_interval_addr_cmd
);
12582 install_element(INTERFACE_NODE
,
12583 &no_ip_ospf_retransmit_interval_addr_cmd
);
12585 /* "ip ospf transmit-delay" commands. */
12586 install_element(INTERFACE_NODE
, &ip_ospf_transmit_delay_addr_cmd
);
12587 install_element(INTERFACE_NODE
, &no_ip_ospf_transmit_delay_addr_cmd
);
12589 /* "ip ospf area" commands. */
12590 install_element(INTERFACE_NODE
, &ip_ospf_area_cmd
);
12591 install_element(INTERFACE_NODE
, &no_ip_ospf_area_cmd
);
12593 /* These commands are compatibitliy for previous version. */
12594 install_element(INTERFACE_NODE
, &ospf_authentication_key_cmd
);
12595 install_element(INTERFACE_NODE
, &ospf_message_digest_key_cmd
);
12596 install_element(INTERFACE_NODE
, &no_ospf_message_digest_key_cmd
);
12597 install_element(INTERFACE_NODE
, &ospf_dead_interval_cmd
);
12598 install_element(INTERFACE_NODE
, &no_ospf_dead_interval_cmd
);
12599 install_element(INTERFACE_NODE
, &ospf_hello_interval_cmd
);
12600 install_element(INTERFACE_NODE
, &no_ospf_hello_interval_cmd
);
12601 install_element(INTERFACE_NODE
, &ospf_cost_cmd
);
12602 install_element(INTERFACE_NODE
, &no_ospf_cost_cmd
);
12603 install_element(INTERFACE_NODE
, &ospf_network_cmd
);
12604 install_element(INTERFACE_NODE
, &no_ospf_network_cmd
);
12605 install_element(INTERFACE_NODE
, &ospf_priority_cmd
);
12606 install_element(INTERFACE_NODE
, &no_ospf_priority_cmd
);
12607 install_element(INTERFACE_NODE
, &ospf_retransmit_interval_cmd
);
12608 install_element(INTERFACE_NODE
, &no_ospf_retransmit_interval_cmd
);
12609 install_element(INTERFACE_NODE
, &ospf_transmit_delay_cmd
);
12610 install_element(INTERFACE_NODE
, &no_ospf_transmit_delay_cmd
);
12613 static void ospf_vty_zebra_init(void)
12615 install_element(OSPF_NODE
, &ospf_redistribute_source_cmd
);
12616 install_element(OSPF_NODE
, &no_ospf_redistribute_source_cmd
);
12617 install_element(OSPF_NODE
, &ospf_redistribute_instance_source_cmd
);
12618 install_element(OSPF_NODE
, &no_ospf_redistribute_instance_source_cmd
);
12620 install_element(OSPF_NODE
, &ospf_distribute_list_out_cmd
);
12621 install_element(OSPF_NODE
, &no_ospf_distribute_list_out_cmd
);
12623 install_element(OSPF_NODE
, &ospf_default_information_originate_cmd
);
12624 install_element(OSPF_NODE
, &no_ospf_default_information_originate_cmd
);
12626 install_element(OSPF_NODE
, &ospf_default_metric_cmd
);
12627 install_element(OSPF_NODE
, &no_ospf_default_metric_cmd
);
12629 install_element(OSPF_NODE
, &ospf_distance_cmd
);
12630 install_element(OSPF_NODE
, &no_ospf_distance_cmd
);
12631 install_element(OSPF_NODE
, &no_ospf_distance_ospf_cmd
);
12632 install_element(OSPF_NODE
, &ospf_distance_ospf_cmd
);
12634 /*Ospf garcefull restart helper configurations */
12635 install_element(OSPF_NODE
, &ospf_gr_helper_enable_cmd
);
12636 install_element(OSPF_NODE
, &no_ospf_gr_helper_enable_cmd
);
12637 install_element(OSPF_NODE
, &ospf_gr_helper_enable_lsacheck_cmd
);
12638 install_element(OSPF_NODE
, &no_ospf_gr_helper_enable_lsacheck_cmd
);
12639 install_element(OSPF_NODE
, &ospf_gr_helper_supported_grace_time_cmd
);
12640 install_element(OSPF_NODE
, &no_ospf_gr_helper_supported_grace_time_cmd
);
12641 install_element(OSPF_NODE
, &ospf_gr_helper_planned_only_cmd
);
12642 install_element(OSPF_NODE
, &no_ospf_gr_helper_planned_only_cmd
);
12644 /* External LSA summarisation config commands.*/
12645 install_element(OSPF_NODE
, &ospf_external_route_aggregation_cmd
);
12646 install_element(OSPF_NODE
, &no_ospf_external_route_aggregation_cmd
);
12647 install_element(OSPF_NODE
,
12648 &ospf_external_route_aggregation_no_adrvertise_cmd
);
12649 install_element(OSPF_NODE
,
12650 &no_ospf_external_route_aggregation_no_adrvertise_cmd
);
12651 install_element(OSPF_NODE
, &ospf_route_aggregation_timer_cmd
);
12652 install_element(OSPF_NODE
, &no_ospf_route_aggregation_timer_cmd
);
12655 static int ospf_config_write(struct vty
*vty
);
12656 static struct cmd_node ospf_node
= {
12659 .parent_node
= CONFIG_NODE
,
12660 .prompt
= "%s(config-router)# ",
12661 .config_write
= ospf_config_write
,
12664 static void ospf_interface_clear(struct interface
*ifp
)
12666 if (!if_is_operative(ifp
))
12669 if (IS_DEBUG_OSPF(ism
, ISM_EVENTS
))
12670 zlog_debug("ISM[%s]: clear by reset", ifp
->name
);
12672 ospf_if_reset(ifp
);
12675 DEFUN (clear_ip_ospf_interface
,
12676 clear_ip_ospf_interface_cmd
,
12677 "clear ip ospf [vrf NAME] interface [IFNAME]",
12680 "OSPF information\n"
12682 "Interface information\n"
12683 "Interface name\n")
12685 int idx_ifname
= 0;
12687 struct interface
*ifp
;
12688 struct listnode
*node
;
12689 struct ospf
*ospf
= NULL
;
12690 char *vrf_name
= NULL
;
12691 vrf_id_t vrf_id
= VRF_DEFAULT
;
12692 struct vrf
*vrf
= NULL
;
12694 if (argv_find(argv
, argc
, "vrf", &idx_vrf
))
12695 vrf_name
= argv
[idx_vrf
+ 1]->arg
;
12696 if (vrf_name
&& strmatch(vrf_name
, VRF_DEFAULT_NAME
))
12699 vrf
= vrf_lookup_by_name(vrf_name
);
12701 vrf_id
= vrf
->vrf_id
;
12703 if (!argv_find(argv
, argc
, "IFNAME", &idx_ifname
)) {
12704 /* Clear all the ospfv2 interfaces. */
12705 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
12706 if (vrf_id
!= ospf
->vrf_id
)
12709 vrf
= vrf_lookup_by_id(ospf
->vrf_id
);
12710 FOR_ALL_INTERFACES (vrf
, ifp
)
12711 ospf_interface_clear(ifp
);
12714 /* Interface name is specified. */
12715 ifp
= if_lookup_by_name(argv
[idx_ifname
]->arg
, vrf_id
);
12717 vty_out(vty
, "No such interface name\n");
12719 ospf_interface_clear(ifp
);
12722 return CMD_SUCCESS
;
12725 void ospf_vty_clear_init(void)
12727 install_element(ENABLE_NODE
, &clear_ip_ospf_interface_cmd
);
12728 install_element(ENABLE_NODE
, &clear_ip_ospf_process_cmd
);
12729 install_element(ENABLE_NODE
, &clear_ip_ospf_neighbor_cmd
);
12733 /* Install OSPF related vty commands. */
12734 void ospf_vty_init(void)
12736 /* Install ospf top node. */
12737 install_node(&ospf_node
);
12739 /* "router ospf" commands. */
12740 install_element(CONFIG_NODE
, &router_ospf_cmd
);
12741 install_element(CONFIG_NODE
, &no_router_ospf_cmd
);
12744 install_default(OSPF_NODE
);
12746 /* "ospf router-id" commands. */
12747 install_element(OSPF_NODE
, &ospf_router_id_cmd
);
12748 install_element(OSPF_NODE
, &ospf_router_id_old_cmd
);
12749 install_element(OSPF_NODE
, &no_ospf_router_id_cmd
);
12751 /* "passive-interface" commands. */
12752 install_element(OSPF_NODE
, &ospf_passive_interface_addr_cmd
);
12753 install_element(OSPF_NODE
, &no_ospf_passive_interface_addr_cmd
);
12755 /* "ospf abr-type" commands. */
12756 install_element(OSPF_NODE
, &ospf_abr_type_cmd
);
12757 install_element(OSPF_NODE
, &no_ospf_abr_type_cmd
);
12759 /* "ospf log-adjacency-changes" commands. */
12760 install_element(OSPF_NODE
, &ospf_log_adjacency_changes_cmd
);
12761 install_element(OSPF_NODE
, &ospf_log_adjacency_changes_detail_cmd
);
12762 install_element(OSPF_NODE
, &no_ospf_log_adjacency_changes_cmd
);
12763 install_element(OSPF_NODE
, &no_ospf_log_adjacency_changes_detail_cmd
);
12765 /* "ospf rfc1583-compatible" commands. */
12766 install_element(OSPF_NODE
, &ospf_compatible_rfc1583_cmd
);
12767 install_element(OSPF_NODE
, &no_ospf_compatible_rfc1583_cmd
);
12768 install_element(OSPF_NODE
, &ospf_rfc1583_flag_cmd
);
12769 install_element(OSPF_NODE
, &no_ospf_rfc1583_flag_cmd
);
12771 /* "network area" commands. */
12772 install_element(OSPF_NODE
, &ospf_network_area_cmd
);
12773 install_element(OSPF_NODE
, &no_ospf_network_area_cmd
);
12775 /* "area authentication" commands. */
12776 install_element(OSPF_NODE
,
12777 &ospf_area_authentication_message_digest_cmd
);
12778 install_element(OSPF_NODE
, &ospf_area_authentication_cmd
);
12779 install_element(OSPF_NODE
, &no_ospf_area_authentication_cmd
);
12781 /* "area range" commands. */
12782 install_element(OSPF_NODE
, &ospf_area_range_cmd
);
12783 install_element(OSPF_NODE
, &ospf_area_range_cost_cmd
);
12784 install_element(OSPF_NODE
, &ospf_area_range_not_advertise_cmd
);
12785 install_element(OSPF_NODE
, &no_ospf_area_range_cmd
);
12786 install_element(OSPF_NODE
, &ospf_area_range_substitute_cmd
);
12787 install_element(OSPF_NODE
, &no_ospf_area_range_substitute_cmd
);
12789 /* "area virtual-link" commands. */
12790 install_element(OSPF_NODE
, &ospf_area_vlink_cmd
);
12791 install_element(OSPF_NODE
, &ospf_area_vlink_intervals_cmd
);
12792 install_element(OSPF_NODE
, &no_ospf_area_vlink_cmd
);
12793 install_element(OSPF_NODE
, &no_ospf_area_vlink_intervals_cmd
);
12796 /* "area stub" commands. */
12797 install_element(OSPF_NODE
, &ospf_area_stub_no_summary_cmd
);
12798 install_element(OSPF_NODE
, &ospf_area_stub_cmd
);
12799 install_element(OSPF_NODE
, &no_ospf_area_stub_no_summary_cmd
);
12800 install_element(OSPF_NODE
, &no_ospf_area_stub_cmd
);
12802 /* "area nssa" commands. */
12803 install_element(OSPF_NODE
, &ospf_area_nssa_cmd
);
12804 install_element(OSPF_NODE
, &ospf_area_nssa_translate_cmd
);
12805 install_element(OSPF_NODE
, &ospf_area_nssa_no_summary_cmd
);
12806 install_element(OSPF_NODE
, &no_ospf_area_nssa_no_summary_cmd
);
12807 install_element(OSPF_NODE
, &ospf_area_nssa_suppress_fa_cmd
);
12808 install_element(OSPF_NODE
, &no_ospf_area_nssa_suppress_fa_cmd
);
12809 install_element(OSPF_NODE
, &no_ospf_area_nssa_cmd
);
12811 install_element(OSPF_NODE
, &ospf_area_default_cost_cmd
);
12812 install_element(OSPF_NODE
, &no_ospf_area_default_cost_cmd
);
12814 install_element(OSPF_NODE
, &ospf_area_shortcut_cmd
);
12815 install_element(OSPF_NODE
, &no_ospf_area_shortcut_cmd
);
12817 install_element(OSPF_NODE
, &ospf_area_export_list_cmd
);
12818 install_element(OSPF_NODE
, &no_ospf_area_export_list_cmd
);
12820 install_element(OSPF_NODE
, &ospf_area_filter_list_cmd
);
12821 install_element(OSPF_NODE
, &no_ospf_area_filter_list_cmd
);
12823 install_element(OSPF_NODE
, &ospf_area_import_list_cmd
);
12824 install_element(OSPF_NODE
, &no_ospf_area_import_list_cmd
);
12826 /* SPF timer commands */
12827 install_element(OSPF_NODE
, &ospf_timers_throttle_spf_cmd
);
12828 install_element(OSPF_NODE
, &no_ospf_timers_throttle_spf_cmd
);
12830 /* LSA timers commands */
12831 install_element(OSPF_NODE
, &ospf_timers_min_ls_interval_cmd
);
12832 install_element(OSPF_NODE
, &no_ospf_timers_min_ls_interval_cmd
);
12833 install_element(OSPF_NODE
, &ospf_timers_lsa_min_arrival_cmd
);
12834 install_element(OSPF_NODE
, &no_ospf_timers_lsa_min_arrival_cmd
);
12836 /* refresh timer commands */
12837 install_element(OSPF_NODE
, &ospf_refresh_timer_cmd
);
12838 install_element(OSPF_NODE
, &no_ospf_refresh_timer_val_cmd
);
12840 /* max-metric commands */
12841 install_element(OSPF_NODE
, &ospf_max_metric_router_lsa_admin_cmd
);
12842 install_element(OSPF_NODE
, &no_ospf_max_metric_router_lsa_admin_cmd
);
12843 install_element(OSPF_NODE
, &ospf_max_metric_router_lsa_startup_cmd
);
12844 install_element(OSPF_NODE
, &no_ospf_max_metric_router_lsa_startup_cmd
);
12845 install_element(OSPF_NODE
, &ospf_max_metric_router_lsa_shutdown_cmd
);
12846 install_element(OSPF_NODE
, &no_ospf_max_metric_router_lsa_shutdown_cmd
);
12848 /* reference bandwidth commands */
12849 install_element(OSPF_NODE
, &ospf_auto_cost_reference_bandwidth_cmd
);
12850 install_element(OSPF_NODE
, &no_ospf_auto_cost_reference_bandwidth_cmd
);
12852 /* "neighbor" commands. */
12853 install_element(OSPF_NODE
, &ospf_neighbor_cmd
);
12854 install_element(OSPF_NODE
, &ospf_neighbor_poll_interval_cmd
);
12855 install_element(OSPF_NODE
, &no_ospf_neighbor_cmd
);
12856 install_element(OSPF_NODE
, &no_ospf_neighbor_poll_cmd
);
12858 /* write multiplier commands */
12859 install_element(OSPF_NODE
, &ospf_write_multiplier_cmd
);
12860 install_element(OSPF_NODE
, &write_multiplier_cmd
);
12861 install_element(OSPF_NODE
, &no_ospf_write_multiplier_cmd
);
12862 install_element(OSPF_NODE
, &no_write_multiplier_cmd
);
12864 /* "proactive-arp" commands. */
12865 install_element(OSPF_NODE
, &ospf_proactive_arp_cmd
);
12866 install_element(OSPF_NODE
, &no_ospf_proactive_arp_cmd
);
12868 /* TI-LFA commands */
12869 install_element(OSPF_NODE
, &ospf_ti_lfa_cmd
);
12870 install_element(OSPF_NODE
, &no_ospf_ti_lfa_cmd
);
12872 /* Max path configurations */
12873 install_element(OSPF_NODE
, &ospf_max_multipath_cmd
);
12874 install_element(OSPF_NODE
, &no_ospf_max_multipath_cmd
);
12876 /* Init interface related vty commands. */
12877 ospf_vty_if_init();
12879 /* Init zebra related vty commands. */
12880 ospf_vty_zebra_init();