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 "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;
205 ospf
= ospf_cmd_lookup_ospf(vty
, argv
, argc
, 1, &instance
);
207 return CMD_WARNING_CONFIG_FAILED
;
209 /* The following logic to set the vty qobj index is in place to be able
210 to ignore the commands which dont belong to this instance. */
211 if (ospf
->instance
!= instance
) {
212 VTY_PUSH_CONTEXT_NULL(OSPF_NODE
);
213 ret
= CMD_NOT_MY_INSTANCE
;
215 if (ospf
->vrf_id
!= VRF_UNKNOWN
)
216 ospf
->oi_running
= 1;
217 if (IS_DEBUG_OSPF_EVENT
)
218 zlog_debug("Config command 'router ospf %d' received, vrf %s id %d oi_running %u",
219 instance
, ospf
->name
? ospf
->name
: "NIL",
220 ospf
->vrf_id
, ospf
->oi_running
);
221 VTY_PUSH_CONTEXT(OSPF_NODE
, ospf
);
222 ospf_router_id_update(ospf
);
228 DEFUN (no_router_ospf
,
230 "no router ospf [{(1-65535)|vrf NAME}]",
232 "Enable a routing process\n"
233 "Start OSPF configuration\n"
238 u_short instance
= 0;
240 ospf
= ospf_cmd_lookup_ospf(vty
, argv
, argc
, 0, &instance
);
243 return CMD_NOT_MY_INSTANCE
;
253 DEFPY (ospf_router_id
,
255 "ospf router-id A.B.C.D",
256 "OSPF specific commands\n"
257 "router-id for the OSPF process\n"
258 "OSPF router-id in IP address format\n")
260 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
262 struct listnode
*node
;
263 struct ospf_area
*area
;
265 ospf
->router_id_static
= router_id
;
267 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
))
268 if (area
->full_nbrs
) {
270 "For this router-id change to take effect,"
271 " save config and restart ospfd\n");
275 ospf_router_id_update(ospf
);
280 DEFUN_HIDDEN (ospf_router_id_old
,
281 ospf_router_id_old_cmd
,
283 "router-id for the OSPF process\n"
284 "OSPF router-id in IP address format\n")
286 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
288 struct listnode
*node
;
289 struct ospf_area
*area
;
290 struct in_addr router_id
;
293 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &router_id
);
295 vty_out(vty
, "Please specify Router ID by A.B.C.D\n");
296 return CMD_WARNING_CONFIG_FAILED
;
299 ospf
->router_id_static
= router_id
;
301 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
))
302 if (area
->full_nbrs
) {
304 "For this router-id change to take effect,"
305 " save config and restart ospfd\n");
309 ospf_router_id_update(ospf
);
314 DEFPY (no_ospf_router_id
,
315 no_ospf_router_id_cmd
,
316 "no ospf router-id [A.B.C.D]",
318 "OSPF specific commands\n"
319 "router-id for the OSPF process\n"
320 "OSPF router-id in IP address format\n")
322 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
323 struct listnode
*node
;
324 struct ospf_area
*area
;
327 if (!IPV4_ADDR_SAME(&ospf
->router_id_static
, &router_id
)) {
328 vty_out(vty
, "%% OSPF router-id doesn't match\n");
329 return CMD_WARNING_CONFIG_FAILED
;
333 ospf
->router_id_static
.s_addr
= 0;
335 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
))
336 if (area
->full_nbrs
) {
338 "For this router-id change to take effect,"
339 " save config and restart ospfd\n");
343 ospf_router_id_update(ospf
);
349 static void ospf_passive_interface_default(struct ospf
*ospf
, u_char newval
)
351 struct vrf
*vrf
= vrf_lookup_by_id(ospf
->vrf_id
);
353 struct interface
*ifp
;
354 struct ospf_interface
*oi
;
356 ospf
->passive_interface_default
= newval
;
358 FOR_ALL_INTERFACES (vrf
, ifp
) {
359 if (ifp
&& OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp
),
361 UNSET_IF_PARAM(IF_DEF_PARAMS(ifp
), passive_interface
);
363 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, ln
, oi
)) {
364 if (OSPF_IF_PARAM_CONFIGURED(oi
->params
, passive_interface
))
365 UNSET_IF_PARAM(oi
->params
, passive_interface
);
366 /* update multicast memberships */
367 ospf_if_set_multicast(oi
);
371 static void ospf_passive_interface_update_addr(struct ospf
*ospf
,
372 struct interface
*ifp
,
373 struct ospf_if_params
*params
,
379 params
->passive_interface
= value
;
380 if (params
!= IF_DEF_PARAMS(ifp
)) {
381 if (OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp
),
383 dflt
= IF_DEF_PARAMS(ifp
)->passive_interface
;
385 dflt
= ospf
->passive_interface_default
;
388 SET_IF_PARAM(params
, passive_interface
);
390 UNSET_IF_PARAM(params
, passive_interface
);
392 ospf_free_if_params(ifp
, addr
);
393 ospf_if_update_params(ifp
, addr
);
397 static void ospf_passive_interface_update(struct ospf
*ospf
,
398 struct interface
*ifp
,
399 struct ospf_if_params
*params
,
402 params
->passive_interface
= value
;
403 if (params
== IF_DEF_PARAMS(ifp
)) {
404 if (value
!= ospf
->passive_interface_default
)
405 SET_IF_PARAM(params
, passive_interface
);
407 UNSET_IF_PARAM(params
, passive_interface
);
411 DEFUN (ospf_passive_interface
,
412 ospf_passive_interface_addr_cmd
,
413 "passive-interface <IFNAME [A.B.C.D]|default>",
414 "Suppress routing updates on an interface\n"
417 "Suppress routing updates on interfaces by default\n")
419 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
421 struct interface
*ifp
;
422 struct in_addr addr
= {.s_addr
= INADDR_ANY
};
424 struct ospf_if_params
*params
;
425 struct route_node
*rn
;
427 if (strmatch(argv
[1]->text
, "default")) {
428 ospf_passive_interface_default(ospf
, OSPF_IF_PASSIVE
);
432 ifp
= if_get_by_name(argv
[1]->arg
, ospf
->vrf_id
, 0);
434 vty_out(vty
, "interface %s not found.\n",
435 (char *)argv
[1]->arg
);
439 params
= IF_DEF_PARAMS(ifp
);
442 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
445 "Please specify interface address by A.B.C.D\n");
446 return CMD_WARNING_CONFIG_FAILED
;
449 params
= ospf_get_if_params(ifp
, addr
);
450 ospf_if_update_params(ifp
, addr
);
451 ospf_passive_interface_update_addr(ospf
, ifp
, params
,
452 OSPF_IF_PASSIVE
, addr
);
455 ospf_passive_interface_update(ospf
, ifp
, params
, OSPF_IF_PASSIVE
);
457 /* XXX We should call ospf_if_set_multicast on exactly those
458 * interfaces for which the passive property changed. It is too much
459 * work to determine this set, so we do this for every interface.
460 * This is safe and reasonable because ospf_if_set_multicast uses a
461 * record of joined groups to avoid systems calls if the desired
462 * memberships match the current memership.
465 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
466 struct ospf_interface
*oi
= rn
->info
;
468 if (oi
&& (OSPF_IF_PARAM(oi
, passive_interface
)
470 ospf_if_set_multicast(oi
);
473 * XXX It is not clear what state transitions the interface needs to
474 * undergo when going from active to passive. Fixing this will
475 * require precise identification of interfaces having such a
482 DEFUN (no_ospf_passive_interface
,
483 no_ospf_passive_interface_addr_cmd
,
484 "no passive-interface <IFNAME [A.B.C.D]|default>",
486 "Allow routing updates on an interface\n"
489 "Allow routing updates on interfaces by default\n")
491 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
493 struct interface
*ifp
;
494 struct in_addr addr
= {.s_addr
= INADDR_ANY
};
495 struct ospf_if_params
*params
;
497 struct route_node
*rn
;
499 if (strmatch(argv
[2]->text
, "default")) {
500 ospf_passive_interface_default(ospf
, OSPF_IF_ACTIVE
);
504 ifp
= if_get_by_name(argv
[2]->arg
, ospf
->vrf_id
, 0);
506 vty_out(vty
, "interface %s not found.\n",
507 (char *)argv
[1]->arg
);
511 params
= IF_DEF_PARAMS(ifp
);
514 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
517 "Please specify interface address by A.B.C.D\n");
518 return CMD_WARNING_CONFIG_FAILED
;
521 params
= ospf_lookup_if_params(ifp
, addr
);
524 ospf_passive_interface_update_addr(ospf
, ifp
, params
,
525 OSPF_IF_ACTIVE
, addr
);
527 ospf_passive_interface_update(ospf
, ifp
, params
, OSPF_IF_ACTIVE
);
529 /* XXX We should call ospf_if_set_multicast on exactly those
530 * interfaces for which the passive property changed. It is too much
531 * work to determine this set, so we do this for every interface.
532 * This is safe and reasonable because ospf_if_set_multicast uses a
533 * record of joined groups to avoid systems calls if the desired
534 * memberships match the current memership.
536 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
537 struct ospf_interface
*oi
= rn
->info
;
540 && (OSPF_IF_PARAM(oi
, passive_interface
) == OSPF_IF_ACTIVE
))
541 ospf_if_set_multicast(oi
);
548 DEFUN (ospf_network_area
,
549 ospf_network_area_cmd
,
550 "network A.B.C.D/M area <A.B.C.D|(0-4294967295)>",
551 "Enable routing on an IP network\n"
552 "OSPF network prefix\n"
553 "Set the OSPF area ID\n"
554 "OSPF area ID in IP address format\n"
555 "OSPF area ID as a decimal value\n")
557 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
558 int idx_ipv4_prefixlen
= 1;
559 int idx_ipv4_number
= 3;
560 struct prefix_ipv4 p
;
561 struct in_addr area_id
;
564 if (ospf
->instance
) {
566 "The network command is not supported in multi-instance ospf\n");
567 return CMD_WARNING_CONFIG_FAILED
;
570 if (ospf
->if_ospf_cli_count
> 0) {
572 "Please remove all ip ospf area x.x.x.x commands first.\n");
573 return CMD_WARNING_CONFIG_FAILED
;
576 /* Get network prefix and Area ID. */
577 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
578 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
580 ret
= ospf_network_set(ospf
, &p
, area_id
, format
);
582 vty_out(vty
, "There is already same network statement.\n");
589 DEFUN (no_ospf_network_area
,
590 no_ospf_network_area_cmd
,
591 "no network A.B.C.D/M area <A.B.C.D|(0-4294967295)>",
593 "Enable routing on an IP network\n"
594 "OSPF network prefix\n"
595 "Set the OSPF area ID\n"
596 "OSPF area ID in IP address format\n"
597 "OSPF area ID as a decimal value\n")
599 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
600 int idx_ipv4_prefixlen
= 2;
601 int idx_ipv4_number
= 4;
602 struct prefix_ipv4 p
;
603 struct in_addr area_id
;
606 if (ospf
->instance
) {
608 "The network command is not supported in multi-instance ospf\n");
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_unset(ospf
, &p
, area_id
);
619 "Can't find specified network area configuration.\n");
620 return CMD_WARNING_CONFIG_FAILED
;
626 DEFUN (ospf_area_range
,
628 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [advertise [cost (0-16777215)]]",
629 "OSPF area parameters\n"
630 "OSPF area ID in IP address format\n"
631 "OSPF area ID as a decimal value\n"
632 "Summarize routes matching address/mask (border routers only)\n"
633 "Area range prefix\n"
634 "Advertise this range (default)\n"
635 "User specified metric for this range\n"
636 "Advertised metric for this range\n")
638 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
639 int idx_ipv4_number
= 1;
640 int idx_ipv4_prefixlen
= 3;
642 struct prefix_ipv4 p
;
643 struct in_addr area_id
;
647 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
648 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
650 ospf_area_range_set(ospf
, area_id
, &p
, OSPF_AREA_RANGE_ADVERTISE
);
652 cost
= strtoul(argv
[idx_cost
]->arg
, NULL
, 10);
653 ospf_area_range_cost_set(ospf
, area_id
, &p
, cost
);
659 DEFUN (ospf_area_range_cost
,
660 ospf_area_range_cost_cmd
,
661 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M cost (0-16777215)",
662 "OSPF area parameters\n"
663 "OSPF area ID in IP address format\n"
664 "OSPF area ID as a decimal value\n"
665 "Summarize routes matching address/mask (border routers only)\n"
666 "Area range prefix\n"
667 "User specified metric for this range\n"
668 "Advertised metric for this range\n")
670 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
671 int idx_ipv4_number
= 1;
672 int idx_ipv4_prefixlen
= 3;
674 struct prefix_ipv4 p
;
675 struct in_addr area_id
;
679 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
680 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
682 ospf_area_range_set(ospf
, area_id
, &p
, OSPF_AREA_RANGE_ADVERTISE
);
683 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
686 cost
= strtoul(argv
[idx_cost
]->arg
, NULL
, 10);
687 ospf_area_range_cost_set(ospf
, area_id
, &p
, cost
);
692 DEFUN (ospf_area_range_not_advertise
,
693 ospf_area_range_not_advertise_cmd
,
694 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M not-advertise",
695 "OSPF area parameters\n"
696 "OSPF area ID in IP address format\n"
697 "OSPF area ID as a decimal value\n"
698 "Summarize routes matching address/mask (border routers only)\n"
699 "Area range prefix\n"
700 "DoNotAdvertise this range\n")
702 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
703 int idx_ipv4_number
= 1;
704 int idx_ipv4_prefixlen
= 3;
705 struct prefix_ipv4 p
;
706 struct in_addr area_id
;
709 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
710 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
712 ospf_area_range_set(ospf
, area_id
, &p
, 0);
713 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
719 DEFUN (no_ospf_area_range
,
720 no_ospf_area_range_cmd
,
721 "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [<cost (0-16777215)|advertise [cost (0-16777215)]|not-advertise>]",
723 "OSPF area parameters\n"
724 "OSPF area ID in IP address format\n"
725 "OSPF area ID as a decimal value\n"
726 "Summarize routes matching address/mask (border routers only)\n"
727 "Area range prefix\n"
728 "User specified metric for this range\n"
729 "Advertised metric for this range\n"
730 "Advertise this range (default)\n"
731 "User specified metric for this range\n"
732 "Advertised metric for this range\n"
733 "DoNotAdvertise this range\n")
735 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
736 int idx_ipv4_number
= 2;
737 int idx_ipv4_prefixlen
= 4;
738 struct prefix_ipv4 p
;
739 struct in_addr area_id
;
742 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
743 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
745 ospf_area_range_unset(ospf
, area_id
, &p
);
750 DEFUN (ospf_area_range_substitute
,
751 ospf_area_range_substitute_cmd
,
752 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M",
753 "OSPF area parameters\n"
754 "OSPF area ID in IP address format\n"
755 "OSPF area ID as a decimal value\n"
756 "Summarize routes matching address/mask (border routers only)\n"
757 "Area range prefix\n"
758 "Announce area range as another prefix\n"
759 "Network prefix to be announced instead of range\n")
761 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
762 int idx_ipv4_number
= 1;
763 int idx_ipv4_prefixlen
= 3;
764 int idx_ipv4_prefixlen_2
= 5;
765 struct prefix_ipv4 p
, s
;
766 struct in_addr area_id
;
769 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
770 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
771 str2prefix_ipv4(argv
[idx_ipv4_prefixlen_2
]->arg
, &s
);
773 ospf_area_range_substitute_set(ospf
, area_id
, &p
, &s
);
774 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
780 DEFUN (no_ospf_area_range_substitute
,
781 no_ospf_area_range_substitute_cmd
,
782 "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M",
784 "OSPF area parameters\n"
785 "OSPF area ID in IP address format\n"
786 "OSPF area ID as a decimal value\n"
787 "Summarize routes matching address/mask (border routers only)\n"
788 "Area range prefix\n"
789 "Announce area range as another prefix\n"
790 "Network prefix to be announced instead of range\n")
792 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
793 int idx_ipv4_number
= 2;
794 int idx_ipv4_prefixlen
= 4;
795 int idx_ipv4_prefixlen_2
= 6;
796 struct prefix_ipv4 p
, s
;
797 struct in_addr area_id
;
800 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
801 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
802 str2prefix_ipv4(argv
[idx_ipv4_prefixlen_2
]->arg
, &s
);
804 ospf_area_range_substitute_unset(ospf
, area_id
, &p
);
810 /* Command Handler Logic in VLink stuff is delicate!!
812 ALTER AT YOUR OWN RISK!!!!
814 Various dummy values are used to represent 'NoChange' state for
815 VLink configuration NOT being changed by a VLink command, and
816 special syntax is used within the command strings so that the
817 typed in command verbs can be seen in the configuration command
818 bacckend handler. This is to drastically reduce the verbeage
819 required to coe up with a reasonably compatible Cisco VLink command
821 - Matthew Grant <grantma@anathoth.gen.nz>
822 Wed, 21 Feb 2001 15:13:52 +1300
825 /* Configuration data for virtual links
827 struct ospf_vl_config_data
{
828 struct vty
*vty
; /* vty stuff */
829 struct in_addr area_id
; /* area ID from command line */
830 int area_id_fmt
; /* command line area ID format */
831 struct in_addr vl_peer
; /* command line vl_peer */
832 int auth_type
; /* Authehntication type, if given */
833 char *auth_key
; /* simple password if present */
834 int crypto_key_id
; /* Cryptographic key ID */
835 char *md5_key
; /* MD5 authentication key */
836 int hello_interval
; /* Obvious what these are... */
837 int retransmit_interval
;
842 static void ospf_vl_config_data_init(struct ospf_vl_config_data
*vl_config
,
845 memset(vl_config
, 0, sizeof(struct ospf_vl_config_data
));
846 vl_config
->auth_type
= OSPF_AUTH_CMD_NOTSEEN
;
847 vl_config
->vty
= vty
;
850 static struct ospf_vl_data
*
851 ospf_find_vl_data(struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
853 struct ospf_area
*area
;
854 struct ospf_vl_data
*vl_data
;
856 struct in_addr area_id
;
858 vty
= vl_config
->vty
;
859 area_id
= vl_config
->area_id
;
861 if (area_id
.s_addr
== OSPF_AREA_BACKBONE
) {
863 "Configuring VLs over the backbone is not allowed\n");
866 area
= ospf_area_get(ospf
, area_id
);
867 ospf_area_display_format_set(ospf
, area
, vl_config
->area_id_fmt
);
869 if (area
->external_routing
!= OSPF_AREA_DEFAULT
) {
870 if (vl_config
->area_id_fmt
== OSPF_AREA_ID_FMT_DOTTEDQUAD
)
871 vty_out(vty
, "Area %s is %s\n", inet_ntoa(area_id
),
872 area
->external_routing
== OSPF_AREA_NSSA
876 vty_out(vty
, "Area %ld is %s\n",
877 (u_long
)ntohl(area_id
.s_addr
),
878 area
->external_routing
== OSPF_AREA_NSSA
884 if ((vl_data
= ospf_vl_lookup(ospf
, area
, vl_config
->vl_peer
))
886 vl_data
= ospf_vl_data_new(area
, vl_config
->vl_peer
);
887 if (vl_data
->vl_oi
== NULL
) {
888 vl_data
->vl_oi
= ospf_vl_new(ospf
, vl_data
);
889 ospf_vl_add(ospf
, vl_data
);
890 ospf_spf_calculate_schedule(ospf
,
891 SPF_FLAG_CONFIG_CHANGE
);
898 static int ospf_vl_set_security(struct ospf_vl_data
*vl_data
,
899 struct ospf_vl_config_data
*vl_config
)
901 struct crypt_key
*ck
;
903 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
905 vty
= vl_config
->vty
;
907 if (vl_config
->auth_type
!= OSPF_AUTH_CMD_NOTSEEN
) {
908 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), auth_type
);
909 IF_DEF_PARAMS(ifp
)->auth_type
= vl_config
->auth_type
;
912 if (vl_config
->auth_key
) {
913 memset(IF_DEF_PARAMS(ifp
)->auth_simple
, 0,
914 OSPF_AUTH_SIMPLE_SIZE
+ 1);
915 strncpy((char *)IF_DEF_PARAMS(ifp
)->auth_simple
,
916 vl_config
->auth_key
, OSPF_AUTH_SIMPLE_SIZE
);
917 } else if (vl_config
->md5_key
) {
918 if (ospf_crypt_key_lookup(IF_DEF_PARAMS(ifp
)->auth_crypt
,
919 vl_config
->crypto_key_id
)
921 vty_out(vty
, "OSPF: Key %d already exists\n",
922 vl_config
->crypto_key_id
);
925 ck
= ospf_crypt_key_new();
926 ck
->key_id
= vl_config
->crypto_key_id
;
927 memset(ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+ 1);
928 strncpy((char *)ck
->auth_key
, vl_config
->md5_key
,
931 ospf_crypt_key_add(IF_DEF_PARAMS(ifp
)->auth_crypt
, ck
);
932 } else if (vl_config
->crypto_key_id
!= 0) {
935 if (ospf_crypt_key_lookup(IF_DEF_PARAMS(ifp
)->auth_crypt
,
936 vl_config
->crypto_key_id
)
938 vty_out(vty
, "OSPF: Key %d does not exist\n",
939 vl_config
->crypto_key_id
);
940 return CMD_WARNING_CONFIG_FAILED
;
943 ospf_crypt_key_delete(IF_DEF_PARAMS(ifp
)->auth_crypt
,
944 vl_config
->crypto_key_id
);
950 static int ospf_vl_set_timers(struct ospf_vl_data
*vl_data
,
951 struct ospf_vl_config_data
*vl_config
)
953 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
954 /* Virtual Link data initialised to defaults, so only set
956 if (vl_config
->hello_interval
) {
957 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), v_hello
);
958 IF_DEF_PARAMS(ifp
)->v_hello
= vl_config
->hello_interval
;
961 if (vl_config
->dead_interval
) {
962 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), v_wait
);
963 IF_DEF_PARAMS(ifp
)->v_wait
= vl_config
->dead_interval
;
966 if (vl_config
->retransmit_interval
) {
967 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), retransmit_interval
);
968 IF_DEF_PARAMS(ifp
)->retransmit_interval
=
969 vl_config
->retransmit_interval
;
972 if (vl_config
->transmit_delay
) {
973 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), transmit_delay
);
974 IF_DEF_PARAMS(ifp
)->transmit_delay
= vl_config
->transmit_delay
;
981 /* The business end of all of the above */
982 static int ospf_vl_set(struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
984 struct ospf_vl_data
*vl_data
;
987 vl_data
= ospf_find_vl_data(ospf
, vl_config
);
989 return CMD_WARNING_CONFIG_FAILED
;
991 /* Process this one first as it can have a fatal result, which can
992 only logically occur if the virtual link exists already
993 Thus a command error does not result in a change to the
994 running configuration such as unexpectedly altered timer
996 ret
= ospf_vl_set_security(vl_data
, vl_config
);
997 if (ret
!= CMD_SUCCESS
)
1000 /* Set any time based parameters, these area already range checked */
1002 ret
= ospf_vl_set_timers(vl_data
, vl_config
);
1003 if (ret
!= CMD_SUCCESS
)
1009 /* This stuff exists to make specifying all the alias commands A LOT simpler
1011 #define VLINK_HELPSTR_IPADDR \
1012 "OSPF area parameters\n" \
1013 "OSPF area ID in IP address format\n" \
1014 "OSPF area ID as a decimal value\n" \
1015 "Configure a virtual link\n" \
1016 "Router ID of the remote ABR\n"
1018 #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
1019 "Enable authentication on this virtual link\n" \
1022 #define VLINK_HELPSTR_AUTHTYPE_ALL \
1023 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
1024 "Use null authentication\n" \
1025 "Use message-digest authentication\n"
1027 #define VLINK_HELPSTR_TIME_PARAM \
1028 "Time between HELLO packets\n" \
1030 "Time between retransmitting lost link state advertisements\n" \
1032 "Link state transmit delay\n" \
1034 "Interval time after which a neighbor is declared down\n" \
1037 #define VLINK_HELPSTR_AUTH_SIMPLE \
1038 "Authentication password (key)\n" \
1039 "The OSPF password (key)\n"
1041 #define VLINK_HELPSTR_AUTH_MD5 \
1042 "Message digest authentication password (key)\n" \
1044 "Use MD5 algorithm\n" \
1045 "The OSPF password (key)\n"
1047 DEFUN (ospf_area_vlink
,
1048 ospf_area_vlink_cmd
,
1049 "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>]",
1050 VLINK_HELPSTR_IPADDR
1051 "Enable authentication on this virtual link\n"
1052 "Use message-digest authentication\n"
1053 "Use null authentication\n"
1054 VLINK_HELPSTR_AUTH_MD5
1055 VLINK_HELPSTR_AUTH_SIMPLE
)
1057 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1058 int idx_ipv4_number
= 1;
1060 struct ospf_vl_config_data vl_config
;
1061 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+ 1];
1062 char md5_key
[OSPF_AUTH_MD5_SIZE
+ 1];
1066 ospf_vl_config_data_init(&vl_config
, vty
);
1068 /* Read off first 2 parameters and check them */
1069 ret
= str2area_id(argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
,
1070 &vl_config
.area_id_fmt
);
1072 vty_out(vty
, "OSPF area ID is invalid\n");
1073 return CMD_WARNING_CONFIG_FAILED
;
1076 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1078 vty_out(vty
, "Please specify valid Router ID as a.b.c.d\n");
1079 return CMD_WARNING_CONFIG_FAILED
;
1083 /* Thats all folks! - BUGS B. strikes again!!!*/
1085 return ospf_vl_set(ospf
, &vl_config
);
1088 if (argv_find(argv
, argc
, "authentication", &idx
)) {
1089 /* authentication - this option can only occur
1090 at start of command line */
1091 vl_config
.auth_type
= OSPF_AUTH_SIMPLE
;
1094 if (argv_find(argv
, argc
, "message-digest", &idx
)) {
1095 /* authentication message-digest */
1096 vl_config
.auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
1097 } else if (argv_find(argv
, argc
, "null", &idx
)) {
1098 /* "authentication null" */
1099 vl_config
.auth_type
= OSPF_AUTH_NULL
;
1102 if (argv_find(argv
, argc
, "message-digest-key", &idx
)) {
1103 vl_config
.md5_key
= NULL
;
1104 vl_config
.crypto_key_id
= strtol(argv
[idx
+ 1]->arg
, NULL
, 10);
1105 if (vl_config
.crypto_key_id
< 0)
1106 return CMD_WARNING_CONFIG_FAILED
;
1108 memset(md5_key
, 0, OSPF_AUTH_MD5_SIZE
+ 1);
1109 strncpy(md5_key
, argv
[idx
+ 3]->arg
, OSPF_AUTH_MD5_SIZE
);
1110 vl_config
.md5_key
= md5_key
;
1113 if (argv_find(argv
, argc
, "authentication-key", &idx
)) {
1114 memset(auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1115 strncpy(auth_key
, argv
[idx
+ 1]->arg
, OSPF_AUTH_SIMPLE_SIZE
);
1116 vl_config
.auth_key
= auth_key
;
1119 /* Action configuration */
1121 return ospf_vl_set(ospf
, &vl_config
);
1124 DEFUN (no_ospf_area_vlink
,
1125 no_ospf_area_vlink_cmd
,
1126 "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>]",
1128 VLINK_HELPSTR_IPADDR
1129 "Enable authentication on this virtual link\n" \
1130 "Use message-digest authentication\n" \
1131 "Use null authentication\n" \
1132 VLINK_HELPSTR_AUTH_MD5
1133 VLINK_HELPSTR_AUTH_SIMPLE
)
1135 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1136 int idx_ipv4_number
= 2;
1138 struct ospf_area
*area
;
1139 struct ospf_vl_config_data vl_config
;
1140 struct ospf_vl_data
*vl_data
= NULL
;
1141 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+ 1];
1145 ospf_vl_config_data_init(&vl_config
, vty
);
1147 ret
= str2area_id(argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
,
1150 vty_out(vty
, "OSPF area ID is invalid\n");
1151 return CMD_WARNING_CONFIG_FAILED
;
1154 area
= ospf_area_lookup_by_area_id(ospf
, vl_config
.area_id
);
1156 vty_out(vty
, "Area does not exist\n");
1157 return CMD_WARNING_CONFIG_FAILED
;
1160 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1162 vty_out(vty
, "Please specify valid Router ID as a.b.c.d\n");
1163 return CMD_WARNING_CONFIG_FAILED
;
1167 /* Basic VLink no command */
1168 /* Thats all folks! - BUGS B. strikes again!!!*/
1169 if ((vl_data
= ospf_vl_lookup(ospf
, area
, vl_config
.vl_peer
)))
1170 ospf_vl_delete(ospf
, vl_data
);
1172 ospf_area_check_free(ospf
, vl_config
.area_id
);
1177 /* If we are down here, we are reseting parameters */
1178 /* Deal with other parameters */
1180 if (argv_find(argv
, argc
, "authentication", &idx
)) {
1181 /* authentication - this option can only occur
1182 at start of command line */
1183 vl_config
.auth_type
= OSPF_AUTH_NOTSET
;
1186 if (argv_find(argv
, argc
, "message-digest-key", &idx
)) {
1187 vl_config
.md5_key
= NULL
;
1188 vl_config
.crypto_key_id
= strtol(argv
[idx
+ 1]->arg
, NULL
, 10);
1189 if (vl_config
.crypto_key_id
< 0)
1190 return CMD_WARNING_CONFIG_FAILED
;
1193 if (argv_find(argv
, argc
, "authentication-key", &idx
)) {
1194 /* Reset authentication-key to 0 */
1195 memset(auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1196 vl_config
.auth_key
= auth_key
;
1199 /* Action configuration */
1201 return ospf_vl_set(ospf
, &vl_config
);
1204 DEFUN (ospf_area_vlink_intervals
,
1205 ospf_area_vlink_intervals_cmd
,
1206 "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)}",
1207 VLINK_HELPSTR_IPADDR
1208 VLINK_HELPSTR_TIME_PARAM
)
1210 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1211 struct ospf_vl_config_data vl_config
;
1214 ospf_vl_config_data_init(&vl_config
, vty
);
1216 char *area_id
= argv
[1]->arg
;
1217 char *router_id
= argv
[3]->arg
;
1219 ret
= str2area_id(area_id
, &vl_config
.area_id
, &vl_config
.area_id_fmt
);
1221 vty_out(vty
, "OSPF area ID is invalid\n");
1222 return CMD_WARNING_CONFIG_FAILED
;
1225 ret
= inet_aton(router_id
, &vl_config
.vl_peer
);
1227 vty_out(vty
, "Please specify valid Router ID as a.b.c.d\n");
1228 return CMD_WARNING_CONFIG_FAILED
;
1231 for (int idx
= 4; idx
< argc
; idx
++) {
1232 if (strmatch(argv
[idx
]->text
, "hello-interval"))
1233 vl_config
.hello_interval
=
1234 strtol(argv
[++idx
]->arg
, NULL
, 10);
1235 else if (strmatch(argv
[idx
]->text
, "retransmit-interval"))
1236 vl_config
.retransmit_interval
=
1237 strtol(argv
[++idx
]->arg
, NULL
, 10);
1238 else if (strmatch(argv
[idx
]->text
, "transmit-delay"))
1239 vl_config
.transmit_delay
=
1240 strtol(argv
[++idx
]->arg
, NULL
, 10);
1241 else if (strmatch(argv
[idx
]->text
, "dead-interval"))
1242 vl_config
.dead_interval
=
1243 strtol(argv
[++idx
]->arg
, NULL
, 10);
1246 /* Action configuration */
1247 return ospf_vl_set(ospf
, &vl_config
);
1250 DEFUN (no_ospf_area_vlink_intervals
,
1251 no_ospf_area_vlink_intervals_cmd
,
1252 "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)}",
1254 VLINK_HELPSTR_IPADDR
1255 VLINK_HELPSTR_TIME_PARAM
)
1257 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1258 struct ospf_vl_config_data vl_config
;
1261 ospf_vl_config_data_init(&vl_config
, vty
);
1263 char *area_id
= argv
[2]->arg
;
1264 char *router_id
= argv
[4]->arg
;
1266 ret
= str2area_id(area_id
, &vl_config
.area_id
, &vl_config
.area_id_fmt
);
1268 vty_out(vty
, "OSPF area ID is invalid\n");
1269 return CMD_WARNING_CONFIG_FAILED
;
1272 ret
= inet_aton(router_id
, &vl_config
.vl_peer
);
1274 vty_out(vty
, "Please specify valid Router ID as a.b.c.d\n");
1275 return CMD_WARNING_CONFIG_FAILED
;
1278 for (int idx
= 5; idx
< argc
; idx
++) {
1279 if (strmatch(argv
[idx
]->text
, "hello-interval"))
1280 vl_config
.hello_interval
= OSPF_HELLO_INTERVAL_DEFAULT
;
1281 else if (strmatch(argv
[idx
]->text
, "retransmit-interval"))
1282 vl_config
.retransmit_interval
=
1283 OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
1284 else if (strmatch(argv
[idx
]->text
, "transmit-delay"))
1285 vl_config
.transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
1286 else if (strmatch(argv
[idx
]->text
, "dead-interval"))
1287 vl_config
.dead_interval
=
1288 OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
1291 /* Action configuration */
1292 return ospf_vl_set(ospf
, &vl_config
);
1295 DEFUN (ospf_area_shortcut
,
1296 ospf_area_shortcut_cmd
,
1297 "area <A.B.C.D|(0-4294967295)> shortcut <default|enable|disable>",
1298 "OSPF area parameters\n"
1299 "OSPF area ID in IP address format\n"
1300 "OSPF area ID as a decimal value\n"
1301 "Configure the area's shortcutting mode\n"
1302 "Set default shortcutting behavior\n"
1303 "Enable shortcutting through the area\n"
1304 "Disable shortcutting through the area\n")
1306 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1307 int idx_ipv4_number
= 1;
1308 int idx_enable_disable
= 3;
1309 struct ospf_area
*area
;
1310 struct in_addr area_id
;
1314 VTY_GET_OSPF_AREA_ID_NO_BB("shortcut", area_id
, format
,
1315 argv
[idx_ipv4_number
]->arg
);
1317 area
= ospf_area_get(ospf
, area_id
);
1318 ospf_area_display_format_set(ospf
, area
, format
);
1320 if (strncmp(argv
[idx_enable_disable
]->arg
, "de", 2) == 0)
1321 mode
= OSPF_SHORTCUT_DEFAULT
;
1322 else if (strncmp(argv
[idx_enable_disable
]->arg
, "di", 2) == 0)
1323 mode
= OSPF_SHORTCUT_DISABLE
;
1324 else if (strncmp(argv
[idx_enable_disable
]->arg
, "e", 1) == 0)
1325 mode
= OSPF_SHORTCUT_ENABLE
;
1327 return CMD_WARNING_CONFIG_FAILED
;
1329 ospf_area_shortcut_set(ospf
, area
, mode
);
1331 if (ospf
->abr_type
!= OSPF_ABR_SHORTCUT
)
1333 "Shortcut area setting will take effect "
1334 "only when the router is configured as Shortcut ABR\n");
1339 DEFUN (no_ospf_area_shortcut
,
1340 no_ospf_area_shortcut_cmd
,
1341 "no area <A.B.C.D|(0-4294967295)> shortcut <enable|disable>",
1343 "OSPF area parameters\n"
1344 "OSPF area ID in IP address format\n"
1345 "OSPF area ID as a decimal value\n"
1346 "Deconfigure the area's shortcutting mode\n"
1347 "Deconfigure enabled shortcutting through the area\n"
1348 "Deconfigure disabled shortcutting through the area\n")
1350 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1351 int idx_ipv4_number
= 2;
1352 struct ospf_area
*area
;
1353 struct in_addr area_id
;
1356 VTY_GET_OSPF_AREA_ID_NO_BB("shortcut", area_id
, format
,
1357 argv
[idx_ipv4_number
]->arg
);
1359 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1363 ospf_area_shortcut_unset(ospf
, area
);
1369 DEFUN (ospf_area_stub
,
1371 "area <A.B.C.D|(0-4294967295)> stub",
1372 "OSPF area parameters\n"
1373 "OSPF area ID in IP address format\n"
1374 "OSPF area ID as a decimal value\n"
1375 "Configure OSPF area as stub\n")
1377 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1378 int idx_ipv4_number
= 1;
1379 struct in_addr area_id
;
1382 VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id
, format
,
1383 argv
[idx_ipv4_number
]->arg
);
1385 ret
= ospf_area_stub_set(ospf
, area_id
);
1386 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1390 "First deconfigure all virtual link through this area\n");
1391 return CMD_WARNING_CONFIG_FAILED
;
1394 ospf_area_no_summary_unset(ospf
, area_id
);
1399 DEFUN (ospf_area_stub_no_summary
,
1400 ospf_area_stub_no_summary_cmd
,
1401 "area <A.B.C.D|(0-4294967295)> stub no-summary",
1402 "OSPF stub parameters\n"
1403 "OSPF area ID in IP address format\n"
1404 "OSPF area ID as a decimal value\n"
1405 "Configure OSPF area as stub\n"
1406 "Do not inject inter-area routes into stub\n")
1408 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1409 int idx_ipv4_number
= 1;
1410 struct in_addr area_id
;
1413 VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id
, format
,
1414 argv
[idx_ipv4_number
]->arg
);
1416 ret
= ospf_area_stub_set(ospf
, area_id
);
1417 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1421 "%% Area cannot be stub as it contains a virtual link\n");
1422 return CMD_WARNING_CONFIG_FAILED
;
1425 ospf_area_no_summary_set(ospf
, area_id
);
1430 DEFUN (no_ospf_area_stub
,
1431 no_ospf_area_stub_cmd
,
1432 "no area <A.B.C.D|(0-4294967295)> stub",
1434 "OSPF area parameters\n"
1435 "OSPF area ID in IP address format\n"
1436 "OSPF area ID as a decimal value\n"
1437 "Configure OSPF area as stub\n")
1439 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1440 int idx_ipv4_number
= 2;
1441 struct in_addr area_id
;
1444 VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id
, format
,
1445 argv
[idx_ipv4_number
]->arg
);
1447 ospf_area_stub_unset(ospf
, area_id
);
1448 ospf_area_no_summary_unset(ospf
, area_id
);
1453 DEFUN (no_ospf_area_stub_no_summary
,
1454 no_ospf_area_stub_no_summary_cmd
,
1455 "no area <A.B.C.D|(0-4294967295)> stub no-summary",
1457 "OSPF area parameters\n"
1458 "OSPF area ID in IP address format\n"
1459 "OSPF area ID as a decimal value\n"
1460 "Configure OSPF area as stub\n"
1461 "Do not inject inter-area routes into area\n")
1463 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1464 int idx_ipv4_number
= 2;
1465 struct in_addr area_id
;
1468 VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id
, format
,
1469 argv
[idx_ipv4_number
]->arg
);
1470 ospf_area_no_summary_unset(ospf
, area_id
);
1475 static int ospf_area_nssa_cmd_handler(struct vty
*vty
, int argc
,
1476 struct cmd_token
**argv
, int cfg_nosum
,
1479 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1480 struct in_addr area_id
;
1483 VTY_GET_OSPF_AREA_ID_NO_BB("NSSA", area_id
, format
, argv
[1]->arg
);
1485 ret
= ospf_area_nssa_set(ospf
, area_id
);
1486 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1490 "%% Area cannot be nssa as it contains a virtual link\n");
1491 return CMD_WARNING_CONFIG_FAILED
;
1495 if (strncmp(argv
[3]->text
, "translate-c", 11) == 0)
1496 ospf_area_nssa_translator_role_set(
1497 ospf
, area_id
, OSPF_NSSA_ROLE_CANDIDATE
);
1498 else if (strncmp(argv
[3]->text
, "translate-n", 11) == 0)
1499 ospf_area_nssa_translator_role_set(
1500 ospf
, area_id
, OSPF_NSSA_ROLE_NEVER
);
1501 else if (strncmp(argv
[3]->text
, "translate-a", 11) == 0)
1502 ospf_area_nssa_translator_role_set(
1503 ospf
, area_id
, OSPF_NSSA_ROLE_ALWAYS
);
1505 ospf_area_nssa_translator_role_set(ospf
, area_id
,
1506 OSPF_NSSA_ROLE_CANDIDATE
);
1511 ospf_area_no_summary_set(ospf
, area_id
);
1513 ospf_area_no_summary_unset(ospf
, area_id
);
1516 ospf_schedule_abr_task(ospf
);
1522 DEFUN (ospf_area_nssa_translate
,
1523 ospf_area_nssa_translate_cmd
,
1524 "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always>",
1525 "OSPF area parameters\n"
1526 "OSPF area ID in IP address format\n"
1527 "OSPF area ID as a decimal value\n"
1528 "Configure OSPF area as nssa\n"
1529 "Configure NSSA-ABR for translate election (default)\n"
1530 "Configure NSSA-ABR to never translate\n"
1531 "Configure NSSA-ABR to always translate\n")
1533 return ospf_area_nssa_cmd_handler(vty
, argc
, argv
, 0, 0);
1536 DEFUN (ospf_area_nssa
,
1538 "area <A.B.C.D|(0-4294967295)> nssa",
1539 "OSPF area parameters\n"
1540 "OSPF area ID in IP address format\n"
1541 "OSPF area ID as a decimal value\n"
1542 "Configure OSPF area as nssa\n")
1544 return ospf_area_nssa_cmd_handler(vty
, argc
, argv
, 1, 0);
1547 DEFUN (ospf_area_nssa_no_summary
,
1548 ospf_area_nssa_no_summary_cmd
,
1549 "area <A.B.C.D|(0-4294967295)> nssa no-summary",
1550 "OSPF area parameters\n"
1551 "OSPF area ID in IP address format\n"
1552 "OSPF area ID as a decimal value\n"
1553 "Configure OSPF area as nssa\n"
1554 "Do not inject inter-area routes into nssa\n")
1556 int idx_ipv4_number
= 1;
1557 struct in_addr area_id
;
1560 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1561 VTY_GET_OSPF_AREA_ID_NO_BB("NSSA", area_id
, format
,
1562 argv
[idx_ipv4_number
]->arg
);
1564 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1566 ospf_area_nssa_no_summary_set(ospf
, area_id
);
1568 ospf_schedule_abr_task(ospf
);
1573 DEFUN (no_ospf_area_nssa_no_summary
,
1574 no_ospf_area_nssa_no_summary_cmd
,
1575 "no area <A.B.C.D|(0-4294967295)> nssa no-summary",
1577 "OSPF area parameters\n"
1578 "OSPF area ID in IP address format\n"
1579 "OSPF area ID as a decimal value\n"
1580 "Configure OSPF area as nssa\n"
1581 "Do not inject inter-area routes into nssa\n")
1583 int idx_ipv4_number
= 2;
1584 struct in_addr area_id
;
1587 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1589 VTY_GET_OSPF_AREA_ID_NO_BB("nssa", area_id
, format
,
1590 argv
[idx_ipv4_number
]->arg
);
1592 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1594 ospf_area_no_summary_unset(ospf
, area_id
);
1596 ospf_schedule_abr_task(ospf
);
1601 DEFUN (no_ospf_area_nssa
,
1602 no_ospf_area_nssa_cmd
,
1603 "no area <A.B.C.D|(0-4294967295)> nssa [<translate-candidate|translate-never|translate-always>]",
1605 "OSPF area parameters\n"
1606 "OSPF area ID in IP address format\n"
1607 "OSPF area ID as a decimal value\n"
1608 "Configure OSPF area as nssa\n"
1609 "Configure NSSA-ABR for translate election (default)\n"
1610 "Configure NSSA-ABR to never translate\n"
1611 "Configure NSSA-ABR to always translate\n")
1613 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1614 int idx_ipv4_number
= 2;
1615 struct in_addr area_id
;
1618 VTY_GET_OSPF_AREA_ID_NO_BB("NSSA", area_id
, format
,
1619 argv
[idx_ipv4_number
]->arg
);
1621 ospf_area_nssa_unset(ospf
, area_id
, argc
);
1623 ospf_schedule_abr_task(ospf
);
1629 DEFUN (ospf_area_default_cost
,
1630 ospf_area_default_cost_cmd
,
1631 "area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1632 "OSPF area parameters\n"
1633 "OSPF area ID in IP address format\n"
1634 "OSPF area ID as a decimal value\n"
1635 "Set the summary-default cost of a NSSA or stub area\n"
1636 "Stub's advertised default summary cost\n")
1638 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1639 int idx_ipv4_number
= 1;
1641 struct ospf_area
*area
;
1642 struct in_addr area_id
;
1645 struct prefix_ipv4 p
;
1647 VTY_GET_OSPF_AREA_ID_NO_BB("default-cost", area_id
, format
,
1648 argv
[idx_ipv4_number
]->arg
);
1649 cost
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1651 area
= ospf_area_get(ospf
, area_id
);
1652 ospf_area_display_format_set(ospf
, area
, format
);
1654 if (area
->external_routing
== OSPF_AREA_DEFAULT
) {
1655 vty_out(vty
, "The area is neither stub, nor NSSA\n");
1656 return CMD_WARNING_CONFIG_FAILED
;
1659 area
->default_cost
= cost
;
1662 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1664 if (IS_DEBUG_OSPF_EVENT
)
1666 "ospf_abr_announce_stub_defaults(): "
1667 "announcing 0.0.0.0/0 to area %s",
1668 inet_ntoa(area
->area_id
));
1669 ospf_abr_announce_network_to_area(&p
, area
->default_cost
, area
);
1674 DEFUN (no_ospf_area_default_cost
,
1675 no_ospf_area_default_cost_cmd
,
1676 "no area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1678 "OSPF area parameters\n"
1679 "OSPF area ID in IP address format\n"
1680 "OSPF area ID as a decimal value\n"
1681 "Set the summary-default cost of a NSSA or stub area\n"
1682 "Stub's advertised default summary cost\n")
1684 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1685 int idx_ipv4_number
= 2;
1686 struct ospf_area
*area
;
1687 struct in_addr area_id
;
1689 struct prefix_ipv4 p
;
1691 VTY_GET_OSPF_AREA_ID_NO_BB("default-cost", area_id
, format
,
1692 argv
[idx_ipv4_number
]->arg
);
1694 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1698 if (area
->external_routing
== OSPF_AREA_DEFAULT
) {
1699 vty_out(vty
, "The area is neither stub, nor NSSA\n");
1700 return CMD_WARNING_CONFIG_FAILED
;
1703 area
->default_cost
= 1;
1706 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1708 if (IS_DEBUG_OSPF_EVENT
)
1710 "ospf_abr_announce_stub_defaults(): "
1711 "announcing 0.0.0.0/0 to area %s",
1712 inet_ntoa(area
->area_id
));
1713 ospf_abr_announce_network_to_area(&p
, area
->default_cost
, area
);
1716 ospf_area_check_free(ospf
, area_id
);
1721 DEFUN (ospf_area_export_list
,
1722 ospf_area_export_list_cmd
,
1723 "area <A.B.C.D|(0-4294967295)> export-list NAME",
1724 "OSPF area parameters\n"
1725 "OSPF area ID in IP address format\n"
1726 "OSPF area ID as a decimal value\n"
1727 "Set the filter for networks announced to other areas\n"
1728 "Name of the access-list\n")
1730 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1731 int idx_ipv4_number
= 1;
1732 struct ospf_area
*area
;
1733 struct in_addr area_id
;
1736 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1738 area
= ospf_area_get(ospf
, area_id
);
1739 ospf_area_display_format_set(ospf
, area
, format
);
1740 ospf_area_export_list_set(ospf
, area
, argv
[3]->arg
);
1745 DEFUN (no_ospf_area_export_list
,
1746 no_ospf_area_export_list_cmd
,
1747 "no area <A.B.C.D|(0-4294967295)> export-list NAME",
1749 "OSPF area parameters\n"
1750 "OSPF area ID in IP address format\n"
1751 "OSPF area ID as a decimal value\n"
1752 "Unset the filter for networks announced to other areas\n"
1753 "Name of the access-list\n")
1755 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1756 int idx_ipv4_number
= 2;
1757 struct ospf_area
*area
;
1758 struct in_addr area_id
;
1761 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1763 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1767 ospf_area_export_list_unset(ospf
, area
);
1773 DEFUN (ospf_area_import_list
,
1774 ospf_area_import_list_cmd
,
1775 "area <A.B.C.D|(0-4294967295)> import-list NAME",
1776 "OSPF area parameters\n"
1777 "OSPF area ID in IP address format\n"
1778 "OSPF area ID as a decimal value\n"
1779 "Set the filter for networks from other areas announced to the specified one\n"
1780 "Name of the access-list\n")
1782 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1783 int idx_ipv4_number
= 1;
1784 struct ospf_area
*area
;
1785 struct in_addr area_id
;
1788 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1790 area
= ospf_area_get(ospf
, area_id
);
1791 ospf_area_display_format_set(ospf
, area
, format
);
1792 ospf_area_import_list_set(ospf
, area
, argv
[3]->arg
);
1797 DEFUN (no_ospf_area_import_list
,
1798 no_ospf_area_import_list_cmd
,
1799 "no area <A.B.C.D|(0-4294967295)> import-list NAME",
1801 "OSPF area parameters\n"
1802 "OSPF area ID in IP address format\n"
1803 "OSPF area ID as a decimal value\n"
1804 "Unset the filter for networks announced to other areas\n"
1805 "Name of the access-list\n")
1807 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1808 int idx_ipv4_number
= 2;
1809 struct ospf_area
*area
;
1810 struct in_addr area_id
;
1813 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1815 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1819 ospf_area_import_list_unset(ospf
, area
);
1824 DEFUN (ospf_area_filter_list
,
1825 ospf_area_filter_list_cmd
,
1826 "area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>",
1827 "OSPF area parameters\n"
1828 "OSPF area ID in IP address format\n"
1829 "OSPF area ID as a decimal value\n"
1830 "Filter networks between OSPF areas\n"
1831 "Filter prefixes between OSPF areas\n"
1832 "Name of an IP prefix-list\n"
1833 "Filter networks sent to this area\n"
1834 "Filter networks sent from this area\n")
1836 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1837 int idx_ipv4_number
= 1;
1840 struct ospf_area
*area
;
1841 struct in_addr area_id
;
1842 struct prefix_list
*plist
;
1845 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1847 area
= ospf_area_get(ospf
, area_id
);
1848 ospf_area_display_format_set(ospf
, area
, format
);
1849 plist
= prefix_list_lookup(AFI_IP
, argv
[idx_word
]->arg
);
1850 if (strncmp(argv
[idx_in_out
]->arg
, "in", 2) == 0) {
1851 PREFIX_LIST_IN(area
) = plist
;
1852 if (PREFIX_NAME_IN(area
))
1853 free(PREFIX_NAME_IN(area
));
1855 PREFIX_NAME_IN(area
) = strdup(argv
[idx_word
]->arg
);
1856 ospf_schedule_abr_task(ospf
);
1858 PREFIX_LIST_OUT(area
) = plist
;
1859 if (PREFIX_NAME_OUT(area
))
1860 free(PREFIX_NAME_OUT(area
));
1862 PREFIX_NAME_OUT(area
) = strdup(argv
[idx_word
]->arg
);
1863 ospf_schedule_abr_task(ospf
);
1869 DEFUN (no_ospf_area_filter_list
,
1870 no_ospf_area_filter_list_cmd
,
1871 "no area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>",
1873 "OSPF area parameters\n"
1874 "OSPF area ID in IP address format\n"
1875 "OSPF area ID as a decimal value\n"
1876 "Filter networks between OSPF areas\n"
1877 "Filter prefixes between OSPF areas\n"
1878 "Name of an IP prefix-list\n"
1879 "Filter networks sent to this area\n"
1880 "Filter networks sent from this area\n")
1882 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1883 int idx_ipv4_number
= 2;
1886 struct ospf_area
*area
;
1887 struct in_addr area_id
;
1890 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1892 if ((area
= ospf_area_lookup_by_area_id(ospf
, area_id
)) == NULL
)
1895 if (strncmp(argv
[idx_in_out
]->arg
, "in", 2) == 0) {
1896 if (PREFIX_NAME_IN(area
))
1897 if (strcmp(PREFIX_NAME_IN(area
), argv
[idx_word
]->arg
)
1901 PREFIX_LIST_IN(area
) = NULL
;
1902 if (PREFIX_NAME_IN(area
))
1903 free(PREFIX_NAME_IN(area
));
1905 PREFIX_NAME_IN(area
) = NULL
;
1907 ospf_schedule_abr_task(ospf
);
1909 if (PREFIX_NAME_OUT(area
))
1910 if (strcmp(PREFIX_NAME_OUT(area
), argv
[idx_word
]->arg
)
1914 PREFIX_LIST_OUT(area
) = NULL
;
1915 if (PREFIX_NAME_OUT(area
))
1916 free(PREFIX_NAME_OUT(area
));
1918 PREFIX_NAME_OUT(area
) = NULL
;
1920 ospf_schedule_abr_task(ospf
);
1927 DEFUN (ospf_area_authentication_message_digest
,
1928 ospf_area_authentication_message_digest_cmd
,
1929 "[no] area <A.B.C.D|(0-4294967295)> authentication message-digest",
1931 "OSPF area parameters\n"
1932 "OSPF area ID in IP address format\n"
1933 "OSPF area ID as a decimal value\n"
1934 "Enable authentication\n"
1935 "Use message-digest authentication\n")
1937 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1938 int idx_ipv4_number
= 1;
1939 struct ospf_area
*area
;
1940 struct in_addr area_id
;
1943 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1945 area
= ospf_area_get(ospf
, area_id
);
1946 ospf_area_display_format_set(ospf
, area
, format
);
1947 area
->auth_type
= strmatch(argv
[0]->text
, "no") ? OSPF_AUTH_NULL
: OSPF_AUTH_CRYPTOGRAPHIC
;
1952 DEFUN (ospf_area_authentication
,
1953 ospf_area_authentication_cmd
,
1954 "area <A.B.C.D|(0-4294967295)> authentication",
1955 "OSPF area parameters\n"
1956 "OSPF area ID in IP address format\n"
1957 "OSPF area ID as a decimal value\n"
1958 "Enable authentication\n")
1960 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1961 int idx_ipv4_number
= 1;
1962 struct ospf_area
*area
;
1963 struct in_addr area_id
;
1966 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1968 area
= ospf_area_get(ospf
, area_id
);
1969 ospf_area_display_format_set(ospf
, area
, format
);
1970 area
->auth_type
= OSPF_AUTH_SIMPLE
;
1975 DEFUN (no_ospf_area_authentication
,
1976 no_ospf_area_authentication_cmd
,
1977 "no area <A.B.C.D|(0-4294967295)> authentication",
1979 "OSPF area parameters\n"
1980 "OSPF area ID in IP address format\n"
1981 "OSPF area ID as a decimal value\n"
1982 "Enable authentication\n")
1984 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1985 int idx_ipv4_number
= 2;
1986 struct ospf_area
*area
;
1987 struct in_addr area_id
;
1990 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1992 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1996 area
->auth_type
= OSPF_AUTH_NULL
;
1998 ospf_area_check_free(ospf
, area_id
);
2004 DEFUN (ospf_abr_type
,
2006 "ospf abr-type <cisco|ibm|shortcut|standard>",
2007 "OSPF specific commands\n"
2008 "Set OSPF ABR type\n"
2009 "Alternative ABR, cisco implementation\n"
2010 "Alternative ABR, IBM implementation\n"
2012 "Standard behavior (RFC2328)\n")
2014 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2016 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2018 if (strncmp(argv
[idx_vendor
]->arg
, "c", 1) == 0)
2019 abr_type
= OSPF_ABR_CISCO
;
2020 else if (strncmp(argv
[idx_vendor
]->arg
, "i", 1) == 0)
2021 abr_type
= OSPF_ABR_IBM
;
2022 else if (strncmp(argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2023 abr_type
= OSPF_ABR_SHORTCUT
;
2024 else if (strncmp(argv
[idx_vendor
]->arg
, "st", 2) == 0)
2025 abr_type
= OSPF_ABR_STAND
;
2027 return CMD_WARNING_CONFIG_FAILED
;
2029 /* If ABR type value is changed, schedule ABR task. */
2030 if (ospf
->abr_type
!= abr_type
) {
2031 ospf
->abr_type
= abr_type
;
2032 ospf_schedule_abr_task(ospf
);
2038 DEFUN (no_ospf_abr_type
,
2039 no_ospf_abr_type_cmd
,
2040 "no ospf abr-type <cisco|ibm|shortcut|standard>",
2042 "OSPF specific commands\n"
2043 "Set OSPF ABR type\n"
2044 "Alternative ABR, cisco implementation\n"
2045 "Alternative ABR, IBM implementation\n"
2049 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2051 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2053 if (strncmp(argv
[idx_vendor
]->arg
, "c", 1) == 0)
2054 abr_type
= OSPF_ABR_CISCO
;
2055 else if (strncmp(argv
[idx_vendor
]->arg
, "i", 1) == 0)
2056 abr_type
= OSPF_ABR_IBM
;
2057 else if (strncmp(argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2058 abr_type
= OSPF_ABR_SHORTCUT
;
2059 else if (strncmp(argv
[idx_vendor
]->arg
, "st", 2) == 0)
2060 abr_type
= OSPF_ABR_STAND
;
2062 return CMD_WARNING_CONFIG_FAILED
;
2064 /* If ABR type value is changed, schedule ABR task. */
2065 if (ospf
->abr_type
== abr_type
) {
2066 ospf
->abr_type
= OSPF_ABR_DEFAULT
;
2067 ospf_schedule_abr_task(ospf
);
2073 DEFUN (ospf_log_adjacency_changes
,
2074 ospf_log_adjacency_changes_cmd
,
2075 "log-adjacency-changes",
2076 "Log changes in adjacency state\n")
2078 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2080 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2081 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2085 DEFUN (ospf_log_adjacency_changes_detail
,
2086 ospf_log_adjacency_changes_detail_cmd
,
2087 "log-adjacency-changes detail",
2088 "Log changes in adjacency state\n"
2089 "Log all state changes\n")
2091 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2093 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2094 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2098 DEFUN (no_ospf_log_adjacency_changes
,
2099 no_ospf_log_adjacency_changes_cmd
,
2100 "no log-adjacency-changes",
2102 "Log changes in adjacency state\n")
2104 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2106 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2107 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2111 DEFUN (no_ospf_log_adjacency_changes_detail
,
2112 no_ospf_log_adjacency_changes_detail_cmd
,
2113 "no log-adjacency-changes detail",
2115 "Log changes in adjacency state\n"
2116 "Log all state changes\n")
2118 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2120 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2124 DEFUN (ospf_compatible_rfc1583
,
2125 ospf_compatible_rfc1583_cmd
,
2126 "compatible rfc1583",
2127 "OSPF compatibility list\n"
2128 "compatible with RFC 1583\n")
2130 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2132 if (!CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)) {
2133 SET_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2134 ospf_spf_calculate_schedule(ospf
, SPF_FLAG_CONFIG_CHANGE
);
2139 DEFUN (no_ospf_compatible_rfc1583
,
2140 no_ospf_compatible_rfc1583_cmd
,
2141 "no compatible rfc1583",
2143 "OSPF compatibility list\n"
2144 "compatible with RFC 1583\n")
2146 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2148 if (CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)) {
2149 UNSET_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2150 ospf_spf_calculate_schedule(ospf
, SPF_FLAG_CONFIG_CHANGE
);
2155 ALIAS(ospf_compatible_rfc1583
, ospf_rfc1583_flag_cmd
,
2156 "ospf rfc1583compatibility",
2157 "OSPF specific commands\n"
2158 "Enable the RFC1583Compatibility flag\n")
2160 ALIAS(no_ospf_compatible_rfc1583
, no_ospf_rfc1583_flag_cmd
,
2161 "no ospf rfc1583compatibility", NO_STR
2162 "OSPF specific commands\n"
2163 "Disable the RFC1583Compatibility flag\n")
2165 static int ospf_timers_spf_set(struct vty
*vty
, unsigned int delay
,
2166 unsigned int hold
, unsigned int max
)
2168 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2170 ospf
->spf_delay
= delay
;
2171 ospf
->spf_holdtime
= hold
;
2172 ospf
->spf_max_holdtime
= max
;
2177 DEFUN (ospf_timers_min_ls_interval
,
2178 ospf_timers_min_ls_interval_cmd
,
2179 "timers throttle lsa all (0-5000)",
2180 "Adjust routing timers\n"
2181 "Throttling adaptive timer\n"
2182 "LSA delay between transmissions\n"
2184 "Delay (msec) between sending LSAs\n")
2186 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2188 unsigned int interval
;
2191 vty_out(vty
, "Insufficient arguments\n");
2192 return CMD_WARNING_CONFIG_FAILED
;
2195 interval
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2197 ospf
->min_ls_interval
= interval
;
2202 DEFUN (no_ospf_timers_min_ls_interval
,
2203 no_ospf_timers_min_ls_interval_cmd
,
2204 "no timers throttle lsa all [(0-5000)]",
2206 "Adjust routing timers\n"
2207 "Throttling adaptive timer\n"
2208 "LSA delay between transmissions\n"
2210 "Delay (msec) between sending LSAs\n")
2212 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2213 ospf
->min_ls_interval
= OSPF_MIN_LS_INTERVAL
;
2218 DEFUN (ospf_timers_throttle_spf
,
2219 ospf_timers_throttle_spf_cmd
,
2220 "timers throttle spf (0-600000) (0-600000) (0-600000)",
2221 "Adjust routing timers\n"
2222 "Throttling adaptive timer\n"
2224 "Delay (msec) from first change received till SPF calculation\n"
2225 "Initial hold time (msec) between consecutive SPF calculations\n"
2226 "Maximum hold time (msec)\n")
2229 int idx_number_2
= 4;
2230 int idx_number_3
= 5;
2231 unsigned int delay
, hold
, max
;
2234 vty_out(vty
, "Insufficient arguments\n");
2235 return CMD_WARNING_CONFIG_FAILED
;
2238 delay
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2239 hold
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
2240 max
= strtoul(argv
[idx_number_3
]->arg
, NULL
, 10);
2242 return ospf_timers_spf_set(vty
, delay
, hold
, max
);
2245 DEFUN (no_ospf_timers_throttle_spf
,
2246 no_ospf_timers_throttle_spf_cmd
,
2247 "no timers throttle spf [(0-600000)(0-600000)(0-600000)]",
2249 "Adjust routing timers\n"
2250 "Throttling adaptive timer\n"
2252 "Delay (msec) from first change received till SPF calculation\n"
2253 "Initial hold time (msec) between consecutive SPF calculations\n"
2254 "Maximum hold time (msec)\n")
2256 return ospf_timers_spf_set(vty
, OSPF_SPF_DELAY_DEFAULT
,
2257 OSPF_SPF_HOLDTIME_DEFAULT
,
2258 OSPF_SPF_MAX_HOLDTIME_DEFAULT
);
2262 DEFUN (ospf_timers_lsa_min_arrival
,
2263 ospf_timers_lsa_min_arrival_cmd
,
2264 "timers lsa min-arrival (0-600000)",
2265 "Adjust routing timers\n"
2267 "Minimum delay in receiving new version of a LSA\n"
2268 "Delay in milliseconds\n")
2270 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2271 ospf
->min_ls_arrival
= strtoul(argv
[argc
- 1]->arg
, NULL
, 10);
2275 DEFUN (no_ospf_timers_lsa_min_arrival
,
2276 no_ospf_timers_lsa_min_arrival_cmd
,
2277 "no timers lsa min-arrival [(0-600000)]",
2279 "Adjust routing timers\n"
2281 "Minimum delay in receiving new version of a LSA\n"
2282 "Delay in milliseconds\n")
2284 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2285 unsigned int minarrival
;
2288 minarrival
= strtoul(argv
[argc
- 1]->arg
, NULL
, 10);
2290 if (ospf
->min_ls_arrival
!= minarrival
2291 || minarrival
== OSPF_MIN_LS_ARRIVAL
)
2295 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2300 #if CONFDATE > 20180708
2301 CPP_NOTICE("ospf: `timers lsa arrival (0-1000)` deprecated 2017/07/08")
2303 ALIAS_HIDDEN (ospf_timers_lsa_min_arrival
,
2304 ospf_timers_lsa_arrival_cmd
,
2305 "timers lsa arrival (0-1000)",
2306 "adjust routing timers\n"
2307 "throttling link state advertisement delays\n"
2308 "ospf minimum arrival interval delay\n"
2309 "delay (msec) between accepted lsas\n");
2311 #if CONFDATE > 20180708
2312 CPP_NOTICE("ospf: `no timers lsa arrival (0-1000)` deprecated 2017/07/08")
2314 ALIAS_HIDDEN (no_ospf_timers_lsa_min_arrival
,
2315 no_ospf_timers_lsa_arrival_cmd
,
2316 "no timers lsa arrival (0-1000)",
2318 "adjust routing timers\n"
2319 "throttling link state advertisement delays\n"
2320 "ospf minimum arrival interval delay\n"
2321 "delay (msec) between accepted lsas\n");
2324 DEFUN (ospf_neighbor
,
2326 "neighbor A.B.C.D [priority (0-255) [poll-interval (1-65535)]]",
2328 "Neighbor IP address\n"
2329 "Neighbor Priority\n"
2331 "Dead Neighbor Polling interval\n"
2334 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2338 struct in_addr nbr_addr
;
2339 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2340 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2342 if (!inet_aton(argv
[idx_ipv4
]->arg
, &nbr_addr
)) {
2343 vty_out(vty
, "Please specify Neighbor ID by A.B.C.D\n");
2344 return CMD_WARNING_CONFIG_FAILED
;
2348 priority
= strtoul(argv
[idx_pri
]->arg
, NULL
, 10);
2351 interval
= strtoul(argv
[idx_poll
]->arg
, NULL
, 10);
2353 ospf_nbr_nbma_set(ospf
, nbr_addr
);
2356 ospf_nbr_nbma_priority_set(ospf
, nbr_addr
, priority
);
2359 ospf_nbr_nbma_poll_interval_set(ospf
, nbr_addr
, interval
);
2364 DEFUN (ospf_neighbor_poll_interval
,
2365 ospf_neighbor_poll_interval_cmd
,
2366 "neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2368 "Neighbor IP address\n"
2369 "Dead Neighbor Polling interval\n"
2371 "OSPF priority of non-broadcast neighbor\n"
2374 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2378 struct in_addr nbr_addr
;
2379 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2380 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2382 if (!inet_aton(argv
[idx_ipv4
]->arg
, &nbr_addr
)) {
2383 vty_out(vty
, "Please specify Neighbor ID by A.B.C.D\n");
2384 return CMD_WARNING_CONFIG_FAILED
;
2387 interval
= strtoul(argv
[idx_poll
]->arg
, NULL
, 10);
2390 priority
= strtoul(argv
[idx_pri
]->arg
, NULL
, 10);
2392 ospf_nbr_nbma_set(ospf
, nbr_addr
);
2393 ospf_nbr_nbma_poll_interval_set(ospf
, nbr_addr
, interval
);
2396 ospf_nbr_nbma_priority_set(ospf
, nbr_addr
, priority
);
2401 DEFUN (no_ospf_neighbor
,
2402 no_ospf_neighbor_cmd
,
2403 "no neighbor A.B.C.D [priority (0-255) [poll-interval (1-65525)]]",
2406 "Neighbor IP address\n"
2407 "Neighbor Priority\n"
2409 "Dead Neighbor Polling interval\n"
2412 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2414 struct in_addr nbr_addr
;
2416 if (!inet_aton(argv
[idx_ipv4
]->arg
, &nbr_addr
)) {
2417 vty_out(vty
, "Please specify Neighbor ID by A.B.C.D\n");
2418 return CMD_WARNING_CONFIG_FAILED
;
2421 (void)ospf_nbr_nbma_unset(ospf
, nbr_addr
);
2426 DEFUN (no_ospf_neighbor_poll
,
2427 no_ospf_neighbor_poll_cmd
,
2428 "no neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2431 "Neighbor IP address\n"
2432 "Dead Neighbor Polling interval\n"
2434 "Neighbor Priority\n"
2437 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2439 struct in_addr nbr_addr
;
2441 if (!inet_aton(argv
[idx_ipv4
]->arg
, &nbr_addr
)) {
2442 vty_out(vty
, "Please specify Neighbor ID by A.B.C.D\n");
2443 return CMD_WARNING_CONFIG_FAILED
;
2446 (void)ospf_nbr_nbma_unset(ospf
, nbr_addr
);
2451 DEFUN (ospf_refresh_timer
,
2452 ospf_refresh_timer_cmd
,
2453 "refresh timer (10-1800)",
2454 "Adjust refresh parameters\n"
2455 "Set refresh timer\n"
2456 "Timer value in seconds\n")
2458 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2460 unsigned int interval
;
2462 interval
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2463 interval
= (interval
/ OSPF_LSA_REFRESHER_GRANULARITY
)
2464 * OSPF_LSA_REFRESHER_GRANULARITY
;
2466 ospf_timers_refresh_set(ospf
, interval
);
2471 DEFUN (no_ospf_refresh_timer
,
2472 no_ospf_refresh_timer_val_cmd
,
2473 "no refresh timer [(10-1800)]",
2475 "Adjust refresh parameters\n"
2476 "Unset refresh timer\n"
2477 "Timer value in seconds\n")
2479 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2481 unsigned int interval
;
2484 interval
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2486 if (ospf
->lsa_refresh_interval
!= interval
2487 || interval
== OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
2491 ospf_timers_refresh_unset(ospf
);
2497 DEFUN (ospf_auto_cost_reference_bandwidth
,
2498 ospf_auto_cost_reference_bandwidth_cmd
,
2499 "auto-cost reference-bandwidth (1-4294967)",
2500 "Calculate OSPF interface cost according to bandwidth\n"
2501 "Use reference bandwidth method to assign OSPF cost\n"
2502 "The reference bandwidth in terms of Mbits per second\n")
2504 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2505 struct vrf
*vrf
= vrf_lookup_by_id(ospf
->vrf_id
);
2508 struct interface
*ifp
;
2510 refbw
= strtol(argv
[idx_number
]->arg
, NULL
, 10);
2511 if (refbw
< 1 || refbw
> 4294967) {
2512 vty_out(vty
, "reference-bandwidth value is invalid\n");
2513 return CMD_WARNING_CONFIG_FAILED
;
2516 /* If reference bandwidth is changed. */
2517 if ((refbw
) == ospf
->ref_bandwidth
)
2520 ospf
->ref_bandwidth
= refbw
;
2521 FOR_ALL_INTERFACES (vrf
, ifp
)
2522 ospf_if_recalculate_output_cost(ifp
);
2527 DEFUN (no_ospf_auto_cost_reference_bandwidth
,
2528 no_ospf_auto_cost_reference_bandwidth_cmd
,
2529 "no auto-cost reference-bandwidth [(1-4294967)]",
2531 "Calculate OSPF interface cost according to bandwidth\n"
2532 "Use reference bandwidth method to assign OSPF cost\n"
2533 "The reference bandwidth in terms of Mbits per second\n")
2535 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2536 struct vrf
*vrf
= vrf_lookup_by_id(ospf
->vrf_id
);
2537 struct interface
*ifp
;
2539 if (ospf
->ref_bandwidth
== OSPF_DEFAULT_REF_BANDWIDTH
)
2542 ospf
->ref_bandwidth
= OSPF_DEFAULT_REF_BANDWIDTH
;
2543 vty_out(vty
, "%% OSPF: Reference bandwidth is changed.\n");
2545 " Please ensure reference bandwidth is consistent across all routers\n");
2547 FOR_ALL_INTERFACES (vrf
, ifp
)
2548 ospf_if_recalculate_output_cost(ifp
);
2553 DEFUN (ospf_write_multiplier
,
2554 ospf_write_multiplier_cmd
,
2555 "ospf write-multiplier (1-100)",
2556 "OSPF specific commands\n"
2557 "Write multiplier\n"
2558 "Maximum number of interface serviced per write\n")
2560 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2562 u_int32_t write_oi_count
;
2569 write_oi_count
= strtol(argv
[idx_number
]->arg
, NULL
, 10);
2570 if (write_oi_count
< 1 || write_oi_count
> 100) {
2571 vty_out(vty
, "write-multiplier value is invalid\n");
2572 return CMD_WARNING_CONFIG_FAILED
;
2575 ospf
->write_oi_count
= write_oi_count
;
2579 ALIAS(ospf_write_multiplier
, write_multiplier_cmd
, "write-multiplier (1-100)",
2580 "Write multiplier\n"
2581 "Maximum number of interface serviced per write\n")
2583 DEFUN (no_ospf_write_multiplier
,
2584 no_ospf_write_multiplier_cmd
,
2585 "no ospf write-multiplier (1-100)",
2587 "OSPF specific commands\n"
2588 "Write multiplier\n"
2589 "Maximum number of interface serviced per write\n")
2591 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2593 ospf
->write_oi_count
= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
;
2597 ALIAS(no_ospf_write_multiplier
, no_write_multiplier_cmd
,
2598 "no write-multiplier (1-100)", NO_STR
2599 "Write multiplier\n"
2600 "Maximum number of interface serviced per write\n")
2602 const char *ospf_abr_type_descr_str
[] = {"Unknown", "Standard (RFC2328)",
2603 "Alternative IBM", "Alternative Cisco",
2604 "Alternative Shortcut"};
2606 const char *ospf_shortcut_mode_descr_str
[] = {"Default", "Enabled", "Disabled"};
2608 static void show_ip_ospf_area(struct vty
*vty
, struct ospf_area
*area
,
2609 json_object
*json_areas
, u_char use_json
)
2611 json_object
*json_area
= NULL
;
2614 json_area
= json_object_new_object();
2618 vty_out(vty
, " Area ID: %s", inet_ntoa(area
->area_id
));
2620 /* Show Area type/mode. */
2621 if (OSPF_IS_AREA_BACKBONE(area
)) {
2623 json_object_boolean_true_add(json_area
, "backbone");
2625 vty_out(vty
, " (Backbone)\n");
2628 if (area
->external_routing
== OSPF_AREA_STUB
) {
2629 if (area
->no_summary
)
2630 json_object_boolean_true_add(
2631 json_area
, "stubNoSummary");
2632 if (area
->shortcut_configured
)
2633 json_object_boolean_true_add(
2634 json_area
, "stubShortcut");
2635 } else if (area
->external_routing
== OSPF_AREA_NSSA
) {
2636 if (area
->no_summary
)
2637 json_object_boolean_true_add(
2638 json_area
, "nssaNoSummary");
2639 if (area
->shortcut_configured
)
2640 json_object_boolean_true_add(
2641 json_area
, "nssaShortcut");
2644 json_object_string_add(
2645 json_area
, "shortcuttingMode",
2646 ospf_shortcut_mode_descr_str
2647 [area
->shortcut_configured
]);
2648 if (area
->shortcut_capability
)
2649 json_object_boolean_true_add(json_area
,
2652 if (area
->external_routing
== OSPF_AREA_STUB
)
2653 vty_out(vty
, " (Stub%s%s)",
2654 area
->no_summary
? ", no summary" : "",
2655 area
->shortcut_configured
? "; " : "");
2656 else if (area
->external_routing
== OSPF_AREA_NSSA
)
2657 vty_out(vty
, " (NSSA%s%s)",
2658 area
->no_summary
? ", no summary" : "",
2659 area
->shortcut_configured
? "; " : "");
2662 vty_out(vty
, " Shortcutting mode: %s",
2663 ospf_shortcut_mode_descr_str
2664 [area
->shortcut_configured
]);
2665 vty_out(vty
, ", S-bit consensus: %s\n",
2666 area
->shortcut_capability
? "ok" : "no");
2670 /* Show number of interfaces */
2672 json_object_int_add(json_area
, "areaIfTotalCounter",
2673 listcount(area
->oiflist
));
2674 json_object_int_add(json_area
, "areaIfActiveCounter",
2678 " Number of interfaces in this area: Total: %d, "
2680 listcount(area
->oiflist
), area
->act_ints
);
2682 if (area
->external_routing
== OSPF_AREA_NSSA
) {
2684 json_object_boolean_true_add(json_area
, "nssa");
2685 if (!IS_OSPF_ABR(area
->ospf
))
2686 json_object_boolean_false_add(json_area
, "abr");
2687 else if (area
->NSSATranslatorState
) {
2688 json_object_boolean_true_add(json_area
, "abr");
2689 if (area
->NSSATranslatorRole
2690 == OSPF_NSSA_ROLE_CANDIDATE
)
2691 json_object_boolean_true_add(
2693 "nssaTranslatorElected");
2694 else if (area
->NSSATranslatorRole
2695 == OSPF_NSSA_ROLE_ALWAYS
)
2696 json_object_boolean_true_add(
2698 "nssaTranslatorAlways");
2700 json_object_boolean_true_add(json_area
, "abr");
2701 if (area
->NSSATranslatorRole
2702 == OSPF_NSSA_ROLE_CANDIDATE
)
2703 json_object_boolean_false_add(
2705 "nssaTranslatorElected");
2707 json_object_boolean_true_add(
2709 "nssaTranslatorNever");
2713 " It is an NSSA configuration. \n Elected NSSA/ABR performs type-7/type-5 LSA translation. \n");
2714 if (!IS_OSPF_ABR(area
->ospf
))
2716 " It is not ABR, therefore not Translator. \n");
2717 else if (area
->NSSATranslatorState
) {
2718 vty_out(vty
, " We are an ABR and ");
2719 if (area
->NSSATranslatorRole
2720 == OSPF_NSSA_ROLE_CANDIDATE
)
2722 "the NSSA Elected Translator. \n");
2723 else if (area
->NSSATranslatorRole
2724 == OSPF_NSSA_ROLE_ALWAYS
)
2726 "always an NSSA Translator. \n");
2728 vty_out(vty
, " We are an ABR, but ");
2729 if (area
->NSSATranslatorRole
2730 == OSPF_NSSA_ROLE_CANDIDATE
)
2732 "not the NSSA Elected Translator. \n");
2735 "never an NSSA Translator. \n");
2740 /* Stub-router state for this area */
2741 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
)) {
2742 char timebuf
[OSPF_TIME_DUMP_SIZE
];
2745 json_object_boolean_true_add(
2746 json_area
, "originStubMaxDistRouterLsa");
2747 if (CHECK_FLAG(area
->stub_router_state
,
2748 OSPF_AREA_ADMIN_STUB_ROUTED
))
2749 json_object_boolean_true_add(
2750 json_area
, "indefiniteActiveAdmin");
2751 if (area
->t_stub_router
) {
2755 &area
->t_stub_router
->u
.sands
,
2758 json_object_int_add(
2760 "activeStartupRemainderMsecs",
2765 " Originating stub / maximum-distance Router-LSA\n");
2766 if (CHECK_FLAG(area
->stub_router_state
,
2767 OSPF_AREA_ADMIN_STUB_ROUTED
))
2769 " Administratively activated (indefinitely)\n");
2770 if (area
->t_stub_router
)
2772 " Active from startup, %s remaining\n",
2773 ospf_timer_dump(area
->t_stub_router
,
2780 /* Show number of fully adjacent neighbors. */
2781 json_object_int_add(json_area
, "nbrFullAdjacentCounter",
2784 /* Show authentication type. */
2785 if (area
->auth_type
== OSPF_AUTH_NULL
)
2786 json_object_string_add(json_area
, "authentication",
2787 "authenticationNone");
2788 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
2789 json_object_string_add(json_area
, "authentication",
2790 "authenticationSimplePassword");
2791 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
2792 json_object_string_add(json_area
, "authentication",
2793 "authenticationMessageDigest");
2795 if (!OSPF_IS_AREA_BACKBONE(area
))
2796 json_object_int_add(json_area
,
2797 "virtualAdjacenciesPassingCounter",
2800 /* Show SPF calculation times. */
2801 json_object_int_add(json_area
, "spfExecutedCounter",
2802 area
->spf_calculation
);
2803 json_object_int_add(json_area
, "lsaNumber", area
->lsdb
->total
);
2804 json_object_int_add(
2805 json_area
, "lsaRouterNumber",
2806 ospf_lsdb_count(area
->lsdb
, OSPF_ROUTER_LSA
));
2807 json_object_int_add(
2808 json_area
, "lsaRouterChecksum",
2809 ospf_lsdb_checksum(area
->lsdb
, OSPF_ROUTER_LSA
));
2810 json_object_int_add(
2811 json_area
, "lsaNetworkNumber",
2812 ospf_lsdb_count(area
->lsdb
, OSPF_NETWORK_LSA
));
2813 json_object_int_add(
2814 json_area
, "lsaNetworkChecksum",
2815 ospf_lsdb_checksum(area
->lsdb
, OSPF_NETWORK_LSA
));
2816 json_object_int_add(
2817 json_area
, "lsaSummaryNumber",
2818 ospf_lsdb_count(area
->lsdb
, OSPF_SUMMARY_LSA
));
2819 json_object_int_add(
2820 json_area
, "lsaSummaryChecksum",
2821 ospf_lsdb_checksum(area
->lsdb
, OSPF_SUMMARY_LSA
));
2822 json_object_int_add(
2823 json_area
, "lsaAsbrNumber",
2824 ospf_lsdb_count(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2825 json_object_int_add(
2826 json_area
, "lsaAsbrChecksum",
2827 ospf_lsdb_checksum(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2828 json_object_int_add(
2829 json_area
, "lsaNssaNumber",
2830 ospf_lsdb_count(area
->lsdb
, OSPF_AS_NSSA_LSA
));
2831 json_object_int_add(
2832 json_area
, "lsaNssaChecksum",
2833 ospf_lsdb_checksum(area
->lsdb
, OSPF_AS_NSSA_LSA
));
2835 /* Show number of fully adjacent neighbors. */
2837 " Number of fully adjacent neighbors in this area:"
2841 /* Show authentication type. */
2842 vty_out(vty
, " Area has ");
2843 if (area
->auth_type
== OSPF_AUTH_NULL
)
2844 vty_out(vty
, "no authentication\n");
2845 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
2846 vty_out(vty
, "simple password authentication\n");
2847 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
2848 vty_out(vty
, "message digest authentication\n");
2850 if (!OSPF_IS_AREA_BACKBONE(area
))
2852 " Number of full virtual adjacencies going through"
2856 /* Show SPF calculation times. */
2857 vty_out(vty
, " SPF algorithm executed %d times\n",
2858 area
->spf_calculation
);
2860 /* Show number of LSA. */
2861 vty_out(vty
, " Number of LSA %ld\n", area
->lsdb
->total
);
2863 " Number of router LSA %ld. Checksum Sum 0x%08x\n",
2864 ospf_lsdb_count(area
->lsdb
, OSPF_ROUTER_LSA
),
2865 ospf_lsdb_checksum(area
->lsdb
, OSPF_ROUTER_LSA
));
2867 " Number of network LSA %ld. Checksum Sum 0x%08x\n",
2868 ospf_lsdb_count(area
->lsdb
, OSPF_NETWORK_LSA
),
2869 ospf_lsdb_checksum(area
->lsdb
, OSPF_NETWORK_LSA
));
2871 " Number of summary LSA %ld. Checksum Sum 0x%08x\n",
2872 ospf_lsdb_count(area
->lsdb
, OSPF_SUMMARY_LSA
),
2873 ospf_lsdb_checksum(area
->lsdb
, OSPF_SUMMARY_LSA
));
2875 " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x\n",
2876 ospf_lsdb_count(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
),
2877 ospf_lsdb_checksum(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2878 vty_out(vty
, " Number of NSSA LSA %ld. Checksum Sum 0x%08x\n",
2879 ospf_lsdb_count(area
->lsdb
, OSPF_AS_NSSA_LSA
),
2880 ospf_lsdb_checksum(area
->lsdb
, OSPF_AS_NSSA_LSA
));
2884 json_object_int_add(
2885 json_area
, "lsaOpaqueLinkNumber",
2886 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
2887 json_object_int_add(
2888 json_area
, "lsaOpaqueLinkChecksum",
2889 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
2890 json_object_int_add(
2891 json_area
, "lsaOpaqueAreaNumber",
2892 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
2893 json_object_int_add(
2894 json_area
, "lsaOpaqueAreaChecksum",
2895 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
2898 " Number of opaque link LSA %ld. Checksum Sum 0x%08x\n",
2899 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
),
2900 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
2902 " Number of opaque area LSA %ld. Checksum Sum 0x%08x\n",
2903 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
),
2904 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
2908 json_object_object_add(json_areas
, inet_ntoa(area
->area_id
),
2914 static int show_ip_ospf_common(struct vty
*vty
, struct ospf
*ospf
,
2915 json_object
*json
, u_char use_vrf
)
2917 struct listnode
*node
, *nnode
;
2918 struct ospf_area
*area
;
2919 struct timeval result
;
2920 char timebuf
[OSPF_TIME_DUMP_SIZE
];
2921 json_object
*json_vrf
= NULL
;
2922 json_object
*json_areas
= NULL
;
2926 json_vrf
= json_object_new_object();
2929 json_areas
= json_object_new_object();
2932 if (ospf
->instance
) {
2934 json_object_int_add(json
, "ospfInstance",
2937 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
2941 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
2943 /* Show Router ID. */
2945 json_object_string_add(json_vrf
, "routerId",
2946 inet_ntoa(ospf
->router_id
));
2948 vty_out(vty
, " OSPF Routing Process, Router ID: %s\n",
2949 inet_ntoa(ospf
->router_id
));
2952 /* Graceful shutdown */
2953 if (ospf
->t_deferred_shutdown
) {
2958 &ospf
->t_deferred_shutdown
->u
.sands
,
2961 json_object_int_add(json_vrf
, "deferredShutdownMsecs",
2965 " Deferred shutdown in progress, %s remaining\n",
2966 ospf_timer_dump(ospf
->t_deferred_shutdown
,
2967 timebuf
, sizeof(timebuf
)));
2971 /* Show capability. */
2973 json_object_boolean_true_add(json_vrf
, "tosRoutesOnly");
2974 json_object_boolean_true_add(json_vrf
, "rfc2328Conform");
2975 if (CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)) {
2976 json_object_boolean_true_add(json_vrf
,
2977 "rfc1583Compatibility");
2980 vty_out(vty
, " Supports only single TOS (TOS0) routes\n");
2981 vty_out(vty
, " This implementation conforms to RFC2328\n");
2982 vty_out(vty
, " RFC1583Compatibility flag is %s\n",
2983 CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)
2989 if (CHECK_FLAG(ospf
->config
, OSPF_OPAQUE_CAPABLE
)) {
2990 json_object_boolean_true_add(json_vrf
, "opaqueCapable");
2993 vty_out(vty
, " OpaqueCapability flag is %s\n",
2994 CHECK_FLAG(ospf
->config
, OSPF_OPAQUE_CAPABLE
)
2999 /* Show stub-router configuration */
3000 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
3001 || ospf
->stub_router_shutdown_time
3002 != OSPF_STUB_ROUTER_UNCONFIGURED
) {
3004 json_object_boolean_true_add(json_vrf
,
3005 "stubAdvertisement");
3006 if (ospf
->stub_router_startup_time
3007 != OSPF_STUB_ROUTER_UNCONFIGURED
)
3008 json_object_int_add(
3009 json_vrf
, "postStartEnabledMsecs",
3010 ospf
->stub_router_startup_time
/ 1000);
3011 if (ospf
->stub_router_shutdown_time
3012 != OSPF_STUB_ROUTER_UNCONFIGURED
)
3013 json_object_int_add(
3014 json_vrf
, "preShutdownEnabledMsecs",
3015 ospf
->stub_router_shutdown_time
/ 1000);
3018 " Stub router advertisement is configured\n");
3019 if (ospf
->stub_router_startup_time
3020 != OSPF_STUB_ROUTER_UNCONFIGURED
)
3022 " Enabled for %us after start-up\n",
3023 ospf
->stub_router_startup_time
);
3024 if (ospf
->stub_router_shutdown_time
3025 != OSPF_STUB_ROUTER_UNCONFIGURED
)
3027 " Enabled for %us prior to full shutdown\n",
3028 ospf
->stub_router_shutdown_time
);
3032 /* Show SPF timers. */
3034 json_object_int_add(json_vrf
, "spfScheduleDelayMsecs",
3036 json_object_int_add(json_vrf
, "holdtimeMinMsecs",
3037 ospf
->spf_holdtime
);
3038 json_object_int_add(json_vrf
, "holdtimeMaxMsecs",
3039 ospf
->spf_max_holdtime
);
3040 json_object_int_add(json_vrf
, "holdtimeMultplier",
3041 ospf
->spf_hold_multiplier
);
3044 " Initial SPF scheduling delay %d millisec(s)\n"
3045 " Minimum hold time between consecutive SPFs %d millisec(s)\n"
3046 " Maximum hold time between consecutive SPFs %d millisec(s)\n"
3047 " Hold time multiplier is currently %d\n",
3048 ospf
->spf_delay
, ospf
->spf_holdtime
,
3049 ospf
->spf_max_holdtime
, ospf
->spf_hold_multiplier
);
3053 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
) {
3054 long time_store
= 0;
3057 monotime_since(&ospf
->ts_spf
, NULL
) / 1000LL;
3058 json_object_int_add(json_vrf
, "spfLastExecutedMsecs",
3061 time_store
= (1000 * ospf
->ts_spf_duration
.tv_sec
)
3062 + (ospf
->ts_spf_duration
.tv_usec
/ 1000);
3063 json_object_int_add(json_vrf
, "spfLastDurationMsecs",
3066 json_object_boolean_true_add(json_vrf
, "spfHasNotRun");
3068 vty_out(vty
, " SPF algorithm ");
3069 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
) {
3070 monotime_since(&ospf
->ts_spf
, &result
);
3071 vty_out(vty
, "last executed %s ago\n",
3072 ospf_timeval_dump(&result
, timebuf
,
3074 vty_out(vty
, " Last SPF duration %s\n",
3075 ospf_timeval_dump(&ospf
->ts_spf_duration
,
3076 timebuf
, sizeof(timebuf
)));
3078 vty_out(vty
, "has not been run\n");
3082 if (ospf
->t_spf_calc
) {
3085 monotime_until(&ospf
->t_spf_calc
->u
.sands
, NULL
)
3087 json_object_int_add(json_vrf
, "spfTimerDueInMsecs",
3091 json_object_int_add(json_vrf
, "lsaMinIntervalMsecs",
3092 ospf
->min_ls_interval
);
3093 json_object_int_add(json_vrf
, "lsaMinArrivalMsecs",
3094 ospf
->min_ls_arrival
);
3095 /* Show write multiplier values */
3096 json_object_int_add(json_vrf
, "writeMultiplier",
3097 ospf
->write_oi_count
);
3098 /* Show refresh parameters. */
3099 json_object_int_add(json_vrf
, "refreshTimerMsecs",
3100 ospf
->lsa_refresh_interval
* 1000);
3102 vty_out(vty
, " SPF timer %s%s\n",
3103 (ospf
->t_spf_calc
? "due in " : "is "),
3104 ospf_timer_dump(ospf
->t_spf_calc
, timebuf
,
3107 vty_out(vty
, " LSA minimum interval %d msecs\n",
3108 ospf
->min_ls_interval
);
3109 vty_out(vty
, " LSA minimum arrival %d msecs\n",
3110 ospf
->min_ls_arrival
);
3112 /* Show write multiplier values */
3113 vty_out(vty
, " Write Multiplier set to %d \n",
3114 ospf
->write_oi_count
);
3116 /* Show refresh parameters. */
3117 vty_out(vty
, " Refresh timer %d secs\n",
3118 ospf
->lsa_refresh_interval
);
3121 /* Show ABR/ASBR flags. */
3122 if (CHECK_FLAG(ospf
->flags
, OSPF_FLAG_ABR
)) {
3124 json_object_string_add(
3125 json_vrf
, "abrType",
3126 ospf_abr_type_descr_str
[ospf
->abr_type
]);
3129 " This router is an ABR, ABR type is: %s\n",
3130 ospf_abr_type_descr_str
[ospf
->abr_type
]);
3132 if (CHECK_FLAG(ospf
->flags
, OSPF_FLAG_ASBR
)) {
3134 json_object_string_add(
3135 json_vrf
, "asbrRouter",
3136 "injectingExternalRoutingInformation");
3139 " This router is an ASBR "
3140 "(injecting external routing information)\n");
3143 /* Show Number of AS-external-LSAs. */
3145 json_object_int_add(
3146 json_vrf
, "lsaExternalCounter",
3147 ospf_lsdb_count(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3148 json_object_int_add(
3149 json_vrf
, "lsaExternalChecksum",
3150 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3153 " Number of external LSA %ld. Checksum Sum 0x%08x\n",
3154 ospf_lsdb_count(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
),
3155 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3159 json_object_int_add(
3160 json_vrf
, "lsaAsopaqueCounter",
3161 ospf_lsdb_count(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3162 json_object_int_add(
3163 json_vrf
, "lsaAsOpaqueChecksum",
3164 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3167 " Number of opaque AS LSA %ld. Checksum Sum 0x%08x\n",
3168 ospf_lsdb_count(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
),
3169 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3172 /* Show number of areas attached. */
3174 json_object_int_add(json_vrf
, "attachedAreaCounter",
3175 listcount(ospf
->areas
));
3177 vty_out(vty
, " Number of areas attached to this router: %d\n",
3178 listcount(ospf
->areas
));
3180 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
)) {
3181 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
)) {
3183 json_object_boolean_true_add(
3184 json_vrf
, "adjacencyChangesLoggedAll");
3187 " All adjacency changes are logged\n");
3190 json_object_boolean_true_add(
3191 json_vrf
, "adjacencyChangesLogged");
3193 vty_out(vty
, " Adjacency changes are logged\n");
3196 /* Show each area status. */
3197 for (ALL_LIST_ELEMENTS(ospf
->areas
, node
, nnode
, area
))
3198 show_ip_ospf_area(vty
, area
, json_areas
, json
? 1 : 0);
3202 json_object_object_add(json_vrf
, "areas", json_areas
);
3203 if (ospf
->vrf_id
== VRF_DEFAULT
)
3204 json_object_object_add(json
, "default",
3207 json_object_object_add(json
, ospf
->name
,
3210 json_object_object_add(json
, "areas", json_areas
);
3218 DEFUN (show_ip_ospf
,
3220 "show ip ospf [vrf <NAME|all>] [json]",
3223 "OSPF information\n"
3229 u_char uj
= use_json(argc
, argv
);
3230 struct listnode
*node
= NULL
;
3231 char *vrf_name
= NULL
;
3232 bool all_vrf
= FALSE
;
3233 int ret
= CMD_SUCCESS
;
3236 json_object
*json
= NULL
;
3239 if (listcount(om
->ospf
) == 0)
3242 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
3245 json
= json_object_new_object();
3247 /* vrf input is provided could be all or specific vrf*/
3251 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
3252 if (!ospf
->oi_running
)
3254 ret
= show_ip_ospf_common(vty
, ospf
, json
,
3258 vty_out(vty
, "%s\n",
3259 json_object_to_json_string_ext(json
,
3260 JSON_C_TO_STRING_PRETTY
));
3261 json_object_free(json
);
3265 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
3266 if ((ospf
== NULL
) || !ospf
->oi_running
) {
3268 json_object_free(json
);
3272 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
3273 /* Display default ospf (instance 0) info */
3274 if (ospf
== NULL
|| !ospf
->oi_running
) {
3276 json_object_free(json
);
3282 show_ip_ospf_common(vty
, ospf
, json
, use_vrf
);
3284 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
3285 json
, JSON_C_TO_STRING_PRETTY
));
3289 json_object_free(json
);
3294 DEFUN (show_ip_ospf_instance
,
3295 show_ip_ospf_instance_cmd
,
3296 "show ip ospf (1-65535) [json]",
3299 "OSPF information\n"
3305 u_short instance
= 0;
3306 u_char uj
= use_json(argc
, argv
);
3307 int ret
= CMD_SUCCESS
;
3308 json_object
*json
= NULL
;
3310 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3311 ospf
= ospf_lookup_instance(instance
);
3313 return CMD_NOT_MY_INSTANCE
;
3315 if (!ospf
->oi_running
)
3319 json
= json_object_new_object();
3321 ret
= show_ip_ospf_common(vty
, ospf
, json
, 0);
3324 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
3325 JSON_C_TO_STRING_PRETTY
));
3326 json_object_free(json
);
3332 static void show_ip_ospf_interface_sub(struct vty
*vty
, struct ospf
*ospf
,
3333 struct interface
*ifp
,
3334 json_object
*json_interface_sub
,
3338 struct ospf_neighbor
*nbr
;
3339 struct route_node
*rn
;
3340 uint32_t bandwidth
= ifp
->bandwidth
? ifp
->bandwidth
: ifp
->speed
;
3342 /* Is interface up? */
3344 is_up
= if_is_operative(ifp
);
3346 json_object_boolean_true_add(json_interface_sub
,
3349 json_object_boolean_false_add(json_interface_sub
,
3352 json_object_int_add(json_interface_sub
, "ifIndex",
3354 json_object_int_add(json_interface_sub
, "mtuBytes", ifp
->mtu
);
3355 json_object_int_add(json_interface_sub
, "bandwidthMbit",
3357 json_object_string_add(json_interface_sub
, "ifFlags",
3358 if_flag_dump(ifp
->flags
));
3360 vty_out(vty
, "%s is %s\n", ifp
->name
,
3361 ((is_up
= if_is_operative(ifp
)) ? "up" : "down"));
3362 vty_out(vty
, " ifindex %u, MTU %u bytes, BW %u Mbit %s\n",
3363 ifp
->ifindex
, ifp
->mtu
, bandwidth
,
3364 if_flag_dump(ifp
->flags
));
3367 /* Is interface OSPF enabled? */
3369 if (ospf_oi_count(ifp
) == 0) {
3370 json_object_boolean_false_add(json_interface_sub
,
3373 } else if (!is_up
) {
3374 json_object_boolean_false_add(json_interface_sub
,
3378 json_object_boolean_true_add(json_interface_sub
,
3381 if (ospf_oi_count(ifp
) == 0) {
3382 vty_out(vty
, " OSPF not enabled on this interface\n");
3384 } else if (!is_up
) {
3386 " OSPF is enabled, but not running on this interface\n");
3391 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
3392 struct ospf_interface
*oi
= rn
->info
;
3397 if (CHECK_FLAG(oi
->connected
->flags
, ZEBRA_IFA_UNNUMBERED
)) {
3399 json_object_boolean_true_add(json_interface_sub
,
3402 vty_out(vty
, " This interface is UNNUMBERED,");
3404 /* Show OSPF interface information. */
3406 json_object_string_add(
3407 json_interface_sub
, "ipAddress",
3408 inet_ntoa(oi
->address
->u
.prefix4
));
3409 json_object_int_add(json_interface_sub
,
3410 "ipAddressPrefixlen",
3411 oi
->address
->prefixlen
);
3413 vty_out(vty
, " Internet Address %s/%d,",
3414 inet_ntoa(oi
->address
->u
.prefix4
),
3415 oi
->address
->prefixlen
);
3417 if (oi
->connected
->destination
3418 || oi
->type
== OSPF_IFTYPE_VIRTUALLINK
) {
3419 struct in_addr
*dest
;
3422 if (CONNECTED_PEER(oi
->connected
)
3423 || oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3428 /* For Vlinks, showing the peer address is
3430 * * * * * informative than the local
3431 * interface that is being used
3433 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3434 dest
= &oi
->vl_data
->peer_addr
;
3436 dest
= &oi
->connected
->destination
->u
3440 json_object_string_add(
3442 "ospfIfType", dstr
);
3443 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3444 json_object_string_add(
3449 json_object_string_add(
3454 vty_out(vty
, " %s %s,", dstr
,
3459 json_object_string_add(json_interface_sub
, "area",
3460 ospf_area_desc_string(oi
->area
));
3461 if (OSPF_IF_PARAM(oi
, mtu_ignore
))
3462 json_object_boolean_true_add(
3464 "mtuMismatchDetect");
3465 json_object_string_add(json_interface_sub
, "routerId",
3466 inet_ntoa(ospf
->router_id
));
3467 json_object_string_add(json_interface_sub
,
3469 ospf_network_type_str
[oi
->type
]);
3470 json_object_int_add(json_interface_sub
, "cost",
3472 json_object_int_add(
3473 json_interface_sub
, "transmitDelayMsecs",
3474 1000 / OSPF_IF_PARAM(oi
, transmit_delay
));
3475 json_object_string_add(json_interface_sub
, "state",
3476 lookup_msg(ospf_ism_state_msg
,
3478 json_object_int_add(json_interface_sub
, "priority",
3481 vty_out(vty
, " Area %s\n",
3482 ospf_area_desc_string(oi
->area
));
3484 vty_out(vty
, " MTU mismatch detection: %s\n",
3485 OSPF_IF_PARAM(oi
, mtu_ignore
) ? "disabled"
3489 " Router ID %s, Network Type %s, Cost: %d\n",
3490 inet_ntoa(ospf
->router_id
),
3491 ospf_network_type_str
[oi
->type
],
3495 " Transmit Delay is %d sec, State %s, Priority %d\n",
3496 OSPF_IF_PARAM(oi
, transmit_delay
),
3497 lookup_msg(ospf_ism_state_msg
, oi
->state
, NULL
),
3501 /* Show DR information. */
3502 if (DR(oi
).s_addr
== 0) {
3505 " No backup designated router on this network\n");
3507 nbr
= ospf_nbr_lookup_by_addr(oi
->nbrs
, &BDR(oi
));
3511 " No backup designated router on this network\n");
3514 json_object_string_add(
3515 json_interface_sub
, "bdrId",
3516 inet_ntoa(nbr
->router_id
));
3517 json_object_string_add(
3520 inet_ntoa(nbr
->address
.u
3524 " Backup Designated Router (ID) %s,",
3525 inet_ntoa(nbr
->router_id
));
3526 vty_out(vty
, " Interface Address %s\n",
3527 inet_ntoa(nbr
->address
.u
3533 /* Next network-LSA sequence number we'll use, if we're elected
3536 && ntohl(oi
->params
->network_lsa_seqnum
)
3537 != OSPF_INITIAL_SEQUENCE_NUMBER
) {
3539 json_object_int_add(
3541 "networkLsaSequence",
3542 ntohl(oi
->params
->network_lsa_seqnum
));
3545 " Saved Network-LSA sequence number 0x%x\n",
3546 ntohl(oi
->params
->network_lsa_seqnum
));
3550 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3551 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
)) {
3552 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3553 json_object_boolean_true_add(
3555 "mcastMemberOspfAllRouters");
3556 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3557 json_object_boolean_true_add(
3559 "mcastMemberOspfDesignatedRouters");
3562 vty_out(vty
, " Multicast group memberships:");
3563 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3564 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
)) {
3565 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3566 vty_out(vty
, " OSPFAllRouters");
3567 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3568 vty_out(vty
, " OSPFDesignatedRouters");
3570 vty_out(vty
, " <None>");
3575 if (OSPF_IF_PARAM(oi
, fast_hello
) == 0)
3576 json_object_int_add(
3577 json_interface_sub
, "timerMsecs",
3578 1000 / OSPF_IF_PARAM(oi
, v_hello
));
3580 json_object_int_add(
3581 json_interface_sub
, "timerMsecs",
3582 1000 / OSPF_IF_PARAM(oi
, fast_hello
));
3583 json_object_int_add(json_interface_sub
,
3585 1000 / OSPF_IF_PARAM(oi
, v_wait
));
3586 json_object_int_add(json_interface_sub
,
3588 1000 / OSPF_IF_PARAM(oi
, v_wait
));
3589 json_object_int_add(
3590 json_interface_sub
, "timerRetransmit",
3591 1000 / OSPF_IF_PARAM(oi
, retransmit_interval
));
3593 vty_out(vty
, " Timer intervals configured,");
3594 vty_out(vty
, " Hello ");
3595 if (OSPF_IF_PARAM(oi
, fast_hello
) == 0)
3596 vty_out(vty
, "%ds,",
3597 OSPF_IF_PARAM(oi
, v_hello
));
3599 vty_out(vty
, "%dms,",
3600 1000 / OSPF_IF_PARAM(oi
, fast_hello
));
3601 vty_out(vty
, " Dead %ds, Wait %ds, Retransmit %d\n",
3602 OSPF_IF_PARAM(oi
, v_wait
),
3603 OSPF_IF_PARAM(oi
, v_wait
),
3604 OSPF_IF_PARAM(oi
, retransmit_interval
));
3607 if (OSPF_IF_PASSIVE_STATUS(oi
) == OSPF_IF_ACTIVE
) {
3608 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3610 long time_store
= 0;
3614 &oi
->t_hello
->u
.sands
,
3617 json_object_int_add(json_interface_sub
,
3618 "timerHelloInMsecs",
3621 vty_out(vty
, " Hello due in %s\n",
3622 ospf_timer_dump(oi
->t_hello
, timebuf
,
3624 } else /* passive-interface is set */
3627 json_object_boolean_true_add(
3629 "timerPassiveIface");
3632 " No Hellos (Passive interface)\n");
3636 json_object_int_add(json_interface_sub
, "nbrCount",
3637 ospf_nbr_count(oi
, 0));
3638 json_object_int_add(json_interface_sub
,
3640 ospf_nbr_count(oi
, NSM_Full
));
3643 " Neighbor Count is %d, Adjacent neighbor count is %d\n",
3644 ospf_nbr_count(oi
, 0),
3645 ospf_nbr_count(oi
, NSM_Full
));
3646 ospf_bfd_interface_show(vty
, ifp
, json_interface_sub
, use_json
);
3650 static int show_ip_ospf_interface_common(struct vty
*vty
, struct ospf
*ospf
,
3651 char *intf_name
, u_char use_vrf
,
3652 json_object
*json
, u_char use_json
)
3654 struct interface
*ifp
;
3655 struct vrf
*vrf
= vrf_lookup_by_id(ospf
->vrf_id
);
3656 json_object
*json_vrf
= NULL
;
3657 json_object
*json_interface_sub
= NULL
;
3661 json_vrf
= json_object_new_object();
3666 if (ospf
->instance
) {
3668 json_object_int_add(json
, "ospfInstance",
3671 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
3674 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
3676 if (intf_name
== NULL
) {
3677 /* Show All Interfaces.*/
3678 FOR_ALL_INTERFACES (vrf
, ifp
) {
3679 if (ospf_oi_count(ifp
)) {
3681 json_interface_sub
=
3682 json_object_new_object();
3684 show_ip_ospf_interface_sub(vty
, ospf
, ifp
,
3689 json_object_object_add(
3690 json_vrf
, ifp
->name
,
3691 json_interface_sub
);
3695 /* Interface name is specified. */
3696 ifp
= if_lookup_by_name(intf_name
, ospf
->vrf_id
);
3699 json_object_boolean_true_add(json_vrf
,
3702 vty_out(vty
, "No such interface name\n");
3705 json_interface_sub
= json_object_new_object();
3707 show_ip_ospf_interface_sub(
3708 vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3711 json_object_object_add(json_vrf
, ifp
->name
,
3712 json_interface_sub
);
3718 if (ospf
->vrf_id
== VRF_DEFAULT
)
3719 json_object_object_add(json
, "default",
3722 json_object_object_add(json
, ospf
->name
,
3731 static void show_ip_ospf_interface_traffic_sub(struct vty
*vty
,
3732 struct ospf_interface
*oi
,
3733 json_object
*json_interface_sub
,
3737 json_object_int_add(json_interface_sub
,
3740 json_object_int_add(json_interface_sub
,
3743 json_object_int_add(json_interface_sub
,
3746 json_object_int_add(json_interface_sub
,
3749 json_object_int_add(json_interface_sub
,
3752 json_object_int_add(json_interface_sub
,
3755 json_object_int_add(json_interface_sub
,
3758 json_object_int_add(json_interface_sub
,
3761 json_object_int_add(json_interface_sub
,
3764 json_object_int_add(json_interface_sub
,
3767 json_object_int_add(json_interface_sub
,
3772 "%-10s %8u/%-8u %7u/%-7u %7u/%-7u %7u/%-7u %7u/%-7u\n",
3773 oi
->ifp
->name
, oi
->hello_in
,
3775 oi
->db_desc_in
, oi
->db_desc_out
,
3776 oi
->ls_req_in
, oi
->ls_req_out
,
3777 oi
->ls_upd_in
, oi
->ls_upd_out
,
3778 oi
->ls_ack_in
, oi
->ls_ack_out
);
3782 /* OSPFv2 Packet Counters */
3783 static int show_ip_ospf_interface_traffic_common(struct vty
*vty
,
3791 struct vrf
*vrf
= NULL
;
3792 struct interface
*ifp
= NULL
;
3793 json_object
*json_vrf
= NULL
;
3794 json_object
*json_interface_sub
= NULL
;
3796 if (!use_json
&& !display_once
) {
3798 vty_out(vty
, "%-12s%-17s%-17s%-17s%-17s%-17s\n",
3799 "Interface", " HELLO", " DB-Desc", " LS-Req",
3800 " LS-Update", " LS-Ack");
3801 vty_out(vty
, "%-10s%-18s%-18s%-17s%-17s%-17s\n", "",
3802 " Rx/Tx", " Rx/Tx", " Rx/Tx", " Rx/Tx", " Rx/Tx");
3804 "--------------------------------------------------------------------------------------------\n");
3805 } else if (use_json
) {
3807 json_vrf
= json_object_new_object();
3812 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
3814 if (intf_name
== NULL
) {
3815 vrf
= vrf_lookup_by_id(ospf
->vrf_id
);
3816 FOR_ALL_INTERFACES (vrf
, ifp
) {
3817 struct route_node
*rn
;
3818 struct ospf_interface
*oi
;
3820 if (ospf_oi_count(ifp
) == 0)
3823 for (rn
= route_top(IF_OIFS(ifp
)); rn
;
3824 rn
= route_next(rn
)) {
3831 json_interface_sub
=
3832 json_object_new_object();
3835 show_ip_ospf_interface_traffic_sub(vty
, oi
,
3839 json_object_object_add(json_vrf
,
3841 json_interface_sub
);
3846 /* Interface name is specified. */
3847 ifp
= if_lookup_by_name(intf_name
, ospf
->vrf_id
);
3849 struct route_node
*rn
;
3850 struct ospf_interface
*oi
;
3852 if (ospf_oi_count(ifp
) == 0) {
3853 vty_out(vty
, " OSPF not enabled on this interface %s\n",
3858 for (rn
= route_top(IF_OIFS(ifp
)); rn
;
3859 rn
= route_next(rn
)) {
3863 json_interface_sub
=
3864 json_object_new_object();
3867 show_ip_ospf_interface_traffic_sub(vty
, oi
,
3871 json_object_object_add(json_vrf
,
3873 json_interface_sub
);
3881 if (ospf
->vrf_id
== VRF_DEFAULT
)
3882 json_object_object_add(json
, "default",
3885 json_object_object_add(json
, ospf
->name
,
3894 DEFUN (show_ip_ospf_interface
,
3895 show_ip_ospf_interface_cmd
,
3896 "show ip ospf [vrf <NAME|all>] interface [INTERFACE] [json]",
3899 "OSPF information\n"
3902 "Interface information\n"
3907 u_char uj
= use_json(argc
, argv
);
3908 struct listnode
*node
= NULL
;
3909 char *vrf_name
= NULL
, *intf_name
= NULL
;
3910 bool all_vrf
= FALSE
;
3911 int ret
= CMD_SUCCESS
;
3913 int idx_vrf
= 0, idx_intf
= 0;
3915 json_object
*json
= NULL
;
3917 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
3919 if (argv_find(argv
, argc
, "INTERFACE", &idx_intf
))
3920 intf_name
= argv
[idx_intf
]->arg
;
3923 json
= json_object_new_object();
3925 /* vrf input is provided could be all or specific vrf*/
3929 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
3930 if (!ospf
->oi_running
)
3932 ret
= show_ip_ospf_interface_common(vty
,
3941 vty_out(vty
, "%s\n",
3942 json_object_to_json_string_ext(json
,
3943 JSON_C_TO_STRING_PRETTY
));
3944 json_object_free(json
);
3949 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
3950 if (ospf
== NULL
|| !ospf
->oi_running
) {
3952 json_object_free(json
);
3955 ret
= show_ip_ospf_interface_common(vty
, ospf
, intf_name
,
3959 /* Display default ospf (instance 0) info */
3960 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
3961 if (ospf
== NULL
|| !ospf
->oi_running
) {
3963 json_object_free(json
);
3966 ret
= show_ip_ospf_interface_common(vty
, ospf
, intf_name
,
3971 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
3972 JSON_C_TO_STRING_PRETTY
));
3973 json_object_free(json
);
3979 DEFUN (show_ip_ospf_instance_interface
,
3980 show_ip_ospf_instance_interface_cmd
,
3981 "show ip ospf (1-65535) interface [INTERFACE] [json]",
3984 "OSPF information\n"
3986 "Interface information\n"
3993 u_short instance
= 0;
3994 u_char uj
= use_json(argc
, argv
);
3995 char *intf_name
= NULL
;
3996 int ret
= CMD_SUCCESS
;
3997 json_object
*json
= NULL
;
3999 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4000 ospf
= ospf_lookup_instance(instance
);
4002 return CMD_NOT_MY_INSTANCE
;
4004 if (!ospf
->oi_running
)
4008 json
= json_object_new_object();
4010 if (argv_find(argv
, argc
, "INTERFACE", &idx_intf
))
4011 intf_name
= argv
[idx_intf
]->arg
;
4013 ret
= show_ip_ospf_interface_common(vty
, ospf
, intf_name
, 0, json
, uj
);
4016 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
4017 JSON_C_TO_STRING_PRETTY
));
4018 json_object_free(json
);
4024 DEFUN (show_ip_ospf_interface_traffic
,
4025 show_ip_ospf_interface_traffic_cmd
,
4026 "show ip ospf [vrf <NAME|all>] interface traffic [INTERFACE] [json]",
4029 "OSPF information\n"
4032 "Interface information\n"
4033 "Protocol Packet counters\n"
4037 struct ospf
*ospf
= NULL
;
4038 struct listnode
*node
= NULL
;
4039 char *vrf_name
= NULL
, *intf_name
= NULL
;
4040 bool all_vrf
= FALSE
;
4042 int idx_vrf
= 0, idx_intf
= 0;
4043 u_char uj
= use_json(argc
, argv
);
4044 json_object
*json
= NULL
;
4045 int ret
= CMD_SUCCESS
;
4046 int display_once
= 0;
4049 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
4051 if (argv_find(argv
, argc
, "INTERFACE", &idx_intf
))
4052 intf_name
= argv
[idx_intf
]->arg
;
4055 json
= json_object_new_object();
4060 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
4061 if (!ospf
->oi_running
)
4064 ret
= show_ip_ospf_interface_traffic_common(vty
,
4074 vty_out(vty
, "%s\n",
4075 json_object_to_json_string_ext(json
,
4076 JSON_C_TO_STRING_PRETTY
));
4077 json_object_free(json
);
4082 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
4083 if (ospf
== NULL
|| !ospf
->oi_running
) {
4085 json_object_free(json
);
4089 ret
= show_ip_ospf_interface_traffic_common(vty
, ospf
,
4094 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
4095 if (ospf
== NULL
|| !ospf
->oi_running
) {
4097 json_object_free(json
);
4101 ret
= show_ip_ospf_interface_traffic_common(vty
, ospf
,
4108 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
4109 JSON_C_TO_STRING_PRETTY
));
4110 json_object_free(json
);
4117 static void show_ip_ospf_neighbour_header(struct vty
*vty
)
4119 vty_out(vty
, "\n%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s\n",
4120 "Neighbor ID", "Pri", "State", "Dead Time", "Address",
4121 "Interface", "RXmtL", "RqstL", "DBsmL");
4124 static void show_ip_ospf_neighbor_sub(struct vty
*vty
,
4125 struct ospf_interface
*oi
,
4126 json_object
*json
, u_char use_json
)
4128 struct route_node
*rn
;
4129 struct ospf_neighbor
*nbr
, *prev_nbr
= NULL
;
4131 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4132 json_object
*json_neighbor
= NULL
, *json_neigh_array
= NULL
;
4134 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
)) {
4135 if ((nbr
= rn
->info
)) {
4136 /* Do not show myself. */
4137 if (nbr
== oi
->nbr_self
)
4139 /* Down state is not shown. */
4140 if (nbr
->state
== NSM_Down
)
4143 char neigh_str
[INET_ADDRSTRLEN
];
4146 !IPV4_ADDR_SAME(&prev_nbr
->src
, &nbr
->src
)) {
4147 /* Start new neigh list */
4148 json_neigh_array
= NULL
;
4151 if (nbr
->state
== NSM_Attempt
&&
4152 nbr
->router_id
.s_addr
== 0)
4153 strlcpy(neigh_str
, "neighbor",
4157 inet_ntoa(nbr
->router_id
),
4160 json_object_object_get_ex(json
, neigh_str
,
4163 if (!json_neigh_array
) {
4164 json_neigh_array
= json_object_new_array();
4165 json_object_object_add(json
, neigh_str
,
4170 json_object_new_object();
4172 ospf_nbr_state_message(nbr
, msgbuf
, 16);
4176 time_store
= monotime_until(
4177 &nbr
->t_inactivity
->u
.sands
,
4180 json_object_int_add(json_neighbor
,
4183 json_object_string_add(json_neighbor
, "state",
4185 json_object_int_add(json_neighbor
,
4188 json_object_string_add(json_neighbor
,
4190 inet_ntoa(nbr
->src
));
4191 json_object_string_add(json_neighbor
,
4194 json_object_int_add(json_neighbor
,
4195 "retransmitCounter",
4196 ospf_ls_retransmit_count(nbr
));
4197 json_object_int_add(json_neighbor
,
4199 ospf_ls_request_count(nbr
));
4200 json_object_int_add(json_neighbor
,
4202 ospf_db_summary_count(nbr
));
4204 json_object_array_add(json_neigh_array
,
4207 ospf_nbr_state_message(nbr
, msgbuf
, 16);
4209 if (nbr
->state
== NSM_Attempt
&&
4210 nbr
->router_id
.s_addr
== 0)
4219 inet_ntoa(nbr
->router_id
),
4223 vty_out(vty
, "%9s ",
4224 ospf_timer_dump(nbr
->t_inactivity
,
4227 vty_out(vty
, "%-15s ", inet_ntoa(nbr
->src
));
4229 "%-20s %5ld %5ld %5d\n",
4231 ospf_ls_retransmit_count(nbr
),
4232 ospf_ls_request_count(nbr
),
4233 ospf_db_summary_count(nbr
));
4240 static int show_ip_ospf_neighbor_common(struct vty
*vty
, struct ospf
*ospf
,
4241 json_object
*json
, u_char use_json
,
4244 struct ospf_interface
*oi
;
4245 struct listnode
*node
;
4246 json_object
*json_vrf
= NULL
;
4250 json_vrf
= json_object_new_object();
4255 if (ospf
->instance
) {
4257 json_object_int_add(json
, "ospfInstance",
4260 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
4263 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
4265 show_ip_ospf_neighbour_header(vty
);
4267 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
))
4268 show_ip_ospf_neighbor_sub(vty
, oi
, json_vrf
, use_json
);
4272 if (ospf
->vrf_id
== VRF_DEFAULT
)
4273 json_object_object_add(json
, "default",
4276 json_object_object_add(json
, ospf
->name
,
4285 DEFUN (show_ip_ospf_neighbor
,
4286 show_ip_ospf_neighbor_cmd
,
4287 "show ip ospf [vrf <NAME|all>] neighbor [json]",
4290 "OSPF information\n"
4297 u_char uj
= use_json(argc
, argv
);
4298 struct listnode
*node
= NULL
;
4299 char *vrf_name
= NULL
;
4300 bool all_vrf
= FALSE
;
4301 int ret
= CMD_SUCCESS
;
4305 json_object
*json
= NULL
;
4307 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
4310 json
= json_object_new_object();
4312 /* vrf input is provided could be all or specific vrf*/
4316 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
4317 if (!ospf
->oi_running
)
4319 ret
= show_ip_ospf_neighbor_common(vty
, ospf
,
4325 vty_out(vty
, "%s\n",
4326 json_object_to_json_string_ext(json
,
4327 JSON_C_TO_STRING_PRETTY
));
4328 json_object_free(json
);
4334 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
4335 if (ospf
== NULL
|| !ospf
->oi_running
) {
4337 json_object_free(json
);
4341 /* Display default ospf (instance 0) info */
4342 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
4343 if (ospf
== NULL
|| !ospf
->oi_running
) {
4345 json_object_free(json
);
4351 ret
= show_ip_ospf_neighbor_common(vty
, ospf
, json
, uj
,
4355 vty_out(vty
, "%s\n",
4356 json_object_to_json_string_ext(json
,
4357 JSON_C_TO_STRING_PRETTY
));
4362 json_object_free(json
);
4368 DEFUN (show_ip_ospf_instance_neighbor
,
4369 show_ip_ospf_instance_neighbor_cmd
,
4370 "show ip ospf (1-65535) neighbor [json]",
4373 "OSPF information\n"
4380 u_short instance
= 0;
4381 u_char uj
= use_json(argc
, argv
);
4382 json_object
*json
= NULL
;
4383 int ret
= CMD_SUCCESS
;
4385 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4386 ospf
= ospf_lookup_instance(instance
);
4388 return CMD_NOT_MY_INSTANCE
;
4390 if (!ospf
->oi_running
)
4394 json
= json_object_new_object();
4396 ret
= show_ip_ospf_neighbor_common(vty
, ospf
, json
, uj
, 0);
4399 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
4400 JSON_C_TO_STRING_PRETTY
));
4401 json_object_free(json
);
4407 static int show_ip_ospf_neighbor_all_common(struct vty
*vty
, struct ospf
*ospf
,
4412 struct listnode
*node
;
4413 struct ospf_interface
*oi
;
4414 json_object
*json_vrf
= NULL
;
4415 json_object
*json_neighbor_sub
= NULL
;
4419 json_vrf
= json_object_new_object();
4422 json_neighbor_sub
= json_object_new_object();
4425 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
4427 show_ip_ospf_neighbour_header(vty
);
4429 if (ospf
->instance
) {
4431 json_object_int_add(json_vrf
, "ospfInstance",
4434 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
4437 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
4438 struct listnode
*nbr_node
;
4439 struct ospf_nbr_nbma
*nbr_nbma
;
4441 show_ip_ospf_neighbor_sub(vty
, oi
, json_vrf
, use_json
);
4443 /* print Down neighbor status */
4444 for (ALL_LIST_ELEMENTS_RO(oi
->nbr_nbma
, nbr_node
, nbr_nbma
)) {
4445 if (nbr_nbma
->nbr
== NULL
4446 || nbr_nbma
->nbr
->state
== NSM_Down
) {
4448 json_object_int_add(json_neighbor_sub
,
4450 nbr_nbma
->priority
);
4451 json_object_boolean_true_add(
4454 json_object_string_add(
4458 json_object_int_add(
4460 "nbrNbmaRetransmitCounter", 0);
4461 json_object_int_add(
4463 "nbrNbmaRequestCounter", 0);
4464 json_object_int_add(
4466 "nbrNbmaDbSummaryCounter", 0);
4467 json_object_object_add(
4469 inet_ntoa(nbr_nbma
->addr
),
4472 vty_out(vty
, "%-15s %3d %-15s %9s ",
4473 "-", nbr_nbma
->priority
, "Down",
4476 "%-15s %-20s %5d %5d %5d\n",
4477 inet_ntoa(nbr_nbma
->addr
),
4478 IF_NAME(oi
), 0, 0, 0);
4486 if (ospf
->vrf_id
== VRF_DEFAULT
)
4487 json_object_object_add(json
, "default",
4490 json_object_object_add(json
, ospf
->name
,
4499 DEFUN (show_ip_ospf_neighbor_all
,
4500 show_ip_ospf_neighbor_all_cmd
,
4501 "show ip ospf [vrf <NAME|all>] neighbor all [json]",
4504 "OSPF information\n"
4508 "include down status neighbor\n"
4512 u_char uj
= use_json(argc
, argv
);
4513 struct listnode
*node
= NULL
;
4514 char *vrf_name
= NULL
;
4515 bool all_vrf
= FALSE
;
4516 int ret
= CMD_SUCCESS
;
4520 json_object
*json
= NULL
;
4522 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
4525 json
= json_object_new_object();
4527 /* vrf input is provided could be all or specific vrf*/
4531 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
4532 if (!ospf
->oi_running
)
4534 ret
= show_ip_ospf_neighbor_all_common(vty
,
4542 vty_out(vty
, "%s\n",
4543 json_object_to_json_string_ext(json
,
4544 JSON_C_TO_STRING_PRETTY
));
4545 json_object_free(json
);
4551 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
4552 if (ospf
== NULL
|| !ospf
->oi_running
) {
4554 json_object_free(json
);
4558 /* Display default ospf (instance 0) info */
4559 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
4560 if (ospf
== NULL
|| !ospf
->oi_running
) {
4562 json_object_free(json
);
4568 ret
= show_ip_ospf_neighbor_all_common(vty
, ospf
, json
, uj
,
4571 vty_out(vty
, "%s\n",
4572 json_object_to_json_string_ext(json
,
4573 JSON_C_TO_STRING_PRETTY
));
4578 json_object_free(json
);
4583 DEFUN (show_ip_ospf_instance_neighbor_all
,
4584 show_ip_ospf_instance_neighbor_all_cmd
,
4585 "show ip ospf (1-65535) neighbor all [json]",
4588 "OSPF information\n"
4591 "include down status neighbor\n"
4596 u_short instance
= 0;
4597 u_char uj
= use_json(argc
, argv
);
4598 json_object
*json
= NULL
;
4599 int ret
= CMD_SUCCESS
;
4601 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4602 ospf
= ospf_lookup_instance(instance
);
4604 return CMD_NOT_MY_INSTANCE
;
4606 if (!ospf
->oi_running
)
4609 json
= json_object_new_object();
4611 ret
= show_ip_ospf_neighbor_all_common(vty
, ospf
, json
, uj
, 0);
4614 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
4615 json
, JSON_C_TO_STRING_PRETTY
));
4616 json_object_free(json
);
4622 static int show_ip_ospf_neighbor_int_common(struct vty
*vty
, struct ospf
*ospf
,
4624 struct cmd_token
**argv
,
4625 u_char use_json
, u_char use_vrf
)
4627 struct interface
*ifp
;
4628 struct route_node
*rn
;
4629 json_object
*json
= NULL
;
4632 json
= json_object_new_object();
4634 if (ospf
->instance
) {
4636 json_object_int_add(json
, "ospfInstance",
4639 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
4642 ospf_show_vrf_name(ospf
, vty
, json
, use_vrf
);
4644 /*ifp = if_lookup_by_name(argv[arg_base]->arg, ospf->vrf_id);*/
4645 ifp
= if_lookup_by_name_all_vrf(argv
[arg_base
]->arg
);
4648 json_object_boolean_true_add(json
, "noSuchIface");
4650 vty_out(vty
, "No such interface.\n");
4654 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
4655 struct ospf_interface
*oi
= rn
->info
;
4660 show_ip_ospf_neighbor_sub(vty
, oi
, json
, use_json
);
4664 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
4665 json
, JSON_C_TO_STRING_PRETTY
));
4666 json_object_free(json
);
4673 DEFUN (show_ip_ospf_neighbor_int
,
4674 show_ip_ospf_neighbor_int_cmd
,
4675 "show ip ospf neighbor IFNAME [json]",
4678 "OSPF information\n"
4685 u_char uj
= use_json(argc
, argv
);
4686 struct listnode
*node
= NULL
;
4687 int ret
= CMD_SUCCESS
;
4688 struct interface
*ifp
= NULL
;
4691 show_ip_ospf_neighbour_header(vty
);
4693 ifp
= if_lookup_by_name_all_vrf(argv
[idx_ifname
]->arg
);
4694 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
4695 if (!ospf
->oi_running
)
4697 if (!ifp
|| ifp
->vrf_id
!= ospf
->vrf_id
)
4699 ret
= show_ip_ospf_neighbor_int_common(vty
, ospf
,
4700 idx_ifname
, argv
, uj
, 0);
4706 DEFUN (show_ip_ospf_instance_neighbor_int
,
4707 show_ip_ospf_instance_neighbor_int_cmd
,
4708 "show ip ospf (1-65535) neighbor IFNAME [json]",
4711 "OSPF information\n"
4720 u_short instance
= 0;
4721 u_char uj
= use_json(argc
, argv
);
4724 show_ip_ospf_neighbour_header(vty
);
4726 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4727 ospf
= ospf_lookup_instance(instance
);
4729 return CMD_NOT_MY_INSTANCE
;
4731 if (!ospf
->oi_running
)
4735 show_ip_ospf_neighbour_header(vty
);
4737 return show_ip_ospf_neighbor_int_common(vty
, ospf
, idx_ifname
,
4741 static void show_ip_ospf_nbr_nbma_detail_sub(struct vty
*vty
,
4742 struct ospf_interface
*oi
,
4743 struct ospf_nbr_nbma
*nbr_nbma
,
4744 u_char use_json
, json_object
*json
)
4746 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4747 json_object
*json_sub
= NULL
;
4750 json_sub
= json_object_new_object();
4751 else /* Show neighbor ID. */
4752 vty_out(vty
, " Neighbor %s,", "-");
4754 /* Show interface address. */
4756 json_object_string_add(json_sub
, "ifaceAddress",
4757 inet_ntoa(nbr_nbma
->addr
));
4759 vty_out(vty
, " interface address %s\n",
4760 inet_ntoa(nbr_nbma
->addr
));
4764 json_object_string_add(json_sub
, "areaId",
4765 ospf_area_desc_string(oi
->area
));
4766 json_object_string_add(json_sub
, "iface", IF_NAME(oi
));
4768 vty_out(vty
, " In the area %s via interface %s\n",
4769 ospf_area_desc_string(oi
->area
), IF_NAME(oi
));
4771 /* Show neighbor priority and state. */
4773 json_object_int_add(json_sub
, "nbrPriority",
4774 nbr_nbma
->priority
);
4775 json_object_string_add(json_sub
, "nbrState", "down");
4777 vty_out(vty
, " Neighbor priority is %d, State is %s,",
4778 nbr_nbma
->priority
, "Down");
4780 /* Show state changes. */
4782 json_object_int_add(json_sub
, "stateChangeCounter",
4783 nbr_nbma
->state_change
);
4785 vty_out(vty
, " %d state changes\n", nbr_nbma
->state_change
);
4787 /* Show PollInterval */
4789 json_object_int_add(json_sub
, "pollInterval", nbr_nbma
->v_poll
);
4791 vty_out(vty
, " Poll interval %d\n", nbr_nbma
->v_poll
);
4793 /* Show poll-interval timer. */
4796 time_store
= monotime_until(&nbr_nbma
->t_poll
->u
.sands
, NULL
)
4798 json_object_int_add(json_sub
, "pollIntervalTimerDueMsec",
4801 vty_out(vty
, " Poll timer due in %s\n",
4802 ospf_timer_dump(nbr_nbma
->t_poll
, timebuf
,
4805 /* Show poll-interval timer thread. */
4807 if (nbr_nbma
->t_poll
!= NULL
)
4808 json_object_string_add(json_sub
,
4809 "pollIntervalTimerThread", "on");
4811 vty_out(vty
, " Thread Poll Timer %s\n",
4812 nbr_nbma
->t_poll
!= NULL
? "on" : "off");
4815 json_object_object_add(json
, "noNbrId", json_sub
);
4818 static void show_ip_ospf_neighbor_detail_sub(struct vty
*vty
,
4819 struct ospf_interface
*oi
,
4820 struct ospf_neighbor
*nbr
,
4824 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4825 json_object
*json_sub
= NULL
;
4828 json_sub
= json_object_new_object();
4830 /* Show neighbor ID. */
4831 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4832 vty_out(vty
, " Neighbor %s,", "-");
4834 vty_out(vty
, " Neighbor %s,",
4835 inet_ntoa(nbr
->router_id
));
4838 /* Show interface address. */
4840 json_object_string_add(json_sub
, "ifaceAddress",
4841 inet_ntoa(nbr
->address
.u
.prefix4
));
4843 vty_out(vty
, " interface address %s\n",
4844 inet_ntoa(nbr
->address
.u
.prefix4
));
4848 json_object_string_add(json_sub
, "areaId",
4849 ospf_area_desc_string(oi
->area
));
4850 json_object_string_add(json_sub
, "ifaceName", oi
->ifp
->name
);
4852 vty_out(vty
, " In the area %s via interface %s\n",
4853 ospf_area_desc_string(oi
->area
), oi
->ifp
->name
);
4855 /* Show neighbor priority and state. */
4857 json_object_int_add(json_sub
, "nbrPriority", nbr
->priority
);
4858 json_object_string_add(
4859 json_sub
, "nbrState",
4860 lookup_msg(ospf_nsm_state_msg
, nbr
->state
, NULL
));
4862 vty_out(vty
, " Neighbor priority is %d, State is %s,",
4864 lookup_msg(ospf_nsm_state_msg
, nbr
->state
, NULL
));
4866 /* Show state changes. */
4868 json_object_int_add(json_sub
, "stateChangeCounter",
4871 vty_out(vty
, " %d state changes\n", nbr
->state_change
);
4873 if (nbr
->ts_last_progress
.tv_sec
|| nbr
->ts_last_progress
.tv_usec
) {
4878 monotime_since(&nbr
->ts_last_progress
, &res
) / 1000LL;
4880 json_object_int_add(json_sub
, "lastPrgrsvChangeMsec",
4884 " Most recent state change statistics:\n");
4885 vty_out(vty
, " Progressive change %s ago\n",
4886 ospf_timeval_dump(&res
, timebuf
,
4891 if (nbr
->ts_last_regress
.tv_sec
|| nbr
->ts_last_regress
.tv_usec
) {
4896 monotime_since(&nbr
->ts_last_regress
, &res
) / 1000LL;
4898 json_object_int_add(json_sub
,
4899 "lastRegressiveChangeMsec",
4901 if (nbr
->last_regress_str
)
4902 json_object_string_add(
4903 json_sub
, "lastRegressiveChangeReason",
4904 nbr
->last_regress_str
);
4907 " Regressive change %s ago, due to %s\n",
4908 ospf_timeval_dump(&res
, timebuf
,
4910 (nbr
->last_regress_str
? nbr
->last_regress_str
4915 /* Show Designated Rotuer ID. */
4917 json_object_string_add(json_sub
, "routerDesignatedId",
4918 inet_ntoa(nbr
->d_router
));
4920 vty_out(vty
, " DR is %s,", inet_ntoa(nbr
->d_router
));
4922 /* Show Backup Designated Rotuer ID. */
4924 json_object_string_add(json_sub
, "routerDesignatedBackupId",
4925 inet_ntoa(nbr
->bd_router
));
4927 vty_out(vty
, " BDR is %s\n", inet_ntoa(nbr
->bd_router
));
4931 json_object_int_add(json_sub
, "optionsCounter", nbr
->options
);
4932 json_object_string_add(json_sub
, "optionsList",
4933 ospf_options_dump(nbr
->options
));
4935 vty_out(vty
, " Options %d %s\n", nbr
->options
,
4936 ospf_options_dump(nbr
->options
));
4938 /* Show Router Dead interval timer. */
4940 if (nbr
->t_inactivity
) {
4942 time_store
= monotime_until(&nbr
->t_inactivity
->u
.sands
,
4945 json_object_int_add(json_sub
,
4946 "routerDeadIntervalTimerDueMsec",
4949 json_object_int_add(
4950 json_sub
, "routerDeadIntervalTimerDueMsec", -1);
4952 vty_out(vty
, " Dead timer due in %s\n",
4953 ospf_timer_dump(nbr
->t_inactivity
, timebuf
,
4956 /* Show Database Summary list. */
4958 json_object_int_add(json_sub
, "databaseSummaryListCounter",
4959 ospf_db_summary_count(nbr
));
4961 vty_out(vty
, " Database Summary List %d\n",
4962 ospf_db_summary_count(nbr
));
4964 /* Show Link State Request list. */
4966 json_object_int_add(json_sub
, "linkStateRequestListCounter",
4967 ospf_ls_request_count(nbr
));
4969 vty_out(vty
, " Link State Request List %ld\n",
4970 ospf_ls_request_count(nbr
));
4972 /* Show Link State Retransmission list. */
4974 json_object_int_add(json_sub
,
4975 "linkStateRetransmissionListCounter",
4976 ospf_ls_retransmit_count(nbr
));
4978 vty_out(vty
, " Link State Retransmission List %ld\n",
4979 ospf_ls_retransmit_count(nbr
));
4981 /* Show inactivity timer thread. */
4983 if (nbr
->t_inactivity
!= NULL
)
4984 json_object_string_add(json_sub
,
4985 "threadInactivityTimer", "on");
4987 vty_out(vty
, " Thread Inactivity Timer %s\n",
4988 nbr
->t_inactivity
!= NULL
? "on" : "off");
4990 /* Show Database Description retransmission thread. */
4992 if (nbr
->t_db_desc
!= NULL
)
4993 json_object_string_add(
4995 "threadDatabaseDescriptionRetransmission",
4999 " Thread Database Description Retransmision %s\n",
5000 nbr
->t_db_desc
!= NULL
? "on" : "off");
5002 /* Show Link State Request Retransmission thread. */
5004 if (nbr
->t_ls_req
!= NULL
)
5005 json_object_string_add(
5007 "threadLinkStateRequestRetransmission", "on");
5010 " Thread Link State Request Retransmission %s\n",
5011 nbr
->t_ls_req
!= NULL
? "on" : "off");
5013 /* Show Link State Update Retransmission thread. */
5015 if (nbr
->t_ls_upd
!= NULL
)
5016 json_object_string_add(
5017 json_sub
, "threadLinkStateUpdateRetransmission",
5021 " Thread Link State Update Retransmission %s\n\n",
5022 nbr
->t_ls_upd
!= NULL
? "on" : "off");
5025 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
5026 json_object_object_add(json
, "noNbrId", json_sub
);
5028 json_object_object_add(json
, inet_ntoa(nbr
->router_id
),
5032 ospf_bfd_show_info(vty
, nbr
->bfd_info
, json
, use_json
, 0);
5035 static int show_ip_ospf_neighbor_id_common(struct vty
*vty
, struct ospf
*ospf
,
5037 struct cmd_token
**argv
,
5041 struct listnode
*node
;
5042 struct ospf_neighbor
*nbr
;
5043 struct ospf_interface
*oi
;
5044 struct in_addr router_id
;
5046 json_object
*json
= NULL
;
5049 json
= json_object_new_object();
5051 if (ospf
->instance
) {
5053 json_object_int_add(json
, "ospfInstance",
5056 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
5059 ospf_show_vrf_name(ospf
, vty
, json
, use_vrf
);
5061 ret
= inet_aton(argv
[arg_base
]->arg
, &router_id
);
5064 vty_out(vty
, "Please specify Neighbor ID by A.B.C.D\n");
5066 vty_out(vty
, "{}\n");
5067 json_object_free(json
);
5072 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
5073 if ((nbr
= ospf_nbr_lookup_by_routerid(oi
->nbrs
, &router_id
))) {
5074 show_ip_ospf_neighbor_detail_sub(vty
, oi
, nbr
, json
,
5080 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
5081 json
, JSON_C_TO_STRING_PRETTY
));
5082 json_object_free(json
);
5089 DEFUN (show_ip_ospf_neighbor_id
,
5090 show_ip_ospf_neighbor_id_cmd
,
5091 "show ip ospf neighbor A.B.C.D [json]",
5094 "OSPF information\n"
5100 u_char uj
= use_json(argc
, argv
);
5101 struct listnode
*node
= NULL
;
5102 int ret
= CMD_SUCCESS
;
5104 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
5105 if (!ospf
->oi_running
)
5107 ret
= show_ip_ospf_neighbor_id_common(vty
, ospf
, 0,
5114 DEFUN (show_ip_ospf_instance_neighbor_id
,
5115 show_ip_ospf_instance_neighbor_id_cmd
,
5116 "show ip ospf (1-65535) neighbor A.B.C.D [json]",
5119 "OSPF information\n"
5126 int idx_router_id
= 5;
5128 u_short instance
= 0;
5129 u_char uj
= use_json(argc
, argv
);
5131 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5132 ospf
= ospf_lookup_instance(instance
);
5134 return CMD_NOT_MY_INSTANCE
;
5136 if (!ospf
->oi_running
)
5139 return show_ip_ospf_neighbor_id_common(vty
, ospf
, idx_router_id
, argv
,
5143 static int show_ip_ospf_neighbor_detail_common(struct vty
*vty
,
5149 struct ospf_interface
*oi
;
5150 struct listnode
*node
;
5151 json_object
*json_vrf
= NULL
;
5155 json_vrf
= json_object_new_object();
5159 if (ospf
->instance
) {
5161 json_object_int_add(json_vrf
, "ospfInstance",
5164 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
5167 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
5169 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
5170 struct route_node
*rn
;
5171 struct ospf_neighbor
*nbr
;
5173 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
)) {
5174 if ((nbr
= rn
->info
)) {
5175 if (nbr
!= oi
->nbr_self
) {
5176 if (nbr
->state
!= NSM_Down
) {
5177 show_ip_ospf_neighbor_detail_sub(
5178 vty
, oi
, nbr
, json_vrf
,
5188 if (ospf
->vrf_id
== VRF_DEFAULT
)
5189 json_object_object_add(json
, "default",
5192 json_object_object_add(json
, ospf
->name
,
5201 DEFUN (show_ip_ospf_neighbor_detail
,
5202 show_ip_ospf_neighbor_detail_cmd
,
5203 "show ip ospf [vrf <NAME|all>] neighbor detail [json]",
5206 "OSPF information\n"
5210 "detail of all neighbors\n"
5214 u_char uj
= use_json(argc
, argv
);
5215 struct listnode
*node
= NULL
;
5216 char *vrf_name
= NULL
;
5217 bool all_vrf
= FALSE
;
5218 int ret
= CMD_SUCCESS
;
5222 json_object
*json
= NULL
;
5224 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
5227 json
= json_object_new_object();
5229 /* vrf input is provided could be all or specific vrf*/
5233 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
5234 if (!ospf
->oi_running
)
5236 ret
= show_ip_ospf_neighbor_detail_common(vty
,
5243 vty_out(vty
, "%s\n",
5244 json_object_to_json_string_ext(json
,
5245 JSON_C_TO_STRING_PRETTY
));
5246 json_object_free(json
);
5251 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
5252 if (ospf
== NULL
|| !ospf
->oi_running
) {
5254 json_object_free(json
);
5258 /* Display default ospf (instance 0) info */
5259 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
5260 if (ospf
== NULL
|| !ospf
->oi_running
) {
5262 json_object_free(json
);
5268 ret
= show_ip_ospf_neighbor_detail_common(vty
, ospf
, json
, uj
,
5271 vty_out(vty
, "%s\n",
5272 json_object_to_json_string_ext(json
,
5273 JSON_C_TO_STRING_PRETTY
));
5278 json_object_free(json
);
5283 DEFUN (show_ip_ospf_instance_neighbor_detail
,
5284 show_ip_ospf_instance_neighbor_detail_cmd
,
5285 "show ip ospf (1-65535) neighbor detail [json]",
5288 "OSPF information\n"
5291 "detail of all neighbors\n"
5296 u_short instance
= 0;
5297 u_char uj
= use_json(argc
, argv
);
5298 json_object
*json
= NULL
;
5299 int ret
= CMD_SUCCESS
;
5301 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5302 ospf
= ospf_lookup_instance(instance
);
5304 return CMD_NOT_MY_INSTANCE
;
5306 if (!ospf
->oi_running
)
5310 json
= json_object_new_object();
5312 ret
= show_ip_ospf_neighbor_detail_common(vty
, ospf
, json
, uj
, 0);
5315 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
5316 json
, JSON_C_TO_STRING_PRETTY
));
5317 json_object_free(json
);
5323 static int show_ip_ospf_neighbor_detail_all_common(struct vty
*vty
,
5329 struct listnode
*node
;
5330 struct ospf_interface
*oi
;
5331 json_object
*json_vrf
= NULL
;
5335 json_vrf
= json_object_new_object();
5340 if (ospf
->instance
) {
5342 json_object_int_add(json
, "ospfInstance",
5345 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
5348 ospf_show_vrf_name(ospf
, vty
, json_vrf
, use_vrf
);
5350 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
5351 struct route_node
*rn
;
5352 struct ospf_neighbor
*nbr
;
5353 struct ospf_nbr_nbma
*nbr_nbma
;
5355 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
))
5356 if ((nbr
= rn
->info
))
5357 if (nbr
!= oi
->nbr_self
)
5358 if (nbr
->state
!= NSM_Down
)
5359 show_ip_ospf_neighbor_detail_sub(
5361 json_vrf
, use_json
);
5363 if (oi
->type
== OSPF_IFTYPE_NBMA
) {
5364 struct listnode
*nd
;
5366 for (ALL_LIST_ELEMENTS_RO(oi
->nbr_nbma
, nd
, nbr_nbma
)) {
5367 if (nbr_nbma
->nbr
== NULL
5368 || nbr_nbma
->nbr
->state
== NSM_Down
)
5369 show_ip_ospf_nbr_nbma_detail_sub(
5370 vty
, oi
, nbr_nbma
, use_json
,
5378 if (ospf
->vrf_id
== VRF_DEFAULT
)
5379 json_object_object_add(json
, "default",
5382 json_object_object_add(json
, ospf
->name
,
5392 DEFUN (show_ip_ospf_neighbor_detail_all
,
5393 show_ip_ospf_neighbor_detail_all_cmd
,
5394 "show ip ospf [vrf <NAME|all>] neighbor detail all [json]",
5397 "OSPF information\n"
5401 "detail of all neighbors\n"
5402 "include down status neighbor\n"
5406 u_char uj
= use_json(argc
, argv
);
5407 struct listnode
*node
= NULL
;
5408 char *vrf_name
= NULL
;
5409 bool all_vrf
= FALSE
;
5410 int ret
= CMD_SUCCESS
;
5414 json_object
*json
= NULL
;
5416 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
5419 json
= json_object_new_object();
5421 /* vrf input is provided could be all or specific vrf*/
5425 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
5426 if (!ospf
->oi_running
)
5428 ret
= show_ip_ospf_neighbor_detail_all_common(vty
,
5436 vty_out(vty
, "%s\n",
5437 json_object_to_json_string_ext(json
,
5438 JSON_C_TO_STRING_PRETTY
));
5439 json_object_free(json
);
5444 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
5445 if (ospf
== NULL
|| !ospf
->oi_running
) {
5447 json_object_free(json
);
5451 /* Display default ospf (instance 0) info */
5452 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
5453 if (ospf
== NULL
|| !ospf
->oi_running
) {
5455 json_object_free(json
);
5461 ret
= show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, json
,
5464 vty_out(vty
, "%s\n",
5465 json_object_to_json_string_ext(json
,
5466 JSON_C_TO_STRING_PRETTY
));
5471 json_object_free(json
);
5476 DEFUN (show_ip_ospf_instance_neighbor_detail_all
,
5477 show_ip_ospf_instance_neighbor_detail_all_cmd
,
5478 "show ip ospf (1-65535) neighbor detail all [json]",
5481 "OSPF information\n"
5484 "detail of all neighbors\n"
5485 "include down status neighbor\n"
5490 u_short instance
= 0;
5491 u_char uj
= use_json(argc
, argv
);
5492 json_object
*json
= NULL
;
5493 int ret
= CMD_SUCCESS
;
5495 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5496 ospf
= ospf_lookup_instance(instance
);
5498 return CMD_NOT_MY_INSTANCE
;
5500 if (!ospf
->oi_running
)
5504 json
= json_object_new_object();
5506 ret
= show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, json
, uj
, 0);
5509 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
5510 JSON_C_TO_STRING_PRETTY
));
5511 json_object_free(json
);
5517 static int show_ip_ospf_neighbor_int_detail_common(struct vty
*vty
,
5520 struct cmd_token
**argv
,
5523 struct ospf_interface
*oi
;
5524 struct interface
*ifp
;
5525 struct route_node
*rn
, *nrn
;
5526 struct ospf_neighbor
*nbr
;
5527 json_object
*json
= NULL
;
5530 json
= json_object_new_object();
5532 if (ospf
->instance
) {
5534 json_object_int_add(json
, "ospfInstance",
5537 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
5540 ifp
= if_lookup_by_name_all_vrf(argv
[arg_base
]->arg
);
5543 vty_out(vty
, "No such interface.\n");
5545 vty_out(vty
, "{}\n");
5546 json_object_free(json
);
5551 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
5552 if ((oi
= rn
->info
)) {
5553 for (nrn
= route_top(oi
->nbrs
); nrn
;
5554 nrn
= route_next(nrn
)) {
5555 if ((nbr
= nrn
->info
)) {
5556 if (nbr
!= oi
->nbr_self
) {
5557 if (nbr
->state
!= NSM_Down
)
5558 show_ip_ospf_neighbor_detail_sub(
5568 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
5569 json
, JSON_C_TO_STRING_PRETTY
));
5570 json_object_free(json
);
5577 DEFUN (show_ip_ospf_neighbor_int_detail
,
5578 show_ip_ospf_neighbor_int_detail_cmd
,
5579 "show ip ospf neighbor IFNAME detail [json]",
5582 "OSPF information\n"
5585 "detail of all neighbors\n"
5589 u_char uj
= use_json(argc
, argv
);
5590 struct listnode
*node
= NULL
;
5591 int ret
= CMD_SUCCESS
;
5593 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
5594 if (!ospf
->oi_running
)
5596 ret
= show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 0,
5603 DEFUN (show_ip_ospf_instance_neighbor_int_detail
,
5604 show_ip_ospf_instance_neighbor_int_detail_cmd
,
5605 "show ip ospf (1-65535) neighbor IFNAME detail [json]",
5608 "OSPF information\n"
5612 "detail of all neighbors\n"
5618 u_short instance
= 0;
5619 u_char uj
= use_json(argc
, argv
);
5621 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5622 ospf
= ospf_lookup_instance(instance
);
5624 return CMD_NOT_MY_INSTANCE
;
5626 if (!ospf
->oi_running
)
5629 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, idx_ifname
, argv
, uj
);
5632 /* Show functions */
5633 static int show_lsa_summary(struct vty
*vty
, struct ospf_lsa
*lsa
, int self
)
5635 struct router_lsa
*rl
;
5636 struct summary_lsa
*sl
;
5637 struct as_external_lsa
*asel
;
5638 struct prefix_ipv4 p
;
5641 /* If self option is set, check LSA self flag. */
5642 if (self
== 0 || IS_LSA_SELF(lsa
)) {
5643 /* LSA common part show. */
5644 vty_out(vty
, "%-15s ", inet_ntoa(lsa
->data
->id
));
5645 vty_out(vty
, "%-15s %4d 0x%08lx 0x%04x",
5646 inet_ntoa(lsa
->data
->adv_router
), LS_AGE(lsa
),
5647 (u_long
)ntohl(lsa
->data
->ls_seqnum
),
5648 ntohs(lsa
->data
->checksum
));
5649 /* LSA specific part show. */
5650 switch (lsa
->data
->type
) {
5651 case OSPF_ROUTER_LSA
:
5652 rl
= (struct router_lsa
*)lsa
->data
;
5653 vty_out(vty
, " %-d", ntohs(rl
->links
));
5655 case OSPF_SUMMARY_LSA
:
5656 sl
= (struct summary_lsa
*)lsa
->data
;
5659 p
.prefix
= sl
->header
.id
;
5660 p
.prefixlen
= ip_masklen(sl
->mask
);
5661 apply_mask_ipv4(&p
);
5663 vty_out(vty
, " %s/%d", inet_ntoa(p
.prefix
),
5666 case OSPF_AS_EXTERNAL_LSA
:
5667 case OSPF_AS_NSSA_LSA
:
5668 asel
= (struct as_external_lsa
*)lsa
->data
;
5671 p
.prefix
= asel
->header
.id
;
5672 p
.prefixlen
= ip_masklen(asel
->mask
);
5673 apply_mask_ipv4(&p
);
5675 vty_out(vty
, " %s %s/%d [0x%lx]",
5676 IS_EXTERNAL_METRIC(asel
->e
[0].tos
)
5679 inet_ntoa(p
.prefix
), p
.prefixlen
,
5680 (u_long
)ntohl(asel
->e
[0].route_tag
));
5682 case OSPF_NETWORK_LSA
:
5683 case OSPF_ASBR_SUMMARY_LSA
:
5684 case OSPF_OPAQUE_LINK_LSA
:
5685 case OSPF_OPAQUE_AREA_LSA
:
5686 case OSPF_OPAQUE_AS_LSA
:
5696 static const char *show_database_desc
[] = {
5698 "Router Link States",
5700 "Summary Link States",
5701 "ASBR-Summary Link States",
5702 "AS External Link States",
5703 "Group Membership LSA",
5704 "NSSA-external Link States",
5706 "Link-Local Opaque-LSA",
5707 "Area-Local Opaque-LSA",
5708 "AS-external Opaque-LSA",
5711 static const char *show_database_header
[] = {
5713 "Link ID ADV Router Age Seq# CkSum Link count",
5714 "Link ID ADV Router Age Seq# CkSum",
5715 "Link ID ADV Router Age Seq# CkSum Route",
5716 "Link ID ADV Router Age Seq# CkSum",
5717 "Link ID ADV Router Age Seq# CkSum Route",
5718 " --- header for Group Member ----",
5719 "Link ID ADV Router Age Seq# CkSum Route",
5721 "Opaque-Type/Id ADV Router Age Seq# CkSum",
5722 "Opaque-Type/Id ADV Router Age Seq# CkSum",
5723 "Opaque-Type/Id ADV Router Age Seq# CkSum",
5726 static void show_ip_ospf_database_header(struct vty
*vty
, struct ospf_lsa
*lsa
)
5728 struct router_lsa
*rlsa
= (struct router_lsa
*)lsa
->data
;
5730 vty_out(vty
, " LS age: %d\n", LS_AGE(lsa
));
5731 vty_out(vty
, " Options: 0x%-2x : %s\n", lsa
->data
->options
,
5732 ospf_options_dump(lsa
->data
->options
));
5733 vty_out(vty
, " LS Flags: 0x%-2x %s\n", lsa
->flags
,
5734 ((lsa
->flags
& OSPF_LSA_LOCAL_XLT
) ? "(Translated from Type-7)"
5737 if (lsa
->data
->type
== OSPF_ROUTER_LSA
) {
5738 vty_out(vty
, " Flags: 0x%x", rlsa
->flags
);
5741 vty_out(vty
, " :%s%s%s%s",
5742 IS_ROUTER_LSA_BORDER(rlsa
) ? " ABR" : "",
5743 IS_ROUTER_LSA_EXTERNAL(rlsa
) ? " ASBR" : "",
5744 IS_ROUTER_LSA_VIRTUAL(rlsa
) ? " VL-endpoint"
5746 IS_ROUTER_LSA_SHORTCUT(rlsa
) ? " Shortcut"
5751 vty_out(vty
, " LS Type: %s\n",
5752 lookup_msg(ospf_lsa_type_msg
, lsa
->data
->type
, NULL
));
5753 vty_out(vty
, " Link State ID: %s %s\n", inet_ntoa(lsa
->data
->id
),
5754 lookup_msg(ospf_link_state_id_type_msg
, lsa
->data
->type
, NULL
));
5755 vty_out(vty
, " Advertising Router: %s\n",
5756 inet_ntoa(lsa
->data
->adv_router
));
5757 vty_out(vty
, " LS Seq Number: %08lx\n",
5758 (u_long
)ntohl(lsa
->data
->ls_seqnum
));
5759 vty_out(vty
, " Checksum: 0x%04x\n", ntohs(lsa
->data
->checksum
));
5760 vty_out(vty
, " Length: %d\n\n", ntohs(lsa
->data
->length
));
5763 const char *link_type_desc
[] = {
5765 "another Router (point-to-point)",
5766 "a Transit Network",
5771 const char *link_id_desc
[] = {
5772 "(null)", "Neighboring Router ID", "Designated Router address",
5773 "Net", "Neighboring Router ID",
5776 const char *link_data_desc
[] = {
5777 "(null)", "Router Interface address", "Router Interface address",
5778 "Network Mask", "Router Interface address",
5781 /* Show router-LSA each Link information. */
5782 static void show_ip_ospf_database_router_links(struct vty
*vty
,
5783 struct router_lsa
*rl
)
5788 len
= ntohs(rl
->header
.length
) - 4;
5789 for (i
= 0; i
< ntohs(rl
->links
) && len
> 0; len
-= 12, i
++) {
5790 type
= rl
->link
[i
].type
;
5792 vty_out(vty
, " Link connected to: %s\n",
5793 link_type_desc
[type
]);
5794 vty_out(vty
, " (Link ID) %s: %s\n", link_id_desc
[type
],
5795 inet_ntoa(rl
->link
[i
].link_id
));
5796 vty_out(vty
, " (Link Data) %s: %s\n", link_data_desc
[type
],
5797 inet_ntoa(rl
->link
[i
].link_data
));
5798 vty_out(vty
, " Number of TOS metrics: 0\n");
5799 vty_out(vty
, " TOS 0 Metric: %d\n",
5800 ntohs(rl
->link
[i
].metric
));
5805 /* Show router-LSA detail information. */
5806 static int show_router_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5809 struct router_lsa
*rl
= (struct router_lsa
*)lsa
->data
;
5811 show_ip_ospf_database_header(vty
, lsa
);
5813 vty_out(vty
, " Number of Links: %d\n\n", ntohs(rl
->links
));
5815 show_ip_ospf_database_router_links(vty
, rl
);
5822 /* Show network-LSA detail information. */
5823 static int show_network_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5828 struct network_lsa
*nl
= (struct network_lsa
*)lsa
->data
;
5830 show_ip_ospf_database_header(vty
, lsa
);
5832 vty_out(vty
, " Network Mask: /%d\n", ip_masklen(nl
->mask
));
5834 length
= ntohs(lsa
->data
->length
) - OSPF_LSA_HEADER_SIZE
- 4;
5836 for (i
= 0; length
> 0; i
++, length
-= 4)
5837 vty_out(vty
, " Attached Router: %s\n",
5838 inet_ntoa(nl
->routers
[i
]));
5846 /* Show summary-LSA detail information. */
5847 static int show_summary_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5850 struct summary_lsa
*sl
= (struct summary_lsa
*)lsa
->data
;
5852 show_ip_ospf_database_header(vty
, lsa
);
5854 vty_out(vty
, " Network Mask: /%d\n", ip_masklen(sl
->mask
));
5855 vty_out(vty
, " TOS: 0 Metric: %d\n",
5856 GET_METRIC(sl
->metric
));
5863 /* Show summary-ASBR-LSA detail information. */
5864 static int show_summary_asbr_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5867 struct summary_lsa
*sl
= (struct summary_lsa
*)lsa
->data
;
5869 show_ip_ospf_database_header(vty
, lsa
);
5871 vty_out(vty
, " Network Mask: /%d\n", ip_masklen(sl
->mask
));
5872 vty_out(vty
, " TOS: 0 Metric: %d\n",
5873 GET_METRIC(sl
->metric
));
5880 /* Show AS-external-LSA detail information. */
5881 static int show_as_external_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5884 struct as_external_lsa
*al
=
5885 (struct as_external_lsa
*)lsa
->data
;
5887 show_ip_ospf_database_header(vty
, lsa
);
5889 vty_out(vty
, " Network Mask: /%d\n", ip_masklen(al
->mask
));
5890 vty_out(vty
, " Metric Type: %s\n",
5891 IS_EXTERNAL_METRIC(al
->e
[0].tos
)
5892 ? "2 (Larger than any link state path)"
5894 vty_out(vty
, " TOS: 0\n");
5895 vty_out(vty
, " Metric: %d\n",
5896 GET_METRIC(al
->e
[0].metric
));
5897 vty_out(vty
, " Forward Address: %s\n",
5898 inet_ntoa(al
->e
[0].fwd_addr
));
5901 " External Route Tag: %" ROUTE_TAG_PRI
"\n\n",
5902 (route_tag_t
)ntohl(al
->e
[0].route_tag
));
5909 show_as_external_lsa_stdvty (struct ospf_lsa
*lsa
)
5911 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5913 /* show_ip_ospf_database_header (vty, lsa); */
5915 zlog_debug( " Network Mask: /%d%s",
5916 ip_masklen (al
->mask
), "\n");
5917 zlog_debug( " Metric Type: %s%s",
5918 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5919 "2 (Larger than any link state path)" : "1", "\n");
5920 zlog_debug( " TOS: 0%s", "\n");
5921 zlog_debug( " Metric: %d%s",
5922 GET_METRIC (al
->e
[0].metric
), "\n");
5923 zlog_debug( " Forward Address: %s%s",
5924 inet_ntoa (al
->e
[0].fwd_addr
), "\n");
5926 zlog_debug( " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5927 (route_tag_t
)ntohl (al
->e
[0].route_tag
), "\n", "\n");
5932 /* Show AS-NSSA-LSA detail information. */
5933 static int show_as_nssa_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5936 struct as_external_lsa
*al
=
5937 (struct as_external_lsa
*)lsa
->data
;
5939 show_ip_ospf_database_header(vty
, lsa
);
5941 vty_out(vty
, " Network Mask: /%d\n", ip_masklen(al
->mask
));
5942 vty_out(vty
, " Metric Type: %s\n",
5943 IS_EXTERNAL_METRIC(al
->e
[0].tos
)
5944 ? "2 (Larger than any link state path)"
5946 vty_out(vty
, " TOS: 0\n");
5947 vty_out(vty
, " Metric: %d\n",
5948 GET_METRIC(al
->e
[0].metric
));
5949 vty_out(vty
, " NSSA: Forward Address: %s\n",
5950 inet_ntoa(al
->e
[0].fwd_addr
));
5953 " External Route Tag: %" ROUTE_TAG_PRI
"\n\n",
5954 (route_tag_t
)ntohl(al
->e
[0].route_tag
));
5960 static int show_func_dummy(struct vty
*vty
, struct ospf_lsa
*lsa
)
5965 static int show_opaque_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5968 show_ip_ospf_database_header(vty
, lsa
);
5969 show_opaque_info_detail(vty
, lsa
);
5976 int (*show_function
[])(struct vty
*, struct ospf_lsa
*) = {
5978 show_router_lsa_detail
,
5979 show_network_lsa_detail
,
5980 show_summary_lsa_detail
,
5981 show_summary_asbr_lsa_detail
,
5982 show_as_external_lsa_detail
,
5984 show_as_nssa_lsa_detail
, /* almost same as external */
5986 show_opaque_lsa_detail
,
5987 show_opaque_lsa_detail
,
5988 show_opaque_lsa_detail
,
5991 static void show_lsa_prefix_set(struct vty
*vty
, struct prefix_ls
*lp
,
5992 struct in_addr
*id
, struct in_addr
*adv_router
)
5994 memset(lp
, 0, sizeof(struct prefix_ls
));
5998 else if (adv_router
== NULL
) {
6004 lp
->adv_router
= *adv_router
;
6008 static void show_lsa_detail_proc(struct vty
*vty
, struct route_table
*rt
,
6009 struct in_addr
*id
, struct in_addr
*adv_router
)
6011 struct prefix_ls lp
;
6012 struct route_node
*rn
, *start
;
6013 struct ospf_lsa
*lsa
;
6015 show_lsa_prefix_set(vty
, &lp
, id
, adv_router
);
6016 start
= route_node_get(rt
, (struct prefix
*)&lp
);
6018 route_lock_node(start
);
6019 for (rn
= start
; rn
; rn
= route_next_until(rn
, start
))
6020 if ((lsa
= rn
->info
)) {
6021 if (show_function
[lsa
->data
->type
] != NULL
)
6022 show_function
[lsa
->data
->type
](vty
,
6025 route_unlock_node(start
);
6029 /* Show detail LSA information
6030 -- if id is NULL then show all LSAs. */
6031 static void show_lsa_detail(struct vty
*vty
, struct ospf
*ospf
, int type
,
6032 struct in_addr
*id
, struct in_addr
*adv_router
)
6034 struct listnode
*node
;
6035 struct ospf_area
*area
;
6038 case OSPF_AS_EXTERNAL_LSA
:
6039 case OSPF_OPAQUE_AS_LSA
:
6040 vty_out(vty
, " %s \n\n",
6041 show_database_desc
[type
]);
6042 show_lsa_detail_proc(vty
, AS_LSDB(ospf
, type
), id
, adv_router
);
6045 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
6046 vty_out(vty
, "\n %s (Area %s)\n\n",
6047 show_database_desc
[type
],
6048 ospf_area_desc_string(area
));
6049 show_lsa_detail_proc(vty
, AREA_LSDB(area
, type
), id
,
6056 static void show_lsa_detail_adv_router_proc(struct vty
*vty
,
6057 struct route_table
*rt
,
6058 struct in_addr
*adv_router
)
6060 struct route_node
*rn
;
6061 struct ospf_lsa
*lsa
;
6063 for (rn
= route_top(rt
); rn
; rn
= route_next(rn
))
6064 if ((lsa
= rn
->info
))
6065 if (IPV4_ADDR_SAME(adv_router
,
6066 &lsa
->data
->adv_router
)) {
6067 if (CHECK_FLAG(lsa
->flags
, OSPF_LSA_LOCAL_XLT
))
6069 if (show_function
[lsa
->data
->type
] != NULL
)
6070 show_function
[lsa
->data
->type
](vty
,
6075 /* Show detail LSA information. */
6076 static void show_lsa_detail_adv_router(struct vty
*vty
, struct ospf
*ospf
,
6077 int type
, struct in_addr
*adv_router
)
6079 struct listnode
*node
;
6080 struct ospf_area
*area
;
6083 case OSPF_AS_EXTERNAL_LSA
:
6084 case OSPF_OPAQUE_AS_LSA
:
6085 vty_out(vty
, " %s \n\n",
6086 show_database_desc
[type
]);
6087 show_lsa_detail_adv_router_proc(vty
, AS_LSDB(ospf
, type
),
6091 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
6092 vty_out(vty
, "\n %s (Area %s)\n\n",
6093 show_database_desc
[type
],
6094 ospf_area_desc_string(area
));
6095 show_lsa_detail_adv_router_proc(
6096 vty
, AREA_LSDB(area
, type
), adv_router
);
6102 static void show_ip_ospf_database_summary(struct vty
*vty
, struct ospf
*ospf
,
6105 struct ospf_lsa
*lsa
;
6106 struct route_node
*rn
;
6107 struct ospf_area
*area
;
6108 struct listnode
*node
;
6111 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
6112 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++) {
6114 case OSPF_AS_EXTERNAL_LSA
:
6115 case OSPF_OPAQUE_AS_LSA
:
6120 if (ospf_lsdb_count_self(area
->lsdb
, type
) > 0
6122 && ospf_lsdb_count(area
->lsdb
, type
) > 0)) {
6123 vty_out(vty
, " %s (Area %s)\n\n",
6124 show_database_desc
[type
],
6125 ospf_area_desc_string(area
));
6126 vty_out(vty
, "%s\n",
6127 show_database_header
[type
]);
6129 LSDB_LOOP(AREA_LSDB(area
, type
), rn
, lsa
)
6130 show_lsa_summary(vty
, lsa
, self
);
6137 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++) {
6139 case OSPF_AS_EXTERNAL_LSA
:
6140 case OSPF_OPAQUE_AS_LSA
:
6145 if (ospf_lsdb_count_self(ospf
->lsdb
, type
)
6146 || (!self
&& ospf_lsdb_count(ospf
->lsdb
, type
))) {
6147 vty_out(vty
, " %s\n\n",
6148 show_database_desc
[type
]);
6149 vty_out(vty
, "%s\n", show_database_header
[type
]);
6151 LSDB_LOOP(AS_LSDB(ospf
, type
), rn
, lsa
)
6152 show_lsa_summary(vty
, lsa
, self
);
6161 static void show_ip_ospf_database_maxage(struct vty
*vty
, struct ospf
*ospf
)
6163 struct route_node
*rn
;
6165 vty_out(vty
, "\n MaxAge Link States:\n\n");
6167 for (rn
= route_top(ospf
->maxage_lsa
); rn
; rn
= route_next(rn
)) {
6168 struct ospf_lsa
*lsa
;
6170 if ((lsa
= rn
->info
) != NULL
) {
6171 vty_out(vty
, "Link type: %d\n", lsa
->data
->type
);
6172 vty_out(vty
, "Link State ID: %s\n",
6173 inet_ntoa(lsa
->data
->id
));
6174 vty_out(vty
, "Advertising Router: %s\n",
6175 inet_ntoa(lsa
->data
->adv_router
));
6176 vty_out(vty
, "LSA lock count: %d\n", lsa
->lock
);
6182 #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
6183 #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
6185 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
6186 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
6187 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
6188 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
6190 #define OSPF_LSA_TYPES_DESC \
6191 "ASBR summary link states\n" \
6192 "External link states\n" \
6193 "Network link states\n" \
6194 "Router link states\n" \
6195 "Network summary link states\n" OSPF_LSA_TYPE_NSSA_DESC \
6196 OSPF_LSA_TYPE_OPAQUE_LINK_DESC OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
6197 OSPF_LSA_TYPE_OPAQUE_AS_DESC
6199 static int show_ip_ospf_database_common(struct vty
*vty
, struct ospf
*ospf
,
6200 int arg_base
, int argc
,
6201 struct cmd_token
**argv
,
6206 struct in_addr id
, adv_router
;
6209 vty_out(vty
, "\nOSPF Instance: %d\n", ospf
->instance
);
6211 ospf_show_vrf_name(ospf
, vty
, NULL
, use_vrf
);
6213 vty_out(vty
, "\n OSPF Router with ID (%s)\n\n",
6214 inet_ntoa(ospf
->router_id
));
6217 if (argc
== arg_base
+ 4) {
6218 show_ip_ospf_database_summary(vty
, ospf
, 0);
6222 /* Set database type to show. */
6223 if (strncmp(argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
6224 type
= OSPF_ROUTER_LSA
;
6225 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
6226 type
= OSPF_NETWORK_LSA
;
6227 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
6228 type
= OSPF_AS_NSSA_LSA
;
6229 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "su", 2) == 0)
6230 type
= OSPF_SUMMARY_LSA
;
6231 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
6232 type
= OSPF_ASBR_SUMMARY_LSA
;
6233 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
6234 type
= OSPF_AS_EXTERNAL_LSA
;
6235 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "se", 2) == 0) {
6236 show_ip_ospf_database_summary(vty
, ospf
, 1);
6238 } else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "m", 1) == 0) {
6239 show_ip_ospf_database_maxage(vty
, ospf
);
6241 } else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
6242 type
= OSPF_OPAQUE_LINK_LSA
;
6243 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
6244 type
= OSPF_OPAQUE_AREA_LSA
;
6245 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
6246 type
= OSPF_OPAQUE_AS_LSA
;
6250 /* `show ip ospf database LSA'. */
6251 if (argc
== arg_base
+ 5)
6252 show_lsa_detail(vty
, ospf
, type
, NULL
, NULL
);
6253 else if (argc
>= arg_base
+ 6) {
6254 ret
= inet_aton(argv
[arg_base
+ 5]->arg
, &id
);
6258 /* `show ip ospf database LSA ID'. */
6259 if (argc
== arg_base
+ 6)
6260 show_lsa_detail(vty
, ospf
, type
, &id
, NULL
);
6261 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
6262 else if (argc
== arg_base
+ 7) {
6263 if (strncmp(argv
[arg_base
+ 6]->text
, "s", 1) == 0)
6264 adv_router
= ospf
->router_id
;
6266 ret
= inet_aton(argv
[arg_base
+ 7]->arg
,
6271 show_lsa_detail(vty
, ospf
, type
, &id
, &adv_router
);
6278 DEFUN (show_ip_ospf_database_max
,
6279 show_ip_ospf_database_max_cmd
,
6280 "show ip ospf [vrf <NAME|all>] database <max-age|self-originate>",
6283 "OSPF information\n"
6286 "Database summary\n"
6287 "LSAs in MaxAge list\n"
6288 "Self-originated link states\n")
6290 struct ospf
*ospf
= NULL
;
6291 struct listnode
*node
= NULL
;
6292 char *vrf_name
= NULL
;
6293 bool all_vrf
= FALSE
;
6294 int ret
= CMD_SUCCESS
;
6299 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
6304 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
6305 if (!ospf
->oi_running
)
6307 ret
= show_ip_ospf_database_common(vty
, ospf
,
6314 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
6315 if (ospf
== NULL
|| !ospf
->oi_running
)
6317 ret
= (show_ip_ospf_database_common(vty
, ospf
, idx_vrf
?
6322 /* Display default ospf (instance 0) info */
6323 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
6324 if (ospf
== NULL
|| !ospf
->oi_running
)
6326 ret
= show_ip_ospf_database_common(vty
, ospf
, 0, argc
, argv
,
6333 DEFUN (show_ip_ospf_instance_database
,
6334 show_ip_ospf_instance_database_cmd
,
6335 "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>]]]",
6338 "OSPF information\n"
6341 "Database summary\n"
6343 "Link State ID (as an IP address)\n"
6344 "Self-originated link states\n"
6345 "Advertising Router link states\n"
6346 "Advertising Router (as an IP address)\n")
6349 u_short instance
= 0;
6350 struct listnode
*node
= NULL
;
6351 char *vrf_name
= NULL
;
6352 bool all_vrf
= FALSE
;
6353 int ret
= CMD_SUCCESS
;
6358 if (argv_find(argv
, argc
, "(1-65535)", &idx
)) {
6359 instance
= strtoul(argv
[idx
]->arg
, NULL
, 10);
6360 ospf
= ospf_lookup_instance(instance
);
6362 return CMD_NOT_MY_INSTANCE
;
6363 if (!ospf
->oi_running
)
6366 return (show_ip_ospf_database_common(vty
, ospf
, idx
? 1 : 0,
6367 argc
, argv
, use_vrf
));
6368 } else if (argv_find(argv
, argc
, "vrf", &idx
)) {
6369 vrf_name
= argv
[++idx
]->arg
;
6370 all_vrf
= strmatch(vrf_name
, "all");
6376 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
6377 if (!ospf
->oi_running
)
6379 ret
= (show_ip_ospf_database_common(vty
, ospf
,
6385 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
6386 if ((ospf
== NULL
) || !ospf
->oi_running
)
6388 ret
= (show_ip_ospf_database_common(vty
, ospf
, idx
? 2 :
6393 /* Display default ospf (instance 0) info */
6394 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
6395 if (ospf
== NULL
|| !ospf
->oi_running
)
6397 ret
= (show_ip_ospf_database_common(vty
, ospf
, 0, argc
, argv
,
6404 DEFUN (show_ip_ospf_instance_database_max
,
6405 show_ip_ospf_instance_database_max_cmd
,
6406 "show ip ospf (1-65535) database <max-age|self-originate>",
6409 "OSPF information\n"
6411 "Database summary\n"
6412 "LSAs in MaxAge list\n"
6413 "Self-originated link states\n")
6417 u_short instance
= 0;
6419 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6421 ospf
= ospf_lookup_instance(instance
);
6423 return CMD_NOT_MY_INSTANCE
;
6425 if (!ospf
->oi_running
)
6428 return show_ip_ospf_database_common(vty
, ospf
, 1, argc
, argv
, 0);
6432 static int show_ip_ospf_database_type_adv_router_common(struct vty
*vty
,
6434 int arg_base
, int argc
,
6435 struct cmd_token
**argv
,
6440 struct in_addr adv_router
;
6443 vty_out(vty
, "\nOSPF Instance: %d\n", ospf
->instance
);
6445 ospf_show_vrf_name(ospf
, vty
, NULL
, use_vrf
);
6447 vty_out(vty
, "\n OSPF Router with ID (%s)\n\n",
6448 inet_ntoa(ospf
->router_id
));
6450 /* Set database type to show. */
6451 if (strncmp(argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
6452 type
= OSPF_ROUTER_LSA
;
6453 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
6454 type
= OSPF_NETWORK_LSA
;
6455 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
6456 type
= OSPF_AS_NSSA_LSA
;
6457 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "s", 1) == 0)
6458 type
= OSPF_SUMMARY_LSA
;
6459 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
6460 type
= OSPF_ASBR_SUMMARY_LSA
;
6461 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
6462 type
= OSPF_AS_EXTERNAL_LSA
;
6463 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
6464 type
= OSPF_OPAQUE_LINK_LSA
;
6465 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
6466 type
= OSPF_OPAQUE_AREA_LSA
;
6467 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
6468 type
= OSPF_OPAQUE_AS_LSA
;
6472 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
6473 if (strncmp(argv
[arg_base
+ 5]->text
, "s", 1) == 0)
6474 adv_router
= ospf
->router_id
;
6476 ret
= inet_aton(argv
[arg_base
+ 6]->arg
, &adv_router
);
6481 show_lsa_detail_adv_router(vty
, ospf
, type
, &adv_router
);
6486 DEFUN (show_ip_ospf_instance_database_type_adv_router
,
6487 show_ip_ospf_instance_database_type_adv_router_cmd
,
6488 "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>",
6491 "OSPF information\n"
6494 "Database summary\n"
6496 "Advertising Router link states\n"
6497 "Advertising Router (as an IP address)\n"
6498 "Self-originated link states\n")
6500 struct ospf
*ospf
= NULL
;
6501 u_short instance
= 0;
6502 struct listnode
*node
= NULL
;
6503 char *vrf_name
= NULL
;
6504 bool all_vrf
= FALSE
;
6505 int ret
= CMD_SUCCESS
;
6507 int idx
= 0, idx_vrf
= 0;
6510 if (argv_find(argv
, argc
, "(1-65535)", &idx
)) {
6511 instance
= strtoul(argv
[idx
]->arg
, NULL
, 10);
6512 ospf
= ospf_lookup_instance(instance
);
6514 return CMD_NOT_MY_INSTANCE
;
6515 if (!ospf
->oi_running
)
6517 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
,
6524 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
6529 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
6530 if (!ospf
->oi_running
)
6532 ret
= show_ip_ospf_database_type_adv_router_common(vty
,
6533 ospf
, idx
? 1 : 0, argc
, argv
,
6537 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
6538 if ((ospf
== NULL
) || !ospf
->oi_running
)
6540 ret
= show_ip_ospf_database_type_adv_router_common(vty
,
6541 ospf
, idx
? 1 : 0, argc
, argv
,
6545 /* Display default ospf (instance 0) info */
6546 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
6547 if (ospf
== NULL
|| !ospf
->oi_running
)
6549 ret
= show_ip_ospf_database_type_adv_router_common(vty
, ospf
,
6555 /*return (show_ip_ospf_database_type_adv_router_common(
6556 vty, ospf, idx ? 1 : 0, argc, argv));*/
6559 DEFUN (ip_ospf_authentication_args
,
6560 ip_ospf_authentication_args_addr_cmd
,
6561 "ip ospf authentication <null|message-digest> [A.B.C.D]",
6563 "OSPF interface commands\n"
6564 "Enable authentication on this interface\n"
6565 "Use null authentication\n"
6566 "Use message-digest authentication\n"
6567 "Address of interface\n")
6569 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6570 int idx_encryption
= 3;
6572 struct in_addr addr
;
6574 struct ospf_if_params
*params
;
6576 params
= IF_DEF_PARAMS(ifp
);
6579 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6582 "Please specify interface address by A.B.C.D\n");
6583 return CMD_WARNING_CONFIG_FAILED
;
6586 params
= ospf_get_if_params(ifp
, addr
);
6587 ospf_if_update_params(ifp
, addr
);
6590 /* Handle null authentication */
6591 if (argv
[idx_encryption
]->arg
[0] == 'n') {
6592 SET_IF_PARAM(params
, auth_type
);
6593 params
->auth_type
= OSPF_AUTH_NULL
;
6597 /* Handle message-digest authentication */
6598 if (argv
[idx_encryption
]->arg
[0] == 'm') {
6599 SET_IF_PARAM(params
, auth_type
);
6600 params
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
6604 vty_out(vty
, "You shouldn't get here!\n");
6605 return CMD_WARNING_CONFIG_FAILED
;
6608 DEFUN (ip_ospf_authentication
,
6609 ip_ospf_authentication_addr_cmd
,
6610 "ip ospf authentication [A.B.C.D]",
6612 "OSPF interface commands\n"
6613 "Enable authentication on this interface\n"
6614 "Address of interface\n")
6616 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6618 struct in_addr addr
;
6620 struct ospf_if_params
*params
;
6622 params
= IF_DEF_PARAMS(ifp
);
6625 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6628 "Please specify interface address by A.B.C.D\n");
6629 return CMD_WARNING_CONFIG_FAILED
;
6632 params
= ospf_get_if_params(ifp
, addr
);
6633 ospf_if_update_params(ifp
, addr
);
6636 SET_IF_PARAM(params
, auth_type
);
6637 params
->auth_type
= OSPF_AUTH_SIMPLE
;
6642 DEFUN (no_ip_ospf_authentication_args
,
6643 no_ip_ospf_authentication_args_addr_cmd
,
6644 "no ip ospf authentication <null|message-digest> [A.B.C.D]",
6647 "OSPF interface commands\n"
6648 "Enable authentication on this interface\n"
6649 "Use null authentication\n"
6650 "Use message-digest authentication\n"
6651 "Address of interface\n")
6653 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6654 int idx_encryption
= 4;
6656 struct in_addr addr
;
6658 struct ospf_if_params
*params
;
6659 struct route_node
*rn
;
6662 params
= IF_DEF_PARAMS(ifp
);
6665 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6668 "Please specify interface address by A.B.C.D\n");
6669 return CMD_WARNING_CONFIG_FAILED
;
6672 params
= ospf_lookup_if_params(ifp
, addr
);
6673 if (params
== NULL
) {
6674 vty_out(vty
, "Ip Address specified is unknown\n");
6675 return CMD_WARNING_CONFIG_FAILED
;
6677 params
->auth_type
= OSPF_AUTH_NOTSET
;
6678 UNSET_IF_PARAM(params
, auth_type
);
6679 if (params
!= IF_DEF_PARAMS(ifp
)) {
6680 ospf_free_if_params(ifp
, addr
);
6681 ospf_if_update_params(ifp
, addr
);
6684 if (argv
[idx_encryption
]->arg
[0] == 'n') {
6685 auth_type
= OSPF_AUTH_NULL
;
6686 } else if (argv
[idx_encryption
]->arg
[0] == 'm') {
6687 auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
6689 vty_out(vty
, "Unexpected input encountered\n");
6690 return CMD_WARNING_CONFIG_FAILED
;
6693 * Here we have a case where the user has entered
6694 * 'no ip ospf authentication (null | message_digest )'
6695 * we need to find if we have any ip addresses underneath it
6697 * correspond to the associated type.
6699 if (params
->auth_type
== auth_type
) {
6700 params
->auth_type
= OSPF_AUTH_NOTSET
;
6701 UNSET_IF_PARAM(params
, auth_type
);
6704 for (rn
= route_top(IF_OIFS_PARAMS(ifp
)); rn
;
6705 rn
= route_next(rn
)) {
6706 if ((params
= rn
->info
)) {
6707 if (params
->auth_type
== auth_type
) {
6708 params
->auth_type
= OSPF_AUTH_NOTSET
;
6709 UNSET_IF_PARAM(params
, auth_type
);
6710 if (params
!= IF_DEF_PARAMS(ifp
)) {
6711 ospf_free_if_params(
6712 ifp
, rn
->p
.u
.prefix4
);
6713 ospf_if_update_params(
6714 ifp
, rn
->p
.u
.prefix4
);
6724 DEFUN (no_ip_ospf_authentication
,
6725 no_ip_ospf_authentication_addr_cmd
,
6726 "no ip ospf authentication [A.B.C.D]",
6729 "OSPF interface commands\n"
6730 "Enable authentication on this interface\n"
6731 "Address of interface\n")
6733 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6735 struct in_addr addr
;
6737 struct ospf_if_params
*params
;
6738 struct route_node
*rn
;
6740 params
= IF_DEF_PARAMS(ifp
);
6743 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6746 "Please specify interface address by A.B.C.D\n");
6747 return CMD_WARNING_CONFIG_FAILED
;
6750 params
= ospf_lookup_if_params(ifp
, addr
);
6751 if (params
== NULL
) {
6752 vty_out(vty
, "Ip Address specified is unknown\n");
6753 return CMD_WARNING_CONFIG_FAILED
;
6756 params
->auth_type
= OSPF_AUTH_NOTSET
;
6757 UNSET_IF_PARAM(params
, auth_type
);
6758 if (params
!= IF_DEF_PARAMS(ifp
)) {
6759 ospf_free_if_params(ifp
, addr
);
6760 ospf_if_update_params(ifp
, addr
);
6764 * When a user enters 'no ip ospf authentication'
6765 * We should remove all authentication types from
6768 if ((params
->auth_type
== OSPF_AUTH_NULL
)
6769 || (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
6770 || (params
->auth_type
== OSPF_AUTH_SIMPLE
)) {
6771 params
->auth_type
= OSPF_AUTH_NOTSET
;
6772 UNSET_IF_PARAM(params
, auth_type
);
6775 for (rn
= route_top(IF_OIFS_PARAMS(ifp
)); rn
;
6776 rn
= route_next(rn
)) {
6777 if ((params
= rn
->info
)) {
6779 if ((params
->auth_type
== OSPF_AUTH_NULL
)
6780 || (params
->auth_type
6781 == OSPF_AUTH_CRYPTOGRAPHIC
)
6782 || (params
->auth_type
6783 == OSPF_AUTH_SIMPLE
)) {
6784 params
->auth_type
= OSPF_AUTH_NOTSET
;
6785 UNSET_IF_PARAM(params
, auth_type
);
6786 if (params
!= IF_DEF_PARAMS(ifp
)) {
6787 ospf_free_if_params(
6788 ifp
, rn
->p
.u
.prefix4
);
6789 ospf_if_update_params(
6790 ifp
, rn
->p
.u
.prefix4
);
6801 DEFUN (ip_ospf_authentication_key
,
6802 ip_ospf_authentication_key_addr_cmd
,
6803 "ip ospf authentication-key AUTH_KEY [A.B.C.D]",
6805 "OSPF interface commands\n"
6806 "Authentication password (key)\n"
6807 "The OSPF password (key)\n"
6808 "Address of interface\n")
6810 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6812 struct in_addr addr
;
6813 struct ospf_if_params
*params
;
6815 params
= IF_DEF_PARAMS(ifp
);
6817 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6818 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6820 "Please specify interface address by A.B.C.D\n");
6821 return CMD_WARNING_CONFIG_FAILED
;
6824 params
= ospf_get_if_params(ifp
, addr
);
6825 ospf_if_update_params(ifp
, addr
);
6828 memset(params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
6829 strncpy((char *)params
->auth_simple
, argv
[3]->arg
,
6830 OSPF_AUTH_SIMPLE_SIZE
);
6831 SET_IF_PARAM(params
, auth_simple
);
6836 DEFUN_HIDDEN (ospf_authentication_key
,
6837 ospf_authentication_key_cmd
,
6838 "ospf authentication-key AUTH_KEY [A.B.C.D]",
6839 "OSPF interface commands\n"
6840 VLINK_HELPSTR_AUTH_SIMPLE
6841 "Address of interface\n")
6843 return ip_ospf_authentication_key(self
, vty
, argc
, argv
);
6846 DEFUN (no_ip_ospf_authentication_key
,
6847 no_ip_ospf_authentication_key_authkey_addr_cmd
,
6848 "no ip ospf authentication-key [AUTH_KEY [A.B.C.D]]",
6851 "OSPF interface commands\n"
6852 VLINK_HELPSTR_AUTH_SIMPLE
6853 "Address of interface\n")
6855 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6857 struct in_addr addr
;
6858 struct ospf_if_params
*params
;
6859 params
= IF_DEF_PARAMS(ifp
);
6861 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6862 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6864 "Please specify interface address by A.B.C.D\n");
6865 return CMD_WARNING_CONFIG_FAILED
;
6868 params
= ospf_lookup_if_params(ifp
, addr
);
6873 memset(params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
);
6874 UNSET_IF_PARAM(params
, auth_simple
);
6876 if (params
!= IF_DEF_PARAMS(ifp
)) {
6877 ospf_free_if_params(ifp
, addr
);
6878 ospf_if_update_params(ifp
, addr
);
6884 DEFUN_HIDDEN (no_ospf_authentication_key
,
6885 no_ospf_authentication_key_authkey_addr_cmd
,
6886 "no ospf authentication-key [AUTH_KEY [A.B.C.D]]",
6888 "OSPF interface commands\n"
6889 VLINK_HELPSTR_AUTH_SIMPLE
6890 "Address of interface\n")
6892 return no_ip_ospf_authentication_key(self
, vty
, argc
, argv
);
6895 DEFUN (ip_ospf_message_digest_key
,
6896 ip_ospf_message_digest_key_cmd
,
6897 "ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
6899 "OSPF interface commands\n"
6900 "Message digest authentication password (key)\n"
6902 "Use MD5 algorithm\n"
6903 "The OSPF password (key)\n"
6904 "Address of interface\n")
6906 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6907 struct crypt_key
*ck
;
6909 struct in_addr addr
;
6910 struct ospf_if_params
*params
;
6912 params
= IF_DEF_PARAMS(ifp
);
6915 argv_find(argv
, argc
, "(1-255)", &idx
);
6916 char *keyid
= argv
[idx
]->arg
;
6917 argv_find(argv
, argc
, "KEY", &idx
);
6918 char *cryptkey
= argv
[idx
]->arg
;
6920 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6921 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6923 "Please specify interface address by A.B.C.D\n");
6924 return CMD_WARNING_CONFIG_FAILED
;
6927 params
= ospf_get_if_params(ifp
, addr
);
6928 ospf_if_update_params(ifp
, addr
);
6931 key_id
= strtol(keyid
, NULL
, 10);
6932 if (ospf_crypt_key_lookup(params
->auth_crypt
, key_id
) != NULL
) {
6933 vty_out(vty
, "OSPF: Key %d already exists\n", key_id
);
6937 ck
= ospf_crypt_key_new();
6938 ck
->key_id
= (u_char
)key_id
;
6939 memset(ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+ 1);
6940 strncpy((char *)ck
->auth_key
, cryptkey
, OSPF_AUTH_MD5_SIZE
);
6942 ospf_crypt_key_add(params
->auth_crypt
, ck
);
6943 SET_IF_PARAM(params
, auth_crypt
);
6948 DEFUN_HIDDEN (ospf_message_digest_key
,
6949 ospf_message_digest_key_cmd
,
6950 "ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
6951 "OSPF interface commands\n"
6952 "Message digest authentication password (key)\n"
6954 "Use MD5 algorithm\n"
6955 "The OSPF password (key)\n"
6956 "Address of interface\n")
6958 return ip_ospf_message_digest_key(self
, vty
, argc
, argv
);
6961 DEFUN (no_ip_ospf_message_digest_key
,
6962 no_ip_ospf_message_digest_key_cmd
,
6963 "no ip ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
6966 "OSPF interface commands\n"
6967 "Message digest authentication password (key)\n"
6969 "Use MD5 algorithm\n"
6970 "The OSPF password (key)\n"
6971 "Address of interface\n")
6973 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6975 struct crypt_key
*ck
;
6977 struct in_addr addr
;
6978 struct ospf_if_params
*params
;
6979 params
= IF_DEF_PARAMS(ifp
);
6981 argv_find(argv
, argc
, "(1-255)", &idx
);
6982 char *keyid
= argv
[idx
]->arg
;
6984 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6985 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6987 "Please specify interface address by A.B.C.D\n");
6988 return CMD_WARNING_CONFIG_FAILED
;
6991 params
= ospf_lookup_if_params(ifp
, addr
);
6996 key_id
= strtol(keyid
, NULL
, 10);
6997 ck
= ospf_crypt_key_lookup(params
->auth_crypt
, key_id
);
6999 vty_out(vty
, "OSPF: Key %d does not exist\n", key_id
);
7000 return CMD_WARNING_CONFIG_FAILED
;
7003 ospf_crypt_key_delete(params
->auth_crypt
, key_id
);
7005 if (params
!= IF_DEF_PARAMS(ifp
)) {
7006 ospf_free_if_params(ifp
, addr
);
7007 ospf_if_update_params(ifp
, addr
);
7013 DEFUN_HIDDEN (no_ospf_message_digest_key
,
7014 no_ospf_message_digest_key_cmd
,
7015 "no ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
7017 "OSPF interface commands\n"
7018 "Message digest authentication password (key)\n"
7020 "Use MD5 algorithm\n"
7021 "The OSPF password (key)\n"
7022 "Address of interface\n")
7024 return no_ip_ospf_message_digest_key(self
, vty
, argc
, argv
);
7027 DEFUN (ip_ospf_cost
,
7029 "ip ospf cost (1-65535) [A.B.C.D]",
7031 "OSPF interface commands\n"
7034 "Address of interface\n")
7036 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7038 u_int32_t cost
= OSPF_OUTPUT_COST_DEFAULT
;
7039 struct in_addr addr
;
7040 struct ospf_if_params
*params
;
7041 params
= IF_DEF_PARAMS(ifp
);
7044 char *coststr
= NULL
, *ifaddr
= NULL
;
7046 argv_find(argv
, argc
, "(1-65535)", &idx
);
7047 coststr
= argv
[idx
]->arg
;
7048 cost
= strtol(coststr
, NULL
, 10);
7050 ifaddr
= argv_find(argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
7052 if (!inet_aton(ifaddr
, &addr
)) {
7054 "Please specify interface address by A.B.C.D\n");
7055 return CMD_WARNING_CONFIG_FAILED
;
7058 params
= ospf_get_if_params(ifp
, addr
);
7059 ospf_if_update_params(ifp
, addr
);
7062 SET_IF_PARAM(params
, output_cost_cmd
);
7063 params
->output_cost_cmd
= cost
;
7065 ospf_if_recalculate_output_cost(ifp
);
7070 DEFUN_HIDDEN (ospf_cost
,
7072 "ospf cost (1-65535) [A.B.C.D]",
7073 "OSPF interface commands\n"
7076 "Address of interface\n")
7078 return ip_ospf_cost(self
, vty
, argc
, argv
);
7081 DEFUN (no_ip_ospf_cost
,
7082 no_ip_ospf_cost_cmd
,
7083 "no ip ospf cost [(1-65535)] [A.B.C.D]",
7086 "OSPF interface commands\n"
7089 "Address of interface\n")
7091 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7093 struct in_addr addr
;
7094 struct ospf_if_params
*params
;
7096 params
= IF_DEF_PARAMS(ifp
);
7099 char *ifaddr
= NULL
;
7100 ifaddr
= argv_find(argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
7102 /* According to the semantics we are mimicking "no ip ospf cost N" is
7103 * always treated as "no ip ospf cost" regardless of the actual value
7104 * of N already configured for the interface. Thus ignore cost. */
7107 if (!inet_aton(ifaddr
, &addr
)) {
7109 "Please specify interface address by A.B.C.D\n");
7110 return CMD_WARNING_CONFIG_FAILED
;
7113 params
= ospf_lookup_if_params(ifp
, addr
);
7118 UNSET_IF_PARAM(params
, output_cost_cmd
);
7120 if (params
!= IF_DEF_PARAMS(ifp
)) {
7121 ospf_free_if_params(ifp
, addr
);
7122 ospf_if_update_params(ifp
, addr
);
7125 ospf_if_recalculate_output_cost(ifp
);
7130 DEFUN_HIDDEN (no_ospf_cost
,
7132 "no ospf cost [(1-65535)] [A.B.C.D]",
7134 "OSPF interface commands\n"
7137 "Address of interface\n")
7139 return no_ip_ospf_cost(self
, vty
, argc
, argv
);
7142 static void ospf_nbr_timer_update(struct ospf_interface
*oi
)
7144 struct route_node
*rn
;
7145 struct ospf_neighbor
*nbr
;
7147 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
))
7148 if ((nbr
= rn
->info
)) {
7149 nbr
->v_inactivity
= OSPF_IF_PARAM(oi
, v_wait
);
7150 nbr
->v_db_desc
= OSPF_IF_PARAM(oi
, retransmit_interval
);
7151 nbr
->v_ls_req
= OSPF_IF_PARAM(oi
, retransmit_interval
);
7152 nbr
->v_ls_upd
= OSPF_IF_PARAM(oi
, retransmit_interval
);
7156 static int ospf_vty_dead_interval_set(struct vty
*vty
, const char *interval_str
,
7157 const char *nbr_str
,
7158 const char *fast_hello_str
)
7160 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7163 struct in_addr addr
;
7165 struct ospf_if_params
*params
;
7166 struct ospf_interface
*oi
;
7167 struct route_node
*rn
;
7169 params
= IF_DEF_PARAMS(ifp
);
7172 ret
= inet_aton(nbr_str
, &addr
);
7175 "Please specify interface address by A.B.C.D\n");
7176 return CMD_WARNING_CONFIG_FAILED
;
7179 params
= ospf_get_if_params(ifp
, addr
);
7180 ospf_if_update_params(ifp
, addr
);
7184 seconds
= strtoul(interval_str
, NULL
, 10);
7186 /* reset fast_hello too, just to be sure */
7187 UNSET_IF_PARAM(params
, fast_hello
);
7188 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
7189 } else if (fast_hello_str
) {
7190 hellomult
= strtoul(fast_hello_str
, NULL
, 10);
7191 /* 1s dead-interval with sub-second hellos desired */
7192 seconds
= OSPF_ROUTER_DEAD_INTERVAL_MINIMAL
;
7193 SET_IF_PARAM(params
, fast_hello
);
7194 params
->fast_hello
= hellomult
;
7197 "Please specify dead-interval or hello-multiplier\n");
7198 return CMD_WARNING_CONFIG_FAILED
;
7201 SET_IF_PARAM(params
, v_wait
);
7202 params
->v_wait
= seconds
;
7204 /* Update timer values in neighbor structure. */
7206 struct ospf
*ospf
= NULL
;
7208 ospf
= ospf_lookup_by_vrf_id(ifp
->vrf_id
);
7210 oi
= ospf_if_lookup_by_local_addr(ospf
, ifp
, addr
);
7212 ospf_nbr_timer_update(oi
);
7215 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
))
7216 if ((oi
= rn
->info
))
7217 ospf_nbr_timer_update(oi
);
7223 DEFUN (ip_ospf_dead_interval
,
7224 ip_ospf_dead_interval_cmd
,
7225 "ip ospf dead-interval (1-65535) [A.B.C.D]",
7227 "OSPF interface commands\n"
7228 "Interval time after which a neighbor is declared down\n"
7230 "Address of interface\n")
7233 char *interval
= argv_find(argv
, argc
, "(1-65535)", &idx
)
7237 argv_find(argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
7238 return ospf_vty_dead_interval_set(vty
, interval
, ifaddr
, NULL
);
7242 DEFUN_HIDDEN (ospf_dead_interval
,
7243 ospf_dead_interval_cmd
,
7244 "ospf dead-interval (1-65535) [A.B.C.D]",
7245 "OSPF interface commands\n"
7246 "Interval time after which a neighbor is declared down\n"
7248 "Address of interface\n")
7250 return ip_ospf_dead_interval(self
, vty
, argc
, argv
);
7253 DEFUN (ip_ospf_dead_interval_minimal
,
7254 ip_ospf_dead_interval_minimal_addr_cmd
,
7255 "ip ospf dead-interval minimal hello-multiplier (1-10) [A.B.C.D]",
7257 "OSPF interface commands\n"
7258 "Interval time after which a neighbor is declared down\n"
7259 "Minimal 1s dead-interval with fast sub-second hellos\n"
7260 "Hello multiplier factor\n"
7261 "Number of Hellos to send each second\n"
7262 "Address of interface\n")
7267 return ospf_vty_dead_interval_set(
7268 vty
, NULL
, argv
[idx_ipv4
]->arg
, argv
[idx_number
]->arg
);
7270 return ospf_vty_dead_interval_set(vty
, NULL
, NULL
,
7271 argv
[idx_number
]->arg
);
7274 DEFUN (no_ip_ospf_dead_interval
,
7275 no_ip_ospf_dead_interval_cmd
,
7276 "no ip ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
7279 "OSPF interface commands\n"
7280 "Interval time after which a neighbor is declared down\n"
7282 "Minimal 1s dead-interval with fast sub-second hellos\n"
7283 "Hello multiplier factor\n"
7284 "Number of Hellos to send each second\n"
7285 "Address of interface\n")
7287 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7288 int idx_ipv4
= argc
- 1;
7289 struct in_addr addr
= {.s_addr
= 0L};
7291 struct ospf_if_params
*params
;
7292 struct ospf_interface
*oi
;
7293 struct route_node
*rn
;
7295 params
= IF_DEF_PARAMS(ifp
);
7297 if (argv
[idx_ipv4
]->type
== IPV4_TKN
) {
7298 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7301 "Please specify interface address by A.B.C.D\n");
7302 return CMD_WARNING_CONFIG_FAILED
;
7305 params
= ospf_lookup_if_params(ifp
, addr
);
7310 UNSET_IF_PARAM(params
, v_wait
);
7311 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
7313 UNSET_IF_PARAM(params
, fast_hello
);
7314 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
7316 if (params
!= IF_DEF_PARAMS(ifp
)) {
7317 ospf_free_if_params(ifp
, addr
);
7318 ospf_if_update_params(ifp
, addr
);
7321 /* Update timer values in neighbor structure. */
7323 struct ospf
*ospf
= NULL
;
7325 ospf
= ospf_lookup_by_vrf_id(ifp
->vrf_id
);
7327 oi
= ospf_if_lookup_by_local_addr(ospf
, ifp
, addr
);
7329 ospf_nbr_timer_update(oi
);
7332 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
))
7333 if ((oi
= rn
->info
))
7334 ospf_nbr_timer_update(oi
);
7340 DEFUN_HIDDEN (no_ospf_dead_interval
,
7341 no_ospf_dead_interval_cmd
,
7342 "no ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
7344 "OSPF interface commands\n"
7345 "Interval time after which a neighbor is declared down\n"
7347 "Minimal 1s dead-interval with fast sub-second hellos\n"
7348 "Hello multiplier factor\n"
7349 "Number of Hellos to send each second\n"
7350 "Address of interface\n")
7352 return no_ip_ospf_dead_interval(self
, vty
, argc
, argv
);
7355 DEFUN (ip_ospf_hello_interval
,
7356 ip_ospf_hello_interval_cmd
,
7357 "ip ospf hello-interval (1-65535) [A.B.C.D]",
7359 "OSPF interface commands\n"
7360 "Time between HELLO packets\n"
7362 "Address of interface\n")
7364 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7366 struct in_addr addr
;
7367 struct ospf_if_params
*params
;
7368 params
= IF_DEF_PARAMS(ifp
);
7369 u_int32_t seconds
= 0;
7371 argv_find(argv
, argc
, "(1-65535)", &idx
);
7372 seconds
= strtol(argv
[idx
]->arg
, NULL
, 10);
7374 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7375 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7377 "Please specify interface address by A.B.C.D\n");
7378 return CMD_WARNING_CONFIG_FAILED
;
7381 params
= ospf_get_if_params(ifp
, addr
);
7382 ospf_if_update_params(ifp
, addr
);
7385 SET_IF_PARAM(params
, v_hello
);
7386 params
->v_hello
= seconds
;
7391 DEFUN_HIDDEN (ospf_hello_interval
,
7392 ospf_hello_interval_cmd
,
7393 "ospf hello-interval (1-65535) [A.B.C.D]",
7394 "OSPF interface commands\n"
7395 "Time between HELLO packets\n"
7397 "Address of interface\n")
7399 return ip_ospf_hello_interval(self
, vty
, argc
, argv
);
7402 DEFUN (no_ip_ospf_hello_interval
,
7403 no_ip_ospf_hello_interval_cmd
,
7404 "no ip ospf hello-interval [(1-65535) [A.B.C.D]]",
7407 "OSPF interface commands\n"
7408 "Time between HELLO packets\n" // ignored
7410 "Address of interface\n")
7412 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7414 struct in_addr addr
;
7415 struct ospf_if_params
*params
;
7417 params
= IF_DEF_PARAMS(ifp
);
7419 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7420 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7422 "Please specify interface address by A.B.C.D\n");
7423 return CMD_WARNING_CONFIG_FAILED
;
7426 params
= ospf_lookup_if_params(ifp
, addr
);
7431 UNSET_IF_PARAM(params
, v_hello
);
7432 params
->v_hello
= OSPF_HELLO_INTERVAL_DEFAULT
;
7434 if (params
!= IF_DEF_PARAMS(ifp
)) {
7435 ospf_free_if_params(ifp
, addr
);
7436 ospf_if_update_params(ifp
, addr
);
7442 DEFUN_HIDDEN (no_ospf_hello_interval
,
7443 no_ospf_hello_interval_cmd
,
7444 "no ospf hello-interval [(1-65535) [A.B.C.D]]",
7446 "OSPF interface commands\n"
7447 "Time between HELLO packets\n" // ignored
7449 "Address of interface\n")
7451 return no_ip_ospf_hello_interval(self
, vty
, argc
, argv
);
7454 DEFUN (ip_ospf_network
,
7455 ip_ospf_network_cmd
,
7456 "ip ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
7458 "OSPF interface commands\n"
7460 "Specify OSPF broadcast multi-access network\n"
7461 "Specify OSPF NBMA network\n"
7462 "Specify OSPF point-to-multipoint network\n"
7463 "Specify OSPF point-to-point network\n")
7465 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7467 int old_type
= IF_DEF_PARAMS(ifp
)->type
;
7468 struct route_node
*rn
;
7470 if (old_type
== OSPF_IFTYPE_LOOPBACK
) {
7472 "This is a loopback interface. Can't set network type.\n");
7473 return CMD_WARNING_CONFIG_FAILED
;
7476 if (argv_find(argv
, argc
, "broadcast", &idx
))
7477 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_BROADCAST
;
7478 else if (argv_find(argv
, argc
, "non-broadcast", &idx
))
7479 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_NBMA
;
7480 else if (argv_find(argv
, argc
, "point-to-multipoint", &idx
))
7481 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_POINTOMULTIPOINT
;
7482 else if (argv_find(argv
, argc
, "point-to-point", &idx
))
7483 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_POINTOPOINT
;
7485 if (IF_DEF_PARAMS(ifp
)->type
== old_type
)
7488 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), type
);
7490 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
7491 struct ospf_interface
*oi
= rn
->info
;
7496 oi
->type
= IF_DEF_PARAMS(ifp
)->type
;
7498 if (oi
->state
> ISM_Down
) {
7499 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceDown
);
7500 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceUp
);
7507 DEFUN_HIDDEN (ospf_network
,
7509 "ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
7510 "OSPF interface commands\n"
7512 "Specify OSPF broadcast multi-access network\n"
7513 "Specify OSPF NBMA network\n"
7514 "Specify OSPF point-to-multipoint network\n"
7515 "Specify OSPF point-to-point network\n")
7517 return ip_ospf_network(self
, vty
, argc
, argv
);
7520 DEFUN (no_ip_ospf_network
,
7521 no_ip_ospf_network_cmd
,
7522 "no ip ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
7525 "OSPF interface commands\n"
7527 "Specify OSPF broadcast multi-access network\n"
7528 "Specify OSPF NBMA network\n"
7529 "Specify OSPF point-to-multipoint network\n"
7530 "Specify OSPF point-to-point network\n")
7532 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7533 int old_type
= IF_DEF_PARAMS(ifp
)->type
;
7534 struct route_node
*rn
;
7536 IF_DEF_PARAMS(ifp
)->type
= ospf_default_iftype(ifp
);
7538 if (IF_DEF_PARAMS(ifp
)->type
== old_type
)
7541 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
7542 struct ospf_interface
*oi
= rn
->info
;
7547 oi
->type
= IF_DEF_PARAMS(ifp
)->type
;
7549 if (oi
->state
> ISM_Down
) {
7550 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceDown
);
7551 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceUp
);
7558 DEFUN_HIDDEN (no_ospf_network
,
7559 no_ospf_network_cmd
,
7560 "no ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
7562 "OSPF interface commands\n"
7564 "Specify OSPF broadcast multi-access network\n"
7565 "Specify OSPF NBMA network\n"
7566 "Specify OSPF point-to-multipoint network\n"
7567 "Specify OSPF point-to-point network\n")
7569 return no_ip_ospf_network(self
, vty
, argc
, argv
);
7572 DEFUN (ip_ospf_priority
,
7573 ip_ospf_priority_cmd
,
7574 "ip ospf priority (0-255) [A.B.C.D]",
7576 "OSPF interface commands\n"
7579 "Address of interface\n")
7581 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7584 struct route_node
*rn
;
7585 struct in_addr addr
;
7586 struct ospf_if_params
*params
;
7587 params
= IF_DEF_PARAMS(ifp
);
7589 argv_find(argv
, argc
, "(0-255)", &idx
);
7590 priority
= strtol(argv
[idx
]->arg
, NULL
, 10);
7592 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7593 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7595 "Please specify interface address by A.B.C.D\n");
7596 return CMD_WARNING_CONFIG_FAILED
;
7599 params
= ospf_get_if_params(ifp
, addr
);
7600 ospf_if_update_params(ifp
, addr
);
7603 SET_IF_PARAM(params
, priority
);
7604 params
->priority
= priority
;
7606 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
7607 struct ospf_interface
*oi
= rn
->info
;
7612 if (PRIORITY(oi
) != OSPF_IF_PARAM(oi
, priority
)) {
7613 PRIORITY(oi
) = OSPF_IF_PARAM(oi
, priority
);
7614 OSPF_ISM_EVENT_SCHEDULE(oi
, ISM_NeighborChange
);
7621 DEFUN_HIDDEN (ospf_priority
,
7623 "ospf priority (0-255) [A.B.C.D]",
7624 "OSPF interface commands\n"
7627 "Address of interface\n")
7629 return ip_ospf_priority(self
, vty
, argc
, argv
);
7632 DEFUN (no_ip_ospf_priority
,
7633 no_ip_ospf_priority_cmd
,
7634 "no ip ospf priority [(0-255) [A.B.C.D]]",
7637 "OSPF interface commands\n"
7638 "Router priority\n" // ignored
7640 "Address of interface\n")
7642 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7644 struct route_node
*rn
;
7645 struct in_addr addr
;
7646 struct ospf_if_params
*params
;
7648 params
= IF_DEF_PARAMS(ifp
);
7650 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7651 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7653 "Please specify interface address by A.B.C.D\n");
7654 return CMD_WARNING_CONFIG_FAILED
;
7657 params
= ospf_lookup_if_params(ifp
, addr
);
7662 UNSET_IF_PARAM(params
, priority
);
7663 params
->priority
= OSPF_ROUTER_PRIORITY_DEFAULT
;
7665 if (params
!= IF_DEF_PARAMS(ifp
)) {
7666 ospf_free_if_params(ifp
, addr
);
7667 ospf_if_update_params(ifp
, addr
);
7670 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
7671 struct ospf_interface
*oi
= rn
->info
;
7676 if (PRIORITY(oi
) != OSPF_IF_PARAM(oi
, priority
)) {
7677 PRIORITY(oi
) = OSPF_IF_PARAM(oi
, priority
);
7678 OSPF_ISM_EVENT_SCHEDULE(oi
, ISM_NeighborChange
);
7685 DEFUN_HIDDEN (no_ospf_priority
,
7686 no_ospf_priority_cmd
,
7687 "no ospf priority [(0-255) [A.B.C.D]]",
7689 "OSPF interface commands\n"
7692 "Address of interface\n")
7694 return no_ip_ospf_priority(self
, vty
, argc
, argv
);
7697 DEFUN (ip_ospf_retransmit_interval
,
7698 ip_ospf_retransmit_interval_addr_cmd
,
7699 "ip ospf retransmit-interval (3-65535) [A.B.C.D]",
7701 "OSPF interface commands\n"
7702 "Time between retransmitting lost link state advertisements\n"
7704 "Address of interface\n")
7706 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7709 struct in_addr addr
;
7710 struct ospf_if_params
*params
;
7711 params
= IF_DEF_PARAMS(ifp
);
7713 argv_find(argv
, argc
, "(3-65535)", &idx
);
7714 seconds
= strtol(argv
[idx
]->arg
, NULL
, 10);
7716 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7717 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7719 "Please specify interface address by A.B.C.D\n");
7720 return CMD_WARNING_CONFIG_FAILED
;
7723 params
= ospf_get_if_params(ifp
, addr
);
7724 ospf_if_update_params(ifp
, addr
);
7727 SET_IF_PARAM(params
, retransmit_interval
);
7728 params
->retransmit_interval
= seconds
;
7733 DEFUN_HIDDEN (ospf_retransmit_interval
,
7734 ospf_retransmit_interval_cmd
,
7735 "ospf retransmit-interval (3-65535) [A.B.C.D]",
7736 "OSPF interface commands\n"
7737 "Time between retransmitting lost link state advertisements\n"
7739 "Address of interface\n")
7741 return ip_ospf_retransmit_interval(self
, vty
, argc
, argv
);
7744 DEFUN (no_ip_ospf_retransmit_interval
,
7745 no_ip_ospf_retransmit_interval_addr_cmd
,
7746 "no ip ospf retransmit-interval [(3-65535)] [A.B.C.D]",
7749 "OSPF interface commands\n"
7750 "Time between retransmitting lost link state advertisements\n"
7752 "Address of interface\n")
7754 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7756 struct in_addr addr
;
7757 struct ospf_if_params
*params
;
7759 params
= IF_DEF_PARAMS(ifp
);
7761 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7762 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7764 "Please specify interface address by A.B.C.D\n");
7765 return CMD_WARNING_CONFIG_FAILED
;
7768 params
= ospf_lookup_if_params(ifp
, addr
);
7773 UNSET_IF_PARAM(params
, retransmit_interval
);
7774 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
7776 if (params
!= IF_DEF_PARAMS(ifp
)) {
7777 ospf_free_if_params(ifp
, addr
);
7778 ospf_if_update_params(ifp
, addr
);
7784 DEFUN_HIDDEN (no_ospf_retransmit_interval
,
7785 no_ospf_retransmit_interval_cmd
,
7786 "no ospf retransmit-interval [(3-65535)] [A.B.C.D]",
7788 "OSPF interface commands\n"
7789 "Time between retransmitting lost link state advertisements\n"
7791 "Address of interface\n")
7793 return no_ip_ospf_retransmit_interval(self
, vty
, argc
, argv
);
7796 DEFUN (ip_ospf_transmit_delay
,
7797 ip_ospf_transmit_delay_addr_cmd
,
7798 "ip ospf transmit-delay (1-65535) [A.B.C.D]",
7800 "OSPF interface commands\n"
7801 "Link state transmit delay\n"
7803 "Address of interface\n")
7805 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7808 struct in_addr addr
;
7809 struct ospf_if_params
*params
;
7811 params
= IF_DEF_PARAMS(ifp
);
7812 argv_find(argv
, argc
, "(1-65535)", &idx
);
7813 seconds
= strtol(argv
[idx
]->arg
, NULL
, 10);
7815 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7816 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7818 "Please specify interface address by A.B.C.D\n");
7819 return CMD_WARNING_CONFIG_FAILED
;
7822 params
= ospf_get_if_params(ifp
, addr
);
7823 ospf_if_update_params(ifp
, addr
);
7826 SET_IF_PARAM(params
, transmit_delay
);
7827 params
->transmit_delay
= seconds
;
7832 DEFUN_HIDDEN (ospf_transmit_delay
,
7833 ospf_transmit_delay_cmd
,
7834 "ospf transmit-delay (1-65535) [A.B.C.D]",
7835 "OSPF interface commands\n"
7836 "Link state transmit delay\n"
7838 "Address of interface\n")
7840 return ip_ospf_transmit_delay(self
, vty
, argc
, argv
);
7843 DEFUN (no_ip_ospf_transmit_delay
,
7844 no_ip_ospf_transmit_delay_addr_cmd
,
7845 "no ip ospf transmit-delay [(1-65535)] [A.B.C.D]",
7848 "OSPF interface commands\n"
7849 "Link state transmit delay\n"
7851 "Address of interface\n")
7853 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7855 struct in_addr addr
;
7856 struct ospf_if_params
*params
;
7858 params
= IF_DEF_PARAMS(ifp
);
7860 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7861 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7863 "Please specify interface address by A.B.C.D\n");
7864 return CMD_WARNING_CONFIG_FAILED
;
7867 params
= ospf_lookup_if_params(ifp
, addr
);
7872 UNSET_IF_PARAM(params
, transmit_delay
);
7873 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
7875 if (params
!= IF_DEF_PARAMS(ifp
)) {
7876 ospf_free_if_params(ifp
, addr
);
7877 ospf_if_update_params(ifp
, addr
);
7884 DEFUN_HIDDEN (no_ospf_transmit_delay
,
7885 no_ospf_transmit_delay_cmd
,
7886 "no ospf transmit-delay [(1-65535) [A.B.C.D]]",
7888 "OSPF interface commands\n"
7889 "Link state transmit delay\n"
7891 "Address of interface\n")
7893 return no_ip_ospf_transmit_delay(self
, vty
, argc
, argv
);
7896 DEFUN (ip_ospf_area
,
7898 "ip ospf [(1-65535)] area <A.B.C.D|(0-4294967295)> [A.B.C.D]",
7900 "OSPF interface commands\n"
7902 "Enable OSPF on this interface\n"
7903 "OSPF area ID in IP address format\n"
7904 "OSPF area ID as a decimal value\n"
7905 "Address of interface\n")
7907 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7910 struct in_addr area_id
;
7911 struct in_addr addr
;
7912 struct ospf_if_params
*params
= NULL
;
7913 struct route_node
*rn
;
7914 struct ospf
*ospf
= NULL
;
7915 u_short instance
= 0;
7918 if (argv_find(argv
, argc
, "(1-65535)", &idx
))
7919 instance
= strtol(argv
[idx
]->arg
, NULL
, 10);
7921 argv_find(argv
, argc
, "area", &idx
);
7922 areaid
= argv
[idx
+ 1]->arg
;
7924 if (ifp
->vrf_id
&& !instance
)
7925 ospf
= ospf_lookup_by_vrf_id(ifp
->vrf_id
);
7927 ospf
= ospf_lookup_instance(instance
);
7930 params
= IF_DEF_PARAMS(ifp
);
7931 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
7932 UNSET_IF_PARAM(params
, if_area
);
7933 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
7934 ospf_interface_area_unset(ospf
, ifp
);
7935 ospf
->if_ospf_cli_count
--;
7937 return CMD_NOT_MY_INSTANCE
;
7940 ret
= str2area_id(areaid
, &area_id
, &format
);
7942 vty_out(vty
, "Please specify area by A.B.C.D|<0-4294967295>\n");
7943 return CMD_WARNING_CONFIG_FAILED
;
7945 if (memcmp(ifp
->name
, "VLINK", 5) == 0) {
7946 vty_out(vty
, "Cannot enable OSPF on a virtual link.\n");
7947 return CMD_WARNING_CONFIG_FAILED
;
7950 params
= IF_DEF_PARAMS(ifp
);
7951 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)
7952 && !IPV4_ADDR_SAME(¶ms
->if_area
, &area_id
)) {
7954 "Must remove previous area config before changing ospf area \n");
7955 return CMD_WARNING_CONFIG_FAILED
;
7958 // Check if we have an address arg and proccess it
7959 if (argc
== idx
+ 3) {
7960 if (!inet_aton(argv
[idx
+ 2]->arg
, &addr
)) {
7961 vty_out(vty
, "Please specify Intf Address by A.B.C.D\n");
7962 return CMD_WARNING_CONFIG_FAILED
;
7964 // update/create address-level params
7965 params
= ospf_get_if_params((ifp
), (addr
));
7966 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
7968 "Must remove previous area/address config before changing ospf area");
7969 return CMD_WARNING_CONFIG_FAILED
;
7971 ospf_if_update_params((ifp
), (addr
));
7974 for (rn
= route_top(ospf
->networks
); rn
; rn
= route_next(rn
)) {
7975 if (rn
->info
!= NULL
) {
7977 "Please remove all network commands first.\n");
7978 return CMD_WARNING_CONFIG_FAILED
;
7982 /* enable ospf on this interface with area_id */
7984 SET_IF_PARAM(params
, if_area
);
7985 params
->if_area
= area_id
;
7986 params
->if_area_id_fmt
= format
;
7988 ospf_interface_area_set(ospf
, ifp
);
7989 ospf
->if_ospf_cli_count
++;
7994 DEFUN (no_ip_ospf_area
,
7995 no_ip_ospf_area_cmd
,
7996 "no ip ospf [(1-65535)] area [<A.B.C.D|(0-4294967295)> [A.B.C.D]]",
7999 "OSPF interface commands\n"
8001 "Disable OSPF on this interface\n"
8002 "OSPF area ID in IP address format\n"
8003 "OSPF area ID as a decimal value\n"
8004 "Address of interface\n")
8006 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8009 struct ospf_if_params
*params
;
8010 u_short instance
= 0;
8011 struct in_addr addr
;
8013 if (argv_find(argv
, argc
, "(1-65535)", &idx
))
8014 instance
= strtol(argv
[idx
]->arg
, NULL
, 10);
8016 if (ifp
->vrf_id
&& !instance
)
8017 ospf
= ospf_lookup_by_vrf_id(ifp
->vrf_id
);
8019 ospf
= ospf_lookup_instance(instance
);
8022 return CMD_NOT_MY_INSTANCE
;
8024 argv_find(argv
, argc
, "area", &idx
);
8026 // Check if we have an address arg and proccess it
8027 if (argc
== idx
+ 3) {
8028 if (!inet_aton(argv
[idx
+ 2]->arg
, &addr
)) {
8029 vty_out(vty
, "Please specify Intf Address by A.B.C.D\n");
8030 return CMD_WARNING_CONFIG_FAILED
;
8032 params
= ospf_lookup_if_params(ifp
, addr
);
8033 if ((params
) == NULL
)
8036 params
= IF_DEF_PARAMS(ifp
);
8038 if (!OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
8040 "Can't find specified interface area configuration.\n");
8041 return CMD_WARNING_CONFIG_FAILED
;
8044 UNSET_IF_PARAM(params
, if_area
);
8045 if (params
!= IF_DEF_PARAMS((ifp
))) {
8046 ospf_free_if_params((ifp
), (addr
));
8047 ospf_if_update_params((ifp
), (addr
));
8050 ospf_interface_area_unset(ospf
, ifp
);
8051 ospf
->if_ospf_cli_count
--;
8055 DEFUN (ospf_redistribute_source
,
8056 ospf_redistribute_source_cmd
,
8057 "redistribute " FRR_REDIST_STR_OSPFD
" [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
8059 FRR_REDIST_HELP_STR_OSPFD
8060 "Metric for redistributed routes\n"
8061 "OSPF default metric\n"
8062 "OSPF exterior metric type for redistributed routes\n"
8063 "Set OSPF External Type 1/2 metrics\n"
8064 "Route map reference\n"
8065 "Pointer to route-map entries\n")
8067 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8068 int idx_protocol
= 1;
8072 struct ospf_redist
*red
;
8078 /* Get distribute source. */
8079 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
8081 return CMD_WARNING_CONFIG_FAILED
;
8083 red
= ospf_redist_add(ospf
, source
, 0);
8085 /* Get metric value. */
8086 if (argv_find(argv
, argc
, "(0-16777214)", &idx
)) {
8087 if (!str2metric(argv
[idx
]->arg
, &metric
))
8088 return CMD_WARNING_CONFIG_FAILED
;
8090 /* Get metric type. */
8091 else if (argv_find(argv
, argc
, "(1-2)", &idx
)) {
8092 if (!str2metric_type(argv
[idx
]->arg
, &type
))
8093 return CMD_WARNING_CONFIG_FAILED
;
8096 else if (argv_find(argv
, argc
, "WORD", &idx
)) {
8097 ospf_routemap_set(red
, argv
[idx
]->arg
);
8099 ospf_routemap_unset(red
);
8101 return ospf_redistribute_set(ospf
, source
, 0, type
, metric
);
8104 DEFUN (no_ospf_redistribute_source
,
8105 no_ospf_redistribute_source_cmd
,
8106 "no redistribute " FRR_REDIST_STR_OSPFD
" [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
8109 FRR_REDIST_HELP_STR_OSPFD
8110 "Metric for redistributed routes\n"
8111 "OSPF default metric\n"
8112 "OSPF exterior metric type for redistributed routes\n"
8113 "Set OSPF External Type 1/2 metrics\n"
8114 "Route map reference\n"
8115 "Pointer to route-map entries\n")
8117 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8118 int idx_protocol
= 2;
8120 struct ospf_redist
*red
;
8122 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
8124 return CMD_WARNING_CONFIG_FAILED
;
8126 red
= ospf_redist_lookup(ospf
, source
, 0);
8130 ospf_routemap_unset(red
);
8131 return ospf_redistribute_unset(ospf
, source
, 0);
8134 DEFUN (ospf_redistribute_instance_source
,
8135 ospf_redistribute_instance_source_cmd
,
8136 "redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
8138 "Open Shortest Path First\n"
8139 "Non-main Kernel Routing Table\n"
8140 "Instance ID/Table ID\n"
8141 "Metric for redistributed routes\n"
8142 "OSPF default metric\n"
8143 "OSPF exterior metric type for redistributed routes\n"
8144 "Set OSPF External Type 1/2 metrics\n"
8145 "Route map reference\n"
8146 "Pointer to route-map entries\n")
8148 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8149 int idx_ospf_table
= 1;
8156 struct ospf_redist
*red
;
8161 source
= proto_redistnum(AFI_IP
, argv
[idx_ospf_table
]->text
);
8163 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8168 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
) {
8170 "Instance redistribution in non-instanced OSPF not allowed\n");
8171 return CMD_WARNING_CONFIG_FAILED
;
8174 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
)) {
8175 vty_out(vty
, "Same instance OSPF redistribution not allowed\n");
8176 return CMD_WARNING_CONFIG_FAILED
;
8179 /* Get metric value. */
8180 if (argv_find(argv
, argc
, "metric", &idx
))
8181 if (!str2metric(argv
[idx
+ 1]->arg
, &metric
))
8182 return CMD_WARNING_CONFIG_FAILED
;
8185 /* Get metric type. */
8186 if (argv_find(argv
, argc
, "metric-type", &idx
))
8187 if (!str2metric_type(argv
[idx
+ 1]->arg
, &type
))
8188 return CMD_WARNING_CONFIG_FAILED
;
8190 red
= ospf_redist_add(ospf
, source
, instance
);
8193 if (argv_find(argv
, argc
, "route-map", &idx
))
8194 ospf_routemap_set(red
, argv
[idx
+ 1]->arg
);
8196 ospf_routemap_unset(red
);
8198 return ospf_redistribute_set(ospf
, source
, instance
, type
, metric
);
8201 DEFUN (no_ospf_redistribute_instance_source
,
8202 no_ospf_redistribute_instance_source_cmd
,
8203 "no redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
8206 "Open Shortest Path First\n"
8207 "Non-main Kernel Routing Table\n"
8208 "Instance ID/Table Id\n"
8209 "Metric for redistributed routes\n"
8210 "OSPF default metric\n"
8211 "OSPF exterior metric type for redistributed routes\n"
8212 "Set OSPF External Type 1/2 metrics\n"
8213 "Route map reference\n"
8214 "Pointer to route-map entries\n")
8216 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8217 int idx_ospf_table
= 2;
8220 struct ospf_redist
*red
;
8223 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
8224 source
= ZEBRA_ROUTE_OSPF
;
8226 source
= ZEBRA_ROUTE_TABLE
;
8228 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8230 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
) {
8232 "Instance redistribution in non-instanced OSPF not allowed\n");
8233 return CMD_WARNING_CONFIG_FAILED
;
8236 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
)) {
8237 vty_out(vty
, "Same instance OSPF redistribution not allowed\n");
8238 return CMD_WARNING_CONFIG_FAILED
;
8241 red
= ospf_redist_lookup(ospf
, source
, instance
);
8245 ospf_routemap_unset(red
);
8246 return ospf_redistribute_unset(ospf
, source
, instance
);
8249 DEFUN (ospf_distribute_list_out
,
8250 ospf_distribute_list_out_cmd
,
8251 "distribute-list WORD out " FRR_REDIST_STR_OSPFD
,
8252 "Filter networks in routing updates\n"
8253 "Access-list name\n"
8255 FRR_REDIST_HELP_STR_OSPFD
)
8257 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8261 char *proto
= argv
[argc
- 1]->text
;
8263 /* Get distribute source. */
8264 source
= proto_redistnum(AFI_IP
, proto
);
8266 return CMD_WARNING_CONFIG_FAILED
;
8268 return ospf_distribute_list_out_set(ospf
, source
, argv
[idx_word
]->arg
);
8271 DEFUN (no_ospf_distribute_list_out
,
8272 no_ospf_distribute_list_out_cmd
,
8273 "no distribute-list WORD out " FRR_REDIST_STR_OSPFD
,
8275 "Filter networks in routing updates\n"
8276 "Access-list name\n"
8278 FRR_REDIST_HELP_STR_OSPFD
)
8280 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8284 char *proto
= argv
[argc
- 1]->text
;
8285 source
= proto_redistnum(AFI_IP
, proto
);
8287 return CMD_WARNING_CONFIG_FAILED
;
8289 return ospf_distribute_list_out_unset(ospf
, source
,
8290 argv
[idx_word
]->arg
);
8293 /* Default information originate. */
8294 DEFUN (ospf_default_information_originate
,
8295 ospf_default_information_originate_cmd
,
8296 "default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
8297 "Control distribution of default information\n"
8298 "Distribute a default route\n"
8299 "Always advertise default route\n"
8300 "OSPF default metric\n"
8302 "OSPF metric type for default routes\n"
8303 "Set OSPF External Type 1/2 metrics\n"
8304 "Route map reference\n"
8305 "Pointer to route-map entries\n")
8307 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8308 int default_originate
= DEFAULT_ORIGINATE_ZEBRA
;
8311 struct ospf_redist
*red
;
8314 red
= ospf_redist_add(ospf
, DEFAULT_ROUTE
, 0);
8316 /* Check whether "always" was specified */
8317 if (argv_find(argv
, argc
, "always", &idx
))
8318 default_originate
= DEFAULT_ORIGINATE_ALWAYS
;
8319 /* Get metric value */
8320 else if (argv_find(argv
, argc
, "(0-16777214)", &idx
)) {
8321 if (!str2metric(argv
[idx
]->arg
, &metric
))
8322 return CMD_WARNING_CONFIG_FAILED
;
8324 /* Get metric type. */
8325 else if (argv_find(argv
, argc
, "(1-2)", &idx
)) {
8326 if (!str2metric_type(argv
[idx
]->arg
, &type
))
8327 return CMD_WARNING_CONFIG_FAILED
;
8330 else if (argv_find(argv
, argc
, "WORD", &idx
))
8331 ospf_routemap_set(red
, argv
[idx
]->arg
);
8333 ospf_routemap_unset(red
);
8335 return ospf_redistribute_default_set(ospf
, default_originate
, type
,
8339 DEFUN (no_ospf_default_information_originate
,
8340 no_ospf_default_information_originate_cmd
,
8341 "no default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
8343 "Control distribution of default information\n"
8344 "Distribute a default route\n"
8345 "Always advertise default route\n"
8346 "OSPF default metric\n"
8348 "OSPF metric type for default routes\n"
8349 "Set OSPF External Type 1/2 metrics\n"
8350 "Route map reference\n"
8351 "Pointer to route-map entries\n")
8353 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8354 struct prefix_ipv4 p
;
8355 struct ospf_external
*ext
;
8356 struct ospf_redist
*red
;
8359 p
.prefix
.s_addr
= 0;
8362 ospf_external_lsa_flush(ospf
, DEFAULT_ROUTE
, &p
, 0);
8364 if ((ext
= ospf_external_lookup(DEFAULT_ROUTE
, 0))
8365 && EXTERNAL_INFO(ext
)) {
8366 ospf_external_info_delete(DEFAULT_ROUTE
, 0, p
);
8367 ospf_external_del(DEFAULT_ROUTE
, 0);
8370 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
8374 ospf_routemap_unset(red
);
8375 return ospf_redistribute_default_unset(ospf
);
8378 DEFUN (ospf_default_metric
,
8379 ospf_default_metric_cmd
,
8380 "default-metric (0-16777214)",
8381 "Set metric of redistributed routes\n"
8384 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8388 if (!str2metric(argv
[idx_number
]->arg
, &metric
))
8389 return CMD_WARNING_CONFIG_FAILED
;
8391 ospf
->default_metric
= metric
;
8396 DEFUN (no_ospf_default_metric
,
8397 no_ospf_default_metric_cmd
,
8398 "no default-metric [(0-16777214)]",
8400 "Set metric of redistributed routes\n"
8403 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8405 ospf
->default_metric
= -1;
8411 DEFUN (ospf_distance
,
8414 "Administrative distance\n"
8415 "OSPF Administrative distance\n")
8417 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8420 ospf
->distance_all
= atoi(argv
[idx_number
]->arg
);
8425 DEFUN (no_ospf_distance
,
8426 no_ospf_distance_cmd
,
8427 "no distance (1-255)",
8429 "Administrative distance\n"
8430 "OSPF Administrative distance\n")
8432 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8434 ospf
->distance_all
= 0;
8439 DEFUN (no_ospf_distance_ospf
,
8440 no_ospf_distance_ospf_cmd
,
8441 "no distance ospf [{intra-area [(1-255)]|inter-area [(1-255)]|external [(1-255)]}]",
8443 "Administrative distance\n"
8444 "OSPF administrative distance\n"
8445 "Intra-area routes\n"
8446 "Distance for intra-area routes\n"
8447 "Inter-area routes\n"
8448 "Distance for inter-area routes\n"
8450 "Distance for external routes\n")
8452 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8458 if (argv_find(argv
, argc
, "intra-area", &idx
) || argc
== 3)
8459 idx
= ospf
->distance_intra
= 0;
8460 if (argv_find(argv
, argc
, "inter-area", &idx
) || argc
== 3)
8461 idx
= ospf
->distance_inter
= 0;
8462 if (argv_find(argv
, argc
, "external", &idx
) || argc
== 3)
8463 ospf
->distance_external
= 0;
8468 DEFUN (ospf_distance_ospf
,
8469 ospf_distance_ospf_cmd
,
8470 "distance ospf {intra-area (1-255)|inter-area (1-255)|external (1-255)}",
8471 "Administrative distance\n"
8472 "OSPF administrative distance\n"
8473 "Intra-area routes\n"
8474 "Distance for intra-area routes\n"
8475 "Inter-area routes\n"
8476 "Distance for inter-area routes\n"
8478 "Distance for external routes\n")
8480 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8483 if (argv_find(argv
, argc
, "intra-area", &idx
))
8484 ospf
->distance_intra
= atoi(argv
[idx
+ 1]->arg
);
8486 if (argv_find(argv
, argc
, "inter-area", &idx
))
8487 ospf
->distance_inter
= atoi(argv
[idx
+ 1]->arg
);
8489 if (argv_find(argv
, argc
, "external", &idx
))
8490 ospf
->distance_external
= atoi(argv
[idx
+ 1]->arg
);
8496 DEFUN (ospf_distance_source
,
8497 ospf_distance_source_cmd
,
8498 "distance (1-255) A.B.C.D/M",
8499 "Administrative distance\n"
8501 "IP source prefix\n")
8503 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
8505 int idx_ipv4_prefixlen
= 2;
8510 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
8515 DEFUN (no_ospf_distance_source
,
8516 no_ospf_distance_source_cmd
,
8517 "no distance (1-255) A.B.C.D/M",
8519 "Administrative distance\n"
8521 "IP source prefix\n")
8523 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
8525 int idx_ipv4_prefixlen
= 3;
8530 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
8535 DEFUN (ospf_distance_source_access_list
,
8536 ospf_distance_source_access_list_cmd
,
8537 "distance (1-255) A.B.C.D/M WORD",
8538 "Administrative distance\n"
8540 "IP source prefix\n"
8541 "Access list name\n")
8543 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
8545 int idx_ipv4_prefixlen
= 2;
8551 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
8556 DEFUN (no_ospf_distance_source_access_list
,
8557 no_ospf_distance_source_access_list_cmd
,
8558 "no distance (1-255) A.B.C.D/M WORD",
8560 "Administrative distance\n"
8562 "IP source prefix\n"
8563 "Access list name\n")
8565 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
8567 int idx_ipv4_prefixlen
= 3;
8573 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
8579 DEFUN (ip_ospf_mtu_ignore
,
8580 ip_ospf_mtu_ignore_addr_cmd
,
8581 "ip ospf mtu-ignore [A.B.C.D]",
8583 "OSPF interface commands\n"
8584 "Disable MTU mismatch detection on this interface\n"
8585 "Address of interface\n")
8587 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8589 struct in_addr addr
;
8592 struct ospf_if_params
*params
;
8593 params
= IF_DEF_PARAMS(ifp
);
8596 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
8599 "Please specify interface address by A.B.C.D\n");
8600 return CMD_WARNING_CONFIG_FAILED
;
8602 params
= ospf_get_if_params(ifp
, addr
);
8603 ospf_if_update_params(ifp
, addr
);
8605 params
->mtu_ignore
= 1;
8606 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
8607 SET_IF_PARAM(params
, mtu_ignore
);
8609 UNSET_IF_PARAM(params
, mtu_ignore
);
8610 if (params
!= IF_DEF_PARAMS(ifp
)) {
8611 ospf_free_if_params(ifp
, addr
);
8612 ospf_if_update_params(ifp
, addr
);
8618 DEFUN (no_ip_ospf_mtu_ignore
,
8619 no_ip_ospf_mtu_ignore_addr_cmd
,
8620 "no ip ospf mtu-ignore [A.B.C.D]",
8623 "OSPF interface commands\n"
8624 "Disable MTU mismatch detection on this interface\n"
8625 "Address of interface\n")
8627 VTY_DECLVAR_CONTEXT(interface
, ifp
);
8629 struct in_addr addr
;
8632 struct ospf_if_params
*params
;
8633 params
= IF_DEF_PARAMS(ifp
);
8636 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
8639 "Please specify interface address by A.B.C.D\n");
8640 return CMD_WARNING_CONFIG_FAILED
;
8642 params
= ospf_get_if_params(ifp
, addr
);
8643 ospf_if_update_params(ifp
, addr
);
8645 params
->mtu_ignore
= 0;
8646 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
8647 SET_IF_PARAM(params
, mtu_ignore
);
8649 UNSET_IF_PARAM(params
, mtu_ignore
);
8650 if (params
!= IF_DEF_PARAMS(ifp
)) {
8651 ospf_free_if_params(ifp
, addr
);
8652 ospf_if_update_params(ifp
, addr
);
8659 DEFUN (ospf_max_metric_router_lsa_admin
,
8660 ospf_max_metric_router_lsa_admin_cmd
,
8661 "max-metric router-lsa administrative",
8662 "OSPF maximum / infinite-distance metric\n"
8663 "Advertise own Router-LSA with infinite distance (stub router)\n"
8664 "Administratively applied, for an indefinite period\n")
8666 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8667 struct listnode
*ln
;
8668 struct ospf_area
*area
;
8670 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
8671 SET_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
8673 if (!CHECK_FLAG(area
->stub_router_state
,
8674 OSPF_AREA_IS_STUB_ROUTED
))
8675 ospf_router_lsa_update_area(area
);
8678 /* Allows for areas configured later to get the property */
8679 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_SET
;
8684 DEFUN (no_ospf_max_metric_router_lsa_admin
,
8685 no_ospf_max_metric_router_lsa_admin_cmd
,
8686 "no max-metric router-lsa administrative",
8688 "OSPF maximum / infinite-distance metric\n"
8689 "Advertise own Router-LSA with infinite distance (stub router)\n"
8690 "Administratively applied, for an indefinite period\n")
8692 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8693 struct listnode
*ln
;
8694 struct ospf_area
*area
;
8696 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
8697 UNSET_FLAG(area
->stub_router_state
,
8698 OSPF_AREA_ADMIN_STUB_ROUTED
);
8700 /* Don't trample on the start-up stub timer */
8701 if (CHECK_FLAG(area
->stub_router_state
,
8702 OSPF_AREA_IS_STUB_ROUTED
)
8703 && !area
->t_stub_router
) {
8704 UNSET_FLAG(area
->stub_router_state
,
8705 OSPF_AREA_IS_STUB_ROUTED
);
8706 ospf_router_lsa_update_area(area
);
8709 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET
;
8713 DEFUN (ospf_max_metric_router_lsa_startup
,
8714 ospf_max_metric_router_lsa_startup_cmd
,
8715 "max-metric router-lsa on-startup (5-86400)",
8716 "OSPF maximum / infinite-distance metric\n"
8717 "Advertise own Router-LSA with infinite distance (stub router)\n"
8718 "Automatically advertise stub Router-LSA on startup of OSPF\n"
8719 "Time (seconds) to advertise self as stub-router\n")
8721 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8723 unsigned int seconds
;
8726 vty_out(vty
, "%% Must supply stub-router period");
8727 return CMD_WARNING_CONFIG_FAILED
;
8730 seconds
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8732 ospf
->stub_router_startup_time
= seconds
;
8737 DEFUN (no_ospf_max_metric_router_lsa_startup
,
8738 no_ospf_max_metric_router_lsa_startup_cmd
,
8739 "no max-metric router-lsa on-startup [(5-86400)]",
8741 "OSPF maximum / infinite-distance metric\n"
8742 "Advertise own Router-LSA with infinite distance (stub router)\n"
8743 "Automatically advertise stub Router-LSA on startup of OSPF\n"
8744 "Time (seconds) to advertise self as stub-router\n")
8746 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8747 struct listnode
*ln
;
8748 struct ospf_area
*area
;
8750 ospf
->stub_router_startup_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
8752 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
8753 SET_FLAG(area
->stub_router_state
,
8754 OSPF_AREA_WAS_START_STUB_ROUTED
);
8755 OSPF_TIMER_OFF(area
->t_stub_router
);
8757 /* Don't trample on admin stub routed */
8758 if (!CHECK_FLAG(area
->stub_router_state
,
8759 OSPF_AREA_ADMIN_STUB_ROUTED
)) {
8760 UNSET_FLAG(area
->stub_router_state
,
8761 OSPF_AREA_IS_STUB_ROUTED
);
8762 ospf_router_lsa_update_area(area
);
8769 DEFUN (ospf_max_metric_router_lsa_shutdown
,
8770 ospf_max_metric_router_lsa_shutdown_cmd
,
8771 "max-metric router-lsa on-shutdown (5-100)",
8772 "OSPF maximum / infinite-distance metric\n"
8773 "Advertise own Router-LSA with infinite distance (stub router)\n"
8774 "Advertise stub-router prior to full shutdown of OSPF\n"
8775 "Time (seconds) to wait till full shutdown\n")
8777 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8779 unsigned int seconds
;
8782 vty_out(vty
, "%% Must supply stub-router shutdown period");
8783 return CMD_WARNING_CONFIG_FAILED
;
8786 seconds
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8788 ospf
->stub_router_shutdown_time
= seconds
;
8793 DEFUN (no_ospf_max_metric_router_lsa_shutdown
,
8794 no_ospf_max_metric_router_lsa_shutdown_cmd
,
8795 "no max-metric router-lsa on-shutdown [(5-100)]",
8797 "OSPF maximum / infinite-distance metric\n"
8798 "Advertise own Router-LSA with infinite distance (stub router)\n"
8799 "Advertise stub-router prior to full shutdown of OSPF\n"
8800 "Time (seconds) to wait till full shutdown\n")
8802 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8804 ospf
->stub_router_shutdown_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
8809 static void config_write_stub_router(struct vty
*vty
, struct ospf
*ospf
)
8811 struct listnode
*ln
;
8812 struct ospf_area
*area
;
8814 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
8815 vty_out(vty
, " max-metric router-lsa on-startup %u\n",
8816 ospf
->stub_router_startup_time
);
8817 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
8818 vty_out(vty
, " max-metric router-lsa on-shutdown %u\n",
8819 ospf
->stub_router_shutdown_time
);
8820 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
8821 if (CHECK_FLAG(area
->stub_router_state
,
8822 OSPF_AREA_ADMIN_STUB_ROUTED
)) {
8823 vty_out(vty
, " max-metric router-lsa administrative\n");
8830 static void show_ip_ospf_route_network(struct vty
*vty
, struct ospf
*ospf
,
8831 struct route_table
*rt
)
8833 struct route_node
*rn
;
8834 struct ospf_route
* or ;
8835 struct listnode
*pnode
, *pnnode
;
8836 struct ospf_path
*path
;
8838 vty_out(vty
, "============ OSPF network routing table ============\n");
8840 for (rn
= route_top(rt
); rn
; rn
= route_next(rn
))
8841 if ((or = rn
->info
) != NULL
) {
8843 snprintf(buf1
, 19, "%s/%d", inet_ntoa(rn
->p
.u
.prefix4
),
8846 switch (or->path_type
) {
8847 case OSPF_PATH_INTER_AREA
:
8848 if (or->type
== OSPF_DESTINATION_NETWORK
)
8850 "N IA %-18s [%d] area: %s\n",
8852 inet_ntoa(or->u
.std
.area_id
));
8853 else if (or->type
== OSPF_DESTINATION_DISCARD
)
8855 "D IA %-18s Discard entry\n",
8858 case OSPF_PATH_INTRA_AREA
:
8859 vty_out(vty
, "N %-18s [%d] area: %s\n",
8861 inet_ntoa(or->u
.std
.area_id
));
8867 if (or->type
== OSPF_DESTINATION_NETWORK
)
8868 for (ALL_LIST_ELEMENTS(or->paths
, pnode
, pnnode
,
8870 if (if_lookup_by_index(path
->ifindex
,
8872 if (path
->nexthop
.s_addr
== 0)
8874 "%24s directly attached to %s\n",
8881 "%24s via %s, %s\n",
8894 static void show_ip_ospf_route_router(struct vty
*vty
, struct ospf
*ospf
,
8895 struct route_table
*rtrs
)
8897 struct route_node
*rn
;
8898 struct ospf_route
* or ;
8899 struct listnode
*pnode
;
8900 struct listnode
*node
;
8901 struct ospf_path
*path
;
8903 vty_out(vty
, "============ OSPF router routing table =============\n");
8904 for (rn
= route_top(rtrs
); rn
; rn
= route_next(rn
))
8908 vty_out(vty
, "R %-15s ",
8909 inet_ntoa(rn
->p
.u
.prefix4
));
8911 for (ALL_LIST_ELEMENTS_RO((struct list
*)rn
->info
, node
,
8914 vty_out(vty
, "%24s", "");
8917 vty_out(vty
, "%s [%d] area: %s",
8918 (or->path_type
== OSPF_PATH_INTER_AREA
8921 or->cost
, inet_ntoa(or->u
.std
.area_id
));
8923 vty_out(vty
, "%s%s\n",
8924 (or->u
.std
.flags
& ROUTER_LSA_BORDER
8927 (or->u
.std
.flags
& ROUTER_LSA_EXTERNAL
8931 for (ALL_LIST_ELEMENTS_RO(or->paths
, pnode
,
8933 if (if_lookup_by_index(path
->ifindex
,
8935 if (path
->nexthop
.s_addr
== 0)
8937 "%24s directly attached to %s\n",
8944 "%24s via %s, %s\n",
8958 static void show_ip_ospf_route_external(struct vty
*vty
, struct ospf
*ospf
,
8959 struct route_table
*rt
)
8961 struct route_node
*rn
;
8962 struct ospf_route
*er
;
8963 struct listnode
*pnode
, *pnnode
;
8964 struct ospf_path
*path
;
8966 vty_out(vty
, "============ OSPF external routing table ===========\n");
8967 for (rn
= route_top(rt
); rn
; rn
= route_next(rn
))
8968 if ((er
= rn
->info
) != NULL
) {
8970 snprintf(buf1
, 19, "%s/%d", inet_ntoa(rn
->p
.u
.prefix4
),
8973 switch (er
->path_type
) {
8974 case OSPF_PATH_TYPE1_EXTERNAL
:
8976 "N E1 %-18s [%d] tag: %" ROUTE_TAG_PRI
8978 buf1
, er
->cost
, er
->u
.ext
.tag
);
8980 case OSPF_PATH_TYPE2_EXTERNAL
:
8982 "N E2 %-18s [%d/%d] tag: %" ROUTE_TAG_PRI
8984 buf1
, er
->cost
, er
->u
.ext
.type2_cost
,
8989 for (ALL_LIST_ELEMENTS(er
->paths
, pnode
, pnnode
,
8991 if (if_lookup_by_index(path
->ifindex
,
8993 if (path
->nexthop
.s_addr
== 0)
8995 "%24s directly attached to %s\n",
9002 "%24s via %s, %s\n",
9015 static int show_ip_ospf_border_routers_common(struct vty
*vty
,
9020 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
9022 ospf_show_vrf_name(ospf
, vty
, NULL
, use_vrf
);
9024 if (ospf
->new_table
== NULL
) {
9025 vty_out(vty
, "No OSPF routing information exist\n");
9029 /* Show Network routes.
9030 show_ip_ospf_route_network (vty, ospf->new_table); */
9032 /* Show Router routes. */
9033 show_ip_ospf_route_router(vty
, ospf
, ospf
->new_rtrs
);
9040 DEFUN (show_ip_ospf_border_routers
,
9041 show_ip_ospf_border_routers_cmd
,
9042 "show ip ospf [vrf <NAME|all>] border-routers",
9045 "OSPF information\n"
9048 "Show all the ABR's and ASBR's\n")
9050 struct ospf
*ospf
= NULL
;
9051 struct listnode
*node
= NULL
;
9052 char *vrf_name
= NULL
;
9053 bool all_vrf
= FALSE
;
9054 int ret
= CMD_SUCCESS
;
9059 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
9064 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
9065 if (!ospf
->oi_running
)
9068 ret
= show_ip_ospf_border_routers_common(vty
,
9073 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
9074 if (ospf
== NULL
|| !ospf
->oi_running
)
9077 ret
= show_ip_ospf_border_routers_common(vty
, ospf
,
9081 /* Display default ospf (instance 0) info */
9082 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
9083 if (ospf
== NULL
|| !ospf
->oi_running
)
9085 ret
= show_ip_ospf_border_routers_common(vty
, ospf
, use_vrf
);
9091 DEFUN (show_ip_ospf_instance_border_routers
,
9092 show_ip_ospf_instance_border_routers_cmd
,
9093 "show ip ospf (1-65535) border-routers",
9096 "OSPF information\n"
9098 "Show all the ABR's and ASBR's\n")
9102 u_short instance
= 0;
9104 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
9105 ospf
= ospf_lookup_instance(instance
);
9107 return CMD_NOT_MY_INSTANCE
;
9109 if (!ospf
->oi_running
)
9112 return show_ip_ospf_border_routers_common(vty
, ospf
, 0);
9115 static int show_ip_ospf_route_common(struct vty
*vty
, struct ospf
*ospf
,
9119 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
9121 ospf_show_vrf_name(ospf
, vty
, NULL
, use_vrf
);
9123 if (ospf
->new_table
== NULL
) {
9124 vty_out(vty
, "No OSPF routing information exist\n");
9128 /* Show Network routes. */
9129 show_ip_ospf_route_network(vty
, ospf
, ospf
->new_table
);
9131 /* Show Router routes. */
9132 show_ip_ospf_route_router(vty
, ospf
, ospf
->new_rtrs
);
9134 /* Show AS External routes. */
9135 show_ip_ospf_route_external(vty
, ospf
, ospf
->old_external_route
);
9142 DEFUN (show_ip_ospf_route
,
9143 show_ip_ospf_route_cmd
,
9144 "show ip ospf [vrf <NAME|all>] route",
9147 "OSPF information\n"
9150 "OSPF routing table\n")
9152 struct ospf
*ospf
= NULL
;
9153 struct listnode
*node
= NULL
;
9154 char *vrf_name
= NULL
;
9155 bool all_vrf
= FALSE
;
9156 int ret
= CMD_SUCCESS
;
9161 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
9163 /* vrf input is provided could be all or specific vrf*/
9167 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
9168 if (!ospf
->oi_running
)
9170 ret
= show_ip_ospf_route_common(vty
, ospf
,
9175 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
9176 if (ospf
== NULL
|| !ospf
->oi_running
)
9179 /* Display default ospf (instance 0) info */
9180 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
9181 if (ospf
== NULL
|| !ospf
->oi_running
)
9186 ret
= show_ip_ospf_route_common(vty
, ospf
, use_vrf
);
9191 DEFUN (show_ip_ospf_instance_route
,
9192 show_ip_ospf_instance_route_cmd
,
9193 "show ip ospf (1-65535) route",
9196 "OSPF information\n"
9198 "OSPF routing table\n")
9202 u_short instance
= 0;
9204 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
9205 ospf
= ospf_lookup_instance(instance
);
9207 return CMD_NOT_MY_INSTANCE
;
9209 if (!ospf
->oi_running
)
9212 return show_ip_ospf_route_common(vty
, ospf
, 0);
9216 DEFUN (show_ip_ospf_vrfs
,
9217 show_ip_ospf_vrfs_cmd
,
9218 "show ip ospf vrfs [json]",
9221 "OSPF information\n"
9225 u_char uj
= use_json(argc
, argv
);
9226 json_object
*json
= NULL
;
9227 json_object
*json_vrfs
= NULL
;
9228 struct ospf
*ospf
= NULL
;
9229 struct listnode
*node
= NULL
;
9231 static char header
[] = "Name Id RouterId ";
9234 json
= json_object_new_object();
9235 json_vrfs
= json_object_new_object();
9238 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
9239 json_object
*json_vrf
= NULL
;
9240 const char *name
= NULL
;
9245 if (!uj
&& count
== 1)
9246 vty_out(vty
, "%s\n", header
);
9248 json_vrf
= json_object_new_object();
9250 if (ospf
->vrf_id
== 0)
9251 name
= VRF_DEFAULT_NAME
;
9255 vrf_id_ui
= (ospf
->vrf_id
== VRF_UNKNOWN
) ? -1 : ospf
->vrf_id
;
9258 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
9259 json_object_string_add(json_vrf
, "routerId",
9260 inet_ntoa(ospf
->router_id
));
9262 json_object_object_add(json_vrfs
, name
, json_vrf
);
9265 vty_out(vty
, "%-25s %-5d %-16s \n",
9266 name
, ospf
->vrf_id
, inet_ntoa(ospf
->router_id
));
9271 json_object_object_add(json
, "vrfs", json_vrfs
);
9272 json_object_int_add(json
, "totalVrfs", count
);
9274 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
9275 JSON_C_TO_STRING_PRETTY
));
9276 json_object_free(json
);
9279 vty_out(vty
, "\nTotal number of OSPF VRFs: %d\n",
9286 const char *ospf_abr_type_str
[] = {"unknown", "standard", "ibm", "cisco",
9289 const char *ospf_shortcut_mode_str
[] = {"default", "enable", "disable"};
9291 const char *ospf_int_type_str
[] = {"unknown", /* should never be used. */
9292 "point-to-point", "broadcast",
9293 "non-broadcast", "point-to-multipoint",
9294 "virtual-link", /* should never be used. */
9297 static int config_write_interface_one(struct vty
*vty
, struct ospf
*ospf
)
9299 struct vrf
*vrf
= vrf_lookup_by_id(ospf
->vrf_id
);
9300 struct listnode
*node
;
9301 struct interface
*ifp
;
9302 struct crypt_key
*ck
;
9303 struct route_node
*rn
= NULL
;
9304 struct ospf_if_params
*params
;
9307 FOR_ALL_INTERFACES (vrf
, ifp
) {
9308 struct vrf
*vrf
= NULL
;
9310 if (memcmp(ifp
->name
, "VLINK", 5) == 0)
9313 vrf
= vrf_lookup_by_id(ifp
->vrf_id
);
9315 vty_frame(vty
, "!\n");
9316 if (ifp
->vrf_id
== VRF_DEFAULT
|| vrf
== NULL
)
9317 vty_frame(vty
, "interface %s\n", ifp
->name
);
9319 vty_frame(vty
, "interface %s vrf %s\n",
9320 ifp
->name
, vrf
->name
);
9322 vty_out(vty
, " description %s\n", ifp
->desc
);
9326 params
= IF_DEF_PARAMS(ifp
);
9329 /* Interface Network print. */
9330 if (OSPF_IF_PARAM_CONFIGURED(params
, type
)
9331 && params
->type
!= OSPF_IFTYPE_LOOPBACK
) {
9332 if (params
->type
!= ospf_default_iftype(ifp
)) {
9333 vty_out(vty
, " ip ospf network %s",
9336 if (params
!= IF_DEF_PARAMS(ifp
))
9344 /* OSPF interface authentication print */
9345 if (OSPF_IF_PARAM_CONFIGURED(params
, auth_type
)
9346 && params
->auth_type
!= OSPF_AUTH_NOTSET
) {
9347 const char *auth_str
;
9349 /* Translation tables are not that much help
9350 * here due to syntax
9351 * of the simple option */
9352 switch (params
->auth_type
) {
9354 case OSPF_AUTH_NULL
:
9358 case OSPF_AUTH_SIMPLE
:
9362 case OSPF_AUTH_CRYPTOGRAPHIC
:
9363 auth_str
= " message-digest";
9371 vty_out(vty
, " ip ospf authentication%s",
9373 if (params
!= IF_DEF_PARAMS(ifp
))
9375 inet_ntoa(rn
->p
.u
.prefix4
));
9379 /* Simple Authentication Password print. */
9380 if (OSPF_IF_PARAM_CONFIGURED(params
, auth_simple
)
9381 && params
->auth_simple
[0] != '\0') {
9382 vty_out(vty
, " ip ospf authentication-key %s",
9383 params
->auth_simple
);
9384 if (params
!= IF_DEF_PARAMS(ifp
))
9386 inet_ntoa(rn
->p
.u
.prefix4
));
9390 /* Cryptographic Authentication Key print. */
9391 if (params
&& params
->auth_crypt
) {
9392 for (ALL_LIST_ELEMENTS_RO(params
->auth_crypt
,
9395 " ip ospf message-digest-key %d md5 %s",
9396 ck
->key_id
, ck
->auth_key
);
9397 if (params
!= IF_DEF_PARAMS(ifp
))
9399 inet_ntoa(rn
->p
.u
.prefix4
));
9404 /* Interface Output Cost print. */
9405 if (OSPF_IF_PARAM_CONFIGURED(params
,
9407 vty_out(vty
, " ip ospf cost %u",
9408 params
->output_cost_cmd
);
9409 if (params
!= IF_DEF_PARAMS(ifp
))
9411 inet_ntoa(rn
->p
.u
.prefix4
));
9415 /* Hello Interval print. */
9416 if (OSPF_IF_PARAM_CONFIGURED(params
, v_hello
)
9417 && params
->v_hello
!= OSPF_HELLO_INTERVAL_DEFAULT
) {
9418 vty_out(vty
, " ip ospf hello-interval %u",
9420 if (params
!= IF_DEF_PARAMS(ifp
))
9422 inet_ntoa(rn
->p
.u
.prefix4
));
9427 /* Router Dead Interval print. */
9428 if (OSPF_IF_PARAM_CONFIGURED(params
, v_wait
)
9430 != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
) {
9431 vty_out(vty
, " ip ospf dead-interval ");
9434 if (OSPF_IF_PARAM_CONFIGURED(params
,
9437 "minimal hello-multiplier %d",
9438 params
->fast_hello
);
9440 vty_out(vty
, "%u", params
->v_wait
);
9442 if (params
!= IF_DEF_PARAMS(ifp
))
9444 inet_ntoa(rn
->p
.u
.prefix4
));
9448 /* Router Priority print. */
9449 if (OSPF_IF_PARAM_CONFIGURED(params
, priority
)
9451 != OSPF_ROUTER_PRIORITY_DEFAULT
) {
9452 vty_out(vty
, " ip ospf priority %u",
9454 if (params
!= IF_DEF_PARAMS(ifp
))
9456 inet_ntoa(rn
->p
.u
.prefix4
));
9460 /* Retransmit Interval print. */
9461 if (OSPF_IF_PARAM_CONFIGURED(params
,
9462 retransmit_interval
)
9463 && params
->retransmit_interval
9464 != OSPF_RETRANSMIT_INTERVAL_DEFAULT
) {
9465 vty_out(vty
, " ip ospf retransmit-interval %u",
9466 params
->retransmit_interval
);
9467 if (params
!= IF_DEF_PARAMS(ifp
))
9469 inet_ntoa(rn
->p
.u
.prefix4
));
9473 /* Transmit Delay print. */
9474 if (OSPF_IF_PARAM_CONFIGURED(params
, transmit_delay
)
9475 && params
->transmit_delay
9476 != OSPF_TRANSMIT_DELAY_DEFAULT
) {
9477 vty_out(vty
, " ip ospf transmit-delay %u",
9478 params
->transmit_delay
);
9479 if (params
!= IF_DEF_PARAMS(ifp
))
9481 inet_ntoa(rn
->p
.u
.prefix4
));
9486 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
9488 vty_out(vty
, " ip ospf %d",
9491 vty_out(vty
, " ip ospf");
9494 size_t buflen
= MAX(strlen("4294967295"),
9495 strlen("255.255.255.255"));
9498 area_id2str(buf
, sizeof(buf
),
9500 params
->if_area_id_fmt
);
9501 vty_out(vty
, " area %s", buf
);
9502 if (params
!= IF_DEF_PARAMS(ifp
))
9504 inet_ntoa(rn
->p
.u
.prefix4
));
9509 ospf_bfd_write_config(vty
, params
);
9511 /* MTU ignore print. */
9512 if (OSPF_IF_PARAM_CONFIGURED(params
, mtu_ignore
)
9513 && params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
) {
9514 if (params
->mtu_ignore
== 0)
9515 vty_out(vty
, " no ip ospf mtu-ignore");
9517 vty_out(vty
, " ip ospf mtu-ignore");
9518 if (params
!= IF_DEF_PARAMS(ifp
))
9520 inet_ntoa(rn
->p
.u
.prefix4
));
9527 rn
= route_top(IF_OIFS_PARAMS(ifp
));
9529 rn
= route_next(rn
);
9539 ospf_opaque_config_write_if(vty
, ifp
);
9541 vty_endframe(vty
, NULL
);
9546 /* Configuration write function for ospfd. */
9547 static int config_write_interface(struct vty
*vty
)
9550 struct ospf
*ospf
= NULL
;
9551 struct listnode
*node
= NULL
;
9553 /* Traverse all ospf [vrf] instances */
9554 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
))
9555 write
+= config_write_interface_one(vty
, ospf
);
9560 static int config_write_network_area(struct vty
*vty
, struct ospf
*ospf
)
9562 struct route_node
*rn
;
9563 u_char buf
[INET_ADDRSTRLEN
];
9565 /* `network area' print. */
9566 for (rn
= route_top(ospf
->networks
); rn
; rn
= route_next(rn
))
9568 struct ospf_network
*n
= rn
->info
;
9570 memset(buf
, 0, INET_ADDRSTRLEN
);
9572 /* Create Area ID string by specified Area ID format. */
9573 if (n
->area_id_fmt
== OSPF_AREA_ID_FMT_DOTTEDQUAD
)
9574 strncpy((char *)buf
, inet_ntoa(n
->area_id
),
9577 sprintf((char *)buf
, "%lu",
9578 (unsigned long int)ntohl(
9579 n
->area_id
.s_addr
));
9581 /* Network print. */
9582 vty_out(vty
, " network %s/%d area %s\n",
9583 inet_ntoa(rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
9590 static int config_write_ospf_area(struct vty
*vty
, struct ospf
*ospf
)
9592 struct listnode
*node
;
9593 struct ospf_area
*area
;
9594 u_char buf
[INET_ADDRSTRLEN
];
9596 /* Area configuration print. */
9597 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
9598 struct route_node
*rn1
;
9600 area_id2str((char *)buf
, INET_ADDRSTRLEN
, &area
->area_id
,
9603 if (area
->auth_type
!= OSPF_AUTH_NULL
) {
9604 if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
9605 vty_out(vty
, " area %s authentication\n", buf
);
9608 " area %s authentication message-digest\n",
9612 if (area
->shortcut_configured
!= OSPF_SHORTCUT_DEFAULT
)
9613 vty_out(vty
, " area %s shortcut %s\n", buf
,
9614 ospf_shortcut_mode_str
9615 [area
->shortcut_configured
]);
9617 if ((area
->external_routing
== OSPF_AREA_STUB
)
9618 || (area
->external_routing
== OSPF_AREA_NSSA
)) {
9619 if (area
->external_routing
== OSPF_AREA_STUB
) {
9620 vty_out(vty
, " area %s stub", buf
);
9621 if (area
->no_summary
)
9622 vty_out(vty
, " no-summary\n");
9624 } else if (area
->external_routing
== OSPF_AREA_NSSA
) {
9625 switch (area
->NSSATranslatorRole
) {
9626 case OSPF_NSSA_ROLE_NEVER
:
9628 " area %s nssa translate-never\n",
9631 case OSPF_NSSA_ROLE_ALWAYS
:
9633 " area %s nssa translate-always\n",
9637 if (area
->no_summary
)
9639 " area %s nssa no-summary\n",
9643 if (area
->default_cost
!= 1)
9644 vty_out(vty
, " area %s default-cost %d\n", buf
,
9645 area
->default_cost
);
9648 for (rn1
= route_top(area
->ranges
); rn1
; rn1
= route_next(rn1
))
9650 struct ospf_area_range
*range
= rn1
->info
;
9652 vty_out(vty
, " area %s range %s/%d", buf
,
9653 inet_ntoa(rn1
->p
.u
.prefix4
),
9656 if (range
->cost_config
9657 != OSPF_AREA_RANGE_COST_UNSPEC
)
9658 vty_out(vty
, " cost %d",
9659 range
->cost_config
);
9661 if (!CHECK_FLAG(range
->flags
,
9662 OSPF_AREA_RANGE_ADVERTISE
))
9663 vty_out(vty
, " not-advertise");
9665 if (CHECK_FLAG(range
->flags
,
9666 OSPF_AREA_RANGE_SUBSTITUTE
))
9667 vty_out(vty
, " substitute %s/%d",
9668 inet_ntoa(range
->subst_addr
),
9669 range
->subst_masklen
);
9674 if (EXPORT_NAME(area
))
9675 vty_out(vty
, " area %s export-list %s\n", buf
,
9678 if (IMPORT_NAME(area
))
9679 vty_out(vty
, " area %s import-list %s\n", buf
,
9682 if (PREFIX_NAME_IN(area
))
9683 vty_out(vty
, " area %s filter-list prefix %s in\n", buf
,
9684 PREFIX_NAME_IN(area
));
9686 if (PREFIX_NAME_OUT(area
))
9687 vty_out(vty
, " area %s filter-list prefix %s out\n",
9688 buf
, PREFIX_NAME_OUT(area
));
9694 static int config_write_ospf_nbr_nbma(struct vty
*vty
, struct ospf
*ospf
)
9696 struct ospf_nbr_nbma
*nbr_nbma
;
9697 struct route_node
*rn
;
9699 /* Static Neighbor configuration print. */
9700 for (rn
= route_top(ospf
->nbr_nbma
); rn
; rn
= route_next(rn
))
9701 if ((nbr_nbma
= rn
->info
)) {
9702 vty_out(vty
, " neighbor %s", inet_ntoa(nbr_nbma
->addr
));
9704 if (nbr_nbma
->priority
9705 != OSPF_NEIGHBOR_PRIORITY_DEFAULT
)
9706 vty_out(vty
, " priority %d",
9707 nbr_nbma
->priority
);
9709 if (nbr_nbma
->v_poll
!= OSPF_POLL_INTERVAL_DEFAULT
)
9710 vty_out(vty
, " poll-interval %d",
9719 static int config_write_virtual_link(struct vty
*vty
, struct ospf
*ospf
)
9721 struct listnode
*node
;
9722 struct ospf_vl_data
*vl_data
;
9723 char buf
[INET_ADDRSTRLEN
];
9725 /* Virtual-Link print */
9726 for (ALL_LIST_ELEMENTS_RO(ospf
->vlinks
, node
, vl_data
)) {
9727 struct listnode
*n2
;
9728 struct crypt_key
*ck
;
9729 struct ospf_interface
*oi
;
9731 if (vl_data
!= NULL
) {
9732 memset(buf
, 0, INET_ADDRSTRLEN
);
9734 area_id2str(buf
, sizeof(buf
), &vl_data
->vl_area_id
,
9735 vl_data
->vl_area_id_fmt
);
9736 oi
= vl_data
->vl_oi
;
9739 if (OSPF_IF_PARAM(oi
, v_hello
)
9740 != OSPF_HELLO_INTERVAL_DEFAULT
9741 || OSPF_IF_PARAM(oi
, v_wait
)
9742 != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
9743 || OSPF_IF_PARAM(oi
, retransmit_interval
)
9744 != OSPF_RETRANSMIT_INTERVAL_DEFAULT
9745 || OSPF_IF_PARAM(oi
, transmit_delay
)
9746 != OSPF_TRANSMIT_DELAY_DEFAULT
)
9748 " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d\n",
9749 buf
, inet_ntoa(vl_data
->vl_peer
),
9750 OSPF_IF_PARAM(oi
, v_hello
),
9751 OSPF_IF_PARAM(oi
, retransmit_interval
),
9752 OSPF_IF_PARAM(oi
, transmit_delay
),
9753 OSPF_IF_PARAM(oi
, v_wait
));
9755 vty_out(vty
, " area %s virtual-link %s\n", buf
,
9756 inet_ntoa(vl_data
->vl_peer
));
9758 if (IF_DEF_PARAMS(vl_data
->vl_oi
->ifp
)->auth_simple
[0]
9761 " area %s virtual-link %s authentication-key %s\n",
9762 buf
, inet_ntoa(vl_data
->vl_peer
),
9763 IF_DEF_PARAMS(vl_data
->vl_oi
->ifp
)
9766 for (ALL_LIST_ELEMENTS_RO(
9767 IF_DEF_PARAMS(vl_data
->vl_oi
->ifp
)
9771 " area %s virtual-link %s"
9772 " message-digest-key %d md5 %s\n",
9773 buf
, inet_ntoa(vl_data
->vl_peer
),
9774 ck
->key_id
, ck
->auth_key
);
9782 static int config_write_ospf_redistribute(struct vty
*vty
, struct ospf
*ospf
)
9786 /* redistribute print. */
9787 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++) {
9788 struct list
*red_list
;
9789 struct listnode
*node
;
9790 struct ospf_redist
*red
;
9792 red_list
= ospf
->redist
[type
];
9796 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
9797 vty_out(vty
, " redistribute %s",
9798 zebra_route_string(type
));
9800 vty_out(vty
, " %d", red
->instance
);
9802 if (red
->dmetric
.value
>= 0)
9803 vty_out(vty
, " metric %d", red
->dmetric
.value
);
9805 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
9806 vty_out(vty
, " metric-type 1");
9808 if (ROUTEMAP_NAME(red
))
9809 vty_out(vty
, " route-map %s",
9810 ROUTEMAP_NAME(red
));
9819 static int config_write_ospf_default_metric(struct vty
*vty
, struct ospf
*ospf
)
9821 if (ospf
->default_metric
!= -1)
9822 vty_out(vty
, " default-metric %d\n", ospf
->default_metric
);
9826 static int config_write_ospf_distribute(struct vty
*vty
, struct ospf
*ospf
)
9829 struct ospf_redist
*red
;
9832 /* distribute-list print. */
9833 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
9834 if (DISTRIBUTE_NAME(ospf
, type
))
9835 vty_out(vty
, " distribute-list %s out %s\n",
9836 DISTRIBUTE_NAME(ospf
, type
),
9837 zebra_route_string(type
));
9839 /* default-information print. */
9840 if (ospf
->default_originate
!= DEFAULT_ORIGINATE_NONE
) {
9841 vty_out(vty
, " default-information originate");
9842 if (ospf
->default_originate
== DEFAULT_ORIGINATE_ALWAYS
)
9843 vty_out(vty
, " always");
9845 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
9847 if (red
->dmetric
.value
>= 0)
9848 vty_out(vty
, " metric %d",
9849 red
->dmetric
.value
);
9850 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
9851 vty_out(vty
, " metric-type 1");
9853 if (ROUTEMAP_NAME(red
))
9854 vty_out(vty
, " route-map %s",
9855 ROUTEMAP_NAME(red
));
9865 static int config_write_ospf_distance(struct vty
*vty
, struct ospf
*ospf
)
9867 struct route_node
*rn
;
9868 struct ospf_distance
*odistance
;
9870 if (ospf
->distance_all
)
9871 vty_out(vty
, " distance %d\n", ospf
->distance_all
);
9873 if (ospf
->distance_intra
|| ospf
->distance_inter
9874 || ospf
->distance_external
) {
9875 vty_out(vty
, " distance ospf");
9877 if (ospf
->distance_intra
)
9878 vty_out(vty
, " intra-area %d", ospf
->distance_intra
);
9879 if (ospf
->distance_inter
)
9880 vty_out(vty
, " inter-area %d", ospf
->distance_inter
);
9881 if (ospf
->distance_external
)
9882 vty_out(vty
, " external %d", ospf
->distance_external
);
9887 for (rn
= route_top(ospf
->distance_table
); rn
; rn
= route_next(rn
))
9888 if ((odistance
= rn
->info
) != NULL
) {
9889 vty_out(vty
, " distance %d %s/%d %s\n",
9890 odistance
->distance
, inet_ntoa(rn
->p
.u
.prefix4
),
9892 odistance
->access_list
? odistance
->access_list
9898 static int ospf_config_write_one(struct vty
*vty
, struct ospf
*ospf
)
9900 struct vrf
*vrf
= vrf_lookup_by_id(ospf
->vrf_id
);
9901 struct interface
*ifp
;
9902 struct ospf_interface
*oi
;
9903 struct listnode
*node
= NULL
;
9906 /* `router ospf' print. */
9907 if (ospf
->instance
&& ospf
->name
) {
9908 vty_out(vty
, "router ospf %d vrf %s\n",
9909 ospf
->instance
, ospf
->name
);
9910 } else if (ospf
->instance
) {
9911 vty_out(vty
, "router ospf %d\n",
9913 } else if (ospf
->name
) {
9914 vty_out(vty
, "router ospf vrf %s\n",
9917 vty_out(vty
, "router ospf\n");
9919 if (!ospf
->networks
) {
9924 /* Router ID print. */
9925 if (ospf
->router_id_static
.s_addr
!= 0)
9926 vty_out(vty
, " ospf router-id %s\n",
9927 inet_ntoa(ospf
->router_id_static
));
9929 /* ABR type print. */
9930 if (ospf
->abr_type
!= OSPF_ABR_DEFAULT
)
9931 vty_out(vty
, " ospf abr-type %s\n",
9932 ospf_abr_type_str
[ospf
->abr_type
]);
9934 /* log-adjacency-changes flag print. */
9935 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
)) {
9936 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
9937 vty_out(vty
, " log-adjacency-changes detail\n");
9938 else if (!DFLT_OSPF_LOG_ADJACENCY_CHANGES
)
9939 vty_out(vty
, " log-adjacency-changes\n");
9940 } else if (DFLT_OSPF_LOG_ADJACENCY_CHANGES
) {
9941 vty_out(vty
, " no log-adjacency-changes\n");
9944 /* RFC1583 compatibility flag print -- Compatible with CISCO
9946 if (CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
9947 vty_out(vty
, " compatible rfc1583\n");
9949 /* auto-cost reference-bandwidth configuration. */
9950 if (ospf
->ref_bandwidth
!= OSPF_DEFAULT_REF_BANDWIDTH
) {
9952 "! Important: ensure reference bandwidth "
9953 "is consistent across all routers\n");
9954 vty_out(vty
, " auto-cost reference-bandwidth %d\n",
9955 ospf
->ref_bandwidth
);
9958 /* SPF timers print. */
9959 if (ospf
->spf_delay
!= OSPF_SPF_DELAY_DEFAULT
9960 || ospf
->spf_holdtime
!= OSPF_SPF_HOLDTIME_DEFAULT
9961 || ospf
->spf_max_holdtime
!= OSPF_SPF_MAX_HOLDTIME_DEFAULT
)
9962 vty_out(vty
, " timers throttle spf %d %d %d\n",
9963 ospf
->spf_delay
, ospf
->spf_holdtime
,
9964 ospf
->spf_max_holdtime
);
9966 /* LSA timers print. */
9967 if (ospf
->min_ls_interval
!= OSPF_MIN_LS_INTERVAL
)
9968 vty_out(vty
, " timers throttle lsa all %d\n",
9969 ospf
->min_ls_interval
);
9970 if (ospf
->min_ls_arrival
!= OSPF_MIN_LS_ARRIVAL
)
9971 vty_out(vty
, " timers lsa min-arrival %d\n",
9972 ospf
->min_ls_arrival
);
9974 /* Write multiplier print. */
9975 if (ospf
->write_oi_count
!= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
)
9976 vty_out(vty
, " ospf write-multiplier %d\n",
9977 ospf
->write_oi_count
);
9979 /* Max-metric router-lsa print */
9980 config_write_stub_router(vty
, ospf
);
9982 /* SPF refresh parameters print. */
9983 if (ospf
->lsa_refresh_interval
9984 != OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
9985 vty_out(vty
, " refresh timer %d\n",
9986 ospf
->lsa_refresh_interval
);
9988 /* Redistribute information print. */
9989 config_write_ospf_redistribute(vty
, ospf
);
9991 /* passive-interface print. */
9992 if (ospf
->passive_interface_default
== OSPF_IF_PASSIVE
)
9993 vty_out(vty
, " passive-interface default\n");
9995 FOR_ALL_INTERFACES (vrf
, ifp
)
9996 if (OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp
),
9998 && IF_DEF_PARAMS(ifp
)->passive_interface
9999 != ospf
->passive_interface_default
) {
10000 vty_out(vty
, " %spassive-interface %s\n",
10001 IF_DEF_PARAMS(ifp
)->passive_interface
10006 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
10007 if (!OSPF_IF_PARAM_CONFIGURED(oi
->params
,
10008 passive_interface
))
10010 if (OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(oi
->ifp
),
10011 passive_interface
)) {
10012 if (oi
->params
->passive_interface
10013 == IF_DEF_PARAMS(oi
->ifp
)
10014 ->passive_interface
)
10016 } else if (oi
->params
->passive_interface
10017 == ospf
->passive_interface_default
)
10020 vty_out(vty
, " %spassive-interface %s %s\n",
10021 oi
->params
->passive_interface
? "" : "no ",
10023 inet_ntoa(oi
->address
->u
.prefix4
));
10026 /* Network area print. */
10027 config_write_network_area(vty
, ospf
);
10029 /* Area config print. */
10030 config_write_ospf_area(vty
, ospf
);
10032 /* static neighbor print. */
10033 config_write_ospf_nbr_nbma(vty
, ospf
);
10035 /* Virtual-Link print. */
10036 config_write_virtual_link(vty
, ospf
);
10038 /* Default metric configuration. */
10039 config_write_ospf_default_metric(vty
, ospf
);
10041 /* Distribute-list and default-information print. */
10042 config_write_ospf_distribute(vty
, ospf
);
10044 /* Distance configuration. */
10045 config_write_ospf_distance(vty
, ospf
);
10047 ospf_opaque_config_write_router(vty
, ospf
);
10053 /* OSPF configuration write function. */
10054 static int ospf_config_write(struct vty
*vty
)
10057 struct listnode
*ospf_node
= NULL
;
10060 if (listcount(om
->ospf
) == 0)
10063 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, ospf_node
, ospf
)) {
10064 if (ospf
->oi_running
)
10065 write
+= ospf_config_write_one(vty
, ospf
);
10070 void ospf_vty_show_init(void)
10072 /* "show ip ospf" commands. */
10073 install_element(VIEW_NODE
, &show_ip_ospf_cmd
);
10075 install_element(VIEW_NODE
, &show_ip_ospf_instance_cmd
);
10077 /* "show ip ospf database" commands. */
10078 install_element(VIEW_NODE
, &show_ip_ospf_database_max_cmd
);
10080 install_element(VIEW_NODE
,
10081 &show_ip_ospf_instance_database_type_adv_router_cmd
);
10082 install_element(VIEW_NODE
, &show_ip_ospf_instance_database_cmd
);
10083 install_element(VIEW_NODE
, &show_ip_ospf_instance_database_max_cmd
);
10085 /* "show ip ospf interface" commands. */
10086 install_element(VIEW_NODE
, &show_ip_ospf_interface_cmd
);
10088 install_element(VIEW_NODE
, &show_ip_ospf_instance_interface_cmd
);
10089 /* "show ip ospf interface traffic */
10090 install_element(VIEW_NODE
, &show_ip_ospf_interface_traffic_cmd
);
10092 /* "show ip ospf neighbor" commands. */
10093 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_int_detail_cmd
);
10094 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_int_cmd
);
10095 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_id_cmd
);
10096 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_detail_all_cmd
);
10097 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_detail_cmd
);
10098 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_cmd
);
10099 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_all_cmd
);
10101 install_element(VIEW_NODE
,
10102 &show_ip_ospf_instance_neighbor_int_detail_cmd
);
10103 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_cmd
);
10104 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_id_cmd
);
10105 install_element(VIEW_NODE
,
10106 &show_ip_ospf_instance_neighbor_detail_all_cmd
);
10107 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_cmd
);
10108 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_cmd
);
10109 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_all_cmd
);
10111 /* "show ip ospf route" commands. */
10112 install_element(VIEW_NODE
, &show_ip_ospf_route_cmd
);
10113 install_element(VIEW_NODE
, &show_ip_ospf_border_routers_cmd
);
10115 install_element(VIEW_NODE
, &show_ip_ospf_instance_route_cmd
);
10116 install_element(VIEW_NODE
, &show_ip_ospf_instance_border_routers_cmd
);
10118 /* "show ip ospf vrfs" commands. */
10119 install_element(VIEW_NODE
, &show_ip_ospf_vrfs_cmd
);
10123 /* ospfd's interface node. */
10124 static struct cmd_node interface_node
= {INTERFACE_NODE
, "%s(config-if)# ", 1};
10126 /* Initialization of OSPF interface. */
10127 static void ospf_vty_if_init(void)
10129 /* Install interface node. */
10130 install_node(&interface_node
, config_write_interface
);
10133 /* "ip ospf authentication" commands. */
10134 install_element(INTERFACE_NODE
, &ip_ospf_authentication_args_addr_cmd
);
10135 install_element(INTERFACE_NODE
, &ip_ospf_authentication_addr_cmd
);
10136 install_element(INTERFACE_NODE
,
10137 &no_ip_ospf_authentication_args_addr_cmd
);
10138 install_element(INTERFACE_NODE
, &no_ip_ospf_authentication_addr_cmd
);
10139 install_element(INTERFACE_NODE
, &ip_ospf_authentication_key_addr_cmd
);
10140 install_element(INTERFACE_NODE
,
10141 &no_ip_ospf_authentication_key_authkey_addr_cmd
);
10142 install_element(INTERFACE_NODE
,
10143 &no_ospf_authentication_key_authkey_addr_cmd
);
10145 /* "ip ospf message-digest-key" commands. */
10146 install_element(INTERFACE_NODE
, &ip_ospf_message_digest_key_cmd
);
10147 install_element(INTERFACE_NODE
, &no_ip_ospf_message_digest_key_cmd
);
10149 /* "ip ospf cost" commands. */
10150 install_element(INTERFACE_NODE
, &ip_ospf_cost_cmd
);
10151 install_element(INTERFACE_NODE
, &no_ip_ospf_cost_cmd
);
10153 /* "ip ospf mtu-ignore" commands. */
10154 install_element(INTERFACE_NODE
, &ip_ospf_mtu_ignore_addr_cmd
);
10155 install_element(INTERFACE_NODE
, &no_ip_ospf_mtu_ignore_addr_cmd
);
10157 /* "ip ospf dead-interval" commands. */
10158 install_element(INTERFACE_NODE
, &ip_ospf_dead_interval_cmd
);
10159 install_element(INTERFACE_NODE
,
10160 &ip_ospf_dead_interval_minimal_addr_cmd
);
10161 install_element(INTERFACE_NODE
, &no_ip_ospf_dead_interval_cmd
);
10163 /* "ip ospf hello-interval" commands. */
10164 install_element(INTERFACE_NODE
, &ip_ospf_hello_interval_cmd
);
10165 install_element(INTERFACE_NODE
, &no_ip_ospf_hello_interval_cmd
);
10167 /* "ip ospf network" commands. */
10168 install_element(INTERFACE_NODE
, &ip_ospf_network_cmd
);
10169 install_element(INTERFACE_NODE
, &no_ip_ospf_network_cmd
);
10171 /* "ip ospf priority" commands. */
10172 install_element(INTERFACE_NODE
, &ip_ospf_priority_cmd
);
10173 install_element(INTERFACE_NODE
, &no_ip_ospf_priority_cmd
);
10175 /* "ip ospf retransmit-interval" commands. */
10176 install_element(INTERFACE_NODE
, &ip_ospf_retransmit_interval_addr_cmd
);
10177 install_element(INTERFACE_NODE
,
10178 &no_ip_ospf_retransmit_interval_addr_cmd
);
10180 /* "ip ospf transmit-delay" commands. */
10181 install_element(INTERFACE_NODE
, &ip_ospf_transmit_delay_addr_cmd
);
10182 install_element(INTERFACE_NODE
, &no_ip_ospf_transmit_delay_addr_cmd
);
10184 /* "ip ospf area" commands. */
10185 install_element(INTERFACE_NODE
, &ip_ospf_area_cmd
);
10186 install_element(INTERFACE_NODE
, &no_ip_ospf_area_cmd
);
10188 /* These commands are compatibitliy for previous version. */
10189 install_element(INTERFACE_NODE
, &ospf_authentication_key_cmd
);
10190 install_element(INTERFACE_NODE
, &ospf_message_digest_key_cmd
);
10191 install_element(INTERFACE_NODE
, &no_ospf_message_digest_key_cmd
);
10192 install_element(INTERFACE_NODE
, &ospf_dead_interval_cmd
);
10193 install_element(INTERFACE_NODE
, &no_ospf_dead_interval_cmd
);
10194 install_element(INTERFACE_NODE
, &ospf_hello_interval_cmd
);
10195 install_element(INTERFACE_NODE
, &no_ospf_hello_interval_cmd
);
10196 install_element(INTERFACE_NODE
, &ospf_cost_cmd
);
10197 install_element(INTERFACE_NODE
, &no_ospf_cost_cmd
);
10198 install_element(INTERFACE_NODE
, &ospf_network_cmd
);
10199 install_element(INTERFACE_NODE
, &no_ospf_network_cmd
);
10200 install_element(INTERFACE_NODE
, &ospf_priority_cmd
);
10201 install_element(INTERFACE_NODE
, &no_ospf_priority_cmd
);
10202 install_element(INTERFACE_NODE
, &ospf_retransmit_interval_cmd
);
10203 install_element(INTERFACE_NODE
, &no_ospf_retransmit_interval_cmd
);
10204 install_element(INTERFACE_NODE
, &ospf_transmit_delay_cmd
);
10205 install_element(INTERFACE_NODE
, &no_ospf_transmit_delay_cmd
);
10208 static void ospf_vty_zebra_init(void)
10210 install_element(OSPF_NODE
, &ospf_redistribute_source_cmd
);
10211 install_element(OSPF_NODE
, &no_ospf_redistribute_source_cmd
);
10212 install_element(OSPF_NODE
, &ospf_redistribute_instance_source_cmd
);
10213 install_element(OSPF_NODE
, &no_ospf_redistribute_instance_source_cmd
);
10215 install_element(OSPF_NODE
, &ospf_distribute_list_out_cmd
);
10216 install_element(OSPF_NODE
, &no_ospf_distribute_list_out_cmd
);
10218 install_element(OSPF_NODE
, &ospf_default_information_originate_cmd
);
10219 install_element(OSPF_NODE
, &no_ospf_default_information_originate_cmd
);
10221 install_element(OSPF_NODE
, &ospf_default_metric_cmd
);
10222 install_element(OSPF_NODE
, &no_ospf_default_metric_cmd
);
10224 install_element(OSPF_NODE
, &ospf_distance_cmd
);
10225 install_element(OSPF_NODE
, &no_ospf_distance_cmd
);
10226 install_element(OSPF_NODE
, &no_ospf_distance_ospf_cmd
);
10227 install_element(OSPF_NODE
, &ospf_distance_ospf_cmd
);
10229 install_element (OSPF_NODE
, &ospf_distance_source_cmd
);
10230 install_element (OSPF_NODE
, &no_ospf_distance_source_cmd
);
10231 install_element (OSPF_NODE
, &ospf_distance_source_access_list_cmd
);
10232 install_element (OSPF_NODE
, &no_ospf_distance_source_access_list_cmd
);
10236 static struct cmd_node ospf_node
= {OSPF_NODE
, "%s(config-router)# ", 1};
10238 static void ospf_interface_clear(struct interface
*ifp
)
10240 if (!if_is_operative(ifp
))
10243 if (IS_DEBUG_OSPF(ism
, ISM_EVENTS
))
10244 zlog_debug("ISM[%s]: clear by reset", ifp
->name
);
10246 ospf_if_reset(ifp
);
10249 DEFUN (clear_ip_ospf_interface
,
10250 clear_ip_ospf_interface_cmd
,
10251 "clear ip ospf interface [IFNAME]",
10254 "OSPF information\n"
10255 "Interface information\n"
10256 "Interface name\n")
10258 int idx_ifname
= 4;
10259 struct interface
*ifp
;
10260 struct listnode
*node
;
10261 struct ospf
*ospf
= NULL
;
10263 if (argc
== 4) /* Clear all the ospfv2 interfaces. */
10265 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
10266 struct vrf
*vrf
= vrf_lookup_by_id(ospf
->vrf_id
);
10267 FOR_ALL_INTERFACES (vrf
, ifp
)
10268 ospf_interface_clear(ifp
);
10271 /* Interface name is specified. */
10272 ifp
= if_lookup_by_name_all_vrf(argv
[idx_ifname
]->arg
);
10274 vty_out(vty
, "No such interface name\n");
10276 ospf_interface_clear(ifp
);
10279 return CMD_SUCCESS
;
10282 void ospf_vty_clear_init(void)
10284 install_element(ENABLE_NODE
, &clear_ip_ospf_interface_cmd
);
10288 /* Install OSPF related vty commands. */
10289 void ospf_vty_init(void)
10291 /* Install ospf top node. */
10292 install_node(&ospf_node
, ospf_config_write
);
10294 /* "router ospf" commands. */
10295 install_element(CONFIG_NODE
, &router_ospf_cmd
);
10296 install_element(CONFIG_NODE
, &no_router_ospf_cmd
);
10299 install_default(OSPF_NODE
);
10301 /* "ospf router-id" commands. */
10302 install_element(OSPF_NODE
, &ospf_router_id_cmd
);
10303 install_element(OSPF_NODE
, &ospf_router_id_old_cmd
);
10304 install_element(OSPF_NODE
, &no_ospf_router_id_cmd
);
10306 /* "passive-interface" commands. */
10307 install_element(OSPF_NODE
, &ospf_passive_interface_addr_cmd
);
10308 install_element(OSPF_NODE
, &no_ospf_passive_interface_addr_cmd
);
10310 /* "ospf abr-type" commands. */
10311 install_element(OSPF_NODE
, &ospf_abr_type_cmd
);
10312 install_element(OSPF_NODE
, &no_ospf_abr_type_cmd
);
10314 /* "ospf log-adjacency-changes" commands. */
10315 install_element(OSPF_NODE
, &ospf_log_adjacency_changes_cmd
);
10316 install_element(OSPF_NODE
, &ospf_log_adjacency_changes_detail_cmd
);
10317 install_element(OSPF_NODE
, &no_ospf_log_adjacency_changes_cmd
);
10318 install_element(OSPF_NODE
, &no_ospf_log_adjacency_changes_detail_cmd
);
10320 /* "ospf rfc1583-compatible" commands. */
10321 install_element(OSPF_NODE
, &ospf_compatible_rfc1583_cmd
);
10322 install_element(OSPF_NODE
, &no_ospf_compatible_rfc1583_cmd
);
10323 install_element(OSPF_NODE
, &ospf_rfc1583_flag_cmd
);
10324 install_element(OSPF_NODE
, &no_ospf_rfc1583_flag_cmd
);
10326 /* "network area" commands. */
10327 install_element(OSPF_NODE
, &ospf_network_area_cmd
);
10328 install_element(OSPF_NODE
, &no_ospf_network_area_cmd
);
10330 /* "area authentication" commands. */
10331 install_element(OSPF_NODE
,
10332 &ospf_area_authentication_message_digest_cmd
);
10333 install_element(OSPF_NODE
, &ospf_area_authentication_cmd
);
10334 install_element(OSPF_NODE
, &no_ospf_area_authentication_cmd
);
10336 /* "area range" commands. */
10337 install_element(OSPF_NODE
, &ospf_area_range_cmd
);
10338 install_element(OSPF_NODE
, &ospf_area_range_cost_cmd
);
10339 install_element(OSPF_NODE
, &ospf_area_range_not_advertise_cmd
);
10340 install_element(OSPF_NODE
, &no_ospf_area_range_cmd
);
10341 install_element(OSPF_NODE
, &ospf_area_range_substitute_cmd
);
10342 install_element(OSPF_NODE
, &no_ospf_area_range_substitute_cmd
);
10344 /* "area virtual-link" commands. */
10345 install_element(OSPF_NODE
, &ospf_area_vlink_cmd
);
10346 install_element(OSPF_NODE
, &ospf_area_vlink_intervals_cmd
);
10347 install_element(OSPF_NODE
, &no_ospf_area_vlink_cmd
);
10348 install_element(OSPF_NODE
, &no_ospf_area_vlink_intervals_cmd
);
10351 /* "area stub" commands. */
10352 install_element(OSPF_NODE
, &ospf_area_stub_no_summary_cmd
);
10353 install_element(OSPF_NODE
, &ospf_area_stub_cmd
);
10354 install_element(OSPF_NODE
, &no_ospf_area_stub_no_summary_cmd
);
10355 install_element(OSPF_NODE
, &no_ospf_area_stub_cmd
);
10357 /* "area nssa" commands. */
10358 install_element(OSPF_NODE
, &ospf_area_nssa_cmd
);
10359 install_element(OSPF_NODE
, &ospf_area_nssa_translate_cmd
);
10360 install_element(OSPF_NODE
, &ospf_area_nssa_no_summary_cmd
);
10361 install_element(OSPF_NODE
, &no_ospf_area_nssa_no_summary_cmd
);
10362 install_element(OSPF_NODE
, &no_ospf_area_nssa_cmd
);
10364 install_element(OSPF_NODE
, &ospf_area_default_cost_cmd
);
10365 install_element(OSPF_NODE
, &no_ospf_area_default_cost_cmd
);
10367 install_element(OSPF_NODE
, &ospf_area_shortcut_cmd
);
10368 install_element(OSPF_NODE
, &no_ospf_area_shortcut_cmd
);
10370 install_element(OSPF_NODE
, &ospf_area_export_list_cmd
);
10371 install_element(OSPF_NODE
, &no_ospf_area_export_list_cmd
);
10373 install_element(OSPF_NODE
, &ospf_area_filter_list_cmd
);
10374 install_element(OSPF_NODE
, &no_ospf_area_filter_list_cmd
);
10376 install_element(OSPF_NODE
, &ospf_area_import_list_cmd
);
10377 install_element(OSPF_NODE
, &no_ospf_area_import_list_cmd
);
10379 /* SPF timer commands */
10380 install_element(OSPF_NODE
, &ospf_timers_throttle_spf_cmd
);
10381 install_element(OSPF_NODE
, &no_ospf_timers_throttle_spf_cmd
);
10383 /* LSA timers commands */
10384 install_element(OSPF_NODE
, &ospf_timers_min_ls_interval_cmd
);
10385 install_element(OSPF_NODE
, &no_ospf_timers_min_ls_interval_cmd
);
10386 install_element(OSPF_NODE
, &ospf_timers_lsa_min_arrival_cmd
);
10387 install_element(OSPF_NODE
, &no_ospf_timers_lsa_min_arrival_cmd
);
10388 install_element(OSPF_NODE
, &ospf_timers_lsa_arrival_cmd
);
10389 install_element(OSPF_NODE
, &no_ospf_timers_lsa_arrival_cmd
);
10391 /* refresh timer commands */
10392 install_element(OSPF_NODE
, &ospf_refresh_timer_cmd
);
10393 install_element(OSPF_NODE
, &no_ospf_refresh_timer_val_cmd
);
10395 /* max-metric commands */
10396 install_element(OSPF_NODE
, &ospf_max_metric_router_lsa_admin_cmd
);
10397 install_element(OSPF_NODE
, &no_ospf_max_metric_router_lsa_admin_cmd
);
10398 install_element(OSPF_NODE
, &ospf_max_metric_router_lsa_startup_cmd
);
10399 install_element(OSPF_NODE
, &no_ospf_max_metric_router_lsa_startup_cmd
);
10400 install_element(OSPF_NODE
, &ospf_max_metric_router_lsa_shutdown_cmd
);
10401 install_element(OSPF_NODE
, &no_ospf_max_metric_router_lsa_shutdown_cmd
);
10403 /* reference bandwidth commands */
10404 install_element(OSPF_NODE
, &ospf_auto_cost_reference_bandwidth_cmd
);
10405 install_element(OSPF_NODE
, &no_ospf_auto_cost_reference_bandwidth_cmd
);
10407 /* "neighbor" commands. */
10408 install_element(OSPF_NODE
, &ospf_neighbor_cmd
);
10409 install_element(OSPF_NODE
, &ospf_neighbor_poll_interval_cmd
);
10410 install_element(OSPF_NODE
, &no_ospf_neighbor_cmd
);
10411 install_element(OSPF_NODE
, &no_ospf_neighbor_poll_cmd
);
10413 /* write multiplier commands */
10414 install_element(OSPF_NODE
, &ospf_write_multiplier_cmd
);
10415 install_element(OSPF_NODE
, &write_multiplier_cmd
);
10416 install_element(OSPF_NODE
, &no_ospf_write_multiplier_cmd
);
10417 install_element(OSPF_NODE
, &no_write_multiplier_cmd
);
10419 /* Init interface related vty commands. */
10420 ospf_vty_if_init();
10422 /* Init zebra related vty commands. */
10423 ospf_vty_zebra_init();