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 "ospfd/ospfd.h"
39 #include "ospfd/ospf_asbr.h"
40 #include "ospfd/ospf_lsa.h"
41 #include "ospfd/ospf_lsdb.h"
42 #include "ospfd/ospf_ism.h"
43 #include "ospfd/ospf_interface.h"
44 #include "ospfd/ospf_nsm.h"
45 #include "ospfd/ospf_neighbor.h"
46 #include "ospfd/ospf_flood.h"
47 #include "ospfd/ospf_abr.h"
48 #include "ospfd/ospf_spf.h"
49 #include "ospfd/ospf_route.h"
50 #include "ospfd/ospf_zebra.h"
51 /*#include "ospfd/ospf_routemap.h" */
52 #include "ospfd/ospf_vty.h"
53 #include "ospfd/ospf_dump.h"
54 #include "ospfd/ospf_bfd.h"
56 static const char *ospf_network_type_str
[] = {
57 "Null", "POINTOPOINT", "BROADCAST", "NBMA", "POINTOMULTIPOINT",
58 "VIRTUALLINK", "LOOPBACK"};
60 /* Utility functions. */
61 int str2area_id(const char *str
, struct in_addr
*area_id
, int *area_id_fmt
)
65 area_id
->s_addr
= htonl(strtoul(str
, &ep
, 10));
66 if (*ep
&& !inet_aton(str
, area_id
))
70 *ep
? OSPF_AREA_ID_FMT_DOTTEDQUAD
: OSPF_AREA_ID_FMT_DECIMAL
;
75 void area_id2str(char *buf
, int length
, struct in_addr
*area_id
,
78 memset(buf
, 0, length
);
80 if (area_id_fmt
== OSPF_AREA_ID_FMT_DOTTEDQUAD
)
81 strncpy(buf
, inet_ntoa(*area_id
), length
);
83 sprintf(buf
, "%lu", (unsigned long)ntohl(area_id
->s_addr
));
86 static int str2metric(const char *str
, int *metric
)
92 *metric
= strtol(str
, NULL
, 10);
93 if (*metric
< 0 && *metric
> 16777214) {
94 /* vty_out (vty, "OSPF metric value is invalid\n"); */
101 static int str2metric_type(const char *str
, int *metric_type
)
107 if (strncmp(str
, "1", 1) == 0)
108 *metric_type
= EXTERNAL_METRIC_TYPE_1
;
109 else if (strncmp(str
, "2", 1) == 0)
110 *metric_type
= EXTERNAL_METRIC_TYPE_2
;
117 int ospf_oi_count(struct interface
*ifp
)
119 struct route_node
*rn
;
122 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
))
129 #define OSPF_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf) \
130 if (argv_find(argv, argc, "vrf", &idx_vrf)) { \
131 vrf_name = argv[idx_vrf + 1]->arg; \
132 all_vrf = strmatch(vrf_name, "all"); \
135 static struct ospf
*ospf_cmd_lookup_ospf(struct vty
*vty
,
136 struct cmd_token
*argv
[],
141 struct ospf
*ospf
= NULL
;
142 int idx_vrf
= 0, idx_inst
= 0;
143 const char *vrf_name
= NULL
;
146 if (argv_find(argv
, argc
, "(1-65535)", &idx_inst
))
147 *instance
= strtoul(argv
[idx_inst
]->arg
, NULL
, 10);
149 if (argv_find(argv
, argc
, "vrf", &idx_vrf
)) {
150 vrf_name
= argv
[idx_vrf
+ 1]->arg
;
152 /* Allocate VRF aware instance */
153 ospf
= ospf_get(*instance
, vrf_name
);
155 ospf
= ospf_lookup_by_inst_name(*instance
, vrf_name
);
159 ospf
= ospf_get(*instance
, NULL
);
161 ospf
= ospf_lookup_instance(*instance
);
168 static void ospf_show_vrf_name(struct ospf
*ospf
, struct vty
*vty
,
169 json_object
*json
, u_char use_vrf
)
173 if (ospf
->vrf_id
== VRF_DEFAULT
)
174 json_object_string_add(json
, "vrfName",
177 json_object_string_add(json
, "vrfName",
179 json_object_int_add(json
, "vrfId", ospf
->vrf_id
);
181 if (ospf
->vrf_id
== VRF_DEFAULT
)
182 vty_out(vty
, "VRF Name: %s\n", "default");
184 vty_out(vty
, "VRF Name: %s\n", ospf
->name
);
189 #ifndef VTYSH_EXTRACT_PL
190 #include "ospfd/ospf_vty_clippy.c"
193 DEFUN_NOSH (router_ospf
,
195 "router ospf [{(1-65535)|vrf NAME}]",
196 "Enable a routing process\n"
197 "Start OSPF configuration\n"
201 struct ospf
*ospf
= NULL
;
202 int ret
= CMD_SUCCESS
;
203 u_short instance
= 0;
204 struct vrf
*vrf
= NULL
;
205 struct route_node
*rn
;
206 struct interface
*ifp
;
208 ospf
= ospf_cmd_lookup_ospf(vty
, argv
, argc
, 1, &instance
);
210 return CMD_WARNING_CONFIG_FAILED
;
212 /* The following logic to set the vty qobj index is in place to be able
213 to ignore the commands which dont belong to this instance. */
214 if (ospf
->instance
!= instance
) {
215 VTY_PUSH_CONTEXT_NULL(OSPF_NODE
);
216 ret
= CMD_NOT_MY_INSTANCE
;
218 if (ospf
->vrf_id
!= VRF_UNKNOWN
)
219 ospf
->oi_running
= 1;
220 if (IS_DEBUG_OSPF_EVENT
)
221 zlog_debug("Config command 'router ospf %d' received, vrf %s id %d oi_running %u",
222 instance
, ospf
->name
? ospf
->name
: "NIL",
223 ospf
->vrf_id
, ospf
->oi_running
);
224 VTY_PUSH_CONTEXT(OSPF_NODE
, ospf
);
226 /* Activate 'ip ospf area x' configured interfaces for given
227 * vrf. Activate area on vrf x aware interfaces.
228 * vrf_enable callback calls router_id_update which
229 * internally will call ospf_if_update to trigger
232 vrf
= vrf_lookup_by_id(ospf
->vrf_id
);
234 FOR_ALL_INTERFACES (vrf
, ifp
) {
235 struct ospf_if_params
*params
;
237 params
= IF_DEF_PARAMS(ifp
);
238 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
239 for (rn
= route_top(ospf
->networks
); rn
;
240 rn
= route_next(rn
)) {
241 if (rn
->info
!= NULL
) {
243 "Interface %s has area config but please remove all network commands first.\n",
248 ospf_interface_area_set(ospf
, ifp
);
249 ospf
->if_ospf_cli_count
++;
253 ospf_router_id_update(ospf
);
259 DEFUN (no_router_ospf
,
261 "no router ospf [{(1-65535)|vrf NAME}]",
263 "Enable a routing process\n"
264 "Start OSPF configuration\n"
269 u_short instance
= 0;
271 ospf
= ospf_cmd_lookup_ospf(vty
, argv
, argc
, 0, &instance
);
274 return CMD_NOT_MY_INSTANCE
;
284 DEFPY (ospf_router_id
,
286 "ospf router-id A.B.C.D",
287 "OSPF specific commands\n"
288 "router-id for the OSPF process\n"
289 "OSPF router-id in IP address format\n")
291 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
293 struct listnode
*node
;
294 struct ospf_area
*area
;
296 ospf
->router_id_static
= router_id
;
298 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
))
299 if (area
->full_nbrs
) {
301 "For this router-id change to take effect,"
302 " save config and restart ospfd\n");
306 ospf_router_id_update(ospf
);
311 DEFUN_HIDDEN (ospf_router_id_old
,
312 ospf_router_id_old_cmd
,
314 "router-id for the OSPF process\n"
315 "OSPF router-id in IP address format\n")
317 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
319 struct listnode
*node
;
320 struct ospf_area
*area
;
321 struct in_addr router_id
;
324 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &router_id
);
326 vty_out(vty
, "Please specify Router ID by A.B.C.D\n");
327 return CMD_WARNING_CONFIG_FAILED
;
330 ospf
->router_id_static
= router_id
;
332 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
))
333 if (area
->full_nbrs
) {
335 "For this router-id change to take effect,"
336 " save config and restart ospfd\n");
340 ospf_router_id_update(ospf
);
345 DEFPY (no_ospf_router_id
,
346 no_ospf_router_id_cmd
,
347 "no ospf router-id [A.B.C.D]",
349 "OSPF specific commands\n"
350 "router-id for the OSPF process\n"
351 "OSPF router-id in IP address format\n")
353 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
354 struct listnode
*node
;
355 struct ospf_area
*area
;
358 if (!IPV4_ADDR_SAME(&ospf
->router_id_static
, &router_id
)) {
359 vty_out(vty
, "%% OSPF router-id doesn't match\n");
360 return CMD_WARNING_CONFIG_FAILED
;
364 ospf
->router_id_static
.s_addr
= 0;
366 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
))
367 if (area
->full_nbrs
) {
369 "For this router-id change to take effect,"
370 " save config and restart ospfd\n");
374 ospf_router_id_update(ospf
);
380 static void ospf_passive_interface_default(struct ospf
*ospf
, u_char newval
)
382 struct vrf
*vrf
= vrf_lookup_by_id(ospf
->vrf_id
);
384 struct interface
*ifp
;
385 struct ospf_interface
*oi
;
387 ospf
->passive_interface_default
= newval
;
389 FOR_ALL_INTERFACES (vrf
, ifp
) {
390 if (ifp
&& OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp
),
392 UNSET_IF_PARAM(IF_DEF_PARAMS(ifp
), passive_interface
);
394 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, ln
, oi
)) {
395 if (OSPF_IF_PARAM_CONFIGURED(oi
->params
, passive_interface
))
396 UNSET_IF_PARAM(oi
->params
, passive_interface
);
397 /* update multicast memberships */
398 ospf_if_set_multicast(oi
);
402 static void ospf_passive_interface_update_addr(struct ospf
*ospf
,
403 struct interface
*ifp
,
404 struct ospf_if_params
*params
,
410 params
->passive_interface
= value
;
411 if (params
!= IF_DEF_PARAMS(ifp
)) {
412 if (OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp
),
414 dflt
= IF_DEF_PARAMS(ifp
)->passive_interface
;
416 dflt
= ospf
->passive_interface_default
;
419 SET_IF_PARAM(params
, passive_interface
);
421 UNSET_IF_PARAM(params
, passive_interface
);
423 ospf_free_if_params(ifp
, addr
);
424 ospf_if_update_params(ifp
, addr
);
428 static void ospf_passive_interface_update(struct ospf
*ospf
,
429 struct interface
*ifp
,
430 struct ospf_if_params
*params
,
433 params
->passive_interface
= value
;
434 if (params
== IF_DEF_PARAMS(ifp
)) {
435 if (value
!= ospf
->passive_interface_default
)
436 SET_IF_PARAM(params
, passive_interface
);
438 UNSET_IF_PARAM(params
, passive_interface
);
442 DEFUN (ospf_passive_interface
,
443 ospf_passive_interface_addr_cmd
,
444 "passive-interface <IFNAME [A.B.C.D]|default>",
445 "Suppress routing updates on an interface\n"
448 "Suppress routing updates on interfaces by default\n")
450 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
452 struct interface
*ifp
;
453 struct in_addr addr
= {.s_addr
= INADDR_ANY
};
455 struct ospf_if_params
*params
;
456 struct route_node
*rn
;
458 if (strmatch(argv
[1]->text
, "default")) {
459 ospf_passive_interface_default(ospf
, OSPF_IF_PASSIVE
);
463 ifp
= if_get_by_name(argv
[1]->arg
, ospf
->vrf_id
, 0);
465 vty_out(vty
, "interface %s not found.\n",
466 (char *)argv
[1]->arg
);
470 params
= IF_DEF_PARAMS(ifp
);
473 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
476 "Please specify interface address by A.B.C.D\n");
477 return CMD_WARNING_CONFIG_FAILED
;
480 params
= ospf_get_if_params(ifp
, addr
);
481 ospf_if_update_params(ifp
, addr
);
482 ospf_passive_interface_update_addr(ospf
, ifp
, params
,
483 OSPF_IF_PASSIVE
, addr
);
486 ospf_passive_interface_update(ospf
, ifp
, params
, OSPF_IF_PASSIVE
);
488 /* XXX We should call ospf_if_set_multicast on exactly those
489 * interfaces for which the passive property changed. It is too much
490 * work to determine this set, so we do this for every interface.
491 * This is safe and reasonable because ospf_if_set_multicast uses a
492 * record of joined groups to avoid systems calls if the desired
493 * memberships match the current memership.
496 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
497 struct ospf_interface
*oi
= rn
->info
;
499 if (oi
&& (OSPF_IF_PARAM(oi
, passive_interface
)
501 ospf_if_set_multicast(oi
);
504 * XXX It is not clear what state transitions the interface needs to
505 * undergo when going from active to passive. Fixing this will
506 * require precise identification of interfaces having such a
513 DEFUN (no_ospf_passive_interface
,
514 no_ospf_passive_interface_addr_cmd
,
515 "no passive-interface <IFNAME [A.B.C.D]|default>",
517 "Allow routing updates on an interface\n"
520 "Allow routing updates on interfaces by default\n")
522 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
524 struct interface
*ifp
;
525 struct in_addr addr
= {.s_addr
= INADDR_ANY
};
526 struct ospf_if_params
*params
;
528 struct route_node
*rn
;
530 if (strmatch(argv
[2]->text
, "default")) {
531 ospf_passive_interface_default(ospf
, OSPF_IF_ACTIVE
);
535 ifp
= if_get_by_name(argv
[2]->arg
, ospf
->vrf_id
, 0);
537 vty_out(vty
, "interface %s not found.\n",
538 (char *)argv
[1]->arg
);
542 params
= IF_DEF_PARAMS(ifp
);
545 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
548 "Please specify interface address by A.B.C.D\n");
549 return CMD_WARNING_CONFIG_FAILED
;
552 params
= ospf_lookup_if_params(ifp
, addr
);
555 ospf_passive_interface_update_addr(ospf
, ifp
, params
,
556 OSPF_IF_ACTIVE
, addr
);
558 ospf_passive_interface_update(ospf
, ifp
, params
, OSPF_IF_ACTIVE
);
560 /* XXX We should call ospf_if_set_multicast on exactly those
561 * interfaces for which the passive property changed. It is too much
562 * work to determine this set, so we do this for every interface.
563 * This is safe and reasonable because ospf_if_set_multicast uses a
564 * record of joined groups to avoid systems calls if the desired
565 * memberships match the current memership.
567 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
568 struct ospf_interface
*oi
= rn
->info
;
571 && (OSPF_IF_PARAM(oi
, passive_interface
) == OSPF_IF_ACTIVE
))
572 ospf_if_set_multicast(oi
);
579 DEFUN (ospf_network_area
,
580 ospf_network_area_cmd
,
581 "network A.B.C.D/M area <A.B.C.D|(0-4294967295)>",
582 "Enable routing on an IP network\n"
583 "OSPF network prefix\n"
584 "Set the OSPF area ID\n"
585 "OSPF area ID in IP address format\n"
586 "OSPF area ID as a decimal value\n")
588 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
589 int idx_ipv4_prefixlen
= 1;
590 int idx_ipv4_number
= 3;
591 struct prefix_ipv4 p
;
592 struct in_addr area_id
;
595 if (ospf
->instance
) {
597 "The network command is not supported in multi-instance ospf\n");
598 return CMD_WARNING_CONFIG_FAILED
;
601 if (ospf
->if_ospf_cli_count
> 0) {
603 "Please remove all ip ospf area x.x.x.x commands first.\n");
604 if (IS_DEBUG_OSPF_EVENT
)
605 zlog_debug("%s ospf vrf %s num of %u ip osp area x config",
607 ospf
->name
? ospf
->name
: "NIL",
608 ospf
->if_ospf_cli_count
);
609 return CMD_WARNING_CONFIG_FAILED
;
612 /* Get network prefix and Area ID. */
613 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
614 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
616 ret
= ospf_network_set(ospf
, &p
, area_id
, format
);
618 vty_out(vty
, "There is already same network statement.\n");
625 DEFUN (no_ospf_network_area
,
626 no_ospf_network_area_cmd
,
627 "no network A.B.C.D/M area <A.B.C.D|(0-4294967295)>",
629 "Enable routing on an IP network\n"
630 "OSPF network prefix\n"
631 "Set the OSPF area ID\n"
632 "OSPF area ID in IP address format\n"
633 "OSPF area ID as a decimal value\n")
635 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
636 int idx_ipv4_prefixlen
= 2;
637 int idx_ipv4_number
= 4;
638 struct prefix_ipv4 p
;
639 struct in_addr area_id
;
642 if (ospf
->instance
) {
644 "The network command is not supported in multi-instance ospf\n");
645 return CMD_WARNING_CONFIG_FAILED
;
648 /* Get network prefix and Area ID. */
649 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
650 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
652 ret
= ospf_network_unset(ospf
, &p
, area_id
);
655 "Can't find specified network area configuration.\n");
656 return CMD_WARNING_CONFIG_FAILED
;
662 DEFUN (ospf_area_range
,
664 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [advertise [cost (0-16777215)]]",
665 "OSPF area parameters\n"
666 "OSPF area ID in IP address format\n"
667 "OSPF area ID as a decimal value\n"
668 "Summarize routes matching address/mask (border routers only)\n"
669 "Area range prefix\n"
670 "Advertise this range (default)\n"
671 "User specified metric for this range\n"
672 "Advertised metric for this range\n")
674 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
675 int idx_ipv4_number
= 1;
676 int idx_ipv4_prefixlen
= 3;
678 struct prefix_ipv4 p
;
679 struct in_addr area_id
;
683 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
684 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
686 ospf_area_range_set(ospf
, area_id
, &p
, OSPF_AREA_RANGE_ADVERTISE
);
688 cost
= strtoul(argv
[idx_cost
]->arg
, NULL
, 10);
689 ospf_area_range_cost_set(ospf
, area_id
, &p
, cost
);
695 DEFUN (ospf_area_range_cost
,
696 ospf_area_range_cost_cmd
,
697 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M cost (0-16777215)",
698 "OSPF area parameters\n"
699 "OSPF area ID in IP address format\n"
700 "OSPF area ID as a decimal value\n"
701 "Summarize routes matching address/mask (border routers only)\n"
702 "Area range prefix\n"
703 "User specified metric for this range\n"
704 "Advertised metric for this range\n")
706 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
707 int idx_ipv4_number
= 1;
708 int idx_ipv4_prefixlen
= 3;
710 struct prefix_ipv4 p
;
711 struct in_addr area_id
;
715 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
716 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
718 ospf_area_range_set(ospf
, area_id
, &p
, OSPF_AREA_RANGE_ADVERTISE
);
719 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
722 cost
= strtoul(argv
[idx_cost
]->arg
, NULL
, 10);
723 ospf_area_range_cost_set(ospf
, area_id
, &p
, cost
);
728 DEFUN (ospf_area_range_not_advertise
,
729 ospf_area_range_not_advertise_cmd
,
730 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M not-advertise",
731 "OSPF area parameters\n"
732 "OSPF area ID in IP address format\n"
733 "OSPF area ID as a decimal value\n"
734 "Summarize routes matching address/mask (border routers only)\n"
735 "Area range prefix\n"
736 "DoNotAdvertise this range\n")
738 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
739 int idx_ipv4_number
= 1;
740 int idx_ipv4_prefixlen
= 3;
741 struct prefix_ipv4 p
;
742 struct in_addr area_id
;
745 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
746 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
748 ospf_area_range_set(ospf
, area_id
, &p
, 0);
749 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
755 DEFUN (no_ospf_area_range
,
756 no_ospf_area_range_cmd
,
757 "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [<cost (0-16777215)|advertise [cost (0-16777215)]|not-advertise>]",
759 "OSPF area parameters\n"
760 "OSPF area ID in IP address format\n"
761 "OSPF area ID as a decimal value\n"
762 "Summarize routes matching address/mask (border routers only)\n"
763 "Area range prefix\n"
764 "User specified metric for this range\n"
765 "Advertised metric for this range\n"
766 "Advertise this range (default)\n"
767 "User specified metric for this range\n"
768 "Advertised metric for this range\n"
769 "DoNotAdvertise this range\n")
771 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
772 int idx_ipv4_number
= 2;
773 int idx_ipv4_prefixlen
= 4;
774 struct prefix_ipv4 p
;
775 struct in_addr area_id
;
778 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
779 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
781 ospf_area_range_unset(ospf
, area_id
, &p
);
786 DEFUN (ospf_area_range_substitute
,
787 ospf_area_range_substitute_cmd
,
788 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M",
789 "OSPF area parameters\n"
790 "OSPF area ID in IP address format\n"
791 "OSPF area ID as a decimal value\n"
792 "Summarize routes matching address/mask (border routers only)\n"
793 "Area range prefix\n"
794 "Announce area range as another prefix\n"
795 "Network prefix to be announced instead of range\n")
797 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
798 int idx_ipv4_number
= 1;
799 int idx_ipv4_prefixlen
= 3;
800 int idx_ipv4_prefixlen_2
= 5;
801 struct prefix_ipv4 p
, s
;
802 struct in_addr area_id
;
805 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
806 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
807 str2prefix_ipv4(argv
[idx_ipv4_prefixlen_2
]->arg
, &s
);
809 ospf_area_range_substitute_set(ospf
, area_id
, &p
, &s
);
810 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
816 DEFUN (no_ospf_area_range_substitute
,
817 no_ospf_area_range_substitute_cmd
,
818 "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M",
820 "OSPF area parameters\n"
821 "OSPF area ID in IP address format\n"
822 "OSPF area ID as a decimal value\n"
823 "Summarize routes matching address/mask (border routers only)\n"
824 "Area range prefix\n"
825 "Announce area range as another prefix\n"
826 "Network prefix to be announced instead of range\n")
828 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
829 int idx_ipv4_number
= 2;
830 int idx_ipv4_prefixlen
= 4;
831 int idx_ipv4_prefixlen_2
= 6;
832 struct prefix_ipv4 p
, s
;
833 struct in_addr area_id
;
836 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
837 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
838 str2prefix_ipv4(argv
[idx_ipv4_prefixlen_2
]->arg
, &s
);
840 ospf_area_range_substitute_unset(ospf
, area_id
, &p
);
846 /* Command Handler Logic in VLink stuff is delicate!!
848 ALTER AT YOUR OWN RISK!!!!
850 Various dummy values are used to represent 'NoChange' state for
851 VLink configuration NOT being changed by a VLink command, and
852 special syntax is used within the command strings so that the
853 typed in command verbs can be seen in the configuration command
854 bacckend handler. This is to drastically reduce the verbeage
855 required to coe up with a reasonably compatible Cisco VLink command
857 - Matthew Grant <grantma@anathoth.gen.nz>
858 Wed, 21 Feb 2001 15:13:52 +1300
861 /* Configuration data for virtual links
863 struct ospf_vl_config_data
{
864 struct vty
*vty
; /* vty stuff */
865 struct in_addr area_id
; /* area ID from command line */
866 int area_id_fmt
; /* command line area ID format */
867 struct in_addr vl_peer
; /* command line vl_peer */
868 int auth_type
; /* Authehntication type, if given */
869 char *auth_key
; /* simple password if present */
870 int crypto_key_id
; /* Cryptographic key ID */
871 char *md5_key
; /* MD5 authentication key */
872 int hello_interval
; /* Obvious what these are... */
873 int retransmit_interval
;
878 static void ospf_vl_config_data_init(struct ospf_vl_config_data
*vl_config
,
881 memset(vl_config
, 0, sizeof(struct ospf_vl_config_data
));
882 vl_config
->auth_type
= OSPF_AUTH_CMD_NOTSEEN
;
883 vl_config
->vty
= vty
;
886 static struct ospf_vl_data
*
887 ospf_find_vl_data(struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
889 struct ospf_area
*area
;
890 struct ospf_vl_data
*vl_data
;
892 struct in_addr area_id
;
894 vty
= vl_config
->vty
;
895 area_id
= vl_config
->area_id
;
897 if (area_id
.s_addr
== OSPF_AREA_BACKBONE
) {
899 "Configuring VLs over the backbone is not allowed\n");
902 area
= ospf_area_get(ospf
, area_id
);
903 ospf_area_display_format_set(ospf
, area
, vl_config
->area_id_fmt
);
905 if (area
->external_routing
!= OSPF_AREA_DEFAULT
) {
906 if (vl_config
->area_id_fmt
== OSPF_AREA_ID_FMT_DOTTEDQUAD
)
907 vty_out(vty
, "Area %s is %s\n", inet_ntoa(area_id
),
908 area
->external_routing
== OSPF_AREA_NSSA
912 vty_out(vty
, "Area %ld is %s\n",
913 (u_long
)ntohl(area_id
.s_addr
),
914 area
->external_routing
== OSPF_AREA_NSSA
920 if ((vl_data
= ospf_vl_lookup(ospf
, area
, vl_config
->vl_peer
))
922 vl_data
= ospf_vl_data_new(area
, vl_config
->vl_peer
);
923 if (vl_data
->vl_oi
== NULL
) {
924 vl_data
->vl_oi
= ospf_vl_new(ospf
, vl_data
);
925 ospf_vl_add(ospf
, vl_data
);
926 ospf_spf_calculate_schedule(ospf
,
927 SPF_FLAG_CONFIG_CHANGE
);
934 static int ospf_vl_set_security(struct ospf_vl_data
*vl_data
,
935 struct ospf_vl_config_data
*vl_config
)
937 struct crypt_key
*ck
;
939 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
941 vty
= vl_config
->vty
;
943 if (vl_config
->auth_type
!= OSPF_AUTH_CMD_NOTSEEN
) {
944 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), auth_type
);
945 IF_DEF_PARAMS(ifp
)->auth_type
= vl_config
->auth_type
;
948 if (vl_config
->auth_key
) {
949 memset(IF_DEF_PARAMS(ifp
)->auth_simple
, 0,
950 OSPF_AUTH_SIMPLE_SIZE
+ 1);
951 strncpy((char *)IF_DEF_PARAMS(ifp
)->auth_simple
,
952 vl_config
->auth_key
, OSPF_AUTH_SIMPLE_SIZE
);
953 } else if (vl_config
->md5_key
) {
954 if (ospf_crypt_key_lookup(IF_DEF_PARAMS(ifp
)->auth_crypt
,
955 vl_config
->crypto_key_id
)
957 vty_out(vty
, "OSPF: Key %d already exists\n",
958 vl_config
->crypto_key_id
);
961 ck
= ospf_crypt_key_new();
962 ck
->key_id
= vl_config
->crypto_key_id
;
963 memset(ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+ 1);
964 strncpy((char *)ck
->auth_key
, vl_config
->md5_key
,
967 ospf_crypt_key_add(IF_DEF_PARAMS(ifp
)->auth_crypt
, ck
);
968 } else if (vl_config
->crypto_key_id
!= 0) {
971 if (ospf_crypt_key_lookup(IF_DEF_PARAMS(ifp
)->auth_crypt
,
972 vl_config
->crypto_key_id
)
974 vty_out(vty
, "OSPF: Key %d does not exist\n",
975 vl_config
->crypto_key_id
);
976 return CMD_WARNING_CONFIG_FAILED
;
979 ospf_crypt_key_delete(IF_DEF_PARAMS(ifp
)->auth_crypt
,
980 vl_config
->crypto_key_id
);
986 static int ospf_vl_set_timers(struct ospf_vl_data
*vl_data
,
987 struct ospf_vl_config_data
*vl_config
)
989 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
990 /* Virtual Link data initialised to defaults, so only set
992 if (vl_config
->hello_interval
) {
993 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), v_hello
);
994 IF_DEF_PARAMS(ifp
)->v_hello
= vl_config
->hello_interval
;
997 if (vl_config
->dead_interval
) {
998 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), v_wait
);
999 IF_DEF_PARAMS(ifp
)->v_wait
= vl_config
->dead_interval
;
1002 if (vl_config
->retransmit_interval
) {
1003 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), retransmit_interval
);
1004 IF_DEF_PARAMS(ifp
)->retransmit_interval
=
1005 vl_config
->retransmit_interval
;
1008 if (vl_config
->transmit_delay
) {
1009 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), transmit_delay
);
1010 IF_DEF_PARAMS(ifp
)->transmit_delay
= vl_config
->transmit_delay
;
1017 /* The business end of all of the above */
1018 static int ospf_vl_set(struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
1020 struct ospf_vl_data
*vl_data
;
1023 vl_data
= ospf_find_vl_data(ospf
, vl_config
);
1025 return CMD_WARNING_CONFIG_FAILED
;
1027 /* Process this one first as it can have a fatal result, which can
1028 only logically occur if the virtual link exists already
1029 Thus a command error does not result in a change to the
1030 running configuration such as unexpectedly altered timer
1032 ret
= ospf_vl_set_security(vl_data
, vl_config
);
1033 if (ret
!= CMD_SUCCESS
)
1036 /* Set any time based parameters, these area already range checked */
1038 ret
= ospf_vl_set_timers(vl_data
, vl_config
);
1039 if (ret
!= CMD_SUCCESS
)
1045 /* This stuff exists to make specifying all the alias commands A LOT simpler
1047 #define VLINK_HELPSTR_IPADDR \
1048 "OSPF area parameters\n" \
1049 "OSPF area ID in IP address format\n" \
1050 "OSPF area ID as a decimal value\n" \
1051 "Configure a virtual link\n" \
1052 "Router ID of the remote ABR\n"
1054 #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
1055 "Enable authentication on this virtual link\n" \
1058 #define VLINK_HELPSTR_AUTHTYPE_ALL \
1059 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
1060 "Use null authentication\n" \
1061 "Use message-digest authentication\n"
1063 #define VLINK_HELPSTR_TIME_PARAM \
1064 "Time between HELLO packets\n" \
1066 "Time between retransmitting lost link state advertisements\n" \
1068 "Link state transmit delay\n" \
1070 "Interval time after which a neighbor is declared down\n" \
1073 #define VLINK_HELPSTR_AUTH_SIMPLE \
1074 "Authentication password (key)\n" \
1075 "The OSPF password (key)\n"
1077 #define VLINK_HELPSTR_AUTH_MD5 \
1078 "Message digest authentication password (key)\n" \
1080 "Use MD5 algorithm\n" \
1081 "The OSPF password (key)\n"
1083 DEFUN (ospf_area_vlink
,
1084 ospf_area_vlink_cmd
,
1085 "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>]",
1086 VLINK_HELPSTR_IPADDR
1087 "Enable authentication on this virtual link\n"
1088 "Use message-digest authentication\n"
1089 "Use null authentication\n"
1090 VLINK_HELPSTR_AUTH_MD5
1091 VLINK_HELPSTR_AUTH_SIMPLE
)
1093 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1094 int idx_ipv4_number
= 1;
1096 struct ospf_vl_config_data vl_config
;
1097 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+ 1];
1098 char md5_key
[OSPF_AUTH_MD5_SIZE
+ 1];
1102 ospf_vl_config_data_init(&vl_config
, vty
);
1104 /* Read off first 2 parameters and check them */
1105 ret
= str2area_id(argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
,
1106 &vl_config
.area_id_fmt
);
1108 vty_out(vty
, "OSPF area ID is invalid\n");
1109 return CMD_WARNING_CONFIG_FAILED
;
1112 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1114 vty_out(vty
, "Please specify valid Router ID as a.b.c.d\n");
1115 return CMD_WARNING_CONFIG_FAILED
;
1119 /* Thats all folks! - BUGS B. strikes again!!!*/
1121 return ospf_vl_set(ospf
, &vl_config
);
1124 if (argv_find(argv
, argc
, "authentication", &idx
)) {
1125 /* authentication - this option can only occur
1126 at start of command line */
1127 vl_config
.auth_type
= OSPF_AUTH_SIMPLE
;
1130 if (argv_find(argv
, argc
, "message-digest", &idx
)) {
1131 /* authentication message-digest */
1132 vl_config
.auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
1133 } else if (argv_find(argv
, argc
, "null", &idx
)) {
1134 /* "authentication null" */
1135 vl_config
.auth_type
= OSPF_AUTH_NULL
;
1138 if (argv_find(argv
, argc
, "message-digest-key", &idx
)) {
1139 vl_config
.md5_key
= NULL
;
1140 vl_config
.crypto_key_id
= strtol(argv
[idx
+ 1]->arg
, NULL
, 10);
1141 if (vl_config
.crypto_key_id
< 0)
1142 return CMD_WARNING_CONFIG_FAILED
;
1144 memset(md5_key
, 0, OSPF_AUTH_MD5_SIZE
+ 1);
1145 strncpy(md5_key
, argv
[idx
+ 3]->arg
, OSPF_AUTH_MD5_SIZE
);
1146 vl_config
.md5_key
= md5_key
;
1149 if (argv_find(argv
, argc
, "authentication-key", &idx
)) {
1150 memset(auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1151 strncpy(auth_key
, argv
[idx
+ 1]->arg
, OSPF_AUTH_SIMPLE_SIZE
);
1152 vl_config
.auth_key
= auth_key
;
1155 /* Action configuration */
1157 return ospf_vl_set(ospf
, &vl_config
);
1160 DEFUN (no_ospf_area_vlink
,
1161 no_ospf_area_vlink_cmd
,
1162 "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>]",
1164 VLINK_HELPSTR_IPADDR
1165 "Enable authentication on this virtual link\n" \
1166 "Use message-digest authentication\n" \
1167 "Use null authentication\n" \
1168 VLINK_HELPSTR_AUTH_MD5
1169 VLINK_HELPSTR_AUTH_SIMPLE
)
1171 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1172 int idx_ipv4_number
= 2;
1174 struct ospf_area
*area
;
1175 struct ospf_vl_config_data vl_config
;
1176 struct ospf_vl_data
*vl_data
= NULL
;
1177 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+ 1];
1181 ospf_vl_config_data_init(&vl_config
, vty
);
1183 ret
= str2area_id(argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
,
1186 vty_out(vty
, "OSPF area ID is invalid\n");
1187 return CMD_WARNING_CONFIG_FAILED
;
1190 area
= ospf_area_lookup_by_area_id(ospf
, vl_config
.area_id
);
1192 vty_out(vty
, "Area does not exist\n");
1193 return CMD_WARNING_CONFIG_FAILED
;
1196 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1198 vty_out(vty
, "Please specify valid Router ID as a.b.c.d\n");
1199 return CMD_WARNING_CONFIG_FAILED
;
1203 /* Basic VLink no command */
1204 /* Thats all folks! - BUGS B. strikes again!!!*/
1205 if ((vl_data
= ospf_vl_lookup(ospf
, area
, vl_config
.vl_peer
)))
1206 ospf_vl_delete(ospf
, vl_data
);
1208 ospf_area_check_free(ospf
, vl_config
.area_id
);
1213 /* If we are down here, we are reseting parameters */
1214 /* Deal with other parameters */
1216 if (argv_find(argv
, argc
, "authentication", &idx
)) {
1217 /* authentication - this option can only occur
1218 at start of command line */
1219 vl_config
.auth_type
= OSPF_AUTH_NOTSET
;
1222 if (argv_find(argv
, argc
, "message-digest-key", &idx
)) {
1223 vl_config
.md5_key
= NULL
;
1224 vl_config
.crypto_key_id
= strtol(argv
[idx
+ 1]->arg
, NULL
, 10);
1225 if (vl_config
.crypto_key_id
< 0)
1226 return CMD_WARNING_CONFIG_FAILED
;
1229 if (argv_find(argv
, argc
, "authentication-key", &idx
)) {
1230 /* Reset authentication-key to 0 */
1231 memset(auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1232 vl_config
.auth_key
= auth_key
;
1235 /* Action configuration */
1237 return ospf_vl_set(ospf
, &vl_config
);
1240 DEFUN (ospf_area_vlink_intervals
,
1241 ospf_area_vlink_intervals_cmd
,
1242 "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)}",
1243 VLINK_HELPSTR_IPADDR
1244 VLINK_HELPSTR_TIME_PARAM
)
1246 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1247 struct ospf_vl_config_data vl_config
;
1250 ospf_vl_config_data_init(&vl_config
, vty
);
1252 char *area_id
= argv
[1]->arg
;
1253 char *router_id
= argv
[3]->arg
;
1255 ret
= str2area_id(area_id
, &vl_config
.area_id
, &vl_config
.area_id_fmt
);
1257 vty_out(vty
, "OSPF area ID is invalid\n");
1258 return CMD_WARNING_CONFIG_FAILED
;
1261 ret
= inet_aton(router_id
, &vl_config
.vl_peer
);
1263 vty_out(vty
, "Please specify valid Router ID as a.b.c.d\n");
1264 return CMD_WARNING_CONFIG_FAILED
;
1267 for (int idx
= 4; idx
< argc
; idx
++) {
1268 if (strmatch(argv
[idx
]->text
, "hello-interval"))
1269 vl_config
.hello_interval
=
1270 strtol(argv
[++idx
]->arg
, NULL
, 10);
1271 else if (strmatch(argv
[idx
]->text
, "retransmit-interval"))
1272 vl_config
.retransmit_interval
=
1273 strtol(argv
[++idx
]->arg
, NULL
, 10);
1274 else if (strmatch(argv
[idx
]->text
, "transmit-delay"))
1275 vl_config
.transmit_delay
=
1276 strtol(argv
[++idx
]->arg
, NULL
, 10);
1277 else if (strmatch(argv
[idx
]->text
, "dead-interval"))
1278 vl_config
.dead_interval
=
1279 strtol(argv
[++idx
]->arg
, NULL
, 10);
1282 /* Action configuration */
1283 return ospf_vl_set(ospf
, &vl_config
);
1286 DEFUN (no_ospf_area_vlink_intervals
,
1287 no_ospf_area_vlink_intervals_cmd
,
1288 "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)}",
1290 VLINK_HELPSTR_IPADDR
1291 VLINK_HELPSTR_TIME_PARAM
)
1293 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1294 struct ospf_vl_config_data vl_config
;
1297 ospf_vl_config_data_init(&vl_config
, vty
);
1299 char *area_id
= argv
[2]->arg
;
1300 char *router_id
= argv
[4]->arg
;
1302 ret
= str2area_id(area_id
, &vl_config
.area_id
, &vl_config
.area_id_fmt
);
1304 vty_out(vty
, "OSPF area ID is invalid\n");
1305 return CMD_WARNING_CONFIG_FAILED
;
1308 ret
= inet_aton(router_id
, &vl_config
.vl_peer
);
1310 vty_out(vty
, "Please specify valid Router ID as a.b.c.d\n");
1311 return CMD_WARNING_CONFIG_FAILED
;
1314 for (int idx
= 5; idx
< argc
; idx
++) {
1315 if (strmatch(argv
[idx
]->text
, "hello-interval"))
1316 vl_config
.hello_interval
= OSPF_HELLO_INTERVAL_DEFAULT
;
1317 else if (strmatch(argv
[idx
]->text
, "retransmit-interval"))
1318 vl_config
.retransmit_interval
=
1319 OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
1320 else if (strmatch(argv
[idx
]->text
, "transmit-delay"))
1321 vl_config
.transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
1322 else if (strmatch(argv
[idx
]->text
, "dead-interval"))
1323 vl_config
.dead_interval
=
1324 OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
1327 /* Action configuration */
1328 return ospf_vl_set(ospf
, &vl_config
);
1331 DEFUN (ospf_area_shortcut
,
1332 ospf_area_shortcut_cmd
,
1333 "area <A.B.C.D|(0-4294967295)> shortcut <default|enable|disable>",
1334 "OSPF area parameters\n"
1335 "OSPF area ID in IP address format\n"
1336 "OSPF area ID as a decimal value\n"
1337 "Configure the area's shortcutting mode\n"
1338 "Set default shortcutting behavior\n"
1339 "Enable shortcutting through the area\n"
1340 "Disable shortcutting through the area\n")
1342 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1343 int idx_ipv4_number
= 1;
1344 int idx_enable_disable
= 3;
1345 struct ospf_area
*area
;
1346 struct in_addr area_id
;
1350 VTY_GET_OSPF_AREA_ID_NO_BB("shortcut", area_id
, format
,
1351 argv
[idx_ipv4_number
]->arg
);
1353 area
= ospf_area_get(ospf
, area_id
);
1354 ospf_area_display_format_set(ospf
, area
, format
);
1356 if (strncmp(argv
[idx_enable_disable
]->arg
, "de", 2) == 0)
1357 mode
= OSPF_SHORTCUT_DEFAULT
;
1358 else if (strncmp(argv
[idx_enable_disable
]->arg
, "di", 2) == 0)
1359 mode
= OSPF_SHORTCUT_DISABLE
;
1360 else if (strncmp(argv
[idx_enable_disable
]->arg
, "e", 1) == 0)
1361 mode
= OSPF_SHORTCUT_ENABLE
;
1363 return CMD_WARNING_CONFIG_FAILED
;
1365 ospf_area_shortcut_set(ospf
, area
, mode
);
1367 if (ospf
->abr_type
!= OSPF_ABR_SHORTCUT
)
1369 "Shortcut area setting will take effect "
1370 "only when the router is configured as Shortcut ABR\n");
1375 DEFUN (no_ospf_area_shortcut
,
1376 no_ospf_area_shortcut_cmd
,
1377 "no area <A.B.C.D|(0-4294967295)> shortcut <enable|disable>",
1379 "OSPF area parameters\n"
1380 "OSPF area ID in IP address format\n"
1381 "OSPF area ID as a decimal value\n"
1382 "Deconfigure the area's shortcutting mode\n"
1383 "Deconfigure enabled shortcutting through the area\n"
1384 "Deconfigure disabled shortcutting through the area\n")
1386 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1387 int idx_ipv4_number
= 2;
1388 struct ospf_area
*area
;
1389 struct in_addr area_id
;
1392 VTY_GET_OSPF_AREA_ID_NO_BB("shortcut", area_id
, format
,
1393 argv
[idx_ipv4_number
]->arg
);
1395 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1399 ospf_area_shortcut_unset(ospf
, area
);
1405 DEFUN (ospf_area_stub
,
1407 "area <A.B.C.D|(0-4294967295)> stub",
1408 "OSPF area parameters\n"
1409 "OSPF area ID in IP address format\n"
1410 "OSPF area ID as a decimal value\n"
1411 "Configure OSPF area as stub\n")
1413 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1414 int idx_ipv4_number
= 1;
1415 struct in_addr area_id
;
1418 VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id
, format
,
1419 argv
[idx_ipv4_number
]->arg
);
1421 ret
= ospf_area_stub_set(ospf
, area_id
);
1422 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1426 "First deconfigure all virtual link through this area\n");
1427 return CMD_WARNING_CONFIG_FAILED
;
1430 ospf_area_no_summary_unset(ospf
, area_id
);
1435 DEFUN (ospf_area_stub_no_summary
,
1436 ospf_area_stub_no_summary_cmd
,
1437 "area <A.B.C.D|(0-4294967295)> stub no-summary",
1438 "OSPF stub parameters\n"
1439 "OSPF area ID in IP address format\n"
1440 "OSPF area ID as a decimal value\n"
1441 "Configure OSPF area as stub\n"
1442 "Do not inject inter-area routes into stub\n")
1444 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1445 int idx_ipv4_number
= 1;
1446 struct in_addr area_id
;
1449 VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id
, format
,
1450 argv
[idx_ipv4_number
]->arg
);
1452 ret
= ospf_area_stub_set(ospf
, area_id
);
1453 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1457 "%% Area cannot be stub as it contains a virtual link\n");
1458 return CMD_WARNING_CONFIG_FAILED
;
1461 ospf_area_no_summary_set(ospf
, area_id
);
1466 DEFUN (no_ospf_area_stub
,
1467 no_ospf_area_stub_cmd
,
1468 "no area <A.B.C.D|(0-4294967295)> stub",
1470 "OSPF area parameters\n"
1471 "OSPF area ID in IP address format\n"
1472 "OSPF area ID as a decimal value\n"
1473 "Configure OSPF area as stub\n")
1475 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1476 int idx_ipv4_number
= 2;
1477 struct in_addr area_id
;
1480 VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id
, format
,
1481 argv
[idx_ipv4_number
]->arg
);
1483 ospf_area_stub_unset(ospf
, area_id
);
1484 ospf_area_no_summary_unset(ospf
, area_id
);
1489 DEFUN (no_ospf_area_stub_no_summary
,
1490 no_ospf_area_stub_no_summary_cmd
,
1491 "no area <A.B.C.D|(0-4294967295)> stub no-summary",
1493 "OSPF area parameters\n"
1494 "OSPF area ID in IP address format\n"
1495 "OSPF area ID as a decimal value\n"
1496 "Configure OSPF area as stub\n"
1497 "Do not inject inter-area routes into area\n")
1499 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1500 int idx_ipv4_number
= 2;
1501 struct in_addr area_id
;
1504 VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id
, format
,
1505 argv
[idx_ipv4_number
]->arg
);
1506 ospf_area_no_summary_unset(ospf
, area_id
);
1511 static int ospf_area_nssa_cmd_handler(struct vty
*vty
, int argc
,
1512 struct cmd_token
**argv
, int cfg_nosum
,
1515 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1516 struct in_addr area_id
;
1519 VTY_GET_OSPF_AREA_ID_NO_BB("NSSA", area_id
, format
, argv
[1]->arg
);
1521 ret
= ospf_area_nssa_set(ospf
, area_id
);
1522 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1526 "%% Area cannot be nssa as it contains a virtual link\n");
1527 return CMD_WARNING_CONFIG_FAILED
;
1531 if (strncmp(argv
[3]->text
, "translate-c", 11) == 0)
1532 ospf_area_nssa_translator_role_set(
1533 ospf
, area_id
, OSPF_NSSA_ROLE_CANDIDATE
);
1534 else if (strncmp(argv
[3]->text
, "translate-n", 11) == 0)
1535 ospf_area_nssa_translator_role_set(
1536 ospf
, area_id
, OSPF_NSSA_ROLE_NEVER
);
1537 else if (strncmp(argv
[3]->text
, "translate-a", 11) == 0)
1538 ospf_area_nssa_translator_role_set(
1539 ospf
, area_id
, OSPF_NSSA_ROLE_ALWAYS
);
1541 ospf_area_nssa_translator_role_set(ospf
, area_id
,
1542 OSPF_NSSA_ROLE_CANDIDATE
);
1547 ospf_area_no_summary_set(ospf
, area_id
);
1549 ospf_area_no_summary_unset(ospf
, area_id
);
1552 ospf_schedule_abr_task(ospf
);
1558 DEFUN (ospf_area_nssa_translate
,
1559 ospf_area_nssa_translate_cmd
,
1560 "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always>",
1561 "OSPF area parameters\n"
1562 "OSPF area ID in IP address format\n"
1563 "OSPF area ID as a decimal value\n"
1564 "Configure OSPF area as nssa\n"
1565 "Configure NSSA-ABR for translate election (default)\n"
1566 "Configure NSSA-ABR to never translate\n"
1567 "Configure NSSA-ABR to always translate\n")
1569 return ospf_area_nssa_cmd_handler(vty
, argc
, argv
, 0, 0);
1572 DEFUN (ospf_area_nssa
,
1574 "area <A.B.C.D|(0-4294967295)> nssa",
1575 "OSPF area parameters\n"
1576 "OSPF area ID in IP address format\n"
1577 "OSPF area ID as a decimal value\n"
1578 "Configure OSPF area as nssa\n")
1580 return ospf_area_nssa_cmd_handler(vty
, argc
, argv
, 0, 0);
1583 DEFUN (ospf_area_nssa_no_summary
,
1584 ospf_area_nssa_no_summary_cmd
,
1585 "area <A.B.C.D|(0-4294967295)> nssa no-summary",
1586 "OSPF area parameters\n"
1587 "OSPF area ID in IP address format\n"
1588 "OSPF area ID as a decimal value\n"
1589 "Configure OSPF area as nssa\n"
1590 "Do not inject inter-area routes into nssa\n")
1592 int idx_ipv4_number
= 1;
1593 struct in_addr area_id
;
1596 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1597 VTY_GET_OSPF_AREA_ID_NO_BB("NSSA", area_id
, format
,
1598 argv
[idx_ipv4_number
]->arg
);
1600 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1602 ospf_area_nssa_no_summary_set(ospf
, area_id
);
1604 ospf_schedule_abr_task(ospf
);
1609 DEFUN (no_ospf_area_nssa_no_summary
,
1610 no_ospf_area_nssa_no_summary_cmd
,
1611 "no area <A.B.C.D|(0-4294967295)> nssa no-summary",
1613 "OSPF area parameters\n"
1614 "OSPF area ID in IP address format\n"
1615 "OSPF area ID as a decimal value\n"
1616 "Configure OSPF area as nssa\n"
1617 "Do not inject inter-area routes into nssa\n")
1619 int idx_ipv4_number
= 2;
1620 struct in_addr area_id
;
1623 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1625 VTY_GET_OSPF_AREA_ID_NO_BB("nssa", area_id
, format
,
1626 argv
[idx_ipv4_number
]->arg
);
1628 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1630 ospf_area_no_summary_unset(ospf
, area_id
);
1632 ospf_schedule_abr_task(ospf
);
1637 DEFUN (no_ospf_area_nssa
,
1638 no_ospf_area_nssa_cmd
,
1639 "no area <A.B.C.D|(0-4294967295)> nssa [<translate-candidate|translate-never|translate-always>]",
1641 "OSPF area parameters\n"
1642 "OSPF area ID in IP address format\n"
1643 "OSPF area ID as a decimal value\n"
1644 "Configure OSPF area as nssa\n"
1645 "Configure NSSA-ABR for translate election (default)\n"
1646 "Configure NSSA-ABR to never translate\n"
1647 "Configure NSSA-ABR to always translate\n")
1649 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1650 int idx_ipv4_number
= 2;
1651 struct in_addr area_id
;
1654 VTY_GET_OSPF_AREA_ID_NO_BB("NSSA", area_id
, format
,
1655 argv
[idx_ipv4_number
]->arg
);
1657 ospf_area_nssa_unset(ospf
, area_id
, argc
);
1659 ospf_schedule_abr_task(ospf
);
1665 DEFUN (ospf_area_default_cost
,
1666 ospf_area_default_cost_cmd
,
1667 "area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1668 "OSPF area parameters\n"
1669 "OSPF area ID in IP address format\n"
1670 "OSPF area ID as a decimal value\n"
1671 "Set the summary-default cost of a NSSA or stub area\n"
1672 "Stub's advertised default summary cost\n")
1674 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1675 int idx_ipv4_number
= 1;
1677 struct ospf_area
*area
;
1678 struct in_addr area_id
;
1681 struct prefix_ipv4 p
;
1683 VTY_GET_OSPF_AREA_ID_NO_BB("default-cost", area_id
, format
,
1684 argv
[idx_ipv4_number
]->arg
);
1685 cost
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1687 area
= ospf_area_get(ospf
, area_id
);
1688 ospf_area_display_format_set(ospf
, area
, format
);
1690 if (area
->external_routing
== OSPF_AREA_DEFAULT
) {
1691 vty_out(vty
, "The area is neither stub, nor NSSA\n");
1692 return CMD_WARNING_CONFIG_FAILED
;
1695 area
->default_cost
= cost
;
1698 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1700 if (IS_DEBUG_OSPF_EVENT
)
1702 "ospf_abr_announce_stub_defaults(): "
1703 "announcing 0.0.0.0/0 to area %s",
1704 inet_ntoa(area
->area_id
));
1705 ospf_abr_announce_network_to_area(&p
, area
->default_cost
, area
);
1710 DEFUN (no_ospf_area_default_cost
,
1711 no_ospf_area_default_cost_cmd
,
1712 "no area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1714 "OSPF area parameters\n"
1715 "OSPF area ID in IP address format\n"
1716 "OSPF area ID as a decimal value\n"
1717 "Set the summary-default cost of a NSSA or stub area\n"
1718 "Stub's advertised default summary cost\n")
1720 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1721 int idx_ipv4_number
= 2;
1722 struct ospf_area
*area
;
1723 struct in_addr area_id
;
1725 struct prefix_ipv4 p
;
1727 VTY_GET_OSPF_AREA_ID_NO_BB("default-cost", area_id
, format
,
1728 argv
[idx_ipv4_number
]->arg
);
1730 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1734 if (area
->external_routing
== OSPF_AREA_DEFAULT
) {
1735 vty_out(vty
, "The area is neither stub, nor NSSA\n");
1736 return CMD_WARNING_CONFIG_FAILED
;
1739 area
->default_cost
= 1;
1742 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1744 if (IS_DEBUG_OSPF_EVENT
)
1746 "ospf_abr_announce_stub_defaults(): "
1747 "announcing 0.0.0.0/0 to area %s",
1748 inet_ntoa(area
->area_id
));
1749 ospf_abr_announce_network_to_area(&p
, area
->default_cost
, area
);
1752 ospf_area_check_free(ospf
, area_id
);
1757 DEFUN (ospf_area_export_list
,
1758 ospf_area_export_list_cmd
,
1759 "area <A.B.C.D|(0-4294967295)> export-list NAME",
1760 "OSPF area parameters\n"
1761 "OSPF area ID in IP address format\n"
1762 "OSPF area ID as a decimal value\n"
1763 "Set the filter for networks announced to other areas\n"
1764 "Name of the access-list\n")
1766 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1767 int idx_ipv4_number
= 1;
1768 struct ospf_area
*area
;
1769 struct in_addr area_id
;
1772 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1774 area
= ospf_area_get(ospf
, area_id
);
1775 ospf_area_display_format_set(ospf
, area
, format
);
1776 ospf_area_export_list_set(ospf
, area
, argv
[3]->arg
);
1781 DEFUN (no_ospf_area_export_list
,
1782 no_ospf_area_export_list_cmd
,
1783 "no area <A.B.C.D|(0-4294967295)> export-list NAME",
1785 "OSPF area parameters\n"
1786 "OSPF area ID in IP address format\n"
1787 "OSPF area ID as a decimal value\n"
1788 "Unset the filter for networks announced to other areas\n"
1789 "Name of the access-list\n")
1791 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1792 int idx_ipv4_number
= 2;
1793 struct ospf_area
*area
;
1794 struct in_addr area_id
;
1797 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1799 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1803 ospf_area_export_list_unset(ospf
, area
);
1809 DEFUN (ospf_area_import_list
,
1810 ospf_area_import_list_cmd
,
1811 "area <A.B.C.D|(0-4294967295)> import-list NAME",
1812 "OSPF area parameters\n"
1813 "OSPF area ID in IP address format\n"
1814 "OSPF area ID as a decimal value\n"
1815 "Set the filter for networks from other areas announced to the specified one\n"
1816 "Name of the access-list\n")
1818 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1819 int idx_ipv4_number
= 1;
1820 struct ospf_area
*area
;
1821 struct in_addr area_id
;
1824 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1826 area
= ospf_area_get(ospf
, area_id
);
1827 ospf_area_display_format_set(ospf
, area
, format
);
1828 ospf_area_import_list_set(ospf
, area
, argv
[3]->arg
);
1833 DEFUN (no_ospf_area_import_list
,
1834 no_ospf_area_import_list_cmd
,
1835 "no area <A.B.C.D|(0-4294967295)> import-list NAME",
1837 "OSPF area parameters\n"
1838 "OSPF area ID in IP address format\n"
1839 "OSPF area ID as a decimal value\n"
1840 "Unset the filter for networks announced to other areas\n"
1841 "Name of the access-list\n")
1843 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1844 int idx_ipv4_number
= 2;
1845 struct ospf_area
*area
;
1846 struct in_addr area_id
;
1849 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1851 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1855 ospf_area_import_list_unset(ospf
, area
);
1860 DEFUN (ospf_area_filter_list
,
1861 ospf_area_filter_list_cmd
,
1862 "area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>",
1863 "OSPF area parameters\n"
1864 "OSPF area ID in IP address format\n"
1865 "OSPF area ID as a decimal value\n"
1866 "Filter networks between OSPF areas\n"
1867 "Filter prefixes between OSPF areas\n"
1868 "Name of an IP prefix-list\n"
1869 "Filter networks sent to this area\n"
1870 "Filter networks sent from this area\n")
1872 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1873 int idx_ipv4_number
= 1;
1876 struct ospf_area
*area
;
1877 struct in_addr area_id
;
1878 struct prefix_list
*plist
;
1881 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1883 area
= ospf_area_get(ospf
, area_id
);
1884 ospf_area_display_format_set(ospf
, area
, format
);
1885 plist
= prefix_list_lookup(AFI_IP
, argv
[idx_word
]->arg
);
1886 if (strncmp(argv
[idx_in_out
]->arg
, "in", 2) == 0) {
1887 PREFIX_LIST_IN(area
) = plist
;
1888 if (PREFIX_NAME_IN(area
))
1889 free(PREFIX_NAME_IN(area
));
1891 PREFIX_NAME_IN(area
) = strdup(argv
[idx_word
]->arg
);
1892 ospf_schedule_abr_task(ospf
);
1894 PREFIX_LIST_OUT(area
) = plist
;
1895 if (PREFIX_NAME_OUT(area
))
1896 free(PREFIX_NAME_OUT(area
));
1898 PREFIX_NAME_OUT(area
) = strdup(argv
[idx_word
]->arg
);
1899 ospf_schedule_abr_task(ospf
);
1905 DEFUN (no_ospf_area_filter_list
,
1906 no_ospf_area_filter_list_cmd
,
1907 "no area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>",
1909 "OSPF area parameters\n"
1910 "OSPF area ID in IP address format\n"
1911 "OSPF area ID as a decimal value\n"
1912 "Filter networks between OSPF areas\n"
1913 "Filter prefixes between OSPF areas\n"
1914 "Name of an IP prefix-list\n"
1915 "Filter networks sent to this area\n"
1916 "Filter networks sent from this area\n")
1918 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1919 int idx_ipv4_number
= 2;
1922 struct ospf_area
*area
;
1923 struct in_addr area_id
;
1926 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1928 if ((area
= ospf_area_lookup_by_area_id(ospf
, area_id
)) == NULL
)
1931 if (strncmp(argv
[idx_in_out
]->arg
, "in", 2) == 0) {
1932 if (PREFIX_NAME_IN(area
))
1933 if (strcmp(PREFIX_NAME_IN(area
), argv
[idx_word
]->arg
)
1937 PREFIX_LIST_IN(area
) = NULL
;
1938 if (PREFIX_NAME_IN(area
))
1939 free(PREFIX_NAME_IN(area
));
1941 PREFIX_NAME_IN(area
) = NULL
;
1943 ospf_schedule_abr_task(ospf
);
1945 if (PREFIX_NAME_OUT(area
))
1946 if (strcmp(PREFIX_NAME_OUT(area
), argv
[idx_word
]->arg
)
1950 PREFIX_LIST_OUT(area
) = NULL
;
1951 if (PREFIX_NAME_OUT(area
))
1952 free(PREFIX_NAME_OUT(area
));
1954 PREFIX_NAME_OUT(area
) = NULL
;
1956 ospf_schedule_abr_task(ospf
);
1963 DEFUN (ospf_area_authentication_message_digest
,
1964 ospf_area_authentication_message_digest_cmd
,
1965 "[no] area <A.B.C.D|(0-4294967295)> authentication message-digest",
1967 "OSPF area parameters\n"
1968 "OSPF area ID in IP address format\n"
1969 "OSPF area ID as a decimal value\n"
1970 "Enable authentication\n"
1971 "Use message-digest authentication\n")
1973 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1974 int idx_ipv4_number
= 1;
1975 struct ospf_area
*area
;
1976 struct in_addr area_id
;
1979 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1981 area
= ospf_area_get(ospf
, area_id
);
1982 ospf_area_display_format_set(ospf
, area
, format
);
1983 area
->auth_type
= strmatch(argv
[0]->text
, "no") ? OSPF_AUTH_NULL
: OSPF_AUTH_CRYPTOGRAPHIC
;
1988 DEFUN (ospf_area_authentication
,
1989 ospf_area_authentication_cmd
,
1990 "area <A.B.C.D|(0-4294967295)> authentication",
1991 "OSPF area parameters\n"
1992 "OSPF area ID in IP address format\n"
1993 "OSPF area ID as a decimal value\n"
1994 "Enable authentication\n")
1996 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1997 int idx_ipv4_number
= 1;
1998 struct ospf_area
*area
;
1999 struct in_addr area_id
;
2002 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
2004 area
= ospf_area_get(ospf
, area_id
);
2005 ospf_area_display_format_set(ospf
, area
, format
);
2006 area
->auth_type
= OSPF_AUTH_SIMPLE
;
2011 DEFUN (no_ospf_area_authentication
,
2012 no_ospf_area_authentication_cmd
,
2013 "no area <A.B.C.D|(0-4294967295)> authentication",
2015 "OSPF area parameters\n"
2016 "OSPF area ID in IP address format\n"
2017 "OSPF area ID as a decimal value\n"
2018 "Enable authentication\n")
2020 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2021 int idx_ipv4_number
= 2;
2022 struct ospf_area
*area
;
2023 struct in_addr area_id
;
2026 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
2028 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
2032 area
->auth_type
= OSPF_AUTH_NULL
;
2034 ospf_area_check_free(ospf
, area_id
);
2040 DEFUN (ospf_abr_type
,
2042 "ospf abr-type <cisco|ibm|shortcut|standard>",
2043 "OSPF specific commands\n"
2044 "Set OSPF ABR type\n"
2045 "Alternative ABR, cisco implementation\n"
2046 "Alternative ABR, IBM implementation\n"
2048 "Standard behavior (RFC2328)\n")
2050 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2052 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2054 if (strncmp(argv
[idx_vendor
]->arg
, "c", 1) == 0)
2055 abr_type
= OSPF_ABR_CISCO
;
2056 else if (strncmp(argv
[idx_vendor
]->arg
, "i", 1) == 0)
2057 abr_type
= OSPF_ABR_IBM
;
2058 else if (strncmp(argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2059 abr_type
= OSPF_ABR_SHORTCUT
;
2060 else if (strncmp(argv
[idx_vendor
]->arg
, "st", 2) == 0)
2061 abr_type
= OSPF_ABR_STAND
;
2063 return CMD_WARNING_CONFIG_FAILED
;
2065 /* If ABR type value is changed, schedule ABR task. */
2066 if (ospf
->abr_type
!= abr_type
) {
2067 ospf
->abr_type
= abr_type
;
2068 ospf_schedule_abr_task(ospf
);
2074 DEFUN (no_ospf_abr_type
,
2075 no_ospf_abr_type_cmd
,
2076 "no ospf abr-type <cisco|ibm|shortcut|standard>",
2078 "OSPF specific commands\n"
2079 "Set OSPF ABR type\n"
2080 "Alternative ABR, cisco implementation\n"
2081 "Alternative ABR, IBM implementation\n"
2085 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2087 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2089 if (strncmp(argv
[idx_vendor
]->arg
, "c", 1) == 0)
2090 abr_type
= OSPF_ABR_CISCO
;
2091 else if (strncmp(argv
[idx_vendor
]->arg
, "i", 1) == 0)
2092 abr_type
= OSPF_ABR_IBM
;
2093 else if (strncmp(argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2094 abr_type
= OSPF_ABR_SHORTCUT
;
2095 else if (strncmp(argv
[idx_vendor
]->arg
, "st", 2) == 0)
2096 abr_type
= OSPF_ABR_STAND
;
2098 return CMD_WARNING_CONFIG_FAILED
;
2100 /* If ABR type value is changed, schedule ABR task. */
2101 if (ospf
->abr_type
== abr_type
) {
2102 ospf
->abr_type
= OSPF_ABR_DEFAULT
;
2103 ospf_schedule_abr_task(ospf
);
2109 DEFUN (ospf_log_adjacency_changes
,
2110 ospf_log_adjacency_changes_cmd
,
2111 "log-adjacency-changes",
2112 "Log changes in adjacency state\n")
2114 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2116 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2117 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2121 DEFUN (ospf_log_adjacency_changes_detail
,
2122 ospf_log_adjacency_changes_detail_cmd
,
2123 "log-adjacency-changes detail",
2124 "Log changes in adjacency state\n"
2125 "Log all state changes\n")
2127 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2129 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2130 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2134 DEFUN (no_ospf_log_adjacency_changes
,
2135 no_ospf_log_adjacency_changes_cmd
,
2136 "no log-adjacency-changes",
2138 "Log changes in adjacency state\n")
2140 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2142 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2143 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2147 DEFUN (no_ospf_log_adjacency_changes_detail
,
2148 no_ospf_log_adjacency_changes_detail_cmd
,
2149 "no log-adjacency-changes detail",
2151 "Log changes in adjacency state\n"
2152 "Log all state changes\n")
2154 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2156 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2160 DEFUN (ospf_compatible_rfc1583
,
2161 ospf_compatible_rfc1583_cmd
,
2162 "compatible rfc1583",
2163 "OSPF compatibility list\n"
2164 "compatible with RFC 1583\n")
2166 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2168 if (!CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)) {
2169 SET_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2170 ospf_spf_calculate_schedule(ospf
, SPF_FLAG_CONFIG_CHANGE
);
2175 DEFUN (no_ospf_compatible_rfc1583
,
2176 no_ospf_compatible_rfc1583_cmd
,
2177 "no compatible rfc1583",
2179 "OSPF compatibility list\n"
2180 "compatible with RFC 1583\n")
2182 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2184 if (CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)) {
2185 UNSET_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2186 ospf_spf_calculate_schedule(ospf
, SPF_FLAG_CONFIG_CHANGE
);
2191 ALIAS(ospf_compatible_rfc1583
, ospf_rfc1583_flag_cmd
,
2192 "ospf rfc1583compatibility",
2193 "OSPF specific commands\n"
2194 "Enable the RFC1583Compatibility flag\n")
2196 ALIAS(no_ospf_compatible_rfc1583
, no_ospf_rfc1583_flag_cmd
,
2197 "no ospf rfc1583compatibility", NO_STR
2198 "OSPF specific commands\n"
2199 "Disable the RFC1583Compatibility flag\n")
2201 static int ospf_timers_spf_set(struct vty
*vty
, unsigned int delay
,
2202 unsigned int hold
, unsigned int max
)
2204 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2206 ospf
->spf_delay
= delay
;
2207 ospf
->spf_holdtime
= hold
;
2208 ospf
->spf_max_holdtime
= max
;
2213 DEFUN (ospf_timers_min_ls_interval
,
2214 ospf_timers_min_ls_interval_cmd
,
2215 "timers throttle lsa all (0-5000)",
2216 "Adjust routing timers\n"
2217 "Throttling adaptive timer\n"
2218 "LSA delay between transmissions\n"
2220 "Delay (msec) between sending LSAs\n")
2222 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2224 unsigned int interval
;
2227 vty_out(vty
, "Insufficient arguments\n");
2228 return CMD_WARNING_CONFIG_FAILED
;
2231 interval
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2233 ospf
->min_ls_interval
= interval
;
2238 DEFUN (no_ospf_timers_min_ls_interval
,
2239 no_ospf_timers_min_ls_interval_cmd
,
2240 "no timers throttle lsa all [(0-5000)]",
2242 "Adjust routing timers\n"
2243 "Throttling adaptive timer\n"
2244 "LSA delay between transmissions\n"
2246 "Delay (msec) between sending LSAs\n")
2248 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2249 ospf
->min_ls_interval
= OSPF_MIN_LS_INTERVAL
;
2254 DEFUN (ospf_timers_throttle_spf
,
2255 ospf_timers_throttle_spf_cmd
,
2256 "timers throttle spf (0-600000) (0-600000) (0-600000)",
2257 "Adjust routing timers\n"
2258 "Throttling adaptive timer\n"
2260 "Delay (msec) from first change received till SPF calculation\n"
2261 "Initial hold time (msec) between consecutive SPF calculations\n"
2262 "Maximum hold time (msec)\n")
2265 int idx_number_2
= 4;
2266 int idx_number_3
= 5;
2267 unsigned int delay
, hold
, max
;
2270 vty_out(vty
, "Insufficient arguments\n");
2271 return CMD_WARNING_CONFIG_FAILED
;
2274 delay
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2275 hold
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
2276 max
= strtoul(argv
[idx_number_3
]->arg
, NULL
, 10);
2278 return ospf_timers_spf_set(vty
, delay
, hold
, max
);
2281 DEFUN (no_ospf_timers_throttle_spf
,
2282 no_ospf_timers_throttle_spf_cmd
,
2283 "no timers throttle spf [(0-600000)(0-600000)(0-600000)]",
2285 "Adjust routing timers\n"
2286 "Throttling adaptive timer\n"
2288 "Delay (msec) from first change received till SPF calculation\n"
2289 "Initial hold time (msec) between consecutive SPF calculations\n"
2290 "Maximum hold time (msec)\n")
2292 return ospf_timers_spf_set(vty
, OSPF_SPF_DELAY_DEFAULT
,
2293 OSPF_SPF_HOLDTIME_DEFAULT
,
2294 OSPF_SPF_MAX_HOLDTIME_DEFAULT
);
2298 DEFUN (ospf_timers_lsa_min_arrival
,
2299 ospf_timers_lsa_min_arrival_cmd
,
2300 "timers lsa min-arrival (0-600000)",
2301 "Adjust routing timers\n"
2303 "Minimum delay in receiving new version of a LSA\n"
2304 "Delay in milliseconds\n")
2306 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2307 ospf
->min_ls_arrival
= strtoul(argv
[argc
- 1]->arg
, NULL
, 10);
2311 DEFUN (no_ospf_timers_lsa_min_arrival
,
2312 no_ospf_timers_lsa_min_arrival_cmd
,
2313 "no timers lsa min-arrival [(0-600000)]",
2315 "Adjust routing timers\n"
2317 "Minimum delay in receiving new version of a LSA\n"
2318 "Delay in milliseconds\n")
2320 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2321 unsigned int minarrival
;
2324 minarrival
= strtoul(argv
[argc
- 1]->arg
, NULL
, 10);
2326 if (ospf
->min_ls_arrival
!= minarrival
2327 || minarrival
== OSPF_MIN_LS_ARRIVAL
)
2331 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2336 #if CONFDATE > 20180708
2337 CPP_NOTICE("ospf: `timers lsa arrival (0-1000)` deprecated 2017/07/08")
2339 ALIAS_HIDDEN (ospf_timers_lsa_min_arrival
,
2340 ospf_timers_lsa_arrival_cmd
,
2341 "timers lsa arrival (0-1000)",
2342 "adjust routing timers\n"
2343 "throttling link state advertisement delays\n"
2344 "ospf minimum arrival interval delay\n"
2345 "delay (msec) between accepted lsas\n");
2347 #if CONFDATE > 20180708
2348 CPP_NOTICE("ospf: `no timers lsa arrival (0-1000)` deprecated 2017/07/08")
2350 ALIAS_HIDDEN (no_ospf_timers_lsa_min_arrival
,
2351 no_ospf_timers_lsa_arrival_cmd
,
2352 "no timers lsa arrival (0-1000)",
2354 "adjust routing timers\n"
2355 "throttling link state advertisement delays\n"
2356 "ospf minimum arrival interval delay\n"
2357 "delay (msec) between accepted lsas\n");
2360 DEFUN (ospf_neighbor
,
2362 "neighbor A.B.C.D [priority (0-255) [poll-interval (1-65535)]]",
2364 "Neighbor IP address\n"
2365 "Neighbor Priority\n"
2367 "Dead Neighbor Polling interval\n"
2370 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2374 struct in_addr nbr_addr
;
2375 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2376 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2378 if (!inet_aton(argv
[idx_ipv4
]->arg
, &nbr_addr
)) {
2379 vty_out(vty
, "Please specify Neighbor ID by A.B.C.D\n");
2380 return CMD_WARNING_CONFIG_FAILED
;
2384 priority
= strtoul(argv
[idx_pri
]->arg
, NULL
, 10);
2387 interval
= strtoul(argv
[idx_poll
]->arg
, NULL
, 10);
2389 ospf_nbr_nbma_set(ospf
, nbr_addr
);
2392 ospf_nbr_nbma_priority_set(ospf
, nbr_addr
, priority
);
2395 ospf_nbr_nbma_poll_interval_set(ospf
, nbr_addr
, interval
);
2400 DEFUN (ospf_neighbor_poll_interval
,
2401 ospf_neighbor_poll_interval_cmd
,
2402 "neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2404 "Neighbor IP address\n"
2405 "Dead Neighbor Polling interval\n"
2407 "OSPF priority of non-broadcast neighbor\n"
2410 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2414 struct in_addr nbr_addr
;
2415 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2416 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2418 if (!inet_aton(argv
[idx_ipv4
]->arg
, &nbr_addr
)) {
2419 vty_out(vty
, "Please specify Neighbor ID by A.B.C.D\n");
2420 return CMD_WARNING_CONFIG_FAILED
;
2423 interval
= strtoul(argv
[idx_poll
]->arg
, NULL
, 10);
2426 priority
= strtoul(argv
[idx_pri
]->arg
, NULL
, 10);
2428 ospf_nbr_nbma_set(ospf
, nbr_addr
);
2429 ospf_nbr_nbma_poll_interval_set(ospf
, nbr_addr
, interval
);
2432 ospf_nbr_nbma_priority_set(ospf
, nbr_addr
, priority
);
2437 DEFUN (no_ospf_neighbor
,
2438 no_ospf_neighbor_cmd
,
2439 "no neighbor A.B.C.D [priority (0-255) [poll-interval (1-65525)]]",
2442 "Neighbor IP address\n"
2443 "Neighbor Priority\n"
2445 "Dead Neighbor Polling interval\n"
2448 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2450 struct in_addr nbr_addr
;
2452 if (!inet_aton(argv
[idx_ipv4
]->arg
, &nbr_addr
)) {
2453 vty_out(vty
, "Please specify Neighbor ID by A.B.C.D\n");
2454 return CMD_WARNING_CONFIG_FAILED
;
2457 (void)ospf_nbr_nbma_unset(ospf
, nbr_addr
);
2462 DEFUN (no_ospf_neighbor_poll
,
2463 no_ospf_neighbor_poll_cmd
,
2464 "no neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2467 "Neighbor IP address\n"
2468 "Dead Neighbor Polling interval\n"
2470 "Neighbor Priority\n"
2473 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2475 struct in_addr nbr_addr
;
2477 if (!inet_aton(argv
[idx_ipv4
]->arg
, &nbr_addr
)) {
2478 vty_out(vty
, "Please specify Neighbor ID by A.B.C.D\n");
2479 return CMD_WARNING_CONFIG_FAILED
;
2482 (void)ospf_nbr_nbma_unset(ospf
, nbr_addr
);
2487 DEFUN (ospf_refresh_timer
,
2488 ospf_refresh_timer_cmd
,
2489 "refresh timer (10-1800)",
2490 "Adjust refresh parameters\n"
2491 "Set refresh timer\n"
2492 "Timer value in seconds\n")
2494 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2496 unsigned int interval
;
2498 interval
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2499 interval
= (interval
/ OSPF_LSA_REFRESHER_GRANULARITY
)
2500 * OSPF_LSA_REFRESHER_GRANULARITY
;
2502 ospf_timers_refresh_set(ospf
, interval
);
2507 DEFUN (no_ospf_refresh_timer
,
2508 no_ospf_refresh_timer_val_cmd
,
2509 "no refresh timer [(10-1800)]",
2511 "Adjust refresh parameters\n"
2512 "Unset refresh timer\n"
2513 "Timer value in seconds\n")
2515 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2517 unsigned int interval
;
2520 interval
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2522 if (ospf
->lsa_refresh_interval
!= interval
2523 || interval
== OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
2527 ospf_timers_refresh_unset(ospf
);
2533 DEFUN (ospf_auto_cost_reference_bandwidth
,
2534 ospf_auto_cost_reference_bandwidth_cmd
,
2535 "auto-cost reference-bandwidth (1-4294967)",
2536 "Calculate OSPF interface cost according to bandwidth\n"
2537 "Use reference bandwidth method to assign OSPF cost\n"
2538 "The reference bandwidth in terms of Mbits per second\n")
2540 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2541 struct vrf
*vrf
= vrf_lookup_by_id(ospf
->vrf_id
);
2544 struct interface
*ifp
;
2546 refbw
= strtol(argv
[idx_number
]->arg
, NULL
, 10);
2547 if (refbw
< 1 || refbw
> 4294967) {
2548 vty_out(vty
, "reference-bandwidth value is invalid\n");
2549 return CMD_WARNING_CONFIG_FAILED
;
2552 /* If reference bandwidth is changed. */
2553 if ((refbw
) == ospf
->ref_bandwidth
)
2556 ospf
->ref_bandwidth
= refbw
;
2557 FOR_ALL_INTERFACES (vrf
, ifp
)
2558 ospf_if_recalculate_output_cost(ifp
);
2563 DEFUN (no_ospf_auto_cost_reference_bandwidth
,
2564 no_ospf_auto_cost_reference_bandwidth_cmd
,
2565 "no auto-cost reference-bandwidth [(1-4294967)]",
2567 "Calculate OSPF interface cost according to bandwidth\n"
2568 "Use reference bandwidth method to assign OSPF cost\n"
2569 "The reference bandwidth in terms of Mbits per second\n")
2571 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2572 struct vrf
*vrf
= vrf_lookup_by_id(ospf
->vrf_id
);
2573 struct interface
*ifp
;
2575 if (ospf
->ref_bandwidth
== OSPF_DEFAULT_REF_BANDWIDTH
)
2578 ospf
->ref_bandwidth
= OSPF_DEFAULT_REF_BANDWIDTH
;
2579 vty_out(vty
, "%% OSPF: Reference bandwidth is changed.\n");
2581 " Please ensure reference bandwidth is consistent across all routers\n");
2583 FOR_ALL_INTERFACES (vrf
, ifp
)
2584 ospf_if_recalculate_output_cost(ifp
);
2589 DEFUN (ospf_write_multiplier
,
2590 ospf_write_multiplier_cmd
,
2591 "ospf write-multiplier (1-100)",
2592 "OSPF specific commands\n"
2593 "Write multiplier\n"
2594 "Maximum number of interface serviced per write\n")
2596 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2598 u_int32_t write_oi_count
;
2605 write_oi_count
= strtol(argv
[idx_number
]->arg
, NULL
, 10);
2606 if (write_oi_count
< 1 || write_oi_count
> 100) {
2607 vty_out(vty
, "write-multiplier value is invalid\n");
2608 return CMD_WARNING_CONFIG_FAILED
;
2611 ospf
->write_oi_count
= write_oi_count
;
2615 ALIAS(ospf_write_multiplier
, write_multiplier_cmd
, "write-multiplier (1-100)",
2616 "Write multiplier\n"
2617 "Maximum number of interface serviced per write\n")
2619 DEFUN (no_ospf_write_multiplier
,
2620 no_ospf_write_multiplier_cmd
,
2621 "no ospf write-multiplier (1-100)",
2623 "OSPF specific commands\n"
2624 "Write multiplier\n"
2625 "Maximum number of interface serviced per write\n")
2627 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2629 ospf
->write_oi_count
= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
;
2633 ALIAS(no_ospf_write_multiplier
, no_write_multiplier_cmd
,
2634 "no write-multiplier (1-100)", NO_STR
2635 "Write multiplier\n"
2636 "Maximum number of interface serviced per write\n")
2638 const char *ospf_abr_type_descr_str
[] = {"Unknown", "Standard (RFC2328)",
2639 "Alternative IBM", "Alternative Cisco",
2640 "Alternative Shortcut"};
2642 const char *ospf_shortcut_mode_descr_str
[] = {"Default", "Enabled", "Disabled"};
2644 static void show_ip_ospf_area(struct vty
*vty
, struct ospf_area
*area
,
2645 json_object
*json_areas
, u_char use_json
)
2647 json_object
*json_area
= NULL
;
2650 json_area
= json_object_new_object();
2654 vty_out(vty
, " Area ID: %s", inet_ntoa(area
->area_id
));
2656 /* Show Area type/mode. */
2657 if (OSPF_IS_AREA_BACKBONE(area
)) {
2659 json_object_boolean_true_add(json_area
, "backbone");
2661 vty_out(vty
, " (Backbone)\n");
2664 if (area
->external_routing
== OSPF_AREA_STUB
) {
2665 if (area
->no_summary
)
2666 json_object_boolean_true_add(
2667 json_area
, "stubNoSummary");
2668 if (area
->shortcut_configured
)
2669 json_object_boolean_true_add(
2670 json_area
, "stubShortcut");
2671 } else if (area
->external_routing
== OSPF_AREA_NSSA
) {
2672 if (area
->no_summary
)
2673 json_object_boolean_true_add(
2674 json_area
, "nssaNoSummary");
2675 if (area
->shortcut_configured
)
2676 json_object_boolean_true_add(
2677 json_area
, "nssaShortcut");
2680 json_object_string_add(
2681 json_area
, "shortcuttingMode",
2682 ospf_shortcut_mode_descr_str
2683 [area
->shortcut_configured
]);
2684 if (area
->shortcut_capability
)
2685 json_object_boolean_true_add(json_area
,
2688 if (area
->external_routing
== OSPF_AREA_STUB
)
2689 vty_out(vty
, " (Stub%s%s)",
2690 area
->no_summary
? ", no summary" : "",
2691 area
->shortcut_configured
? "; " : "");
2692 else if (area
->external_routing
== OSPF_AREA_NSSA
)
2693 vty_out(vty
, " (NSSA%s%s)",
2694 area
->no_summary
? ", no summary" : "",
2695 area
->shortcut_configured
? "; " : "");
2698 vty_out(vty
, " Shortcutting mode: %s",
2699 ospf_shortcut_mode_descr_str
2700 [area
->shortcut_configured
]);
2701 vty_out(vty
, ", S-bit consensus: %s\n",
2702 area
->shortcut_capability
? "ok" : "no");
2706 /* Show number of interfaces */
2708 json_object_int_add(json_area
, "areaIfTotalCounter",
2709 listcount(area
->oiflist
));
2710 json_object_int_add(json_area
, "areaIfActiveCounter",
2714 " Number of interfaces in this area: Total: %d, "
2716 listcount(area
->oiflist
), area
->act_ints
);
2718 if (area
->external_routing
== OSPF_AREA_NSSA
) {
2720 json_object_boolean_true_add(json_area
, "nssa");
2721 if (!IS_OSPF_ABR(area
->ospf
))
2722 json_object_boolean_false_add(json_area
, "abr");
2723 else if (area
->NSSATranslatorState
) {
2724 json_object_boolean_true_add(json_area
, "abr");
2725 if (area
->NSSATranslatorRole
2726 == OSPF_NSSA_ROLE_CANDIDATE
)
2727 json_object_boolean_true_add(
2729 "nssaTranslatorElected");
2730 else if (area
->NSSATranslatorRole
2731 == OSPF_NSSA_ROLE_ALWAYS
)
2732 json_object_boolean_true_add(
2734 "nssaTranslatorAlways");
2736 json_object_boolean_true_add(json_area
, "abr");
2737 if (area
->NSSATranslatorRole
2738 == OSPF_NSSA_ROLE_CANDIDATE
)
2739 json_object_boolean_false_add(
2741 "nssaTranslatorElected");
2743 json_object_boolean_true_add(
2745 "nssaTranslatorNever");
2749 " It is an NSSA configuration. \n Elected NSSA/ABR performs type-7/type-5 LSA translation. \n");
2750 if (!IS_OSPF_ABR(area
->ospf
))
2752 " It is not ABR, therefore not Translator. \n");
2753 else if (area
->NSSATranslatorState
) {
2754 vty_out(vty
, " We are an ABR and ");
2755 if (area
->NSSATranslatorRole
2756 == OSPF_NSSA_ROLE_CANDIDATE
)
2758 "the NSSA Elected Translator. \n");
2759 else if (area
->NSSATranslatorRole
2760 == OSPF_NSSA_ROLE_ALWAYS
)
2762 "always an NSSA Translator. \n");
2764 vty_out(vty
, " We are an ABR, but ");
2765 if (area
->NSSATranslatorRole
2766 == OSPF_NSSA_ROLE_CANDIDATE
)
2768 "not the NSSA Elected Translator. \n");
2771 "never an NSSA Translator. \n");
2776 /* Stub-router state for this area */
2777 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
)) {
2778 char timebuf
[OSPF_TIME_DUMP_SIZE
];
2781 json_object_boolean_true_add(
2782 json_area
, "originStubMaxDistRouterLsa");
2783 if (CHECK_FLAG(area
->stub_router_state
,
2784 OSPF_AREA_ADMIN_STUB_ROUTED
))
2785 json_object_boolean_true_add(
2786 json_area
, "indefiniteActiveAdmin");
2787 if (area
->t_stub_router
) {
2791 &area
->t_stub_router
->u
.sands
,
2794 json_object_int_add(
2796 "activeStartupRemainderMsecs",
2801 " Originating stub / maximum-distance Router-LSA\n");
2802 if (CHECK_FLAG(area
->stub_router_state
,
2803 OSPF_AREA_ADMIN_STUB_ROUTED
))
2805 " Administratively activated (indefinitely)\n");
2806 if (area
->t_stub_router
)
2808 " Active from startup, %s remaining\n",
2809 ospf_timer_dump(area
->t_stub_router
,
2816 /* Show number of fully adjacent neighbors. */
2817 json_object_int_add(json_area
, "nbrFullAdjacentCounter",
2820 /* Show authentication type. */
2821 if (area
->auth_type
== OSPF_AUTH_NULL
)
2822 json_object_string_add(json_area
, "authentication",
2823 "authenticationNone");
2824 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
2825 json_object_string_add(json_area
, "authentication",
2826 "authenticationSimplePassword");
2827 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
2828 json_object_string_add(json_area
, "authentication",
2829 "authenticationMessageDigest");
2831 if (!OSPF_IS_AREA_BACKBONE(area
))
2832 json_object_int_add(json_area
,
2833 "virtualAdjacenciesPassingCounter",
2836 /* Show SPF calculation times. */
2837 json_object_int_add(json_area
, "spfExecutedCounter",
2838 area
->spf_calculation
);
2839 json_object_int_add(json_area
, "lsaNumber", area
->lsdb
->total
);
2840 json_object_int_add(
2841 json_area
, "lsaRouterNumber",
2842 ospf_lsdb_count(area
->lsdb
, OSPF_ROUTER_LSA
));
2843 json_object_int_add(
2844 json_area
, "lsaRouterChecksum",
2845 ospf_lsdb_checksum(area
->lsdb
, OSPF_ROUTER_LSA
));
2846 json_object_int_add(
2847 json_area
, "lsaNetworkNumber",
2848 ospf_lsdb_count(area
->lsdb
, OSPF_NETWORK_LSA
));
2849 json_object_int_add(
2850 json_area
, "lsaNetworkChecksum",
2851 ospf_lsdb_checksum(area
->lsdb
, OSPF_NETWORK_LSA
));
2852 json_object_int_add(
2853 json_area
, "lsaSummaryNumber",
2854 ospf_lsdb_count(area
->lsdb
, OSPF_SUMMARY_LSA
));
2855 json_object_int_add(
2856 json_area
, "lsaSummaryChecksum",
2857 ospf_lsdb_checksum(area
->lsdb
, OSPF_SUMMARY_LSA
));
2858 json_object_int_add(
2859 json_area
, "lsaAsbrNumber",
2860 ospf_lsdb_count(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2861 json_object_int_add(
2862 json_area
, "lsaAsbrChecksum",
2863 ospf_lsdb_checksum(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2864 json_object_int_add(
2865 json_area
, "lsaNssaNumber",
2866 ospf_lsdb_count(area
->lsdb
, OSPF_AS_NSSA_LSA
));
2867 json_object_int_add(
2868 json_area
, "lsaNssaChecksum",
2869 ospf_lsdb_checksum(area
->lsdb
, OSPF_AS_NSSA_LSA
));
2871 /* Show number of fully adjacent neighbors. */
2873 " Number of fully adjacent neighbors in this area:"
2877 /* Show authentication type. */
2878 vty_out(vty
, " Area has ");
2879 if (area
->auth_type
== OSPF_AUTH_NULL
)
2880 vty_out(vty
, "no authentication\n");
2881 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
2882 vty_out(vty
, "simple password authentication\n");
2883 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
2884 vty_out(vty
, "message digest authentication\n");
2886 if (!OSPF_IS_AREA_BACKBONE(area
))
2888 " Number of full virtual adjacencies going through"
2892 /* Show SPF calculation times. */
2893 vty_out(vty
, " SPF algorithm executed %d times\n",
2894 area
->spf_calculation
);
2896 /* Show number of LSA. */
2897 vty_out(vty
, " Number of LSA %ld\n", area
->lsdb
->total
);
2899 " Number of router LSA %ld. Checksum Sum 0x%08x\n",
2900 ospf_lsdb_count(area
->lsdb
, OSPF_ROUTER_LSA
),
2901 ospf_lsdb_checksum(area
->lsdb
, OSPF_ROUTER_LSA
));
2903 " Number of network LSA %ld. Checksum Sum 0x%08x\n",
2904 ospf_lsdb_count(area
->lsdb
, OSPF_NETWORK_LSA
),
2905 ospf_lsdb_checksum(area
->lsdb
, OSPF_NETWORK_LSA
));
2907 " Number of summary LSA %ld. Checksum Sum 0x%08x\n",
2908 ospf_lsdb_count(area
->lsdb
, OSPF_SUMMARY_LSA
),
2909 ospf_lsdb_checksum(area
->lsdb
, OSPF_SUMMARY_LSA
));
2911 " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x\n",
2912 ospf_lsdb_count(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
),
2913 ospf_lsdb_checksum(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2914 vty_out(vty
, " Number of NSSA LSA %ld. Checksum Sum 0x%08x\n",
2915 ospf_lsdb_count(area
->lsdb
, OSPF_AS_NSSA_LSA
),
2916 ospf_lsdb_checksum(area
->lsdb
, OSPF_AS_NSSA_LSA
));
2920 json_object_int_add(
2921 json_area
, "lsaOpaqueLinkNumber",
2922 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
2923 json_object_int_add(
2924 json_area
, "lsaOpaqueLinkChecksum",
2925 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
2926 json_object_int_add(
2927 json_area
, "lsaOpaqueAreaNumber",
2928 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
2929 json_object_int_add(
2930 json_area
, "lsaOpaqueAreaChecksum",
2931 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
2934 " Number of opaque link LSA %ld. Checksum Sum 0x%08x\n",
2935 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
),
2936 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
2938 " Number of opaque area LSA %ld. Checksum Sum 0x%08x\n",
2939 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
),
2940 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
2944 json_object_object_add(json_areas
, inet_ntoa(area
->area_id
),
2950 static int show_ip_ospf_common(struct vty
*vty
, struct ospf
*ospf
,
2951 json_object
*json
, u_char use_vrf
)
2953 struct listnode
*node
, *nnode
;
2954 struct ospf_area
*area
;
2955 struct timeval result
;
2956 char timebuf
[OSPF_TIME_DUMP_SIZE
];
2957 json_object
*json_vrf
= NULL
;
2958 json_object
*json_areas
= NULL
;
2962 json_vrf
= json_object_new_object();
2965 json_areas
= json_object_new_object();
2968 if (ospf
->instance
) {
2970 json_object_int_add(json
, "ospfInstance",
2973 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
2977 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
2979 /* Show Router ID. */
2981 json_object_string_add(json_vrf
, "routerId",
2982 inet_ntoa(ospf
->router_id
));
2984 vty_out(vty
, " OSPF Routing Process, Router ID: %s\n",
2985 inet_ntoa(ospf
->router_id
));
2988 /* Graceful shutdown */
2989 if (ospf
->t_deferred_shutdown
) {
2994 &ospf
->t_deferred_shutdown
->u
.sands
,
2997 json_object_int_add(json_vrf
, "deferredShutdownMsecs",
3001 " Deferred shutdown in progress, %s remaining\n",
3002 ospf_timer_dump(ospf
->t_deferred_shutdown
,
3003 timebuf
, sizeof(timebuf
)));
3007 /* Show capability. */
3009 json_object_boolean_true_add(json_vrf
, "tosRoutesOnly");
3010 json_object_boolean_true_add(json_vrf
, "rfc2328Conform");
3011 if (CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)) {
3012 json_object_boolean_true_add(json_vrf
,
3013 "rfc1583Compatibility");
3016 vty_out(vty
, " Supports only single TOS (TOS0) routes\n");
3017 vty_out(vty
, " This implementation conforms to RFC2328\n");
3018 vty_out(vty
, " RFC1583Compatibility flag is %s\n",
3019 CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)
3025 if (CHECK_FLAG(ospf
->config
, OSPF_OPAQUE_CAPABLE
)) {
3026 json_object_boolean_true_add(json_vrf
, "opaqueCapable");
3029 vty_out(vty
, " OpaqueCapability flag is %s\n",
3030 CHECK_FLAG(ospf
->config
, OSPF_OPAQUE_CAPABLE
)
3035 /* Show stub-router configuration */
3036 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
3037 || ospf
->stub_router_shutdown_time
3038 != OSPF_STUB_ROUTER_UNCONFIGURED
) {
3040 json_object_boolean_true_add(json_vrf
,
3041 "stubAdvertisement");
3042 if (ospf
->stub_router_startup_time
3043 != OSPF_STUB_ROUTER_UNCONFIGURED
)
3044 json_object_int_add(
3045 json_vrf
, "postStartEnabledMsecs",
3046 ospf
->stub_router_startup_time
/ 1000);
3047 if (ospf
->stub_router_shutdown_time
3048 != OSPF_STUB_ROUTER_UNCONFIGURED
)
3049 json_object_int_add(
3050 json_vrf
, "preShutdownEnabledMsecs",
3051 ospf
->stub_router_shutdown_time
/ 1000);
3054 " Stub router advertisement is configured\n");
3055 if (ospf
->stub_router_startup_time
3056 != OSPF_STUB_ROUTER_UNCONFIGURED
)
3058 " Enabled for %us after start-up\n",
3059 ospf
->stub_router_startup_time
);
3060 if (ospf
->stub_router_shutdown_time
3061 != OSPF_STUB_ROUTER_UNCONFIGURED
)
3063 " Enabled for %us prior to full shutdown\n",
3064 ospf
->stub_router_shutdown_time
);
3068 /* Show SPF timers. */
3070 json_object_int_add(json_vrf
, "spfScheduleDelayMsecs",
3072 json_object_int_add(json_vrf
, "holdtimeMinMsecs",
3073 ospf
->spf_holdtime
);
3074 json_object_int_add(json_vrf
, "holdtimeMaxMsecs",
3075 ospf
->spf_max_holdtime
);
3076 json_object_int_add(json_vrf
, "holdtimeMultplier",
3077 ospf
->spf_hold_multiplier
);
3080 " Initial SPF scheduling delay %d millisec(s)\n"
3081 " Minimum hold time between consecutive SPFs %d millisec(s)\n"
3082 " Maximum hold time between consecutive SPFs %d millisec(s)\n"
3083 " Hold time multiplier is currently %d\n",
3084 ospf
->spf_delay
, ospf
->spf_holdtime
,
3085 ospf
->spf_max_holdtime
, ospf
->spf_hold_multiplier
);
3089 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
) {
3090 long time_store
= 0;
3093 monotime_since(&ospf
->ts_spf
, NULL
) / 1000LL;
3094 json_object_int_add(json_vrf
, "spfLastExecutedMsecs",
3097 time_store
= (1000 * ospf
->ts_spf_duration
.tv_sec
)
3098 + (ospf
->ts_spf_duration
.tv_usec
/ 1000);
3099 json_object_int_add(json_vrf
, "spfLastDurationMsecs",
3102 json_object_boolean_true_add(json_vrf
, "spfHasNotRun");
3104 vty_out(vty
, " SPF algorithm ");
3105 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
) {
3106 monotime_since(&ospf
->ts_spf
, &result
);
3107 vty_out(vty
, "last executed %s ago\n",
3108 ospf_timeval_dump(&result
, timebuf
,
3110 vty_out(vty
, " Last SPF duration %s\n",
3111 ospf_timeval_dump(&ospf
->ts_spf_duration
,
3112 timebuf
, sizeof(timebuf
)));
3114 vty_out(vty
, "has not been run\n");
3118 if (ospf
->t_spf_calc
) {
3121 monotime_until(&ospf
->t_spf_calc
->u
.sands
, NULL
)
3123 json_object_int_add(json_vrf
, "spfTimerDueInMsecs",
3127 json_object_int_add(json_vrf
, "lsaMinIntervalMsecs",
3128 ospf
->min_ls_interval
);
3129 json_object_int_add(json_vrf
, "lsaMinArrivalMsecs",
3130 ospf
->min_ls_arrival
);
3131 /* Show write multiplier values */
3132 json_object_int_add(json_vrf
, "writeMultiplier",
3133 ospf
->write_oi_count
);
3134 /* Show refresh parameters. */
3135 json_object_int_add(json_vrf
, "refreshTimerMsecs",
3136 ospf
->lsa_refresh_interval
* 1000);
3138 vty_out(vty
, " SPF timer %s%s\n",
3139 (ospf
->t_spf_calc
? "due in " : "is "),
3140 ospf_timer_dump(ospf
->t_spf_calc
, timebuf
,
3143 vty_out(vty
, " LSA minimum interval %d msecs\n",
3144 ospf
->min_ls_interval
);
3145 vty_out(vty
, " LSA minimum arrival %d msecs\n",
3146 ospf
->min_ls_arrival
);
3148 /* Show write multiplier values */
3149 vty_out(vty
, " Write Multiplier set to %d \n",
3150 ospf
->write_oi_count
);
3152 /* Show refresh parameters. */
3153 vty_out(vty
, " Refresh timer %d secs\n",
3154 ospf
->lsa_refresh_interval
);
3157 /* Show ABR/ASBR flags. */
3158 if (CHECK_FLAG(ospf
->flags
, OSPF_FLAG_ABR
)) {
3160 json_object_string_add(
3161 json_vrf
, "abrType",
3162 ospf_abr_type_descr_str
[ospf
->abr_type
]);
3165 " This router is an ABR, ABR type is: %s\n",
3166 ospf_abr_type_descr_str
[ospf
->abr_type
]);
3168 if (CHECK_FLAG(ospf
->flags
, OSPF_FLAG_ASBR
)) {
3170 json_object_string_add(
3171 json_vrf
, "asbrRouter",
3172 "injectingExternalRoutingInformation");
3175 " This router is an ASBR "
3176 "(injecting external routing information)\n");
3179 /* Show Number of AS-external-LSAs. */
3181 json_object_int_add(
3182 json_vrf
, "lsaExternalCounter",
3183 ospf_lsdb_count(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3184 json_object_int_add(
3185 json_vrf
, "lsaExternalChecksum",
3186 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3189 " Number of external LSA %ld. Checksum Sum 0x%08x\n",
3190 ospf_lsdb_count(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
),
3191 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3195 json_object_int_add(
3196 json_vrf
, "lsaAsopaqueCounter",
3197 ospf_lsdb_count(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3198 json_object_int_add(
3199 json_vrf
, "lsaAsOpaqueChecksum",
3200 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3203 " Number of opaque AS LSA %ld. Checksum Sum 0x%08x\n",
3204 ospf_lsdb_count(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
),
3205 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3208 /* Show number of areas attached. */
3210 json_object_int_add(json_vrf
, "attachedAreaCounter",
3211 listcount(ospf
->areas
));
3213 vty_out(vty
, " Number of areas attached to this router: %d\n",
3214 listcount(ospf
->areas
));
3216 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
)) {
3217 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
)) {
3219 json_object_boolean_true_add(
3220 json_vrf
, "adjacencyChangesLoggedAll");
3223 " All adjacency changes are logged\n");
3226 json_object_boolean_true_add(
3227 json_vrf
, "adjacencyChangesLogged");
3229 vty_out(vty
, " Adjacency changes are logged\n");
3232 /* Show each area status. */
3233 for (ALL_LIST_ELEMENTS(ospf
->areas
, node
, nnode
, area
))
3234 show_ip_ospf_area(vty
, area
, json_areas
, json
? 1 : 0);
3238 json_object_object_add(json_vrf
, "areas", json_areas
);
3239 if (ospf
->vrf_id
== VRF_DEFAULT
)
3240 json_object_object_add(json
, "default",
3243 json_object_object_add(json
, ospf
->name
,
3246 json_object_object_add(json
, "areas", json_areas
);
3254 DEFUN (show_ip_ospf
,
3256 "show ip ospf [vrf <NAME|all>] [json]",
3259 "OSPF information\n"
3265 u_char uj
= use_json(argc
, argv
);
3266 struct listnode
*node
= NULL
;
3267 char *vrf_name
= NULL
;
3268 bool all_vrf
= FALSE
;
3269 int ret
= CMD_SUCCESS
;
3272 json_object
*json
= NULL
;
3275 if (listcount(om
->ospf
) == 0)
3278 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
3281 json
= json_object_new_object();
3283 /* vrf input is provided could be all or specific vrf*/
3287 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
3288 if (!ospf
->oi_running
)
3290 ret
= show_ip_ospf_common(vty
, ospf
, json
,
3294 vty_out(vty
, "%s\n",
3295 json_object_to_json_string_ext(json
,
3296 JSON_C_TO_STRING_PRETTY
));
3297 json_object_free(json
);
3301 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
3302 if ((ospf
== NULL
) || !ospf
->oi_running
) {
3304 json_object_free(json
);
3308 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
3309 /* Display default ospf (instance 0) info */
3310 if (ospf
== NULL
|| !ospf
->oi_running
) {
3312 json_object_free(json
);
3318 show_ip_ospf_common(vty
, ospf
, json
, use_vrf
);
3320 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
3321 json
, JSON_C_TO_STRING_PRETTY
));
3325 json_object_free(json
);
3330 DEFUN (show_ip_ospf_instance
,
3331 show_ip_ospf_instance_cmd
,
3332 "show ip ospf (1-65535) [json]",
3335 "OSPF information\n"
3341 u_short instance
= 0;
3342 u_char uj
= use_json(argc
, argv
);
3343 int ret
= CMD_SUCCESS
;
3344 json_object
*json
= NULL
;
3346 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3347 ospf
= ospf_lookup_instance(instance
);
3349 return CMD_NOT_MY_INSTANCE
;
3351 if (!ospf
->oi_running
)
3355 json
= json_object_new_object();
3357 ret
= show_ip_ospf_common(vty
, ospf
, json
, 0);
3360 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
3361 JSON_C_TO_STRING_PRETTY
));
3362 json_object_free(json
);
3368 static void show_ip_ospf_interface_sub(struct vty
*vty
, struct ospf
*ospf
,
3369 struct interface
*ifp
,
3370 json_object
*json_interface_sub
,
3374 struct ospf_neighbor
*nbr
;
3375 struct route_node
*rn
;
3376 uint32_t bandwidth
= ifp
->bandwidth
? ifp
->bandwidth
: ifp
->speed
;
3378 /* Is interface up? */
3380 is_up
= if_is_operative(ifp
);
3382 json_object_boolean_true_add(json_interface_sub
,
3385 json_object_boolean_false_add(json_interface_sub
,
3388 json_object_int_add(json_interface_sub
, "ifIndex",
3390 json_object_int_add(json_interface_sub
, "mtuBytes", ifp
->mtu
);
3391 json_object_int_add(json_interface_sub
, "bandwidthMbit",
3393 json_object_string_add(json_interface_sub
, "ifFlags",
3394 if_flag_dump(ifp
->flags
));
3396 vty_out(vty
, "%s is %s\n", ifp
->name
,
3397 ((is_up
= if_is_operative(ifp
)) ? "up" : "down"));
3398 vty_out(vty
, " ifindex %u, MTU %u bytes, BW %u Mbit %s\n",
3399 ifp
->ifindex
, ifp
->mtu
, bandwidth
,
3400 if_flag_dump(ifp
->flags
));
3403 /* Is interface OSPF enabled? */
3405 if (ospf_oi_count(ifp
) == 0) {
3406 json_object_boolean_false_add(json_interface_sub
,
3409 } else if (!is_up
) {
3410 json_object_boolean_false_add(json_interface_sub
,
3414 json_object_boolean_true_add(json_interface_sub
,
3417 if (ospf_oi_count(ifp
) == 0) {
3418 vty_out(vty
, " OSPF not enabled on this interface\n");
3420 } else if (!is_up
) {
3422 " OSPF is enabled, but not running on this interface\n");
3427 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
3428 struct ospf_interface
*oi
= rn
->info
;
3433 if (CHECK_FLAG(oi
->connected
->flags
, ZEBRA_IFA_UNNUMBERED
)) {
3435 json_object_boolean_true_add(json_interface_sub
,
3438 vty_out(vty
, " This interface is UNNUMBERED,");
3440 /* Show OSPF interface information. */
3442 json_object_string_add(
3443 json_interface_sub
, "ipAddress",
3444 inet_ntoa(oi
->address
->u
.prefix4
));
3445 json_object_int_add(json_interface_sub
,
3446 "ipAddressPrefixlen",
3447 oi
->address
->prefixlen
);
3449 vty_out(vty
, " Internet Address %s/%d,",
3450 inet_ntoa(oi
->address
->u
.prefix4
),
3451 oi
->address
->prefixlen
);
3453 if (oi
->connected
->destination
3454 || oi
->type
== OSPF_IFTYPE_VIRTUALLINK
) {
3455 struct in_addr
*dest
;
3458 if (CONNECTED_PEER(oi
->connected
)
3459 || oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3464 /* For Vlinks, showing the peer address is
3466 * * * * * informative than the local
3467 * interface that is being used
3469 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3470 dest
= &oi
->vl_data
->peer_addr
;
3472 dest
= &oi
->connected
->destination
->u
3476 json_object_string_add(
3478 "ospfIfType", dstr
);
3479 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3480 json_object_string_add(
3485 json_object_string_add(
3490 vty_out(vty
, " %s %s,", dstr
,
3495 json_object_string_add(json_interface_sub
, "area",
3496 ospf_area_desc_string(oi
->area
));
3497 if (OSPF_IF_PARAM(oi
, mtu_ignore
))
3498 json_object_boolean_true_add(
3500 "mtuMismatchDetect");
3501 json_object_string_add(json_interface_sub
, "routerId",
3502 inet_ntoa(ospf
->router_id
));
3503 json_object_string_add(json_interface_sub
,
3505 ospf_network_type_str
[oi
->type
]);
3506 json_object_int_add(json_interface_sub
, "cost",
3508 json_object_int_add(
3509 json_interface_sub
, "transmitDelayMsecs",
3510 1000 / OSPF_IF_PARAM(oi
, transmit_delay
));
3511 json_object_string_add(json_interface_sub
, "state",
3512 lookup_msg(ospf_ism_state_msg
,
3514 json_object_int_add(json_interface_sub
, "priority",
3517 vty_out(vty
, " Area %s\n",
3518 ospf_area_desc_string(oi
->area
));
3520 vty_out(vty
, " MTU mismatch detection: %s\n",
3521 OSPF_IF_PARAM(oi
, mtu_ignore
) ? "disabled"
3525 " Router ID %s, Network Type %s, Cost: %d\n",
3526 inet_ntoa(ospf
->router_id
),
3527 ospf_network_type_str
[oi
->type
],
3531 " Transmit Delay is %d sec, State %s, Priority %d\n",
3532 OSPF_IF_PARAM(oi
, transmit_delay
),
3533 lookup_msg(ospf_ism_state_msg
, oi
->state
, NULL
),
3537 /* Show DR information. */
3538 if (DR(oi
).s_addr
== 0) {
3541 " No backup designated router on this network\n");
3543 nbr
= ospf_nbr_lookup_by_addr(oi
->nbrs
, &BDR(oi
));
3547 " No backup designated router on this network\n");
3550 json_object_string_add(
3551 json_interface_sub
, "bdrId",
3552 inet_ntoa(nbr
->router_id
));
3553 json_object_string_add(
3556 inet_ntoa(nbr
->address
.u
3560 " Backup Designated Router (ID) %s,",
3561 inet_ntoa(nbr
->router_id
));
3562 vty_out(vty
, " Interface Address %s\n",
3563 inet_ntoa(nbr
->address
.u
3569 /* Next network-LSA sequence number we'll use, if we're elected
3572 && ntohl(oi
->params
->network_lsa_seqnum
)
3573 != OSPF_INITIAL_SEQUENCE_NUMBER
) {
3575 json_object_int_add(
3577 "networkLsaSequence",
3578 ntohl(oi
->params
->network_lsa_seqnum
));
3581 " Saved Network-LSA sequence number 0x%x\n",
3582 ntohl(oi
->params
->network_lsa_seqnum
));
3586 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3587 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
)) {
3588 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3589 json_object_boolean_true_add(
3591 "mcastMemberOspfAllRouters");
3592 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3593 json_object_boolean_true_add(
3595 "mcastMemberOspfDesignatedRouters");
3598 vty_out(vty
, " Multicast group memberships:");
3599 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3600 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
)) {
3601 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3602 vty_out(vty
, " OSPFAllRouters");
3603 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3604 vty_out(vty
, " OSPFDesignatedRouters");
3606 vty_out(vty
, " <None>");
3611 if (OSPF_IF_PARAM(oi
, fast_hello
) == 0)
3612 json_object_int_add(
3613 json_interface_sub
, "timerMsecs",
3614 1000 / OSPF_IF_PARAM(oi
, v_hello
));
3616 json_object_int_add(
3617 json_interface_sub
, "timerMsecs",
3618 1000 / OSPF_IF_PARAM(oi
, fast_hello
));
3619 json_object_int_add(json_interface_sub
,
3621 1000 / OSPF_IF_PARAM(oi
, v_wait
));
3622 json_object_int_add(json_interface_sub
,
3624 1000 / OSPF_IF_PARAM(oi
, v_wait
));
3625 json_object_int_add(
3626 json_interface_sub
, "timerRetransmit",
3627 1000 / OSPF_IF_PARAM(oi
, retransmit_interval
));
3629 vty_out(vty
, " Timer intervals configured,");
3630 vty_out(vty
, " Hello ");
3631 if (OSPF_IF_PARAM(oi
, fast_hello
) == 0)
3632 vty_out(vty
, "%ds,",
3633 OSPF_IF_PARAM(oi
, v_hello
));
3635 vty_out(vty
, "%dms,",
3636 1000 / OSPF_IF_PARAM(oi
, fast_hello
));
3637 vty_out(vty
, " Dead %ds, Wait %ds, Retransmit %d\n",
3638 OSPF_IF_PARAM(oi
, v_wait
),
3639 OSPF_IF_PARAM(oi
, v_wait
),
3640 OSPF_IF_PARAM(oi
, retransmit_interval
));
3643 if (OSPF_IF_PASSIVE_STATUS(oi
) == OSPF_IF_ACTIVE
) {
3644 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3646 long time_store
= 0;
3650 &oi
->t_hello
->u
.sands
,
3653 json_object_int_add(json_interface_sub
,
3654 "timerHelloInMsecs",
3657 vty_out(vty
, " Hello due in %s\n",
3658 ospf_timer_dump(oi
->t_hello
, timebuf
,
3660 } else /* passive-interface is set */
3663 json_object_boolean_true_add(
3665 "timerPassiveIface");
3668 " No Hellos (Passive interface)\n");
3672 json_object_int_add(json_interface_sub
, "nbrCount",
3673 ospf_nbr_count(oi
, 0));
3674 json_object_int_add(json_interface_sub
,
3676 ospf_nbr_count(oi
, NSM_Full
));
3679 " Neighbor Count is %d, Adjacent neighbor count is %d\n",
3680 ospf_nbr_count(oi
, 0),
3681 ospf_nbr_count(oi
, NSM_Full
));
3682 ospf_bfd_interface_show(vty
, ifp
, json_interface_sub
, use_json
);
3686 static int show_ip_ospf_interface_common(struct vty
*vty
, struct ospf
*ospf
,
3687 char *intf_name
, u_char use_vrf
,
3688 json_object
*json
, u_char use_json
)
3690 struct interface
*ifp
;
3691 struct vrf
*vrf
= vrf_lookup_by_id(ospf
->vrf_id
);
3692 json_object
*json_vrf
= NULL
;
3693 json_object
*json_interface_sub
= NULL
;
3697 json_vrf
= json_object_new_object();
3702 if (ospf
->instance
) {
3704 json_object_int_add(json
, "ospfInstance",
3707 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
3710 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
3712 if (intf_name
== NULL
) {
3713 /* Show All Interfaces.*/
3714 FOR_ALL_INTERFACES (vrf
, ifp
) {
3715 if (ospf_oi_count(ifp
)) {
3717 json_interface_sub
=
3718 json_object_new_object();
3720 show_ip_ospf_interface_sub(vty
, ospf
, ifp
,
3725 json_object_object_add(
3726 json_vrf
, ifp
->name
,
3727 json_interface_sub
);
3731 /* Interface name is specified. */
3732 ifp
= if_lookup_by_name(intf_name
, ospf
->vrf_id
);
3735 json_object_boolean_true_add(json_vrf
,
3738 vty_out(vty
, "No such interface name\n");
3741 json_interface_sub
= json_object_new_object();
3743 show_ip_ospf_interface_sub(
3744 vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3747 json_object_object_add(json_vrf
, ifp
->name
,
3748 json_interface_sub
);
3754 if (ospf
->vrf_id
== VRF_DEFAULT
)
3755 json_object_object_add(json
, "default",
3758 json_object_object_add(json
, ospf
->name
,
3767 static void show_ip_ospf_interface_traffic_sub(struct vty
*vty
,
3768 struct ospf_interface
*oi
,
3769 json_object
*json_interface_sub
,
3773 json_object_int_add(json_interface_sub
,
3776 json_object_int_add(json_interface_sub
,
3779 json_object_int_add(json_interface_sub
,
3782 json_object_int_add(json_interface_sub
,
3785 json_object_int_add(json_interface_sub
,
3788 json_object_int_add(json_interface_sub
,
3791 json_object_int_add(json_interface_sub
,
3794 json_object_int_add(json_interface_sub
,
3797 json_object_int_add(json_interface_sub
,
3800 json_object_int_add(json_interface_sub
,
3803 json_object_int_add(json_interface_sub
,
3808 "%-10s %8u/%-8u %7u/%-7u %7u/%-7u %7u/%-7u %7u/%-7u\n",
3809 oi
->ifp
->name
, oi
->hello_in
,
3811 oi
->db_desc_in
, oi
->db_desc_out
,
3812 oi
->ls_req_in
, oi
->ls_req_out
,
3813 oi
->ls_upd_in
, oi
->ls_upd_out
,
3814 oi
->ls_ack_in
, oi
->ls_ack_out
);
3818 /* OSPFv2 Packet Counters */
3819 static int show_ip_ospf_interface_traffic_common(struct vty
*vty
,
3827 struct vrf
*vrf
= NULL
;
3828 struct interface
*ifp
= NULL
;
3829 json_object
*json_vrf
= NULL
;
3830 json_object
*json_interface_sub
= NULL
;
3832 if (!use_json
&& !display_once
) {
3834 vty_out(vty
, "%-12s%-17s%-17s%-17s%-17s%-17s\n",
3835 "Interface", " HELLO", " DB-Desc", " LS-Req",
3836 " LS-Update", " LS-Ack");
3837 vty_out(vty
, "%-10s%-18s%-18s%-17s%-17s%-17s\n", "",
3838 " Rx/Tx", " Rx/Tx", " Rx/Tx", " Rx/Tx", " Rx/Tx");
3840 "--------------------------------------------------------------------------------------------\n");
3841 } else if (use_json
) {
3843 json_vrf
= json_object_new_object();
3848 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
3850 if (intf_name
== NULL
) {
3851 vrf
= vrf_lookup_by_id(ospf
->vrf_id
);
3852 FOR_ALL_INTERFACES (vrf
, ifp
) {
3853 struct route_node
*rn
;
3854 struct ospf_interface
*oi
;
3856 if (ospf_oi_count(ifp
) == 0)
3859 for (rn
= route_top(IF_OIFS(ifp
)); rn
;
3860 rn
= route_next(rn
)) {
3867 json_interface_sub
=
3868 json_object_new_object();
3871 show_ip_ospf_interface_traffic_sub(vty
, oi
,
3875 json_object_object_add(json_vrf
,
3877 json_interface_sub
);
3882 /* Interface name is specified. */
3883 ifp
= if_lookup_by_name(intf_name
, ospf
->vrf_id
);
3885 struct route_node
*rn
;
3886 struct ospf_interface
*oi
;
3888 if (ospf_oi_count(ifp
) == 0) {
3889 vty_out(vty
, " OSPF not enabled on this interface %s\n",
3894 for (rn
= route_top(IF_OIFS(ifp
)); rn
;
3895 rn
= route_next(rn
)) {
3899 json_interface_sub
=
3900 json_object_new_object();
3903 show_ip_ospf_interface_traffic_sub(vty
, oi
,
3907 json_object_object_add(json_vrf
,
3909 json_interface_sub
);
3917 if (ospf
->vrf_id
== VRF_DEFAULT
)
3918 json_object_object_add(json
, "default",
3921 json_object_object_add(json
, ospf
->name
,
3930 DEFUN (show_ip_ospf_interface
,
3931 show_ip_ospf_interface_cmd
,
3932 "show ip ospf [vrf <NAME|all>] interface [INTERFACE] [json]",
3935 "OSPF information\n"
3938 "Interface information\n"
3943 u_char uj
= use_json(argc
, argv
);
3944 struct listnode
*node
= NULL
;
3945 char *vrf_name
= NULL
, *intf_name
= NULL
;
3946 bool all_vrf
= FALSE
;
3947 int ret
= CMD_SUCCESS
;
3949 int idx_vrf
= 0, idx_intf
= 0;
3951 json_object
*json
= NULL
;
3953 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
3955 if (argv_find(argv
, argc
, "INTERFACE", &idx_intf
))
3956 intf_name
= argv
[idx_intf
]->arg
;
3959 json
= json_object_new_object();
3961 /* vrf input is provided could be all or specific vrf*/
3965 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
3966 if (!ospf
->oi_running
)
3968 ret
= show_ip_ospf_interface_common(vty
,
3977 vty_out(vty
, "%s\n",
3978 json_object_to_json_string_ext(json
,
3979 JSON_C_TO_STRING_PRETTY
));
3980 json_object_free(json
);
3985 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
3986 if (ospf
== NULL
|| !ospf
->oi_running
) {
3988 json_object_free(json
);
3991 ret
= show_ip_ospf_interface_common(vty
, ospf
, intf_name
,
3995 /* Display default ospf (instance 0) info */
3996 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
3997 if (ospf
== NULL
|| !ospf
->oi_running
) {
3999 json_object_free(json
);
4002 ret
= show_ip_ospf_interface_common(vty
, ospf
, intf_name
,
4007 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
4008 JSON_C_TO_STRING_PRETTY
));
4009 json_object_free(json
);
4015 DEFUN (show_ip_ospf_instance_interface
,
4016 show_ip_ospf_instance_interface_cmd
,
4017 "show ip ospf (1-65535) interface [INTERFACE] [json]",
4020 "OSPF information\n"
4022 "Interface information\n"
4029 u_short instance
= 0;
4030 u_char uj
= use_json(argc
, argv
);
4031 char *intf_name
= NULL
;
4032 int ret
= CMD_SUCCESS
;
4033 json_object
*json
= NULL
;
4035 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4036 ospf
= ospf_lookup_instance(instance
);
4038 return CMD_NOT_MY_INSTANCE
;
4040 if (!ospf
->oi_running
)
4044 json
= json_object_new_object();
4046 if (argv_find(argv
, argc
, "INTERFACE", &idx_intf
))
4047 intf_name
= argv
[idx_intf
]->arg
;
4049 ret
= show_ip_ospf_interface_common(vty
, ospf
, intf_name
, 0, json
, uj
);
4052 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
4053 JSON_C_TO_STRING_PRETTY
));
4054 json_object_free(json
);
4060 DEFUN (show_ip_ospf_interface_traffic
,
4061 show_ip_ospf_interface_traffic_cmd
,
4062 "show ip ospf [vrf <NAME|all>] interface traffic [INTERFACE] [json]",
4065 "OSPF information\n"
4068 "Interface information\n"
4069 "Protocol Packet counters\n"
4073 struct ospf
*ospf
= NULL
;
4074 struct listnode
*node
= NULL
;
4075 char *vrf_name
= NULL
, *intf_name
= NULL
;
4076 bool all_vrf
= FALSE
;
4078 int idx_vrf
= 0, idx_intf
= 0;
4079 u_char uj
= use_json(argc
, argv
);
4080 json_object
*json
= NULL
;
4081 int ret
= CMD_SUCCESS
;
4082 int display_once
= 0;
4085 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
4087 if (argv_find(argv
, argc
, "INTERFACE", &idx_intf
))
4088 intf_name
= argv
[idx_intf
]->arg
;
4091 json
= json_object_new_object();
4096 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
4097 if (!ospf
->oi_running
)
4100 ret
= show_ip_ospf_interface_traffic_common(vty
,
4110 vty_out(vty
, "%s\n",
4111 json_object_to_json_string_ext(json
,
4112 JSON_C_TO_STRING_PRETTY
));
4113 json_object_free(json
);
4118 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
4119 if (ospf
== NULL
|| !ospf
->oi_running
) {
4121 json_object_free(json
);
4125 ret
= show_ip_ospf_interface_traffic_common(vty
, ospf
,
4130 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
4131 if (ospf
== NULL
|| !ospf
->oi_running
) {
4133 json_object_free(json
);
4137 ret
= show_ip_ospf_interface_traffic_common(vty
, ospf
,
4144 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
4145 JSON_C_TO_STRING_PRETTY
));
4146 json_object_free(json
);
4153 static void show_ip_ospf_neighbour_header(struct vty
*vty
)
4155 vty_out(vty
, "\n%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s\n",
4156 "Neighbor ID", "Pri", "State", "Dead Time", "Address",
4157 "Interface", "RXmtL", "RqstL", "DBsmL");
4160 static void show_ip_ospf_neighbor_sub(struct vty
*vty
,
4161 struct ospf_interface
*oi
,
4162 json_object
*json
, u_char use_json
)
4164 struct route_node
*rn
;
4165 struct ospf_neighbor
*nbr
, *prev_nbr
= NULL
;
4167 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4168 json_object
*json_neighbor
= NULL
, *json_neigh_array
= NULL
;
4170 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
)) {
4171 if ((nbr
= rn
->info
)) {
4172 /* Do not show myself. */
4173 if (nbr
== oi
->nbr_self
)
4175 /* Down state is not shown. */
4176 if (nbr
->state
== NSM_Down
)
4179 char neigh_str
[INET_ADDRSTRLEN
];
4182 !IPV4_ADDR_SAME(&prev_nbr
->src
, &nbr
->src
)) {
4183 /* Start new neigh list */
4184 json_neigh_array
= NULL
;
4187 if (nbr
->state
== NSM_Attempt
&&
4188 nbr
->router_id
.s_addr
== 0)
4189 strlcpy(neigh_str
, "neighbor",
4193 inet_ntoa(nbr
->router_id
),
4196 json_object_object_get_ex(json
, neigh_str
,
4199 if (!json_neigh_array
) {
4200 json_neigh_array
= json_object_new_array();
4201 json_object_object_add(json
, neigh_str
,
4206 json_object_new_object();
4208 ospf_nbr_state_message(nbr
, msgbuf
, 16);
4212 time_store
= monotime_until(
4213 &nbr
->t_inactivity
->u
.sands
,
4216 json_object_int_add(json_neighbor
,
4219 json_object_string_add(json_neighbor
, "state",
4221 json_object_int_add(json_neighbor
,
4224 json_object_string_add(json_neighbor
,
4226 inet_ntoa(nbr
->src
));
4227 json_object_string_add(json_neighbor
,
4230 json_object_int_add(json_neighbor
,
4231 "retransmitCounter",
4232 ospf_ls_retransmit_count(nbr
));
4233 json_object_int_add(json_neighbor
,
4235 ospf_ls_request_count(nbr
));
4236 json_object_int_add(json_neighbor
,
4238 ospf_db_summary_count(nbr
));
4240 json_object_array_add(json_neigh_array
,
4243 ospf_nbr_state_message(nbr
, msgbuf
, 16);
4245 if (nbr
->state
== NSM_Attempt
&&
4246 nbr
->router_id
.s_addr
== 0)
4255 inet_ntoa(nbr
->router_id
),
4259 vty_out(vty
, "%9s ",
4260 ospf_timer_dump(nbr
->t_inactivity
,
4263 vty_out(vty
, "%-15s ", inet_ntoa(nbr
->src
));
4265 "%-20s %5ld %5ld %5d\n",
4267 ospf_ls_retransmit_count(nbr
),
4268 ospf_ls_request_count(nbr
),
4269 ospf_db_summary_count(nbr
));
4276 static int show_ip_ospf_neighbor_common(struct vty
*vty
, struct ospf
*ospf
,
4277 json_object
*json
, u_char use_json
,
4280 struct ospf_interface
*oi
;
4281 struct listnode
*node
;
4282 json_object
*json_vrf
= NULL
;
4286 json_vrf
= json_object_new_object();
4291 if (ospf
->instance
) {
4293 json_object_int_add(json
, "ospfInstance",
4296 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
4299 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
4301 show_ip_ospf_neighbour_header(vty
);
4303 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
))
4304 show_ip_ospf_neighbor_sub(vty
, oi
, json_vrf
, use_json
);
4308 if (ospf
->vrf_id
== VRF_DEFAULT
)
4309 json_object_object_add(json
, "default",
4312 json_object_object_add(json
, ospf
->name
,
4321 DEFUN (show_ip_ospf_neighbor
,
4322 show_ip_ospf_neighbor_cmd
,
4323 "show ip ospf [vrf <NAME|all>] neighbor [json]",
4326 "OSPF information\n"
4333 u_char uj
= use_json(argc
, argv
);
4334 struct listnode
*node
= NULL
;
4335 char *vrf_name
= NULL
;
4336 bool all_vrf
= FALSE
;
4337 int ret
= CMD_SUCCESS
;
4341 json_object
*json
= NULL
;
4343 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
4346 json
= json_object_new_object();
4348 /* vrf input is provided could be all or specific vrf*/
4352 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
4353 if (!ospf
->oi_running
)
4355 ret
= show_ip_ospf_neighbor_common(vty
, ospf
,
4361 vty_out(vty
, "%s\n",
4362 json_object_to_json_string_ext(json
,
4363 JSON_C_TO_STRING_PRETTY
));
4364 json_object_free(json
);
4370 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
4371 if (ospf
== NULL
|| !ospf
->oi_running
) {
4373 json_object_free(json
);
4377 /* Display default ospf (instance 0) info */
4378 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
4379 if (ospf
== NULL
|| !ospf
->oi_running
) {
4381 json_object_free(json
);
4387 ret
= show_ip_ospf_neighbor_common(vty
, ospf
, json
, uj
,
4391 vty_out(vty
, "%s\n",
4392 json_object_to_json_string_ext(json
,
4393 JSON_C_TO_STRING_PRETTY
));
4398 json_object_free(json
);
4404 DEFUN (show_ip_ospf_instance_neighbor
,
4405 show_ip_ospf_instance_neighbor_cmd
,
4406 "show ip ospf (1-65535) neighbor [json]",
4409 "OSPF information\n"
4416 u_short instance
= 0;
4417 u_char uj
= use_json(argc
, argv
);
4418 json_object
*json
= NULL
;
4419 int ret
= CMD_SUCCESS
;
4421 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4422 ospf
= ospf_lookup_instance(instance
);
4424 return CMD_NOT_MY_INSTANCE
;
4426 if (!ospf
->oi_running
)
4430 json
= json_object_new_object();
4432 ret
= show_ip_ospf_neighbor_common(vty
, ospf
, json
, uj
, 0);
4435 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
4436 JSON_C_TO_STRING_PRETTY
));
4437 json_object_free(json
);
4443 static int show_ip_ospf_neighbor_all_common(struct vty
*vty
, struct ospf
*ospf
,
4448 struct listnode
*node
;
4449 struct ospf_interface
*oi
;
4450 json_object
*json_vrf
= NULL
;
4451 json_object
*json_neighbor_sub
= NULL
;
4455 json_vrf
= json_object_new_object();
4458 json_neighbor_sub
= json_object_new_object();
4461 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
4463 show_ip_ospf_neighbour_header(vty
);
4465 if (ospf
->instance
) {
4467 json_object_int_add(json_vrf
, "ospfInstance",
4470 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
4473 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
4474 struct listnode
*nbr_node
;
4475 struct ospf_nbr_nbma
*nbr_nbma
;
4477 show_ip_ospf_neighbor_sub(vty
, oi
, json_vrf
, use_json
);
4479 /* print Down neighbor status */
4480 for (ALL_LIST_ELEMENTS_RO(oi
->nbr_nbma
, nbr_node
, nbr_nbma
)) {
4481 if (nbr_nbma
->nbr
== NULL
4482 || nbr_nbma
->nbr
->state
== NSM_Down
) {
4484 json_object_int_add(json_neighbor_sub
,
4486 nbr_nbma
->priority
);
4487 json_object_boolean_true_add(
4490 json_object_string_add(
4494 json_object_int_add(
4496 "nbrNbmaRetransmitCounter", 0);
4497 json_object_int_add(
4499 "nbrNbmaRequestCounter", 0);
4500 json_object_int_add(
4502 "nbrNbmaDbSummaryCounter", 0);
4503 json_object_object_add(
4505 inet_ntoa(nbr_nbma
->addr
),
4508 vty_out(vty
, "%-15s %3d %-15s %9s ",
4509 "-", nbr_nbma
->priority
, "Down",
4512 "%-15s %-20s %5d %5d %5d\n",
4513 inet_ntoa(nbr_nbma
->addr
),
4514 IF_NAME(oi
), 0, 0, 0);
4522 if (ospf
->vrf_id
== VRF_DEFAULT
)
4523 json_object_object_add(json
, "default",
4526 json_object_object_add(json
, ospf
->name
,
4535 DEFUN (show_ip_ospf_neighbor_all
,
4536 show_ip_ospf_neighbor_all_cmd
,
4537 "show ip ospf [vrf <NAME|all>] neighbor all [json]",
4540 "OSPF information\n"
4544 "include down status neighbor\n"
4548 u_char uj
= use_json(argc
, argv
);
4549 struct listnode
*node
= NULL
;
4550 char *vrf_name
= NULL
;
4551 bool all_vrf
= FALSE
;
4552 int ret
= CMD_SUCCESS
;
4556 json_object
*json
= NULL
;
4558 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
4561 json
= json_object_new_object();
4563 /* vrf input is provided could be all or specific vrf*/
4567 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
4568 if (!ospf
->oi_running
)
4570 ret
= show_ip_ospf_neighbor_all_common(vty
,
4578 vty_out(vty
, "%s\n",
4579 json_object_to_json_string_ext(json
,
4580 JSON_C_TO_STRING_PRETTY
));
4581 json_object_free(json
);
4587 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
4588 if (ospf
== NULL
|| !ospf
->oi_running
) {
4590 json_object_free(json
);
4594 /* Display default ospf (instance 0) info */
4595 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
4596 if (ospf
== NULL
|| !ospf
->oi_running
) {
4598 json_object_free(json
);
4604 ret
= show_ip_ospf_neighbor_all_common(vty
, ospf
, json
, uj
,
4607 vty_out(vty
, "%s\n",
4608 json_object_to_json_string_ext(json
,
4609 JSON_C_TO_STRING_PRETTY
));
4614 json_object_free(json
);
4619 DEFUN (show_ip_ospf_instance_neighbor_all
,
4620 show_ip_ospf_instance_neighbor_all_cmd
,
4621 "show ip ospf (1-65535) neighbor all [json]",
4624 "OSPF information\n"
4627 "include down status neighbor\n"
4632 u_short instance
= 0;
4633 u_char 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 ospf
= ospf_lookup_instance(instance
);
4640 return CMD_NOT_MY_INSTANCE
;
4642 if (!ospf
->oi_running
)
4645 json
= json_object_new_object();
4647 ret
= show_ip_ospf_neighbor_all_common(vty
, ospf
, json
, uj
, 0);
4650 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
4651 json
, JSON_C_TO_STRING_PRETTY
));
4652 json_object_free(json
);
4658 static int show_ip_ospf_neighbor_int_common(struct vty
*vty
, struct ospf
*ospf
,
4660 struct cmd_token
**argv
,
4661 u_char use_json
, u_char use_vrf
)
4663 struct interface
*ifp
;
4664 struct route_node
*rn
;
4665 json_object
*json
= NULL
;
4668 json
= json_object_new_object();
4670 if (ospf
->instance
) {
4672 json_object_int_add(json
, "ospfInstance",
4675 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
4678 ospf_show_vrf_name(ospf
, vty
, json
, use_vrf
);
4680 /*ifp = if_lookup_by_name(argv[arg_base]->arg, ospf->vrf_id);*/
4681 ifp
= if_lookup_by_name_all_vrf(argv
[arg_base
]->arg
);
4684 json_object_boolean_true_add(json
, "noSuchIface");
4686 vty_out(vty
, "No such interface.\n");
4690 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
4691 struct ospf_interface
*oi
= rn
->info
;
4696 show_ip_ospf_neighbor_sub(vty
, oi
, json
, use_json
);
4700 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
4701 json
, JSON_C_TO_STRING_PRETTY
));
4702 json_object_free(json
);
4709 DEFUN (show_ip_ospf_neighbor_int
,
4710 show_ip_ospf_neighbor_int_cmd
,
4711 "show ip ospf neighbor IFNAME [json]",
4714 "OSPF information\n"
4721 u_char uj
= use_json(argc
, argv
);
4722 struct listnode
*node
= NULL
;
4723 int ret
= CMD_SUCCESS
;
4724 struct interface
*ifp
= NULL
;
4727 show_ip_ospf_neighbour_header(vty
);
4729 ifp
= if_lookup_by_name_all_vrf(argv
[idx_ifname
]->arg
);
4730 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
4731 if (!ospf
->oi_running
)
4733 if (!ifp
|| ifp
->vrf_id
!= ospf
->vrf_id
)
4735 ret
= show_ip_ospf_neighbor_int_common(vty
, ospf
,
4736 idx_ifname
, argv
, uj
, 0);
4742 DEFUN (show_ip_ospf_instance_neighbor_int
,
4743 show_ip_ospf_instance_neighbor_int_cmd
,
4744 "show ip ospf (1-65535) neighbor IFNAME [json]",
4747 "OSPF information\n"
4756 u_short instance
= 0;
4757 u_char uj
= use_json(argc
, argv
);
4760 show_ip_ospf_neighbour_header(vty
);
4762 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4763 ospf
= ospf_lookup_instance(instance
);
4765 return CMD_NOT_MY_INSTANCE
;
4767 if (!ospf
->oi_running
)
4771 show_ip_ospf_neighbour_header(vty
);
4773 return show_ip_ospf_neighbor_int_common(vty
, ospf
, idx_ifname
,
4777 static void show_ip_ospf_nbr_nbma_detail_sub(struct vty
*vty
,
4778 struct ospf_interface
*oi
,
4779 struct ospf_nbr_nbma
*nbr_nbma
,
4780 u_char use_json
, json_object
*json
)
4782 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4783 json_object
*json_sub
= NULL
;
4786 json_sub
= json_object_new_object();
4787 else /* Show neighbor ID. */
4788 vty_out(vty
, " Neighbor %s,", "-");
4790 /* Show interface address. */
4792 json_object_string_add(json_sub
, "ifaceAddress",
4793 inet_ntoa(nbr_nbma
->addr
));
4795 vty_out(vty
, " interface address %s\n",
4796 inet_ntoa(nbr_nbma
->addr
));
4800 json_object_string_add(json_sub
, "areaId",
4801 ospf_area_desc_string(oi
->area
));
4802 json_object_string_add(json_sub
, "iface", IF_NAME(oi
));
4804 vty_out(vty
, " In the area %s via interface %s\n",
4805 ospf_area_desc_string(oi
->area
), IF_NAME(oi
));
4807 /* Show neighbor priority and state. */
4809 json_object_int_add(json_sub
, "nbrPriority",
4810 nbr_nbma
->priority
);
4811 json_object_string_add(json_sub
, "nbrState", "down");
4813 vty_out(vty
, " Neighbor priority is %d, State is %s,",
4814 nbr_nbma
->priority
, "Down");
4816 /* Show state changes. */
4818 json_object_int_add(json_sub
, "stateChangeCounter",
4819 nbr_nbma
->state_change
);
4821 vty_out(vty
, " %d state changes\n", nbr_nbma
->state_change
);
4823 /* Show PollInterval */
4825 json_object_int_add(json_sub
, "pollInterval", nbr_nbma
->v_poll
);
4827 vty_out(vty
, " Poll interval %d\n", nbr_nbma
->v_poll
);
4829 /* Show poll-interval timer. */
4832 time_store
= monotime_until(&nbr_nbma
->t_poll
->u
.sands
, NULL
)
4834 json_object_int_add(json_sub
, "pollIntervalTimerDueMsec",
4837 vty_out(vty
, " Poll timer due in %s\n",
4838 ospf_timer_dump(nbr_nbma
->t_poll
, timebuf
,
4841 /* Show poll-interval timer thread. */
4843 if (nbr_nbma
->t_poll
!= NULL
)
4844 json_object_string_add(json_sub
,
4845 "pollIntervalTimerThread", "on");
4847 vty_out(vty
, " Thread Poll Timer %s\n",
4848 nbr_nbma
->t_poll
!= NULL
? "on" : "off");
4851 json_object_object_add(json
, "noNbrId", json_sub
);
4854 static void show_ip_ospf_neighbor_detail_sub(struct vty
*vty
,
4855 struct ospf_interface
*oi
,
4856 struct ospf_neighbor
*nbr
,
4860 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4861 json_object
*json_sub
= NULL
;
4864 json_sub
= json_object_new_object();
4866 /* Show neighbor ID. */
4867 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4868 vty_out(vty
, " Neighbor %s,", "-");
4870 vty_out(vty
, " Neighbor %s,",
4871 inet_ntoa(nbr
->router_id
));
4874 /* Show interface address. */
4876 json_object_string_add(json_sub
, "ifaceAddress",
4877 inet_ntoa(nbr
->address
.u
.prefix4
));
4879 vty_out(vty
, " interface address %s\n",
4880 inet_ntoa(nbr
->address
.u
.prefix4
));
4884 json_object_string_add(json_sub
, "areaId",
4885 ospf_area_desc_string(oi
->area
));
4886 json_object_string_add(json_sub
, "ifaceName", oi
->ifp
->name
);
4888 vty_out(vty
, " In the area %s via interface %s\n",
4889 ospf_area_desc_string(oi
->area
), oi
->ifp
->name
);
4891 /* Show neighbor priority and state. */
4893 json_object_int_add(json_sub
, "nbrPriority", nbr
->priority
);
4894 json_object_string_add(
4895 json_sub
, "nbrState",
4896 lookup_msg(ospf_nsm_state_msg
, nbr
->state
, NULL
));
4898 vty_out(vty
, " Neighbor priority is %d, State is %s,",
4900 lookup_msg(ospf_nsm_state_msg
, nbr
->state
, NULL
));
4902 /* Show state changes. */
4904 json_object_int_add(json_sub
, "stateChangeCounter",
4907 vty_out(vty
, " %d state changes\n", nbr
->state_change
);
4909 if (nbr
->ts_last_progress
.tv_sec
|| nbr
->ts_last_progress
.tv_usec
) {
4914 monotime_since(&nbr
->ts_last_progress
, &res
) / 1000LL;
4916 json_object_int_add(json_sub
, "lastPrgrsvChangeMsec",
4920 " Most recent state change statistics:\n");
4921 vty_out(vty
, " Progressive change %s ago\n",
4922 ospf_timeval_dump(&res
, timebuf
,
4927 if (nbr
->ts_last_regress
.tv_sec
|| nbr
->ts_last_regress
.tv_usec
) {
4932 monotime_since(&nbr
->ts_last_regress
, &res
) / 1000LL;
4934 json_object_int_add(json_sub
,
4935 "lastRegressiveChangeMsec",
4937 if (nbr
->last_regress_str
)
4938 json_object_string_add(
4939 json_sub
, "lastRegressiveChangeReason",
4940 nbr
->last_regress_str
);
4943 " Regressive change %s ago, due to %s\n",
4944 ospf_timeval_dump(&res
, timebuf
,
4946 (nbr
->last_regress_str
? nbr
->last_regress_str
4951 /* Show Designated Rotuer ID. */
4953 json_object_string_add(json_sub
, "routerDesignatedId",
4954 inet_ntoa(nbr
->d_router
));
4956 vty_out(vty
, " DR is %s,", inet_ntoa(nbr
->d_router
));
4958 /* Show Backup Designated Rotuer ID. */
4960 json_object_string_add(json_sub
, "routerDesignatedBackupId",
4961 inet_ntoa(nbr
->bd_router
));
4963 vty_out(vty
, " BDR is %s\n", inet_ntoa(nbr
->bd_router
));
4967 json_object_int_add(json_sub
, "optionsCounter", nbr
->options
);
4968 json_object_string_add(json_sub
, "optionsList",
4969 ospf_options_dump(nbr
->options
));
4971 vty_out(vty
, " Options %d %s\n", nbr
->options
,
4972 ospf_options_dump(nbr
->options
));
4974 /* Show Router Dead interval timer. */
4976 if (nbr
->t_inactivity
) {
4978 time_store
= monotime_until(&nbr
->t_inactivity
->u
.sands
,
4981 json_object_int_add(json_sub
,
4982 "routerDeadIntervalTimerDueMsec",
4985 json_object_int_add(
4986 json_sub
, "routerDeadIntervalTimerDueMsec", -1);
4988 vty_out(vty
, " Dead timer due in %s\n",
4989 ospf_timer_dump(nbr
->t_inactivity
, timebuf
,
4992 /* Show Database Summary list. */
4994 json_object_int_add(json_sub
, "databaseSummaryListCounter",
4995 ospf_db_summary_count(nbr
));
4997 vty_out(vty
, " Database Summary List %d\n",
4998 ospf_db_summary_count(nbr
));
5000 /* Show Link State Request list. */
5002 json_object_int_add(json_sub
, "linkStateRequestListCounter",
5003 ospf_ls_request_count(nbr
));
5005 vty_out(vty
, " Link State Request List %ld\n",
5006 ospf_ls_request_count(nbr
));
5008 /* Show Link State Retransmission list. */
5010 json_object_int_add(json_sub
,
5011 "linkStateRetransmissionListCounter",
5012 ospf_ls_retransmit_count(nbr
));
5014 vty_out(vty
, " Link State Retransmission List %ld\n",
5015 ospf_ls_retransmit_count(nbr
));
5017 /* Show inactivity timer thread. */
5019 if (nbr
->t_inactivity
!= NULL
)
5020 json_object_string_add(json_sub
,
5021 "threadInactivityTimer", "on");
5023 vty_out(vty
, " Thread Inactivity Timer %s\n",
5024 nbr
->t_inactivity
!= NULL
? "on" : "off");
5026 /* Show Database Description retransmission thread. */
5028 if (nbr
->t_db_desc
!= NULL
)
5029 json_object_string_add(
5031 "threadDatabaseDescriptionRetransmission",
5035 " Thread Database Description Retransmision %s\n",
5036 nbr
->t_db_desc
!= NULL
? "on" : "off");
5038 /* Show Link State Request Retransmission thread. */
5040 if (nbr
->t_ls_req
!= NULL
)
5041 json_object_string_add(
5043 "threadLinkStateRequestRetransmission", "on");
5046 " Thread Link State Request Retransmission %s\n",
5047 nbr
->t_ls_req
!= NULL
? "on" : "off");
5049 /* Show Link State Update Retransmission thread. */
5051 if (nbr
->t_ls_upd
!= NULL
)
5052 json_object_string_add(
5053 json_sub
, "threadLinkStateUpdateRetransmission",
5057 " Thread Link State Update Retransmission %s\n\n",
5058 nbr
->t_ls_upd
!= NULL
? "on" : "off");
5061 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
5062 json_object_object_add(json
, "noNbrId", json_sub
);
5064 json_object_object_add(json
, inet_ntoa(nbr
->router_id
),
5068 ospf_bfd_show_info(vty
, nbr
->bfd_info
, json
, use_json
, 0);
5071 static int show_ip_ospf_neighbor_id_common(struct vty
*vty
, struct ospf
*ospf
,
5073 struct cmd_token
**argv
,
5077 struct listnode
*node
;
5078 struct ospf_neighbor
*nbr
;
5079 struct ospf_interface
*oi
;
5080 struct in_addr router_id
;
5082 json_object
*json
= NULL
;
5085 json
= json_object_new_object();
5087 if (ospf
->instance
) {
5089 json_object_int_add(json
, "ospfInstance",
5092 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
5095 ospf_show_vrf_name(ospf
, vty
, json
, use_vrf
);
5097 ret
= inet_aton(argv
[arg_base
]->arg
, &router_id
);
5100 vty_out(vty
, "Please specify Neighbor ID by A.B.C.D\n");
5102 vty_out(vty
, "{}\n");
5103 json_object_free(json
);
5108 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
5109 if ((nbr
= ospf_nbr_lookup_by_routerid(oi
->nbrs
, &router_id
))) {
5110 show_ip_ospf_neighbor_detail_sub(vty
, oi
, nbr
, json
,
5116 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
5117 json
, JSON_C_TO_STRING_PRETTY
));
5118 json_object_free(json
);
5125 DEFUN (show_ip_ospf_neighbor_id
,
5126 show_ip_ospf_neighbor_id_cmd
,
5127 "show ip ospf neighbor A.B.C.D [json]",
5130 "OSPF information\n"
5136 u_char uj
= use_json(argc
, argv
);
5137 struct listnode
*node
= NULL
;
5138 int ret
= CMD_SUCCESS
;
5140 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
5141 if (!ospf
->oi_running
)
5143 ret
= show_ip_ospf_neighbor_id_common(vty
, ospf
, 0,
5150 DEFUN (show_ip_ospf_instance_neighbor_id
,
5151 show_ip_ospf_instance_neighbor_id_cmd
,
5152 "show ip ospf (1-65535) neighbor A.B.C.D [json]",
5155 "OSPF information\n"
5162 int idx_router_id
= 5;
5164 u_short instance
= 0;
5165 u_char uj
= use_json(argc
, argv
);
5167 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5168 ospf
= ospf_lookup_instance(instance
);
5170 return CMD_NOT_MY_INSTANCE
;
5172 if (!ospf
->oi_running
)
5175 return show_ip_ospf_neighbor_id_common(vty
, ospf
, idx_router_id
, argv
,
5179 static int show_ip_ospf_neighbor_detail_common(struct vty
*vty
,
5185 struct ospf_interface
*oi
;
5186 struct listnode
*node
;
5187 json_object
*json_vrf
= NULL
;
5191 json_vrf
= json_object_new_object();
5195 if (ospf
->instance
) {
5197 json_object_int_add(json_vrf
, "ospfInstance",
5200 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
5203 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
5205 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
5206 struct route_node
*rn
;
5207 struct ospf_neighbor
*nbr
;
5209 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
)) {
5210 if ((nbr
= rn
->info
)) {
5211 if (nbr
!= oi
->nbr_self
) {
5212 if (nbr
->state
!= NSM_Down
) {
5213 show_ip_ospf_neighbor_detail_sub(
5214 vty
, oi
, nbr
, json_vrf
,
5224 if (ospf
->vrf_id
== VRF_DEFAULT
)
5225 json_object_object_add(json
, "default",
5228 json_object_object_add(json
, ospf
->name
,
5237 DEFUN (show_ip_ospf_neighbor_detail
,
5238 show_ip_ospf_neighbor_detail_cmd
,
5239 "show ip ospf [vrf <NAME|all>] neighbor detail [json]",
5242 "OSPF information\n"
5246 "detail of all neighbors\n"
5250 u_char uj
= use_json(argc
, argv
);
5251 struct listnode
*node
= NULL
;
5252 char *vrf_name
= NULL
;
5253 bool all_vrf
= FALSE
;
5254 int ret
= CMD_SUCCESS
;
5258 json_object
*json
= NULL
;
5260 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
5263 json
= json_object_new_object();
5265 /* vrf input is provided could be all or specific vrf*/
5269 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
5270 if (!ospf
->oi_running
)
5272 ret
= show_ip_ospf_neighbor_detail_common(vty
,
5279 vty_out(vty
, "%s\n",
5280 json_object_to_json_string_ext(json
,
5281 JSON_C_TO_STRING_PRETTY
));
5282 json_object_free(json
);
5287 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
5288 if (ospf
== NULL
|| !ospf
->oi_running
) {
5290 json_object_free(json
);
5294 /* Display default ospf (instance 0) info */
5295 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
5296 if (ospf
== NULL
|| !ospf
->oi_running
) {
5298 json_object_free(json
);
5304 ret
= show_ip_ospf_neighbor_detail_common(vty
, ospf
, json
, uj
,
5307 vty_out(vty
, "%s\n",
5308 json_object_to_json_string_ext(json
,
5309 JSON_C_TO_STRING_PRETTY
));
5314 json_object_free(json
);
5319 DEFUN (show_ip_ospf_instance_neighbor_detail
,
5320 show_ip_ospf_instance_neighbor_detail_cmd
,
5321 "show ip ospf (1-65535) neighbor detail [json]",
5324 "OSPF information\n"
5327 "detail of all neighbors\n"
5332 u_short instance
= 0;
5333 u_char uj
= use_json(argc
, argv
);
5334 json_object
*json
= NULL
;
5335 int ret
= CMD_SUCCESS
;
5337 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5338 ospf
= ospf_lookup_instance(instance
);
5340 return CMD_NOT_MY_INSTANCE
;
5342 if (!ospf
->oi_running
)
5346 json
= json_object_new_object();
5348 ret
= show_ip_ospf_neighbor_detail_common(vty
, ospf
, json
, uj
, 0);
5351 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
5352 json
, JSON_C_TO_STRING_PRETTY
));
5353 json_object_free(json
);
5359 static int show_ip_ospf_neighbor_detail_all_common(struct vty
*vty
,
5365 struct listnode
*node
;
5366 struct ospf_interface
*oi
;
5367 json_object
*json_vrf
= NULL
;
5371 json_vrf
= json_object_new_object();
5376 if (ospf
->instance
) {
5378 json_object_int_add(json
, "ospfInstance",
5381 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
5384 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
5386 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
5387 struct route_node
*rn
;
5388 struct ospf_neighbor
*nbr
;
5389 struct ospf_nbr_nbma
*nbr_nbma
;
5391 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
))
5392 if ((nbr
= rn
->info
))
5393 if (nbr
!= oi
->nbr_self
)
5394 if (nbr
->state
!= NSM_Down
)
5395 show_ip_ospf_neighbor_detail_sub(
5397 json_vrf
, use_json
);
5399 if (oi
->type
== OSPF_IFTYPE_NBMA
) {
5400 struct listnode
*nd
;
5402 for (ALL_LIST_ELEMENTS_RO(oi
->nbr_nbma
, nd
, nbr_nbma
)) {
5403 if (nbr_nbma
->nbr
== NULL
5404 || nbr_nbma
->nbr
->state
== NSM_Down
)
5405 show_ip_ospf_nbr_nbma_detail_sub(
5406 vty
, oi
, nbr_nbma
, use_json
,
5414 if (ospf
->vrf_id
== VRF_DEFAULT
)
5415 json_object_object_add(json
, "default",
5418 json_object_object_add(json
, ospf
->name
,
5428 DEFUN (show_ip_ospf_neighbor_detail_all
,
5429 show_ip_ospf_neighbor_detail_all_cmd
,
5430 "show ip ospf [vrf <NAME|all>] neighbor detail all [json]",
5433 "OSPF information\n"
5437 "detail of all neighbors\n"
5438 "include down status neighbor\n"
5442 u_char uj
= use_json(argc
, argv
);
5443 struct listnode
*node
= NULL
;
5444 char *vrf_name
= NULL
;
5445 bool all_vrf
= FALSE
;
5446 int ret
= CMD_SUCCESS
;
5450 json_object
*json
= NULL
;
5452 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
5455 json
= json_object_new_object();
5457 /* vrf input is provided could be all or specific vrf*/
5461 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
5462 if (!ospf
->oi_running
)
5464 ret
= show_ip_ospf_neighbor_detail_all_common(vty
,
5472 vty_out(vty
, "%s\n",
5473 json_object_to_json_string_ext(json
,
5474 JSON_C_TO_STRING_PRETTY
));
5475 json_object_free(json
);
5480 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
5481 if (ospf
== NULL
|| !ospf
->oi_running
) {
5483 json_object_free(json
);
5487 /* Display default ospf (instance 0) info */
5488 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
5489 if (ospf
== NULL
|| !ospf
->oi_running
) {
5491 json_object_free(json
);
5497 ret
= show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, json
,
5500 vty_out(vty
, "%s\n",
5501 json_object_to_json_string_ext(json
,
5502 JSON_C_TO_STRING_PRETTY
));
5507 json_object_free(json
);
5512 DEFUN (show_ip_ospf_instance_neighbor_detail_all
,
5513 show_ip_ospf_instance_neighbor_detail_all_cmd
,
5514 "show ip ospf (1-65535) neighbor detail all [json]",
5517 "OSPF information\n"
5520 "detail of all neighbors\n"
5521 "include down status neighbor\n"
5526 u_short instance
= 0;
5527 u_char uj
= use_json(argc
, argv
);
5528 json_object
*json
= NULL
;
5529 int ret
= CMD_SUCCESS
;
5531 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5532 ospf
= ospf_lookup_instance(instance
);
5534 return CMD_NOT_MY_INSTANCE
;
5536 if (!ospf
->oi_running
)
5540 json
= json_object_new_object();
5542 ret
= show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, json
, uj
, 0);
5545 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
5546 JSON_C_TO_STRING_PRETTY
));
5547 json_object_free(json
);
5553 static int show_ip_ospf_neighbor_int_detail_common(struct vty
*vty
,
5556 struct cmd_token
**argv
,
5559 struct ospf_interface
*oi
;
5560 struct interface
*ifp
;
5561 struct route_node
*rn
, *nrn
;
5562 struct ospf_neighbor
*nbr
;
5563 json_object
*json
= NULL
;
5566 json
= json_object_new_object();
5568 if (ospf
->instance
) {
5570 json_object_int_add(json
, "ospfInstance",
5573 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
5576 ifp
= if_lookup_by_name_all_vrf(argv
[arg_base
]->arg
);
5579 vty_out(vty
, "No such interface.\n");
5581 vty_out(vty
, "{}\n");
5582 json_object_free(json
);
5587 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
5588 if ((oi
= rn
->info
)) {
5589 for (nrn
= route_top(oi
->nbrs
); nrn
;
5590 nrn
= route_next(nrn
)) {
5591 if ((nbr
= nrn
->info
)) {
5592 if (nbr
!= oi
->nbr_self
) {
5593 if (nbr
->state
!= NSM_Down
)
5594 show_ip_ospf_neighbor_detail_sub(
5604 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
5605 json
, JSON_C_TO_STRING_PRETTY
));
5606 json_object_free(json
);
5613 DEFUN (show_ip_ospf_neighbor_int_detail
,
5614 show_ip_ospf_neighbor_int_detail_cmd
,
5615 "show ip ospf neighbor IFNAME detail [json]",
5618 "OSPF information\n"
5621 "detail of all neighbors\n"
5625 u_char uj
= use_json(argc
, argv
);
5626 struct listnode
*node
= NULL
;
5627 int ret
= CMD_SUCCESS
;
5629 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
5630 if (!ospf
->oi_running
)
5632 ret
= show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 0,
5639 DEFUN (show_ip_ospf_instance_neighbor_int_detail
,
5640 show_ip_ospf_instance_neighbor_int_detail_cmd
,
5641 "show ip ospf (1-65535) neighbor IFNAME detail [json]",
5644 "OSPF information\n"
5648 "detail of all neighbors\n"
5654 u_short instance
= 0;
5655 u_char uj
= use_json(argc
, argv
);
5657 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5658 ospf
= ospf_lookup_instance(instance
);
5660 return CMD_NOT_MY_INSTANCE
;
5662 if (!ospf
->oi_running
)
5665 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, idx_ifname
, argv
, uj
);
5668 /* Show functions */
5669 static int show_lsa_summary(struct vty
*vty
, struct ospf_lsa
*lsa
, int self
)
5671 struct router_lsa
*rl
;
5672 struct summary_lsa
*sl
;
5673 struct as_external_lsa
*asel
;
5674 struct prefix_ipv4 p
;
5677 /* If self option is set, check LSA self flag. */
5678 if (self
== 0 || IS_LSA_SELF(lsa
)) {
5679 /* LSA common part show. */
5680 vty_out(vty
, "%-15s ", inet_ntoa(lsa
->data
->id
));
5681 vty_out(vty
, "%-15s %4d 0x%08lx 0x%04x",
5682 inet_ntoa(lsa
->data
->adv_router
), LS_AGE(lsa
),
5683 (u_long
)ntohl(lsa
->data
->ls_seqnum
),
5684 ntohs(lsa
->data
->checksum
));
5685 /* LSA specific part show. */
5686 switch (lsa
->data
->type
) {
5687 case OSPF_ROUTER_LSA
:
5688 rl
= (struct router_lsa
*)lsa
->data
;
5689 vty_out(vty
, " %-d", ntohs(rl
->links
));
5691 case OSPF_SUMMARY_LSA
:
5692 sl
= (struct summary_lsa
*)lsa
->data
;
5695 p
.prefix
= sl
->header
.id
;
5696 p
.prefixlen
= ip_masklen(sl
->mask
);
5697 apply_mask_ipv4(&p
);
5699 vty_out(vty
, " %s/%d", inet_ntoa(p
.prefix
),
5702 case OSPF_AS_EXTERNAL_LSA
:
5703 case OSPF_AS_NSSA_LSA
:
5704 asel
= (struct as_external_lsa
*)lsa
->data
;
5707 p
.prefix
= asel
->header
.id
;
5708 p
.prefixlen
= ip_masklen(asel
->mask
);
5709 apply_mask_ipv4(&p
);
5711 vty_out(vty
, " %s %s/%d [0x%lx]",
5712 IS_EXTERNAL_METRIC(asel
->e
[0].tos
)
5715 inet_ntoa(p
.prefix
), p
.prefixlen
,
5716 (u_long
)ntohl(asel
->e
[0].route_tag
));
5718 case OSPF_NETWORK_LSA
:
5719 case OSPF_ASBR_SUMMARY_LSA
:
5720 case OSPF_OPAQUE_LINK_LSA
:
5721 case OSPF_OPAQUE_AREA_LSA
:
5722 case OSPF_OPAQUE_AS_LSA
:
5732 static const char *show_database_desc
[] = {
5734 "Router Link States",
5736 "Summary Link States",
5737 "ASBR-Summary Link States",
5738 "AS External Link States",
5739 "Group Membership LSA",
5740 "NSSA-external Link States",
5742 "Link-Local Opaque-LSA",
5743 "Area-Local Opaque-LSA",
5744 "AS-external Opaque-LSA",
5747 static const char *show_database_header
[] = {
5749 "Link ID ADV Router Age Seq# CkSum Link count",
5750 "Link ID ADV Router Age Seq# CkSum",
5751 "Link ID ADV Router Age Seq# CkSum Route",
5752 "Link ID ADV Router Age Seq# CkSum",
5753 "Link ID ADV Router Age Seq# CkSum Route",
5754 " --- header for Group Member ----",
5755 "Link ID ADV Router Age Seq# CkSum Route",
5757 "Opaque-Type/Id ADV Router Age Seq# CkSum",
5758 "Opaque-Type/Id ADV Router Age Seq# CkSum",
5759 "Opaque-Type/Id ADV Router Age Seq# CkSum",
5762 static void show_ip_ospf_database_header(struct vty
*vty
, struct ospf_lsa
*lsa
)
5764 struct router_lsa
*rlsa
= (struct router_lsa
*)lsa
->data
;
5766 vty_out(vty
, " LS age: %d\n", LS_AGE(lsa
));
5767 vty_out(vty
, " Options: 0x%-2x : %s\n", lsa
->data
->options
,
5768 ospf_options_dump(lsa
->data
->options
));
5769 vty_out(vty
, " LS Flags: 0x%-2x %s\n", lsa
->flags
,
5770 ((lsa
->flags
& OSPF_LSA_LOCAL_XLT
) ? "(Translated from Type-7)"
5773 if (lsa
->data
->type
== OSPF_ROUTER_LSA
) {
5774 vty_out(vty
, " Flags: 0x%x", rlsa
->flags
);
5777 vty_out(vty
, " :%s%s%s%s",
5778 IS_ROUTER_LSA_BORDER(rlsa
) ? " ABR" : "",
5779 IS_ROUTER_LSA_EXTERNAL(rlsa
) ? " ASBR" : "",
5780 IS_ROUTER_LSA_VIRTUAL(rlsa
) ? " VL-endpoint"
5782 IS_ROUTER_LSA_SHORTCUT(rlsa
) ? " Shortcut"
5787 vty_out(vty
, " LS Type: %s\n",
5788 lookup_msg(ospf_lsa_type_msg
, lsa
->data
->type
, NULL
));
5789 vty_out(vty
, " Link State ID: %s %s\n", inet_ntoa(lsa
->data
->id
),
5790 lookup_msg(ospf_link_state_id_type_msg
, lsa
->data
->type
, NULL
));
5791 vty_out(vty
, " Advertising Router: %s\n",
5792 inet_ntoa(lsa
->data
->adv_router
));
5793 vty_out(vty
, " LS Seq Number: %08lx\n",
5794 (u_long
)ntohl(lsa
->data
->ls_seqnum
));
5795 vty_out(vty
, " Checksum: 0x%04x\n", ntohs(lsa
->data
->checksum
));
5796 vty_out(vty
, " Length: %d\n\n", ntohs(lsa
->data
->length
));
5799 const char *link_type_desc
[] = {
5801 "another Router (point-to-point)",
5802 "a Transit Network",
5807 const char *link_id_desc
[] = {
5808 "(null)", "Neighboring Router ID", "Designated Router address",
5809 "Net", "Neighboring Router ID",
5812 const char *link_data_desc
[] = {
5813 "(null)", "Router Interface address", "Router Interface address",
5814 "Network Mask", "Router Interface address",
5817 /* Show router-LSA each Link information. */
5818 static void show_ip_ospf_database_router_links(struct vty
*vty
,
5819 struct router_lsa
*rl
)
5824 len
= ntohs(rl
->header
.length
) - 4;
5825 for (i
= 0; i
< ntohs(rl
->links
) && len
> 0; len
-= 12, i
++) {
5826 type
= rl
->link
[i
].type
;
5828 vty_out(vty
, " Link connected to: %s\n",
5829 link_type_desc
[type
]);
5830 vty_out(vty
, " (Link ID) %s: %s\n", link_id_desc
[type
],
5831 inet_ntoa(rl
->link
[i
].link_id
));
5832 vty_out(vty
, " (Link Data) %s: %s\n", link_data_desc
[type
],
5833 inet_ntoa(rl
->link
[i
].link_data
));
5834 vty_out(vty
, " Number of TOS metrics: 0\n");
5835 vty_out(vty
, " TOS 0 Metric: %d\n",
5836 ntohs(rl
->link
[i
].metric
));
5841 /* Show router-LSA detail information. */
5842 static int show_router_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5845 struct router_lsa
*rl
= (struct router_lsa
*)lsa
->data
;
5847 show_ip_ospf_database_header(vty
, lsa
);
5849 vty_out(vty
, " Number of Links: %d\n\n", ntohs(rl
->links
));
5851 show_ip_ospf_database_router_links(vty
, rl
);
5858 /* Show network-LSA detail information. */
5859 static int show_network_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5864 struct network_lsa
*nl
= (struct network_lsa
*)lsa
->data
;
5866 show_ip_ospf_database_header(vty
, lsa
);
5868 vty_out(vty
, " Network Mask: /%d\n", ip_masklen(nl
->mask
));
5870 length
= ntohs(lsa
->data
->length
) - OSPF_LSA_HEADER_SIZE
- 4;
5872 for (i
= 0; length
> 0; i
++, length
-= 4)
5873 vty_out(vty
, " Attached Router: %s\n",
5874 inet_ntoa(nl
->routers
[i
]));
5882 /* Show summary-LSA detail information. */
5883 static int show_summary_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5886 struct summary_lsa
*sl
= (struct summary_lsa
*)lsa
->data
;
5888 show_ip_ospf_database_header(vty
, lsa
);
5890 vty_out(vty
, " Network Mask: /%d\n", ip_masklen(sl
->mask
));
5891 vty_out(vty
, " TOS: 0 Metric: %d\n",
5892 GET_METRIC(sl
->metric
));
5899 /* Show summary-ASBR-LSA detail information. */
5900 static int show_summary_asbr_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5903 struct summary_lsa
*sl
= (struct summary_lsa
*)lsa
->data
;
5905 show_ip_ospf_database_header(vty
, lsa
);
5907 vty_out(vty
, " Network Mask: /%d\n", ip_masklen(sl
->mask
));
5908 vty_out(vty
, " TOS: 0 Metric: %d\n",
5909 GET_METRIC(sl
->metric
));
5916 /* Show AS-external-LSA detail information. */
5917 static int show_as_external_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5920 struct as_external_lsa
*al
=
5921 (struct as_external_lsa
*)lsa
->data
;
5923 show_ip_ospf_database_header(vty
, lsa
);
5925 vty_out(vty
, " Network Mask: /%d\n", ip_masklen(al
->mask
));
5926 vty_out(vty
, " Metric Type: %s\n",
5927 IS_EXTERNAL_METRIC(al
->e
[0].tos
)
5928 ? "2 (Larger than any link state path)"
5930 vty_out(vty
, " TOS: 0\n");
5931 vty_out(vty
, " Metric: %d\n",
5932 GET_METRIC(al
->e
[0].metric
));
5933 vty_out(vty
, " Forward Address: %s\n",
5934 inet_ntoa(al
->e
[0].fwd_addr
));
5937 " External Route Tag: %" ROUTE_TAG_PRI
"\n\n",
5938 (route_tag_t
)ntohl(al
->e
[0].route_tag
));
5945 show_as_external_lsa_stdvty (struct ospf_lsa
*lsa
)
5947 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5949 /* show_ip_ospf_database_header (vty, lsa); */
5951 zlog_debug( " Network Mask: /%d%s",
5952 ip_masklen (al
->mask
), "\n");
5953 zlog_debug( " Metric Type: %s%s",
5954 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5955 "2 (Larger than any link state path)" : "1", "\n");
5956 zlog_debug( " TOS: 0%s", "\n");
5957 zlog_debug( " Metric: %d%s",
5958 GET_METRIC (al
->e
[0].metric
), "\n");
5959 zlog_debug( " Forward Address: %s%s",
5960 inet_ntoa (al
->e
[0].fwd_addr
), "\n");
5962 zlog_debug( " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5963 (route_tag_t
)ntohl (al
->e
[0].route_tag
), "\n", "\n");
5968 /* Show AS-NSSA-LSA detail information. */
5969 static int show_as_nssa_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5972 struct as_external_lsa
*al
=
5973 (struct as_external_lsa
*)lsa
->data
;
5975 show_ip_ospf_database_header(vty
, lsa
);
5977 vty_out(vty
, " Network Mask: /%d\n", ip_masklen(al
->mask
));
5978 vty_out(vty
, " Metric Type: %s\n",
5979 IS_EXTERNAL_METRIC(al
->e
[0].tos
)
5980 ? "2 (Larger than any link state path)"
5982 vty_out(vty
, " TOS: 0\n");
5983 vty_out(vty
, " Metric: %d\n",
5984 GET_METRIC(al
->e
[0].metric
));
5985 vty_out(vty
, " NSSA: Forward Address: %s\n",
5986 inet_ntoa(al
->e
[0].fwd_addr
));
5989 " External Route Tag: %" ROUTE_TAG_PRI
"\n\n",
5990 (route_tag_t
)ntohl(al
->e
[0].route_tag
));
5996 static int show_func_dummy(struct vty
*vty
, struct ospf_lsa
*lsa
)
6001 static int show_opaque_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
6004 show_ip_ospf_database_header(vty
, lsa
);
6005 show_opaque_info_detail(vty
, lsa
);
6012 int (*show_function
[])(struct vty
*, struct ospf_lsa
*) = {
6014 show_router_lsa_detail
,
6015 show_network_lsa_detail
,
6016 show_summary_lsa_detail
,
6017 show_summary_asbr_lsa_detail
,
6018 show_as_external_lsa_detail
,
6020 show_as_nssa_lsa_detail
, /* almost same as external */
6022 show_opaque_lsa_detail
,
6023 show_opaque_lsa_detail
,
6024 show_opaque_lsa_detail
,
6027 static void show_lsa_prefix_set(struct vty
*vty
, struct prefix_ls
*lp
,
6028 struct in_addr
*id
, struct in_addr
*adv_router
)
6030 memset(lp
, 0, sizeof(struct prefix_ls
));
6034 else if (adv_router
== NULL
) {
6040 lp
->adv_router
= *adv_router
;
6044 static void show_lsa_detail_proc(struct vty
*vty
, struct route_table
*rt
,
6045 struct in_addr
*id
, struct in_addr
*adv_router
)
6047 struct prefix_ls lp
;
6048 struct route_node
*rn
, *start
;
6049 struct ospf_lsa
*lsa
;
6051 show_lsa_prefix_set(vty
, &lp
, id
, adv_router
);
6052 start
= route_node_get(rt
, (struct prefix
*)&lp
);
6054 route_lock_node(start
);
6055 for (rn
= start
; rn
; rn
= route_next_until(rn
, start
))
6056 if ((lsa
= rn
->info
)) {
6057 if (show_function
[lsa
->data
->type
] != NULL
)
6058 show_function
[lsa
->data
->type
](vty
,
6061 route_unlock_node(start
);
6065 /* Show detail LSA information
6066 -- if id is NULL then show all LSAs. */
6067 static void show_lsa_detail(struct vty
*vty
, struct ospf
*ospf
, int type
,
6068 struct in_addr
*id
, struct in_addr
*adv_router
)
6070 struct listnode
*node
;
6071 struct ospf_area
*area
;
6074 case OSPF_AS_EXTERNAL_LSA
:
6075 case OSPF_OPAQUE_AS_LSA
:
6076 vty_out(vty
, " %s \n\n",
6077 show_database_desc
[type
]);
6078 show_lsa_detail_proc(vty
, AS_LSDB(ospf
, type
), id
, adv_router
);
6081 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
6082 vty_out(vty
, "\n %s (Area %s)\n\n",
6083 show_database_desc
[type
],
6084 ospf_area_desc_string(area
));
6085 show_lsa_detail_proc(vty
, AREA_LSDB(area
, type
), id
,
6092 static void show_lsa_detail_adv_router_proc(struct vty
*vty
,
6093 struct route_table
*rt
,
6094 struct in_addr
*adv_router
)
6096 struct route_node
*rn
;
6097 struct ospf_lsa
*lsa
;
6099 for (rn
= route_top(rt
); rn
; rn
= route_next(rn
))
6100 if ((lsa
= rn
->info
))
6101 if (IPV4_ADDR_SAME(adv_router
,
6102 &lsa
->data
->adv_router
)) {
6103 if (CHECK_FLAG(lsa
->flags
, OSPF_LSA_LOCAL_XLT
))
6105 if (show_function
[lsa
->data
->type
] != NULL
)
6106 show_function
[lsa
->data
->type
](vty
,
6111 /* Show detail LSA information. */
6112 static void show_lsa_detail_adv_router(struct vty
*vty
, struct ospf
*ospf
,
6113 int type
, struct in_addr
*adv_router
)
6115 struct listnode
*node
;
6116 struct ospf_area
*area
;
6119 case OSPF_AS_EXTERNAL_LSA
:
6120 case OSPF_OPAQUE_AS_LSA
:
6121 vty_out(vty
, " %s \n\n",
6122 show_database_desc
[type
]);
6123 show_lsa_detail_adv_router_proc(vty
, AS_LSDB(ospf
, type
),
6127 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
6128 vty_out(vty
, "\n %s (Area %s)\n\n",
6129 show_database_desc
[type
],
6130 ospf_area_desc_string(area
));
6131 show_lsa_detail_adv_router_proc(
6132 vty
, AREA_LSDB(area
, type
), adv_router
);
6138 static void show_ip_ospf_database_summary(struct vty
*vty
, struct ospf
*ospf
,
6141 struct ospf_lsa
*lsa
;
6142 struct route_node
*rn
;
6143 struct ospf_area
*area
;
6144 struct listnode
*node
;
6147 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
6148 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++) {
6150 case OSPF_AS_EXTERNAL_LSA
:
6151 case OSPF_OPAQUE_AS_LSA
:
6156 if (ospf_lsdb_count_self(area
->lsdb
, type
) > 0
6158 && ospf_lsdb_count(area
->lsdb
, type
) > 0)) {
6159 vty_out(vty
, " %s (Area %s)\n\n",
6160 show_database_desc
[type
],
6161 ospf_area_desc_string(area
));
6162 vty_out(vty
, "%s\n",
6163 show_database_header
[type
]);
6165 LSDB_LOOP(AREA_LSDB(area
, type
), rn
, lsa
)
6166 show_lsa_summary(vty
, lsa
, self
);
6173 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++) {
6175 case OSPF_AS_EXTERNAL_LSA
:
6176 case OSPF_OPAQUE_AS_LSA
:
6181 if (ospf_lsdb_count_self(ospf
->lsdb
, type
)
6182 || (!self
&& ospf_lsdb_count(ospf
->lsdb
, type
))) {
6183 vty_out(vty
, " %s\n\n",
6184 show_database_desc
[type
]);
6185 vty_out(vty
, "%s\n", show_database_header
[type
]);
6187 LSDB_LOOP(AS_LSDB(ospf
, type
), rn
, lsa
)
6188 show_lsa_summary(vty
, lsa
, self
);
6197 static void show_ip_ospf_database_maxage(struct vty
*vty
, struct ospf
*ospf
)
6199 struct route_node
*rn
;
6201 vty_out(vty
, "\n MaxAge Link States:\n\n");
6203 for (rn
= route_top(ospf
->maxage_lsa
); rn
; rn
= route_next(rn
)) {
6204 struct ospf_lsa
*lsa
;
6206 if ((lsa
= rn
->info
) != NULL
) {
6207 vty_out(vty
, "Link type: %d\n", lsa
->data
->type
);
6208 vty_out(vty
, "Link State ID: %s\n",
6209 inet_ntoa(lsa
->data
->id
));
6210 vty_out(vty
, "Advertising Router: %s\n",
6211 inet_ntoa(lsa
->data
->adv_router
));
6212 vty_out(vty
, "LSA lock count: %d\n", lsa
->lock
);
6218 #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
6219 #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
6221 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
6222 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
6223 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
6224 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
6226 #define OSPF_LSA_TYPES_DESC \
6227 "ASBR summary link states\n" \
6228 "External link states\n" \
6229 "Network link states\n" \
6230 "Router link states\n" \
6231 "Network summary link states\n" OSPF_LSA_TYPE_NSSA_DESC \
6232 OSPF_LSA_TYPE_OPAQUE_LINK_DESC OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
6233 OSPF_LSA_TYPE_OPAQUE_AS_DESC
6235 static int show_ip_ospf_database_common(struct vty
*vty
, struct ospf
*ospf
,
6236 int arg_base
, int argc
,
6237 struct cmd_token
**argv
,
6242 struct in_addr id
, adv_router
;
6245 vty_out(vty
, "\nOSPF Instance: %d\n", ospf
->instance
);
6247 ospf_show_vrf_name(ospf
, vty
, NULL
, use_vrf
);
6249 vty_out(vty
, "\n OSPF Router with ID (%s)\n\n",
6250 inet_ntoa(ospf
->router_id
));
6253 if (argc
== arg_base
+ 4) {
6254 show_ip_ospf_database_summary(vty
, ospf
, 0);
6258 /* Set database type to show. */
6259 if (strncmp(argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
6260 type
= OSPF_ROUTER_LSA
;
6261 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
6262 type
= OSPF_NETWORK_LSA
;
6263 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
6264 type
= OSPF_AS_NSSA_LSA
;
6265 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "su", 2) == 0)
6266 type
= OSPF_SUMMARY_LSA
;
6267 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
6268 type
= OSPF_ASBR_SUMMARY_LSA
;
6269 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
6270 type
= OSPF_AS_EXTERNAL_LSA
;
6271 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "se", 2) == 0) {
6272 show_ip_ospf_database_summary(vty
, ospf
, 1);
6274 } else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "m", 1) == 0) {
6275 show_ip_ospf_database_maxage(vty
, ospf
);
6277 } else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
6278 type
= OSPF_OPAQUE_LINK_LSA
;
6279 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
6280 type
= OSPF_OPAQUE_AREA_LSA
;
6281 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
6282 type
= OSPF_OPAQUE_AS_LSA
;
6286 /* `show ip ospf database LSA'. */
6287 if (argc
== arg_base
+ 5)
6288 show_lsa_detail(vty
, ospf
, type
, NULL
, NULL
);
6289 else if (argc
>= arg_base
+ 6) {
6290 ret
= inet_aton(argv
[arg_base
+ 5]->arg
, &id
);
6294 /* `show ip ospf database LSA ID'. */
6295 if (argc
== arg_base
+ 6)
6296 show_lsa_detail(vty
, ospf
, type
, &id
, NULL
);
6297 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
6298 else if (argc
== arg_base
+ 7) {
6299 if (strncmp(argv
[arg_base
+ 6]->text
, "s", 1) == 0)
6300 adv_router
= ospf
->router_id
;
6302 ret
= inet_aton(argv
[arg_base
+ 7]->arg
,
6307 show_lsa_detail(vty
, ospf
, type
, &id
, &adv_router
);
6314 DEFUN (show_ip_ospf_database_max
,
6315 show_ip_ospf_database_max_cmd
,
6316 "show ip ospf [vrf <NAME|all>] database <max-age|self-originate>",
6319 "OSPF information\n"
6322 "Database summary\n"
6323 "LSAs in MaxAge list\n"
6324 "Self-originated link states\n")
6326 struct ospf
*ospf
= NULL
;
6327 struct listnode
*node
= NULL
;
6328 char *vrf_name
= NULL
;
6329 bool all_vrf
= FALSE
;
6330 int ret
= CMD_SUCCESS
;
6335 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
6340 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
6341 if (!ospf
->oi_running
)
6343 ret
= show_ip_ospf_database_common(vty
, ospf
,
6350 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
6351 if (ospf
== NULL
|| !ospf
->oi_running
)
6353 ret
= (show_ip_ospf_database_common(vty
, ospf
, idx_vrf
?
6358 /* Display default ospf (instance 0) info */
6359 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
6360 if (ospf
== NULL
|| !ospf
->oi_running
)
6362 ret
= show_ip_ospf_database_common(vty
, ospf
, 0, argc
, argv
,
6369 DEFUN (show_ip_ospf_instance_database
,
6370 show_ip_ospf_instance_database_cmd
,
6371 "show ip ospf [{(1-65535)|vrf NAME}] 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>]]]",
6374 "OSPF information\n"
6377 "Database summary\n"
6379 "Link State ID (as an IP address)\n"
6380 "Self-originated link states\n"
6381 "Advertising Router link states\n"
6382 "Advertising Router (as an IP address)\n")
6385 u_short instance
= 0;
6386 struct listnode
*node
= NULL
;
6387 char *vrf_name
= NULL
;
6388 bool all_vrf
= FALSE
;
6389 int ret
= CMD_SUCCESS
;
6394 if (argv_find(argv
, argc
, "(1-65535)", &idx
)) {
6395 instance
= strtoul(argv
[idx
]->arg
, NULL
, 10);
6396 ospf
= ospf_lookup_instance(instance
);
6398 return CMD_NOT_MY_INSTANCE
;
6399 if (!ospf
->oi_running
)
6402 return (show_ip_ospf_database_common(vty
, ospf
, idx
? 1 : 0,
6403 argc
, argv
, use_vrf
));
6404 } else if (argv_find(argv
, argc
, "vrf", &idx
)) {
6405 vrf_name
= argv
[++idx
]->arg
;
6406 all_vrf
= strmatch(vrf_name
, "all");
6412 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
6413 if (!ospf
->oi_running
)
6415 ret
= (show_ip_ospf_database_common(vty
, ospf
,
6421 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
6422 if ((ospf
== NULL
) || !ospf
->oi_running
)
6424 ret
= (show_ip_ospf_database_common(vty
, ospf
, idx
? 2 :
6429 /* Display default ospf (instance 0) info */
6430 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
6431 if (ospf
== NULL
|| !ospf
->oi_running
)
6433 ret
= (show_ip_ospf_database_common(vty
, ospf
, 0, argc
, argv
,
6440 DEFUN (show_ip_ospf_instance_database_max
,
6441 show_ip_ospf_instance_database_max_cmd
,
6442 "show ip ospf (1-65535) database <max-age|self-originate>",
6445 "OSPF information\n"
6447 "Database summary\n"
6448 "LSAs in MaxAge list\n"
6449 "Self-originated link states\n")
6453 u_short instance
= 0;
6455 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6457 ospf
= ospf_lookup_instance(instance
);
6459 return CMD_NOT_MY_INSTANCE
;
6461 if (!ospf
->oi_running
)
6464 return show_ip_ospf_database_common(vty
, ospf
, 1, argc
, argv
, 0);
6468 static int show_ip_ospf_database_type_adv_router_common(struct vty
*vty
,
6470 int arg_base
, int argc
,
6471 struct cmd_token
**argv
,
6476 struct in_addr adv_router
;
6479 vty_out(vty
, "\nOSPF Instance: %d\n", ospf
->instance
);
6481 ospf_show_vrf_name(ospf
, vty
, NULL
, use_vrf
);
6483 vty_out(vty
, "\n OSPF Router with ID (%s)\n\n",
6484 inet_ntoa(ospf
->router_id
));
6486 /* Set database type to show. */
6487 if (strncmp(argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
6488 type
= OSPF_ROUTER_LSA
;
6489 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
6490 type
= OSPF_NETWORK_LSA
;
6491 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
6492 type
= OSPF_AS_NSSA_LSA
;
6493 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "s", 1) == 0)
6494 type
= OSPF_SUMMARY_LSA
;
6495 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
6496 type
= OSPF_ASBR_SUMMARY_LSA
;
6497 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
6498 type
= OSPF_AS_EXTERNAL_LSA
;
6499 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
6500 type
= OSPF_OPAQUE_LINK_LSA
;
6501 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
6502 type
= OSPF_OPAQUE_AREA_LSA
;
6503 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
6504 type
= OSPF_OPAQUE_AS_LSA
;
6508 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
6509 if (strncmp(argv
[arg_base
+ 5]->text
, "s", 1) == 0)
6510 adv_router
= ospf
->router_id
;
6512 ret
= inet_aton(argv
[arg_base
+ 6]->arg
, &adv_router
);
6517 show_lsa_detail_adv_router(vty
, ospf
, type
, &adv_router
);
6522 DEFUN (show_ip_ospf_instance_database_type_adv_router
,
6523 show_ip_ospf_instance_database_type_adv_router_cmd
,
6524 "show ip ospf [{(1-65535)|vrf NAME}] database <asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as> <adv-router A.B.C.D|self-originate>",
6527 "OSPF information\n"
6530 "Database summary\n"
6532 "Advertising Router link states\n"
6533 "Advertising Router (as an IP address)\n"
6534 "Self-originated link states\n")
6536 struct ospf
*ospf
= NULL
;
6537 u_short instance
= 0;
6538 struct listnode
*node
= NULL
;
6539 char *vrf_name
= NULL
;
6540 bool all_vrf
= FALSE
;
6541 int ret
= CMD_SUCCESS
;
6543 int idx
= 0, idx_vrf
= 0;
6546 if (argv_find(argv
, argc
, "(1-65535)", &idx
)) {
6547 instance
= strtoul(argv
[idx
]->arg
, NULL
, 10);
6548 ospf
= ospf_lookup_instance(instance
);
6550 return CMD_NOT_MY_INSTANCE
;
6551 if (!ospf
->oi_running
)
6553 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
,
6560 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
6565 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
6566 if (!ospf
->oi_running
)
6568 ret
= show_ip_ospf_database_type_adv_router_common(vty
,
6569 ospf
, idx
? 1 : 0, argc
, argv
,
6573 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
6574 if ((ospf
== NULL
) || !ospf
->oi_running
)
6576 ret
= show_ip_ospf_database_type_adv_router_common(vty
,
6577 ospf
, idx
? 1 : 0, argc
, argv
,
6581 /* Display default ospf (instance 0) info */
6582 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
6583 if (ospf
== NULL
|| !ospf
->oi_running
)
6585 ret
= show_ip_ospf_database_type_adv_router_common(vty
, ospf
,
6591 /*return (show_ip_ospf_database_type_adv_router_common(
6592 vty, ospf, idx ? 1 : 0, argc, argv));*/
6595 DEFUN (ip_ospf_authentication_args
,
6596 ip_ospf_authentication_args_addr_cmd
,
6597 "ip ospf authentication <null|message-digest> [A.B.C.D]",
6599 "OSPF interface commands\n"
6600 "Enable authentication on this interface\n"
6601 "Use null authentication\n"
6602 "Use message-digest authentication\n"
6603 "Address of interface\n")
6605 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6606 int idx_encryption
= 3;
6608 struct in_addr addr
;
6610 struct ospf_if_params
*params
;
6612 params
= IF_DEF_PARAMS(ifp
);
6615 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6618 "Please specify interface address by A.B.C.D\n");
6619 return CMD_WARNING_CONFIG_FAILED
;
6622 params
= ospf_get_if_params(ifp
, addr
);
6623 ospf_if_update_params(ifp
, addr
);
6626 /* Handle null authentication */
6627 if (argv
[idx_encryption
]->arg
[0] == 'n') {
6628 SET_IF_PARAM(params
, auth_type
);
6629 params
->auth_type
= OSPF_AUTH_NULL
;
6633 /* Handle message-digest authentication */
6634 if (argv
[idx_encryption
]->arg
[0] == 'm') {
6635 SET_IF_PARAM(params
, auth_type
);
6636 params
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
6640 vty_out(vty
, "You shouldn't get here!\n");
6641 return CMD_WARNING_CONFIG_FAILED
;
6644 DEFUN (ip_ospf_authentication
,
6645 ip_ospf_authentication_addr_cmd
,
6646 "ip ospf authentication [A.B.C.D]",
6648 "OSPF interface commands\n"
6649 "Enable authentication on this interface\n"
6650 "Address of interface\n")
6652 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6654 struct in_addr addr
;
6656 struct ospf_if_params
*params
;
6658 params
= IF_DEF_PARAMS(ifp
);
6661 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6664 "Please specify interface address by A.B.C.D\n");
6665 return CMD_WARNING_CONFIG_FAILED
;
6668 params
= ospf_get_if_params(ifp
, addr
);
6669 ospf_if_update_params(ifp
, addr
);
6672 SET_IF_PARAM(params
, auth_type
);
6673 params
->auth_type
= OSPF_AUTH_SIMPLE
;
6678 DEFUN (no_ip_ospf_authentication_args
,
6679 no_ip_ospf_authentication_args_addr_cmd
,
6680 "no ip ospf authentication <null|message-digest> [A.B.C.D]",
6683 "OSPF interface commands\n"
6684 "Enable authentication on this interface\n"
6685 "Use null authentication\n"
6686 "Use message-digest authentication\n"
6687 "Address of interface\n")
6689 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6690 int idx_encryption
= 4;
6692 struct in_addr addr
;
6694 struct ospf_if_params
*params
;
6695 struct route_node
*rn
;
6698 params
= IF_DEF_PARAMS(ifp
);
6701 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6704 "Please specify interface address by A.B.C.D\n");
6705 return CMD_WARNING_CONFIG_FAILED
;
6708 params
= ospf_lookup_if_params(ifp
, addr
);
6709 if (params
== NULL
) {
6710 vty_out(vty
, "Ip Address specified is unknown\n");
6711 return CMD_WARNING_CONFIG_FAILED
;
6713 params
->auth_type
= OSPF_AUTH_NOTSET
;
6714 UNSET_IF_PARAM(params
, auth_type
);
6715 if (params
!= IF_DEF_PARAMS(ifp
)) {
6716 ospf_free_if_params(ifp
, addr
);
6717 ospf_if_update_params(ifp
, addr
);
6720 if (argv
[idx_encryption
]->arg
[0] == 'n') {
6721 auth_type
= OSPF_AUTH_NULL
;
6722 } else if (argv
[idx_encryption
]->arg
[0] == 'm') {
6723 auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
6725 vty_out(vty
, "Unexpected input encountered\n");
6726 return CMD_WARNING_CONFIG_FAILED
;
6729 * Here we have a case where the user has entered
6730 * 'no ip ospf authentication (null | message_digest )'
6731 * we need to find if we have any ip addresses underneath it
6733 * correspond to the associated type.
6735 if (params
->auth_type
== auth_type
) {
6736 params
->auth_type
= OSPF_AUTH_NOTSET
;
6737 UNSET_IF_PARAM(params
, auth_type
);
6740 for (rn
= route_top(IF_OIFS_PARAMS(ifp
)); rn
;
6741 rn
= route_next(rn
)) {
6742 if ((params
= rn
->info
)) {
6743 if (params
->auth_type
== auth_type
) {
6744 params
->auth_type
= OSPF_AUTH_NOTSET
;
6745 UNSET_IF_PARAM(params
, auth_type
);
6746 if (params
!= IF_DEF_PARAMS(ifp
)) {
6747 ospf_free_if_params(
6748 ifp
, rn
->p
.u
.prefix4
);
6749 ospf_if_update_params(
6750 ifp
, rn
->p
.u
.prefix4
);
6760 DEFUN (no_ip_ospf_authentication
,
6761 no_ip_ospf_authentication_addr_cmd
,
6762 "no ip ospf authentication [A.B.C.D]",
6765 "OSPF interface commands\n"
6766 "Enable authentication on this interface\n"
6767 "Address of interface\n")
6769 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6771 struct in_addr addr
;
6773 struct ospf_if_params
*params
;
6774 struct route_node
*rn
;
6776 params
= IF_DEF_PARAMS(ifp
);
6779 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6782 "Please specify interface address by A.B.C.D\n");
6783 return CMD_WARNING_CONFIG_FAILED
;
6786 params
= ospf_lookup_if_params(ifp
, addr
);
6787 if (params
== NULL
) {
6788 vty_out(vty
, "Ip Address specified is unknown\n");
6789 return CMD_WARNING_CONFIG_FAILED
;
6792 params
->auth_type
= OSPF_AUTH_NOTSET
;
6793 UNSET_IF_PARAM(params
, auth_type
);
6794 if (params
!= IF_DEF_PARAMS(ifp
)) {
6795 ospf_free_if_params(ifp
, addr
);
6796 ospf_if_update_params(ifp
, addr
);
6800 * When a user enters 'no ip ospf authentication'
6801 * We should remove all authentication types from
6804 if ((params
->auth_type
== OSPF_AUTH_NULL
)
6805 || (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
6806 || (params
->auth_type
== OSPF_AUTH_SIMPLE
)) {
6807 params
->auth_type
= OSPF_AUTH_NOTSET
;
6808 UNSET_IF_PARAM(params
, auth_type
);
6811 for (rn
= route_top(IF_OIFS_PARAMS(ifp
)); rn
;
6812 rn
= route_next(rn
)) {
6813 if ((params
= rn
->info
)) {
6815 if ((params
->auth_type
== OSPF_AUTH_NULL
)
6816 || (params
->auth_type
6817 == OSPF_AUTH_CRYPTOGRAPHIC
)
6818 || (params
->auth_type
6819 == OSPF_AUTH_SIMPLE
)) {
6820 params
->auth_type
= OSPF_AUTH_NOTSET
;
6821 UNSET_IF_PARAM(params
, auth_type
);
6822 if (params
!= IF_DEF_PARAMS(ifp
)) {
6823 ospf_free_if_params(
6824 ifp
, rn
->p
.u
.prefix4
);
6825 ospf_if_update_params(
6826 ifp
, rn
->p
.u
.prefix4
);
6837 DEFUN (ip_ospf_authentication_key
,
6838 ip_ospf_authentication_key_addr_cmd
,
6839 "ip ospf authentication-key AUTH_KEY [A.B.C.D]",
6841 "OSPF interface commands\n"
6842 "Authentication password (key)\n"
6843 "The OSPF password (key)\n"
6844 "Address of interface\n")
6846 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6848 struct in_addr addr
;
6849 struct ospf_if_params
*params
;
6851 params
= IF_DEF_PARAMS(ifp
);
6853 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6854 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6856 "Please specify interface address by A.B.C.D\n");
6857 return CMD_WARNING_CONFIG_FAILED
;
6860 params
= ospf_get_if_params(ifp
, addr
);
6861 ospf_if_update_params(ifp
, addr
);
6864 memset(params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
6865 strncpy((char *)params
->auth_simple
, argv
[3]->arg
,
6866 OSPF_AUTH_SIMPLE_SIZE
);
6867 SET_IF_PARAM(params
, auth_simple
);
6872 DEFUN_HIDDEN (ospf_authentication_key
,
6873 ospf_authentication_key_cmd
,
6874 "ospf authentication-key AUTH_KEY [A.B.C.D]",
6875 "OSPF interface commands\n"
6876 VLINK_HELPSTR_AUTH_SIMPLE
6877 "Address of interface\n")
6879 return ip_ospf_authentication_key(self
, vty
, argc
, argv
);
6882 DEFUN (no_ip_ospf_authentication_key
,
6883 no_ip_ospf_authentication_key_authkey_addr_cmd
,
6884 "no ip ospf authentication-key [AUTH_KEY [A.B.C.D]]",
6887 "OSPF interface commands\n"
6888 VLINK_HELPSTR_AUTH_SIMPLE
6889 "Address of interface\n")
6891 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6893 struct in_addr addr
;
6894 struct ospf_if_params
*params
;
6895 params
= IF_DEF_PARAMS(ifp
);
6897 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6898 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6900 "Please specify interface address by A.B.C.D\n");
6901 return CMD_WARNING_CONFIG_FAILED
;
6904 params
= ospf_lookup_if_params(ifp
, addr
);
6909 memset(params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
);
6910 UNSET_IF_PARAM(params
, auth_simple
);
6912 if (params
!= IF_DEF_PARAMS(ifp
)) {
6913 ospf_free_if_params(ifp
, addr
);
6914 ospf_if_update_params(ifp
, addr
);
6920 DEFUN_HIDDEN (no_ospf_authentication_key
,
6921 no_ospf_authentication_key_authkey_addr_cmd
,
6922 "no ospf authentication-key [AUTH_KEY [A.B.C.D]]",
6924 "OSPF interface commands\n"
6925 VLINK_HELPSTR_AUTH_SIMPLE
6926 "Address of interface\n")
6928 return no_ip_ospf_authentication_key(self
, vty
, argc
, argv
);
6931 DEFUN (ip_ospf_message_digest_key
,
6932 ip_ospf_message_digest_key_cmd
,
6933 "ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
6935 "OSPF interface commands\n"
6936 "Message digest authentication password (key)\n"
6938 "Use MD5 algorithm\n"
6939 "The OSPF password (key)\n"
6940 "Address of interface\n")
6942 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6943 struct crypt_key
*ck
;
6945 struct in_addr addr
;
6946 struct ospf_if_params
*params
;
6948 params
= IF_DEF_PARAMS(ifp
);
6951 argv_find(argv
, argc
, "(1-255)", &idx
);
6952 char *keyid
= argv
[idx
]->arg
;
6953 argv_find(argv
, argc
, "KEY", &idx
);
6954 char *cryptkey
= argv
[idx
]->arg
;
6956 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6957 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6959 "Please specify interface address by A.B.C.D\n");
6960 return CMD_WARNING_CONFIG_FAILED
;
6963 params
= ospf_get_if_params(ifp
, addr
);
6964 ospf_if_update_params(ifp
, addr
);
6967 key_id
= strtol(keyid
, NULL
, 10);
6968 if (ospf_crypt_key_lookup(params
->auth_crypt
, key_id
) != NULL
) {
6969 vty_out(vty
, "OSPF: Key %d already exists\n", key_id
);
6973 ck
= ospf_crypt_key_new();
6974 ck
->key_id
= (u_char
)key_id
;
6975 memset(ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+ 1);
6976 strncpy((char *)ck
->auth_key
, cryptkey
, OSPF_AUTH_MD5_SIZE
);
6978 ospf_crypt_key_add(params
->auth_crypt
, ck
);
6979 SET_IF_PARAM(params
, auth_crypt
);
6984 DEFUN_HIDDEN (ospf_message_digest_key
,
6985 ospf_message_digest_key_cmd
,
6986 "ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
6987 "OSPF interface commands\n"
6988 "Message digest authentication password (key)\n"
6990 "Use MD5 algorithm\n"
6991 "The OSPF password (key)\n"
6992 "Address of interface\n")
6994 return ip_ospf_message_digest_key(self
, vty
, argc
, argv
);
6997 DEFUN (no_ip_ospf_message_digest_key
,
6998 no_ip_ospf_message_digest_key_cmd
,
6999 "no ip ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
7002 "OSPF interface commands\n"
7003 "Message digest authentication password (key)\n"
7005 "Use MD5 algorithm\n"
7006 "The OSPF password (key)\n"
7007 "Address of interface\n")
7009 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7011 struct crypt_key
*ck
;
7013 struct in_addr addr
;
7014 struct ospf_if_params
*params
;
7015 params
= IF_DEF_PARAMS(ifp
);
7017 argv_find(argv
, argc
, "(1-255)", &idx
);
7018 char *keyid
= argv
[idx
]->arg
;
7020 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7021 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7023 "Please specify interface address by A.B.C.D\n");
7024 return CMD_WARNING_CONFIG_FAILED
;
7027 params
= ospf_lookup_if_params(ifp
, addr
);
7032 key_id
= strtol(keyid
, NULL
, 10);
7033 ck
= ospf_crypt_key_lookup(params
->auth_crypt
, key_id
);
7035 vty_out(vty
, "OSPF: Key %d does not exist\n", key_id
);
7036 return CMD_WARNING_CONFIG_FAILED
;
7039 ospf_crypt_key_delete(params
->auth_crypt
, key_id
);
7041 if (params
!= IF_DEF_PARAMS(ifp
)) {
7042 ospf_free_if_params(ifp
, addr
);
7043 ospf_if_update_params(ifp
, addr
);
7049 DEFUN_HIDDEN (no_ospf_message_digest_key
,
7050 no_ospf_message_digest_key_cmd
,
7051 "no ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
7053 "OSPF interface commands\n"
7054 "Message digest authentication password (key)\n"
7056 "Use MD5 algorithm\n"
7057 "The OSPF password (key)\n"
7058 "Address of interface\n")
7060 return no_ip_ospf_message_digest_key(self
, vty
, argc
, argv
);
7063 DEFUN (ip_ospf_cost
,
7065 "ip ospf cost (1-65535) [A.B.C.D]",
7067 "OSPF interface commands\n"
7070 "Address of interface\n")
7072 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7074 u_int32_t cost
= OSPF_OUTPUT_COST_DEFAULT
;
7075 struct in_addr addr
;
7076 struct ospf_if_params
*params
;
7077 params
= IF_DEF_PARAMS(ifp
);
7080 char *coststr
= NULL
, *ifaddr
= NULL
;
7082 argv_find(argv
, argc
, "(1-65535)", &idx
);
7083 coststr
= argv
[idx
]->arg
;
7084 cost
= strtol(coststr
, NULL
, 10);
7086 ifaddr
= argv_find(argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
7088 if (!inet_aton(ifaddr
, &addr
)) {
7090 "Please specify interface address by A.B.C.D\n");
7091 return CMD_WARNING_CONFIG_FAILED
;
7094 params
= ospf_get_if_params(ifp
, addr
);
7095 ospf_if_update_params(ifp
, addr
);
7098 SET_IF_PARAM(params
, output_cost_cmd
);
7099 params
->output_cost_cmd
= cost
;
7101 ospf_if_recalculate_output_cost(ifp
);
7106 DEFUN_HIDDEN (ospf_cost
,
7108 "ospf cost (1-65535) [A.B.C.D]",
7109 "OSPF interface commands\n"
7112 "Address of interface\n")
7114 return ip_ospf_cost(self
, vty
, argc
, argv
);
7117 DEFUN (no_ip_ospf_cost
,
7118 no_ip_ospf_cost_cmd
,
7119 "no ip ospf cost [(1-65535)] [A.B.C.D]",
7122 "OSPF interface commands\n"
7125 "Address of interface\n")
7127 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7129 struct in_addr addr
;
7130 struct ospf_if_params
*params
;
7132 params
= IF_DEF_PARAMS(ifp
);
7135 char *ifaddr
= NULL
;
7136 ifaddr
= argv_find(argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
7138 /* According to the semantics we are mimicking "no ip ospf cost N" is
7139 * always treated as "no ip ospf cost" regardless of the actual value
7140 * of N already configured for the interface. Thus ignore cost. */
7143 if (!inet_aton(ifaddr
, &addr
)) {
7145 "Please specify interface address by A.B.C.D\n");
7146 return CMD_WARNING_CONFIG_FAILED
;
7149 params
= ospf_lookup_if_params(ifp
, addr
);
7154 UNSET_IF_PARAM(params
, output_cost_cmd
);
7156 if (params
!= IF_DEF_PARAMS(ifp
)) {
7157 ospf_free_if_params(ifp
, addr
);
7158 ospf_if_update_params(ifp
, addr
);
7161 ospf_if_recalculate_output_cost(ifp
);
7166 DEFUN_HIDDEN (no_ospf_cost
,
7168 "no ospf cost [(1-65535)] [A.B.C.D]",
7170 "OSPF interface commands\n"
7173 "Address of interface\n")
7175 return no_ip_ospf_cost(self
, vty
, argc
, argv
);
7178 static void ospf_nbr_timer_update(struct ospf_interface
*oi
)
7180 struct route_node
*rn
;
7181 struct ospf_neighbor
*nbr
;
7183 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
))
7184 if ((nbr
= rn
->info
)) {
7185 nbr
->v_inactivity
= OSPF_IF_PARAM(oi
, v_wait
);
7186 nbr
->v_db_desc
= OSPF_IF_PARAM(oi
, retransmit_interval
);
7187 nbr
->v_ls_req
= OSPF_IF_PARAM(oi
, retransmit_interval
);
7188 nbr
->v_ls_upd
= OSPF_IF_PARAM(oi
, retransmit_interval
);
7192 static int ospf_vty_dead_interval_set(struct vty
*vty
, const char *interval_str
,
7193 const char *nbr_str
,
7194 const char *fast_hello_str
)
7196 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7199 struct in_addr addr
;
7201 struct ospf_if_params
*params
;
7202 struct ospf_interface
*oi
;
7203 struct route_node
*rn
;
7205 params
= IF_DEF_PARAMS(ifp
);
7208 ret
= inet_aton(nbr_str
, &addr
);
7211 "Please specify interface address by A.B.C.D\n");
7212 return CMD_WARNING_CONFIG_FAILED
;
7215 params
= ospf_get_if_params(ifp
, addr
);
7216 ospf_if_update_params(ifp
, addr
);
7220 seconds
= strtoul(interval_str
, NULL
, 10);
7222 /* reset fast_hello too, just to be sure */
7223 UNSET_IF_PARAM(params
, fast_hello
);
7224 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
7225 } else if (fast_hello_str
) {
7226 hellomult
= strtoul(fast_hello_str
, NULL
, 10);
7227 /* 1s dead-interval with sub-second hellos desired */
7228 seconds
= OSPF_ROUTER_DEAD_INTERVAL_MINIMAL
;
7229 SET_IF_PARAM(params
, fast_hello
);
7230 params
->fast_hello
= hellomult
;
7233 "Please specify dead-interval or hello-multiplier\n");
7234 return CMD_WARNING_CONFIG_FAILED
;
7237 SET_IF_PARAM(params
, v_wait
);
7238 params
->v_wait
= seconds
;
7240 /* Update timer values in neighbor structure. */
7242 struct ospf
*ospf
= NULL
;
7244 ospf
= ospf_lookup_by_vrf_id(ifp
->vrf_id
);
7246 oi
= ospf_if_lookup_by_local_addr(ospf
, ifp
, addr
);
7248 ospf_nbr_timer_update(oi
);
7251 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
))
7252 if ((oi
= rn
->info
))
7253 ospf_nbr_timer_update(oi
);
7259 DEFUN (ip_ospf_dead_interval
,
7260 ip_ospf_dead_interval_cmd
,
7261 "ip ospf dead-interval (1-65535) [A.B.C.D]",
7263 "OSPF interface commands\n"
7264 "Interval time after which a neighbor is declared down\n"
7266 "Address of interface\n")
7269 char *interval
= argv_find(argv
, argc
, "(1-65535)", &idx
)
7273 argv_find(argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
7274 return ospf_vty_dead_interval_set(vty
, interval
, ifaddr
, NULL
);
7278 DEFUN_HIDDEN (ospf_dead_interval
,
7279 ospf_dead_interval_cmd
,
7280 "ospf dead-interval (1-65535) [A.B.C.D]",
7281 "OSPF interface commands\n"
7282 "Interval time after which a neighbor is declared down\n"
7284 "Address of interface\n")
7286 return ip_ospf_dead_interval(self
, vty
, argc
, argv
);
7289 DEFUN (ip_ospf_dead_interval_minimal
,
7290 ip_ospf_dead_interval_minimal_addr_cmd
,
7291 "ip ospf dead-interval minimal hello-multiplier (1-10) [A.B.C.D]",
7293 "OSPF interface commands\n"
7294 "Interval time after which a neighbor is declared down\n"
7295 "Minimal 1s dead-interval with fast sub-second hellos\n"
7296 "Hello multiplier factor\n"
7297 "Number of Hellos to send each second\n"
7298 "Address of interface\n")
7303 return ospf_vty_dead_interval_set(
7304 vty
, NULL
, argv
[idx_ipv4
]->arg
, argv
[idx_number
]->arg
);
7306 return ospf_vty_dead_interval_set(vty
, NULL
, NULL
,
7307 argv
[idx_number
]->arg
);
7310 DEFUN (no_ip_ospf_dead_interval
,
7311 no_ip_ospf_dead_interval_cmd
,
7312 "no ip ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
7315 "OSPF interface commands\n"
7316 "Interval time after which a neighbor is declared down\n"
7318 "Minimal 1s dead-interval with fast sub-second hellos\n"
7319 "Hello multiplier factor\n"
7320 "Number of Hellos to send each second\n"
7321 "Address of interface\n")
7323 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7324 int idx_ipv4
= argc
- 1;
7325 struct in_addr addr
= {.s_addr
= 0L};
7327 struct ospf_if_params
*params
;
7328 struct ospf_interface
*oi
;
7329 struct route_node
*rn
;
7331 params
= IF_DEF_PARAMS(ifp
);
7333 if (argv
[idx_ipv4
]->type
== IPV4_TKN
) {
7334 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7337 "Please specify interface address by A.B.C.D\n");
7338 return CMD_WARNING_CONFIG_FAILED
;
7341 params
= ospf_lookup_if_params(ifp
, addr
);
7346 UNSET_IF_PARAM(params
, v_wait
);
7347 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
7349 UNSET_IF_PARAM(params
, fast_hello
);
7350 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
7352 if (params
!= IF_DEF_PARAMS(ifp
)) {
7353 ospf_free_if_params(ifp
, addr
);
7354 ospf_if_update_params(ifp
, addr
);
7357 /* Update timer values in neighbor structure. */
7359 struct ospf
*ospf
= NULL
;
7361 ospf
= ospf_lookup_by_vrf_id(ifp
->vrf_id
);
7363 oi
= ospf_if_lookup_by_local_addr(ospf
, ifp
, addr
);
7365 ospf_nbr_timer_update(oi
);
7368 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
))
7369 if ((oi
= rn
->info
))
7370 ospf_nbr_timer_update(oi
);
7376 DEFUN_HIDDEN (no_ospf_dead_interval
,
7377 no_ospf_dead_interval_cmd
,
7378 "no ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
7380 "OSPF interface commands\n"
7381 "Interval time after which a neighbor is declared down\n"
7383 "Minimal 1s dead-interval with fast sub-second hellos\n"
7384 "Hello multiplier factor\n"
7385 "Number of Hellos to send each second\n"
7386 "Address of interface\n")
7388 return no_ip_ospf_dead_interval(self
, vty
, argc
, argv
);
7391 DEFUN (ip_ospf_hello_interval
,
7392 ip_ospf_hello_interval_cmd
,
7393 "ip ospf hello-interval (1-65535) [A.B.C.D]",
7395 "OSPF interface commands\n"
7396 "Time between HELLO packets\n"
7398 "Address of interface\n")
7400 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7402 struct in_addr addr
;
7403 struct ospf_if_params
*params
;
7404 params
= IF_DEF_PARAMS(ifp
);
7405 u_int32_t seconds
= 0;
7407 argv_find(argv
, argc
, "(1-65535)", &idx
);
7408 seconds
= strtol(argv
[idx
]->arg
, NULL
, 10);
7410 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7411 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7413 "Please specify interface address by A.B.C.D\n");
7414 return CMD_WARNING_CONFIG_FAILED
;
7417 params
= ospf_get_if_params(ifp
, addr
);
7418 ospf_if_update_params(ifp
, addr
);
7421 SET_IF_PARAM(params
, v_hello
);
7422 params
->v_hello
= seconds
;
7427 DEFUN_HIDDEN (ospf_hello_interval
,
7428 ospf_hello_interval_cmd
,
7429 "ospf hello-interval (1-65535) [A.B.C.D]",
7430 "OSPF interface commands\n"
7431 "Time between HELLO packets\n"
7433 "Address of interface\n")
7435 return ip_ospf_hello_interval(self
, vty
, argc
, argv
);
7438 DEFUN (no_ip_ospf_hello_interval
,
7439 no_ip_ospf_hello_interval_cmd
,
7440 "no ip ospf hello-interval [(1-65535) [A.B.C.D]]",
7443 "OSPF interface commands\n"
7444 "Time between HELLO packets\n" // ignored
7446 "Address of interface\n")
7448 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7450 struct in_addr addr
;
7451 struct ospf_if_params
*params
;
7453 params
= IF_DEF_PARAMS(ifp
);
7455 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7456 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7458 "Please specify interface address by A.B.C.D\n");
7459 return CMD_WARNING_CONFIG_FAILED
;
7462 params
= ospf_lookup_if_params(ifp
, addr
);
7467 UNSET_IF_PARAM(params
, v_hello
);
7468 params
->v_hello
= OSPF_HELLO_INTERVAL_DEFAULT
;
7470 if (params
!= IF_DEF_PARAMS(ifp
)) {
7471 ospf_free_if_params(ifp
, addr
);
7472 ospf_if_update_params(ifp
, addr
);
7478 DEFUN_HIDDEN (no_ospf_hello_interval
,
7479 no_ospf_hello_interval_cmd
,
7480 "no ospf hello-interval [(1-65535) [A.B.C.D]]",
7482 "OSPF interface commands\n"
7483 "Time between HELLO packets\n" // ignored
7485 "Address of interface\n")
7487 return no_ip_ospf_hello_interval(self
, vty
, argc
, argv
);
7490 DEFUN (ip_ospf_network
,
7491 ip_ospf_network_cmd
,
7492 "ip ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
7494 "OSPF interface commands\n"
7496 "Specify OSPF broadcast multi-access network\n"
7497 "Specify OSPF NBMA network\n"
7498 "Specify OSPF point-to-multipoint network\n"
7499 "Specify OSPF point-to-point network\n")
7501 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7503 int old_type
= IF_DEF_PARAMS(ifp
)->type
;
7504 struct route_node
*rn
;
7506 if (old_type
== OSPF_IFTYPE_LOOPBACK
) {
7508 "This is a loopback interface. Can't set network type.\n");
7509 return CMD_WARNING_CONFIG_FAILED
;
7512 if (argv_find(argv
, argc
, "broadcast", &idx
))
7513 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_BROADCAST
;
7514 else if (argv_find(argv
, argc
, "non-broadcast", &idx
))
7515 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_NBMA
;
7516 else if (argv_find(argv
, argc
, "point-to-multipoint", &idx
))
7517 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_POINTOMULTIPOINT
;
7518 else if (argv_find(argv
, argc
, "point-to-point", &idx
))
7519 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_POINTOPOINT
;
7521 if (IF_DEF_PARAMS(ifp
)->type
== old_type
)
7524 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), type
);
7526 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
7527 struct ospf_interface
*oi
= rn
->info
;
7532 oi
->type
= IF_DEF_PARAMS(ifp
)->type
;
7534 if (oi
->state
> ISM_Down
) {
7535 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceDown
);
7536 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceUp
);
7543 DEFUN_HIDDEN (ospf_network
,
7545 "ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
7546 "OSPF interface commands\n"
7548 "Specify OSPF broadcast multi-access network\n"
7549 "Specify OSPF NBMA network\n"
7550 "Specify OSPF point-to-multipoint network\n"
7551 "Specify OSPF point-to-point network\n")
7553 return ip_ospf_network(self
, vty
, argc
, argv
);
7556 DEFUN (no_ip_ospf_network
,
7557 no_ip_ospf_network_cmd
,
7558 "no ip ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
7561 "OSPF interface commands\n"
7563 "Specify OSPF broadcast multi-access network\n"
7564 "Specify OSPF NBMA network\n"
7565 "Specify OSPF point-to-multipoint network\n"
7566 "Specify OSPF point-to-point network\n")
7568 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7569 int old_type
= IF_DEF_PARAMS(ifp
)->type
;
7570 struct route_node
*rn
;
7572 IF_DEF_PARAMS(ifp
)->type
= ospf_default_iftype(ifp
);
7574 if (IF_DEF_PARAMS(ifp
)->type
== old_type
)
7577 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
7578 struct ospf_interface
*oi
= rn
->info
;
7583 oi
->type
= IF_DEF_PARAMS(ifp
)->type
;
7585 if (oi
->state
> ISM_Down
) {
7586 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceDown
);
7587 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceUp
);
7594 DEFUN_HIDDEN (no_ospf_network
,
7595 no_ospf_network_cmd
,
7596 "no ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
7598 "OSPF interface commands\n"
7600 "Specify OSPF broadcast multi-access network\n"
7601 "Specify OSPF NBMA network\n"
7602 "Specify OSPF point-to-multipoint network\n"
7603 "Specify OSPF point-to-point network\n")
7605 return no_ip_ospf_network(self
, vty
, argc
, argv
);
7608 DEFUN (ip_ospf_priority
,
7609 ip_ospf_priority_cmd
,
7610 "ip ospf priority (0-255) [A.B.C.D]",
7612 "OSPF interface commands\n"
7615 "Address of interface\n")
7617 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7620 struct route_node
*rn
;
7621 struct in_addr addr
;
7622 struct ospf_if_params
*params
;
7623 params
= IF_DEF_PARAMS(ifp
);
7625 argv_find(argv
, argc
, "(0-255)", &idx
);
7626 priority
= strtol(argv
[idx
]->arg
, NULL
, 10);
7628 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7629 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7631 "Please specify interface address by A.B.C.D\n");
7632 return CMD_WARNING_CONFIG_FAILED
;
7635 params
= ospf_get_if_params(ifp
, addr
);
7636 ospf_if_update_params(ifp
, addr
);
7639 SET_IF_PARAM(params
, priority
);
7640 params
->priority
= priority
;
7642 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
7643 struct ospf_interface
*oi
= rn
->info
;
7648 if (PRIORITY(oi
) != OSPF_IF_PARAM(oi
, priority
)) {
7649 PRIORITY(oi
) = OSPF_IF_PARAM(oi
, priority
);
7650 OSPF_ISM_EVENT_SCHEDULE(oi
, ISM_NeighborChange
);
7657 DEFUN_HIDDEN (ospf_priority
,
7659 "ospf priority (0-255) [A.B.C.D]",
7660 "OSPF interface commands\n"
7663 "Address of interface\n")
7665 return ip_ospf_priority(self
, vty
, argc
, argv
);
7668 DEFUN (no_ip_ospf_priority
,
7669 no_ip_ospf_priority_cmd
,
7670 "no ip ospf priority [(0-255) [A.B.C.D]]",
7673 "OSPF interface commands\n"
7674 "Router priority\n" // ignored
7676 "Address of interface\n")
7678 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7680 struct route_node
*rn
;
7681 struct in_addr addr
;
7682 struct ospf_if_params
*params
;
7684 params
= IF_DEF_PARAMS(ifp
);
7686 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7687 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7689 "Please specify interface address by A.B.C.D\n");
7690 return CMD_WARNING_CONFIG_FAILED
;
7693 params
= ospf_lookup_if_params(ifp
, addr
);
7698 UNSET_IF_PARAM(params
, priority
);
7699 params
->priority
= OSPF_ROUTER_PRIORITY_DEFAULT
;
7701 if (params
!= IF_DEF_PARAMS(ifp
)) {
7702 ospf_free_if_params(ifp
, addr
);
7703 ospf_if_update_params(ifp
, addr
);
7706 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
7707 struct ospf_interface
*oi
= rn
->info
;
7712 if (PRIORITY(oi
) != OSPF_IF_PARAM(oi
, priority
)) {
7713 PRIORITY(oi
) = OSPF_IF_PARAM(oi
, priority
);
7714 OSPF_ISM_EVENT_SCHEDULE(oi
, ISM_NeighborChange
);
7721 DEFUN_HIDDEN (no_ospf_priority
,
7722 no_ospf_priority_cmd
,
7723 "no ospf priority [(0-255) [A.B.C.D]]",
7725 "OSPF interface commands\n"
7728 "Address of interface\n")
7730 return no_ip_ospf_priority(self
, vty
, argc
, argv
);
7733 DEFUN (ip_ospf_retransmit_interval
,
7734 ip_ospf_retransmit_interval_addr_cmd
,
7735 "ip ospf retransmit-interval (3-65535) [A.B.C.D]",
7737 "OSPF interface commands\n"
7738 "Time between retransmitting lost link state advertisements\n"
7740 "Address of interface\n")
7742 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7745 struct in_addr addr
;
7746 struct ospf_if_params
*params
;
7747 params
= IF_DEF_PARAMS(ifp
);
7749 argv_find(argv
, argc
, "(3-65535)", &idx
);
7750 seconds
= strtol(argv
[idx
]->arg
, NULL
, 10);
7752 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7753 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7755 "Please specify interface address by A.B.C.D\n");
7756 return CMD_WARNING_CONFIG_FAILED
;
7759 params
= ospf_get_if_params(ifp
, addr
);
7760 ospf_if_update_params(ifp
, addr
);
7763 SET_IF_PARAM(params
, retransmit_interval
);
7764 params
->retransmit_interval
= seconds
;
7769 DEFUN_HIDDEN (ospf_retransmit_interval
,
7770 ospf_retransmit_interval_cmd
,
7771 "ospf retransmit-interval (3-65535) [A.B.C.D]",
7772 "OSPF interface commands\n"
7773 "Time between retransmitting lost link state advertisements\n"
7775 "Address of interface\n")
7777 return ip_ospf_retransmit_interval(self
, vty
, argc
, argv
);
7780 DEFUN (no_ip_ospf_retransmit_interval
,
7781 no_ip_ospf_retransmit_interval_addr_cmd
,
7782 "no ip ospf retransmit-interval [(3-65535)] [A.B.C.D]",
7785 "OSPF interface commands\n"
7786 "Time between retransmitting lost link state advertisements\n"
7788 "Address of interface\n")
7790 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7792 struct in_addr addr
;
7793 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 UNSET_IF_PARAM(params
, retransmit_interval
);
7810 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
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_retransmit_interval
,
7821 no_ospf_retransmit_interval_cmd
,
7822 "no ospf retransmit-interval [(3-65535)] [A.B.C.D]",
7824 "OSPF interface commands\n"
7825 "Time between retransmitting lost link state advertisements\n"
7827 "Address of interface\n")
7829 return no_ip_ospf_retransmit_interval(self
, vty
, argc
, argv
);
7832 DEFUN (ip_ospf_transmit_delay
,
7833 ip_ospf_transmit_delay_addr_cmd
,
7834 "ip ospf transmit-delay (1-65535) [A.B.C.D]",
7836 "OSPF interface commands\n"
7837 "Link state transmit delay\n"
7839 "Address of interface\n")
7841 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7844 struct in_addr addr
;
7845 struct ospf_if_params
*params
;
7847 params
= IF_DEF_PARAMS(ifp
);
7848 argv_find(argv
, argc
, "(1-65535)", &idx
);
7849 seconds
= strtol(argv
[idx
]->arg
, NULL
, 10);
7851 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7852 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7854 "Please specify interface address by A.B.C.D\n");
7855 return CMD_WARNING_CONFIG_FAILED
;
7858 params
= ospf_get_if_params(ifp
, addr
);
7859 ospf_if_update_params(ifp
, addr
);
7862 SET_IF_PARAM(params
, transmit_delay
);
7863 params
->transmit_delay
= seconds
;
7868 DEFUN_HIDDEN (ospf_transmit_delay
,
7869 ospf_transmit_delay_cmd
,
7870 "ospf transmit-delay (1-65535) [A.B.C.D]",
7871 "OSPF interface commands\n"
7872 "Link state transmit delay\n"
7874 "Address of interface\n")
7876 return ip_ospf_transmit_delay(self
, vty
, argc
, argv
);
7879 DEFUN (no_ip_ospf_transmit_delay
,
7880 no_ip_ospf_transmit_delay_addr_cmd
,
7881 "no ip ospf transmit-delay [(1-65535)] [A.B.C.D]",
7884 "OSPF interface commands\n"
7885 "Link state transmit delay\n"
7887 "Address of interface\n")
7889 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7891 struct in_addr addr
;
7892 struct ospf_if_params
*params
;
7894 params
= IF_DEF_PARAMS(ifp
);
7896 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7897 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7899 "Please specify interface address by A.B.C.D\n");
7900 return CMD_WARNING_CONFIG_FAILED
;
7903 params
= ospf_lookup_if_params(ifp
, addr
);
7908 UNSET_IF_PARAM(params
, transmit_delay
);
7909 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
7911 if (params
!= IF_DEF_PARAMS(ifp
)) {
7912 ospf_free_if_params(ifp
, addr
);
7913 ospf_if_update_params(ifp
, addr
);
7920 DEFUN_HIDDEN (no_ospf_transmit_delay
,
7921 no_ospf_transmit_delay_cmd
,
7922 "no ospf transmit-delay [(1-65535) [A.B.C.D]]",
7924 "OSPF interface commands\n"
7925 "Link state transmit delay\n"
7927 "Address of interface\n")
7929 return no_ip_ospf_transmit_delay(self
, vty
, argc
, argv
);
7932 DEFUN (ip_ospf_area
,
7934 "ip ospf [(1-65535)] area <A.B.C.D|(0-4294967295)> [A.B.C.D]",
7936 "OSPF interface commands\n"
7938 "Enable OSPF on this interface\n"
7939 "OSPF area ID in IP address format\n"
7940 "OSPF area ID as a decimal value\n"
7941 "Address of interface\n")
7943 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7946 struct in_addr area_id
;
7947 struct in_addr addr
;
7948 struct ospf_if_params
*params
= NULL
;
7949 struct route_node
*rn
;
7950 struct ospf
*ospf
= NULL
;
7951 u_short instance
= 0;
7954 if (argv_find(argv
, argc
, "(1-65535)", &idx
))
7955 instance
= strtol(argv
[idx
]->arg
, NULL
, 10);
7957 argv_find(argv
, argc
, "area", &idx
);
7958 areaid
= argv
[idx
+ 1]->arg
;
7960 if (ifp
->vrf_id
&& !instance
)
7961 ospf
= ospf_lookup_by_vrf_id(ifp
->vrf_id
);
7963 ospf
= ospf_lookup_instance(instance
);
7965 if (instance
&& ospf
== NULL
) {
7966 params
= IF_DEF_PARAMS(ifp
);
7967 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
7968 UNSET_IF_PARAM(params
, if_area
);
7969 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
7970 ospf_interface_area_unset(ospf
, ifp
);
7971 ospf
->if_ospf_cli_count
--;
7973 return CMD_NOT_MY_INSTANCE
;
7976 ret
= str2area_id(areaid
, &area_id
, &format
);
7978 vty_out(vty
, "Please specify area by A.B.C.D|<0-4294967295>\n");
7979 return CMD_WARNING_CONFIG_FAILED
;
7981 if (memcmp(ifp
->name
, "VLINK", 5) == 0) {
7982 vty_out(vty
, "Cannot enable OSPF on a virtual link.\n");
7983 return CMD_WARNING_CONFIG_FAILED
;
7986 params
= IF_DEF_PARAMS(ifp
);
7987 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)
7988 && !IPV4_ADDR_SAME(¶ms
->if_area
, &area_id
)) {
7990 "Must remove previous area config before changing ospf area \n");
7991 return CMD_WARNING_CONFIG_FAILED
;
7994 // Check if we have an address arg and proccess it
7995 if (argc
== idx
+ 3) {
7996 if (!inet_aton(argv
[idx
+ 2]->arg
, &addr
)) {
7997 vty_out(vty
, "Please specify Intf Address by A.B.C.D\n");
7998 return CMD_WARNING_CONFIG_FAILED
;
8000 // update/create address-level params
8001 params
= ospf_get_if_params((ifp
), (addr
));
8002 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
8004 "Must remove previous area/address config before changing ospf area");
8005 return CMD_WARNING_CONFIG_FAILED
;
8007 ospf_if_update_params((ifp
), (addr
));
8011 for (rn
= route_top(ospf
->networks
); rn
; rn
= route_next(rn
)) {
8012 if (rn
->info
!= NULL
) {
8014 "Please remove all network commands first.\n");
8015 return CMD_WARNING_CONFIG_FAILED
;
8020 /* enable ospf on this interface with area_id */
8022 SET_IF_PARAM(params
, if_area
);
8023 params
->if_area
= area_id
;
8024 params
->if_area_id_fmt
= format
;
8028 ospf_interface_area_set(ospf
, ifp
);
8029 ospf
->if_ospf_cli_count
++;
8035 DEFUN (no_ip_ospf_area
,
8036 no_ip_ospf_area_cmd
,
8037 "no ip ospf [(1-65535)] area [<A.B.C.D|(0-4294967295)> [A.B.C.D]]",
8040 "OSPF interface commands\n"
8042 "Disable OSPF on this interface\n"
8043 "OSPF area ID in IP address format\n"
8044 "OSPF area ID as a decimal value\n"
8045 "Address of interface\n")
8047 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8050 struct ospf_if_params
*params
;
8051 u_short instance
= 0;
8052 struct in_addr addr
;
8054 if (argv_find(argv
, argc
, "(1-65535)", &idx
))
8055 instance
= strtol(argv
[idx
]->arg
, NULL
, 10);
8057 if (ifp
->vrf_id
&& !instance
)
8058 ospf
= ospf_lookup_by_vrf_id(ifp
->vrf_id
);
8060 ospf
= ospf_lookup_instance(instance
);
8063 return CMD_NOT_MY_INSTANCE
;
8065 argv_find(argv
, argc
, "area", &idx
);
8067 // Check if we have an address arg and proccess it
8068 if (argc
== idx
+ 3) {
8069 if (!inet_aton(argv
[idx
+ 2]->arg
, &addr
)) {
8070 vty_out(vty
, "Please specify Intf Address by A.B.C.D\n");
8071 return CMD_WARNING_CONFIG_FAILED
;
8073 params
= ospf_lookup_if_params(ifp
, addr
);
8074 if ((params
) == NULL
)
8077 params
= IF_DEF_PARAMS(ifp
);
8079 if (!OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
8081 "Can't find specified interface area configuration.\n");
8082 return CMD_WARNING_CONFIG_FAILED
;
8085 UNSET_IF_PARAM(params
, if_area
);
8086 if (params
!= IF_DEF_PARAMS((ifp
))) {
8087 ospf_free_if_params((ifp
), (addr
));
8088 ospf_if_update_params((ifp
), (addr
));
8091 ospf_interface_area_unset(ospf
, ifp
);
8092 ospf
->if_ospf_cli_count
--;
8096 DEFUN (ospf_redistribute_source
,
8097 ospf_redistribute_source_cmd
,
8098 "redistribute " FRR_REDIST_STR_OSPFD
" [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
8100 FRR_REDIST_HELP_STR_OSPFD
8101 "Metric for redistributed routes\n"
8102 "OSPF default metric\n"
8103 "OSPF exterior metric type for redistributed routes\n"
8104 "Set OSPF External Type 1/2 metrics\n"
8105 "Route map reference\n"
8106 "Pointer to route-map entries\n")
8108 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8109 int idx_protocol
= 1;
8113 struct ospf_redist
*red
;
8119 /* Get distribute source. */
8120 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
8122 return CMD_WARNING_CONFIG_FAILED
;
8124 red
= ospf_redist_add(ospf
, source
, 0);
8126 /* Get metric value. */
8127 if (argv_find(argv
, argc
, "(0-16777214)", &idx
)) {
8128 if (!str2metric(argv
[idx
]->arg
, &metric
))
8129 return CMD_WARNING_CONFIG_FAILED
;
8131 /* Get metric type. */
8132 else if (argv_find(argv
, argc
, "(1-2)", &idx
)) {
8133 if (!str2metric_type(argv
[idx
]->arg
, &type
))
8134 return CMD_WARNING_CONFIG_FAILED
;
8137 else if (argv_find(argv
, argc
, "WORD", &idx
)) {
8138 ospf_routemap_set(red
, argv
[idx
]->arg
);
8140 ospf_routemap_unset(red
);
8142 return ospf_redistribute_set(ospf
, source
, 0, type
, metric
);
8145 DEFUN (no_ospf_redistribute_source
,
8146 no_ospf_redistribute_source_cmd
,
8147 "no redistribute " FRR_REDIST_STR_OSPFD
" [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
8150 FRR_REDIST_HELP_STR_OSPFD
8151 "Metric for redistributed routes\n"
8152 "OSPF default metric\n"
8153 "OSPF exterior metric type for redistributed routes\n"
8154 "Set OSPF External Type 1/2 metrics\n"
8155 "Route map reference\n"
8156 "Pointer to route-map entries\n")
8158 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8159 int idx_protocol
= 2;
8161 struct ospf_redist
*red
;
8163 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
8165 return CMD_WARNING_CONFIG_FAILED
;
8167 red
= ospf_redist_lookup(ospf
, source
, 0);
8171 ospf_routemap_unset(red
);
8172 return ospf_redistribute_unset(ospf
, source
, 0);
8175 DEFUN (ospf_redistribute_instance_source
,
8176 ospf_redistribute_instance_source_cmd
,
8177 "redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
8179 "Open Shortest Path First\n"
8180 "Non-main Kernel Routing Table\n"
8181 "Instance ID/Table ID\n"
8182 "Metric for redistributed routes\n"
8183 "OSPF default metric\n"
8184 "OSPF exterior metric type for redistributed routes\n"
8185 "Set OSPF External Type 1/2 metrics\n"
8186 "Route map reference\n"
8187 "Pointer to route-map entries\n")
8189 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8190 int idx_ospf_table
= 1;
8197 struct ospf_redist
*red
;
8202 source
= proto_redistnum(AFI_IP
, argv
[idx_ospf_table
]->text
);
8204 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8209 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
) {
8211 "Instance redistribution in non-instanced OSPF not allowed\n");
8212 return CMD_WARNING_CONFIG_FAILED
;
8215 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
)) {
8216 vty_out(vty
, "Same instance OSPF redistribution not allowed\n");
8217 return CMD_WARNING_CONFIG_FAILED
;
8220 /* Get metric value. */
8221 if (argv_find(argv
, argc
, "metric", &idx
))
8222 if (!str2metric(argv
[idx
+ 1]->arg
, &metric
))
8223 return CMD_WARNING_CONFIG_FAILED
;
8226 /* Get metric type. */
8227 if (argv_find(argv
, argc
, "metric-type", &idx
))
8228 if (!str2metric_type(argv
[idx
+ 1]->arg
, &type
))
8229 return CMD_WARNING_CONFIG_FAILED
;
8231 red
= ospf_redist_add(ospf
, source
, instance
);
8234 if (argv_find(argv
, argc
, "route-map", &idx
))
8235 ospf_routemap_set(red
, argv
[idx
+ 1]->arg
);
8237 ospf_routemap_unset(red
);
8239 return ospf_redistribute_set(ospf
, source
, instance
, type
, metric
);
8242 DEFUN (no_ospf_redistribute_instance_source
,
8243 no_ospf_redistribute_instance_source_cmd
,
8244 "no redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
8247 "Open Shortest Path First\n"
8248 "Non-main Kernel Routing Table\n"
8249 "Instance ID/Table Id\n"
8250 "Metric for redistributed routes\n"
8251 "OSPF default metric\n"
8252 "OSPF exterior metric type for redistributed routes\n"
8253 "Set OSPF External Type 1/2 metrics\n"
8254 "Route map reference\n"
8255 "Pointer to route-map entries\n")
8257 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8258 int idx_ospf_table
= 2;
8261 struct ospf_redist
*red
;
8264 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
8265 source
= ZEBRA_ROUTE_OSPF
;
8267 source
= ZEBRA_ROUTE_TABLE
;
8269 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8271 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
) {
8273 "Instance redistribution in non-instanced OSPF not allowed\n");
8274 return CMD_WARNING_CONFIG_FAILED
;
8277 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
)) {
8278 vty_out(vty
, "Same instance OSPF redistribution not allowed\n");
8279 return CMD_WARNING_CONFIG_FAILED
;
8282 red
= ospf_redist_lookup(ospf
, source
, instance
);
8286 ospf_routemap_unset(red
);
8287 return ospf_redistribute_unset(ospf
, source
, instance
);
8290 DEFUN (ospf_distribute_list_out
,
8291 ospf_distribute_list_out_cmd
,
8292 "distribute-list WORD out " FRR_REDIST_STR_OSPFD
,
8293 "Filter networks in routing updates\n"
8294 "Access-list name\n"
8296 FRR_REDIST_HELP_STR_OSPFD
)
8298 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8302 char *proto
= argv
[argc
- 1]->text
;
8304 /* Get distribute source. */
8305 source
= proto_redistnum(AFI_IP
, proto
);
8307 return CMD_WARNING_CONFIG_FAILED
;
8309 return ospf_distribute_list_out_set(ospf
, source
, argv
[idx_word
]->arg
);
8312 DEFUN (no_ospf_distribute_list_out
,
8313 no_ospf_distribute_list_out_cmd
,
8314 "no distribute-list WORD out " FRR_REDIST_STR_OSPFD
,
8316 "Filter networks in routing updates\n"
8317 "Access-list name\n"
8319 FRR_REDIST_HELP_STR_OSPFD
)
8321 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8325 char *proto
= argv
[argc
- 1]->text
;
8326 source
= proto_redistnum(AFI_IP
, proto
);
8328 return CMD_WARNING_CONFIG_FAILED
;
8330 return ospf_distribute_list_out_unset(ospf
, source
,
8331 argv
[idx_word
]->arg
);
8334 /* Default information originate. */
8335 DEFUN (ospf_default_information_originate
,
8336 ospf_default_information_originate_cmd
,
8337 "default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
8338 "Control distribution of default information\n"
8339 "Distribute a default route\n"
8340 "Always advertise default route\n"
8341 "OSPF default metric\n"
8343 "OSPF metric type for default routes\n"
8344 "Set OSPF External Type 1/2 metrics\n"
8345 "Route map reference\n"
8346 "Pointer to route-map entries\n")
8348 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8349 int default_originate
= DEFAULT_ORIGINATE_ZEBRA
;
8352 struct ospf_redist
*red
;
8355 red
= ospf_redist_add(ospf
, DEFAULT_ROUTE
, 0);
8357 /* Check whether "always" was specified */
8358 if (argv_find(argv
, argc
, "always", &idx
))
8359 default_originate
= DEFAULT_ORIGINATE_ALWAYS
;
8360 /* Get metric value */
8361 else if (argv_find(argv
, argc
, "(0-16777214)", &idx
)) {
8362 if (!str2metric(argv
[idx
]->arg
, &metric
))
8363 return CMD_WARNING_CONFIG_FAILED
;
8365 /* Get metric type. */
8366 else if (argv_find(argv
, argc
, "(1-2)", &idx
)) {
8367 if (!str2metric_type(argv
[idx
]->arg
, &type
))
8368 return CMD_WARNING_CONFIG_FAILED
;
8371 else if (argv_find(argv
, argc
, "WORD", &idx
))
8372 ospf_routemap_set(red
, argv
[idx
]->arg
);
8374 ospf_routemap_unset(red
);
8376 return ospf_redistribute_default_set(ospf
, default_originate
, type
,
8380 DEFUN (no_ospf_default_information_originate
,
8381 no_ospf_default_information_originate_cmd
,
8382 "no default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
8384 "Control distribution of default information\n"
8385 "Distribute a default route\n"
8386 "Always advertise default route\n"
8387 "OSPF default metric\n"
8389 "OSPF metric type for default routes\n"
8390 "Set OSPF External Type 1/2 metrics\n"
8391 "Route map reference\n"
8392 "Pointer to route-map entries\n")
8394 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8395 struct prefix_ipv4 p
;
8396 struct ospf_external
*ext
;
8397 struct ospf_redist
*red
;
8400 p
.prefix
.s_addr
= 0;
8403 ospf_external_lsa_flush(ospf
, DEFAULT_ROUTE
, &p
, 0);
8405 ext
= ospf_external_lookup(ospf
, DEFAULT_ROUTE
, 0);
8406 if (ext
&& EXTERNAL_INFO(ext
)) {
8407 ospf_external_info_delete(ospf
, DEFAULT_ROUTE
, 0, p
);
8408 ospf_external_del(ospf
, DEFAULT_ROUTE
, 0);
8411 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
8415 ospf_routemap_unset(red
);
8416 return ospf_redistribute_default_unset(ospf
);
8419 DEFUN (ospf_default_metric
,
8420 ospf_default_metric_cmd
,
8421 "default-metric (0-16777214)",
8422 "Set metric of redistributed routes\n"
8425 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8429 if (!str2metric(argv
[idx_number
]->arg
, &metric
))
8430 return CMD_WARNING_CONFIG_FAILED
;
8432 ospf
->default_metric
= metric
;
8437 DEFUN (no_ospf_default_metric
,
8438 no_ospf_default_metric_cmd
,
8439 "no default-metric [(0-16777214)]",
8441 "Set metric of redistributed routes\n"
8444 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8446 ospf
->default_metric
= -1;
8452 DEFUN (ospf_distance
,
8455 "Administrative distance\n"
8456 "OSPF Administrative distance\n")
8458 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8461 ospf
->distance_all
= atoi(argv
[idx_number
]->arg
);
8466 DEFUN (no_ospf_distance
,
8467 no_ospf_distance_cmd
,
8468 "no distance (1-255)",
8470 "Administrative distance\n"
8471 "OSPF Administrative distance\n")
8473 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8475 ospf
->distance_all
= 0;
8480 DEFUN (no_ospf_distance_ospf
,
8481 no_ospf_distance_ospf_cmd
,
8482 "no distance ospf [{intra-area [(1-255)]|inter-area [(1-255)]|external [(1-255)]}]",
8484 "Administrative distance\n"
8485 "OSPF administrative distance\n"
8486 "Intra-area routes\n"
8487 "Distance for intra-area routes\n"
8488 "Inter-area routes\n"
8489 "Distance for inter-area routes\n"
8491 "Distance for external routes\n")
8493 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8499 if (argv_find(argv
, argc
, "intra-area", &idx
) || argc
== 3)
8500 idx
= ospf
->distance_intra
= 0;
8501 if (argv_find(argv
, argc
, "inter-area", &idx
) || argc
== 3)
8502 idx
= ospf
->distance_inter
= 0;
8503 if (argv_find(argv
, argc
, "external", &idx
) || argc
== 3)
8504 ospf
->distance_external
= 0;
8509 DEFUN (ospf_distance_ospf
,
8510 ospf_distance_ospf_cmd
,
8511 "distance ospf {intra-area (1-255)|inter-area (1-255)|external (1-255)}",
8512 "Administrative distance\n"
8513 "OSPF administrative distance\n"
8514 "Intra-area routes\n"
8515 "Distance for intra-area routes\n"
8516 "Inter-area routes\n"
8517 "Distance for inter-area routes\n"
8519 "Distance for external routes\n")
8521 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8524 if (argv_find(argv
, argc
, "intra-area", &idx
))
8525 ospf
->distance_intra
= atoi(argv
[idx
+ 1]->arg
);
8527 if (argv_find(argv
, argc
, "inter-area", &idx
))
8528 ospf
->distance_inter
= atoi(argv
[idx
+ 1]->arg
);
8530 if (argv_find(argv
, argc
, "external", &idx
))
8531 ospf
->distance_external
= atoi(argv
[idx
+ 1]->arg
);
8537 DEFUN (ospf_distance_source
,
8538 ospf_distance_source_cmd
,
8539 "distance (1-255) A.B.C.D/M",
8540 "Administrative distance\n"
8542 "IP source prefix\n")
8544 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
8546 int idx_ipv4_prefixlen
= 2;
8551 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
8556 DEFUN (no_ospf_distance_source
,
8557 no_ospf_distance_source_cmd
,
8558 "no distance (1-255) A.B.C.D/M",
8560 "Administrative distance\n"
8562 "IP source prefix\n")
8564 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
8566 int idx_ipv4_prefixlen
= 3;
8571 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
8576 DEFUN (ospf_distance_source_access_list
,
8577 ospf_distance_source_access_list_cmd
,
8578 "distance (1-255) A.B.C.D/M WORD",
8579 "Administrative distance\n"
8581 "IP source prefix\n"
8582 "Access list name\n")
8584 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
8586 int idx_ipv4_prefixlen
= 2;
8592 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
8597 DEFUN (no_ospf_distance_source_access_list
,
8598 no_ospf_distance_source_access_list_cmd
,
8599 "no distance (1-255) A.B.C.D/M WORD",
8601 "Administrative distance\n"
8603 "IP source prefix\n"
8604 "Access list name\n")
8606 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
8608 int idx_ipv4_prefixlen
= 3;
8614 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
8620 DEFUN (ip_ospf_mtu_ignore
,
8621 ip_ospf_mtu_ignore_addr_cmd
,
8622 "ip ospf mtu-ignore [A.B.C.D]",
8624 "OSPF interface commands\n"
8625 "Disable MTU mismatch detection on this interface\n"
8626 "Address of interface\n")
8628 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8630 struct in_addr addr
;
8633 struct ospf_if_params
*params
;
8634 params
= IF_DEF_PARAMS(ifp
);
8637 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
8640 "Please specify interface address by A.B.C.D\n");
8641 return CMD_WARNING_CONFIG_FAILED
;
8643 params
= ospf_get_if_params(ifp
, addr
);
8644 ospf_if_update_params(ifp
, addr
);
8646 params
->mtu_ignore
= 1;
8647 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
8648 SET_IF_PARAM(params
, mtu_ignore
);
8650 UNSET_IF_PARAM(params
, mtu_ignore
);
8651 if (params
!= IF_DEF_PARAMS(ifp
)) {
8652 ospf_free_if_params(ifp
, addr
);
8653 ospf_if_update_params(ifp
, addr
);
8659 DEFUN (no_ip_ospf_mtu_ignore
,
8660 no_ip_ospf_mtu_ignore_addr_cmd
,
8661 "no ip ospf mtu-ignore [A.B.C.D]",
8664 "OSPF interface commands\n"
8665 "Disable MTU mismatch detection on this interface\n"
8666 "Address of interface\n")
8668 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8670 struct in_addr addr
;
8673 struct ospf_if_params
*params
;
8674 params
= IF_DEF_PARAMS(ifp
);
8677 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
8680 "Please specify interface address by A.B.C.D\n");
8681 return CMD_WARNING_CONFIG_FAILED
;
8683 params
= ospf_get_if_params(ifp
, addr
);
8684 ospf_if_update_params(ifp
, addr
);
8686 params
->mtu_ignore
= 0;
8687 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
8688 SET_IF_PARAM(params
, mtu_ignore
);
8690 UNSET_IF_PARAM(params
, mtu_ignore
);
8691 if (params
!= IF_DEF_PARAMS(ifp
)) {
8692 ospf_free_if_params(ifp
, addr
);
8693 ospf_if_update_params(ifp
, addr
);
8700 DEFUN (ospf_max_metric_router_lsa_admin
,
8701 ospf_max_metric_router_lsa_admin_cmd
,
8702 "max-metric router-lsa administrative",
8703 "OSPF maximum / infinite-distance metric\n"
8704 "Advertise own Router-LSA with infinite distance (stub router)\n"
8705 "Administratively applied, for an indefinite period\n")
8707 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8708 struct listnode
*ln
;
8709 struct ospf_area
*area
;
8711 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
8712 SET_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
8714 if (!CHECK_FLAG(area
->stub_router_state
,
8715 OSPF_AREA_IS_STUB_ROUTED
))
8716 ospf_router_lsa_update_area(area
);
8719 /* Allows for areas configured later to get the property */
8720 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_SET
;
8725 DEFUN (no_ospf_max_metric_router_lsa_admin
,
8726 no_ospf_max_metric_router_lsa_admin_cmd
,
8727 "no max-metric router-lsa administrative",
8729 "OSPF maximum / infinite-distance metric\n"
8730 "Advertise own Router-LSA with infinite distance (stub router)\n"
8731 "Administratively applied, for an indefinite period\n")
8733 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8734 struct listnode
*ln
;
8735 struct ospf_area
*area
;
8737 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
8738 UNSET_FLAG(area
->stub_router_state
,
8739 OSPF_AREA_ADMIN_STUB_ROUTED
);
8741 /* Don't trample on the start-up stub timer */
8742 if (CHECK_FLAG(area
->stub_router_state
,
8743 OSPF_AREA_IS_STUB_ROUTED
)
8744 && !area
->t_stub_router
) {
8745 UNSET_FLAG(area
->stub_router_state
,
8746 OSPF_AREA_IS_STUB_ROUTED
);
8747 ospf_router_lsa_update_area(area
);
8750 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET
;
8754 DEFUN (ospf_max_metric_router_lsa_startup
,
8755 ospf_max_metric_router_lsa_startup_cmd
,
8756 "max-metric router-lsa on-startup (5-86400)",
8757 "OSPF maximum / infinite-distance metric\n"
8758 "Advertise own Router-LSA with infinite distance (stub router)\n"
8759 "Automatically advertise stub Router-LSA on startup of OSPF\n"
8760 "Time (seconds) to advertise self as stub-router\n")
8762 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8764 unsigned int seconds
;
8767 vty_out(vty
, "%% Must supply stub-router period");
8768 return CMD_WARNING_CONFIG_FAILED
;
8771 seconds
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8773 ospf
->stub_router_startup_time
= seconds
;
8778 DEFUN (no_ospf_max_metric_router_lsa_startup
,
8779 no_ospf_max_metric_router_lsa_startup_cmd
,
8780 "no max-metric router-lsa on-startup [(5-86400)]",
8782 "OSPF maximum / infinite-distance metric\n"
8783 "Advertise own Router-LSA with infinite distance (stub router)\n"
8784 "Automatically advertise stub Router-LSA on startup of OSPF\n"
8785 "Time (seconds) to advertise self as stub-router\n")
8787 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8788 struct listnode
*ln
;
8789 struct ospf_area
*area
;
8791 ospf
->stub_router_startup_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
8793 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
8794 SET_FLAG(area
->stub_router_state
,
8795 OSPF_AREA_WAS_START_STUB_ROUTED
);
8796 OSPF_TIMER_OFF(area
->t_stub_router
);
8798 /* Don't trample on admin stub routed */
8799 if (!CHECK_FLAG(area
->stub_router_state
,
8800 OSPF_AREA_ADMIN_STUB_ROUTED
)) {
8801 UNSET_FLAG(area
->stub_router_state
,
8802 OSPF_AREA_IS_STUB_ROUTED
);
8803 ospf_router_lsa_update_area(area
);
8810 DEFUN (ospf_max_metric_router_lsa_shutdown
,
8811 ospf_max_metric_router_lsa_shutdown_cmd
,
8812 "max-metric router-lsa on-shutdown (5-100)",
8813 "OSPF maximum / infinite-distance metric\n"
8814 "Advertise own Router-LSA with infinite distance (stub router)\n"
8815 "Advertise stub-router prior to full shutdown of OSPF\n"
8816 "Time (seconds) to wait till full shutdown\n")
8818 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8820 unsigned int seconds
;
8823 vty_out(vty
, "%% Must supply stub-router shutdown period");
8824 return CMD_WARNING_CONFIG_FAILED
;
8827 seconds
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8829 ospf
->stub_router_shutdown_time
= seconds
;
8834 DEFUN (no_ospf_max_metric_router_lsa_shutdown
,
8835 no_ospf_max_metric_router_lsa_shutdown_cmd
,
8836 "no max-metric router-lsa on-shutdown [(5-100)]",
8838 "OSPF maximum / infinite-distance metric\n"
8839 "Advertise own Router-LSA with infinite distance (stub router)\n"
8840 "Advertise stub-router prior to full shutdown of OSPF\n"
8841 "Time (seconds) to wait till full shutdown\n")
8843 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8845 ospf
->stub_router_shutdown_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
8850 static void config_write_stub_router(struct vty
*vty
, struct ospf
*ospf
)
8852 struct listnode
*ln
;
8853 struct ospf_area
*area
;
8855 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
8856 vty_out(vty
, " max-metric router-lsa on-startup %u\n",
8857 ospf
->stub_router_startup_time
);
8858 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
8859 vty_out(vty
, " max-metric router-lsa on-shutdown %u\n",
8860 ospf
->stub_router_shutdown_time
);
8861 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
8862 if (CHECK_FLAG(area
->stub_router_state
,
8863 OSPF_AREA_ADMIN_STUB_ROUTED
)) {
8864 vty_out(vty
, " max-metric router-lsa administrative\n");
8871 static void show_ip_ospf_route_network(struct vty
*vty
, struct ospf
*ospf
,
8872 struct route_table
*rt
,
8875 struct route_node
*rn
;
8876 struct ospf_route
* or ;
8877 struct listnode
*pnode
, *pnnode
;
8878 struct ospf_path
*path
;
8879 json_object
*json_route
= NULL
, *json_nexthop_array
= NULL
,
8880 *json_nexthop
= NULL
;
8883 vty_out(vty
, "============ OSPF network routing table ============\n");
8885 for (rn
= route_top(rt
); rn
; rn
= route_next(rn
)) {
8886 if ((or = rn
->info
) == NULL
)
8888 char buf1
[PREFIX2STR_BUFFER
];
8890 memset(buf1
, 0, sizeof(buf1
));
8891 prefix2str(&rn
->p
, buf1
, sizeof(buf1
));
8893 json_route
= json_object_new_object();
8895 json_object_object_add(json
, buf1
, json_route
);
8896 json_object_to_json_string_ext(json
,
8897 JSON_C_TO_STRING_NOSLASHESCAPE
);
8901 switch (or->path_type
) {
8902 case OSPF_PATH_INTER_AREA
:
8903 if (or->type
== OSPF_DESTINATION_NETWORK
) {
8905 json_object_string_add(json_route
,
8908 json_object_int_add(json_route
,
8911 json_object_string_add(
8915 or->u
.std
.area_id
));
8918 "N IA %-18s [%d] area: %s\n",
8920 inet_ntoa(or->u
.std
.area_id
));
8922 } else if (or->type
==
8923 OSPF_DESTINATION_DISCARD
) {
8925 json_object_string_add(json_route
,
8930 "D IA %-18s Discard entry\n",
8935 case OSPF_PATH_INTRA_AREA
:
8937 json_object_string_add(json_route
,
8939 json_object_int_add(json_route
, "cost",
8941 json_object_string_add(json_route
,
8942 "area", inet_ntoa(or->u
.std
.area_id
));
8944 vty_out(vty
, "N %-18s [%d] area: %s\n",
8946 inet_ntoa(or->u
.std
.area_id
));
8953 if (or->type
== OSPF_DESTINATION_NETWORK
) {
8955 json_nexthop_array
= json_object_new_array();
8956 json_object_object_add(json_route
, "nexthops",
8957 json_nexthop_array
);
8960 for (ALL_LIST_ELEMENTS(or->paths
, pnode
, pnnode
,
8964 json_object_new_object();
8965 json_object_array_add(json_nexthop_array
,
8968 if (if_lookup_by_index(path
->ifindex
,
8971 if (path
->nexthop
.s_addr
== 0) {
8973 json_object_string_add(
8977 json_object_string_add(
8979 "directly attached to",
8985 "%24s directly attached to %s\n",
8993 json_object_string_add(
8998 json_object_string_add(
9006 "%24s via %s, %s\n",
9019 json_object_free(json_route
);
9025 static void show_ip_ospf_route_router(struct vty
*vty
, struct ospf
*ospf
,
9026 struct route_table
*rtrs
,
9029 struct route_node
*rn
;
9030 struct ospf_route
* or ;
9031 struct listnode
*pnode
;
9032 struct listnode
*node
;
9033 struct ospf_path
*path
;
9034 json_object
*json_route
= NULL
, *json_nexthop_array
= NULL
,
9035 *json_nexthop
= NULL
;
9038 vty_out(vty
, "============ OSPF router routing table =============\n");
9040 for (rn
= route_top(rtrs
); rn
; rn
= route_next(rn
)) {
9041 if (rn
->info
== NULL
)
9045 json_route
= json_object_new_object();
9047 json_object_object_add(json
,
9048 inet_ntoa(rn
->p
.u
.prefix4
),
9050 json_object_string_add(json_route
, "routeType",
9053 vty_out(vty
, "R %-15s ",
9054 inet_ntoa(rn
->p
.u
.prefix4
));
9057 for (ALL_LIST_ELEMENTS_RO((struct list
*)rn
->info
, node
,
9061 vty_out(vty
, "%24s", "");
9066 json_object_int_add(json_route
, "cost",
9068 json_object_string_add(json_route
,
9070 inet_ntoa(or->u
.std
.area_id
));
9071 if (or->path_type
==
9072 OSPF_PATH_INTER_AREA
)
9073 json_object_boolean_true_add(
9076 if (or->u
.std
.flags
& ROUTER_LSA_BORDER
)
9077 json_object_string_add(
9081 else if (or->u
.std
.flags
&
9082 ROUTER_LSA_EXTERNAL
)
9083 json_object_string_add(
9088 vty_out(vty
, "%s [%d] area: %s",
9089 (or->path_type
== OSPF_PATH_INTER_AREA
9092 or->cost
, inet_ntoa(or->u
.std
.area_id
));
9094 vty_out(vty
, "%s%s\n",
9095 (or->u
.std
.flags
& ROUTER_LSA_BORDER
9098 (or->u
.std
.flags
& ROUTER_LSA_EXTERNAL
9104 json_nexthop_array
=
9105 json_object_new_array();
9106 json_object_object_add(json_route
, "nexthops",
9107 json_nexthop_array
);
9110 for (ALL_LIST_ELEMENTS_RO(or->paths
, pnode
,
9114 json_object_new_object();
9115 json_object_array_add(
9119 if (if_lookup_by_index(path
->ifindex
,
9121 if (path
->nexthop
.s_addr
== 0) {
9123 json_object_string_add(
9127 json_object_string_add(
9129 "directly attached to",
9135 "%24s directly attached to %s\n",
9143 json_object_string_add(
9146 inet_ntoa(path
->nexthop
));
9147 json_object_string_add(
9155 "%24s via %s, %s\n",
9168 json_object_free(json_route
);
9174 static void show_ip_ospf_route_external(struct vty
*vty
, struct ospf
*ospf
,
9175 struct route_table
*rt
,
9178 struct route_node
*rn
;
9179 struct ospf_route
*er
;
9180 struct listnode
*pnode
, *pnnode
;
9181 struct ospf_path
*path
;
9182 json_object
*json_route
= NULL
, *json_nexthop_array
= NULL
,
9183 *json_nexthop
= NULL
;
9186 vty_out(vty
, "============ OSPF external routing table ===========\n");
9188 for (rn
= route_top(rt
); rn
; rn
= route_next(rn
)) {
9189 if ((er
= rn
->info
) == NULL
)
9194 snprintf(buf1
, 19, "%s/%d", inet_ntoa(rn
->p
.u
.prefix4
),
9196 json_route
= json_object_new_object();
9198 json_object_object_add(json
, buf1
, json_route
);
9199 json_object_to_json_string_ext(json
,
9200 JSON_C_TO_STRING_NOSLASHESCAPE
);
9204 switch (er
->path_type
) {
9205 case OSPF_PATH_TYPE1_EXTERNAL
:
9207 json_object_string_add(json_route
,
9210 json_object_int_add(json_route
, "cost",
9214 "N E1 %-18s [%d] tag: %" ROUTE_TAG_PRI
9216 buf1
, er
->cost
, er
->u
.ext
.tag
);
9219 case OSPF_PATH_TYPE2_EXTERNAL
:
9221 json_object_string_add(json_route
,
9224 json_object_int_add(json_route
, "cost",
9228 "N E2 %-18s [%d/%d] tag: %"
9230 "\n", buf1
, er
->cost
,
9231 er
->u
.ext
.type2_cost
,
9238 json_nexthop_array
= json_object_new_array();
9239 json_object_object_add(json_route
, "nexthops",
9240 json_nexthop_array
);
9243 for (ALL_LIST_ELEMENTS(er
->paths
, pnode
, pnnode
,
9246 json_nexthop
= json_object_new_object();
9247 json_object_array_add(json_nexthop_array
9251 if (if_lookup_by_index(path
->ifindex
,
9253 if (path
->nexthop
.s_addr
== 0) {
9255 json_object_string_add(
9259 json_object_string_add(
9261 "directly attached to",
9267 "%24s directly attached to %s\n",
9275 json_object_string_add(
9280 json_object_string_add(
9288 "%24s via %s, %s\n",
9300 json_object_free(json_route
);
9306 static int show_ip_ospf_border_routers_common(struct vty
*vty
,
9311 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
9313 ospf_show_vrf_name(ospf
, vty
, NULL
, use_vrf
);
9315 if (ospf
->new_table
== NULL
) {
9316 vty_out(vty
, "No OSPF routing information exist\n");
9320 /* Show Network routes.
9321 show_ip_ospf_route_network (vty, ospf->new_table); */
9323 /* Show Router routes. */
9324 show_ip_ospf_route_router(vty
, ospf
, ospf
->new_rtrs
, NULL
);
9331 DEFUN (show_ip_ospf_border_routers
,
9332 show_ip_ospf_border_routers_cmd
,
9333 "show ip ospf [vrf <NAME|all>] border-routers",
9336 "OSPF information\n"
9339 "Show all the ABR's and ASBR's\n")
9341 struct ospf
*ospf
= NULL
;
9342 struct listnode
*node
= NULL
;
9343 char *vrf_name
= NULL
;
9344 bool all_vrf
= FALSE
;
9345 int ret
= CMD_SUCCESS
;
9350 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
9355 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
9356 if (!ospf
->oi_running
)
9359 ret
= show_ip_ospf_border_routers_common(vty
,
9364 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
9365 if (ospf
== NULL
|| !ospf
->oi_running
)
9368 ret
= show_ip_ospf_border_routers_common(vty
, ospf
,
9372 /* Display default ospf (instance 0) info */
9373 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
9374 if (ospf
== NULL
|| !ospf
->oi_running
)
9376 ret
= show_ip_ospf_border_routers_common(vty
, ospf
, use_vrf
);
9382 DEFUN (show_ip_ospf_instance_border_routers
,
9383 show_ip_ospf_instance_border_routers_cmd
,
9384 "show ip ospf (1-65535) border-routers",
9387 "OSPF information\n"
9389 "Show all the ABR's and ASBR's\n")
9393 u_short instance
= 0;
9395 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
9396 ospf
= ospf_lookup_instance(instance
);
9398 return CMD_NOT_MY_INSTANCE
;
9400 if (!ospf
->oi_running
)
9403 return show_ip_ospf_border_routers_common(vty
, ospf
, 0);
9406 static int show_ip_ospf_route_common(struct vty
*vty
, struct ospf
*ospf
,
9407 json_object
*json
, u_char use_vrf
)
9409 json_object
*json_vrf
= NULL
;
9412 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
9417 json_vrf
= json_object_new_object();
9422 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
9424 if (ospf
->new_table
== NULL
) {
9425 vty_out(vty
, "No OSPF routing information exist\n");
9429 /* Show Network routes. */
9430 show_ip_ospf_route_network(vty
, ospf
, ospf
->new_table
, json_vrf
);
9432 /* Show Router routes. */
9433 show_ip_ospf_route_router(vty
, ospf
, ospf
->new_rtrs
, json_vrf
);
9435 /* Show AS External routes. */
9436 show_ip_ospf_route_external(vty
, ospf
, ospf
->old_external_route
,
9441 //json_object_object_add(json_vrf, "areas", json_areas);
9442 if (ospf
->vrf_id
== VRF_DEFAULT
)
9443 json_object_object_add(json
, "default",
9446 json_object_object_add(json
, ospf
->name
,
9456 DEFUN (show_ip_ospf_route
,
9457 show_ip_ospf_route_cmd
,
9458 "show ip ospf [vrf <NAME|all>] route [json]",
9461 "OSPF information\n"
9464 "OSPF routing table\n"
9467 struct ospf
*ospf
= NULL
;
9468 struct listnode
*node
= NULL
;
9469 char *vrf_name
= NULL
;
9470 bool all_vrf
= FALSE
;
9471 int ret
= CMD_SUCCESS
;
9475 u_char uj
= use_json(argc
, argv
);
9476 json_object
*json
= NULL
;
9479 json
= json_object_new_object();
9481 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
9483 /* vrf input is provided could be all or specific vrf*/
9487 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
9488 if (!ospf
->oi_running
)
9490 ret
= show_ip_ospf_route_common(vty
, ospf
, json
,
9495 vty_out(vty
, "%s\n",
9496 json_object_to_json_string_ext(json
,
9497 JSON_C_TO_STRING_PRETTY
));
9498 json_object_free(json
);
9503 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
9504 if (ospf
== NULL
|| !ospf
->oi_running
) {
9506 json_object_free(json
);
9510 /* Display default ospf (instance 0) info */
9511 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
9512 if (ospf
== NULL
|| !ospf
->oi_running
) {
9514 json_object_free(json
);
9520 ret
= show_ip_ospf_route_common(vty
, ospf
, json
, use_vrf
);
9522 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
9523 json
, JSON_C_TO_STRING_PRETTY
));
9527 json_object_free(json
);
9532 DEFUN (show_ip_ospf_instance_route
,
9533 show_ip_ospf_instance_route_cmd
,
9534 "show ip ospf (1-65535) route",
9537 "OSPF information\n"
9539 "OSPF routing table\n")
9543 u_short instance
= 0;
9545 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
9546 ospf
= ospf_lookup_instance(instance
);
9548 return CMD_NOT_MY_INSTANCE
;
9550 if (!ospf
->oi_running
)
9553 return show_ip_ospf_route_common(vty
, ospf
, NULL
, 0);
9557 DEFUN (show_ip_ospf_vrfs
,
9558 show_ip_ospf_vrfs_cmd
,
9559 "show ip ospf vrfs [json]",
9562 "OSPF information\n"
9566 u_char uj
= use_json(argc
, argv
);
9567 json_object
*json
= NULL
;
9568 json_object
*json_vrfs
= NULL
;
9569 struct ospf
*ospf
= NULL
;
9570 struct listnode
*node
= NULL
;
9572 static char header
[] = "Name Id RouterId ";
9575 json
= json_object_new_object();
9576 json_vrfs
= json_object_new_object();
9579 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
9580 json_object
*json_vrf
= NULL
;
9581 const char *name
= NULL
;
9586 if (!uj
&& count
== 1)
9587 vty_out(vty
, "%s\n", header
);
9589 json_vrf
= json_object_new_object();
9591 if (ospf
->vrf_id
== 0)
9592 name
= VRF_DEFAULT_NAME
;
9596 vrf_id_ui
= (ospf
->vrf_id
== VRF_UNKNOWN
) ? -1 : ospf
->vrf_id
;
9599 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
9600 json_object_string_add(json_vrf
, "routerId",
9601 inet_ntoa(ospf
->router_id
));
9603 json_object_object_add(json_vrfs
, name
, json_vrf
);
9606 vty_out(vty
, "%-25s %-5d %-16s \n",
9607 name
, ospf
->vrf_id
, inet_ntoa(ospf
->router_id
));
9612 json_object_object_add(json
, "vrfs", json_vrfs
);
9613 json_object_int_add(json
, "totalVrfs", count
);
9615 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
9616 JSON_C_TO_STRING_PRETTY
));
9617 json_object_free(json
);
9620 vty_out(vty
, "\nTotal number of OSPF VRFs: %d\n",
9627 const char *ospf_abr_type_str
[] = {"unknown", "standard", "ibm", "cisco",
9630 const char *ospf_shortcut_mode_str
[] = {"default", "enable", "disable"};
9632 const char *ospf_int_type_str
[] = {"unknown", /* should never be used. */
9633 "point-to-point", "broadcast",
9634 "non-broadcast", "point-to-multipoint",
9635 "virtual-link", /* should never be used. */
9638 static int config_write_interface_one(struct vty
*vty
, struct vrf
*vrf
)
9640 struct listnode
*node
;
9641 struct interface
*ifp
;
9642 struct crypt_key
*ck
;
9643 struct route_node
*rn
= NULL
;
9644 struct ospf_if_params
*params
;
9646 struct ospf
*ospf
= vrf
->info
;
9648 FOR_ALL_INTERFACES (vrf
, ifp
) {
9650 if (memcmp(ifp
->name
, "VLINK", 5) == 0)
9653 vty_frame(vty
, "!\n");
9654 if (ifp
->vrf_id
== VRF_DEFAULT
)
9655 vty_frame(vty
, "interface %s\n", ifp
->name
);
9657 vty_frame(vty
, "interface %s vrf %s\n",
9658 ifp
->name
, vrf
->name
);
9660 vty_out(vty
, " description %s\n", ifp
->desc
);
9664 params
= IF_DEF_PARAMS(ifp
);
9667 /* Interface Network print. */
9668 if (OSPF_IF_PARAM_CONFIGURED(params
, type
)
9669 && params
->type
!= OSPF_IFTYPE_LOOPBACK
) {
9671 ospf_default_iftype(ifp
)) {
9672 vty_out(vty
, " ip ospf network %s",
9675 if (params
!= IF_DEF_PARAMS(ifp
))
9683 /* OSPF interface authentication print */
9684 if (OSPF_IF_PARAM_CONFIGURED(params
, auth_type
)
9685 && params
->auth_type
!= OSPF_AUTH_NOTSET
) {
9686 const char *auth_str
;
9688 /* Translation tables are not that much help
9689 * here due to syntax
9690 * of the simple option */
9691 switch (params
->auth_type
) {
9693 case OSPF_AUTH_NULL
:
9697 case OSPF_AUTH_SIMPLE
:
9701 case OSPF_AUTH_CRYPTOGRAPHIC
:
9702 auth_str
= " message-digest";
9710 vty_out(vty
, " ip ospf authentication%s",
9712 if (params
!= IF_DEF_PARAMS(ifp
))
9714 inet_ntoa(rn
->p
.u
.prefix4
));
9718 /* Simple Authentication Password print. */
9719 if (OSPF_IF_PARAM_CONFIGURED(params
, auth_simple
)
9720 && params
->auth_simple
[0] != '\0') {
9721 vty_out(vty
, " ip ospf authentication-key %s",
9722 params
->auth_simple
);
9723 if (params
!= IF_DEF_PARAMS(ifp
))
9725 inet_ntoa(rn
->p
.u
.prefix4
));
9729 /* Cryptographic Authentication Key print. */
9730 if (params
&& params
->auth_crypt
) {
9731 for (ALL_LIST_ELEMENTS_RO(
9735 " ip ospf message-digest-key %d md5 %s",
9738 if (params
!= IF_DEF_PARAMS(ifp
))
9740 inet_ntoa(rn
->p
.u
.prefix4
));
9745 /* Interface Output Cost print. */
9746 if (OSPF_IF_PARAM_CONFIGURED(params
,
9748 vty_out(vty
, " ip ospf cost %u",
9749 params
->output_cost_cmd
);
9750 if (params
!= IF_DEF_PARAMS(ifp
))
9752 inet_ntoa(rn
->p
.u
.prefix4
));
9756 /* Hello Interval print. */
9757 if (OSPF_IF_PARAM_CONFIGURED(params
, v_hello
)
9758 && params
->v_hello
!=
9759 OSPF_HELLO_INTERVAL_DEFAULT
) {
9760 vty_out(vty
, " ip ospf hello-interval %u",
9762 if (params
!= IF_DEF_PARAMS(ifp
))
9764 inet_ntoa(rn
->p
.u
.prefix4
));
9769 /* Router Dead Interval print. */
9770 if (OSPF_IF_PARAM_CONFIGURED(params
, v_wait
)
9772 != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
) {
9773 vty_out(vty
, " ip ospf dead-interval ");
9776 if (OSPF_IF_PARAM_CONFIGURED(params
,
9779 "minimal hello-multiplier %d",
9780 params
->fast_hello
);
9785 if (params
!= IF_DEF_PARAMS(ifp
))
9787 inet_ntoa(rn
->p
.u
.prefix4
));
9791 /* Router Priority print. */
9792 if (OSPF_IF_PARAM_CONFIGURED(params
, priority
)
9794 != OSPF_ROUTER_PRIORITY_DEFAULT
) {
9795 vty_out(vty
, " ip ospf priority %u",
9797 if (params
!= IF_DEF_PARAMS(ifp
))
9799 inet_ntoa(rn
->p
.u
.prefix4
));
9803 /* Retransmit Interval print. */
9804 if (OSPF_IF_PARAM_CONFIGURED(params
,
9805 retransmit_interval
)
9806 && params
->retransmit_interval
9807 != OSPF_RETRANSMIT_INTERVAL_DEFAULT
) {
9808 vty_out(vty
, " ip ospf retransmit-interval %u",
9809 params
->retransmit_interval
);
9810 if (params
!= IF_DEF_PARAMS(ifp
))
9812 inet_ntoa(rn
->p
.u
.prefix4
));
9816 /* Transmit Delay print. */
9817 if (OSPF_IF_PARAM_CONFIGURED(params
,
9819 && params
->transmit_delay
9820 != OSPF_TRANSMIT_DELAY_DEFAULT
) {
9821 vty_out(vty
, " ip ospf transmit-delay %u",
9822 params
->transmit_delay
);
9823 if (params
!= IF_DEF_PARAMS(ifp
))
9825 inet_ntoa(rn
->p
.u
.prefix4
));
9830 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
9831 if (ospf
&& ospf
->instance
)
9832 vty_out(vty
, " ip ospf %d",
9835 vty_out(vty
, " ip ospf");
9838 size_t buflen
= MAX(strlen("4294967295"),
9839 strlen("255.255.255.255"));
9842 area_id2str(buf
, sizeof(buf
),
9844 params
->if_area_id_fmt
);
9845 vty_out(vty
, " area %s", buf
);
9846 if (params
!= IF_DEF_PARAMS(ifp
))
9848 inet_ntoa(rn
->p
.u
.prefix4
));
9853 if (params
->bfd_info
)
9854 ospf_bfd_write_config(vty
, params
);
9856 /* MTU ignore print. */
9857 if (OSPF_IF_PARAM_CONFIGURED(params
, mtu_ignore
)
9858 && params
->mtu_ignore
!=
9859 OSPF_MTU_IGNORE_DEFAULT
) {
9860 if (params
->mtu_ignore
== 0)
9861 vty_out(vty
, " no ip ospf mtu-ignore");
9863 vty_out(vty
, " ip ospf mtu-ignore");
9864 if (params
!= IF_DEF_PARAMS(ifp
))
9866 inet_ntoa(rn
->p
.u
.prefix4
));
9874 IF_OIFS_PARAMS(ifp
));
9876 rn
= route_next(rn
);
9886 ospf_opaque_config_write_if(vty
, ifp
);
9888 vty_endframe(vty
, NULL
);
9894 /* Configuration write function for ospfd. */
9895 static int config_write_interface(struct vty
*vty
)
9898 struct vrf
*vrf
= NULL
;
9900 /* Display all VRF aware OSPF interface configuration */
9901 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
9902 write
+= config_write_interface_one(vty
, vrf
);
9908 static int config_write_network_area(struct vty
*vty
, struct ospf
*ospf
)
9910 struct route_node
*rn
;
9911 u_char buf
[INET_ADDRSTRLEN
];
9913 /* `network area' print. */
9914 for (rn
= route_top(ospf
->networks
); rn
; rn
= route_next(rn
))
9916 struct ospf_network
*n
= rn
->info
;
9918 memset(buf
, 0, INET_ADDRSTRLEN
);
9920 /* Create Area ID string by specified Area ID format. */
9921 if (n
->area_id_fmt
== OSPF_AREA_ID_FMT_DOTTEDQUAD
)
9922 strncpy((char *)buf
, inet_ntoa(n
->area_id
),
9925 sprintf((char *)buf
, "%lu",
9926 (unsigned long int)ntohl(
9927 n
->area_id
.s_addr
));
9929 /* Network print. */
9930 vty_out(vty
, " network %s/%d area %s\n",
9931 inet_ntoa(rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
9938 static int config_write_ospf_area(struct vty
*vty
, struct ospf
*ospf
)
9940 struct listnode
*node
;
9941 struct ospf_area
*area
;
9942 u_char buf
[INET_ADDRSTRLEN
];
9944 /* Area configuration print. */
9945 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
9946 struct route_node
*rn1
;
9948 area_id2str((char *)buf
, INET_ADDRSTRLEN
, &area
->area_id
,
9951 if (area
->auth_type
!= OSPF_AUTH_NULL
) {
9952 if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
9953 vty_out(vty
, " area %s authentication\n", buf
);
9956 " area %s authentication message-digest\n",
9960 if (area
->shortcut_configured
!= OSPF_SHORTCUT_DEFAULT
)
9961 vty_out(vty
, " area %s shortcut %s\n", buf
,
9962 ospf_shortcut_mode_str
9963 [area
->shortcut_configured
]);
9965 if ((area
->external_routing
== OSPF_AREA_STUB
)
9966 || (area
->external_routing
== OSPF_AREA_NSSA
)) {
9967 if (area
->external_routing
== OSPF_AREA_STUB
) {
9968 vty_out(vty
, " area %s stub", buf
);
9969 if (area
->no_summary
)
9970 vty_out(vty
, " no-summary\n");
9972 } else if (area
->external_routing
== OSPF_AREA_NSSA
) {
9973 switch (area
->NSSATranslatorRole
) {
9974 case OSPF_NSSA_ROLE_NEVER
:
9976 " area %s nssa translate-never\n",
9979 case OSPF_NSSA_ROLE_ALWAYS
:
9981 " area %s nssa translate-always\n",
9984 case OSPF_NSSA_ROLE_CANDIDATE
:
9985 vty_out(vty
, " area %s nssa \n", buf
);
9988 if (area
->no_summary
)
9990 " area %s nssa no-summary\n",
9994 if (area
->default_cost
!= 1)
9995 vty_out(vty
, " area %s default-cost %d\n", buf
,
9996 area
->default_cost
);
9999 for (rn1
= route_top(area
->ranges
); rn1
; rn1
= route_next(rn1
))
10001 struct ospf_area_range
*range
= rn1
->info
;
10003 vty_out(vty
, " area %s range %s/%d", buf
,
10004 inet_ntoa(rn1
->p
.u
.prefix4
),
10007 if (range
->cost_config
10008 != OSPF_AREA_RANGE_COST_UNSPEC
)
10009 vty_out(vty
, " cost %d",
10010 range
->cost_config
);
10012 if (!CHECK_FLAG(range
->flags
,
10013 OSPF_AREA_RANGE_ADVERTISE
))
10014 vty_out(vty
, " not-advertise");
10016 if (CHECK_FLAG(range
->flags
,
10017 OSPF_AREA_RANGE_SUBSTITUTE
))
10018 vty_out(vty
, " substitute %s/%d",
10019 inet_ntoa(range
->subst_addr
),
10020 range
->subst_masklen
);
10022 vty_out(vty
, "\n");
10025 if (EXPORT_NAME(area
))
10026 vty_out(vty
, " area %s export-list %s\n", buf
,
10027 EXPORT_NAME(area
));
10029 if (IMPORT_NAME(area
))
10030 vty_out(vty
, " area %s import-list %s\n", buf
,
10031 IMPORT_NAME(area
));
10033 if (PREFIX_NAME_IN(area
))
10034 vty_out(vty
, " area %s filter-list prefix %s in\n", buf
,
10035 PREFIX_NAME_IN(area
));
10037 if (PREFIX_NAME_OUT(area
))
10038 vty_out(vty
, " area %s filter-list prefix %s out\n",
10039 buf
, PREFIX_NAME_OUT(area
));
10045 static int config_write_ospf_nbr_nbma(struct vty
*vty
, struct ospf
*ospf
)
10047 struct ospf_nbr_nbma
*nbr_nbma
;
10048 struct route_node
*rn
;
10050 /* Static Neighbor configuration print. */
10051 for (rn
= route_top(ospf
->nbr_nbma
); rn
; rn
= route_next(rn
))
10052 if ((nbr_nbma
= rn
->info
)) {
10053 vty_out(vty
, " neighbor %s", inet_ntoa(nbr_nbma
->addr
));
10055 if (nbr_nbma
->priority
10056 != OSPF_NEIGHBOR_PRIORITY_DEFAULT
)
10057 vty_out(vty
, " priority %d",
10058 nbr_nbma
->priority
);
10060 if (nbr_nbma
->v_poll
!= OSPF_POLL_INTERVAL_DEFAULT
)
10061 vty_out(vty
, " poll-interval %d",
10064 vty_out(vty
, "\n");
10070 static int config_write_virtual_link(struct vty
*vty
, struct ospf
*ospf
)
10072 struct listnode
*node
;
10073 struct ospf_vl_data
*vl_data
;
10074 char buf
[INET_ADDRSTRLEN
];
10076 /* Virtual-Link print */
10077 for (ALL_LIST_ELEMENTS_RO(ospf
->vlinks
, node
, vl_data
)) {
10078 struct listnode
*n2
;
10079 struct crypt_key
*ck
;
10080 struct ospf_interface
*oi
;
10082 if (vl_data
!= NULL
) {
10083 memset(buf
, 0, INET_ADDRSTRLEN
);
10085 area_id2str(buf
, sizeof(buf
), &vl_data
->vl_area_id
,
10086 vl_data
->vl_area_id_fmt
);
10087 oi
= vl_data
->vl_oi
;
10090 if (OSPF_IF_PARAM(oi
, v_hello
)
10091 != OSPF_HELLO_INTERVAL_DEFAULT
10092 || OSPF_IF_PARAM(oi
, v_wait
)
10093 != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
10094 || OSPF_IF_PARAM(oi
, retransmit_interval
)
10095 != OSPF_RETRANSMIT_INTERVAL_DEFAULT
10096 || OSPF_IF_PARAM(oi
, transmit_delay
)
10097 != OSPF_TRANSMIT_DELAY_DEFAULT
)
10099 " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d\n",
10100 buf
, inet_ntoa(vl_data
->vl_peer
),
10101 OSPF_IF_PARAM(oi
, v_hello
),
10102 OSPF_IF_PARAM(oi
, retransmit_interval
),
10103 OSPF_IF_PARAM(oi
, transmit_delay
),
10104 OSPF_IF_PARAM(oi
, v_wait
));
10106 vty_out(vty
, " area %s virtual-link %s\n", buf
,
10107 inet_ntoa(vl_data
->vl_peer
));
10109 if (IF_DEF_PARAMS(vl_data
->vl_oi
->ifp
)->auth_simple
[0]
10112 " area %s virtual-link %s authentication-key %s\n",
10113 buf
, inet_ntoa(vl_data
->vl_peer
),
10114 IF_DEF_PARAMS(vl_data
->vl_oi
->ifp
)
10117 for (ALL_LIST_ELEMENTS_RO(
10118 IF_DEF_PARAMS(vl_data
->vl_oi
->ifp
)
10122 " area %s virtual-link %s"
10123 " message-digest-key %d md5 %s\n",
10124 buf
, inet_ntoa(vl_data
->vl_peer
),
10125 ck
->key_id
, ck
->auth_key
);
10133 static int config_write_ospf_redistribute(struct vty
*vty
, struct ospf
*ospf
)
10137 /* redistribute print. */
10138 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++) {
10139 struct list
*red_list
;
10140 struct listnode
*node
;
10141 struct ospf_redist
*red
;
10143 red_list
= ospf
->redist
[type
];
10147 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
10148 vty_out(vty
, " redistribute %s",
10149 zebra_route_string(type
));
10151 vty_out(vty
, " %d", red
->instance
);
10153 if (red
->dmetric
.value
>= 0)
10154 vty_out(vty
, " metric %d", red
->dmetric
.value
);
10156 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
10157 vty_out(vty
, " metric-type 1");
10159 if (ROUTEMAP_NAME(red
))
10160 vty_out(vty
, " route-map %s",
10161 ROUTEMAP_NAME(red
));
10163 vty_out(vty
, "\n");
10170 static int config_write_ospf_default_metric(struct vty
*vty
, struct ospf
*ospf
)
10172 if (ospf
->default_metric
!= -1)
10173 vty_out(vty
, " default-metric %d\n", ospf
->default_metric
);
10177 static int config_write_ospf_distribute(struct vty
*vty
, struct ospf
*ospf
)
10180 struct ospf_redist
*red
;
10183 /* distribute-list print. */
10184 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
10185 if (DISTRIBUTE_NAME(ospf
, type
))
10186 vty_out(vty
, " distribute-list %s out %s\n",
10187 DISTRIBUTE_NAME(ospf
, type
),
10188 zebra_route_string(type
));
10190 /* default-information print. */
10191 if (ospf
->default_originate
!= DEFAULT_ORIGINATE_NONE
) {
10192 vty_out(vty
, " default-information originate");
10193 if (ospf
->default_originate
== DEFAULT_ORIGINATE_ALWAYS
)
10194 vty_out(vty
, " always");
10196 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
10198 if (red
->dmetric
.value
>= 0)
10199 vty_out(vty
, " metric %d",
10200 red
->dmetric
.value
);
10201 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
10202 vty_out(vty
, " metric-type 1");
10204 if (ROUTEMAP_NAME(red
))
10205 vty_out(vty
, " route-map %s",
10206 ROUTEMAP_NAME(red
));
10209 vty_out(vty
, "\n");
10216 static int config_write_ospf_distance(struct vty
*vty
, struct ospf
*ospf
)
10218 struct route_node
*rn
;
10219 struct ospf_distance
*odistance
;
10221 if (ospf
->distance_all
)
10222 vty_out(vty
, " distance %d\n", ospf
->distance_all
);
10224 if (ospf
->distance_intra
|| ospf
->distance_inter
10225 || ospf
->distance_external
) {
10226 vty_out(vty
, " distance ospf");
10228 if (ospf
->distance_intra
)
10229 vty_out(vty
, " intra-area %d", ospf
->distance_intra
);
10230 if (ospf
->distance_inter
)
10231 vty_out(vty
, " inter-area %d", ospf
->distance_inter
);
10232 if (ospf
->distance_external
)
10233 vty_out(vty
, " external %d", ospf
->distance_external
);
10235 vty_out(vty
, "\n");
10238 for (rn
= route_top(ospf
->distance_table
); rn
; rn
= route_next(rn
))
10239 if ((odistance
= rn
->info
) != NULL
) {
10240 vty_out(vty
, " distance %d %s/%d %s\n",
10241 odistance
->distance
, inet_ntoa(rn
->p
.u
.prefix4
),
10243 odistance
->access_list
? odistance
->access_list
10249 static int ospf_config_write_one(struct vty
*vty
, struct ospf
*ospf
)
10251 struct vrf
*vrf
= vrf_lookup_by_id(ospf
->vrf_id
);
10252 struct interface
*ifp
;
10253 struct ospf_interface
*oi
;
10254 struct listnode
*node
= NULL
;
10257 /* `router ospf' print. */
10258 if (ospf
->instance
&& ospf
->name
) {
10259 vty_out(vty
, "router ospf %d vrf %s\n",
10260 ospf
->instance
, ospf
->name
);
10261 } else if (ospf
->instance
) {
10262 vty_out(vty
, "router ospf %d\n",
10264 } else if (ospf
->name
) {
10265 vty_out(vty
, "router ospf vrf %s\n",
10268 vty_out(vty
, "router ospf\n");
10270 if (!ospf
->networks
) {
10275 /* Router ID print. */
10276 if (ospf
->router_id_static
.s_addr
!= 0)
10277 vty_out(vty
, " ospf router-id %s\n",
10278 inet_ntoa(ospf
->router_id_static
));
10280 /* ABR type print. */
10281 if (ospf
->abr_type
!= OSPF_ABR_DEFAULT
)
10282 vty_out(vty
, " ospf abr-type %s\n",
10283 ospf_abr_type_str
[ospf
->abr_type
]);
10285 /* log-adjacency-changes flag print. */
10286 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
)) {
10287 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
10288 vty_out(vty
, " log-adjacency-changes detail\n");
10289 else if (!DFLT_OSPF_LOG_ADJACENCY_CHANGES
)
10290 vty_out(vty
, " log-adjacency-changes\n");
10291 } else if (DFLT_OSPF_LOG_ADJACENCY_CHANGES
) {
10292 vty_out(vty
, " no log-adjacency-changes\n");
10295 /* RFC1583 compatibility flag print -- Compatible with CISCO
10297 if (CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
10298 vty_out(vty
, " compatible rfc1583\n");
10300 /* auto-cost reference-bandwidth configuration. */
10301 if (ospf
->ref_bandwidth
!= OSPF_DEFAULT_REF_BANDWIDTH
) {
10303 "! Important: ensure reference bandwidth "
10304 "is consistent across all routers\n");
10305 vty_out(vty
, " auto-cost reference-bandwidth %d\n",
10306 ospf
->ref_bandwidth
);
10309 /* SPF timers print. */
10310 if (ospf
->spf_delay
!= OSPF_SPF_DELAY_DEFAULT
10311 || ospf
->spf_holdtime
!= OSPF_SPF_HOLDTIME_DEFAULT
10312 || ospf
->spf_max_holdtime
!= OSPF_SPF_MAX_HOLDTIME_DEFAULT
)
10313 vty_out(vty
, " timers throttle spf %d %d %d\n",
10314 ospf
->spf_delay
, ospf
->spf_holdtime
,
10315 ospf
->spf_max_holdtime
);
10317 /* LSA timers print. */
10318 if (ospf
->min_ls_interval
!= OSPF_MIN_LS_INTERVAL
)
10319 vty_out(vty
, " timers throttle lsa all %d\n",
10320 ospf
->min_ls_interval
);
10321 if (ospf
->min_ls_arrival
!= OSPF_MIN_LS_ARRIVAL
)
10322 vty_out(vty
, " timers lsa min-arrival %d\n",
10323 ospf
->min_ls_arrival
);
10325 /* Write multiplier print. */
10326 if (ospf
->write_oi_count
!= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
)
10327 vty_out(vty
, " ospf write-multiplier %d\n",
10328 ospf
->write_oi_count
);
10330 /* Max-metric router-lsa print */
10331 config_write_stub_router(vty
, ospf
);
10333 /* SPF refresh parameters print. */
10334 if (ospf
->lsa_refresh_interval
10335 != OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
10336 vty_out(vty
, " refresh timer %d\n",
10337 ospf
->lsa_refresh_interval
);
10339 /* Redistribute information print. */
10340 config_write_ospf_redistribute(vty
, ospf
);
10342 /* passive-interface print. */
10343 if (ospf
->passive_interface_default
== OSPF_IF_PASSIVE
)
10344 vty_out(vty
, " passive-interface default\n");
10346 FOR_ALL_INTERFACES (vrf
, ifp
)
10347 if (OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp
),
10349 && IF_DEF_PARAMS(ifp
)->passive_interface
10350 != ospf
->passive_interface_default
) {
10351 vty_out(vty
, " %spassive-interface %s\n",
10352 IF_DEF_PARAMS(ifp
)->passive_interface
10357 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
10358 if (!OSPF_IF_PARAM_CONFIGURED(oi
->params
,
10359 passive_interface
))
10361 if (OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(oi
->ifp
),
10362 passive_interface
)) {
10363 if (oi
->params
->passive_interface
10364 == IF_DEF_PARAMS(oi
->ifp
)
10365 ->passive_interface
)
10367 } else if (oi
->params
->passive_interface
10368 == ospf
->passive_interface_default
)
10371 vty_out(vty
, " %spassive-interface %s %s\n",
10372 oi
->params
->passive_interface
? "" : "no ",
10374 inet_ntoa(oi
->address
->u
.prefix4
));
10377 /* Network area print. */
10378 config_write_network_area(vty
, ospf
);
10380 /* Area config print. */
10381 config_write_ospf_area(vty
, ospf
);
10383 /* static neighbor print. */
10384 config_write_ospf_nbr_nbma(vty
, ospf
);
10386 /* Virtual-Link print. */
10387 config_write_virtual_link(vty
, ospf
);
10389 /* Default metric configuration. */
10390 config_write_ospf_default_metric(vty
, ospf
);
10392 /* Distribute-list and default-information print. */
10393 config_write_ospf_distribute(vty
, ospf
);
10395 /* Distance configuration. */
10396 config_write_ospf_distance(vty
, ospf
);
10398 ospf_opaque_config_write_router(vty
, ospf
);
10404 /* OSPF configuration write function. */
10405 static int ospf_config_write(struct vty
*vty
)
10408 struct listnode
*ospf_node
= NULL
;
10411 if (listcount(om
->ospf
) == 0)
10414 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, ospf_node
, ospf
)) {
10415 /* VRF Default check if it is running.
10416 * Upon daemon start, there could be default instance
10417 * in absence of 'router ospf'/oi_running is disabled. */
10418 if (ospf
->vrf_id
== VRF_DEFAULT
&& ospf
->oi_running
)
10419 write
+= ospf_config_write_one(vty
, ospf
);
10420 /* For Non-Default VRF simply display the configuration,
10421 * even if it is not oi_running. */
10422 else if (ospf
->vrf_id
!= VRF_DEFAULT
)
10423 write
+= ospf_config_write_one(vty
, ospf
);
10428 void ospf_vty_show_init(void)
10430 /* "show ip ospf" commands. */
10431 install_element(VIEW_NODE
, &show_ip_ospf_cmd
);
10433 install_element(VIEW_NODE
, &show_ip_ospf_instance_cmd
);
10435 /* "show ip ospf database" commands. */
10436 install_element(VIEW_NODE
, &show_ip_ospf_database_max_cmd
);
10438 install_element(VIEW_NODE
,
10439 &show_ip_ospf_instance_database_type_adv_router_cmd
);
10440 install_element(VIEW_NODE
, &show_ip_ospf_instance_database_cmd
);
10441 install_element(VIEW_NODE
, &show_ip_ospf_instance_database_max_cmd
);
10443 /* "show ip ospf interface" commands. */
10444 install_element(VIEW_NODE
, &show_ip_ospf_interface_cmd
);
10446 install_element(VIEW_NODE
, &show_ip_ospf_instance_interface_cmd
);
10447 /* "show ip ospf interface traffic */
10448 install_element(VIEW_NODE
, &show_ip_ospf_interface_traffic_cmd
);
10450 /* "show ip ospf neighbor" commands. */
10451 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_int_detail_cmd
);
10452 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_int_cmd
);
10453 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_id_cmd
);
10454 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_detail_all_cmd
);
10455 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_detail_cmd
);
10456 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_cmd
);
10457 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_all_cmd
);
10459 install_element(VIEW_NODE
,
10460 &show_ip_ospf_instance_neighbor_int_detail_cmd
);
10461 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_cmd
);
10462 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_id_cmd
);
10463 install_element(VIEW_NODE
,
10464 &show_ip_ospf_instance_neighbor_detail_all_cmd
);
10465 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_cmd
);
10466 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_cmd
);
10467 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_all_cmd
);
10469 /* "show ip ospf route" commands. */
10470 install_element(VIEW_NODE
, &show_ip_ospf_route_cmd
);
10471 install_element(VIEW_NODE
, &show_ip_ospf_border_routers_cmd
);
10473 install_element(VIEW_NODE
, &show_ip_ospf_instance_route_cmd
);
10474 install_element(VIEW_NODE
, &show_ip_ospf_instance_border_routers_cmd
);
10476 /* "show ip ospf vrfs" commands. */
10477 install_element(VIEW_NODE
, &show_ip_ospf_vrfs_cmd
);
10481 /* ospfd's interface node. */
10482 static struct cmd_node interface_node
= {INTERFACE_NODE
, "%s(config-if)# ", 1};
10484 /* Initialization of OSPF interface. */
10485 static void ospf_vty_if_init(void)
10487 /* Install interface node. */
10488 install_node(&interface_node
, config_write_interface
);
10491 /* "ip ospf authentication" commands. */
10492 install_element(INTERFACE_NODE
, &ip_ospf_authentication_args_addr_cmd
);
10493 install_element(INTERFACE_NODE
, &ip_ospf_authentication_addr_cmd
);
10494 install_element(INTERFACE_NODE
,
10495 &no_ip_ospf_authentication_args_addr_cmd
);
10496 install_element(INTERFACE_NODE
, &no_ip_ospf_authentication_addr_cmd
);
10497 install_element(INTERFACE_NODE
, &ip_ospf_authentication_key_addr_cmd
);
10498 install_element(INTERFACE_NODE
,
10499 &no_ip_ospf_authentication_key_authkey_addr_cmd
);
10500 install_element(INTERFACE_NODE
,
10501 &no_ospf_authentication_key_authkey_addr_cmd
);
10503 /* "ip ospf message-digest-key" commands. */
10504 install_element(INTERFACE_NODE
, &ip_ospf_message_digest_key_cmd
);
10505 install_element(INTERFACE_NODE
, &no_ip_ospf_message_digest_key_cmd
);
10507 /* "ip ospf cost" commands. */
10508 install_element(INTERFACE_NODE
, &ip_ospf_cost_cmd
);
10509 install_element(INTERFACE_NODE
, &no_ip_ospf_cost_cmd
);
10511 /* "ip ospf mtu-ignore" commands. */
10512 install_element(INTERFACE_NODE
, &ip_ospf_mtu_ignore_addr_cmd
);
10513 install_element(INTERFACE_NODE
, &no_ip_ospf_mtu_ignore_addr_cmd
);
10515 /* "ip ospf dead-interval" commands. */
10516 install_element(INTERFACE_NODE
, &ip_ospf_dead_interval_cmd
);
10517 install_element(INTERFACE_NODE
,
10518 &ip_ospf_dead_interval_minimal_addr_cmd
);
10519 install_element(INTERFACE_NODE
, &no_ip_ospf_dead_interval_cmd
);
10521 /* "ip ospf hello-interval" commands. */
10522 install_element(INTERFACE_NODE
, &ip_ospf_hello_interval_cmd
);
10523 install_element(INTERFACE_NODE
, &no_ip_ospf_hello_interval_cmd
);
10525 /* "ip ospf network" commands. */
10526 install_element(INTERFACE_NODE
, &ip_ospf_network_cmd
);
10527 install_element(INTERFACE_NODE
, &no_ip_ospf_network_cmd
);
10529 /* "ip ospf priority" commands. */
10530 install_element(INTERFACE_NODE
, &ip_ospf_priority_cmd
);
10531 install_element(INTERFACE_NODE
, &no_ip_ospf_priority_cmd
);
10533 /* "ip ospf retransmit-interval" commands. */
10534 install_element(INTERFACE_NODE
, &ip_ospf_retransmit_interval_addr_cmd
);
10535 install_element(INTERFACE_NODE
,
10536 &no_ip_ospf_retransmit_interval_addr_cmd
);
10538 /* "ip ospf transmit-delay" commands. */
10539 install_element(INTERFACE_NODE
, &ip_ospf_transmit_delay_addr_cmd
);
10540 install_element(INTERFACE_NODE
, &no_ip_ospf_transmit_delay_addr_cmd
);
10542 /* "ip ospf area" commands. */
10543 install_element(INTERFACE_NODE
, &ip_ospf_area_cmd
);
10544 install_element(INTERFACE_NODE
, &no_ip_ospf_area_cmd
);
10546 /* These commands are compatibitliy for previous version. */
10547 install_element(INTERFACE_NODE
, &ospf_authentication_key_cmd
);
10548 install_element(INTERFACE_NODE
, &ospf_message_digest_key_cmd
);
10549 install_element(INTERFACE_NODE
, &no_ospf_message_digest_key_cmd
);
10550 install_element(INTERFACE_NODE
, &ospf_dead_interval_cmd
);
10551 install_element(INTERFACE_NODE
, &no_ospf_dead_interval_cmd
);
10552 install_element(INTERFACE_NODE
, &ospf_hello_interval_cmd
);
10553 install_element(INTERFACE_NODE
, &no_ospf_hello_interval_cmd
);
10554 install_element(INTERFACE_NODE
, &ospf_cost_cmd
);
10555 install_element(INTERFACE_NODE
, &no_ospf_cost_cmd
);
10556 install_element(INTERFACE_NODE
, &ospf_network_cmd
);
10557 install_element(INTERFACE_NODE
, &no_ospf_network_cmd
);
10558 install_element(INTERFACE_NODE
, &ospf_priority_cmd
);
10559 install_element(INTERFACE_NODE
, &no_ospf_priority_cmd
);
10560 install_element(INTERFACE_NODE
, &ospf_retransmit_interval_cmd
);
10561 install_element(INTERFACE_NODE
, &no_ospf_retransmit_interval_cmd
);
10562 install_element(INTERFACE_NODE
, &ospf_transmit_delay_cmd
);
10563 install_element(INTERFACE_NODE
, &no_ospf_transmit_delay_cmd
);
10566 static void ospf_vty_zebra_init(void)
10568 install_element(OSPF_NODE
, &ospf_redistribute_source_cmd
);
10569 install_element(OSPF_NODE
, &no_ospf_redistribute_source_cmd
);
10570 install_element(OSPF_NODE
, &ospf_redistribute_instance_source_cmd
);
10571 install_element(OSPF_NODE
, &no_ospf_redistribute_instance_source_cmd
);
10573 install_element(OSPF_NODE
, &ospf_distribute_list_out_cmd
);
10574 install_element(OSPF_NODE
, &no_ospf_distribute_list_out_cmd
);
10576 install_element(OSPF_NODE
, &ospf_default_information_originate_cmd
);
10577 install_element(OSPF_NODE
, &no_ospf_default_information_originate_cmd
);
10579 install_element(OSPF_NODE
, &ospf_default_metric_cmd
);
10580 install_element(OSPF_NODE
, &no_ospf_default_metric_cmd
);
10582 install_element(OSPF_NODE
, &ospf_distance_cmd
);
10583 install_element(OSPF_NODE
, &no_ospf_distance_cmd
);
10584 install_element(OSPF_NODE
, &no_ospf_distance_ospf_cmd
);
10585 install_element(OSPF_NODE
, &ospf_distance_ospf_cmd
);
10587 install_element (OSPF_NODE
, &ospf_distance_source_cmd
);
10588 install_element (OSPF_NODE
, &no_ospf_distance_source_cmd
);
10589 install_element (OSPF_NODE
, &ospf_distance_source_access_list_cmd
);
10590 install_element (OSPF_NODE
, &no_ospf_distance_source_access_list_cmd
);
10594 static struct cmd_node ospf_node
= {OSPF_NODE
, "%s(config-router)# ", 1};
10596 static void ospf_interface_clear(struct interface
*ifp
)
10598 if (!if_is_operative(ifp
))
10601 if (IS_DEBUG_OSPF(ism
, ISM_EVENTS
))
10602 zlog_debug("ISM[%s]: clear by reset", ifp
->name
);
10604 ospf_if_reset(ifp
);
10607 DEFUN (clear_ip_ospf_interface
,
10608 clear_ip_ospf_interface_cmd
,
10609 "clear ip ospf interface [IFNAME]",
10612 "OSPF information\n"
10613 "Interface information\n"
10614 "Interface name\n")
10616 int idx_ifname
= 4;
10617 struct interface
*ifp
;
10618 struct listnode
*node
;
10619 struct ospf
*ospf
= NULL
;
10621 if (argc
== 4) /* Clear all the ospfv2 interfaces. */
10623 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
10624 struct vrf
*vrf
= vrf_lookup_by_id(ospf
->vrf_id
);
10625 FOR_ALL_INTERFACES (vrf
, ifp
)
10626 ospf_interface_clear(ifp
);
10629 /* Interface name is specified. */
10630 ifp
= if_lookup_by_name_all_vrf(argv
[idx_ifname
]->arg
);
10632 vty_out(vty
, "No such interface name\n");
10634 ospf_interface_clear(ifp
);
10637 return CMD_SUCCESS
;
10640 void ospf_vty_clear_init(void)
10642 install_element(ENABLE_NODE
, &clear_ip_ospf_interface_cmd
);
10646 /* Install OSPF related vty commands. */
10647 void ospf_vty_init(void)
10649 /* Install ospf top node. */
10650 install_node(&ospf_node
, ospf_config_write
);
10652 /* "router ospf" commands. */
10653 install_element(CONFIG_NODE
, &router_ospf_cmd
);
10654 install_element(CONFIG_NODE
, &no_router_ospf_cmd
);
10657 install_default(OSPF_NODE
);
10659 /* "ospf router-id" commands. */
10660 install_element(OSPF_NODE
, &ospf_router_id_cmd
);
10661 install_element(OSPF_NODE
, &ospf_router_id_old_cmd
);
10662 install_element(OSPF_NODE
, &no_ospf_router_id_cmd
);
10664 /* "passive-interface" commands. */
10665 install_element(OSPF_NODE
, &ospf_passive_interface_addr_cmd
);
10666 install_element(OSPF_NODE
, &no_ospf_passive_interface_addr_cmd
);
10668 /* "ospf abr-type" commands. */
10669 install_element(OSPF_NODE
, &ospf_abr_type_cmd
);
10670 install_element(OSPF_NODE
, &no_ospf_abr_type_cmd
);
10672 /* "ospf log-adjacency-changes" commands. */
10673 install_element(OSPF_NODE
, &ospf_log_adjacency_changes_cmd
);
10674 install_element(OSPF_NODE
, &ospf_log_adjacency_changes_detail_cmd
);
10675 install_element(OSPF_NODE
, &no_ospf_log_adjacency_changes_cmd
);
10676 install_element(OSPF_NODE
, &no_ospf_log_adjacency_changes_detail_cmd
);
10678 /* "ospf rfc1583-compatible" commands. */
10679 install_element(OSPF_NODE
, &ospf_compatible_rfc1583_cmd
);
10680 install_element(OSPF_NODE
, &no_ospf_compatible_rfc1583_cmd
);
10681 install_element(OSPF_NODE
, &ospf_rfc1583_flag_cmd
);
10682 install_element(OSPF_NODE
, &no_ospf_rfc1583_flag_cmd
);
10684 /* "network area" commands. */
10685 install_element(OSPF_NODE
, &ospf_network_area_cmd
);
10686 install_element(OSPF_NODE
, &no_ospf_network_area_cmd
);
10688 /* "area authentication" commands. */
10689 install_element(OSPF_NODE
,
10690 &ospf_area_authentication_message_digest_cmd
);
10691 install_element(OSPF_NODE
, &ospf_area_authentication_cmd
);
10692 install_element(OSPF_NODE
, &no_ospf_area_authentication_cmd
);
10694 /* "area range" commands. */
10695 install_element(OSPF_NODE
, &ospf_area_range_cmd
);
10696 install_element(OSPF_NODE
, &ospf_area_range_cost_cmd
);
10697 install_element(OSPF_NODE
, &ospf_area_range_not_advertise_cmd
);
10698 install_element(OSPF_NODE
, &no_ospf_area_range_cmd
);
10699 install_element(OSPF_NODE
, &ospf_area_range_substitute_cmd
);
10700 install_element(OSPF_NODE
, &no_ospf_area_range_substitute_cmd
);
10702 /* "area virtual-link" commands. */
10703 install_element(OSPF_NODE
, &ospf_area_vlink_cmd
);
10704 install_element(OSPF_NODE
, &ospf_area_vlink_intervals_cmd
);
10705 install_element(OSPF_NODE
, &no_ospf_area_vlink_cmd
);
10706 install_element(OSPF_NODE
, &no_ospf_area_vlink_intervals_cmd
);
10709 /* "area stub" commands. */
10710 install_element(OSPF_NODE
, &ospf_area_stub_no_summary_cmd
);
10711 install_element(OSPF_NODE
, &ospf_area_stub_cmd
);
10712 install_element(OSPF_NODE
, &no_ospf_area_stub_no_summary_cmd
);
10713 install_element(OSPF_NODE
, &no_ospf_area_stub_cmd
);
10715 /* "area nssa" commands. */
10716 install_element(OSPF_NODE
, &ospf_area_nssa_cmd
);
10717 install_element(OSPF_NODE
, &ospf_area_nssa_translate_cmd
);
10718 install_element(OSPF_NODE
, &ospf_area_nssa_no_summary_cmd
);
10719 install_element(OSPF_NODE
, &no_ospf_area_nssa_no_summary_cmd
);
10720 install_element(OSPF_NODE
, &no_ospf_area_nssa_cmd
);
10722 install_element(OSPF_NODE
, &ospf_area_default_cost_cmd
);
10723 install_element(OSPF_NODE
, &no_ospf_area_default_cost_cmd
);
10725 install_element(OSPF_NODE
, &ospf_area_shortcut_cmd
);
10726 install_element(OSPF_NODE
, &no_ospf_area_shortcut_cmd
);
10728 install_element(OSPF_NODE
, &ospf_area_export_list_cmd
);
10729 install_element(OSPF_NODE
, &no_ospf_area_export_list_cmd
);
10731 install_element(OSPF_NODE
, &ospf_area_filter_list_cmd
);
10732 install_element(OSPF_NODE
, &no_ospf_area_filter_list_cmd
);
10734 install_element(OSPF_NODE
, &ospf_area_import_list_cmd
);
10735 install_element(OSPF_NODE
, &no_ospf_area_import_list_cmd
);
10737 /* SPF timer commands */
10738 install_element(OSPF_NODE
, &ospf_timers_throttle_spf_cmd
);
10739 install_element(OSPF_NODE
, &no_ospf_timers_throttle_spf_cmd
);
10741 /* LSA timers commands */
10742 install_element(OSPF_NODE
, &ospf_timers_min_ls_interval_cmd
);
10743 install_element(OSPF_NODE
, &no_ospf_timers_min_ls_interval_cmd
);
10744 install_element(OSPF_NODE
, &ospf_timers_lsa_min_arrival_cmd
);
10745 install_element(OSPF_NODE
, &no_ospf_timers_lsa_min_arrival_cmd
);
10746 install_element(OSPF_NODE
, &ospf_timers_lsa_arrival_cmd
);
10747 install_element(OSPF_NODE
, &no_ospf_timers_lsa_arrival_cmd
);
10749 /* refresh timer commands */
10750 install_element(OSPF_NODE
, &ospf_refresh_timer_cmd
);
10751 install_element(OSPF_NODE
, &no_ospf_refresh_timer_val_cmd
);
10753 /* max-metric commands */
10754 install_element(OSPF_NODE
, &ospf_max_metric_router_lsa_admin_cmd
);
10755 install_element(OSPF_NODE
, &no_ospf_max_metric_router_lsa_admin_cmd
);
10756 install_element(OSPF_NODE
, &ospf_max_metric_router_lsa_startup_cmd
);
10757 install_element(OSPF_NODE
, &no_ospf_max_metric_router_lsa_startup_cmd
);
10758 install_element(OSPF_NODE
, &ospf_max_metric_router_lsa_shutdown_cmd
);
10759 install_element(OSPF_NODE
, &no_ospf_max_metric_router_lsa_shutdown_cmd
);
10761 /* reference bandwidth commands */
10762 install_element(OSPF_NODE
, &ospf_auto_cost_reference_bandwidth_cmd
);
10763 install_element(OSPF_NODE
, &no_ospf_auto_cost_reference_bandwidth_cmd
);
10765 /* "neighbor" commands. */
10766 install_element(OSPF_NODE
, &ospf_neighbor_cmd
);
10767 install_element(OSPF_NODE
, &ospf_neighbor_poll_interval_cmd
);
10768 install_element(OSPF_NODE
, &no_ospf_neighbor_cmd
);
10769 install_element(OSPF_NODE
, &no_ospf_neighbor_poll_cmd
);
10771 /* write multiplier commands */
10772 install_element(OSPF_NODE
, &ospf_write_multiplier_cmd
);
10773 install_element(OSPF_NODE
, &write_multiplier_cmd
);
10774 install_element(OSPF_NODE
, &no_ospf_write_multiplier_cmd
);
10775 install_element(OSPF_NODE
, &no_write_multiplier_cmd
);
10777 /* Init interface related vty commands. */
10778 ospf_vty_if_init();
10780 /* Init zebra related vty commands. */
10781 ospf_vty_zebra_init();