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
;
143 const char *vrf_name
= NULL
;
145 if (argv_find(argv
, argc
, "vrf", &idx_vrf
)) {
146 vrf_name
= argv
[idx_vrf
+ 1]->arg
;
149 *instance
= strtoul(argv
[2]->arg
, NULL
, 10);
150 /* Allocate VRF aware instance */
151 ospf
= ospf_get(*instance
, vrf_name
);
154 *instance
= strtoul(argv
[3]->arg
, NULL
, 10);
155 ospf
= ospf_lookup_by_inst_name(*instance
, vrf_name
);
159 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
162 "There isn't active ospf instance\n");
164 *instance
= strtoul(argv
[2]->arg
, NULL
, 10);
167 *instance
= strtoul(argv
[3]->arg
, NULL
, 10);
168 ospf
= ospf_lookup_instance(*instance
);
174 #ifndef VTYSH_EXTRACT_PL
175 #include "ospf_vty_clippy.c"
178 DEFUN_NOSH (router_ospf
,
180 "router ospf [{(1-65535)|vrf NAME}]",
181 "Enable a routing process\n"
182 "Start OSPF configuration\n"
186 struct ospf
*ospf
= NULL
;
187 int ret
= CMD_SUCCESS
;
188 u_short instance
= 0;
190 ospf
= ospf_cmd_lookup_ospf(vty
, argv
, argc
, 1, &instance
);
192 return CMD_WARNING_CONFIG_FAILED
;
194 /* The following logic to set the vty qobj index is in place to be able
195 to ignore the commands which dont belong to this instance. */
196 if (ospf
->instance
!= instance
) {
197 VTY_PUSH_CONTEXT_NULL(OSPF_NODE
);
198 ret
= CMD_NOT_MY_INSTANCE
;
200 if (ospf
->vrf_id
!= VRF_UNKNOWN
)
201 ospf
->oi_running
= 1;
202 if (IS_DEBUG_OSPF_EVENT
)
203 zlog_debug("Config command 'router ospf %d' received, vrf %s id %d oi_running %u",
204 instance
, ospf
->name
? ospf
->name
: "NIL",
205 ospf
->vrf_id
, ospf
->oi_running
);
206 VTY_PUSH_CONTEXT(OSPF_NODE
, ospf
);
207 ospf_router_id_update(ospf
);
213 DEFUN (no_router_ospf
,
215 "no router ospf [{(1-65535)|vrf NAME}]",
217 "Enable a routing process\n"
218 "Start OSPF configuration\n"
223 u_short instance
= 0;
225 ospf
= ospf_cmd_lookup_ospf(vty
, argv
, argc
, 0, &instance
);
228 return CMD_NOT_MY_INSTANCE
;
238 DEFPY (ospf_router_id
,
240 "ospf router-id A.B.C.D",
241 "OSPF specific commands\n"
242 "router-id for the OSPF process\n"
243 "OSPF router-id in IP address format\n")
245 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
247 struct listnode
*node
;
248 struct ospf_area
*area
;
250 ospf
->router_id_static
= router_id
;
252 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
))
253 if (area
->full_nbrs
) {
255 "For this router-id change to take effect,"
256 " save config and restart ospfd\n");
260 ospf_router_id_update(ospf
);
265 DEFUN_HIDDEN (ospf_router_id_old
,
266 ospf_router_id_old_cmd
,
268 "router-id for the OSPF process\n"
269 "OSPF router-id in IP address format\n")
271 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
273 struct listnode
*node
;
274 struct ospf_area
*area
;
275 struct in_addr router_id
;
278 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &router_id
);
280 vty_out(vty
, "Please specify Router ID by A.B.C.D\n");
281 return CMD_WARNING_CONFIG_FAILED
;
284 ospf
->router_id_static
= router_id
;
286 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
))
287 if (area
->full_nbrs
) {
289 "For this router-id change to take effect,"
290 " save config and restart ospfd\n");
294 ospf_router_id_update(ospf
);
299 DEFPY (no_ospf_router_id
,
300 no_ospf_router_id_cmd
,
301 "no ospf router-id [A.B.C.D]",
303 "OSPF specific commands\n"
304 "router-id for the OSPF process\n"
305 "OSPF router-id in IP address format\n")
307 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
308 struct listnode
*node
;
309 struct ospf_area
*area
;
312 if (!IPV4_ADDR_SAME(&ospf
->router_id_static
, &router_id
)) {
313 vty_out(vty
, "%% OSPF router-id doesn't match\n");
314 return CMD_WARNING_CONFIG_FAILED
;
318 ospf
->router_id_static
.s_addr
= 0;
320 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
))
321 if (area
->full_nbrs
) {
323 "For this router-id change to take effect,"
324 " save config and restart ospfd\n");
328 ospf_router_id_update(ospf
);
334 static void ospf_passive_interface_default(struct ospf
*ospf
, u_char newval
)
337 struct interface
*ifp
;
338 struct ospf_interface
*oi
;
340 ospf
->passive_interface_default
= newval
;
342 for (ALL_LIST_ELEMENTS_RO(vrf_iflist(ospf
->vrf_id
), ln
, ifp
)) {
343 if (ifp
&& OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp
),
345 UNSET_IF_PARAM(IF_DEF_PARAMS(ifp
), passive_interface
);
347 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, ln
, oi
)) {
348 if (OSPF_IF_PARAM_CONFIGURED(oi
->params
, passive_interface
))
349 UNSET_IF_PARAM(oi
->params
, passive_interface
);
350 /* update multicast memberships */
351 ospf_if_set_multicast(oi
);
355 static void ospf_passive_interface_update_addr(struct ospf
*ospf
,
356 struct interface
*ifp
,
357 struct ospf_if_params
*params
,
363 params
->passive_interface
= value
;
364 if (params
!= IF_DEF_PARAMS(ifp
)) {
365 if (OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp
),
367 dflt
= IF_DEF_PARAMS(ifp
)->passive_interface
;
369 dflt
= ospf
->passive_interface_default
;
372 SET_IF_PARAM(params
, passive_interface
);
374 UNSET_IF_PARAM(params
, passive_interface
);
376 ospf_free_if_params(ifp
, addr
);
377 ospf_if_update_params(ifp
, addr
);
381 static void ospf_passive_interface_update(struct ospf
*ospf
,
382 struct interface
*ifp
,
383 struct ospf_if_params
*params
,
386 params
->passive_interface
= value
;
387 if (params
== IF_DEF_PARAMS(ifp
)) {
388 if (value
!= ospf
->passive_interface_default
)
389 SET_IF_PARAM(params
, passive_interface
);
391 UNSET_IF_PARAM(params
, passive_interface
);
395 DEFUN (ospf_passive_interface
,
396 ospf_passive_interface_addr_cmd
,
397 "passive-interface <IFNAME [A.B.C.D]|default>",
398 "Suppress routing updates on an interface\n"
401 "Suppress routing updates on interfaces by default\n")
403 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
405 struct interface
*ifp
;
406 struct in_addr addr
= {.s_addr
= INADDR_ANY
};
408 struct ospf_if_params
*params
;
409 struct route_node
*rn
;
411 if (strmatch(argv
[1]->text
, "default")) {
412 ospf_passive_interface_default(ospf
, OSPF_IF_PASSIVE
);
416 ifp
= if_get_by_name(argv
[1]->arg
, ospf
->vrf_id
, 0);
418 vty_out(vty
, "interface %s not found.\n",
419 (char *)argv
[1]->arg
);
423 params
= IF_DEF_PARAMS(ifp
);
426 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
429 "Please specify interface address by A.B.C.D\n");
430 return CMD_WARNING_CONFIG_FAILED
;
433 params
= ospf_get_if_params(ifp
, addr
);
434 ospf_if_update_params(ifp
, addr
);
435 ospf_passive_interface_update_addr(ospf
, ifp
, params
,
436 OSPF_IF_PASSIVE
, addr
);
439 ospf_passive_interface_update(ospf
, ifp
, params
, OSPF_IF_PASSIVE
);
441 /* XXX We should call ospf_if_set_multicast on exactly those
442 * interfaces for which the passive property changed. It is too much
443 * work to determine this set, so we do this for every interface.
444 * This is safe and reasonable because ospf_if_set_multicast uses a
445 * record of joined groups to avoid systems calls if the desired
446 * memberships match the current memership.
449 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
450 struct ospf_interface
*oi
= rn
->info
;
452 if (oi
&& (OSPF_IF_PARAM(oi
, passive_interface
)
454 ospf_if_set_multicast(oi
);
457 * XXX It is not clear what state transitions the interface needs to
458 * undergo when going from active to passive. Fixing this will
459 * require precise identification of interfaces having such a
466 DEFUN (no_ospf_passive_interface
,
467 no_ospf_passive_interface_addr_cmd
,
468 "no passive-interface <IFNAME [A.B.C.D]|default>",
470 "Allow routing updates on an interface\n"
473 "Allow routing updates on interfaces by default\n")
475 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
477 struct interface
*ifp
;
478 struct in_addr addr
= {.s_addr
= INADDR_ANY
};
479 struct ospf_if_params
*params
;
481 struct route_node
*rn
;
483 if (strmatch(argv
[2]->text
, "default")) {
484 ospf_passive_interface_default(ospf
, OSPF_IF_ACTIVE
);
488 ifp
= if_get_by_name(argv
[2]->arg
, ospf
->vrf_id
, 0);
490 vty_out(vty
, "interface %s not found.\n",
491 (char *)argv
[1]->arg
);
495 params
= IF_DEF_PARAMS(ifp
);
498 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
501 "Please specify interface address by A.B.C.D\n");
502 return CMD_WARNING_CONFIG_FAILED
;
505 params
= ospf_lookup_if_params(ifp
, addr
);
508 ospf_passive_interface_update_addr(ospf
, ifp
, params
,
509 OSPF_IF_ACTIVE
, addr
);
511 ospf_passive_interface_update(ospf
, ifp
, params
, OSPF_IF_ACTIVE
);
513 /* XXX We should call ospf_if_set_multicast on exactly those
514 * interfaces for which the passive property changed. It is too much
515 * work to determine this set, so we do this for every interface.
516 * This is safe and reasonable because ospf_if_set_multicast uses a
517 * record of joined groups to avoid systems calls if the desired
518 * memberships match the current memership.
520 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
521 struct ospf_interface
*oi
= rn
->info
;
524 && (OSPF_IF_PARAM(oi
, passive_interface
) == OSPF_IF_ACTIVE
))
525 ospf_if_set_multicast(oi
);
532 DEFUN (ospf_network_area
,
533 ospf_network_area_cmd
,
534 "network A.B.C.D/M area <A.B.C.D|(0-4294967295)>",
535 "Enable routing on an IP network\n"
536 "OSPF network prefix\n"
537 "Set the OSPF area ID\n"
538 "OSPF area ID in IP address format\n"
539 "OSPF area ID as a decimal value\n")
541 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
542 int idx_ipv4_prefixlen
= 1;
543 int idx_ipv4_number
= 3;
544 struct prefix_ipv4 p
;
545 struct in_addr area_id
;
548 if (ospf
->instance
) {
550 "The network command is not supported in multi-instance ospf\n");
551 return CMD_WARNING_CONFIG_FAILED
;
554 if (ospf
->if_ospf_cli_count
> 0) {
556 "Please remove all ip ospf area x.x.x.x commands first.\n");
557 return CMD_WARNING_CONFIG_FAILED
;
560 /* Get network prefix and Area ID. */
561 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
562 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
564 ret
= ospf_network_set(ospf
, &p
, area_id
, format
);
566 vty_out(vty
, "There is already same network statement.\n");
573 DEFUN (no_ospf_network_area
,
574 no_ospf_network_area_cmd
,
575 "no network A.B.C.D/M area <A.B.C.D|(0-4294967295)>",
577 "Enable routing on an IP network\n"
578 "OSPF network prefix\n"
579 "Set the OSPF area ID\n"
580 "OSPF area ID in IP address format\n"
581 "OSPF area ID as a decimal value\n")
583 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
584 int idx_ipv4_prefixlen
= 2;
585 int idx_ipv4_number
= 4;
586 struct prefix_ipv4 p
;
587 struct in_addr area_id
;
590 if (ospf
->instance
) {
592 "The network command is not supported in multi-instance ospf\n");
593 return CMD_WARNING_CONFIG_FAILED
;
596 /* Get network prefix and Area ID. */
597 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
598 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
600 ret
= ospf_network_unset(ospf
, &p
, area_id
);
603 "Can't find specified network area configuration.\n");
604 return CMD_WARNING_CONFIG_FAILED
;
610 DEFUN (ospf_area_range
,
612 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [advertise [cost (0-16777215)]]",
613 "OSPF area parameters\n"
614 "OSPF area ID in IP address format\n"
615 "OSPF area ID as a decimal value\n"
616 "Summarize routes matching address/mask (border routers only)\n"
617 "Area range prefix\n"
618 "Advertise this range (default)\n"
619 "User specified metric for this range\n"
620 "Advertised metric for this range\n")
622 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
623 int idx_ipv4_number
= 1;
624 int idx_ipv4_prefixlen
= 3;
626 struct prefix_ipv4 p
;
627 struct in_addr area_id
;
631 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
632 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
634 ospf_area_range_set(ospf
, area_id
, &p
, OSPF_AREA_RANGE_ADVERTISE
);
636 cost
= strtoul(argv
[idx_cost
]->arg
, NULL
, 10);
637 ospf_area_range_cost_set(ospf
, area_id
, &p
, cost
);
643 DEFUN (ospf_area_range_cost
,
644 ospf_area_range_cost_cmd
,
645 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M cost (0-16777215)",
646 "OSPF area parameters\n"
647 "OSPF area ID in IP address format\n"
648 "OSPF area ID as a decimal value\n"
649 "Summarize routes matching address/mask (border routers only)\n"
650 "Area range prefix\n"
651 "User specified metric for this range\n"
652 "Advertised metric for this range\n")
654 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
655 int idx_ipv4_number
= 1;
656 int idx_ipv4_prefixlen
= 3;
658 struct prefix_ipv4 p
;
659 struct in_addr area_id
;
663 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
664 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
666 ospf_area_range_set(ospf
, area_id
, &p
, OSPF_AREA_RANGE_ADVERTISE
);
667 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
670 cost
= strtoul(argv
[idx_cost
]->arg
, NULL
, 10);
671 ospf_area_range_cost_set(ospf
, area_id
, &p
, cost
);
676 DEFUN (ospf_area_range_not_advertise
,
677 ospf_area_range_not_advertise_cmd
,
678 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M not-advertise",
679 "OSPF area parameters\n"
680 "OSPF area ID in IP address format\n"
681 "OSPF area ID as a decimal value\n"
682 "Summarize routes matching address/mask (border routers only)\n"
683 "Area range prefix\n"
684 "DoNotAdvertise this range\n")
686 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
687 int idx_ipv4_number
= 1;
688 int idx_ipv4_prefixlen
= 3;
689 struct prefix_ipv4 p
;
690 struct in_addr area_id
;
693 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
694 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
696 ospf_area_range_set(ospf
, area_id
, &p
, 0);
697 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
703 DEFUN (no_ospf_area_range
,
704 no_ospf_area_range_cmd
,
705 "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [<cost (0-16777215)|advertise [cost (0-16777215)]|not-advertise>]",
707 "OSPF area parameters\n"
708 "OSPF area ID in IP address format\n"
709 "OSPF area ID as a decimal value\n"
710 "Summarize routes matching address/mask (border routers only)\n"
711 "Area range prefix\n"
712 "User specified metric for this range\n"
713 "Advertised metric for this range\n"
714 "Advertise this range (default)\n"
715 "User specified metric for this range\n"
716 "Advertised metric for this range\n"
717 "DoNotAdvertise this range\n")
719 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
720 int idx_ipv4_number
= 2;
721 int idx_ipv4_prefixlen
= 4;
722 struct prefix_ipv4 p
;
723 struct in_addr area_id
;
726 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
727 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
729 ospf_area_range_unset(ospf
, area_id
, &p
);
734 DEFUN (ospf_area_range_substitute
,
735 ospf_area_range_substitute_cmd
,
736 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M",
737 "OSPF area parameters\n"
738 "OSPF area ID in IP address format\n"
739 "OSPF area ID as a decimal value\n"
740 "Summarize routes matching address/mask (border routers only)\n"
741 "Area range prefix\n"
742 "Announce area range as another prefix\n"
743 "Network prefix to be announced instead of range\n")
745 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
746 int idx_ipv4_number
= 1;
747 int idx_ipv4_prefixlen
= 3;
748 int idx_ipv4_prefixlen_2
= 5;
749 struct prefix_ipv4 p
, s
;
750 struct in_addr area_id
;
753 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
754 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
755 str2prefix_ipv4(argv
[idx_ipv4_prefixlen_2
]->arg
, &s
);
757 ospf_area_range_substitute_set(ospf
, area_id
, &p
, &s
);
758 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
764 DEFUN (no_ospf_area_range_substitute
,
765 no_ospf_area_range_substitute_cmd
,
766 "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M",
768 "OSPF area parameters\n"
769 "OSPF area ID in IP address format\n"
770 "OSPF area ID as a decimal value\n"
771 "Summarize routes matching address/mask (border routers only)\n"
772 "Area range prefix\n"
773 "Announce area range as another prefix\n"
774 "Network prefix to be announced instead of range\n")
776 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
777 int idx_ipv4_number
= 2;
778 int idx_ipv4_prefixlen
= 4;
779 int idx_ipv4_prefixlen_2
= 6;
780 struct prefix_ipv4 p
, s
;
781 struct in_addr area_id
;
784 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
785 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
786 str2prefix_ipv4(argv
[idx_ipv4_prefixlen_2
]->arg
, &s
);
788 ospf_area_range_substitute_unset(ospf
, area_id
, &p
);
794 /* Command Handler Logic in VLink stuff is delicate!!
796 ALTER AT YOUR OWN RISK!!!!
798 Various dummy values are used to represent 'NoChange' state for
799 VLink configuration NOT being changed by a VLink command, and
800 special syntax is used within the command strings so that the
801 typed in command verbs can be seen in the configuration command
802 bacckend handler. This is to drastically reduce the verbeage
803 required to coe up with a reasonably compatible Cisco VLink command
805 - Matthew Grant <grantma@anathoth.gen.nz>
806 Wed, 21 Feb 2001 15:13:52 +1300
809 /* Configuration data for virtual links
811 struct ospf_vl_config_data
{
812 struct vty
*vty
; /* vty stuff */
813 struct in_addr area_id
; /* area ID from command line */
814 int area_id_fmt
; /* command line area ID format */
815 struct in_addr vl_peer
; /* command line vl_peer */
816 int auth_type
; /* Authehntication type, if given */
817 char *auth_key
; /* simple password if present */
818 int crypto_key_id
; /* Cryptographic key ID */
819 char *md5_key
; /* MD5 authentication key */
820 int hello_interval
; /* Obvious what these are... */
821 int retransmit_interval
;
826 static void ospf_vl_config_data_init(struct ospf_vl_config_data
*vl_config
,
829 memset(vl_config
, 0, sizeof(struct ospf_vl_config_data
));
830 vl_config
->auth_type
= OSPF_AUTH_CMD_NOTSEEN
;
831 vl_config
->vty
= vty
;
834 static struct ospf_vl_data
*
835 ospf_find_vl_data(struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
837 struct ospf_area
*area
;
838 struct ospf_vl_data
*vl_data
;
840 struct in_addr area_id
;
842 vty
= vl_config
->vty
;
843 area_id
= vl_config
->area_id
;
845 if (area_id
.s_addr
== OSPF_AREA_BACKBONE
) {
847 "Configuring VLs over the backbone is not allowed\n");
850 area
= ospf_area_get(ospf
, area_id
);
851 ospf_area_display_format_set(ospf
, area
, vl_config
->area_id_fmt
);
853 if (area
->external_routing
!= OSPF_AREA_DEFAULT
) {
854 if (vl_config
->area_id_fmt
== OSPF_AREA_ID_FMT_DOTTEDQUAD
)
855 vty_out(vty
, "Area %s is %s\n", inet_ntoa(area_id
),
856 area
->external_routing
== OSPF_AREA_NSSA
860 vty_out(vty
, "Area %ld is %s\n",
861 (u_long
)ntohl(area_id
.s_addr
),
862 area
->external_routing
== OSPF_AREA_NSSA
868 if ((vl_data
= ospf_vl_lookup(ospf
, area
, vl_config
->vl_peer
))
870 vl_data
= ospf_vl_data_new(area
, vl_config
->vl_peer
);
871 if (vl_data
->vl_oi
== NULL
) {
872 vl_data
->vl_oi
= ospf_vl_new(ospf
, vl_data
);
873 ospf_vl_add(ospf
, vl_data
);
874 ospf_spf_calculate_schedule(ospf
,
875 SPF_FLAG_CONFIG_CHANGE
);
882 static int ospf_vl_set_security(struct ospf_vl_data
*vl_data
,
883 struct ospf_vl_config_data
*vl_config
)
885 struct crypt_key
*ck
;
887 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
889 vty
= vl_config
->vty
;
891 if (vl_config
->auth_type
!= OSPF_AUTH_CMD_NOTSEEN
) {
892 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), auth_type
);
893 IF_DEF_PARAMS(ifp
)->auth_type
= vl_config
->auth_type
;
896 if (vl_config
->auth_key
) {
897 memset(IF_DEF_PARAMS(ifp
)->auth_simple
, 0,
898 OSPF_AUTH_SIMPLE_SIZE
+ 1);
899 strncpy((char *)IF_DEF_PARAMS(ifp
)->auth_simple
,
900 vl_config
->auth_key
, OSPF_AUTH_SIMPLE_SIZE
);
901 } else if (vl_config
->md5_key
) {
902 if (ospf_crypt_key_lookup(IF_DEF_PARAMS(ifp
)->auth_crypt
,
903 vl_config
->crypto_key_id
)
905 vty_out(vty
, "OSPF: Key %d already exists\n",
906 vl_config
->crypto_key_id
);
909 ck
= ospf_crypt_key_new();
910 ck
->key_id
= vl_config
->crypto_key_id
;
911 memset(ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+ 1);
912 strncpy((char *)ck
->auth_key
, vl_config
->md5_key
,
915 ospf_crypt_key_add(IF_DEF_PARAMS(ifp
)->auth_crypt
, ck
);
916 } else if (vl_config
->crypto_key_id
!= 0) {
919 if (ospf_crypt_key_lookup(IF_DEF_PARAMS(ifp
)->auth_crypt
,
920 vl_config
->crypto_key_id
)
922 vty_out(vty
, "OSPF: Key %d does not exist\n",
923 vl_config
->crypto_key_id
);
924 return CMD_WARNING_CONFIG_FAILED
;
927 ospf_crypt_key_delete(IF_DEF_PARAMS(ifp
)->auth_crypt
,
928 vl_config
->crypto_key_id
);
934 static int ospf_vl_set_timers(struct ospf_vl_data
*vl_data
,
935 struct ospf_vl_config_data
*vl_config
)
937 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
938 /* Virtual Link data initialised to defaults, so only set
940 if (vl_config
->hello_interval
) {
941 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), v_hello
);
942 IF_DEF_PARAMS(ifp
)->v_hello
= vl_config
->hello_interval
;
945 if (vl_config
->dead_interval
) {
946 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), v_wait
);
947 IF_DEF_PARAMS(ifp
)->v_wait
= vl_config
->dead_interval
;
950 if (vl_config
->retransmit_interval
) {
951 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), retransmit_interval
);
952 IF_DEF_PARAMS(ifp
)->retransmit_interval
=
953 vl_config
->retransmit_interval
;
956 if (vl_config
->transmit_delay
) {
957 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), transmit_delay
);
958 IF_DEF_PARAMS(ifp
)->transmit_delay
= vl_config
->transmit_delay
;
965 /* The business end of all of the above */
966 static int ospf_vl_set(struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
968 struct ospf_vl_data
*vl_data
;
971 vl_data
= ospf_find_vl_data(ospf
, vl_config
);
973 return CMD_WARNING_CONFIG_FAILED
;
975 /* Process this one first as it can have a fatal result, which can
976 only logically occur if the virtual link exists already
977 Thus a command error does not result in a change to the
978 running configuration such as unexpectedly altered timer
980 ret
= ospf_vl_set_security(vl_data
, vl_config
);
981 if (ret
!= CMD_SUCCESS
)
984 /* Set any time based parameters, these area already range checked */
986 ret
= ospf_vl_set_timers(vl_data
, vl_config
);
987 if (ret
!= CMD_SUCCESS
)
993 /* This stuff exists to make specifying all the alias commands A LOT simpler
995 #define VLINK_HELPSTR_IPADDR \
996 "OSPF area parameters\n" \
997 "OSPF area ID in IP address format\n" \
998 "OSPF area ID as a decimal value\n" \
999 "Configure a virtual link\n" \
1000 "Router ID of the remote ABR\n"
1002 #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
1003 "Enable authentication on this virtual link\n" \
1006 #define VLINK_HELPSTR_AUTHTYPE_ALL \
1007 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
1008 "Use null authentication\n" \
1009 "Use message-digest authentication\n"
1011 #define VLINK_HELPSTR_TIME_PARAM \
1012 "Time between HELLO packets\n" \
1014 "Time between retransmitting lost link state advertisements\n" \
1016 "Link state transmit delay\n" \
1018 "Interval time after which a neighbor is declared down\n" \
1021 #define VLINK_HELPSTR_AUTH_SIMPLE \
1022 "Authentication password (key)\n" \
1023 "The OSPF password (key)\n"
1025 #define VLINK_HELPSTR_AUTH_MD5 \
1026 "Message digest authentication password (key)\n" \
1028 "Use MD5 algorithm\n" \
1029 "The OSPF password (key)\n"
1031 DEFUN (ospf_area_vlink
,
1032 ospf_area_vlink_cmd
,
1033 "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>]",
1034 VLINK_HELPSTR_IPADDR
1035 "Enable authentication on this virtual link\n"
1036 "Use message-digest authentication\n"
1037 "Use null authentication\n"
1038 VLINK_HELPSTR_AUTH_MD5
1039 VLINK_HELPSTR_AUTH_SIMPLE
)
1041 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1042 int idx_ipv4_number
= 1;
1044 struct ospf_vl_config_data vl_config
;
1045 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+ 1];
1046 char md5_key
[OSPF_AUTH_MD5_SIZE
+ 1];
1050 ospf_vl_config_data_init(&vl_config
, vty
);
1052 /* Read off first 2 parameters and check them */
1053 ret
= str2area_id(argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
,
1054 &vl_config
.area_id_fmt
);
1056 vty_out(vty
, "OSPF area ID is invalid\n");
1057 return CMD_WARNING_CONFIG_FAILED
;
1060 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1062 vty_out(vty
, "Please specify valid Router ID as a.b.c.d\n");
1063 return CMD_WARNING_CONFIG_FAILED
;
1067 /* Thats all folks! - BUGS B. strikes again!!!*/
1069 return ospf_vl_set(ospf
, &vl_config
);
1072 if (argv_find(argv
, argc
, "authentication", &idx
)) {
1073 /* authentication - this option can only occur
1074 at start of command line */
1075 vl_config
.auth_type
= OSPF_AUTH_SIMPLE
;
1078 if (argv_find(argv
, argc
, "message-digest", &idx
)) {
1079 /* authentication message-digest */
1080 vl_config
.auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
1081 } else if (argv_find(argv
, argc
, "null", &idx
)) {
1082 /* "authentication null" */
1083 vl_config
.auth_type
= OSPF_AUTH_NULL
;
1086 if (argv_find(argv
, argc
, "message-digest-key", &idx
)) {
1087 vl_config
.md5_key
= NULL
;
1088 vl_config
.crypto_key_id
= strtol(argv
[idx
+ 1]->arg
, NULL
, 10);
1089 if (vl_config
.crypto_key_id
< 0)
1090 return CMD_WARNING_CONFIG_FAILED
;
1092 memset(md5_key
, 0, OSPF_AUTH_MD5_SIZE
+ 1);
1093 strncpy(md5_key
, argv
[idx
+ 3]->arg
, OSPF_AUTH_MD5_SIZE
);
1094 vl_config
.md5_key
= md5_key
;
1097 if (argv_find(argv
, argc
, "authentication-key", &idx
)) {
1098 memset(auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1099 strncpy(auth_key
, argv
[idx
+ 1]->arg
, OSPF_AUTH_SIMPLE_SIZE
);
1100 vl_config
.auth_key
= auth_key
;
1103 /* Action configuration */
1105 return ospf_vl_set(ospf
, &vl_config
);
1108 DEFUN (no_ospf_area_vlink
,
1109 no_ospf_area_vlink_cmd
,
1110 "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>]",
1112 VLINK_HELPSTR_IPADDR
1113 "Enable authentication on this virtual link\n" \
1114 "Use message-digest authentication\n" \
1115 "Use null authentication\n" \
1116 VLINK_HELPSTR_AUTH_MD5
1117 VLINK_HELPSTR_AUTH_SIMPLE
)
1119 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1120 int idx_ipv4_number
= 2;
1122 struct ospf_area
*area
;
1123 struct ospf_vl_config_data vl_config
;
1124 struct ospf_vl_data
*vl_data
= NULL
;
1125 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+ 1];
1129 ospf_vl_config_data_init(&vl_config
, vty
);
1131 ret
= str2area_id(argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
,
1134 vty_out(vty
, "OSPF area ID is invalid\n");
1135 return CMD_WARNING_CONFIG_FAILED
;
1138 area
= ospf_area_lookup_by_area_id(ospf
, vl_config
.area_id
);
1140 vty_out(vty
, "Area does not exist\n");
1141 return CMD_WARNING_CONFIG_FAILED
;
1144 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1146 vty_out(vty
, "Please specify valid Router ID as a.b.c.d\n");
1147 return CMD_WARNING_CONFIG_FAILED
;
1151 /* Basic VLink no command */
1152 /* Thats all folks! - BUGS B. strikes again!!!*/
1153 if ((vl_data
= ospf_vl_lookup(ospf
, area
, vl_config
.vl_peer
)))
1154 ospf_vl_delete(ospf
, vl_data
);
1156 ospf_area_check_free(ospf
, vl_config
.area_id
);
1161 /* If we are down here, we are reseting parameters */
1162 /* Deal with other parameters */
1164 if (argv_find(argv
, argc
, "authentication", &idx
)) {
1165 /* authentication - this option can only occur
1166 at start of command line */
1167 vl_config
.auth_type
= OSPF_AUTH_NOTSET
;
1170 if (argv_find(argv
, argc
, "message-digest-key", &idx
)) {
1171 vl_config
.md5_key
= NULL
;
1172 vl_config
.crypto_key_id
= strtol(argv
[idx
+ 1]->arg
, NULL
, 10);
1173 if (vl_config
.crypto_key_id
< 0)
1174 return CMD_WARNING_CONFIG_FAILED
;
1177 if (argv_find(argv
, argc
, "authentication-key", &idx
)) {
1178 /* Reset authentication-key to 0 */
1179 memset(auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1180 vl_config
.auth_key
= auth_key
;
1183 /* Action configuration */
1185 return ospf_vl_set(ospf
, &vl_config
);
1188 DEFUN (ospf_area_vlink_intervals
,
1189 ospf_area_vlink_intervals_cmd
,
1190 "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)}",
1191 VLINK_HELPSTR_IPADDR
1192 VLINK_HELPSTR_TIME_PARAM
)
1194 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1195 struct ospf_vl_config_data vl_config
;
1198 ospf_vl_config_data_init(&vl_config
, vty
);
1200 char *area_id
= argv
[1]->arg
;
1201 char *router_id
= argv
[3]->arg
;
1203 ret
= str2area_id(area_id
, &vl_config
.area_id
, &vl_config
.area_id_fmt
);
1205 vty_out(vty
, "OSPF area ID is invalid\n");
1206 return CMD_WARNING_CONFIG_FAILED
;
1209 ret
= inet_aton(router_id
, &vl_config
.vl_peer
);
1211 vty_out(vty
, "Please specify valid Router ID as a.b.c.d\n");
1212 return CMD_WARNING_CONFIG_FAILED
;
1215 for (int idx
= 4; idx
< argc
; idx
++) {
1216 if (strmatch(argv
[idx
]->text
, "hello-interval"))
1217 vl_config
.hello_interval
=
1218 strtol(argv
[++idx
]->arg
, NULL
, 10);
1219 else if (strmatch(argv
[idx
]->text
, "retransmit-interval"))
1220 vl_config
.retransmit_interval
=
1221 strtol(argv
[++idx
]->arg
, NULL
, 10);
1222 else if (strmatch(argv
[idx
]->text
, "transmit-delay"))
1223 vl_config
.transmit_delay
=
1224 strtol(argv
[++idx
]->arg
, NULL
, 10);
1225 else if (strmatch(argv
[idx
]->text
, "dead-interval"))
1226 vl_config
.dead_interval
=
1227 strtol(argv
[++idx
]->arg
, NULL
, 10);
1230 /* Action configuration */
1231 return ospf_vl_set(ospf
, &vl_config
);
1234 DEFUN (no_ospf_area_vlink_intervals
,
1235 no_ospf_area_vlink_intervals_cmd
,
1236 "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)}",
1238 VLINK_HELPSTR_IPADDR
1239 VLINK_HELPSTR_TIME_PARAM
)
1241 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1242 struct ospf_vl_config_data vl_config
;
1245 ospf_vl_config_data_init(&vl_config
, vty
);
1247 char *area_id
= argv
[2]->arg
;
1248 char *router_id
= argv
[4]->arg
;
1250 ret
= str2area_id(area_id
, &vl_config
.area_id
, &vl_config
.area_id_fmt
);
1252 vty_out(vty
, "OSPF area ID is invalid\n");
1253 return CMD_WARNING_CONFIG_FAILED
;
1256 ret
= inet_aton(router_id
, &vl_config
.vl_peer
);
1258 vty_out(vty
, "Please specify valid Router ID as a.b.c.d\n");
1259 return CMD_WARNING_CONFIG_FAILED
;
1262 for (int idx
= 5; idx
< argc
; idx
++) {
1263 if (strmatch(argv
[idx
]->text
, "hello-interval"))
1264 vl_config
.hello_interval
= OSPF_HELLO_INTERVAL_DEFAULT
;
1265 else if (strmatch(argv
[idx
]->text
, "retransmit-interval"))
1266 vl_config
.retransmit_interval
=
1267 OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
1268 else if (strmatch(argv
[idx
]->text
, "transmit-delay"))
1269 vl_config
.transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
1270 else if (strmatch(argv
[idx
]->text
, "dead-interval"))
1271 vl_config
.dead_interval
=
1272 OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
1275 /* Action configuration */
1276 return ospf_vl_set(ospf
, &vl_config
);
1279 DEFUN (ospf_area_shortcut
,
1280 ospf_area_shortcut_cmd
,
1281 "area <A.B.C.D|(0-4294967295)> shortcut <default|enable|disable>",
1282 "OSPF area parameters\n"
1283 "OSPF area ID in IP address format\n"
1284 "OSPF area ID as a decimal value\n"
1285 "Configure the area's shortcutting mode\n"
1286 "Set default shortcutting behavior\n"
1287 "Enable shortcutting through the area\n"
1288 "Disable shortcutting through the area\n")
1290 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1291 int idx_ipv4_number
= 1;
1292 int idx_enable_disable
= 3;
1293 struct ospf_area
*area
;
1294 struct in_addr area_id
;
1298 VTY_GET_OSPF_AREA_ID_NO_BB("shortcut", area_id
, format
,
1299 argv
[idx_ipv4_number
]->arg
);
1301 area
= ospf_area_get(ospf
, area_id
);
1302 ospf_area_display_format_set(ospf
, area
, format
);
1304 if (strncmp(argv
[idx_enable_disable
]->arg
, "de", 2) == 0)
1305 mode
= OSPF_SHORTCUT_DEFAULT
;
1306 else if (strncmp(argv
[idx_enable_disable
]->arg
, "di", 2) == 0)
1307 mode
= OSPF_SHORTCUT_DISABLE
;
1308 else if (strncmp(argv
[idx_enable_disable
]->arg
, "e", 1) == 0)
1309 mode
= OSPF_SHORTCUT_ENABLE
;
1311 return CMD_WARNING_CONFIG_FAILED
;
1313 ospf_area_shortcut_set(ospf
, area
, mode
);
1315 if (ospf
->abr_type
!= OSPF_ABR_SHORTCUT
)
1317 "Shortcut area setting will take effect "
1318 "only when the router is configured as Shortcut ABR\n");
1323 DEFUN (no_ospf_area_shortcut
,
1324 no_ospf_area_shortcut_cmd
,
1325 "no area <A.B.C.D|(0-4294967295)> shortcut <enable|disable>",
1327 "OSPF area parameters\n"
1328 "OSPF area ID in IP address format\n"
1329 "OSPF area ID as a decimal value\n"
1330 "Deconfigure the area's shortcutting mode\n"
1331 "Deconfigure enabled shortcutting through the area\n"
1332 "Deconfigure disabled shortcutting through the area\n")
1334 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1335 int idx_ipv4_number
= 2;
1336 struct ospf_area
*area
;
1337 struct in_addr area_id
;
1340 VTY_GET_OSPF_AREA_ID_NO_BB("shortcut", area_id
, format
,
1341 argv
[idx_ipv4_number
]->arg
);
1343 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1347 ospf_area_shortcut_unset(ospf
, area
);
1353 DEFUN (ospf_area_stub
,
1355 "area <A.B.C.D|(0-4294967295)> stub",
1356 "OSPF area parameters\n"
1357 "OSPF area ID in IP address format\n"
1358 "OSPF area ID as a decimal value\n"
1359 "Configure OSPF area as stub\n")
1361 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1362 int idx_ipv4_number
= 1;
1363 struct in_addr area_id
;
1366 VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id
, format
,
1367 argv
[idx_ipv4_number
]->arg
);
1369 ret
= ospf_area_stub_set(ospf
, area_id
);
1370 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1374 "First deconfigure all virtual link through this area\n");
1375 return CMD_WARNING_CONFIG_FAILED
;
1378 ospf_area_no_summary_unset(ospf
, area_id
);
1383 DEFUN (ospf_area_stub_no_summary
,
1384 ospf_area_stub_no_summary_cmd
,
1385 "area <A.B.C.D|(0-4294967295)> stub no-summary",
1386 "OSPF stub parameters\n"
1387 "OSPF area ID in IP address format\n"
1388 "OSPF area ID as a decimal value\n"
1389 "Configure OSPF area as stub\n"
1390 "Do not inject inter-area routes into stub\n")
1392 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1393 int idx_ipv4_number
= 1;
1394 struct in_addr area_id
;
1397 VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id
, format
,
1398 argv
[idx_ipv4_number
]->arg
);
1400 ret
= ospf_area_stub_set(ospf
, area_id
);
1401 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1405 "%% Area cannot be stub as it contains a virtual link\n");
1406 return CMD_WARNING_CONFIG_FAILED
;
1409 ospf_area_no_summary_set(ospf
, area_id
);
1414 DEFUN (no_ospf_area_stub
,
1415 no_ospf_area_stub_cmd
,
1416 "no area <A.B.C.D|(0-4294967295)> stub",
1418 "OSPF area parameters\n"
1419 "OSPF area ID in IP address format\n"
1420 "OSPF area ID as a decimal value\n"
1421 "Configure OSPF area as stub\n")
1423 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1424 int idx_ipv4_number
= 2;
1425 struct in_addr area_id
;
1428 VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id
, format
,
1429 argv
[idx_ipv4_number
]->arg
);
1431 ospf_area_stub_unset(ospf
, area_id
);
1432 ospf_area_no_summary_unset(ospf
, area_id
);
1437 DEFUN (no_ospf_area_stub_no_summary
,
1438 no_ospf_area_stub_no_summary_cmd
,
1439 "no area <A.B.C.D|(0-4294967295)> stub no-summary",
1441 "OSPF area parameters\n"
1442 "OSPF area ID in IP address format\n"
1443 "OSPF area ID as a decimal value\n"
1444 "Configure OSPF area as stub\n"
1445 "Do not inject inter-area routes into area\n")
1447 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1448 int idx_ipv4_number
= 2;
1449 struct in_addr area_id
;
1452 VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id
, format
,
1453 argv
[idx_ipv4_number
]->arg
);
1454 ospf_area_no_summary_unset(ospf
, area_id
);
1459 static int ospf_area_nssa_cmd_handler(struct vty
*vty
, int argc
,
1460 struct cmd_token
**argv
, int nosum
)
1462 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1463 struct in_addr area_id
;
1466 VTY_GET_OSPF_AREA_ID_NO_BB("NSSA", area_id
, format
, argv
[1]->arg
);
1468 ret
= ospf_area_nssa_set(ospf
, area_id
);
1469 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1473 "%% Area cannot be nssa as it contains a virtual link\n");
1474 return CMD_WARNING_CONFIG_FAILED
;
1478 if (strncmp(argv
[3]->text
, "translate-c", 11) == 0)
1479 ospf_area_nssa_translator_role_set(
1480 ospf
, area_id
, OSPF_NSSA_ROLE_CANDIDATE
);
1481 else if (strncmp(argv
[3]->text
, "translate-n", 11) == 0)
1482 ospf_area_nssa_translator_role_set(
1483 ospf
, area_id
, OSPF_NSSA_ROLE_NEVER
);
1484 else if (strncmp(argv
[3]->text
, "translate-a", 11) == 0)
1485 ospf_area_nssa_translator_role_set(
1486 ospf
, area_id
, OSPF_NSSA_ROLE_ALWAYS
);
1488 ospf_area_nssa_translator_role_set(ospf
, area_id
,
1489 OSPF_NSSA_ROLE_CANDIDATE
);
1493 ospf_area_no_summary_set(ospf
, area_id
);
1495 ospf_area_no_summary_unset(ospf
, area_id
);
1497 ospf_schedule_abr_task(ospf
);
1502 DEFUN (ospf_area_nssa_translate_no_summary
,
1503 ospf_area_nssa_translate_no_summary_cmd
,
1504 "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always> no-summary",
1505 "OSPF area parameters\n"
1506 "OSPF area ID in IP address format\n"
1507 "OSPF area ID as a decimal value\n"
1508 "Configure OSPF area as nssa\n"
1509 "Configure NSSA-ABR for translate election (default)\n"
1510 "Configure NSSA-ABR to never translate\n"
1511 "Configure NSSA-ABR to always translate\n"
1512 "Do not inject inter-area routes into nssa\n")
1514 return ospf_area_nssa_cmd_handler(vty
, argc
, argv
, 1);
1517 DEFUN (ospf_area_nssa_translate
,
1518 ospf_area_nssa_translate_cmd
,
1519 "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always>",
1520 "OSPF area parameters\n"
1521 "OSPF area ID in IP address format\n"
1522 "OSPF area ID as a decimal value\n"
1523 "Configure OSPF area as nssa\n"
1524 "Configure NSSA-ABR for translate election (default)\n"
1525 "Configure NSSA-ABR to never translate\n"
1526 "Configure NSSA-ABR to always translate\n")
1528 return ospf_area_nssa_cmd_handler(vty
, argc
, argv
, 0);
1531 DEFUN (ospf_area_nssa
,
1533 "area <A.B.C.D|(0-4294967295)> nssa",
1534 "OSPF area parameters\n"
1535 "OSPF area ID in IP address format\n"
1536 "OSPF area ID as a decimal value\n"
1537 "Configure OSPF area as nssa\n")
1539 return ospf_area_nssa_cmd_handler(vty
, argc
, argv
, 0);
1542 DEFUN (ospf_area_nssa_no_summary
,
1543 ospf_area_nssa_no_summary_cmd
,
1544 "area <A.B.C.D|(0-4294967295)> nssa no-summary",
1545 "OSPF area parameters\n"
1546 "OSPF area ID in IP address format\n"
1547 "OSPF area ID as a decimal value\n"
1548 "Configure OSPF area as nssa\n"
1549 "Do not inject inter-area routes into nssa\n")
1551 return ospf_area_nssa_cmd_handler(vty
, argc
, argv
, 1);
1554 DEFUN (no_ospf_area_nssa
,
1555 no_ospf_area_nssa_cmd
,
1556 "no area <A.B.C.D|(0-4294967295)> nssa [<translate-candidate|translate-never|translate-always> [no-summary]]",
1558 "OSPF area parameters\n"
1559 "OSPF area ID in IP address format\n"
1560 "OSPF area ID as a decimal value\n"
1561 "Configure OSPF area as nssa\n"
1562 "Configure NSSA-ABR for translate election (default)\n"
1563 "Configure NSSA-ABR to never translate\n"
1564 "Configure NSSA-ABR to always translate\n"
1565 "Do not inject inter-area routes into nssa\n")
1567 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1568 int idx_ipv4_number
= 2;
1569 struct in_addr area_id
;
1572 VTY_GET_OSPF_AREA_ID_NO_BB("NSSA", area_id
, format
,
1573 argv
[idx_ipv4_number
]->arg
);
1575 ospf_area_nssa_unset(ospf
, area_id
);
1576 ospf_area_no_summary_unset(ospf
, area_id
);
1578 ospf_schedule_abr_task(ospf
);
1584 DEFUN (ospf_area_default_cost
,
1585 ospf_area_default_cost_cmd
,
1586 "area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1587 "OSPF area parameters\n"
1588 "OSPF area ID in IP address format\n"
1589 "OSPF area ID as a decimal value\n"
1590 "Set the summary-default cost of a NSSA or stub area\n"
1591 "Stub's advertised default summary cost\n")
1593 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1594 int idx_ipv4_number
= 1;
1596 struct ospf_area
*area
;
1597 struct in_addr area_id
;
1600 struct prefix_ipv4 p
;
1602 VTY_GET_OSPF_AREA_ID_NO_BB("default-cost", area_id
, format
,
1603 argv
[idx_ipv4_number
]->arg
);
1604 cost
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1606 area
= ospf_area_get(ospf
, area_id
);
1607 ospf_area_display_format_set(ospf
, area
, format
);
1609 if (area
->external_routing
== OSPF_AREA_DEFAULT
) {
1610 vty_out(vty
, "The area is neither stub, nor NSSA\n");
1611 return CMD_WARNING_CONFIG_FAILED
;
1614 area
->default_cost
= cost
;
1617 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1619 if (IS_DEBUG_OSPF_EVENT
)
1621 "ospf_abr_announce_stub_defaults(): "
1622 "announcing 0.0.0.0/0 to area %s",
1623 inet_ntoa(area
->area_id
));
1624 ospf_abr_announce_network_to_area(&p
, area
->default_cost
, area
);
1629 DEFUN (no_ospf_area_default_cost
,
1630 no_ospf_area_default_cost_cmd
,
1631 "no area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1633 "OSPF area parameters\n"
1634 "OSPF area ID in IP address format\n"
1635 "OSPF area ID as a decimal value\n"
1636 "Set the summary-default cost of a NSSA or stub area\n"
1637 "Stub's advertised default summary cost\n")
1639 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1640 int idx_ipv4_number
= 2;
1641 struct ospf_area
*area
;
1642 struct in_addr area_id
;
1644 struct prefix_ipv4 p
;
1646 VTY_GET_OSPF_AREA_ID_NO_BB("default-cost", area_id
, format
,
1647 argv
[idx_ipv4_number
]->arg
);
1649 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1653 if (area
->external_routing
== OSPF_AREA_DEFAULT
) {
1654 vty_out(vty
, "The area is neither stub, nor NSSA\n");
1655 return CMD_WARNING_CONFIG_FAILED
;
1658 area
->default_cost
= 1;
1661 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1663 if (IS_DEBUG_OSPF_EVENT
)
1665 "ospf_abr_announce_stub_defaults(): "
1666 "announcing 0.0.0.0/0 to area %s",
1667 inet_ntoa(area
->area_id
));
1668 ospf_abr_announce_network_to_area(&p
, area
->default_cost
, area
);
1671 ospf_area_check_free(ospf
, area_id
);
1676 DEFUN (ospf_area_export_list
,
1677 ospf_area_export_list_cmd
,
1678 "area <A.B.C.D|(0-4294967295)> export-list NAME",
1679 "OSPF area parameters\n"
1680 "OSPF area ID in IP address format\n"
1681 "OSPF area ID as a decimal value\n"
1682 "Set the filter for networks announced to other areas\n"
1683 "Name of the access-list\n")
1685 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1686 int idx_ipv4_number
= 1;
1687 struct ospf_area
*area
;
1688 struct in_addr area_id
;
1691 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1693 area
= ospf_area_get(ospf
, area_id
);
1694 ospf_area_display_format_set(ospf
, area
, format
);
1695 ospf_area_export_list_set(ospf
, area
, argv
[3]->arg
);
1700 DEFUN (no_ospf_area_export_list
,
1701 no_ospf_area_export_list_cmd
,
1702 "no area <A.B.C.D|(0-4294967295)> export-list NAME",
1704 "OSPF area parameters\n"
1705 "OSPF area ID in IP address format\n"
1706 "OSPF area ID as a decimal value\n"
1707 "Unset the filter for networks announced to other areas\n"
1708 "Name of the access-list\n")
1710 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1711 int idx_ipv4_number
= 2;
1712 struct ospf_area
*area
;
1713 struct in_addr area_id
;
1716 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1718 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1722 ospf_area_export_list_unset(ospf
, area
);
1728 DEFUN (ospf_area_import_list
,
1729 ospf_area_import_list_cmd
,
1730 "area <A.B.C.D|(0-4294967295)> import-list NAME",
1731 "OSPF area parameters\n"
1732 "OSPF area ID in IP address format\n"
1733 "OSPF area ID as a decimal value\n"
1734 "Set the filter for networks from other areas announced to the specified one\n"
1735 "Name of the access-list\n")
1737 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1738 int idx_ipv4_number
= 1;
1739 struct ospf_area
*area
;
1740 struct in_addr area_id
;
1743 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1745 area
= ospf_area_get(ospf
, area_id
);
1746 ospf_area_display_format_set(ospf
, area
, format
);
1747 ospf_area_import_list_set(ospf
, area
, argv
[3]->arg
);
1752 DEFUN (no_ospf_area_import_list
,
1753 no_ospf_area_import_list_cmd
,
1754 "no area <A.B.C.D|(0-4294967295)> import-list NAME",
1756 "OSPF area parameters\n"
1757 "OSPF area ID in IP address format\n"
1758 "OSPF area ID as a decimal value\n"
1759 "Unset the filter for networks announced to other areas\n"
1760 "Name of the access-list\n")
1762 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1763 int idx_ipv4_number
= 2;
1764 struct ospf_area
*area
;
1765 struct in_addr area_id
;
1768 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1770 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1774 ospf_area_import_list_unset(ospf
, area
);
1779 DEFUN (ospf_area_filter_list
,
1780 ospf_area_filter_list_cmd
,
1781 "area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>",
1782 "OSPF area parameters\n"
1783 "OSPF area ID in IP address format\n"
1784 "OSPF area ID as a decimal value\n"
1785 "Filter networks between OSPF areas\n"
1786 "Filter prefixes between OSPF areas\n"
1787 "Name of an IP prefix-list\n"
1788 "Filter networks sent to this area\n"
1789 "Filter networks sent from this area\n")
1791 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1792 int idx_ipv4_number
= 1;
1795 struct ospf_area
*area
;
1796 struct in_addr area_id
;
1797 struct prefix_list
*plist
;
1800 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1802 area
= ospf_area_get(ospf
, area_id
);
1803 ospf_area_display_format_set(ospf
, area
, format
);
1804 plist
= prefix_list_lookup(AFI_IP
, argv
[idx_word
]->arg
);
1805 if (strncmp(argv
[idx_in_out
]->arg
, "in", 2) == 0) {
1806 PREFIX_LIST_IN(area
) = plist
;
1807 if (PREFIX_NAME_IN(area
))
1808 free(PREFIX_NAME_IN(area
));
1810 PREFIX_NAME_IN(area
) = strdup(argv
[idx_word
]->arg
);
1811 ospf_schedule_abr_task(ospf
);
1813 PREFIX_LIST_OUT(area
) = plist
;
1814 if (PREFIX_NAME_OUT(area
))
1815 free(PREFIX_NAME_OUT(area
));
1817 PREFIX_NAME_OUT(area
) = strdup(argv
[idx_word
]->arg
);
1818 ospf_schedule_abr_task(ospf
);
1824 DEFUN (no_ospf_area_filter_list
,
1825 no_ospf_area_filter_list_cmd
,
1826 "no area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>",
1828 "OSPF area parameters\n"
1829 "OSPF area ID in IP address format\n"
1830 "OSPF area ID as a decimal value\n"
1831 "Filter networks between OSPF areas\n"
1832 "Filter prefixes between OSPF areas\n"
1833 "Name of an IP prefix-list\n"
1834 "Filter networks sent to this area\n"
1835 "Filter networks sent from this area\n")
1837 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1838 int idx_ipv4_number
= 2;
1841 struct ospf_area
*area
;
1842 struct in_addr area_id
;
1845 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1847 if ((area
= ospf_area_lookup_by_area_id(ospf
, area_id
)) == NULL
)
1850 if (strncmp(argv
[idx_in_out
]->arg
, "in", 2) == 0) {
1851 if (PREFIX_NAME_IN(area
))
1852 if (strcmp(PREFIX_NAME_IN(area
), argv
[idx_word
]->arg
)
1856 PREFIX_LIST_IN(area
) = NULL
;
1857 if (PREFIX_NAME_IN(area
))
1858 free(PREFIX_NAME_IN(area
));
1860 PREFIX_NAME_IN(area
) = NULL
;
1862 ospf_schedule_abr_task(ospf
);
1864 if (PREFIX_NAME_OUT(area
))
1865 if (strcmp(PREFIX_NAME_OUT(area
), argv
[idx_word
]->arg
)
1869 PREFIX_LIST_OUT(area
) = NULL
;
1870 if (PREFIX_NAME_OUT(area
))
1871 free(PREFIX_NAME_OUT(area
));
1873 PREFIX_NAME_OUT(area
) = NULL
;
1875 ospf_schedule_abr_task(ospf
);
1882 DEFUN (ospf_area_authentication_message_digest
,
1883 ospf_area_authentication_message_digest_cmd
,
1884 "[no] area <A.B.C.D|(0-4294967295)> authentication message-digest",
1886 "OSPF area parameters\n"
1887 "OSPF area ID in IP address format\n"
1888 "OSPF area ID as a decimal value\n"
1889 "Enable authentication\n"
1890 "Use message-digest authentication\n")
1892 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1893 int idx_ipv4_number
= 1;
1894 struct ospf_area
*area
;
1895 struct in_addr area_id
;
1898 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1900 area
= ospf_area_get(ospf
, area_id
);
1901 ospf_area_display_format_set(ospf
, area
, format
);
1902 area
->auth_type
= strmatch(argv
[0]->text
, "no") ? OSPF_AUTH_NULL
: OSPF_AUTH_CRYPTOGRAPHIC
;
1907 DEFUN (ospf_area_authentication
,
1908 ospf_area_authentication_cmd
,
1909 "area <A.B.C.D|(0-4294967295)> authentication",
1910 "OSPF area parameters\n"
1911 "OSPF area ID in IP address format\n"
1912 "OSPF area ID as a decimal value\n"
1913 "Enable authentication\n")
1915 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1916 int idx_ipv4_number
= 1;
1917 struct ospf_area
*area
;
1918 struct in_addr area_id
;
1921 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1923 area
= ospf_area_get(ospf
, area_id
);
1924 ospf_area_display_format_set(ospf
, area
, format
);
1925 area
->auth_type
= OSPF_AUTH_SIMPLE
;
1930 DEFUN (no_ospf_area_authentication
,
1931 no_ospf_area_authentication_cmd
,
1932 "no area <A.B.C.D|(0-4294967295)> authentication",
1934 "OSPF area parameters\n"
1935 "OSPF area ID in IP address format\n"
1936 "OSPF area ID as a decimal value\n"
1937 "Enable authentication\n")
1939 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1940 int idx_ipv4_number
= 2;
1941 struct ospf_area
*area
;
1942 struct in_addr area_id
;
1945 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1947 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1951 area
->auth_type
= OSPF_AUTH_NULL
;
1953 ospf_area_check_free(ospf
, area_id
);
1959 DEFUN (ospf_abr_type
,
1961 "ospf abr-type <cisco|ibm|shortcut|standard>",
1962 "OSPF specific commands\n"
1963 "Set OSPF ABR type\n"
1964 "Alternative ABR, cisco implementation\n"
1965 "Alternative ABR, IBM implementation\n"
1967 "Standard behavior (RFC2328)\n")
1969 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1971 u_char abr_type
= OSPF_ABR_UNKNOWN
;
1973 if (strncmp(argv
[idx_vendor
]->arg
, "c", 1) == 0)
1974 abr_type
= OSPF_ABR_CISCO
;
1975 else if (strncmp(argv
[idx_vendor
]->arg
, "i", 1) == 0)
1976 abr_type
= OSPF_ABR_IBM
;
1977 else if (strncmp(argv
[idx_vendor
]->arg
, "sh", 2) == 0)
1978 abr_type
= OSPF_ABR_SHORTCUT
;
1979 else if (strncmp(argv
[idx_vendor
]->arg
, "st", 2) == 0)
1980 abr_type
= OSPF_ABR_STAND
;
1982 return CMD_WARNING_CONFIG_FAILED
;
1984 /* If ABR type value is changed, schedule ABR task. */
1985 if (ospf
->abr_type
!= abr_type
) {
1986 ospf
->abr_type
= abr_type
;
1987 ospf_schedule_abr_task(ospf
);
1993 DEFUN (no_ospf_abr_type
,
1994 no_ospf_abr_type_cmd
,
1995 "no ospf abr-type <cisco|ibm|shortcut|standard>",
1997 "OSPF specific commands\n"
1998 "Set OSPF ABR type\n"
1999 "Alternative ABR, cisco implementation\n"
2000 "Alternative ABR, IBM implementation\n"
2004 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2006 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2008 if (strncmp(argv
[idx_vendor
]->arg
, "c", 1) == 0)
2009 abr_type
= OSPF_ABR_CISCO
;
2010 else if (strncmp(argv
[idx_vendor
]->arg
, "i", 1) == 0)
2011 abr_type
= OSPF_ABR_IBM
;
2012 else if (strncmp(argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2013 abr_type
= OSPF_ABR_SHORTCUT
;
2014 else if (strncmp(argv
[idx_vendor
]->arg
, "st", 2) == 0)
2015 abr_type
= OSPF_ABR_STAND
;
2017 return CMD_WARNING_CONFIG_FAILED
;
2019 /* If ABR type value is changed, schedule ABR task. */
2020 if (ospf
->abr_type
== abr_type
) {
2021 ospf
->abr_type
= OSPF_ABR_DEFAULT
;
2022 ospf_schedule_abr_task(ospf
);
2028 DEFUN (ospf_log_adjacency_changes
,
2029 ospf_log_adjacency_changes_cmd
,
2030 "log-adjacency-changes",
2031 "Log changes in adjacency state\n")
2033 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2035 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2036 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2040 DEFUN (ospf_log_adjacency_changes_detail
,
2041 ospf_log_adjacency_changes_detail_cmd
,
2042 "log-adjacency-changes detail",
2043 "Log changes in adjacency state\n"
2044 "Log all state changes\n")
2046 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2048 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2049 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2053 DEFUN (no_ospf_log_adjacency_changes
,
2054 no_ospf_log_adjacency_changes_cmd
,
2055 "no log-adjacency-changes",
2057 "Log changes in adjacency state\n")
2059 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2061 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2062 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2066 DEFUN (no_ospf_log_adjacency_changes_detail
,
2067 no_ospf_log_adjacency_changes_detail_cmd
,
2068 "no log-adjacency-changes detail",
2070 "Log changes in adjacency state\n"
2071 "Log all state changes\n")
2073 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2075 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2079 DEFUN (ospf_compatible_rfc1583
,
2080 ospf_compatible_rfc1583_cmd
,
2081 "compatible rfc1583",
2082 "OSPF compatibility list\n"
2083 "compatible with RFC 1583\n")
2085 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2087 if (!CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)) {
2088 SET_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2089 ospf_spf_calculate_schedule(ospf
, SPF_FLAG_CONFIG_CHANGE
);
2094 DEFUN (no_ospf_compatible_rfc1583
,
2095 no_ospf_compatible_rfc1583_cmd
,
2096 "no compatible rfc1583",
2098 "OSPF compatibility list\n"
2099 "compatible with RFC 1583\n")
2101 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2103 if (CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)) {
2104 UNSET_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2105 ospf_spf_calculate_schedule(ospf
, SPF_FLAG_CONFIG_CHANGE
);
2110 ALIAS(ospf_compatible_rfc1583
, ospf_rfc1583_flag_cmd
,
2111 "ospf rfc1583compatibility",
2112 "OSPF specific commands\n"
2113 "Enable the RFC1583Compatibility flag\n")
2115 ALIAS(no_ospf_compatible_rfc1583
, no_ospf_rfc1583_flag_cmd
,
2116 "no ospf rfc1583compatibility", NO_STR
2117 "OSPF specific commands\n"
2118 "Disable the RFC1583Compatibility flag\n")
2120 static int ospf_timers_spf_set(struct vty
*vty
, unsigned int delay
,
2121 unsigned int hold
, unsigned int max
)
2123 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2125 ospf
->spf_delay
= delay
;
2126 ospf
->spf_holdtime
= hold
;
2127 ospf
->spf_max_holdtime
= max
;
2132 DEFUN (ospf_timers_min_ls_interval
,
2133 ospf_timers_min_ls_interval_cmd
,
2134 "timers throttle lsa all (0-5000)",
2135 "Adjust routing timers\n"
2136 "Throttling adaptive timer\n"
2137 "LSA delay between transmissions\n"
2139 "Delay (msec) between sending LSAs\n")
2141 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2143 unsigned int interval
;
2146 vty_out(vty
, "Insufficient arguments\n");
2147 return CMD_WARNING_CONFIG_FAILED
;
2150 interval
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2152 ospf
->min_ls_interval
= interval
;
2157 DEFUN (no_ospf_timers_min_ls_interval
,
2158 no_ospf_timers_min_ls_interval_cmd
,
2159 "no timers throttle lsa all [(0-5000)]",
2161 "Adjust routing timers\n"
2162 "Throttling adaptive timer\n"
2163 "LSA delay between transmissions\n"
2165 "Delay (msec) between sending LSAs\n")
2167 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2168 ospf
->min_ls_interval
= OSPF_MIN_LS_INTERVAL
;
2173 DEFUN (ospf_timers_throttle_spf
,
2174 ospf_timers_throttle_spf_cmd
,
2175 "timers throttle spf (0-600000) (0-600000) (0-600000)",
2176 "Adjust routing timers\n"
2177 "Throttling adaptive timer\n"
2179 "Delay (msec) from first change received till SPF calculation\n"
2180 "Initial hold time (msec) between consecutive SPF calculations\n"
2181 "Maximum hold time (msec)\n")
2184 int idx_number_2
= 4;
2185 int idx_number_3
= 5;
2186 unsigned int delay
, hold
, max
;
2189 vty_out(vty
, "Insufficient arguments\n");
2190 return CMD_WARNING_CONFIG_FAILED
;
2193 delay
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2194 hold
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
2195 max
= strtoul(argv
[idx_number_3
]->arg
, NULL
, 10);
2197 return ospf_timers_spf_set(vty
, delay
, hold
, max
);
2200 DEFUN (no_ospf_timers_throttle_spf
,
2201 no_ospf_timers_throttle_spf_cmd
,
2202 "no timers throttle spf [(0-600000)(0-600000)(0-600000)]",
2204 "Adjust routing timers\n"
2205 "Throttling adaptive timer\n"
2207 "Delay (msec) from first change received till SPF calculation\n"
2208 "Initial hold time (msec) between consecutive SPF calculations\n"
2209 "Maximum hold time (msec)\n")
2211 return ospf_timers_spf_set(vty
, OSPF_SPF_DELAY_DEFAULT
,
2212 OSPF_SPF_HOLDTIME_DEFAULT
,
2213 OSPF_SPF_MAX_HOLDTIME_DEFAULT
);
2217 DEFUN (ospf_timers_lsa_min_arrival
,
2218 ospf_timers_lsa_min_arrival_cmd
,
2219 "timers lsa min-arrival (0-600000)",
2220 "Adjust routing timers\n"
2222 "Minimum delay in receiving new version of a LSA\n"
2223 "Delay in milliseconds\n")
2225 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2226 ospf
->min_ls_arrival
= strtoul(argv
[argc
- 1]->arg
, NULL
, 10);
2230 DEFUN (no_ospf_timers_lsa_min_arrival
,
2231 no_ospf_timers_lsa_min_arrival_cmd
,
2232 "no timers lsa min-arrival [(0-600000)]",
2234 "Adjust routing timers\n"
2236 "Minimum delay in receiving new version of a LSA\n"
2237 "Delay in milliseconds\n")
2239 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2240 unsigned int minarrival
;
2243 minarrival
= strtoul(argv
[argc
- 1]->arg
, NULL
, 10);
2245 if (ospf
->min_ls_arrival
!= minarrival
2246 || minarrival
== OSPF_MIN_LS_ARRIVAL
)
2250 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2255 #if CONFDATE > 20180708
2256 CPP_NOTICE("ospf: `timers lsa arrival (0-1000)` deprecated 2017/07/08")
2258 ALIAS_HIDDEN (ospf_timers_lsa_min_arrival
,
2259 ospf_timers_lsa_arrival_cmd
,
2260 "timers lsa arrival (0-1000)",
2261 "adjust routing timers\n"
2262 "throttling link state advertisement delays\n"
2263 "ospf minimum arrival interval delay\n"
2264 "delay (msec) between accepted lsas\n");
2266 #if CONFDATE > 20180708
2267 CPP_NOTICE("ospf: `no timers lsa arrival (0-1000)` deprecated 2017/07/08")
2269 ALIAS_HIDDEN (no_ospf_timers_lsa_min_arrival
,
2270 no_ospf_timers_lsa_arrival_cmd
,
2271 "no timers lsa arrival (0-1000)",
2273 "adjust routing timers\n"
2274 "throttling link state advertisement delays\n"
2275 "ospf minimum arrival interval delay\n"
2276 "delay (msec) between accepted lsas\n");
2279 DEFUN (ospf_neighbor
,
2281 "neighbor A.B.C.D [priority (0-255) [poll-interval (1-65535)]]",
2283 "Neighbor IP address\n"
2284 "Neighbor Priority\n"
2286 "Dead Neighbor Polling interval\n"
2289 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2293 struct in_addr nbr_addr
;
2294 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2295 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2297 if (!inet_aton(argv
[idx_ipv4
]->arg
, &nbr_addr
)) {
2298 vty_out(vty
, "Please specify Neighbor ID by A.B.C.D\n");
2299 return CMD_WARNING_CONFIG_FAILED
;
2303 priority
= strtoul(argv
[idx_pri
]->arg
, NULL
, 10);
2306 interval
= strtoul(argv
[idx_poll
]->arg
, NULL
, 10);
2308 ospf_nbr_nbma_set(ospf
, nbr_addr
);
2311 ospf_nbr_nbma_priority_set(ospf
, nbr_addr
, priority
);
2314 ospf_nbr_nbma_poll_interval_set(ospf
, nbr_addr
, interval
);
2319 DEFUN (ospf_neighbor_poll_interval
,
2320 ospf_neighbor_poll_interval_cmd
,
2321 "neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2323 "Neighbor IP address\n"
2324 "Dead Neighbor Polling interval\n"
2326 "OSPF priority of non-broadcast neighbor\n"
2329 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2333 struct in_addr nbr_addr
;
2334 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2335 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2337 if (!inet_aton(argv
[idx_ipv4
]->arg
, &nbr_addr
)) {
2338 vty_out(vty
, "Please specify Neighbor ID by A.B.C.D\n");
2339 return CMD_WARNING_CONFIG_FAILED
;
2342 interval
= strtoul(argv
[idx_poll
]->arg
, NULL
, 10);
2345 priority
= strtoul(argv
[idx_pri
]->arg
, NULL
, 10);
2347 ospf_nbr_nbma_set(ospf
, nbr_addr
);
2348 ospf_nbr_nbma_poll_interval_set(ospf
, nbr_addr
, interval
);
2351 ospf_nbr_nbma_priority_set(ospf
, nbr_addr
, priority
);
2356 DEFUN (no_ospf_neighbor
,
2357 no_ospf_neighbor_cmd
,
2358 "no neighbor A.B.C.D [priority (0-255) [poll-interval (1-65525)]]",
2361 "Neighbor IP address\n"
2362 "Neighbor Priority\n"
2364 "Dead Neighbor Polling interval\n"
2367 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2369 struct in_addr nbr_addr
;
2371 if (!inet_aton(argv
[idx_ipv4
]->arg
, &nbr_addr
)) {
2372 vty_out(vty
, "Please specify Neighbor ID by A.B.C.D\n");
2373 return CMD_WARNING_CONFIG_FAILED
;
2376 (void)ospf_nbr_nbma_unset(ospf
, nbr_addr
);
2381 DEFUN (no_ospf_neighbor_poll
,
2382 no_ospf_neighbor_poll_cmd
,
2383 "no neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2386 "Neighbor IP address\n"
2387 "Dead Neighbor Polling interval\n"
2389 "Neighbor Priority\n"
2392 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2394 struct in_addr nbr_addr
;
2396 if (!inet_aton(argv
[idx_ipv4
]->arg
, &nbr_addr
)) {
2397 vty_out(vty
, "Please specify Neighbor ID by A.B.C.D\n");
2398 return CMD_WARNING_CONFIG_FAILED
;
2401 (void)ospf_nbr_nbma_unset(ospf
, nbr_addr
);
2406 DEFUN (ospf_refresh_timer
,
2407 ospf_refresh_timer_cmd
,
2408 "refresh timer (10-1800)",
2409 "Adjust refresh parameters\n"
2410 "Set refresh timer\n"
2411 "Timer value in seconds\n")
2413 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2415 unsigned int interval
;
2417 interval
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2418 interval
= (interval
/ OSPF_LSA_REFRESHER_GRANULARITY
)
2419 * OSPF_LSA_REFRESHER_GRANULARITY
;
2421 ospf_timers_refresh_set(ospf
, interval
);
2426 DEFUN (no_ospf_refresh_timer
,
2427 no_ospf_refresh_timer_val_cmd
,
2428 "no refresh timer [(10-1800)]",
2430 "Adjust refresh parameters\n"
2431 "Unset refresh timer\n"
2432 "Timer value in seconds\n")
2434 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2436 unsigned int interval
;
2439 interval
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2441 if (ospf
->lsa_refresh_interval
!= interval
2442 || interval
== OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
2446 ospf_timers_refresh_unset(ospf
);
2452 DEFUN (ospf_auto_cost_reference_bandwidth
,
2453 ospf_auto_cost_reference_bandwidth_cmd
,
2454 "auto-cost reference-bandwidth (1-4294967)",
2455 "Calculate OSPF interface cost according to bandwidth\n"
2456 "Use reference bandwidth method to assign OSPF cost\n"
2457 "The reference bandwidth in terms of Mbits per second\n")
2459 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2462 struct listnode
*node
;
2463 struct interface
*ifp
;
2465 refbw
= strtol(argv
[idx_number
]->arg
, NULL
, 10);
2466 if (refbw
< 1 || refbw
> 4294967) {
2467 vty_out(vty
, "reference-bandwidth value is invalid\n");
2468 return CMD_WARNING_CONFIG_FAILED
;
2471 /* If reference bandwidth is changed. */
2472 if ((refbw
) == ospf
->ref_bandwidth
)
2475 ospf
->ref_bandwidth
= refbw
;
2476 for (ALL_LIST_ELEMENTS_RO(vrf_iflist(ospf
->vrf_id
), node
, ifp
))
2477 ospf_if_recalculate_output_cost(ifp
);
2482 DEFUN (no_ospf_auto_cost_reference_bandwidth
,
2483 no_ospf_auto_cost_reference_bandwidth_cmd
,
2484 "no auto-cost reference-bandwidth [(1-4294967)]",
2486 "Calculate OSPF interface cost according to bandwidth\n"
2487 "Use reference bandwidth method to assign OSPF cost\n"
2488 "The reference bandwidth in terms of Mbits per second\n")
2490 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2491 struct listnode
*node
, *nnode
;
2492 struct interface
*ifp
;
2494 if (ospf
->ref_bandwidth
== OSPF_DEFAULT_REF_BANDWIDTH
)
2497 ospf
->ref_bandwidth
= OSPF_DEFAULT_REF_BANDWIDTH
;
2498 vty_out(vty
, "%% OSPF: Reference bandwidth is changed.\n");
2500 " Please ensure reference bandwidth is consistent across all routers\n");
2502 for (ALL_LIST_ELEMENTS(vrf_iflist(ospf
->vrf_id
), node
, nnode
, ifp
))
2503 ospf_if_recalculate_output_cost(ifp
);
2508 DEFUN (ospf_write_multiplier
,
2509 ospf_write_multiplier_cmd
,
2510 "ospf write-multiplier (1-100)",
2511 "OSPF specific commands\n"
2512 "Write multiplier\n"
2513 "Maximum number of interface serviced per write\n")
2515 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2517 u_int32_t write_oi_count
;
2524 write_oi_count
= strtol(argv
[idx_number
]->arg
, NULL
, 10);
2525 if (write_oi_count
< 1 || write_oi_count
> 100) {
2526 vty_out(vty
, "write-multiplier value is invalid\n");
2527 return CMD_WARNING_CONFIG_FAILED
;
2530 ospf
->write_oi_count
= write_oi_count
;
2534 ALIAS(ospf_write_multiplier
, write_multiplier_cmd
, "write-multiplier (1-100)",
2535 "Write multiplier\n"
2536 "Maximum number of interface serviced per write\n")
2538 DEFUN (no_ospf_write_multiplier
,
2539 no_ospf_write_multiplier_cmd
,
2540 "no ospf write-multiplier (1-100)",
2542 "OSPF specific commands\n"
2543 "Write multiplier\n"
2544 "Maximum number of interface serviced per write\n")
2546 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2548 ospf
->write_oi_count
= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
;
2552 ALIAS(no_ospf_write_multiplier
, no_write_multiplier_cmd
,
2553 "no write-multiplier (1-100)", NO_STR
2554 "Write multiplier\n"
2555 "Maximum number of interface serviced per write\n")
2557 const char *ospf_abr_type_descr_str
[] = {"Unknown", "Standard (RFC2328)",
2558 "Alternative IBM", "Alternative Cisco",
2559 "Alternative Shortcut"};
2561 const char *ospf_shortcut_mode_descr_str
[] = {"Default", "Enabled", "Disabled"};
2563 static void show_ip_ospf_area(struct vty
*vty
, struct ospf_area
*area
,
2564 json_object
*json_areas
, u_char use_json
)
2566 json_object
*json_area
= NULL
;
2569 json_area
= json_object_new_object();
2573 vty_out(vty
, " Area ID: %s", inet_ntoa(area
->area_id
));
2575 /* Show Area type/mode. */
2576 if (OSPF_IS_AREA_BACKBONE(area
)) {
2578 json_object_boolean_true_add(json_area
, "backbone");
2580 vty_out(vty
, " (Backbone)\n");
2583 if (area
->external_routing
== OSPF_AREA_STUB
) {
2584 if (area
->no_summary
)
2585 json_object_boolean_true_add(
2586 json_area
, "stubNoSummary");
2587 if (area
->shortcut_configured
)
2588 json_object_boolean_true_add(
2589 json_area
, "stubShortcut");
2590 } else if (area
->external_routing
== OSPF_AREA_NSSA
) {
2591 if (area
->no_summary
)
2592 json_object_boolean_true_add(
2593 json_area
, "nssaNoSummary");
2594 if (area
->shortcut_configured
)
2595 json_object_boolean_true_add(
2596 json_area
, "nssaShortcut");
2599 json_object_string_add(
2600 json_area
, "shortcuttingMode",
2601 ospf_shortcut_mode_descr_str
2602 [area
->shortcut_configured
]);
2603 if (area
->shortcut_capability
)
2604 json_object_boolean_true_add(json_area
,
2607 if (area
->external_routing
== OSPF_AREA_STUB
)
2608 vty_out(vty
, " (Stub%s%s)",
2609 area
->no_summary
? ", no summary" : "",
2610 area
->shortcut_configured
? "; " : "");
2611 else if (area
->external_routing
== OSPF_AREA_NSSA
)
2612 vty_out(vty
, " (NSSA%s%s)",
2613 area
->no_summary
? ", no summary" : "",
2614 area
->shortcut_configured
? "; " : "");
2617 vty_out(vty
, " Shortcutting mode: %s",
2618 ospf_shortcut_mode_descr_str
2619 [area
->shortcut_configured
]);
2620 vty_out(vty
, ", S-bit consensus: %s\n",
2621 area
->shortcut_capability
? "ok" : "no");
2625 /* Show number of interfaces */
2627 json_object_int_add(json_area
, "areaIfTotalCounter",
2628 listcount(area
->oiflist
));
2629 json_object_int_add(json_area
, "areaIfActiveCounter",
2633 " Number of interfaces in this area: Total: %d, "
2635 listcount(area
->oiflist
), area
->act_ints
);
2637 if (area
->external_routing
== OSPF_AREA_NSSA
) {
2639 json_object_boolean_true_add(json_area
, "nssa");
2640 if (!IS_OSPF_ABR(area
->ospf
))
2641 json_object_boolean_false_add(json_area
, "abr");
2642 else if (area
->NSSATranslatorState
) {
2643 json_object_boolean_true_add(json_area
, "abr");
2644 if (area
->NSSATranslatorRole
2645 == OSPF_NSSA_ROLE_CANDIDATE
)
2646 json_object_boolean_true_add(
2648 "nssaTranslatorElected");
2649 else if (area
->NSSATranslatorRole
2650 == OSPF_NSSA_ROLE_ALWAYS
)
2651 json_object_boolean_true_add(
2653 "nssaTranslatorAlways");
2655 json_object_boolean_true_add(json_area
, "abr");
2656 if (area
->NSSATranslatorRole
2657 == OSPF_NSSA_ROLE_CANDIDATE
)
2658 json_object_boolean_false_add(
2660 "nssaTranslatorElected");
2662 json_object_boolean_true_add(
2664 "nssaTranslatorNever");
2668 " It is an NSSA configuration. \n Elected NSSA/ABR performs type-7/type-5 LSA translation. \n");
2669 if (!IS_OSPF_ABR(area
->ospf
))
2671 " It is not ABR, therefore not Translator. \n");
2672 else if (area
->NSSATranslatorState
) {
2673 vty_out(vty
, " We are an ABR and ");
2674 if (area
->NSSATranslatorRole
2675 == OSPF_NSSA_ROLE_CANDIDATE
)
2677 "the NSSA Elected Translator. \n");
2678 else if (area
->NSSATranslatorRole
2679 == OSPF_NSSA_ROLE_ALWAYS
)
2681 "always an NSSA Translator. \n");
2683 vty_out(vty
, " We are an ABR, but ");
2684 if (area
->NSSATranslatorRole
2685 == OSPF_NSSA_ROLE_CANDIDATE
)
2687 "not the NSSA Elected Translator. \n");
2690 "never an NSSA Translator. \n");
2695 /* Stub-router state for this area */
2696 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
)) {
2697 char timebuf
[OSPF_TIME_DUMP_SIZE
];
2700 json_object_boolean_true_add(
2701 json_area
, "originStubMaxDistRouterLsa");
2702 if (CHECK_FLAG(area
->stub_router_state
,
2703 OSPF_AREA_ADMIN_STUB_ROUTED
))
2704 json_object_boolean_true_add(
2705 json_area
, "indefiniteActiveAdmin");
2706 if (area
->t_stub_router
) {
2710 &area
->t_stub_router
->u
.sands
,
2713 json_object_int_add(
2715 "activeStartupRemainderMsecs",
2720 " Originating stub / maximum-distance Router-LSA\n");
2721 if (CHECK_FLAG(area
->stub_router_state
,
2722 OSPF_AREA_ADMIN_STUB_ROUTED
))
2724 " Administratively activated (indefinitely)\n");
2725 if (area
->t_stub_router
)
2727 " Active from startup, %s remaining\n",
2728 ospf_timer_dump(area
->t_stub_router
,
2735 /* Show number of fully adjacent neighbors. */
2736 json_object_int_add(json_area
, "nbrFullAdjacentCounter",
2739 /* Show authentication type. */
2740 if (area
->auth_type
== OSPF_AUTH_NULL
)
2741 json_object_string_add(json_area
, "authentication",
2742 "authenticationNone");
2743 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
2744 json_object_string_add(json_area
, "authentication",
2745 "authenticationSimplePassword");
2746 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
2747 json_object_string_add(json_area
, "authentication",
2748 "authenticationMessageDigest");
2750 if (!OSPF_IS_AREA_BACKBONE(area
))
2751 json_object_int_add(json_area
,
2752 "virtualAdjacenciesPassingCounter",
2755 /* Show SPF calculation times. */
2756 json_object_int_add(json_area
, "spfExecutedCounter",
2757 area
->spf_calculation
);
2758 json_object_int_add(json_area
, "lsaNumber", area
->lsdb
->total
);
2759 json_object_int_add(
2760 json_area
, "lsaRouterNumber",
2761 ospf_lsdb_count(area
->lsdb
, OSPF_ROUTER_LSA
));
2762 json_object_int_add(
2763 json_area
, "lsaRouterChecksum",
2764 ospf_lsdb_checksum(area
->lsdb
, OSPF_ROUTER_LSA
));
2765 json_object_int_add(
2766 json_area
, "lsaNetworkNumber",
2767 ospf_lsdb_count(area
->lsdb
, OSPF_NETWORK_LSA
));
2768 json_object_int_add(
2769 json_area
, "lsaNetworkChecksum",
2770 ospf_lsdb_checksum(area
->lsdb
, OSPF_NETWORK_LSA
));
2771 json_object_int_add(
2772 json_area
, "lsaSummaryNumber",
2773 ospf_lsdb_count(area
->lsdb
, OSPF_SUMMARY_LSA
));
2774 json_object_int_add(
2775 json_area
, "lsaSummaryChecksum",
2776 ospf_lsdb_checksum(area
->lsdb
, OSPF_SUMMARY_LSA
));
2777 json_object_int_add(
2778 json_area
, "lsaAsbrNumber",
2779 ospf_lsdb_count(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2780 json_object_int_add(
2781 json_area
, "lsaAsbrChecksum",
2782 ospf_lsdb_checksum(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2783 json_object_int_add(
2784 json_area
, "lsaNssaNumber",
2785 ospf_lsdb_count(area
->lsdb
, OSPF_AS_NSSA_LSA
));
2786 json_object_int_add(
2787 json_area
, "lsaNssaChecksum",
2788 ospf_lsdb_checksum(area
->lsdb
, OSPF_AS_NSSA_LSA
));
2790 /* Show number of fully adjacent neighbors. */
2792 " Number of fully adjacent neighbors in this area:"
2796 /* Show authentication type. */
2797 vty_out(vty
, " Area has ");
2798 if (area
->auth_type
== OSPF_AUTH_NULL
)
2799 vty_out(vty
, "no authentication\n");
2800 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
2801 vty_out(vty
, "simple password authentication\n");
2802 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
2803 vty_out(vty
, "message digest authentication\n");
2805 if (!OSPF_IS_AREA_BACKBONE(area
))
2807 " Number of full virtual adjacencies going through"
2811 /* Show SPF calculation times. */
2812 vty_out(vty
, " SPF algorithm executed %d times\n",
2813 area
->spf_calculation
);
2815 /* Show number of LSA. */
2816 vty_out(vty
, " Number of LSA %ld\n", area
->lsdb
->total
);
2818 " Number of router LSA %ld. Checksum Sum 0x%08x\n",
2819 ospf_lsdb_count(area
->lsdb
, OSPF_ROUTER_LSA
),
2820 ospf_lsdb_checksum(area
->lsdb
, OSPF_ROUTER_LSA
));
2822 " Number of network LSA %ld. Checksum Sum 0x%08x\n",
2823 ospf_lsdb_count(area
->lsdb
, OSPF_NETWORK_LSA
),
2824 ospf_lsdb_checksum(area
->lsdb
, OSPF_NETWORK_LSA
));
2826 " Number of summary LSA %ld. Checksum Sum 0x%08x\n",
2827 ospf_lsdb_count(area
->lsdb
, OSPF_SUMMARY_LSA
),
2828 ospf_lsdb_checksum(area
->lsdb
, OSPF_SUMMARY_LSA
));
2830 " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x\n",
2831 ospf_lsdb_count(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
),
2832 ospf_lsdb_checksum(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2833 vty_out(vty
, " Number of NSSA LSA %ld. Checksum Sum 0x%08x\n",
2834 ospf_lsdb_count(area
->lsdb
, OSPF_AS_NSSA_LSA
),
2835 ospf_lsdb_checksum(area
->lsdb
, OSPF_AS_NSSA_LSA
));
2839 json_object_int_add(
2840 json_area
, "lsaOpaqueLinkNumber",
2841 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
2842 json_object_int_add(
2843 json_area
, "lsaOpaqueLinkChecksum",
2844 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
2845 json_object_int_add(
2846 json_area
, "lsaOpaqueAreaNumber",
2847 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
2848 json_object_int_add(
2849 json_area
, "lsaOpaqueAreaChecksum",
2850 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
2853 " Number of opaque link LSA %ld. Checksum Sum 0x%08x\n",
2854 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
),
2855 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
2857 " Number of opaque area LSA %ld. Checksum Sum 0x%08x\n",
2858 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
),
2859 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
2863 json_object_object_add(json_areas
, inet_ntoa(area
->area_id
),
2869 static int show_ip_ospf_common(struct vty
*vty
, struct ospf
*ospf
,
2872 struct listnode
*node
, *nnode
;
2873 struct ospf_area
*area
;
2874 struct timeval result
;
2875 char timebuf
[OSPF_TIME_DUMP_SIZE
];
2876 json_object
*json
= NULL
;
2877 json_object
*json_areas
= NULL
;
2880 json
= json_object_new_object();
2881 json_areas
= json_object_new_object();
2884 if (ospf
->instance
) {
2886 json_object_int_add(json
, "ospfInstance",
2889 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
2893 /* Show Router ID. */
2895 json_object_string_add(json
, "routerId",
2896 inet_ntoa(ospf
->router_id
));
2898 vty_out(vty
, " OSPF Routing Process, Router ID: %s\n",
2899 inet_ntoa(ospf
->router_id
));
2902 /* Graceful shutdown */
2903 if (ospf
->t_deferred_shutdown
) {
2908 &ospf
->t_deferred_shutdown
->u
.sands
,
2911 json_object_int_add(json
, "deferredShutdownMsecs",
2915 " Deferred shutdown in progress, %s remaining\n",
2916 ospf_timer_dump(ospf
->t_deferred_shutdown
,
2917 timebuf
, sizeof(timebuf
)));
2921 /* Show capability. */
2923 json_object_boolean_true_add(json
, "tosRoutesOnly");
2924 json_object_boolean_true_add(json
, "rfc2328Conform");
2925 if (CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)) {
2926 json_object_boolean_true_add(json
,
2927 "rfc1583Compatibility");
2930 vty_out(vty
, " Supports only single TOS (TOS0) routes\n");
2931 vty_out(vty
, " This implementation conforms to RFC2328\n");
2932 vty_out(vty
, " RFC1583Compatibility flag is %s\n",
2933 CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)
2939 if (CHECK_FLAG(ospf
->config
, OSPF_OPAQUE_CAPABLE
)) {
2940 json_object_boolean_true_add(json
, "opaqueCapable");
2943 vty_out(vty
, " OpaqueCapability flag is %s\n",
2944 CHECK_FLAG(ospf
->config
, OSPF_OPAQUE_CAPABLE
)
2949 /* Show stub-router configuration */
2950 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
2951 || ospf
->stub_router_shutdown_time
2952 != OSPF_STUB_ROUTER_UNCONFIGURED
) {
2954 json_object_boolean_true_add(json
, "stubAdvertisement");
2955 if (ospf
->stub_router_startup_time
2956 != OSPF_STUB_ROUTER_UNCONFIGURED
)
2957 json_object_int_add(
2958 json
, "postStartEnabledMsecs",
2959 ospf
->stub_router_startup_time
/ 1000);
2960 if (ospf
->stub_router_shutdown_time
2961 != OSPF_STUB_ROUTER_UNCONFIGURED
)
2962 json_object_int_add(
2963 json
, "preShutdownEnabledMsecs",
2964 ospf
->stub_router_shutdown_time
/ 1000);
2967 " Stub router advertisement is configured\n");
2968 if (ospf
->stub_router_startup_time
2969 != OSPF_STUB_ROUTER_UNCONFIGURED
)
2971 " Enabled for %us after start-up\n",
2972 ospf
->stub_router_startup_time
);
2973 if (ospf
->stub_router_shutdown_time
2974 != OSPF_STUB_ROUTER_UNCONFIGURED
)
2976 " Enabled for %us prior to full shutdown\n",
2977 ospf
->stub_router_shutdown_time
);
2981 /* Show SPF timers. */
2983 json_object_int_add(json
, "spfScheduleDelayMsecs",
2985 json_object_int_add(json
, "holdtimeMinMsecs",
2986 ospf
->spf_holdtime
);
2987 json_object_int_add(json
, "holdtimeMaxMsecs",
2988 ospf
->spf_max_holdtime
);
2989 json_object_int_add(json
, "holdtimeMultplier",
2990 ospf
->spf_hold_multiplier
);
2993 " Initial SPF scheduling delay %d millisec(s)\n"
2994 " Minimum hold time between consecutive SPFs %d millisec(s)\n"
2995 " Maximum hold time between consecutive SPFs %d millisec(s)\n"
2996 " Hold time multiplier is currently %d\n",
2997 ospf
->spf_delay
, ospf
->spf_holdtime
,
2998 ospf
->spf_max_holdtime
, ospf
->spf_hold_multiplier
);
3002 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
) {
3003 long time_store
= 0;
3006 monotime_since(&ospf
->ts_spf
, NULL
) / 1000LL;
3007 json_object_int_add(json
, "spfLastExecutedMsecs",
3010 time_store
= (1000 * ospf
->ts_spf_duration
.tv_sec
)
3011 + (ospf
->ts_spf_duration
.tv_usec
/ 1000);
3012 json_object_int_add(json
, "spfLastDurationMsecs",
3015 json_object_boolean_true_add(json
, "spfHasNotRun");
3017 vty_out(vty
, " SPF algorithm ");
3018 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
) {
3019 monotime_since(&ospf
->ts_spf
, &result
);
3020 vty_out(vty
, "last executed %s ago\n",
3021 ospf_timeval_dump(&result
, timebuf
,
3023 vty_out(vty
, " Last SPF duration %s\n",
3024 ospf_timeval_dump(&ospf
->ts_spf_duration
,
3025 timebuf
, sizeof(timebuf
)));
3027 vty_out(vty
, "has not been run\n");
3031 if (ospf
->t_spf_calc
) {
3034 monotime_until(&ospf
->t_spf_calc
->u
.sands
, NULL
)
3036 json_object_int_add(json
, "spfTimerDueInMsecs",
3040 json_object_int_add(json
, "lsaMinIntervalMsecs",
3041 ospf
->min_ls_interval
);
3042 json_object_int_add(json
, "lsaMinArrivalMsecs",
3043 ospf
->min_ls_arrival
);
3044 /* Show write multiplier values */
3045 json_object_int_add(json
, "writeMultiplier",
3046 ospf
->write_oi_count
);
3047 /* Show refresh parameters. */
3048 json_object_int_add(json
, "refreshTimerMsecs",
3049 ospf
->lsa_refresh_interval
* 1000);
3051 vty_out(vty
, " SPF timer %s%s\n",
3052 (ospf
->t_spf_calc
? "due in " : "is "),
3053 ospf_timer_dump(ospf
->t_spf_calc
, timebuf
,
3056 vty_out(vty
, " LSA minimum interval %d msecs\n",
3057 ospf
->min_ls_interval
);
3058 vty_out(vty
, " LSA minimum arrival %d msecs\n",
3059 ospf
->min_ls_arrival
);
3061 /* Show write multiplier values */
3062 vty_out(vty
, " Write Multiplier set to %d \n",
3063 ospf
->write_oi_count
);
3065 /* Show refresh parameters. */
3066 vty_out(vty
, " Refresh timer %d secs\n",
3067 ospf
->lsa_refresh_interval
);
3070 /* Show ABR/ASBR flags. */
3071 if (CHECK_FLAG(ospf
->flags
, OSPF_FLAG_ABR
)) {
3073 json_object_string_add(
3075 ospf_abr_type_descr_str
[ospf
->abr_type
]);
3078 " This router is an ABR, ABR type is: %s\n",
3079 ospf_abr_type_descr_str
[ospf
->abr_type
]);
3081 if (CHECK_FLAG(ospf
->flags
, OSPF_FLAG_ASBR
)) {
3083 json_object_string_add(
3085 "injectingExternalRoutingInformation");
3088 " This router is an ASBR "
3089 "(injecting external routing information)\n");
3092 /* Show Number of AS-external-LSAs. */
3094 json_object_int_add(
3095 json
, "lsaExternalCounter",
3096 ospf_lsdb_count(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3097 json_object_int_add(
3098 json
, "lsaExternalChecksum",
3099 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3102 " Number of external LSA %ld. Checksum Sum 0x%08x\n",
3103 ospf_lsdb_count(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
),
3104 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3108 json_object_int_add(
3109 json
, "lsaAsopaqueCounter",
3110 ospf_lsdb_count(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3111 json_object_int_add(
3112 json
, "lsaAsOpaqueChecksum",
3113 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3116 " Number of opaque AS LSA %ld. Checksum Sum 0x%08x\n",
3117 ospf_lsdb_count(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
),
3118 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3121 /* Show number of areas attached. */
3123 json_object_int_add(json
, "attachedAreaCounter",
3124 listcount(ospf
->areas
));
3126 vty_out(vty
, " Number of areas attached to this router: %d\n",
3127 listcount(ospf
->areas
));
3129 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
)) {
3130 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
)) {
3132 json_object_boolean_true_add(
3133 json
, "adjacencyChangesLoggedAll");
3136 " All adjacency changes are logged\n");
3139 json_object_boolean_true_add(
3140 json
, "adjacencyChangesLogged");
3142 vty_out(vty
, " Adjacency changes are logged\n");
3145 /* Show each area status. */
3146 for (ALL_LIST_ELEMENTS(ospf
->areas
, node
, nnode
, area
))
3147 show_ip_ospf_area(vty
, area
, json_areas
, use_json
);
3150 json_object_object_add(json
, "areas", json_areas
);
3151 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
3152 json
, JSON_C_TO_STRING_PRETTY
));
3153 json_object_free(json
);
3160 DEFUN (show_ip_ospf
,
3162 "show ip ospf [vrf <NAME|all>] [json]",
3165 "OSPF information\n"
3171 u_char uj
= use_json(argc
, argv
);
3172 struct listnode
*node
= NULL
;
3173 char *vrf_name
= NULL
;
3174 bool all_vrf
= FALSE
;
3175 int ret
= CMD_SUCCESS
;
3179 if (listcount(om
->ospf
) == 0)
3182 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
3184 /* vrf input is provided could be all or specific vrf*/
3187 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
3188 if (!ospf
->oi_running
)
3190 ret
= show_ip_ospf_common(vty
, ospf
, uj
);
3194 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
3195 if ((ospf
== NULL
) || !ospf
->oi_running
)
3198 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
3199 /* Display default ospf (instance 0) info */
3200 if (ospf
== NULL
|| !ospf
->oi_running
)
3205 show_ip_ospf_common(vty
, ospf
, uj
);
3210 DEFUN (show_ip_ospf_instance
,
3211 show_ip_ospf_instance_cmd
,
3212 "show ip ospf (1-65535) [json]",
3215 "OSPF information\n"
3221 u_short instance
= 0;
3222 u_char uj
= use_json(argc
, argv
);
3224 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3225 ospf
= ospf_lookup_instance(instance
);
3227 return CMD_NOT_MY_INSTANCE
;
3229 if (!ospf
->oi_running
)
3232 return (show_ip_ospf_common(vty
, ospf
, uj
));
3235 static void show_ip_ospf_interface_sub(struct vty
*vty
, struct ospf
*ospf
,
3236 struct interface
*ifp
,
3237 json_object
*json_interface_sub
,
3241 struct ospf_neighbor
*nbr
;
3242 struct route_node
*rn
;
3243 uint32_t bandwidth
= ifp
->bandwidth
? ifp
->bandwidth
: ifp
->speed
;
3245 /* Is interface up? */
3247 is_up
= if_is_operative(ifp
);
3249 json_object_boolean_true_add(json_interface_sub
,
3252 json_object_boolean_false_add(json_interface_sub
,
3255 json_object_int_add(json_interface_sub
, "ifIndex",
3257 json_object_int_add(json_interface_sub
, "mtuBytes", ifp
->mtu
);
3258 json_object_int_add(json_interface_sub
, "bandwidthMbit",
3260 json_object_string_add(json_interface_sub
, "ifFlags",
3261 if_flag_dump(ifp
->flags
));
3263 vty_out(vty
, "%s is %s\n", ifp
->name
,
3264 ((is_up
= if_is_operative(ifp
)) ? "up" : "down"));
3265 vty_out(vty
, " ifindex %u, MTU %u bytes, BW %u Mbit %s\n",
3266 ifp
->ifindex
, ifp
->mtu
, bandwidth
,
3267 if_flag_dump(ifp
->flags
));
3270 /* Is interface OSPF enabled? */
3272 if (ospf_oi_count(ifp
) == 0) {
3273 json_object_boolean_false_add(json_interface_sub
,
3276 } else if (!is_up
) {
3277 json_object_boolean_false_add(json_interface_sub
,
3281 json_object_boolean_true_add(json_interface_sub
,
3284 if (ospf_oi_count(ifp
) == 0) {
3285 vty_out(vty
, " OSPF not enabled on this interface\n");
3287 } else if (!is_up
) {
3289 " OSPF is enabled, but not running on this interface\n");
3294 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
3295 struct ospf_interface
*oi
= rn
->info
;
3300 if (CHECK_FLAG(oi
->connected
->flags
, ZEBRA_IFA_UNNUMBERED
)) {
3302 json_object_boolean_true_add(json_interface_sub
,
3305 vty_out(vty
, " This interface is UNNUMBERED,");
3307 /* Show OSPF interface information. */
3309 json_object_string_add(
3310 json_interface_sub
, "ipAddress",
3311 inet_ntoa(oi
->address
->u
.prefix4
));
3312 json_object_int_add(json_interface_sub
,
3313 "ipAddressPrefixlen",
3314 oi
->address
->prefixlen
);
3316 vty_out(vty
, " Internet Address %s/%d,",
3317 inet_ntoa(oi
->address
->u
.prefix4
),
3318 oi
->address
->prefixlen
);
3320 if (oi
->connected
->destination
3321 || oi
->type
== OSPF_IFTYPE_VIRTUALLINK
) {
3322 struct in_addr
*dest
;
3325 if (CONNECTED_PEER(oi
->connected
)
3326 || oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3331 /* For Vlinks, showing the peer address is
3333 * * * * * informative than the local
3334 * interface that is being used
3336 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3337 dest
= &oi
->vl_data
->peer_addr
;
3339 dest
= &oi
->connected
->destination
->u
3343 json_object_string_add(
3345 "ospfIfType", dstr
);
3346 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3347 json_object_string_add(
3352 json_object_string_add(
3357 vty_out(vty
, " %s %s,", dstr
,
3362 json_object_string_add(json_interface_sub
, "area",
3363 ospf_area_desc_string(oi
->area
));
3364 if (OSPF_IF_PARAM(oi
, mtu_ignore
))
3365 json_object_boolean_true_add(
3367 "mtuMismatchDetect");
3368 json_object_string_add(json_interface_sub
, "routerId",
3369 inet_ntoa(ospf
->router_id
));
3370 json_object_string_add(json_interface_sub
,
3372 ospf_network_type_str
[oi
->type
]);
3373 json_object_int_add(json_interface_sub
, "cost",
3375 json_object_int_add(
3376 json_interface_sub
, "transmitDelayMsecs",
3377 1000 / OSPF_IF_PARAM(oi
, transmit_delay
));
3378 json_object_string_add(json_interface_sub
, "state",
3379 lookup_msg(ospf_ism_state_msg
,
3381 json_object_int_add(json_interface_sub
, "priority",
3384 vty_out(vty
, " Area %s\n",
3385 ospf_area_desc_string(oi
->area
));
3387 vty_out(vty
, " MTU mismatch detection: %s\n",
3388 OSPF_IF_PARAM(oi
, mtu_ignore
) ? "disabled"
3392 " Router ID %s, Network Type %s, Cost: %d\n",
3393 inet_ntoa(ospf
->router_id
),
3394 ospf_network_type_str
[oi
->type
],
3398 " Transmit Delay is %d sec, State %s, Priority %d\n",
3399 OSPF_IF_PARAM(oi
, transmit_delay
),
3400 lookup_msg(ospf_ism_state_msg
, oi
->state
, NULL
),
3404 /* Show DR information. */
3405 if (DR(oi
).s_addr
== 0) {
3408 " No backup designated router on this network\n");
3410 nbr
= ospf_nbr_lookup_by_addr(oi
->nbrs
, &BDR(oi
));
3414 " No backup designated router on this network\n");
3417 json_object_string_add(
3418 json_interface_sub
, "bdrId",
3419 inet_ntoa(nbr
->router_id
));
3420 json_object_string_add(
3423 inet_ntoa(nbr
->address
.u
3427 " Backup Designated Router (ID) %s,",
3428 inet_ntoa(nbr
->router_id
));
3429 vty_out(vty
, " Interface Address %s\n",
3430 inet_ntoa(nbr
->address
.u
3436 /* Next network-LSA sequence number we'll use, if we're elected
3439 && ntohl(oi
->params
->network_lsa_seqnum
)
3440 != OSPF_INITIAL_SEQUENCE_NUMBER
) {
3442 json_object_int_add(
3444 "networkLsaSequence",
3445 ntohl(oi
->params
->network_lsa_seqnum
));
3448 " Saved Network-LSA sequence number 0x%x\n",
3449 ntohl(oi
->params
->network_lsa_seqnum
));
3453 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3454 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
)) {
3455 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3456 json_object_boolean_true_add(
3458 "mcastMemberOspfAllRouters");
3459 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3460 json_object_boolean_true_add(
3462 "mcastMemberOspfDesignatedRouters");
3465 vty_out(vty
, " Multicast group memberships:");
3466 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3467 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
)) {
3468 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3469 vty_out(vty
, " OSPFAllRouters");
3470 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3471 vty_out(vty
, " OSPFDesignatedRouters");
3473 vty_out(vty
, " <None>");
3478 if (OSPF_IF_PARAM(oi
, fast_hello
) == 0)
3479 json_object_int_add(
3480 json_interface_sub
, "timerMsecs",
3481 1000 / OSPF_IF_PARAM(oi
, v_hello
));
3483 json_object_int_add(
3484 json_interface_sub
, "timerMsecs",
3485 1000 / OSPF_IF_PARAM(oi
, fast_hello
));
3486 json_object_int_add(json_interface_sub
,
3488 1000 / OSPF_IF_PARAM(oi
, v_wait
));
3489 json_object_int_add(json_interface_sub
,
3491 1000 / OSPF_IF_PARAM(oi
, v_wait
));
3492 json_object_int_add(
3493 json_interface_sub
, "timerRetransmit",
3494 1000 / OSPF_IF_PARAM(oi
, retransmit_interval
));
3496 vty_out(vty
, " Timer intervals configured,");
3497 vty_out(vty
, " Hello ");
3498 if (OSPF_IF_PARAM(oi
, fast_hello
) == 0)
3499 vty_out(vty
, "%ds,",
3500 OSPF_IF_PARAM(oi
, v_hello
));
3502 vty_out(vty
, "%dms,",
3503 1000 / OSPF_IF_PARAM(oi
, fast_hello
));
3504 vty_out(vty
, " Dead %ds, Wait %ds, Retransmit %d\n",
3505 OSPF_IF_PARAM(oi
, v_wait
),
3506 OSPF_IF_PARAM(oi
, v_wait
),
3507 OSPF_IF_PARAM(oi
, retransmit_interval
));
3510 if (OSPF_IF_PASSIVE_STATUS(oi
) == OSPF_IF_ACTIVE
) {
3511 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3513 long time_store
= 0;
3517 &oi
->t_hello
->u
.sands
,
3520 json_object_int_add(json_interface_sub
,
3521 "timerHelloInMsecs",
3524 vty_out(vty
, " Hello due in %s\n",
3525 ospf_timer_dump(oi
->t_hello
, timebuf
,
3527 } else /* passive-interface is set */
3530 json_object_boolean_true_add(
3532 "timerPassiveIface");
3535 " No Hellos (Passive interface)\n");
3539 json_object_int_add(json_interface_sub
, "nbrCount",
3540 ospf_nbr_count(oi
, 0));
3541 json_object_int_add(json_interface_sub
,
3543 ospf_nbr_count(oi
, NSM_Full
));
3546 " Neighbor Count is %d, Adjacent neighbor count is %d\n",
3547 ospf_nbr_count(oi
, 0),
3548 ospf_nbr_count(oi
, NSM_Full
));
3549 ospf_bfd_interface_show(vty
, ifp
, json_interface_sub
, use_json
);
3553 static int show_ip_ospf_interface_common(struct vty
*vty
, struct ospf
*ospf
,
3554 int argc
, struct cmd_token
**argv
,
3555 int iface_argv
, u_char use_json
)
3557 struct interface
*ifp
;
3558 struct listnode
*node
;
3559 json_object
*json
= NULL
;
3560 json_object
*json_interface_sub
= NULL
;
3563 json
= json_object_new_object();
3566 if (ospf
->instance
) {
3568 json_object_int_add(json
, "ospfInstance",
3571 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
3574 if (argc
== iface_argv
) {
3575 /* Show All Interfaces.*/
3576 for (ALL_LIST_ELEMENTS_RO(vrf_iflist(ospf
->vrf_id
),
3578 if (ospf_oi_count(ifp
)) {
3580 json_interface_sub
=
3581 json_object_new_object();
3583 show_ip_ospf_interface_sub(vty
, ospf
, ifp
,
3588 json_object_object_add(
3590 json_interface_sub
);
3594 /* Interface name is specified. */
3595 if ((ifp
= if_lookup_by_name(argv
[iface_argv
]->arg
,
3599 json_object_boolean_true_add(json
,
3602 vty_out(vty
, "No such interface name\n");
3605 json_interface_sub
= json_object_new_object();
3607 show_ip_ospf_interface_sub(
3608 vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3611 json_object_object_add(json
, ifp
->name
,
3612 json_interface_sub
);
3617 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
3618 json
, JSON_C_TO_STRING_PRETTY
));
3619 json_object_free(json
);
3626 DEFUN (show_ip_ospf_interface
,
3627 show_ip_ospf_interface_cmd
,
3628 "show ip ospf [vrf <NAME|all>] interface [INTERFACE] [json]",
3631 "OSPF information\n"
3634 "Interface information\n"
3639 u_char uj
= use_json(argc
, argv
);
3640 struct listnode
*node
= NULL
;
3641 char *vrf_name
= NULL
;
3642 bool all_vrf
= FALSE
;
3643 int ret
= CMD_SUCCESS
;
3647 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
3652 /* vrf input is provided could be all or specific vrf*/
3655 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
3656 if (!ospf
->oi_running
)
3658 ret
= show_ip_ospf_interface_common(vty
,
3665 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
3666 if (ospf
== NULL
|| !ospf
->oi_running
)
3668 ret
= show_ip_ospf_interface_common(vty
, ospf
,
3672 /* Display default ospf (instance 0) info */
3673 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
3674 if (ospf
== NULL
|| !ospf
->oi_running
)
3676 ret
= show_ip_ospf_interface_common(vty
, ospf
,
3683 DEFUN (show_ip_ospf_instance_interface
,
3684 show_ip_ospf_instance_interface_cmd
,
3685 "show ip ospf (1-65535) interface [INTERFACE] [json]",
3688 "OSPF information\n"
3690 "Interface information\n"
3696 u_short instance
= 0;
3697 u_char uj
= use_json(argc
, argv
);
3699 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3700 ospf
= ospf_lookup_instance(instance
);
3702 return CMD_NOT_MY_INSTANCE
;
3704 if (!ospf
->oi_running
)
3710 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 5, uj
);
3713 static void show_ip_ospf_neighbour_header(struct vty
*vty
)
3715 vty_out(vty
, "\n%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s\n",
3716 "Neighbor ID", "Pri", "State", "Dead Time", "Address",
3717 "Interface", "RXmtL", "RqstL", "DBsmL");
3720 static void show_ip_ospf_neighbor_sub(struct vty
*vty
,
3721 struct ospf_interface
*oi
,
3722 json_object
*json
, u_char use_json
)
3724 struct route_node
*rn
;
3725 struct ospf_neighbor
*nbr
;
3727 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3728 json_object
*json_neighbor
= NULL
;
3730 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
)) {
3731 if ((nbr
= rn
->info
)) {
3732 /* Do not show myself. */
3733 if (nbr
!= oi
->nbr_self
) {
3734 /* Down state is not shown. */
3735 if (nbr
->state
!= NSM_Down
) {
3738 json_object_new_object();
3739 ospf_nbr_state_message(
3752 json_object_int_add(
3756 json_object_string_add(
3757 json_neighbor
, "state",
3759 json_object_int_add(
3763 json_object_string_add(
3766 inet_ntoa(nbr
->src
));
3767 json_object_string_add(
3771 json_object_int_add(
3773 "retransmitCounter",
3774 ospf_ls_retransmit_count(
3776 json_object_int_add(
3779 ospf_ls_request_count(
3781 json_object_int_add(
3784 ospf_db_summary_count(
3786 if (nbr
->state
== NSM_Attempt
3787 && nbr
->router_id
.s_addr
3789 json_object_object_add(
3794 json_object_object_add(
3800 ospf_nbr_state_message(
3803 if (nbr
->state
== NSM_Attempt
3804 && nbr
->router_id
.s_addr
3819 vty_out(vty
, "%9s ",
3824 vty_out(vty
, "%-15s ",
3825 inet_ntoa(nbr
->src
));
3827 "%-20s %5ld %5ld %5d\n",
3829 ospf_ls_retransmit_count(
3831 ospf_ls_request_count(
3833 ospf_db_summary_count(
3842 static int show_ip_ospf_neighbor_common(struct vty
*vty
, struct ospf
*ospf
,
3845 struct ospf_interface
*oi
;
3846 struct listnode
*node
;
3847 json_object
*json
= NULL
;
3850 json
= json_object_new_object();
3852 if (ospf
->instance
) {
3854 json_object_int_add(json
, "ospfInstance",
3857 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
3860 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
))
3861 show_ip_ospf_neighbor_sub(vty
, oi
, json
, use_json
);
3864 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
3865 json
, JSON_C_TO_STRING_PRETTY
));
3866 json_object_free(json
);
3873 DEFUN (show_ip_ospf_neighbor
,
3874 show_ip_ospf_neighbor_cmd
,
3875 "show ip ospf [vrf <NAME|all>] neighbor [json]",
3878 "OSPF information\n"
3885 u_char uj
= use_json(argc
, argv
);
3886 struct listnode
*node
= NULL
;
3887 char *vrf_name
= NULL
;
3888 bool all_vrf
= FALSE
;
3889 int ret
= CMD_SUCCESS
;
3893 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
3896 show_ip_ospf_neighbour_header(vty
);
3898 /* vrf input is provided could be all or specific vrf*/
3901 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
3902 if (!ospf
->oi_running
)
3904 ret
= show_ip_ospf_neighbor_common(vty
, ospf
,
3909 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
3910 if (ospf
== NULL
|| !ospf
->oi_running
)
3913 /* Display default ospf (instance 0) info */
3914 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
3915 if (ospf
== NULL
|| !ospf
->oi_running
)
3920 ret
= show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
3926 DEFUN (show_ip_ospf_instance_neighbor
,
3927 show_ip_ospf_instance_neighbor_cmd
,
3928 "show ip ospf (1-65535) neighbor [json]",
3931 "OSPF information\n"
3938 u_short instance
= 0;
3939 u_char uj
= use_json(argc
, argv
);
3941 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3942 ospf
= ospf_lookup_instance(instance
);
3944 return CMD_NOT_MY_INSTANCE
;
3946 if (!ospf
->oi_running
)
3950 show_ip_ospf_neighbour_header(vty
);
3952 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
3955 static int show_ip_ospf_neighbor_all_common(struct vty
*vty
, struct ospf
*ospf
,
3958 struct listnode
*node
;
3959 struct ospf_interface
*oi
;
3960 json_object
*json
= NULL
;
3961 json_object
*json_neighbor_sub
= NULL
;
3964 json
= json_object_new_object();
3965 json_neighbor_sub
= json_object_new_object();
3968 if (ospf
->instance
) {
3970 json_object_int_add(json
, "ospfInstance",
3973 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
3978 json_object_int_add(json
, "vrfId",
3979 (ospf
->vrf_id
== VRF_UNKNOWN
)
3980 ? -1 : ospf
->vrf_id
);
3981 json_object_string_add(json
, "vrfName",
3982 (ospf
->vrf_id
== VRF_DEFAULT
)
3983 ? "Default" : ospf
->name
);
3985 vty_out(vty
, "\nOSPF vrf: %s\n\n",
3986 ospf
->vrf_id
== VRF_DEFAULT
3987 ? "Default" : ospf
->name
);
3992 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
3993 struct listnode
*nbr_node
;
3994 struct ospf_nbr_nbma
*nbr_nbma
;
3996 show_ip_ospf_neighbor_sub(vty
, oi
, json
, use_json
);
3998 /* print Down neighbor status */
3999 for (ALL_LIST_ELEMENTS_RO(oi
->nbr_nbma
, nbr_node
, nbr_nbma
)) {
4000 if (nbr_nbma
->nbr
== NULL
4001 || nbr_nbma
->nbr
->state
== NSM_Down
) {
4003 json_object_int_add(json_neighbor_sub
,
4005 nbr_nbma
->priority
);
4006 json_object_boolean_true_add(
4009 json_object_string_add(
4013 json_object_int_add(
4015 "nbrNbmaRetransmitCounter", 0);
4016 json_object_int_add(
4018 "nbrNbmaRequestCounter", 0);
4019 json_object_int_add(
4021 "nbrNbmaDbSummaryCounter", 0);
4022 json_object_object_add(
4023 json
, inet_ntoa(nbr_nbma
->addr
),
4026 vty_out(vty
, "%-15s %3d %-15s %9s ",
4027 "-", nbr_nbma
->priority
, "Down",
4030 "%-15s %-20s %5d %5d %5d\n",
4031 inet_ntoa(nbr_nbma
->addr
),
4032 IF_NAME(oi
), 0, 0, 0);
4039 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
4040 json
, JSON_C_TO_STRING_PRETTY
));
4041 json_object_free(json
);
4048 DEFUN (show_ip_ospf_neighbor_all
,
4049 show_ip_ospf_neighbor_all_cmd
,
4050 "show ip ospf [vrf <NAME|all>] neighbor all [json]",
4053 "OSPF information\n"
4057 "include down status neighbor\n"
4061 u_char uj
= use_json(argc
, argv
);
4062 struct listnode
*node
= NULL
;
4063 char *vrf_name
= NULL
;
4064 bool all_vrf
= FALSE
;
4065 int ret
= CMD_SUCCESS
;
4069 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
4072 show_ip_ospf_neighbour_header(vty
);
4074 /* vrf input is provided could be all or specific vrf*/
4077 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
4078 if (!ospf
->oi_running
)
4080 ret
= show_ip_ospf_neighbor_all_common(vty
,
4086 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
4087 if (ospf
== NULL
|| !ospf
->oi_running
)
4090 /* Display default ospf (instance 0) info */
4091 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
4092 if (ospf
== NULL
|| !ospf
->oi_running
)
4097 ret
= show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
4102 DEFUN (show_ip_ospf_instance_neighbor_all
,
4103 show_ip_ospf_instance_neighbor_all_cmd
,
4104 "show ip ospf (1-65535) neighbor all [json]",
4107 "OSPF information\n"
4110 "include down status neighbor\n"
4115 u_short instance
= 0;
4116 u_char uj
= use_json(argc
, argv
);
4118 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4119 ospf
= ospf_lookup_instance(instance
);
4121 return CMD_NOT_MY_INSTANCE
;
4123 if (!ospf
->oi_running
)
4126 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
4129 static int show_ip_ospf_neighbor_int_common(struct vty
*vty
, struct ospf
*ospf
,
4131 struct cmd_token
**argv
,
4134 struct interface
*ifp
;
4135 struct route_node
*rn
;
4136 json_object
*json
= NULL
;
4139 json
= json_object_new_object();
4141 if (ospf
->instance
) {
4143 json_object_int_add(json
, "ospfInstance",
4146 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
4149 /*ifp = if_lookup_by_name(argv[arg_base]->arg, ospf->vrf_id);*/
4150 ifp
= if_lookup_by_name_all_vrf(argv
[arg_base
]->arg
);
4153 json_object_boolean_true_add(json
, "noSuchIface");
4155 vty_out(vty
, "No such interface.\n");
4159 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
4160 struct ospf_interface
*oi
= rn
->info
;
4165 show_ip_ospf_neighbor_sub(vty
, oi
, json
, use_json
);
4169 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
4170 json
, JSON_C_TO_STRING_PRETTY
));
4171 json_object_free(json
);
4178 DEFUN (show_ip_ospf_neighbor_int
,
4179 show_ip_ospf_neighbor_int_cmd
,
4180 "show ip ospf neighbor IFNAME [json]",
4183 "OSPF information\n"
4190 u_char uj
= use_json(argc
, argv
);
4191 struct listnode
*node
= NULL
;
4192 int ret
= CMD_SUCCESS
;
4193 struct interface
*ifp
= NULL
;
4196 show_ip_ospf_neighbour_header(vty
);
4198 ifp
= if_lookup_by_name_all_vrf(argv
[idx_ifname
]->arg
);
4199 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
4200 if (!ospf
->oi_running
)
4202 if (!ifp
|| ifp
->vrf_id
!= ospf
->vrf_id
)
4204 ret
= show_ip_ospf_neighbor_int_common(vty
, ospf
,
4205 idx_ifname
, argv
, uj
);
4211 DEFUN (show_ip_ospf_instance_neighbor_int
,
4212 show_ip_ospf_instance_neighbor_int_cmd
,
4213 "show ip ospf (1-65535) neighbor IFNAME [json]",
4216 "OSPF information\n"
4225 u_short instance
= 0;
4226 u_char uj
= use_json(argc
, argv
);
4229 show_ip_ospf_neighbour_header(vty
);
4231 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4232 ospf
= ospf_lookup_instance(instance
);
4234 return CMD_NOT_MY_INSTANCE
;
4236 if (!ospf
->oi_running
)
4240 show_ip_ospf_neighbour_header(vty
);
4242 return show_ip_ospf_neighbor_int_common(vty
, ospf
, idx_ifname
, argv
, uj
);
4245 static void show_ip_ospf_nbr_nbma_detail_sub(struct vty
*vty
,
4246 struct ospf_interface
*oi
,
4247 struct ospf_nbr_nbma
*nbr_nbma
,
4248 u_char use_json
, json_object
*json
)
4250 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4251 json_object
*json_sub
= NULL
;
4254 json_sub
= json_object_new_object();
4255 else /* Show neighbor ID. */
4256 vty_out(vty
, " Neighbor %s,", "-");
4258 /* Show interface address. */
4260 json_object_string_add(json_sub
, "ifaceAddress",
4261 inet_ntoa(nbr_nbma
->addr
));
4263 vty_out(vty
, " interface address %s\n",
4264 inet_ntoa(nbr_nbma
->addr
));
4268 json_object_string_add(json_sub
, "areaId",
4269 ospf_area_desc_string(oi
->area
));
4270 json_object_string_add(json_sub
, "iface", IF_NAME(oi
));
4272 vty_out(vty
, " In the area %s via interface %s\n",
4273 ospf_area_desc_string(oi
->area
), IF_NAME(oi
));
4275 /* Show neighbor priority and state. */
4277 json_object_int_add(json_sub
, "nbrPriority",
4278 nbr_nbma
->priority
);
4279 json_object_string_add(json_sub
, "nbrState", "down");
4281 vty_out(vty
, " Neighbor priority is %d, State is %s,",
4282 nbr_nbma
->priority
, "Down");
4284 /* Show state changes. */
4286 json_object_int_add(json_sub
, "stateChangeCounter",
4287 nbr_nbma
->state_change
);
4289 vty_out(vty
, " %d state changes\n", nbr_nbma
->state_change
);
4291 /* Show PollInterval */
4293 json_object_int_add(json_sub
, "pollInterval", nbr_nbma
->v_poll
);
4295 vty_out(vty
, " Poll interval %d\n", nbr_nbma
->v_poll
);
4297 /* Show poll-interval timer. */
4300 time_store
= monotime_until(&nbr_nbma
->t_poll
->u
.sands
, NULL
)
4302 json_object_int_add(json_sub
, "pollIntervalTimerDueMsec",
4305 vty_out(vty
, " Poll timer due in %s\n",
4306 ospf_timer_dump(nbr_nbma
->t_poll
, timebuf
,
4309 /* Show poll-interval timer thread. */
4311 if (nbr_nbma
->t_poll
!= NULL
)
4312 json_object_string_add(json_sub
,
4313 "pollIntervalTimerThread", "on");
4315 vty_out(vty
, " Thread Poll Timer %s\n",
4316 nbr_nbma
->t_poll
!= NULL
? "on" : "off");
4319 json_object_object_add(json
, "noNbrId", json_sub
);
4322 static void show_ip_ospf_neighbor_detail_sub(struct vty
*vty
,
4323 struct ospf_interface
*oi
,
4324 struct ospf_neighbor
*nbr
,
4325 u_char use_json
, json_object
*json
)
4327 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4328 json_object
*json_sub
= NULL
;
4331 json_sub
= json_object_new_object();
4333 /* Show neighbor ID. */
4334 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4335 vty_out(vty
, " Neighbor %s,", "-");
4337 vty_out(vty
, " Neighbor %s,",
4338 inet_ntoa(nbr
->router_id
));
4341 /* Show interface address. */
4343 json_object_string_add(json_sub
, "ifaceAddress",
4344 inet_ntoa(nbr
->address
.u
.prefix4
));
4346 vty_out(vty
, " interface address %s\n",
4347 inet_ntoa(nbr
->address
.u
.prefix4
));
4351 json_object_string_add(json_sub
, "areaId",
4352 ospf_area_desc_string(oi
->area
));
4353 json_object_string_add(json_sub
, "ifaceName", oi
->ifp
->name
);
4355 vty_out(vty
, " In the area %s via interface %s\n",
4356 ospf_area_desc_string(oi
->area
), oi
->ifp
->name
);
4358 /* Show neighbor priority and state. */
4360 json_object_int_add(json_sub
, "nbrPriority", nbr
->priority
);
4361 json_object_string_add(
4362 json_sub
, "nbrState",
4363 lookup_msg(ospf_nsm_state_msg
, nbr
->state
, NULL
));
4365 vty_out(vty
, " Neighbor priority is %d, State is %s,",
4367 lookup_msg(ospf_nsm_state_msg
, nbr
->state
, NULL
));
4369 /* Show state changes. */
4371 json_object_int_add(json_sub
, "stateChangeCounter",
4374 vty_out(vty
, " %d state changes\n", nbr
->state_change
);
4376 if (nbr
->ts_last_progress
.tv_sec
|| nbr
->ts_last_progress
.tv_usec
) {
4381 monotime_since(&nbr
->ts_last_progress
, &res
) / 1000LL;
4383 json_object_int_add(json_sub
, "lastPrgrsvChangeMsec",
4387 " Most recent state change statistics:\n");
4388 vty_out(vty
, " Progressive change %s ago\n",
4389 ospf_timeval_dump(&res
, timebuf
,
4394 if (nbr
->ts_last_regress
.tv_sec
|| nbr
->ts_last_regress
.tv_usec
) {
4399 monotime_since(&nbr
->ts_last_regress
, &res
) / 1000LL;
4401 json_object_int_add(json_sub
,
4402 "lastRegressiveChangeMsec",
4404 if (nbr
->last_regress_str
)
4405 json_object_string_add(
4406 json_sub
, "lastRegressiveChangeReason",
4407 nbr
->last_regress_str
);
4410 " Regressive change %s ago, due to %s\n",
4411 ospf_timeval_dump(&res
, timebuf
,
4413 (nbr
->last_regress_str
? nbr
->last_regress_str
4418 /* Show Designated Rotuer ID. */
4420 json_object_string_add(json_sub
, "routerDesignatedId",
4421 inet_ntoa(nbr
->d_router
));
4423 vty_out(vty
, " DR is %s,", inet_ntoa(nbr
->d_router
));
4425 /* Show Backup Designated Rotuer ID. */
4427 json_object_string_add(json_sub
, "routerDesignatedBackupId",
4428 inet_ntoa(nbr
->bd_router
));
4430 vty_out(vty
, " BDR is %s\n", inet_ntoa(nbr
->bd_router
));
4434 json_object_int_add(json_sub
, "optionsCounter", nbr
->options
);
4435 json_object_string_add(json_sub
, "optionsList",
4436 ospf_options_dump(nbr
->options
));
4438 vty_out(vty
, " Options %d %s\n", nbr
->options
,
4439 ospf_options_dump(nbr
->options
));
4441 /* Show Router Dead interval timer. */
4443 if (nbr
->t_inactivity
) {
4445 time_store
= monotime_until(&nbr
->t_inactivity
->u
.sands
,
4448 json_object_int_add(json_sub
,
4449 "routerDeadIntervalTimerDueMsec",
4452 json_object_int_add(
4453 json_sub
, "routerDeadIntervalTimerDueMsec", -1);
4455 vty_out(vty
, " Dead timer due in %s\n",
4456 ospf_timer_dump(nbr
->t_inactivity
, timebuf
,
4459 /* Show Database Summary list. */
4461 json_object_int_add(json_sub
, "databaseSummaryListCounter",
4462 ospf_db_summary_count(nbr
));
4464 vty_out(vty
, " Database Summary List %d\n",
4465 ospf_db_summary_count(nbr
));
4467 /* Show Link State Request list. */
4469 json_object_int_add(json_sub
, "linkStateRequestListCounter",
4470 ospf_ls_request_count(nbr
));
4472 vty_out(vty
, " Link State Request List %ld\n",
4473 ospf_ls_request_count(nbr
));
4475 /* Show Link State Retransmission list. */
4477 json_object_int_add(json_sub
,
4478 "linkStateRetransmissionListCounter",
4479 ospf_ls_retransmit_count(nbr
));
4481 vty_out(vty
, " Link State Retransmission List %ld\n",
4482 ospf_ls_retransmit_count(nbr
));
4484 /* Show inactivity timer thread. */
4486 if (nbr
->t_inactivity
!= NULL
)
4487 json_object_string_add(json_sub
,
4488 "threadInactivityTimer", "on");
4490 vty_out(vty
, " Thread Inactivity Timer %s\n",
4491 nbr
->t_inactivity
!= NULL
? "on" : "off");
4493 /* Show Database Description retransmission thread. */
4495 if (nbr
->t_db_desc
!= NULL
)
4496 json_object_string_add(
4498 "threadDatabaseDescriptionRetransmission",
4502 " Thread Database Description Retransmision %s\n",
4503 nbr
->t_db_desc
!= NULL
? "on" : "off");
4505 /* Show Link State Request Retransmission thread. */
4507 if (nbr
->t_ls_req
!= NULL
)
4508 json_object_string_add(
4510 "threadLinkStateRequestRetransmission", "on");
4513 " Thread Link State Request Retransmission %s\n",
4514 nbr
->t_ls_req
!= NULL
? "on" : "off");
4516 /* Show Link State Update Retransmission thread. */
4518 if (nbr
->t_ls_upd
!= NULL
)
4519 json_object_string_add(
4520 json_sub
, "threadLinkStateUpdateRetransmission",
4524 " Thread Link State Update Retransmission %s\n\n",
4525 nbr
->t_ls_upd
!= NULL
? "on" : "off");
4528 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4529 json_object_object_add(json
, "noNbrId", json_sub
);
4531 json_object_object_add(json
, inet_ntoa(nbr
->router_id
),
4535 ospf_bfd_show_info(vty
, nbr
->bfd_info
, json
, use_json
, 0);
4538 static int show_ip_ospf_neighbor_id_common(struct vty
*vty
, struct ospf
*ospf
,
4540 struct cmd_token
**argv
,
4543 struct listnode
*node
;
4544 struct ospf_neighbor
*nbr
;
4545 struct ospf_interface
*oi
;
4546 struct in_addr router_id
;
4548 json_object
*json
= NULL
;
4551 json
= json_object_new_object();
4553 if (ospf
->instance
) {
4555 json_object_int_add(json
, "ospfInstance",
4558 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
4561 ret
= inet_aton(argv
[arg_base
]->arg
, &router_id
);
4564 vty_out(vty
, "Please specify Neighbor ID by A.B.C.D\n");
4566 vty_out(vty
, "{}\n");
4567 json_object_free(json
);
4572 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
4573 if ((nbr
= ospf_nbr_lookup_by_routerid(oi
->nbrs
, &router_id
))) {
4574 show_ip_ospf_neighbor_detail_sub(vty
, oi
, nbr
, use_json
,
4580 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
4581 json
, JSON_C_TO_STRING_PRETTY
));
4582 json_object_free(json
);
4589 DEFUN (show_ip_ospf_neighbor_id
,
4590 show_ip_ospf_neighbor_id_cmd
,
4591 "show ip ospf neighbor A.B.C.D [json]",
4594 "OSPF information\n"
4600 u_char uj
= use_json(argc
, argv
);
4601 struct listnode
*node
= NULL
;
4602 int ret
= CMD_SUCCESS
;
4604 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
4605 if (!ospf
->oi_running
)
4607 ret
= show_ip_ospf_neighbor_id_common(vty
, ospf
, 0, argv
, uj
);
4613 DEFUN (show_ip_ospf_instance_neighbor_id
,
4614 show_ip_ospf_instance_neighbor_id_cmd
,
4615 "show ip ospf (1-65535) neighbor A.B.C.D [json]",
4618 "OSPF information\n"
4625 int idx_router_id
= 5;
4627 u_short instance
= 0;
4628 u_char uj
= use_json(argc
, argv
);
4630 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4631 ospf
= ospf_lookup_instance(instance
);
4633 return CMD_NOT_MY_INSTANCE
;
4635 if (!ospf
->oi_running
)
4638 return show_ip_ospf_neighbor_id_common(vty
, ospf
, idx_router_id
, argv
, uj
);
4641 static int show_ip_ospf_neighbor_detail_common(struct vty
*vty
,
4645 struct ospf_interface
*oi
;
4646 struct listnode
*node
;
4647 json_object
*json
= NULL
;
4650 json
= json_object_new_object();
4652 if (ospf
->instance
) {
4654 json_object_int_add(json
, "ospfInstance",
4657 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
4660 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
4661 struct route_node
*rn
;
4662 struct ospf_neighbor
*nbr
;
4664 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
)) {
4665 if ((nbr
= rn
->info
)) {
4666 if (nbr
!= oi
->nbr_self
) {
4667 if (nbr
->state
!= NSM_Down
) {
4668 show_ip_ospf_neighbor_detail_sub(
4669 vty
, oi
, nbr
, use_json
,
4678 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
4679 json
, JSON_C_TO_STRING_PRETTY
));
4680 json_object_free(json
);
4687 DEFUN (show_ip_ospf_neighbor_detail
,
4688 show_ip_ospf_neighbor_detail_cmd
,
4689 "show ip ospf [vrf <NAME|all>] neighbor detail [json]",
4692 "OSPF information\n"
4696 "detail of all neighbors\n"
4700 u_char uj
= use_json(argc
, argv
);
4701 struct listnode
*node
= NULL
;
4702 char *vrf_name
= NULL
;
4703 bool all_vrf
= FALSE
;
4704 int ret
= CMD_SUCCESS
;
4708 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
4710 /* vrf input is provided could be all or specific vrf*/
4713 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
4714 if (!ospf
->oi_running
)
4716 ret
= show_ip_ospf_neighbor_detail_common(vty
,
4722 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
4723 if (ospf
== NULL
|| !ospf
->oi_running
)
4726 /* Display default ospf (instance 0) info */
4727 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
4728 if (ospf
== NULL
|| !ospf
->oi_running
)
4733 ret
= show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4738 DEFUN (show_ip_ospf_instance_neighbor_detail
,
4739 show_ip_ospf_instance_neighbor_detail_cmd
,
4740 "show ip ospf (1-65535) neighbor detail [json]",
4743 "OSPF information\n"
4746 "detail of all neighbors\n"
4751 u_short instance
= 0;
4752 u_char uj
= use_json(argc
, argv
);
4754 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4755 ospf
= ospf_lookup_instance(instance
);
4757 return CMD_NOT_MY_INSTANCE
;
4759 if (!ospf
->oi_running
)
4762 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4765 static int show_ip_ospf_neighbor_detail_all_common(struct vty
*vty
,
4769 struct listnode
*node
;
4770 struct ospf_interface
*oi
;
4771 json_object
*json
= NULL
;
4774 json
= json_object_new_object();
4776 if (ospf
->instance
) {
4778 json_object_int_add(json
, "ospfInstance",
4781 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
4784 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
4785 struct route_node
*rn
;
4786 struct ospf_neighbor
*nbr
;
4787 struct ospf_nbr_nbma
*nbr_nbma
;
4789 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
))
4790 if ((nbr
= rn
->info
))
4791 if (nbr
!= oi
->nbr_self
)
4792 if (nbr
->state
!= NSM_Down
)
4793 show_ip_ospf_neighbor_detail_sub(
4797 if (oi
->type
== OSPF_IFTYPE_NBMA
) {
4798 struct listnode
*nd
;
4800 for (ALL_LIST_ELEMENTS_RO(oi
->nbr_nbma
, nd
, nbr_nbma
)) {
4801 if (nbr_nbma
->nbr
== NULL
4802 || nbr_nbma
->nbr
->state
== NSM_Down
)
4803 show_ip_ospf_nbr_nbma_detail_sub(
4804 vty
, oi
, nbr_nbma
, use_json
,
4811 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
4812 json
, JSON_C_TO_STRING_PRETTY
));
4813 json_object_free(json
);
4821 DEFUN (show_ip_ospf_neighbor_detail_all
,
4822 show_ip_ospf_neighbor_detail_all_cmd
,
4823 "show ip ospf [vrf <NAME|all>] neighbor detail all [json]",
4826 "OSPF information\n"
4830 "detail of all neighbors\n"
4831 "include down status neighbor\n"
4835 u_char uj
= use_json(argc
, argv
);
4836 struct listnode
*node
= NULL
;
4837 char *vrf_name
= NULL
;
4838 bool all_vrf
= FALSE
;
4839 int ret
= CMD_SUCCESS
;
4843 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
4845 /* vrf input is provided could be all or specific vrf*/
4848 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
4849 if (!ospf
->oi_running
)
4851 ret
= show_ip_ospf_neighbor_detail_all_common(vty
,
4857 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
4858 if (ospf
== NULL
|| !ospf
->oi_running
)
4861 /* Display default ospf (instance 0) info */
4862 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
4863 if (ospf
== NULL
|| !ospf
->oi_running
)
4868 ret
= show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4873 DEFUN (show_ip_ospf_instance_neighbor_detail_all
,
4874 show_ip_ospf_instance_neighbor_detail_all_cmd
,
4875 "show ip ospf (1-65535) neighbor detail all [json]",
4878 "OSPF information\n"
4881 "detail of all neighbors\n"
4882 "include down status neighbor\n"
4887 u_short instance
= 0;
4888 u_char uj
= use_json(argc
, argv
);
4890 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4891 ospf
= ospf_lookup_instance(instance
);
4893 return CMD_NOT_MY_INSTANCE
;
4895 if (!ospf
->oi_running
)
4898 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4901 static int show_ip_ospf_neighbor_int_detail_common(struct vty
*vty
,
4904 struct cmd_token
**argv
,
4907 struct ospf_interface
*oi
;
4908 struct interface
*ifp
;
4909 struct route_node
*rn
, *nrn
;
4910 struct ospf_neighbor
*nbr
;
4911 json_object
*json
= NULL
;
4914 json
= json_object_new_object();
4916 if (ospf
->instance
) {
4918 json_object_int_add(json
, "ospfInstance",
4921 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
4924 ifp
= if_lookup_by_name_all_vrf(argv
[arg_base
]->arg
);
4927 vty_out(vty
, "No such interface.\n");
4929 vty_out(vty
, "{}\n");
4930 json_object_free(json
);
4935 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
4936 if ((oi
= rn
->info
)) {
4937 for (nrn
= route_top(oi
->nbrs
); nrn
;
4938 nrn
= route_next(nrn
)) {
4939 if ((nbr
= nrn
->info
)) {
4940 if (nbr
!= oi
->nbr_self
) {
4941 if (nbr
->state
!= NSM_Down
)
4942 show_ip_ospf_neighbor_detail_sub(
4952 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
4953 json
, JSON_C_TO_STRING_PRETTY
));
4954 json_object_free(json
);
4961 DEFUN (show_ip_ospf_neighbor_int_detail
,
4962 show_ip_ospf_neighbor_int_detail_cmd
,
4963 "show ip ospf neighbor IFNAME detail [json]",
4966 "OSPF information\n"
4969 "detail of all neighbors\n"
4973 u_char uj
= use_json(argc
, argv
);
4974 struct listnode
*node
= NULL
;
4975 int ret
= CMD_SUCCESS
;
4977 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
4978 if (!ospf
->oi_running
)
4980 ret
= show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 0,
4987 DEFUN (show_ip_ospf_instance_neighbor_int_detail
,
4988 show_ip_ospf_instance_neighbor_int_detail_cmd
,
4989 "show ip ospf (1-65535) neighbor IFNAME detail [json]",
4992 "OSPF information\n"
4996 "detail of all neighbors\n"
5002 u_short instance
= 0;
5003 u_char uj
= use_json(argc
, argv
);
5005 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5006 ospf
= ospf_lookup_instance(instance
);
5008 return CMD_NOT_MY_INSTANCE
;
5010 if (!ospf
->oi_running
)
5013 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, idx_ifname
, argv
, uj
);
5016 /* Show functions */
5017 static int show_lsa_summary(struct vty
*vty
, struct ospf_lsa
*lsa
, int self
)
5019 struct router_lsa
*rl
;
5020 struct summary_lsa
*sl
;
5021 struct as_external_lsa
*asel
;
5022 struct prefix_ipv4 p
;
5025 /* If self option is set, check LSA self flag. */
5026 if (self
== 0 || IS_LSA_SELF(lsa
)) {
5027 /* LSA common part show. */
5028 vty_out(vty
, "%-15s ", inet_ntoa(lsa
->data
->id
));
5029 vty_out(vty
, "%-15s %4d 0x%08lx 0x%04x",
5030 inet_ntoa(lsa
->data
->adv_router
), LS_AGE(lsa
),
5031 (u_long
)ntohl(lsa
->data
->ls_seqnum
),
5032 ntohs(lsa
->data
->checksum
));
5033 /* LSA specific part show. */
5034 switch (lsa
->data
->type
) {
5035 case OSPF_ROUTER_LSA
:
5036 rl
= (struct router_lsa
*)lsa
->data
;
5037 vty_out(vty
, " %-d", ntohs(rl
->links
));
5039 case OSPF_SUMMARY_LSA
:
5040 sl
= (struct summary_lsa
*)lsa
->data
;
5043 p
.prefix
= sl
->header
.id
;
5044 p
.prefixlen
= ip_masklen(sl
->mask
);
5045 apply_mask_ipv4(&p
);
5047 vty_out(vty
, " %s/%d", inet_ntoa(p
.prefix
),
5050 case OSPF_AS_EXTERNAL_LSA
:
5051 case OSPF_AS_NSSA_LSA
:
5052 asel
= (struct as_external_lsa
*)lsa
->data
;
5055 p
.prefix
= asel
->header
.id
;
5056 p
.prefixlen
= ip_masklen(asel
->mask
);
5057 apply_mask_ipv4(&p
);
5059 vty_out(vty
, " %s %s/%d [0x%lx]",
5060 IS_EXTERNAL_METRIC(asel
->e
[0].tos
)
5063 inet_ntoa(p
.prefix
), p
.prefixlen
,
5064 (u_long
)ntohl(asel
->e
[0].route_tag
));
5066 case OSPF_NETWORK_LSA
:
5067 case OSPF_ASBR_SUMMARY_LSA
:
5068 case OSPF_OPAQUE_LINK_LSA
:
5069 case OSPF_OPAQUE_AREA_LSA
:
5070 case OSPF_OPAQUE_AS_LSA
:
5080 static const char *show_database_desc
[] = {
5082 "Router Link States",
5084 "Summary Link States",
5085 "ASBR-Summary Link States",
5086 "AS External Link States",
5087 "Group Membership LSA",
5088 "NSSA-external Link States",
5090 "Link-Local Opaque-LSA",
5091 "Area-Local Opaque-LSA",
5092 "AS-external Opaque-LSA",
5095 static const char *show_database_header
[] = {
5097 "Link ID ADV Router Age Seq# CkSum Link count",
5098 "Link ID ADV Router Age Seq# CkSum",
5099 "Link ID ADV Router Age Seq# CkSum Route",
5100 "Link ID ADV Router Age Seq# CkSum",
5101 "Link ID ADV Router Age Seq# CkSum Route",
5102 " --- header for Group Member ----",
5103 "Link ID ADV Router Age Seq# CkSum Route",
5105 "Opaque-Type/Id ADV Router Age Seq# CkSum",
5106 "Opaque-Type/Id ADV Router Age Seq# CkSum",
5107 "Opaque-Type/Id ADV Router Age Seq# CkSum",
5110 static void show_ip_ospf_database_header(struct vty
*vty
, struct ospf_lsa
*lsa
)
5112 struct router_lsa
*rlsa
= (struct router_lsa
*)lsa
->data
;
5114 vty_out(vty
, " LS age: %d\n", LS_AGE(lsa
));
5115 vty_out(vty
, " Options: 0x%-2x : %s\n", lsa
->data
->options
,
5116 ospf_options_dump(lsa
->data
->options
));
5117 vty_out(vty
, " LS Flags: 0x%-2x %s\n", lsa
->flags
,
5118 ((lsa
->flags
& OSPF_LSA_LOCAL_XLT
) ? "(Translated from Type-7)"
5121 if (lsa
->data
->type
== OSPF_ROUTER_LSA
) {
5122 vty_out(vty
, " Flags: 0x%x", rlsa
->flags
);
5125 vty_out(vty
, " :%s%s%s%s",
5126 IS_ROUTER_LSA_BORDER(rlsa
) ? " ABR" : "",
5127 IS_ROUTER_LSA_EXTERNAL(rlsa
) ? " ASBR" : "",
5128 IS_ROUTER_LSA_VIRTUAL(rlsa
) ? " VL-endpoint"
5130 IS_ROUTER_LSA_SHORTCUT(rlsa
) ? " Shortcut"
5135 vty_out(vty
, " LS Type: %s\n",
5136 lookup_msg(ospf_lsa_type_msg
, lsa
->data
->type
, NULL
));
5137 vty_out(vty
, " Link State ID: %s %s\n", inet_ntoa(lsa
->data
->id
),
5138 lookup_msg(ospf_link_state_id_type_msg
, lsa
->data
->type
, NULL
));
5139 vty_out(vty
, " Advertising Router: %s\n",
5140 inet_ntoa(lsa
->data
->adv_router
));
5141 vty_out(vty
, " LS Seq Number: %08lx\n",
5142 (u_long
)ntohl(lsa
->data
->ls_seqnum
));
5143 vty_out(vty
, " Checksum: 0x%04x\n", ntohs(lsa
->data
->checksum
));
5144 vty_out(vty
, " Length: %d\n\n", ntohs(lsa
->data
->length
));
5147 const char *link_type_desc
[] = {
5149 "another Router (point-to-point)",
5150 "a Transit Network",
5155 const char *link_id_desc
[] = {
5156 "(null)", "Neighboring Router ID", "Designated Router address",
5157 "Net", "Neighboring Router ID",
5160 const char *link_data_desc
[] = {
5161 "(null)", "Router Interface address", "Router Interface address",
5162 "Network Mask", "Router Interface address",
5165 /* Show router-LSA each Link information. */
5166 static void show_ip_ospf_database_router_links(struct vty
*vty
,
5167 struct router_lsa
*rl
)
5172 len
= ntohs(rl
->header
.length
) - 4;
5173 for (i
= 0; i
< ntohs(rl
->links
) && len
> 0; len
-= 12, i
++) {
5174 type
= rl
->link
[i
].type
;
5176 vty_out(vty
, " Link connected to: %s\n",
5177 link_type_desc
[type
]);
5178 vty_out(vty
, " (Link ID) %s: %s\n", link_id_desc
[type
],
5179 inet_ntoa(rl
->link
[i
].link_id
));
5180 vty_out(vty
, " (Link Data) %s: %s\n", link_data_desc
[type
],
5181 inet_ntoa(rl
->link
[i
].link_data
));
5182 vty_out(vty
, " Number of TOS metrics: 0\n");
5183 vty_out(vty
, " TOS 0 Metric: %d\n",
5184 ntohs(rl
->link
[i
].metric
));
5189 /* Show router-LSA detail information. */
5190 static int show_router_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5193 struct router_lsa
*rl
= (struct router_lsa
*)lsa
->data
;
5195 show_ip_ospf_database_header(vty
, lsa
);
5197 vty_out(vty
, " Number of Links: %d\n\n", ntohs(rl
->links
));
5199 show_ip_ospf_database_router_links(vty
, rl
);
5206 /* Show network-LSA detail information. */
5207 static int show_network_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5212 struct network_lsa
*nl
= (struct network_lsa
*)lsa
->data
;
5214 show_ip_ospf_database_header(vty
, lsa
);
5216 vty_out(vty
, " Network Mask: /%d\n", ip_masklen(nl
->mask
));
5218 length
= ntohs(lsa
->data
->length
) - OSPF_LSA_HEADER_SIZE
- 4;
5220 for (i
= 0; length
> 0; i
++, length
-= 4)
5221 vty_out(vty
, " Attached Router: %s\n",
5222 inet_ntoa(nl
->routers
[i
]));
5230 /* Show summary-LSA detail information. */
5231 static int show_summary_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5234 struct summary_lsa
*sl
= (struct summary_lsa
*)lsa
->data
;
5236 show_ip_ospf_database_header(vty
, lsa
);
5238 vty_out(vty
, " Network Mask: /%d\n", ip_masklen(sl
->mask
));
5239 vty_out(vty
, " TOS: 0 Metric: %d\n",
5240 GET_METRIC(sl
->metric
));
5247 /* Show summary-ASBR-LSA detail information. */
5248 static int show_summary_asbr_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5251 struct summary_lsa
*sl
= (struct summary_lsa
*)lsa
->data
;
5253 show_ip_ospf_database_header(vty
, lsa
);
5255 vty_out(vty
, " Network Mask: /%d\n", ip_masklen(sl
->mask
));
5256 vty_out(vty
, " TOS: 0 Metric: %d\n",
5257 GET_METRIC(sl
->metric
));
5264 /* Show AS-external-LSA detail information. */
5265 static int show_as_external_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5268 struct as_external_lsa
*al
=
5269 (struct as_external_lsa
*)lsa
->data
;
5271 show_ip_ospf_database_header(vty
, lsa
);
5273 vty_out(vty
, " Network Mask: /%d\n", ip_masklen(al
->mask
));
5274 vty_out(vty
, " Metric Type: %s\n",
5275 IS_EXTERNAL_METRIC(al
->e
[0].tos
)
5276 ? "2 (Larger than any link state path)"
5278 vty_out(vty
, " TOS: 0\n");
5279 vty_out(vty
, " Metric: %d\n",
5280 GET_METRIC(al
->e
[0].metric
));
5281 vty_out(vty
, " Forward Address: %s\n",
5282 inet_ntoa(al
->e
[0].fwd_addr
));
5285 " External Route Tag: %" ROUTE_TAG_PRI
"\n\n",
5286 (route_tag_t
)ntohl(al
->e
[0].route_tag
));
5293 show_as_external_lsa_stdvty (struct ospf_lsa
*lsa
)
5295 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5297 /* show_ip_ospf_database_header (vty, lsa); */
5299 zlog_debug( " Network Mask: /%d%s",
5300 ip_masklen (al
->mask
), "\n");
5301 zlog_debug( " Metric Type: %s%s",
5302 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5303 "2 (Larger than any link state path)" : "1", "\n");
5304 zlog_debug( " TOS: 0%s", "\n");
5305 zlog_debug( " Metric: %d%s",
5306 GET_METRIC (al
->e
[0].metric
), "\n");
5307 zlog_debug( " Forward Address: %s%s",
5308 inet_ntoa (al
->e
[0].fwd_addr
), "\n");
5310 zlog_debug( " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5311 (route_tag_t
)ntohl (al
->e
[0].route_tag
), "\n", "\n");
5316 /* Show AS-NSSA-LSA detail information. */
5317 static int show_as_nssa_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5320 struct as_external_lsa
*al
=
5321 (struct as_external_lsa
*)lsa
->data
;
5323 show_ip_ospf_database_header(vty
, lsa
);
5325 vty_out(vty
, " Network Mask: /%d\n", ip_masklen(al
->mask
));
5326 vty_out(vty
, " Metric Type: %s\n",
5327 IS_EXTERNAL_METRIC(al
->e
[0].tos
)
5328 ? "2 (Larger than any link state path)"
5330 vty_out(vty
, " TOS: 0\n");
5331 vty_out(vty
, " Metric: %d\n",
5332 GET_METRIC(al
->e
[0].metric
));
5333 vty_out(vty
, " NSSA: Forward Address: %s\n",
5334 inet_ntoa(al
->e
[0].fwd_addr
));
5337 " External Route Tag: %" ROUTE_TAG_PRI
"\n\n",
5338 (route_tag_t
)ntohl(al
->e
[0].route_tag
));
5344 static int show_func_dummy(struct vty
*vty
, struct ospf_lsa
*lsa
)
5349 static int show_opaque_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5352 show_ip_ospf_database_header(vty
, lsa
);
5353 show_opaque_info_detail(vty
, lsa
);
5360 int (*show_function
[])(struct vty
*, struct ospf_lsa
*) = {
5362 show_router_lsa_detail
,
5363 show_network_lsa_detail
,
5364 show_summary_lsa_detail
,
5365 show_summary_asbr_lsa_detail
,
5366 show_as_external_lsa_detail
,
5368 show_as_nssa_lsa_detail
, /* almost same as external */
5370 show_opaque_lsa_detail
,
5371 show_opaque_lsa_detail
,
5372 show_opaque_lsa_detail
,
5375 static void show_lsa_prefix_set(struct vty
*vty
, struct prefix_ls
*lp
,
5376 struct in_addr
*id
, struct in_addr
*adv_router
)
5378 memset(lp
, 0, sizeof(struct prefix_ls
));
5382 else if (adv_router
== NULL
) {
5388 lp
->adv_router
= *adv_router
;
5392 static void show_lsa_detail_proc(struct vty
*vty
, struct route_table
*rt
,
5393 struct in_addr
*id
, struct in_addr
*adv_router
)
5395 struct prefix_ls lp
;
5396 struct route_node
*rn
, *start
;
5397 struct ospf_lsa
*lsa
;
5399 show_lsa_prefix_set(vty
, &lp
, id
, adv_router
);
5400 start
= route_node_get(rt
, (struct prefix
*)&lp
);
5402 route_lock_node(start
);
5403 for (rn
= start
; rn
; rn
= route_next_until(rn
, start
))
5404 if ((lsa
= rn
->info
)) {
5405 if (show_function
[lsa
->data
->type
] != NULL
)
5406 show_function
[lsa
->data
->type
](vty
,
5409 route_unlock_node(start
);
5413 /* Show detail LSA information
5414 -- if id is NULL then show all LSAs. */
5415 static void show_lsa_detail(struct vty
*vty
, struct ospf
*ospf
, int type
,
5416 struct in_addr
*id
, struct in_addr
*adv_router
)
5418 struct listnode
*node
;
5419 struct ospf_area
*area
;
5422 case OSPF_AS_EXTERNAL_LSA
:
5423 case OSPF_OPAQUE_AS_LSA
:
5424 vty_out(vty
, " %s \n\n",
5425 show_database_desc
[type
]);
5426 show_lsa_detail_proc(vty
, AS_LSDB(ospf
, type
), id
, adv_router
);
5429 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
5430 vty_out(vty
, "\n %s (Area %s)\n\n",
5431 show_database_desc
[type
],
5432 ospf_area_desc_string(area
));
5433 show_lsa_detail_proc(vty
, AREA_LSDB(area
, type
), id
,
5440 static void show_lsa_detail_adv_router_proc(struct vty
*vty
,
5441 struct route_table
*rt
,
5442 struct in_addr
*adv_router
)
5444 struct route_node
*rn
;
5445 struct ospf_lsa
*lsa
;
5447 for (rn
= route_top(rt
); rn
; rn
= route_next(rn
))
5448 if ((lsa
= rn
->info
))
5449 if (IPV4_ADDR_SAME(adv_router
,
5450 &lsa
->data
->adv_router
)) {
5451 if (CHECK_FLAG(lsa
->flags
, OSPF_LSA_LOCAL_XLT
))
5453 if (show_function
[lsa
->data
->type
] != NULL
)
5454 show_function
[lsa
->data
->type
](vty
,
5459 /* Show detail LSA information. */
5460 static void show_lsa_detail_adv_router(struct vty
*vty
, struct ospf
*ospf
,
5461 int type
, struct in_addr
*adv_router
)
5463 struct listnode
*node
;
5464 struct ospf_area
*area
;
5467 case OSPF_AS_EXTERNAL_LSA
:
5468 case OSPF_OPAQUE_AS_LSA
:
5469 vty_out(vty
, " %s \n\n",
5470 show_database_desc
[type
]);
5471 show_lsa_detail_adv_router_proc(vty
, AS_LSDB(ospf
, type
),
5475 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
5476 vty_out(vty
, "\n %s (Area %s)\n\n",
5477 show_database_desc
[type
],
5478 ospf_area_desc_string(area
));
5479 show_lsa_detail_adv_router_proc(
5480 vty
, AREA_LSDB(area
, type
), adv_router
);
5486 static void show_ip_ospf_database_summary(struct vty
*vty
, struct ospf
*ospf
,
5489 struct ospf_lsa
*lsa
;
5490 struct route_node
*rn
;
5491 struct ospf_area
*area
;
5492 struct listnode
*node
;
5495 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
5496 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++) {
5498 case OSPF_AS_EXTERNAL_LSA
:
5499 case OSPF_OPAQUE_AS_LSA
:
5504 if (ospf_lsdb_count_self(area
->lsdb
, type
) > 0
5506 && ospf_lsdb_count(area
->lsdb
, type
) > 0)) {
5507 vty_out(vty
, " %s (Area %s)\n\n",
5508 show_database_desc
[type
],
5509 ospf_area_desc_string(area
));
5510 vty_out(vty
, "%s\n",
5511 show_database_header
[type
]);
5513 LSDB_LOOP(AREA_LSDB(area
, type
), rn
, lsa
)
5514 show_lsa_summary(vty
, lsa
, self
);
5521 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++) {
5523 case OSPF_AS_EXTERNAL_LSA
:
5524 case OSPF_OPAQUE_AS_LSA
:
5529 if (ospf_lsdb_count_self(ospf
->lsdb
, type
)
5530 || (!self
&& ospf_lsdb_count(ospf
->lsdb
, type
))) {
5531 vty_out(vty
, " %s\n\n",
5532 show_database_desc
[type
]);
5533 vty_out(vty
, "%s\n", show_database_header
[type
]);
5535 LSDB_LOOP(AS_LSDB(ospf
, type
), rn
, lsa
)
5536 show_lsa_summary(vty
, lsa
, self
);
5545 static void show_ip_ospf_database_maxage(struct vty
*vty
, struct ospf
*ospf
)
5547 struct route_node
*rn
;
5549 vty_out(vty
, "\n MaxAge Link States:\n\n");
5551 for (rn
= route_top(ospf
->maxage_lsa
); rn
; rn
= route_next(rn
)) {
5552 struct ospf_lsa
*lsa
;
5554 if ((lsa
= rn
->info
) != NULL
) {
5555 vty_out(vty
, "Link type: %d\n", lsa
->data
->type
);
5556 vty_out(vty
, "Link State ID: %s\n",
5557 inet_ntoa(lsa
->data
->id
));
5558 vty_out(vty
, "Advertising Router: %s\n",
5559 inet_ntoa(lsa
->data
->adv_router
));
5560 vty_out(vty
, "LSA lock count: %d\n", lsa
->lock
);
5566 #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
5567 #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
5569 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
5570 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
5571 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
5572 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
5574 #define OSPF_LSA_TYPES_DESC \
5575 "ASBR summary link states\n" \
5576 "External link states\n" \
5577 "Network link states\n" \
5578 "Router link states\n" \
5579 "Network summary link states\n" OSPF_LSA_TYPE_NSSA_DESC \
5580 OSPF_LSA_TYPE_OPAQUE_LINK_DESC OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
5581 OSPF_LSA_TYPE_OPAQUE_AS_DESC
5583 static int show_ip_ospf_database_common(struct vty
*vty
, struct ospf
*ospf
,
5584 int arg_base
, int argc
,
5585 struct cmd_token
**argv
)
5589 struct in_addr id
, adv_router
;
5592 vty_out(vty
, "\nOSPF Instance: %d\n", ospf
->instance
);
5594 vty_out(vty
, "\n OSPF Router with ID (%s)\n\n",
5595 inet_ntoa(ospf
->router_id
));
5598 if (argc
== arg_base
+ 4) {
5599 show_ip_ospf_database_summary(vty
, ospf
, 0);
5603 /* Set database type to show. */
5604 if (strncmp(argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5605 type
= OSPF_ROUTER_LSA
;
5606 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5607 type
= OSPF_NETWORK_LSA
;
5608 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5609 type
= OSPF_AS_NSSA_LSA
;
5610 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "su", 2) == 0)
5611 type
= OSPF_SUMMARY_LSA
;
5612 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5613 type
= OSPF_ASBR_SUMMARY_LSA
;
5614 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5615 type
= OSPF_AS_EXTERNAL_LSA
;
5616 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "se", 2) == 0) {
5617 show_ip_ospf_database_summary(vty
, ospf
, 1);
5619 } else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "m", 1) == 0) {
5620 show_ip_ospf_database_maxage(vty
, ospf
);
5622 } else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5623 type
= OSPF_OPAQUE_LINK_LSA
;
5624 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5625 type
= OSPF_OPAQUE_AREA_LSA
;
5626 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5627 type
= OSPF_OPAQUE_AS_LSA
;
5631 /* `show ip ospf database LSA'. */
5632 if (argc
== arg_base
+ 5)
5633 show_lsa_detail(vty
, ospf
, type
, NULL
, NULL
);
5634 else if (argc
>= arg_base
+ 6) {
5635 ret
= inet_aton(argv
[arg_base
+ 5]->arg
, &id
);
5639 /* `show ip ospf database LSA ID'. */
5640 if (argc
== arg_base
+ 6)
5641 show_lsa_detail(vty
, ospf
, type
, &id
, NULL
);
5642 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
5643 else if (argc
== arg_base
+ 7) {
5644 if (strncmp(argv
[arg_base
+ 6]->text
, "s", 1) == 0)
5645 adv_router
= ospf
->router_id
;
5647 ret
= inet_aton(argv
[arg_base
+ 7]->arg
,
5652 show_lsa_detail(vty
, ospf
, type
, &id
, &adv_router
);
5659 DEFUN (show_ip_ospf_database_max
,
5660 show_ip_ospf_database_max_cmd
,
5661 "show ip ospf [vrf <NAME|all>] database <max-age|self-originate>",
5664 "OSPF information\n"
5667 "Database summary\n"
5668 "LSAs in MaxAge list\n"
5669 "Self-originated link states\n")
5671 struct ospf
*ospf
= NULL
;
5672 struct listnode
*node
= NULL
;
5673 char *vrf_name
= NULL
;
5674 bool all_vrf
= FALSE
;
5675 int ret
= CMD_SUCCESS
;
5679 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
5683 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
5684 if (!ospf
->oi_running
)
5686 ret
= show_ip_ospf_database_common(vty
, ospf
,
5692 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
5693 if (ospf
== NULL
|| !ospf
->oi_running
)
5695 ret
= (show_ip_ospf_database_common(vty
, ospf
, idx_vrf
?
5696 2 : 0, argc
, argv
));
5699 /* Display default ospf (instance 0) info */
5700 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
5701 if (ospf
== NULL
|| !ospf
->oi_running
)
5703 ret
= show_ip_ospf_database_common(vty
, ospf
, 0, argc
, argv
);
5709 DEFUN (show_ip_ospf_instance_database
,
5710 show_ip_ospf_instance_database_cmd
,
5711 "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>]]]",
5714 "OSPF information\n"
5717 "Database summary\n"
5719 "Link State ID (as an IP address)\n"
5720 "Self-originated link states\n"
5721 "Advertising Router link states\n"
5722 "Advertising Router (as an IP address)\n")
5725 u_short instance
= 0;
5726 struct listnode
*node
= NULL
;
5727 char *vrf_name
= NULL
;
5728 bool all_vrf
= FALSE
;
5729 int ret
= CMD_SUCCESS
;
5733 if (argv_find(argv
, argc
, "(1-65535)", &idx
)) {
5734 instance
= strtoul(argv
[idx
]->arg
, NULL
, 10);
5735 ospf
= ospf_lookup_instance(instance
);
5737 return CMD_NOT_MY_INSTANCE
;
5738 if (!ospf
->oi_running
)
5741 return (show_ip_ospf_database_common(vty
, ospf
, idx
? 1 : 0,
5743 } else if (argv_find(argv
, argc
, "vrf", &idx
)) {
5744 vrf_name
= argv
[++idx
]->arg
;
5745 all_vrf
= strmatch(vrf_name
, "all");
5750 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
5751 if (!ospf
->oi_running
)
5753 ret
= (show_ip_ospf_database_common(vty
, ospf
,
5758 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
5759 if ((ospf
== NULL
) || !ospf
->oi_running
)
5761 ret
= (show_ip_ospf_database_common(vty
, ospf
, idx
? 2 :
5765 /* Display default ospf (instance 0) info */
5766 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
5767 if (ospf
== NULL
|| !ospf
->oi_running
)
5769 ret
= (show_ip_ospf_database_common(vty
, ospf
, 0, argc
, argv
));
5775 DEFUN (show_ip_ospf_instance_database_max
,
5776 show_ip_ospf_instance_database_max_cmd
,
5777 "show ip ospf (1-65535) database <max-age|self-originate>",
5780 "OSPF information\n"
5782 "Database summary\n"
5783 "LSAs in MaxAge list\n"
5784 "Self-originated link states\n")
5788 u_short instance
= 0;
5790 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5792 ospf
= ospf_lookup_instance(instance
);
5794 return CMD_NOT_MY_INSTANCE
;
5796 if (!ospf
->oi_running
)
5799 return (show_ip_ospf_database_common(vty
, ospf
, 1, argc
, argv
));
5803 static int show_ip_ospf_database_type_adv_router_common(struct vty
*vty
,
5805 int arg_base
, int argc
,
5806 struct cmd_token
**argv
)
5810 struct in_addr adv_router
;
5813 vty_out(vty
, "\nOSPF Instance: %d\n", ospf
->instance
);
5815 vty_out(vty
, "\n OSPF Router with ID (%s)\n\n",
5816 inet_ntoa(ospf
->router_id
));
5818 /* Set database type to show. */
5819 if (strncmp(argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5820 type
= OSPF_ROUTER_LSA
;
5821 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5822 type
= OSPF_NETWORK_LSA
;
5823 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5824 type
= OSPF_AS_NSSA_LSA
;
5825 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "s", 1) == 0)
5826 type
= OSPF_SUMMARY_LSA
;
5827 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5828 type
= OSPF_ASBR_SUMMARY_LSA
;
5829 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5830 type
= OSPF_AS_EXTERNAL_LSA
;
5831 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5832 type
= OSPF_OPAQUE_LINK_LSA
;
5833 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5834 type
= OSPF_OPAQUE_AREA_LSA
;
5835 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5836 type
= OSPF_OPAQUE_AS_LSA
;
5840 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
5841 if (strncmp(argv
[arg_base
+ 5]->text
, "s", 1) == 0)
5842 adv_router
= ospf
->router_id
;
5844 ret
= inet_aton(argv
[arg_base
+ 6]->arg
, &adv_router
);
5849 show_lsa_detail_adv_router(vty
, ospf
, type
, &adv_router
);
5854 DEFUN (show_ip_ospf_instance_database_type_adv_router
,
5855 show_ip_ospf_instance_database_type_adv_router_cmd
,
5856 "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>",
5859 "OSPF information\n"
5862 "Database summary\n"
5864 "Advertising Router link states\n"
5865 "Advertising Router (as an IP address)\n"
5866 "Self-originated link states\n")
5868 struct ospf
*ospf
= NULL
;
5869 u_short instance
= 0;
5870 struct listnode
*node
= NULL
;
5871 char *vrf_name
= NULL
;
5872 bool all_vrf
= FALSE
;
5873 int ret
= CMD_SUCCESS
;
5875 int idx
= 0, idx_vrf
= 0;
5877 if (argv_find(argv
, argc
, "(1-65535)", &idx
)) {
5878 instance
= strtoul(argv
[idx
]->arg
, NULL
, 10);
5879 ospf
= ospf_lookup_instance(instance
);
5881 return CMD_NOT_MY_INSTANCE
;
5882 if (!ospf
->oi_running
)
5884 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
,
5890 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
5894 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
5895 if (!ospf
->oi_running
)
5897 ret
= show_ip_ospf_database_type_adv_router_common(vty
,
5898 ospf
, idx
? 1 : 0, argc
, argv
);
5901 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
5902 if ((ospf
== NULL
) || !ospf
->oi_running
)
5904 ret
= show_ip_ospf_database_type_adv_router_common(vty
,
5905 ospf
, idx
? 1 : 0, argc
, argv
);
5908 /* Display default ospf (instance 0) info */
5909 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
5910 if (ospf
== NULL
|| !ospf
->oi_running
)
5912 ret
= show_ip_ospf_database_type_adv_router_common(vty
, ospf
,
5917 /*return (show_ip_ospf_database_type_adv_router_common(
5918 vty, ospf, idx ? 1 : 0, argc, argv));*/
5921 DEFUN (ip_ospf_authentication_args
,
5922 ip_ospf_authentication_args_addr_cmd
,
5923 "ip ospf authentication <null|message-digest> [A.B.C.D]",
5925 "OSPF interface commands\n"
5926 "Enable authentication on this interface\n"
5927 "Use null authentication\n"
5928 "Use message-digest authentication\n"
5929 "Address of interface\n")
5931 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5932 int idx_encryption
= 3;
5934 struct in_addr addr
;
5936 struct ospf_if_params
*params
;
5938 params
= IF_DEF_PARAMS(ifp
);
5941 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5944 "Please specify interface address by A.B.C.D\n");
5945 return CMD_WARNING_CONFIG_FAILED
;
5948 params
= ospf_get_if_params(ifp
, addr
);
5949 ospf_if_update_params(ifp
, addr
);
5952 /* Handle null authentication */
5953 if (argv
[idx_encryption
]->arg
[0] == 'n') {
5954 SET_IF_PARAM(params
, auth_type
);
5955 params
->auth_type
= OSPF_AUTH_NULL
;
5959 /* Handle message-digest authentication */
5960 if (argv
[idx_encryption
]->arg
[0] == 'm') {
5961 SET_IF_PARAM(params
, auth_type
);
5962 params
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5966 vty_out(vty
, "You shouldn't get here!\n");
5967 return CMD_WARNING_CONFIG_FAILED
;
5970 DEFUN (ip_ospf_authentication
,
5971 ip_ospf_authentication_addr_cmd
,
5972 "ip ospf authentication [A.B.C.D]",
5974 "OSPF interface commands\n"
5975 "Enable authentication on this interface\n"
5976 "Address of interface")
5978 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5980 struct in_addr addr
;
5982 struct ospf_if_params
*params
;
5984 params
= IF_DEF_PARAMS(ifp
);
5987 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5990 "Please specify interface address by A.B.C.D\n");
5991 return CMD_WARNING_CONFIG_FAILED
;
5994 params
= ospf_get_if_params(ifp
, addr
);
5995 ospf_if_update_params(ifp
, addr
);
5998 SET_IF_PARAM(params
, auth_type
);
5999 params
->auth_type
= OSPF_AUTH_SIMPLE
;
6004 DEFUN (no_ip_ospf_authentication_args
,
6005 no_ip_ospf_authentication_args_addr_cmd
,
6006 "no ip ospf authentication <null|message-digest> [A.B.C.D]",
6009 "OSPF interface commands\n"
6010 "Enable authentication on this interface\n"
6011 "Use null authentication\n"
6012 "Use message-digest authentication\n"
6013 "Address of interface")
6015 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6016 int idx_encryption
= 4;
6018 struct in_addr addr
;
6020 struct ospf_if_params
*params
;
6021 struct route_node
*rn
;
6024 params
= IF_DEF_PARAMS(ifp
);
6027 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6030 "Please specify interface address by A.B.C.D\n");
6031 return CMD_WARNING_CONFIG_FAILED
;
6034 params
= ospf_lookup_if_params(ifp
, addr
);
6035 if (params
== NULL
) {
6036 vty_out(vty
, "Ip Address specified is unknown\n");
6037 return CMD_WARNING_CONFIG_FAILED
;
6039 params
->auth_type
= OSPF_AUTH_NOTSET
;
6040 UNSET_IF_PARAM(params
, auth_type
);
6041 if (params
!= IF_DEF_PARAMS(ifp
)) {
6042 ospf_free_if_params(ifp
, addr
);
6043 ospf_if_update_params(ifp
, addr
);
6046 if (argv
[idx_encryption
]->arg
[0] == 'n') {
6047 auth_type
= OSPF_AUTH_NULL
;
6048 } else if (argv
[idx_encryption
]->arg
[0] == 'm') {
6049 auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
6051 vty_out(vty
, "Unexpected input encountered\n");
6052 return CMD_WARNING_CONFIG_FAILED
;
6055 * Here we have a case where the user has entered
6056 * 'no ip ospf authentication (null | message_digest )'
6057 * we need to find if we have any ip addresses underneath it
6059 * correspond to the associated type.
6061 if (params
->auth_type
== auth_type
) {
6062 params
->auth_type
= OSPF_AUTH_NOTSET
;
6063 UNSET_IF_PARAM(params
, auth_type
);
6066 for (rn
= route_top(IF_OIFS_PARAMS(ifp
)); rn
;
6067 rn
= route_next(rn
)) {
6068 if ((params
= rn
->info
)) {
6069 if (params
->auth_type
== auth_type
) {
6070 params
->auth_type
= OSPF_AUTH_NOTSET
;
6071 UNSET_IF_PARAM(params
, auth_type
);
6072 if (params
!= IF_DEF_PARAMS(ifp
)) {
6073 ospf_free_if_params(
6074 ifp
, rn
->p
.u
.prefix4
);
6075 ospf_if_update_params(
6076 ifp
, rn
->p
.u
.prefix4
);
6086 DEFUN (no_ip_ospf_authentication
,
6087 no_ip_ospf_authentication_addr_cmd
,
6088 "no ip ospf authentication [A.B.C.D]",
6091 "OSPF interface commands\n"
6092 "Enable authentication on this interface\n"
6093 "Address of interface")
6095 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6097 struct in_addr addr
;
6099 struct ospf_if_params
*params
;
6100 struct route_node
*rn
;
6102 params
= IF_DEF_PARAMS(ifp
);
6105 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6108 "Please specify interface address by A.B.C.D\n");
6109 return CMD_WARNING_CONFIG_FAILED
;
6112 params
= ospf_lookup_if_params(ifp
, addr
);
6113 if (params
== NULL
) {
6114 vty_out(vty
, "Ip Address specified is unknown\n");
6115 return CMD_WARNING_CONFIG_FAILED
;
6118 params
->auth_type
= OSPF_AUTH_NOTSET
;
6119 UNSET_IF_PARAM(params
, auth_type
);
6120 if (params
!= IF_DEF_PARAMS(ifp
)) {
6121 ospf_free_if_params(ifp
, addr
);
6122 ospf_if_update_params(ifp
, addr
);
6126 * When a user enters 'no ip ospf authentication'
6127 * We should remove all authentication types from
6130 if ((params
->auth_type
== OSPF_AUTH_NULL
)
6131 || (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
6132 || (params
->auth_type
== OSPF_AUTH_SIMPLE
)) {
6133 params
->auth_type
= OSPF_AUTH_NOTSET
;
6134 UNSET_IF_PARAM(params
, auth_type
);
6137 for (rn
= route_top(IF_OIFS_PARAMS(ifp
)); rn
;
6138 rn
= route_next(rn
)) {
6139 if ((params
= rn
->info
)) {
6141 if ((params
->auth_type
== OSPF_AUTH_NULL
)
6142 || (params
->auth_type
6143 == OSPF_AUTH_CRYPTOGRAPHIC
)
6144 || (params
->auth_type
6145 == OSPF_AUTH_SIMPLE
)) {
6146 params
->auth_type
= OSPF_AUTH_NOTSET
;
6147 UNSET_IF_PARAM(params
, auth_type
);
6148 if (params
!= IF_DEF_PARAMS(ifp
)) {
6149 ospf_free_if_params(
6150 ifp
, rn
->p
.u
.prefix4
);
6151 ospf_if_update_params(
6152 ifp
, rn
->p
.u
.prefix4
);
6163 DEFUN (ip_ospf_authentication_key
,
6164 ip_ospf_authentication_key_addr_cmd
,
6165 "ip ospf authentication-key AUTH_KEY [A.B.C.D]",
6167 "OSPF interface commands\n"
6168 "Authentication password (key)\n"
6169 "The OSPF password (key)\n"
6170 "Address of interface")
6172 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6174 struct in_addr addr
;
6175 struct ospf_if_params
*params
;
6177 params
= IF_DEF_PARAMS(ifp
);
6179 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6180 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6182 "Please specify interface address by A.B.C.D\n");
6183 return CMD_WARNING_CONFIG_FAILED
;
6186 params
= ospf_get_if_params(ifp
, addr
);
6187 ospf_if_update_params(ifp
, addr
);
6190 memset(params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
6191 strncpy((char *)params
->auth_simple
, argv
[3]->arg
,
6192 OSPF_AUTH_SIMPLE_SIZE
);
6193 SET_IF_PARAM(params
, auth_simple
);
6198 DEFUN_HIDDEN (ospf_authentication_key
,
6199 ospf_authentication_key_cmd
,
6200 "ospf authentication-key AUTH_KEY [A.B.C.D]",
6201 "OSPF interface commands\n"
6202 VLINK_HELPSTR_AUTH_SIMPLE
6203 "Address of interface\n")
6205 return ip_ospf_authentication_key(self
, vty
, argc
, argv
);
6208 DEFUN (no_ip_ospf_authentication_key
,
6209 no_ip_ospf_authentication_key_authkey_addr_cmd
,
6210 "no ip ospf authentication-key [AUTH_KEY [A.B.C.D]]",
6213 "OSPF interface commands\n"
6214 VLINK_HELPSTR_AUTH_SIMPLE
6215 "Address of interface\n")
6217 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6219 struct in_addr addr
;
6220 struct ospf_if_params
*params
;
6221 params
= IF_DEF_PARAMS(ifp
);
6223 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6224 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6226 "Please specify interface address by A.B.C.D\n");
6227 return CMD_WARNING_CONFIG_FAILED
;
6230 params
= ospf_lookup_if_params(ifp
, addr
);
6235 memset(params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
);
6236 UNSET_IF_PARAM(params
, auth_simple
);
6238 if (params
!= IF_DEF_PARAMS(ifp
)) {
6239 ospf_free_if_params(ifp
, addr
);
6240 ospf_if_update_params(ifp
, addr
);
6246 DEFUN_HIDDEN (no_ospf_authentication_key
,
6247 no_ospf_authentication_key_authkey_addr_cmd
,
6248 "no ospf authentication-key [AUTH_KEY [A.B.C.D]]",
6250 "OSPF interface commands\n"
6251 VLINK_HELPSTR_AUTH_SIMPLE
6252 "Address of interface\n")
6254 return no_ip_ospf_authentication_key(self
, vty
, argc
, argv
);
6257 DEFUN (ip_ospf_message_digest_key
,
6258 ip_ospf_message_digest_key_cmd
,
6259 "ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
6261 "OSPF interface commands\n"
6262 "Message digest authentication password (key)\n"
6264 "Use MD5 algorithm\n"
6265 "The OSPF password (key)\n"
6266 "Address of interface\n")
6268 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6269 struct crypt_key
*ck
;
6271 struct in_addr addr
;
6272 struct ospf_if_params
*params
;
6274 params
= IF_DEF_PARAMS(ifp
);
6277 argv_find(argv
, argc
, "(1-255)", &idx
);
6278 char *keyid
= argv
[idx
]->arg
;
6279 argv_find(argv
, argc
, "KEY", &idx
);
6280 char *cryptkey
= argv
[idx
]->arg
;
6282 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6283 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6285 "Please specify interface address by A.B.C.D\n");
6286 return CMD_WARNING_CONFIG_FAILED
;
6289 params
= ospf_get_if_params(ifp
, addr
);
6290 ospf_if_update_params(ifp
, addr
);
6293 key_id
= strtol(keyid
, NULL
, 10);
6294 if (ospf_crypt_key_lookup(params
->auth_crypt
, key_id
) != NULL
) {
6295 vty_out(vty
, "OSPF: Key %d already exists\n", key_id
);
6299 ck
= ospf_crypt_key_new();
6300 ck
->key_id
= (u_char
)key_id
;
6301 memset(ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+ 1);
6302 strncpy((char *)ck
->auth_key
, cryptkey
, OSPF_AUTH_MD5_SIZE
);
6304 ospf_crypt_key_add(params
->auth_crypt
, ck
);
6305 SET_IF_PARAM(params
, auth_crypt
);
6310 DEFUN_HIDDEN (ospf_message_digest_key
,
6311 ospf_message_digest_key_cmd
,
6312 "ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
6313 "OSPF interface commands\n"
6314 "Message digest authentication password (key)\n"
6316 "Use MD5 algorithm\n"
6317 "The OSPF password (key)\n"
6318 "Address of interface\n")
6320 return ip_ospf_message_digest_key(self
, vty
, argc
, argv
);
6323 DEFUN (no_ip_ospf_message_digest_key
,
6324 no_ip_ospf_message_digest_key_cmd
,
6325 "no ip ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
6328 "OSPF interface commands\n"
6329 "Message digest authentication password (key)\n"
6331 "Use MD5 algorithm\n"
6332 "The OSPF password (key)\n"
6333 "Address of interface\n")
6335 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6337 struct crypt_key
*ck
;
6339 struct in_addr addr
;
6340 struct ospf_if_params
*params
;
6341 params
= IF_DEF_PARAMS(ifp
);
6343 argv_find(argv
, argc
, "(1-255)", &idx
);
6344 char *keyid
= argv
[idx
]->arg
;
6346 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6347 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6349 "Please specify interface address by A.B.C.D\n");
6350 return CMD_WARNING_CONFIG_FAILED
;
6353 params
= ospf_lookup_if_params(ifp
, addr
);
6358 key_id
= strtol(keyid
, NULL
, 10);
6359 ck
= ospf_crypt_key_lookup(params
->auth_crypt
, key_id
);
6361 vty_out(vty
, "OSPF: Key %d does not exist\n", key_id
);
6362 return CMD_WARNING_CONFIG_FAILED
;
6365 ospf_crypt_key_delete(params
->auth_crypt
, key_id
);
6367 if (params
!= IF_DEF_PARAMS(ifp
)) {
6368 ospf_free_if_params(ifp
, addr
);
6369 ospf_if_update_params(ifp
, addr
);
6375 DEFUN_HIDDEN (no_ospf_message_digest_key
,
6376 no_ospf_message_digest_key_cmd
,
6377 "no ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
6379 "OSPF interface commands\n"
6380 "Message digest authentication password (key)\n"
6382 "Address of interface")
6384 return no_ip_ospf_message_digest_key(self
, vty
, argc
, argv
);
6387 DEFUN (ip_ospf_cost
,
6389 "ip ospf cost (1-65535) [A.B.C.D]",
6391 "OSPF interface commands\n"
6394 "Address of interface\n")
6396 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6398 u_int32_t cost
= OSPF_OUTPUT_COST_DEFAULT
;
6399 struct in_addr addr
;
6400 struct ospf_if_params
*params
;
6401 params
= IF_DEF_PARAMS(ifp
);
6404 char *coststr
= NULL
, *ifaddr
= NULL
;
6406 argv_find(argv
, argc
, "(1-65535)", &idx
);
6407 coststr
= argv
[idx
]->arg
;
6408 cost
= strtol(coststr
, NULL
, 10);
6410 ifaddr
= argv_find(argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6412 if (!inet_aton(ifaddr
, &addr
)) {
6414 "Please specify interface address by A.B.C.D\n");
6415 return CMD_WARNING_CONFIG_FAILED
;
6418 params
= ospf_get_if_params(ifp
, addr
);
6419 ospf_if_update_params(ifp
, addr
);
6422 SET_IF_PARAM(params
, output_cost_cmd
);
6423 params
->output_cost_cmd
= cost
;
6425 ospf_if_recalculate_output_cost(ifp
);
6430 DEFUN_HIDDEN (ospf_cost
,
6432 "ospf cost (1-65535) [A.B.C.D]",
6433 "OSPF interface commands\n"
6436 "Address of interface\n")
6438 return ip_ospf_cost(self
, vty
, argc
, argv
);
6441 DEFUN (no_ip_ospf_cost
,
6442 no_ip_ospf_cost_cmd
,
6443 "no ip ospf cost [(1-65535)] [A.B.C.D]",
6445 "OSPF interface commands\n"
6447 "Address of interface")
6449 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6451 struct in_addr addr
;
6452 struct ospf_if_params
*params
;
6454 params
= IF_DEF_PARAMS(ifp
);
6457 char *ifaddr
= NULL
;
6458 ifaddr
= argv_find(argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6460 /* According to the semantics we are mimicking "no ip ospf cost N" is
6461 * always treated as "no ip ospf cost" regardless of the actual value
6462 * of N already configured for the interface. Thus ignore cost. */
6465 if (!inet_aton(ifaddr
, &addr
)) {
6467 "Please specify interface address by A.B.C.D\n");
6468 return CMD_WARNING_CONFIG_FAILED
;
6471 params
= ospf_lookup_if_params(ifp
, addr
);
6476 UNSET_IF_PARAM(params
, output_cost_cmd
);
6478 if (params
!= IF_DEF_PARAMS(ifp
)) {
6479 ospf_free_if_params(ifp
, addr
);
6480 ospf_if_update_params(ifp
, addr
);
6483 ospf_if_recalculate_output_cost(ifp
);
6488 DEFUN_HIDDEN (no_ospf_cost
,
6490 "no ospf cost [(1-65535)] [A.B.C.D]",
6492 "OSPF interface commands\n"
6495 "Address of interface\n")
6497 return no_ip_ospf_cost(self
, vty
, argc
, argv
);
6500 static void ospf_nbr_timer_update(struct ospf_interface
*oi
)
6502 struct route_node
*rn
;
6503 struct ospf_neighbor
*nbr
;
6505 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
))
6506 if ((nbr
= rn
->info
)) {
6507 nbr
->v_inactivity
= OSPF_IF_PARAM(oi
, v_wait
);
6508 nbr
->v_db_desc
= OSPF_IF_PARAM(oi
, retransmit_interval
);
6509 nbr
->v_ls_req
= OSPF_IF_PARAM(oi
, retransmit_interval
);
6510 nbr
->v_ls_upd
= OSPF_IF_PARAM(oi
, retransmit_interval
);
6514 static int ospf_vty_dead_interval_set(struct vty
*vty
, const char *interval_str
,
6515 const char *nbr_str
,
6516 const char *fast_hello_str
)
6518 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6521 struct in_addr addr
;
6523 struct ospf_if_params
*params
;
6524 struct ospf_interface
*oi
;
6525 struct route_node
*rn
;
6527 params
= IF_DEF_PARAMS(ifp
);
6530 ret
= inet_aton(nbr_str
, &addr
);
6533 "Please specify interface address by A.B.C.D\n");
6534 return CMD_WARNING_CONFIG_FAILED
;
6537 params
= ospf_get_if_params(ifp
, addr
);
6538 ospf_if_update_params(ifp
, addr
);
6542 seconds
= strtoul(interval_str
, NULL
, 10);
6544 /* reset fast_hello too, just to be sure */
6545 UNSET_IF_PARAM(params
, fast_hello
);
6546 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6547 } else if (fast_hello_str
) {
6548 hellomult
= strtoul(fast_hello_str
, NULL
, 10);
6549 /* 1s dead-interval with sub-second hellos desired */
6550 seconds
= OSPF_ROUTER_DEAD_INTERVAL_MINIMAL
;
6551 SET_IF_PARAM(params
, fast_hello
);
6552 params
->fast_hello
= hellomult
;
6555 "Please specify dead-interval or hello-multiplier\n");
6556 return CMD_WARNING_CONFIG_FAILED
;
6559 SET_IF_PARAM(params
, v_wait
);
6560 params
->v_wait
= seconds
;
6562 /* Update timer values in neighbor structure. */
6564 struct ospf
*ospf
= NULL
;
6566 ospf
= ospf_lookup_by_vrf_id(ifp
->vrf_id
);
6568 oi
= ospf_if_lookup_by_local_addr(ospf
, ifp
, addr
);
6570 ospf_nbr_timer_update(oi
);
6573 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
))
6574 if ((oi
= rn
->info
))
6575 ospf_nbr_timer_update(oi
);
6581 DEFUN (ip_ospf_dead_interval
,
6582 ip_ospf_dead_interval_cmd
,
6583 "ip ospf dead-interval (1-65535) [A.B.C.D]",
6585 "OSPF interface commands\n"
6586 "Interval time after which a neighbor is declared down\n"
6588 "Address of interface\n")
6591 char *interval
= argv_find(argv
, argc
, "(1-65535)", &idx
)
6595 argv_find(argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6596 return ospf_vty_dead_interval_set(vty
, interval
, ifaddr
, NULL
);
6600 DEFUN_HIDDEN (ospf_dead_interval
,
6601 ospf_dead_interval_cmd
,
6602 "ospf dead-interval (1-65535) [A.B.C.D]",
6603 "OSPF interface commands\n"
6604 "Interval time after which a neighbor is declared down\n"
6606 "Address of interface\n")
6608 return ip_ospf_dead_interval(self
, vty
, argc
, argv
);
6611 DEFUN (ip_ospf_dead_interval_minimal
,
6612 ip_ospf_dead_interval_minimal_addr_cmd
,
6613 "ip ospf dead-interval minimal hello-multiplier (1-10) [A.B.C.D]",
6615 "OSPF interface commands\n"
6616 "Interval time after which a neighbor is declared down\n"
6617 "Minimal 1s dead-interval with fast sub-second hellos\n"
6618 "Hello multiplier factor\n"
6619 "Number of Hellos to send each second\n"
6620 "Address of interface\n")
6625 return ospf_vty_dead_interval_set(
6626 vty
, NULL
, argv
[idx_ipv4
]->arg
, argv
[idx_number
]->arg
);
6628 return ospf_vty_dead_interval_set(vty
, NULL
, NULL
,
6629 argv
[idx_number
]->arg
);
6632 DEFUN (no_ip_ospf_dead_interval
,
6633 no_ip_ospf_dead_interval_cmd
,
6634 "no ip ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6637 "OSPF interface commands\n"
6638 "Interval time after which a neighbor is declared down\n"
6640 "Address of interface")
6642 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6643 int idx_ipv4
= argc
- 1;
6644 struct in_addr addr
= {.s_addr
= 0L};
6646 struct ospf_if_params
*params
;
6647 struct ospf_interface
*oi
;
6648 struct route_node
*rn
;
6650 params
= IF_DEF_PARAMS(ifp
);
6652 if (argv
[idx_ipv4
]->type
== IPV4_TKN
) {
6653 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6656 "Please specify interface address by A.B.C.D\n");
6657 return CMD_WARNING_CONFIG_FAILED
;
6660 params
= ospf_lookup_if_params(ifp
, addr
);
6665 UNSET_IF_PARAM(params
, v_wait
);
6666 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
6668 UNSET_IF_PARAM(params
, fast_hello
);
6669 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6671 if (params
!= IF_DEF_PARAMS(ifp
)) {
6672 ospf_free_if_params(ifp
, addr
);
6673 ospf_if_update_params(ifp
, addr
);
6676 /* Update timer values in neighbor structure. */
6678 struct ospf
*ospf
= NULL
;
6680 ospf
= ospf_lookup_by_vrf_id(ifp
->vrf_id
);
6682 oi
= ospf_if_lookup_by_local_addr(ospf
, ifp
, addr
);
6684 ospf_nbr_timer_update(oi
);
6687 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
))
6688 if ((oi
= rn
->info
))
6689 ospf_nbr_timer_update(oi
);
6695 DEFUN_HIDDEN (no_ospf_dead_interval
,
6696 no_ospf_dead_interval_cmd
,
6697 "no ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6699 "OSPF interface commands\n"
6700 "Interval time after which a neighbor is declared down\n"
6702 "Address of interface")
6704 return no_ip_ospf_dead_interval(self
, vty
, argc
, argv
);
6707 DEFUN (ip_ospf_hello_interval
,
6708 ip_ospf_hello_interval_cmd
,
6709 "ip ospf hello-interval (1-65535) [A.B.C.D]",
6711 "OSPF interface commands\n"
6712 "Time between HELLO packets\n"
6714 "Address of interface\n")
6716 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6718 struct in_addr addr
;
6719 struct ospf_if_params
*params
;
6720 params
= IF_DEF_PARAMS(ifp
);
6721 u_int32_t seconds
= 0;
6723 argv_find(argv
, argc
, "(1-65535)", &idx
);
6724 seconds
= strtol(argv
[idx
]->arg
, NULL
, 10);
6726 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6727 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6729 "Please specify interface address by A.B.C.D\n");
6730 return CMD_WARNING_CONFIG_FAILED
;
6733 params
= ospf_get_if_params(ifp
, addr
);
6734 ospf_if_update_params(ifp
, addr
);
6737 SET_IF_PARAM(params
, v_hello
);
6738 params
->v_hello
= seconds
;
6743 DEFUN_HIDDEN (ospf_hello_interval
,
6744 ospf_hello_interval_cmd
,
6745 "ospf hello-interval (1-65535) [A.B.C.D]",
6746 "OSPF interface commands\n"
6747 "Time between HELLO packets\n"
6749 "Address of interface\n")
6751 return ip_ospf_hello_interval(self
, vty
, argc
, argv
);
6754 DEFUN (no_ip_ospf_hello_interval
,
6755 no_ip_ospf_hello_interval_cmd
,
6756 "no ip ospf hello-interval [(1-65535) [A.B.C.D]]",
6759 "OSPF interface commands\n"
6760 "Time between HELLO packets\n" // ignored
6762 "Address of interface\n")
6764 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6766 struct in_addr addr
;
6767 struct ospf_if_params
*params
;
6769 params
= IF_DEF_PARAMS(ifp
);
6771 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6772 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6774 "Please specify interface address by A.B.C.D\n");
6775 return CMD_WARNING_CONFIG_FAILED
;
6778 params
= ospf_lookup_if_params(ifp
, addr
);
6783 UNSET_IF_PARAM(params
, v_hello
);
6784 params
->v_hello
= OSPF_HELLO_INTERVAL_DEFAULT
;
6786 if (params
!= IF_DEF_PARAMS(ifp
)) {
6787 ospf_free_if_params(ifp
, addr
);
6788 ospf_if_update_params(ifp
, addr
);
6794 DEFUN_HIDDEN (no_ospf_hello_interval
,
6795 no_ospf_hello_interval_cmd
,
6796 "no ospf hello-interval [(1-65535) [A.B.C.D]]",
6798 "OSPF interface commands\n"
6799 "Time between HELLO packets\n" // ignored
6801 "Address of interface\n")
6803 return no_ip_ospf_hello_interval(self
, vty
, argc
, argv
);
6806 DEFUN (ip_ospf_network
,
6807 ip_ospf_network_cmd
,
6808 "ip ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
6810 "OSPF interface commands\n"
6812 "Specify OSPF broadcast multi-access network\n"
6813 "Specify OSPF NBMA network\n"
6814 "Specify OSPF point-to-multipoint network\n"
6815 "Specify OSPF point-to-point network\n")
6817 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6819 int old_type
= IF_DEF_PARAMS(ifp
)->type
;
6820 struct route_node
*rn
;
6822 if (old_type
== OSPF_IFTYPE_LOOPBACK
) {
6824 "This is a loopback interface. Can't set network type.\n");
6825 return CMD_WARNING_CONFIG_FAILED
;
6828 if (argv_find(argv
, argc
, "broadcast", &idx
))
6829 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_BROADCAST
;
6830 else if (argv_find(argv
, argc
, "non-broadcast", &idx
))
6831 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_NBMA
;
6832 else if (argv_find(argv
, argc
, "point-to-multipoint", &idx
))
6833 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_POINTOMULTIPOINT
;
6834 else if (argv_find(argv
, argc
, "point-to-point", &idx
))
6835 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_POINTOPOINT
;
6837 if (IF_DEF_PARAMS(ifp
)->type
== old_type
)
6840 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), type
);
6842 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
6843 struct ospf_interface
*oi
= rn
->info
;
6848 oi
->type
= IF_DEF_PARAMS(ifp
)->type
;
6850 if (oi
->state
> ISM_Down
) {
6851 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceDown
);
6852 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceUp
);
6859 DEFUN_HIDDEN (ospf_network
,
6861 "ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
6862 "OSPF interface commands\n"
6864 "Specify OSPF broadcast multi-access network\n"
6865 "Specify OSPF NBMA network\n"
6866 "Specify OSPF point-to-multipoint network\n"
6867 "Specify OSPF point-to-point network\n")
6869 return ip_ospf_network(self
, vty
, argc
, argv
);
6872 DEFUN (no_ip_ospf_network
,
6873 no_ip_ospf_network_cmd
,
6874 "no ip ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
6877 "OSPF interface commands\n"
6879 "Specify OSPF broadcast multi-access network\n"
6880 "Specify OSPF NBMA network\n"
6881 "Specify OSPF point-to-multipoint network\n"
6882 "Specify OSPF point-to-point network\n")
6884 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6885 int old_type
= IF_DEF_PARAMS(ifp
)->type
;
6886 struct route_node
*rn
;
6888 IF_DEF_PARAMS(ifp
)->type
= ospf_default_iftype(ifp
);
6890 if (IF_DEF_PARAMS(ifp
)->type
== old_type
)
6893 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
6894 struct ospf_interface
*oi
= rn
->info
;
6899 oi
->type
= IF_DEF_PARAMS(ifp
)->type
;
6901 if (oi
->state
> ISM_Down
) {
6902 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceDown
);
6903 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceUp
);
6910 DEFUN_HIDDEN (no_ospf_network
,
6911 no_ospf_network_cmd
,
6912 "no ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
6914 "OSPF interface commands\n"
6916 "Specify OSPF broadcast multi-access network\n"
6917 "Specify OSPF NBMA network\n"
6918 "Specify OSPF point-to-multipoint network\n"
6919 "Specify OSPF point-to-point network\n")
6921 return no_ip_ospf_network(self
, vty
, argc
, argv
);
6924 DEFUN (ip_ospf_priority
,
6925 ip_ospf_priority_cmd
,
6926 "ip ospf priority (0-255) [A.B.C.D]",
6928 "OSPF interface commands\n"
6931 "Address of interface")
6933 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6936 struct route_node
*rn
;
6937 struct in_addr addr
;
6938 struct ospf_if_params
*params
;
6939 params
= IF_DEF_PARAMS(ifp
);
6941 argv_find(argv
, argc
, "(0-255)", &idx
);
6942 priority
= strtol(argv
[idx
]->arg
, NULL
, 10);
6944 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6945 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6947 "Please specify interface address by A.B.C.D\n");
6948 return CMD_WARNING_CONFIG_FAILED
;
6951 params
= ospf_get_if_params(ifp
, addr
);
6952 ospf_if_update_params(ifp
, addr
);
6955 SET_IF_PARAM(params
, priority
);
6956 params
->priority
= priority
;
6958 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
6959 struct ospf_interface
*oi
= rn
->info
;
6964 if (PRIORITY(oi
) != OSPF_IF_PARAM(oi
, priority
)) {
6965 PRIORITY(oi
) = OSPF_IF_PARAM(oi
, priority
);
6966 OSPF_ISM_EVENT_SCHEDULE(oi
, ISM_NeighborChange
);
6973 DEFUN_HIDDEN (ospf_priority
,
6975 "ospf priority (0-255) [A.B.C.D]",
6976 "OSPF interface commands\n"
6979 "Address of interface")
6981 return ip_ospf_priority(self
, vty
, argc
, argv
);
6984 DEFUN (no_ip_ospf_priority
,
6985 no_ip_ospf_priority_cmd
,
6986 "no ip ospf priority [(0-255) [A.B.C.D]]",
6989 "OSPF interface commands\n"
6990 "Router priority\n" // ignored
6992 "Address of interface")
6994 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6996 struct route_node
*rn
;
6997 struct in_addr addr
;
6998 struct ospf_if_params
*params
;
7000 params
= IF_DEF_PARAMS(ifp
);
7002 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7003 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7005 "Please specify interface address by A.B.C.D\n");
7006 return CMD_WARNING_CONFIG_FAILED
;
7009 params
= ospf_lookup_if_params(ifp
, addr
);
7014 UNSET_IF_PARAM(params
, priority
);
7015 params
->priority
= OSPF_ROUTER_PRIORITY_DEFAULT
;
7017 if (params
!= IF_DEF_PARAMS(ifp
)) {
7018 ospf_free_if_params(ifp
, addr
);
7019 ospf_if_update_params(ifp
, addr
);
7022 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
7023 struct ospf_interface
*oi
= rn
->info
;
7028 if (PRIORITY(oi
) != OSPF_IF_PARAM(oi
, priority
)) {
7029 PRIORITY(oi
) = OSPF_IF_PARAM(oi
, priority
);
7030 OSPF_ISM_EVENT_SCHEDULE(oi
, ISM_NeighborChange
);
7037 DEFUN_HIDDEN (no_ospf_priority
,
7038 no_ospf_priority_cmd
,
7039 "no ospf priority [(0-255) [A.B.C.D]]",
7041 "OSPF interface commands\n"
7044 "Address of interface")
7046 return no_ip_ospf_priority(self
, vty
, argc
, argv
);
7049 DEFUN (ip_ospf_retransmit_interval
,
7050 ip_ospf_retransmit_interval_addr_cmd
,
7051 "ip ospf retransmit-interval (3-65535) [A.B.C.D]",
7053 "OSPF interface commands\n"
7054 "Time between retransmitting lost link state advertisements\n"
7056 "Address of interface")
7058 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7061 struct in_addr addr
;
7062 struct ospf_if_params
*params
;
7063 params
= IF_DEF_PARAMS(ifp
);
7065 argv_find(argv
, argc
, "(3-65535)", &idx
);
7066 seconds
= strtol(argv
[idx
]->arg
, NULL
, 10);
7068 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7069 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7071 "Please specify interface address by A.B.C.D\n");
7072 return CMD_WARNING_CONFIG_FAILED
;
7075 params
= ospf_get_if_params(ifp
, addr
);
7076 ospf_if_update_params(ifp
, addr
);
7079 SET_IF_PARAM(params
, retransmit_interval
);
7080 params
->retransmit_interval
= seconds
;
7085 DEFUN_HIDDEN (ospf_retransmit_interval
,
7086 ospf_retransmit_interval_cmd
,
7087 "ospf retransmit-interval (3-65535) [A.B.C.D]",
7088 "OSPF interface commands\n"
7089 "Time between retransmitting lost link state advertisements\n"
7091 "Address of interface")
7093 return ip_ospf_retransmit_interval(self
, vty
, argc
, argv
);
7096 DEFUN (no_ip_ospf_retransmit_interval
,
7097 no_ip_ospf_retransmit_interval_addr_cmd
,
7098 "no ip ospf retransmit-interval [(3-65535)] [A.B.C.D]",
7101 "OSPF interface commands\n"
7102 "Time between retransmitting lost link state advertisements\n"
7104 "Address of interface\n")
7106 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7108 struct in_addr addr
;
7109 struct ospf_if_params
*params
;
7111 params
= IF_DEF_PARAMS(ifp
);
7113 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7114 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7116 "Please specify interface address by A.B.C.D\n");
7117 return CMD_WARNING_CONFIG_FAILED
;
7120 params
= ospf_lookup_if_params(ifp
, addr
);
7125 UNSET_IF_PARAM(params
, retransmit_interval
);
7126 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
7128 if (params
!= IF_DEF_PARAMS(ifp
)) {
7129 ospf_free_if_params(ifp
, addr
);
7130 ospf_if_update_params(ifp
, addr
);
7136 DEFUN_HIDDEN (no_ospf_retransmit_interval
,
7137 no_ospf_retransmit_interval_cmd
,
7138 "no ospf retransmit-interval [(3-65535)] [A.B.C.D]",
7140 "OSPF interface commands\n"
7141 "Time between retransmitting lost link state advertisements\n"
7143 "Address of interface\n")
7145 return no_ip_ospf_retransmit_interval(self
, vty
, argc
, argv
);
7148 DEFUN (ip_ospf_transmit_delay
,
7149 ip_ospf_transmit_delay_addr_cmd
,
7150 "ip ospf transmit-delay (1-65535) [A.B.C.D]",
7152 "OSPF interface commands\n"
7153 "Link state transmit delay\n"
7155 "Address of interface")
7157 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7160 struct in_addr addr
;
7161 struct ospf_if_params
*params
;
7163 params
= IF_DEF_PARAMS(ifp
);
7164 argv_find(argv
, argc
, "(1-65535)", &idx
);
7165 seconds
= strtol(argv
[idx
]->arg
, NULL
, 10);
7167 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7168 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7170 "Please specify interface address by A.B.C.D\n");
7171 return CMD_WARNING_CONFIG_FAILED
;
7174 params
= ospf_get_if_params(ifp
, addr
);
7175 ospf_if_update_params(ifp
, addr
);
7178 SET_IF_PARAM(params
, transmit_delay
);
7179 params
->transmit_delay
= seconds
;
7184 DEFUN_HIDDEN (ospf_transmit_delay
,
7185 ospf_transmit_delay_cmd
,
7186 "ospf transmit-delay (1-65535) [A.B.C.D]",
7187 "OSPF interface commands\n"
7188 "Link state transmit delay\n"
7190 "Address of interface")
7192 return ip_ospf_transmit_delay(self
, vty
, argc
, argv
);
7195 DEFUN (no_ip_ospf_transmit_delay
,
7196 no_ip_ospf_transmit_delay_addr_cmd
,
7197 "no ip ospf transmit-delay [(1-65535)] [A.B.C.D]",
7200 "OSPF interface commands\n"
7201 "Link state transmit delay\n"
7202 "Address of interface")
7204 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7206 struct in_addr addr
;
7207 struct ospf_if_params
*params
;
7209 params
= IF_DEF_PARAMS(ifp
);
7211 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7212 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
7214 "Please specify interface address by A.B.C.D\n");
7215 return CMD_WARNING_CONFIG_FAILED
;
7218 params
= ospf_lookup_if_params(ifp
, addr
);
7223 UNSET_IF_PARAM(params
, transmit_delay
);
7224 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
7226 if (params
!= IF_DEF_PARAMS(ifp
)) {
7227 ospf_free_if_params(ifp
, addr
);
7228 ospf_if_update_params(ifp
, addr
);
7235 DEFUN_HIDDEN (no_ospf_transmit_delay
,
7236 no_ospf_transmit_delay_cmd
,
7237 "no ospf transmit-delay [(1-65535) [A.B.C.D]]",
7239 "OSPF interface commands\n"
7240 "Link state transmit delay\n"
7242 "Address of interface")
7244 return no_ip_ospf_transmit_delay(self
, vty
, argc
, argv
);
7247 DEFUN (ip_ospf_area
,
7249 "ip ospf [(1-65535)] area <A.B.C.D|(0-4294967295)> [A.B.C.D]",
7251 "OSPF interface commands\n"
7253 "Enable OSPF on this interface\n"
7254 "OSPF area ID in IP address format\n"
7255 "OSPF area ID as a decimal value\n"
7256 "Address of interface\n")
7258 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7261 struct in_addr area_id
;
7262 struct in_addr addr
;
7263 struct ospf_if_params
*params
= NULL
;
7264 struct route_node
*rn
;
7265 struct ospf
*ospf
= NULL
;
7266 u_short instance
= 0;
7269 if (argv_find(argv
, argc
, "(1-65535)", &idx
))
7270 instance
= strtol(argv
[idx
]->arg
, NULL
, 10);
7272 argv_find(argv
, argc
, "area", &idx
);
7273 areaid
= argv
[idx
+ 1]->arg
;
7275 if (ifp
->vrf_id
&& !instance
)
7276 ospf
= ospf_lookup_by_vrf_id(ifp
->vrf_id
);
7278 ospf
= ospf_lookup_instance(instance
);
7281 params
= IF_DEF_PARAMS(ifp
);
7282 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
7283 UNSET_IF_PARAM(params
, if_area
);
7284 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
7285 ospf_interface_area_unset(ospf
, ifp
);
7286 ospf
->if_ospf_cli_count
--;
7288 return CMD_NOT_MY_INSTANCE
;
7291 ret
= str2area_id(areaid
, &area_id
, &format
);
7293 vty_out(vty
, "Please specify area by A.B.C.D|<0-4294967295>\n");
7294 return CMD_WARNING_CONFIG_FAILED
;
7296 if (memcmp(ifp
->name
, "VLINK", 5) == 0) {
7297 vty_out(vty
, "Cannot enable OSPF on a virtual link.\n");
7298 return CMD_WARNING_CONFIG_FAILED
;
7301 params
= IF_DEF_PARAMS(ifp
);
7302 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)
7303 && !IPV4_ADDR_SAME(¶ms
->if_area
, &area_id
)) {
7305 "Must remove previous area config before changing ospf area \n");
7306 return CMD_WARNING_CONFIG_FAILED
;
7309 // Check if we have an address arg and proccess it
7310 if (argc
== idx
+ 3) {
7311 if (!inet_aton(argv
[idx
+ 2]->arg
, &addr
)) {
7312 vty_out(vty
, "Please specify Intf Address by A.B.C.D\n");
7313 return CMD_WARNING_CONFIG_FAILED
;
7315 // update/create address-level params
7316 params
= ospf_get_if_params((ifp
), (addr
));
7317 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
7319 "Must remove previous area/address config before changing ospf area");
7320 return CMD_WARNING_CONFIG_FAILED
;
7322 ospf_if_update_params((ifp
), (addr
));
7325 for (rn
= route_top(ospf
->networks
); rn
; rn
= route_next(rn
)) {
7326 if (rn
->info
!= NULL
) {
7328 "Please remove all network commands first.\n");
7329 return CMD_WARNING_CONFIG_FAILED
;
7333 /* enable ospf on this interface with area_id */
7335 SET_IF_PARAM(params
, if_area
);
7336 params
->if_area
= area_id
;
7337 params
->if_area_id_fmt
= format
;
7339 ospf_interface_area_set(ospf
, ifp
);
7340 ospf
->if_ospf_cli_count
++;
7345 DEFUN (no_ip_ospf_area
,
7346 no_ip_ospf_area_cmd
,
7347 "no ip ospf [(1-65535)] area [<A.B.C.D|(0-4294967295)> [A.B.C.D]]",
7350 "OSPF interface commands\n"
7352 "Disable OSPF on this interface\n"
7353 "OSPF area ID in IP address format\n"
7354 "OSPF area ID as a decimal value\n"
7355 "Address of interface\n")
7357 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7360 struct ospf_if_params
*params
;
7361 u_short instance
= 0;
7362 struct in_addr addr
;
7364 if (argv_find(argv
, argc
, "(1-65535)", &idx
))
7365 instance
= strtol(argv
[idx
]->arg
, NULL
, 10);
7367 if (ifp
->vrf_id
&& !instance
)
7368 ospf
= ospf_lookup_by_vrf_id(ifp
->vrf_id
);
7370 ospf
= ospf_lookup_instance(instance
);
7373 return CMD_NOT_MY_INSTANCE
;
7375 argv_find(argv
, argc
, "area", &idx
);
7377 // Check if we have an address arg and proccess it
7378 if (argc
== idx
+ 3) {
7379 if (!inet_aton(argv
[idx
+ 2]->arg
, &addr
)) {
7380 vty_out(vty
, "Please specify Intf Address by A.B.C.D\n");
7381 return CMD_WARNING_CONFIG_FAILED
;
7383 params
= ospf_lookup_if_params(ifp
, addr
);
7384 if ((params
) == NULL
)
7387 params
= IF_DEF_PARAMS(ifp
);
7389 if (!OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
7391 "Can't find specified interface area configuration.\n");
7392 return CMD_WARNING_CONFIG_FAILED
;
7395 UNSET_IF_PARAM(params
, if_area
);
7396 if (params
!= IF_DEF_PARAMS((ifp
))) {
7397 ospf_free_if_params((ifp
), (addr
));
7398 ospf_if_update_params((ifp
), (addr
));
7401 ospf_interface_area_unset(ospf
, ifp
);
7402 ospf
->if_ospf_cli_count
--;
7406 DEFUN (ospf_redistribute_source
,
7407 ospf_redistribute_source_cmd
,
7408 "redistribute " FRR_REDIST_STR_OSPFD
" [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7410 FRR_REDIST_HELP_STR_OSPFD
7411 "Metric for redistributed routes\n"
7412 "OSPF default metric\n"
7413 "OSPF exterior metric type for redistributed routes\n"
7414 "Set OSPF External Type 1/2 metrics\n"
7415 "Route map reference\n"
7416 "Pointer to route-map entries\n")
7418 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7419 int idx_protocol
= 1;
7423 struct ospf_redist
*red
;
7429 /* Get distribute source. */
7430 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
7432 return CMD_WARNING_CONFIG_FAILED
;
7434 red
= ospf_redist_add(ospf
, source
, 0);
7436 /* Get metric value. */
7437 if (argv_find(argv
, argc
, "(0-16777214)", &idx
)) {
7438 if (!str2metric(argv
[idx
]->arg
, &metric
))
7439 return CMD_WARNING_CONFIG_FAILED
;
7441 /* Get metric type. */
7442 else if (argv_find(argv
, argc
, "(1-2)", &idx
)) {
7443 if (!str2metric_type(argv
[idx
]->arg
, &type
))
7444 return CMD_WARNING_CONFIG_FAILED
;
7447 else if (argv_find(argv
, argc
, "WORD", &idx
)) {
7448 ospf_routemap_set(red
, argv
[idx
]->arg
);
7450 ospf_routemap_unset(red
);
7452 return ospf_redistribute_set(ospf
, source
, 0, type
, metric
);
7455 DEFUN (no_ospf_redistribute_source
,
7456 no_ospf_redistribute_source_cmd
,
7457 "no redistribute " FRR_REDIST_STR_OSPFD
" [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7460 FRR_REDIST_HELP_STR_OSPFD
7461 "Metric for redistributed routes\n"
7462 "OSPF default metric\n"
7463 "OSPF exterior metric type for redistributed routes\n"
7464 "Set OSPF External Type 1/2 metrics\n"
7465 "Route map reference\n"
7466 "Pointer to route-map entries\n")
7468 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7469 int idx_protocol
= 2;
7471 struct ospf_redist
*red
;
7473 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
7475 return CMD_WARNING_CONFIG_FAILED
;
7477 red
= ospf_redist_lookup(ospf
, source
, 0);
7481 ospf_routemap_unset(red
);
7482 return ospf_redistribute_unset(ospf
, source
, 0);
7485 DEFUN (ospf_redistribute_instance_source
,
7486 ospf_redistribute_instance_source_cmd
,
7487 "redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
7489 "Open Shortest Path First\n"
7490 "Non-main Kernel Routing Table\n"
7491 "Instance ID/Table ID\n"
7492 "Metric for redistributed routes\n"
7493 "OSPF default metric\n"
7494 "OSPF exterior metric type for redistributed routes\n"
7495 "Set OSPF External Type 1/2 metrics\n"
7496 "Route map reference\n"
7497 "Pointer to route-map entries\n")
7499 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7500 int idx_ospf_table
= 1;
7507 struct ospf_redist
*red
;
7512 source
= proto_redistnum(AFI_IP
, argv
[idx_ospf_table
]->text
);
7514 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7519 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
) {
7521 "Instance redistribution in non-instanced OSPF not allowed\n");
7522 return CMD_WARNING_CONFIG_FAILED
;
7525 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
)) {
7526 vty_out(vty
, "Same instance OSPF redistribution not allowed\n");
7527 return CMD_WARNING_CONFIG_FAILED
;
7530 /* Get metric value. */
7531 if (argv_find(argv
, argc
, "metric", &idx
))
7532 if (!str2metric(argv
[idx
+ 1]->arg
, &metric
))
7533 return CMD_WARNING_CONFIG_FAILED
;
7536 /* Get metric type. */
7537 if (argv_find(argv
, argc
, "metric-type", &idx
))
7538 if (!str2metric_type(argv
[idx
+ 1]->arg
, &type
))
7539 return CMD_WARNING_CONFIG_FAILED
;
7541 red
= ospf_redist_add(ospf
, source
, instance
);
7544 if (argv_find(argv
, argc
, "route-map", &idx
))
7545 ospf_routemap_set(red
, argv
[idx
+ 1]->arg
);
7547 ospf_routemap_unset(red
);
7549 return ospf_redistribute_set(ospf
, source
, instance
, type
, metric
);
7552 DEFUN (no_ospf_redistribute_instance_source
,
7553 no_ospf_redistribute_instance_source_cmd
,
7554 "no redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
7557 "Open Shortest Path First\n"
7558 "Non-main Kernel Routing Table\n"
7559 "Instance ID/Table Id\n"
7560 "Metric for redistributed routes\n"
7561 "OSPF default metric\n"
7562 "OSPF exterior metric type for redistributed routes\n"
7563 "Set OSPF External Type 1/2 metrics\n"
7564 "Route map reference\n"
7565 "Pointer to route-map entries\n")
7567 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7568 int idx_ospf_table
= 2;
7571 struct ospf_redist
*red
;
7574 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
7575 source
= ZEBRA_ROUTE_OSPF
;
7577 source
= ZEBRA_ROUTE_TABLE
;
7579 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7581 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
) {
7583 "Instance redistribution in non-instanced OSPF not allowed\n");
7584 return CMD_WARNING_CONFIG_FAILED
;
7587 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
)) {
7588 vty_out(vty
, "Same instance OSPF redistribution not allowed\n");
7589 return CMD_WARNING_CONFIG_FAILED
;
7592 red
= ospf_redist_lookup(ospf
, source
, instance
);
7596 ospf_routemap_unset(red
);
7597 return ospf_redistribute_unset(ospf
, source
, instance
);
7600 DEFUN (ospf_distribute_list_out
,
7601 ospf_distribute_list_out_cmd
,
7602 "distribute-list WORD out " FRR_REDIST_STR_OSPFD
,
7603 "Filter networks in routing updates\n"
7604 "Access-list name\n"
7606 FRR_REDIST_HELP_STR_OSPFD
)
7608 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7612 char *proto
= argv
[argc
- 1]->text
;
7614 /* Get distribute source. */
7615 source
= proto_redistnum(AFI_IP
, proto
);
7617 return CMD_WARNING_CONFIG_FAILED
;
7619 return ospf_distribute_list_out_set(ospf
, source
, argv
[idx_word
]->arg
);
7622 DEFUN (no_ospf_distribute_list_out
,
7623 no_ospf_distribute_list_out_cmd
,
7624 "no distribute-list WORD out " FRR_REDIST_STR_OSPFD
,
7626 "Filter networks in routing updates\n"
7627 "Access-list name\n"
7629 FRR_REDIST_HELP_STR_OSPFD
)
7631 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7635 char *proto
= argv
[argc
- 1]->text
;
7636 source
= proto_redistnum(AFI_IP
, proto
);
7638 return CMD_WARNING_CONFIG_FAILED
;
7640 return ospf_distribute_list_out_unset(ospf
, source
,
7641 argv
[idx_word
]->arg
);
7644 /* Default information originate. */
7645 DEFUN (ospf_default_information_originate
,
7646 ospf_default_information_originate_cmd
,
7647 "default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7648 "Control distribution of default information\n"
7649 "Distribute a default route\n"
7650 "Always advertise default route\n"
7651 "OSPF default metric\n"
7653 "OSPF metric type for default routes\n"
7654 "Set OSPF External Type 1/2 metrics\n"
7655 "Route map reference\n"
7656 "Pointer to route-map entries\n")
7658 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7659 int default_originate
= DEFAULT_ORIGINATE_ZEBRA
;
7662 struct ospf_redist
*red
;
7665 red
= ospf_redist_add(ospf
, DEFAULT_ROUTE
, 0);
7667 /* Check whether "always" was specified */
7668 if (argv_find(argv
, argc
, "always", &idx
))
7669 default_originate
= DEFAULT_ORIGINATE_ALWAYS
;
7670 /* Get metric value */
7671 else if (argv_find(argv
, argc
, "(0-16777214)", &idx
)) {
7672 if (!str2metric(argv
[idx
]->arg
, &metric
))
7673 return CMD_WARNING_CONFIG_FAILED
;
7675 /* Get metric type. */
7676 else if (argv_find(argv
, argc
, "(1-2)", &idx
)) {
7677 if (!str2metric_type(argv
[idx
]->arg
, &type
))
7678 return CMD_WARNING_CONFIG_FAILED
;
7681 else if (argv_find(argv
, argc
, "WORD", &idx
))
7682 ospf_routemap_set(red
, argv
[idx
]->arg
);
7684 ospf_routemap_unset(red
);
7686 return ospf_redistribute_default_set(ospf
, default_originate
, type
,
7690 DEFUN (no_ospf_default_information_originate
,
7691 no_ospf_default_information_originate_cmd
,
7692 "no default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7694 "Control distribution of default information\n"
7695 "Distribute a default route\n"
7696 "Always advertise default route\n"
7697 "OSPF default metric\n"
7699 "OSPF metric type for default routes\n"
7700 "Set OSPF External Type 1/2 metrics\n"
7701 "Route map reference\n"
7702 "Pointer to route-map entries\n")
7704 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7705 struct prefix_ipv4 p
;
7706 struct ospf_external
*ext
;
7707 struct ospf_redist
*red
;
7710 p
.prefix
.s_addr
= 0;
7713 ospf_external_lsa_flush(ospf
, DEFAULT_ROUTE
, &p
, 0);
7715 if ((ext
= ospf_external_lookup(DEFAULT_ROUTE
, 0))
7716 && EXTERNAL_INFO(ext
)) {
7717 ospf_external_info_delete(DEFAULT_ROUTE
, 0, p
);
7718 ospf_external_del(DEFAULT_ROUTE
, 0);
7721 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
7725 ospf_routemap_unset(red
);
7726 return ospf_redistribute_default_unset(ospf
);
7729 DEFUN (ospf_default_metric
,
7730 ospf_default_metric_cmd
,
7731 "default-metric (0-16777214)",
7732 "Set metric of redistributed routes\n"
7735 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7739 if (!str2metric(argv
[idx_number
]->arg
, &metric
))
7740 return CMD_WARNING_CONFIG_FAILED
;
7742 ospf
->default_metric
= metric
;
7747 DEFUN (no_ospf_default_metric
,
7748 no_ospf_default_metric_cmd
,
7749 "no default-metric [(0-16777214)]",
7751 "Set metric of redistributed routes\n"
7754 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7756 ospf
->default_metric
= -1;
7762 DEFUN (ospf_distance
,
7765 "Administrative distance\n"
7766 "OSPF Administrative distance\n")
7768 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7771 ospf
->distance_all
= atoi(argv
[idx_number
]->arg
);
7776 DEFUN (no_ospf_distance
,
7777 no_ospf_distance_cmd
,
7778 "no distance (1-255)",
7780 "Administrative distance\n"
7781 "OSPF Administrative distance\n")
7783 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7785 ospf
->distance_all
= 0;
7790 DEFUN (no_ospf_distance_ospf
,
7791 no_ospf_distance_ospf_cmd
,
7792 "no distance ospf [{intra-area [(1-255)]|inter-area [(1-255)]|external [(1-255)]}]",
7794 "Administrative distance\n"
7795 "OSPF administrative distance\n"
7796 "Intra-area routes\n"
7797 "Distance for intra-area routes\n"
7798 "Inter-area routes\n"
7799 "Distance for inter-area routes\n"
7801 "Distance for external routes\n")
7803 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7809 if (argv_find(argv
, argc
, "intra-area", &idx
) || argc
== 3)
7810 idx
= ospf
->distance_intra
= 0;
7811 if (argv_find(argv
, argc
, "inter-area", &idx
) || argc
== 3)
7812 idx
= ospf
->distance_inter
= 0;
7813 if (argv_find(argv
, argc
, "external", &idx
) || argc
== 3)
7814 ospf
->distance_external
= 0;
7819 DEFUN (ospf_distance_ospf
,
7820 ospf_distance_ospf_cmd
,
7821 "distance ospf {intra-area (1-255)|inter-area (1-255)|external (1-255)}",
7822 "Administrative distance\n"
7823 "OSPF administrative distance\n"
7824 "Intra-area routes\n"
7825 "Distance for intra-area routes\n"
7826 "Inter-area routes\n"
7827 "Distance for inter-area routes\n"
7829 "Distance for external routes\n")
7831 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7834 if (argv_find(argv
, argc
, "intra-area", &idx
))
7835 ospf
->distance_intra
= atoi(argv
[idx
+ 1]->arg
);
7837 if (argv_find(argv
, argc
, "inter-area", &idx
))
7838 ospf
->distance_inter
= atoi(argv
[idx
+ 1]->arg
);
7840 if (argv_find(argv
, argc
, "external", &idx
))
7841 ospf
->distance_external
= atoi(argv
[idx
+ 1]->arg
);
7847 DEFUN (ospf_distance_source
,
7848 ospf_distance_source_cmd
,
7849 "distance (1-255) A.B.C.D/M",
7850 "Administrative distance\n"
7852 "IP source prefix\n")
7854 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7856 int idx_ipv4_prefixlen
= 2;
7861 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
7866 DEFUN (no_ospf_distance_source
,
7867 no_ospf_distance_source_cmd
,
7868 "no distance (1-255) A.B.C.D/M",
7870 "Administrative distance\n"
7872 "IP source prefix\n")
7874 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7876 int idx_ipv4_prefixlen
= 3;
7881 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
7886 DEFUN (ospf_distance_source_access_list
,
7887 ospf_distance_source_access_list_cmd
,
7888 "distance (1-255) A.B.C.D/M WORD",
7889 "Administrative distance\n"
7891 "IP source prefix\n"
7892 "Access list name\n")
7894 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7896 int idx_ipv4_prefixlen
= 2;
7902 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
7907 DEFUN (no_ospf_distance_source_access_list
,
7908 no_ospf_distance_source_access_list_cmd
,
7909 "no distance (1-255) A.B.C.D/M WORD",
7911 "Administrative distance\n"
7913 "IP source prefix\n"
7914 "Access list name\n")
7916 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7918 int idx_ipv4_prefixlen
= 3;
7924 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
7930 DEFUN (ip_ospf_mtu_ignore
,
7931 ip_ospf_mtu_ignore_addr_cmd
,
7932 "ip ospf mtu-ignore [A.B.C.D]",
7934 "OSPF interface commands\n"
7935 "Disable MTU mismatch detection on this interface\n"
7936 "Address of interface")
7938 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7940 struct in_addr addr
;
7943 struct ospf_if_params
*params
;
7944 params
= IF_DEF_PARAMS(ifp
);
7947 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7950 "Please specify interface address by A.B.C.D\n");
7951 return CMD_WARNING_CONFIG_FAILED
;
7953 params
= ospf_get_if_params(ifp
, addr
);
7954 ospf_if_update_params(ifp
, addr
);
7956 params
->mtu_ignore
= 1;
7957 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
7958 SET_IF_PARAM(params
, mtu_ignore
);
7960 UNSET_IF_PARAM(params
, mtu_ignore
);
7961 if (params
!= IF_DEF_PARAMS(ifp
)) {
7962 ospf_free_if_params(ifp
, addr
);
7963 ospf_if_update_params(ifp
, addr
);
7969 DEFUN (no_ip_ospf_mtu_ignore
,
7970 no_ip_ospf_mtu_ignore_addr_cmd
,
7971 "no ip ospf mtu-ignore [A.B.C.D]",
7973 "OSPF interface commands\n"
7974 "Disable MTU mismatch detection on this interface\n"
7975 "Address of interface")
7977 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7979 struct in_addr addr
;
7982 struct ospf_if_params
*params
;
7983 params
= IF_DEF_PARAMS(ifp
);
7986 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7989 "Please specify interface address by A.B.C.D\n");
7990 return CMD_WARNING_CONFIG_FAILED
;
7992 params
= ospf_get_if_params(ifp
, addr
);
7993 ospf_if_update_params(ifp
, addr
);
7995 params
->mtu_ignore
= 0;
7996 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
7997 SET_IF_PARAM(params
, mtu_ignore
);
7999 UNSET_IF_PARAM(params
, mtu_ignore
);
8000 if (params
!= IF_DEF_PARAMS(ifp
)) {
8001 ospf_free_if_params(ifp
, addr
);
8002 ospf_if_update_params(ifp
, addr
);
8009 DEFUN (ospf_max_metric_router_lsa_admin
,
8010 ospf_max_metric_router_lsa_admin_cmd
,
8011 "max-metric router-lsa administrative",
8012 "OSPF maximum / infinite-distance metric\n"
8013 "Advertise own Router-LSA with infinite distance (stub router)\n"
8014 "Administratively applied, for an indefinite period\n")
8016 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8017 struct listnode
*ln
;
8018 struct ospf_area
*area
;
8020 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
8021 SET_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
8023 if (!CHECK_FLAG(area
->stub_router_state
,
8024 OSPF_AREA_IS_STUB_ROUTED
))
8025 ospf_router_lsa_update_area(area
);
8028 /* Allows for areas configured later to get the property */
8029 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_SET
;
8034 DEFUN (no_ospf_max_metric_router_lsa_admin
,
8035 no_ospf_max_metric_router_lsa_admin_cmd
,
8036 "no max-metric router-lsa administrative",
8038 "OSPF maximum / infinite-distance metric\n"
8039 "Advertise own Router-LSA with infinite distance (stub router)\n"
8040 "Administratively applied, for an indefinite period\n")
8042 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8043 struct listnode
*ln
;
8044 struct ospf_area
*area
;
8046 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
8047 UNSET_FLAG(area
->stub_router_state
,
8048 OSPF_AREA_ADMIN_STUB_ROUTED
);
8050 /* Don't trample on the start-up stub timer */
8051 if (CHECK_FLAG(area
->stub_router_state
,
8052 OSPF_AREA_IS_STUB_ROUTED
)
8053 && !area
->t_stub_router
) {
8054 UNSET_FLAG(area
->stub_router_state
,
8055 OSPF_AREA_IS_STUB_ROUTED
);
8056 ospf_router_lsa_update_area(area
);
8059 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET
;
8063 DEFUN (ospf_max_metric_router_lsa_startup
,
8064 ospf_max_metric_router_lsa_startup_cmd
,
8065 "max-metric router-lsa on-startup (5-86400)",
8066 "OSPF maximum / infinite-distance metric\n"
8067 "Advertise own Router-LSA with infinite distance (stub router)\n"
8068 "Automatically advertise stub Router-LSA on startup of OSPF\n"
8069 "Time (seconds) to advertise self as stub-router\n")
8071 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8073 unsigned int seconds
;
8076 vty_out(vty
, "%% Must supply stub-router period");
8077 return CMD_WARNING_CONFIG_FAILED
;
8080 seconds
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8082 ospf
->stub_router_startup_time
= seconds
;
8087 DEFUN (no_ospf_max_metric_router_lsa_startup
,
8088 no_ospf_max_metric_router_lsa_startup_cmd
,
8089 "no max-metric router-lsa on-startup [(5-86400)]",
8091 "OSPF maximum / infinite-distance metric\n"
8092 "Advertise own Router-LSA with infinite distance (stub router)\n"
8093 "Automatically advertise stub Router-LSA on startup of OSPF\n"
8094 "Time (seconds) to advertise self as stub-router\n")
8096 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8097 struct listnode
*ln
;
8098 struct ospf_area
*area
;
8100 ospf
->stub_router_startup_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
8102 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
8103 SET_FLAG(area
->stub_router_state
,
8104 OSPF_AREA_WAS_START_STUB_ROUTED
);
8105 OSPF_TIMER_OFF(area
->t_stub_router
);
8107 /* Don't trample on admin stub routed */
8108 if (!CHECK_FLAG(area
->stub_router_state
,
8109 OSPF_AREA_ADMIN_STUB_ROUTED
)) {
8110 UNSET_FLAG(area
->stub_router_state
,
8111 OSPF_AREA_IS_STUB_ROUTED
);
8112 ospf_router_lsa_update_area(area
);
8119 DEFUN (ospf_max_metric_router_lsa_shutdown
,
8120 ospf_max_metric_router_lsa_shutdown_cmd
,
8121 "max-metric router-lsa on-shutdown (5-100)",
8122 "OSPF maximum / infinite-distance metric\n"
8123 "Advertise own Router-LSA with infinite distance (stub router)\n"
8124 "Advertise stub-router prior to full shutdown of OSPF\n"
8125 "Time (seconds) to wait till full shutdown\n")
8127 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8129 unsigned int seconds
;
8132 vty_out(vty
, "%% Must supply stub-router shutdown period");
8133 return CMD_WARNING_CONFIG_FAILED
;
8136 seconds
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8138 ospf
->stub_router_shutdown_time
= seconds
;
8143 DEFUN (no_ospf_max_metric_router_lsa_shutdown
,
8144 no_ospf_max_metric_router_lsa_shutdown_cmd
,
8145 "no max-metric router-lsa on-shutdown [(5-100)]",
8147 "OSPF maximum / infinite-distance metric\n"
8148 "Advertise own Router-LSA with infinite distance (stub router)\n"
8149 "Advertise stub-router prior to full shutdown of OSPF\n"
8150 "Time (seconds) to wait till full shutdown\n")
8152 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
8154 ospf
->stub_router_shutdown_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
8159 static void config_write_stub_router(struct vty
*vty
, struct ospf
*ospf
)
8161 struct listnode
*ln
;
8162 struct ospf_area
*area
;
8164 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
8165 vty_out(vty
, " max-metric router-lsa on-startup %u\n",
8166 ospf
->stub_router_startup_time
);
8167 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
8168 vty_out(vty
, " max-metric router-lsa on-shutdown %u\n",
8169 ospf
->stub_router_shutdown_time
);
8170 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
8171 if (CHECK_FLAG(area
->stub_router_state
,
8172 OSPF_AREA_ADMIN_STUB_ROUTED
)) {
8173 vty_out(vty
, " max-metric router-lsa administrative\n");
8180 static void show_ip_ospf_route_network(struct vty
*vty
, struct ospf
*ospf
,
8181 struct route_table
*rt
)
8183 struct route_node
*rn
;
8184 struct ospf_route
* or ;
8185 struct listnode
*pnode
, *pnnode
;
8186 struct ospf_path
*path
;
8188 vty_out(vty
, "============ OSPF network routing table ============\n");
8190 for (rn
= route_top(rt
); rn
; rn
= route_next(rn
))
8191 if ((or = rn
->info
) != NULL
) {
8193 snprintf(buf1
, 19, "%s/%d", inet_ntoa(rn
->p
.u
.prefix4
),
8196 switch (or->path_type
) {
8197 case OSPF_PATH_INTER_AREA
:
8198 if (or->type
== OSPF_DESTINATION_NETWORK
)
8200 "N IA %-18s [%d] area: %s\n",
8202 inet_ntoa(or->u
.std
.area_id
));
8203 else if (or->type
== OSPF_DESTINATION_DISCARD
)
8205 "D IA %-18s Discard entry\n",
8208 case OSPF_PATH_INTRA_AREA
:
8209 vty_out(vty
, "N %-18s [%d] area: %s\n",
8211 inet_ntoa(or->u
.std
.area_id
));
8217 if (or->type
== OSPF_DESTINATION_NETWORK
)
8218 for (ALL_LIST_ELEMENTS(or->paths
, pnode
, pnnode
,
8220 if (if_lookup_by_index(path
->ifindex
,
8222 if (path
->nexthop
.s_addr
== 0)
8224 "%24s directly attached to %s\n",
8231 "%24s via %s, %s\n",
8244 static void show_ip_ospf_route_router(struct vty
*vty
, struct ospf
*ospf
,
8245 struct route_table
*rtrs
)
8247 struct route_node
*rn
;
8248 struct ospf_route
* or ;
8249 struct listnode
*pnode
;
8250 struct listnode
*node
;
8251 struct ospf_path
*path
;
8253 vty_out(vty
, "============ OSPF router routing table =============\n");
8254 for (rn
= route_top(rtrs
); rn
; rn
= route_next(rn
))
8258 vty_out(vty
, "R %-15s ",
8259 inet_ntoa(rn
->p
.u
.prefix4
));
8261 for (ALL_LIST_ELEMENTS_RO((struct list
*)rn
->info
, node
,
8264 vty_out(vty
, "%24s", "");
8267 vty_out(vty
, "%s [%d] area: %s",
8268 (or->path_type
== OSPF_PATH_INTER_AREA
8271 or->cost
, inet_ntoa(or->u
.std
.area_id
));
8273 vty_out(vty
, "%s%s\n",
8274 (or->u
.std
.flags
& ROUTER_LSA_BORDER
8277 (or->u
.std
.flags
& ROUTER_LSA_EXTERNAL
8281 for (ALL_LIST_ELEMENTS_RO(or->paths
, pnode
,
8283 if (if_lookup_by_index(path
->ifindex
,
8285 if (path
->nexthop
.s_addr
== 0)
8287 "%24s directly attached to %s\n",
8294 "%24s via %s, %s\n",
8308 static void show_ip_ospf_route_external(struct vty
*vty
, struct ospf
*ospf
,
8309 struct route_table
*rt
)
8311 struct route_node
*rn
;
8312 struct ospf_route
*er
;
8313 struct listnode
*pnode
, *pnnode
;
8314 struct ospf_path
*path
;
8316 vty_out(vty
, "============ OSPF external routing table ===========\n");
8317 for (rn
= route_top(rt
); rn
; rn
= route_next(rn
))
8318 if ((er
= rn
->info
) != NULL
) {
8320 snprintf(buf1
, 19, "%s/%d", inet_ntoa(rn
->p
.u
.prefix4
),
8323 switch (er
->path_type
) {
8324 case OSPF_PATH_TYPE1_EXTERNAL
:
8326 "N E1 %-18s [%d] tag: %" ROUTE_TAG_PRI
8328 buf1
, er
->cost
, er
->u
.ext
.tag
);
8330 case OSPF_PATH_TYPE2_EXTERNAL
:
8332 "N E2 %-18s [%d/%d] tag: %" ROUTE_TAG_PRI
8334 buf1
, er
->cost
, er
->u
.ext
.type2_cost
,
8339 for (ALL_LIST_ELEMENTS(er
->paths
, pnode
, pnnode
,
8341 if (if_lookup_by_index(path
->ifindex
,
8343 if (path
->nexthop
.s_addr
== 0)
8345 "%24s directly attached to %s\n",
8352 "%24s via %s, %s\n",
8365 static int show_ip_ospf_border_routers_common(struct vty
*vty
,
8369 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
8371 if (ospf
->new_table
== NULL
) {
8372 vty_out(vty
, "No OSPF routing information exist\n");
8376 /* Show Network routes.
8377 show_ip_ospf_route_network (vty, ospf->new_table); */
8379 /* Show Router routes. */
8380 show_ip_ospf_route_router(vty
, ospf
, ospf
->new_rtrs
);
8387 DEFUN (show_ip_ospf_border_routers
,
8388 show_ip_ospf_border_routers_cmd
,
8389 "show ip ospf [vrf <NAME|all>] border-routers",
8392 "OSPF information\n"
8395 "Show all the ABR's and ASBR's\n")
8397 struct ospf
*ospf
= NULL
;
8398 struct listnode
*node
= NULL
;
8399 char *vrf_name
= NULL
;
8400 bool all_vrf
= FALSE
;
8401 int ret
= CMD_SUCCESS
;
8405 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
8409 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
8410 if (!ospf
->oi_running
)
8413 ret
= show_ip_ospf_border_routers_common(vty
,
8417 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
8418 if (ospf
== NULL
|| !ospf
->oi_running
)
8421 ret
= show_ip_ospf_border_routers_common(vty
, ospf
);
8424 /* Display default ospf (instance 0) info */
8425 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
8426 if (ospf
== NULL
|| !ospf
->oi_running
)
8428 ret
= show_ip_ospf_border_routers_common(vty
, ospf
);
8434 DEFUN (show_ip_ospf_instance_border_routers
,
8435 show_ip_ospf_instance_border_routers_cmd
,
8436 "show ip ospf (1-65535) border-routers",
8439 "OSPF information\n"
8441 "Show all the ABR's and ASBR's\n")
8445 u_short instance
= 0;
8447 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8448 ospf
= ospf_lookup_instance(instance
);
8450 return CMD_NOT_MY_INSTANCE
;
8452 if (!ospf
->oi_running
)
8455 return show_ip_ospf_border_routers_common(vty
, ospf
);
8458 static int show_ip_ospf_route_common(struct vty
*vty
, struct ospf
*ospf
)
8461 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
8463 if (ospf
->new_table
== NULL
) {
8464 vty_out(vty
, "No OSPF routing information exist\n");
8468 /* Show Network routes. */
8469 show_ip_ospf_route_network(vty
, ospf
, ospf
->new_table
);
8471 /* Show Router routes. */
8472 show_ip_ospf_route_router(vty
, ospf
, ospf
->new_rtrs
);
8474 /* Show AS External routes. */
8475 show_ip_ospf_route_external(vty
, ospf
, ospf
->old_external_route
);
8482 DEFUN (show_ip_ospf_route
,
8483 show_ip_ospf_route_cmd
,
8484 "show ip ospf [vrf <NAME|all>] route",
8487 "OSPF information\n"
8490 "OSPF routing table\n")
8492 struct ospf
*ospf
= NULL
;
8493 struct listnode
*node
= NULL
;
8494 char *vrf_name
= NULL
;
8495 bool all_vrf
= FALSE
;
8496 int ret
= CMD_SUCCESS
;
8500 OSPF_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
8502 /* vrf input is provided could be all or specific vrf*/
8505 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
8506 if (!ospf
->oi_running
)
8508 ret
= show_ip_ospf_route_common(vty
, ospf
);
8512 ospf
= ospf_lookup_by_inst_name(inst
, vrf_name
);
8513 if (ospf
== NULL
|| !ospf
->oi_running
)
8516 /* Display default ospf (instance 0) info */
8517 ospf
= ospf_lookup_by_vrf_id(VRF_DEFAULT
);
8518 if (ospf
== NULL
|| !ospf
->oi_running
)
8523 ret
= show_ip_ospf_route_common(vty
, ospf
);
8528 DEFUN (show_ip_ospf_instance_route
,
8529 show_ip_ospf_instance_route_cmd
,
8530 "show ip ospf (1-65535) route",
8533 "OSPF information\n"
8535 "OSPF routing table\n")
8539 u_short instance
= 0;
8541 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8542 ospf
= ospf_lookup_instance(instance
);
8544 return CMD_NOT_MY_INSTANCE
;
8546 if (!ospf
->oi_running
)
8549 return show_ip_ospf_route_common(vty
, ospf
);
8553 DEFUN (show_ip_ospf_vrfs
,
8554 show_ip_ospf_vrfs_cmd
,
8555 "show ip ospf vrfs [json]",
8558 "OSPF information\n"
8562 u_char uj
= use_json(argc
, argv
);
8563 json_object
*json
= NULL
;
8564 json_object
*json_vrfs
= NULL
;
8565 struct ospf
*ospf
= NULL
;
8566 struct listnode
*node
= NULL
;
8568 static char header
[] = "Name Id RouterId ";
8571 json
= json_object_new_object();
8572 json_vrfs
= json_object_new_object();
8575 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
8576 json_object
*json_vrf
= NULL
;
8577 const char *name
= NULL
;
8582 if (!uj
&& count
== 1)
8583 vty_out(vty
, "%s\n", header
);
8585 json_vrf
= json_object_new_object();
8587 if (ospf
->vrf_id
== 0)
8588 name
= VRF_DEFAULT_NAME
;
8592 vrf_id_ui
= (ospf
->vrf_id
== VRF_UNKNOWN
) ? -1 : ospf
->vrf_id
;
8595 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
8596 json_object_string_add(json_vrf
, "routerId",
8597 inet_ntoa(ospf
->router_id
));
8599 json_object_object_add(json_vrfs
, name
, json_vrf
);
8602 vty_out(vty
, "%-25s %-5d %-16s \n",
8603 name
, ospf
->vrf_id
, inet_ntoa(ospf
->router_id
));
8608 json_object_object_add(json
, "vrfs", json_vrfs
);
8609 json_object_int_add(json
, "totalVrfs", count
);
8611 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
8612 JSON_C_TO_STRING_PRETTY
));
8613 json_object_free(json
);
8616 vty_out(vty
, "\nTotal number of OSPF VRFs (including default): %d\n",
8623 const char *ospf_abr_type_str
[] = {"unknown", "standard", "ibm", "cisco",
8626 const char *ospf_shortcut_mode_str
[] = {"default", "enable", "disable"};
8628 const char *ospf_int_type_str
[] = {"unknown", /* should never be used. */
8629 "point-to-point", "broadcast",
8630 "non-broadcast", "point-to-multipoint",
8631 "virtual-link", /* should never be used. */
8634 static int config_write_interface_one(struct vty
*vty
, struct ospf
*ospf
)
8636 struct listnode
*n1
, *n2
;
8637 struct interface
*ifp
;
8638 struct crypt_key
*ck
;
8639 struct route_node
*rn
= NULL
;
8640 struct ospf_if_params
*params
;
8643 for (ALL_LIST_ELEMENTS_RO(vrf_iflist(ospf
->vrf_id
), n1
, ifp
)) {
8644 struct vrf
*vrf
= NULL
;
8646 if (memcmp(ifp
->name
, "VLINK", 5) == 0)
8649 if (ifp
->ifindex
== IFINDEX_DELETED
)
8652 vrf
= vrf_lookup_by_id(ifp
->vrf_id
);
8654 vty_frame(vty
, "!\n");
8655 if (ifp
->vrf_id
== VRF_DEFAULT
|| vrf
== NULL
)
8656 vty_frame(vty
, "interface %s\n", ifp
->name
);
8658 vty_frame(vty
, "interface %s vrf %s\n",
8659 ifp
->name
, vrf
->name
);
8661 vty_out(vty
, " description %s\n", ifp
->desc
);
8665 params
= IF_DEF_PARAMS(ifp
);
8668 /* Interface Network print. */
8669 if (OSPF_IF_PARAM_CONFIGURED(params
, type
)
8670 && params
->type
!= OSPF_IFTYPE_LOOPBACK
) {
8671 if (params
->type
!= ospf_default_iftype(ifp
)) {
8672 vty_out(vty
, " ip ospf network %s",
8675 if (params
!= IF_DEF_PARAMS(ifp
))
8683 /* OSPF interface authentication print */
8684 if (OSPF_IF_PARAM_CONFIGURED(params
, auth_type
)
8685 && params
->auth_type
!= OSPF_AUTH_NOTSET
) {
8686 const char *auth_str
;
8688 /* Translation tables are not that much help
8689 * here due to syntax
8690 * of the simple option */
8691 switch (params
->auth_type
) {
8693 case OSPF_AUTH_NULL
:
8697 case OSPF_AUTH_SIMPLE
:
8701 case OSPF_AUTH_CRYPTOGRAPHIC
:
8702 auth_str
= " message-digest";
8710 vty_out(vty
, " ip ospf authentication%s",
8712 if (params
!= IF_DEF_PARAMS(ifp
))
8714 inet_ntoa(rn
->p
.u
.prefix4
));
8718 /* Simple Authentication Password print. */
8719 if (OSPF_IF_PARAM_CONFIGURED(params
, auth_simple
)
8720 && params
->auth_simple
[0] != '\0') {
8721 vty_out(vty
, " ip ospf authentication-key %s",
8722 params
->auth_simple
);
8723 if (params
!= IF_DEF_PARAMS(ifp
))
8725 inet_ntoa(rn
->p
.u
.prefix4
));
8729 /* Cryptographic Authentication Key print. */
8730 if (params
&& params
->auth_crypt
) {
8731 for (ALL_LIST_ELEMENTS_RO(params
->auth_crypt
,
8734 " ip ospf message-digest-key %d md5 %s",
8735 ck
->key_id
, ck
->auth_key
);
8736 if (params
!= IF_DEF_PARAMS(ifp
))
8738 inet_ntoa(rn
->p
.u
.prefix4
));
8743 /* Interface Output Cost print. */
8744 if (OSPF_IF_PARAM_CONFIGURED(params
,
8746 vty_out(vty
, " ip ospf cost %u",
8747 params
->output_cost_cmd
);
8748 if (params
!= IF_DEF_PARAMS(ifp
))
8750 inet_ntoa(rn
->p
.u
.prefix4
));
8754 /* Hello Interval print. */
8755 if (OSPF_IF_PARAM_CONFIGURED(params
, v_hello
)
8756 && params
->v_hello
!= OSPF_HELLO_INTERVAL_DEFAULT
) {
8757 vty_out(vty
, " ip ospf hello-interval %u",
8759 if (params
!= IF_DEF_PARAMS(ifp
))
8761 inet_ntoa(rn
->p
.u
.prefix4
));
8766 /* Router Dead Interval print. */
8767 if (OSPF_IF_PARAM_CONFIGURED(params
, v_wait
)
8769 != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
) {
8770 vty_out(vty
, " ip ospf dead-interval ");
8773 if (OSPF_IF_PARAM_CONFIGURED(params
,
8776 "minimal hello-multiplier %d",
8777 params
->fast_hello
);
8779 vty_out(vty
, "%u", params
->v_wait
);
8781 if (params
!= IF_DEF_PARAMS(ifp
))
8783 inet_ntoa(rn
->p
.u
.prefix4
));
8787 /* Router Priority print. */
8788 if (OSPF_IF_PARAM_CONFIGURED(params
, priority
)
8790 != OSPF_ROUTER_PRIORITY_DEFAULT
) {
8791 vty_out(vty
, " ip ospf priority %u",
8793 if (params
!= IF_DEF_PARAMS(ifp
))
8795 inet_ntoa(rn
->p
.u
.prefix4
));
8799 /* Retransmit Interval print. */
8800 if (OSPF_IF_PARAM_CONFIGURED(params
,
8801 retransmit_interval
)
8802 && params
->retransmit_interval
8803 != OSPF_RETRANSMIT_INTERVAL_DEFAULT
) {
8804 vty_out(vty
, " ip ospf retransmit-interval %u",
8805 params
->retransmit_interval
);
8806 if (params
!= IF_DEF_PARAMS(ifp
))
8808 inet_ntoa(rn
->p
.u
.prefix4
));
8812 /* Transmit Delay print. */
8813 if (OSPF_IF_PARAM_CONFIGURED(params
, transmit_delay
)
8814 && params
->transmit_delay
8815 != OSPF_TRANSMIT_DELAY_DEFAULT
) {
8816 vty_out(vty
, " ip ospf transmit-delay %u",
8817 params
->transmit_delay
);
8818 if (params
!= IF_DEF_PARAMS(ifp
))
8820 inet_ntoa(rn
->p
.u
.prefix4
));
8825 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
8827 vty_out(vty
, " ip ospf %d",
8830 vty_out(vty
, " ip ospf");
8833 size_t buflen
= MAX(strlen("4294967295"),
8834 strlen("255.255.255.255"));
8837 area_id2str(buf
, sizeof(buf
),
8839 params
->if_area_id_fmt
);
8840 vty_out(vty
, " area %s", buf
);
8841 if (params
!= IF_DEF_PARAMS(ifp
))
8843 inet_ntoa(rn
->p
.u
.prefix4
));
8848 ospf_bfd_write_config(vty
, params
);
8850 /* MTU ignore print. */
8851 if (OSPF_IF_PARAM_CONFIGURED(params
, mtu_ignore
)
8852 && params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
) {
8853 if (params
->mtu_ignore
== 0)
8854 vty_out(vty
, " no ip ospf mtu-ignore");
8856 vty_out(vty
, " ip ospf mtu-ignore");
8857 if (params
!= IF_DEF_PARAMS(ifp
))
8859 inet_ntoa(rn
->p
.u
.prefix4
));
8866 rn
= route_top(IF_OIFS_PARAMS(ifp
));
8868 rn
= route_next(rn
);
8878 ospf_opaque_config_write_if(vty
, ifp
);
8880 vty_endframe(vty
, NULL
);
8885 /* Configuration write function for ospfd. */
8886 static int config_write_interface(struct vty
*vty
)
8889 struct ospf
*ospf
= NULL
;
8890 struct listnode
*node
= NULL
;
8892 /* Traverse all ospf [vrf] instances */
8893 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
))
8894 write
+= config_write_interface_one(vty
, ospf
);
8899 static int config_write_network_area(struct vty
*vty
, struct ospf
*ospf
)
8901 struct route_node
*rn
;
8902 u_char buf
[INET_ADDRSTRLEN
];
8904 /* `network area' print. */
8905 for (rn
= route_top(ospf
->networks
); rn
; rn
= route_next(rn
))
8907 struct ospf_network
*n
= rn
->info
;
8909 memset(buf
, 0, INET_ADDRSTRLEN
);
8911 /* Create Area ID string by specified Area ID format. */
8912 if (n
->area_id_fmt
== OSPF_AREA_ID_FMT_DOTTEDQUAD
)
8913 strncpy((char *)buf
, inet_ntoa(n
->area_id
),
8916 sprintf((char *)buf
, "%lu",
8917 (unsigned long int)ntohl(
8918 n
->area_id
.s_addr
));
8920 /* Network print. */
8921 vty_out(vty
, " network %s/%d area %s\n",
8922 inet_ntoa(rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
8929 static int config_write_ospf_area(struct vty
*vty
, struct ospf
*ospf
)
8931 struct listnode
*node
;
8932 struct ospf_area
*area
;
8933 u_char buf
[INET_ADDRSTRLEN
];
8935 /* Area configuration print. */
8936 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
8937 struct route_node
*rn1
;
8939 area_id2str((char *)buf
, INET_ADDRSTRLEN
, &area
->area_id
,
8942 if (area
->auth_type
!= OSPF_AUTH_NULL
) {
8943 if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
8944 vty_out(vty
, " area %s authentication\n", buf
);
8947 " area %s authentication message-digest\n",
8951 if (area
->shortcut_configured
!= OSPF_SHORTCUT_DEFAULT
)
8952 vty_out(vty
, " area %s shortcut %s\n", buf
,
8953 ospf_shortcut_mode_str
8954 [area
->shortcut_configured
]);
8956 if ((area
->external_routing
== OSPF_AREA_STUB
)
8957 || (area
->external_routing
== OSPF_AREA_NSSA
)) {
8958 if (area
->external_routing
== OSPF_AREA_STUB
)
8959 vty_out(vty
, " area %s stub", buf
);
8960 else if (area
->external_routing
== OSPF_AREA_NSSA
) {
8961 vty_out(vty
, " area %s nssa", buf
);
8962 switch (area
->NSSATranslatorRole
) {
8963 case OSPF_NSSA_ROLE_NEVER
:
8964 vty_out(vty
, " translate-never");
8966 case OSPF_NSSA_ROLE_ALWAYS
:
8967 vty_out(vty
, " translate-always");
8969 case OSPF_NSSA_ROLE_CANDIDATE
:
8971 vty_out(vty
, " translate-candidate");
8975 if (area
->no_summary
)
8976 vty_out(vty
, " no-summary");
8980 if (area
->default_cost
!= 1)
8981 vty_out(vty
, " area %s default-cost %d\n", buf
,
8982 area
->default_cost
);
8985 for (rn1
= route_top(area
->ranges
); rn1
; rn1
= route_next(rn1
))
8987 struct ospf_area_range
*range
= rn1
->info
;
8989 vty_out(vty
, " area %s range %s/%d", buf
,
8990 inet_ntoa(rn1
->p
.u
.prefix4
),
8993 if (range
->cost_config
8994 != OSPF_AREA_RANGE_COST_UNSPEC
)
8995 vty_out(vty
, " cost %d",
8996 range
->cost_config
);
8998 if (!CHECK_FLAG(range
->flags
,
8999 OSPF_AREA_RANGE_ADVERTISE
))
9000 vty_out(vty
, " not-advertise");
9002 if (CHECK_FLAG(range
->flags
,
9003 OSPF_AREA_RANGE_SUBSTITUTE
))
9004 vty_out(vty
, " substitute %s/%d",
9005 inet_ntoa(range
->subst_addr
),
9006 range
->subst_masklen
);
9011 if (EXPORT_NAME(area
))
9012 vty_out(vty
, " area %s export-list %s\n", buf
,
9015 if (IMPORT_NAME(area
))
9016 vty_out(vty
, " area %s import-list %s\n", buf
,
9019 if (PREFIX_NAME_IN(area
))
9020 vty_out(vty
, " area %s filter-list prefix %s in\n", buf
,
9021 PREFIX_NAME_IN(area
));
9023 if (PREFIX_NAME_OUT(area
))
9024 vty_out(vty
, " area %s filter-list prefix %s out\n",
9025 buf
, PREFIX_NAME_OUT(area
));
9031 static int config_write_ospf_nbr_nbma(struct vty
*vty
, struct ospf
*ospf
)
9033 struct ospf_nbr_nbma
*nbr_nbma
;
9034 struct route_node
*rn
;
9036 /* Static Neighbor configuration print. */
9037 for (rn
= route_top(ospf
->nbr_nbma
); rn
; rn
= route_next(rn
))
9038 if ((nbr_nbma
= rn
->info
)) {
9039 vty_out(vty
, " neighbor %s", inet_ntoa(nbr_nbma
->addr
));
9041 if (nbr_nbma
->priority
9042 != OSPF_NEIGHBOR_PRIORITY_DEFAULT
)
9043 vty_out(vty
, " priority %d",
9044 nbr_nbma
->priority
);
9046 if (nbr_nbma
->v_poll
!= OSPF_POLL_INTERVAL_DEFAULT
)
9047 vty_out(vty
, " poll-interval %d",
9056 static int config_write_virtual_link(struct vty
*vty
, struct ospf
*ospf
)
9058 struct listnode
*node
;
9059 struct ospf_vl_data
*vl_data
;
9060 char buf
[INET_ADDRSTRLEN
];
9062 /* Virtual-Link print */
9063 for (ALL_LIST_ELEMENTS_RO(ospf
->vlinks
, node
, vl_data
)) {
9064 struct listnode
*n2
;
9065 struct crypt_key
*ck
;
9066 struct ospf_interface
*oi
;
9068 if (vl_data
!= NULL
) {
9069 memset(buf
, 0, INET_ADDRSTRLEN
);
9071 area_id2str(buf
, sizeof(buf
), &vl_data
->vl_area_id
,
9072 vl_data
->vl_area_id_fmt
);
9073 oi
= vl_data
->vl_oi
;
9076 if (OSPF_IF_PARAM(oi
, v_hello
)
9077 != OSPF_HELLO_INTERVAL_DEFAULT
9078 || OSPF_IF_PARAM(oi
, v_wait
)
9079 != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
9080 || OSPF_IF_PARAM(oi
, retransmit_interval
)
9081 != OSPF_RETRANSMIT_INTERVAL_DEFAULT
9082 || OSPF_IF_PARAM(oi
, transmit_delay
)
9083 != OSPF_TRANSMIT_DELAY_DEFAULT
)
9085 " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d\n",
9086 buf
, inet_ntoa(vl_data
->vl_peer
),
9087 OSPF_IF_PARAM(oi
, v_hello
),
9088 OSPF_IF_PARAM(oi
, retransmit_interval
),
9089 OSPF_IF_PARAM(oi
, transmit_delay
),
9090 OSPF_IF_PARAM(oi
, v_wait
));
9092 vty_out(vty
, " area %s virtual-link %s\n", buf
,
9093 inet_ntoa(vl_data
->vl_peer
));
9095 if (IF_DEF_PARAMS(vl_data
->vl_oi
->ifp
)->auth_simple
[0]
9098 " area %s virtual-link %s authentication-key %s\n",
9099 buf
, inet_ntoa(vl_data
->vl_peer
),
9100 IF_DEF_PARAMS(vl_data
->vl_oi
->ifp
)
9103 for (ALL_LIST_ELEMENTS_RO(
9104 IF_DEF_PARAMS(vl_data
->vl_oi
->ifp
)
9108 " area %s virtual-link %s"
9109 " message-digest-key %d md5 %s\n",
9110 buf
, inet_ntoa(vl_data
->vl_peer
),
9111 ck
->key_id
, ck
->auth_key
);
9119 static int config_write_ospf_redistribute(struct vty
*vty
, struct ospf
*ospf
)
9123 /* redistribute print. */
9124 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++) {
9125 struct list
*red_list
;
9126 struct listnode
*node
;
9127 struct ospf_redist
*red
;
9129 red_list
= ospf
->redist
[type
];
9133 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
9134 vty_out(vty
, " redistribute %s",
9135 zebra_route_string(type
));
9137 vty_out(vty
, " %d", red
->instance
);
9139 if (red
->dmetric
.value
>= 0)
9140 vty_out(vty
, " metric %d", red
->dmetric
.value
);
9142 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
9143 vty_out(vty
, " metric-type 1");
9145 if (ROUTEMAP_NAME(red
))
9146 vty_out(vty
, " route-map %s",
9147 ROUTEMAP_NAME(red
));
9156 static int config_write_ospf_default_metric(struct vty
*vty
, struct ospf
*ospf
)
9158 if (ospf
->default_metric
!= -1)
9159 vty_out(vty
, " default-metric %d\n", ospf
->default_metric
);
9163 static int config_write_ospf_distribute(struct vty
*vty
, struct ospf
*ospf
)
9166 struct ospf_redist
*red
;
9169 /* distribute-list print. */
9170 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
9171 if (DISTRIBUTE_NAME(ospf
, type
))
9172 vty_out(vty
, " distribute-list %s out %s\n",
9173 DISTRIBUTE_NAME(ospf
, type
),
9174 zebra_route_string(type
));
9176 /* default-information print. */
9177 if (ospf
->default_originate
!= DEFAULT_ORIGINATE_NONE
) {
9178 vty_out(vty
, " default-information originate");
9179 if (ospf
->default_originate
== DEFAULT_ORIGINATE_ALWAYS
)
9180 vty_out(vty
, " always");
9182 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
9184 if (red
->dmetric
.value
>= 0)
9185 vty_out(vty
, " metric %d",
9186 red
->dmetric
.value
);
9187 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
9188 vty_out(vty
, " metric-type 1");
9190 if (ROUTEMAP_NAME(red
))
9191 vty_out(vty
, " route-map %s",
9192 ROUTEMAP_NAME(red
));
9202 static int config_write_ospf_distance(struct vty
*vty
, struct ospf
*ospf
)
9204 struct route_node
*rn
;
9205 struct ospf_distance
*odistance
;
9207 if (ospf
->distance_all
)
9208 vty_out(vty
, " distance %d\n", ospf
->distance_all
);
9210 if (ospf
->distance_intra
|| ospf
->distance_inter
9211 || ospf
->distance_external
) {
9212 vty_out(vty
, " distance ospf");
9214 if (ospf
->distance_intra
)
9215 vty_out(vty
, " intra-area %d", ospf
->distance_intra
);
9216 if (ospf
->distance_inter
)
9217 vty_out(vty
, " inter-area %d", ospf
->distance_inter
);
9218 if (ospf
->distance_external
)
9219 vty_out(vty
, " external %d", ospf
->distance_external
);
9224 for (rn
= route_top(ospf
->distance_table
); rn
; rn
= route_next(rn
))
9225 if ((odistance
= rn
->info
) != NULL
) {
9226 vty_out(vty
, " distance %d %s/%d %s\n",
9227 odistance
->distance
, inet_ntoa(rn
->p
.u
.prefix4
),
9229 odistance
->access_list
? odistance
->access_list
9235 static int ospf_config_write_one(struct vty
*vty
, struct ospf
*ospf
)
9237 struct interface
*ifp
;
9238 struct ospf_interface
*oi
;
9239 struct listnode
*node
= NULL
;
9242 /* `router ospf' print. */
9243 if (ospf
->instance
&& ospf
->name
) {
9244 vty_out(vty
, "router ospf %d vrf %s\n",
9245 ospf
->instance
, ospf
->name
);
9246 } else if (ospf
->instance
) {
9247 vty_out(vty
, "router ospf %d\n",
9249 } else if (ospf
->name
) {
9250 vty_out(vty
, "router ospf vrf %s\n",
9253 vty_out(vty
, "router ospf\n");
9255 if (!ospf
->networks
) {
9260 /* Router ID print. */
9261 if (ospf
->router_id_static
.s_addr
!= 0)
9262 vty_out(vty
, " ospf router-id %s\n",
9263 inet_ntoa(ospf
->router_id_static
));
9265 /* ABR type print. */
9266 if (ospf
->abr_type
!= OSPF_ABR_DEFAULT
)
9267 vty_out(vty
, " ospf abr-type %s\n",
9268 ospf_abr_type_str
[ospf
->abr_type
]);
9270 /* log-adjacency-changes flag print. */
9271 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
)) {
9272 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
9273 vty_out(vty
, " log-adjacency-changes detail\n");
9274 else if (!DFLT_OSPF_LOG_ADJACENCY_CHANGES
)
9275 vty_out(vty
, " log-adjacency-changes\n");
9276 } else if (DFLT_OSPF_LOG_ADJACENCY_CHANGES
) {
9277 vty_out(vty
, " no log-adjacency-changes\n");
9280 /* RFC1583 compatibility flag print -- Compatible with CISCO
9282 if (CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
9283 vty_out(vty
, " compatible rfc1583\n");
9285 /* auto-cost reference-bandwidth configuration. */
9286 if (ospf
->ref_bandwidth
!= OSPF_DEFAULT_REF_BANDWIDTH
) {
9288 "! Important: ensure reference bandwidth "
9289 "is consistent across all routers\n");
9290 vty_out(vty
, " auto-cost reference-bandwidth %d\n",
9291 ospf
->ref_bandwidth
);
9294 /* SPF timers print. */
9295 if (ospf
->spf_delay
!= OSPF_SPF_DELAY_DEFAULT
9296 || ospf
->spf_holdtime
!= OSPF_SPF_HOLDTIME_DEFAULT
9297 || ospf
->spf_max_holdtime
!= OSPF_SPF_MAX_HOLDTIME_DEFAULT
)
9298 vty_out(vty
, " timers throttle spf %d %d %d\n",
9299 ospf
->spf_delay
, ospf
->spf_holdtime
,
9300 ospf
->spf_max_holdtime
);
9302 /* LSA timers print. */
9303 if (ospf
->min_ls_interval
!= OSPF_MIN_LS_INTERVAL
)
9304 vty_out(vty
, " timers throttle lsa all %d\n",
9305 ospf
->min_ls_interval
);
9306 if (ospf
->min_ls_arrival
!= OSPF_MIN_LS_ARRIVAL
)
9307 vty_out(vty
, " timers lsa min-arrival %d\n",
9308 ospf
->min_ls_arrival
);
9310 /* Write multiplier print. */
9311 if (ospf
->write_oi_count
!= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
)
9312 vty_out(vty
, " ospf write-multiplier %d\n",
9313 ospf
->write_oi_count
);
9315 /* Max-metric router-lsa print */
9316 config_write_stub_router(vty
, ospf
);
9318 /* SPF refresh parameters print. */
9319 if (ospf
->lsa_refresh_interval
9320 != OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
9321 vty_out(vty
, " refresh timer %d\n",
9322 ospf
->lsa_refresh_interval
);
9324 /* Redistribute information print. */
9325 config_write_ospf_redistribute(vty
, ospf
);
9327 /* passive-interface print. */
9328 if (ospf
->passive_interface_default
== OSPF_IF_PASSIVE
)
9329 vty_out(vty
, " passive-interface default\n");
9331 for (ALL_LIST_ELEMENTS_RO(vrf_iflist(ospf
->vrf_id
), node
, ifp
))
9332 if (OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp
),
9334 && IF_DEF_PARAMS(ifp
)->passive_interface
9335 != ospf
->passive_interface_default
) {
9336 vty_out(vty
, " %spassive-interface %s\n",
9337 IF_DEF_PARAMS(ifp
)->passive_interface
9342 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
9343 if (!OSPF_IF_PARAM_CONFIGURED(oi
->params
,
9346 if (OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(oi
->ifp
),
9347 passive_interface
)) {
9348 if (oi
->params
->passive_interface
9349 == IF_DEF_PARAMS(oi
->ifp
)
9350 ->passive_interface
)
9352 } else if (oi
->params
->passive_interface
9353 == ospf
->passive_interface_default
)
9356 vty_out(vty
, " %spassive-interface %s %s\n",
9357 oi
->params
->passive_interface
? "" : "no ",
9359 inet_ntoa(oi
->address
->u
.prefix4
));
9362 /* Network area print. */
9363 config_write_network_area(vty
, ospf
);
9365 /* Area config print. */
9366 config_write_ospf_area(vty
, ospf
);
9368 /* static neighbor print. */
9369 config_write_ospf_nbr_nbma(vty
, ospf
);
9371 /* Virtual-Link print. */
9372 config_write_virtual_link(vty
, ospf
);
9374 /* Default metric configuration. */
9375 config_write_ospf_default_metric(vty
, ospf
);
9377 /* Distribute-list and default-information print. */
9378 config_write_ospf_distribute(vty
, ospf
);
9380 /* Distance configuration. */
9381 config_write_ospf_distance(vty
, ospf
);
9383 ospf_opaque_config_write_router(vty
, ospf
);
9389 /* OSPF configuration write function. */
9390 static int ospf_config_write(struct vty
*vty
)
9393 struct listnode
*ospf_node
= NULL
;
9396 if (listcount(om
->ospf
) == 0)
9399 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, ospf_node
, ospf
)) {
9400 if (ospf
->oi_running
)
9401 write
+= ospf_config_write_one(vty
, ospf
);
9406 void ospf_vty_show_init(void)
9408 /* "show ip ospf" commands. */
9409 install_element(VIEW_NODE
, &show_ip_ospf_cmd
);
9411 install_element(VIEW_NODE
, &show_ip_ospf_instance_cmd
);
9413 /* "show ip ospf database" commands. */
9414 install_element(VIEW_NODE
, &show_ip_ospf_database_max_cmd
);
9416 install_element(VIEW_NODE
,
9417 &show_ip_ospf_instance_database_type_adv_router_cmd
);
9418 install_element(VIEW_NODE
, &show_ip_ospf_instance_database_cmd
);
9419 install_element(VIEW_NODE
, &show_ip_ospf_instance_database_max_cmd
);
9421 /* "show ip ospf interface" commands. */
9422 install_element(VIEW_NODE
, &show_ip_ospf_interface_cmd
);
9424 install_element(VIEW_NODE
, &show_ip_ospf_instance_interface_cmd
);
9426 /* "show ip ospf neighbor" commands. */
9427 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_int_detail_cmd
);
9428 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_int_cmd
);
9429 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_id_cmd
);
9430 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_detail_all_cmd
);
9431 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_detail_cmd
);
9432 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_cmd
);
9433 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_all_cmd
);
9435 install_element(VIEW_NODE
,
9436 &show_ip_ospf_instance_neighbor_int_detail_cmd
);
9437 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_cmd
);
9438 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_id_cmd
);
9439 install_element(VIEW_NODE
,
9440 &show_ip_ospf_instance_neighbor_detail_all_cmd
);
9441 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_cmd
);
9442 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_cmd
);
9443 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_all_cmd
);
9445 /* "show ip ospf route" commands. */
9446 install_element(VIEW_NODE
, &show_ip_ospf_route_cmd
);
9447 install_element(VIEW_NODE
, &show_ip_ospf_border_routers_cmd
);
9449 install_element(VIEW_NODE
, &show_ip_ospf_instance_route_cmd
);
9450 install_element(VIEW_NODE
, &show_ip_ospf_instance_border_routers_cmd
);
9452 /* "show ip ospf vrfs" commands. */
9453 install_element(VIEW_NODE
, &show_ip_ospf_vrfs_cmd
);
9457 /* ospfd's interface node. */
9458 static struct cmd_node interface_node
= {INTERFACE_NODE
, "%s(config-if)# ", 1};
9460 /* Initialization of OSPF interface. */
9461 static void ospf_vty_if_init(void)
9463 /* Install interface node. */
9464 install_node(&interface_node
, config_write_interface
);
9467 /* "ip ospf authentication" commands. */
9468 install_element(INTERFACE_NODE
, &ip_ospf_authentication_args_addr_cmd
);
9469 install_element(INTERFACE_NODE
, &ip_ospf_authentication_addr_cmd
);
9470 install_element(INTERFACE_NODE
,
9471 &no_ip_ospf_authentication_args_addr_cmd
);
9472 install_element(INTERFACE_NODE
, &no_ip_ospf_authentication_addr_cmd
);
9473 install_element(INTERFACE_NODE
, &ip_ospf_authentication_key_addr_cmd
);
9474 install_element(INTERFACE_NODE
,
9475 &no_ip_ospf_authentication_key_authkey_addr_cmd
);
9476 install_element(INTERFACE_NODE
,
9477 &no_ospf_authentication_key_authkey_addr_cmd
);
9479 /* "ip ospf message-digest-key" commands. */
9480 install_element(INTERFACE_NODE
, &ip_ospf_message_digest_key_cmd
);
9481 install_element(INTERFACE_NODE
, &no_ip_ospf_message_digest_key_cmd
);
9483 /* "ip ospf cost" commands. */
9484 install_element(INTERFACE_NODE
, &ip_ospf_cost_cmd
);
9485 install_element(INTERFACE_NODE
, &no_ip_ospf_cost_cmd
);
9487 /* "ip ospf mtu-ignore" commands. */
9488 install_element(INTERFACE_NODE
, &ip_ospf_mtu_ignore_addr_cmd
);
9489 install_element(INTERFACE_NODE
, &no_ip_ospf_mtu_ignore_addr_cmd
);
9491 /* "ip ospf dead-interval" commands. */
9492 install_element(INTERFACE_NODE
, &ip_ospf_dead_interval_cmd
);
9493 install_element(INTERFACE_NODE
,
9494 &ip_ospf_dead_interval_minimal_addr_cmd
);
9495 install_element(INTERFACE_NODE
, &no_ip_ospf_dead_interval_cmd
);
9497 /* "ip ospf hello-interval" commands. */
9498 install_element(INTERFACE_NODE
, &ip_ospf_hello_interval_cmd
);
9499 install_element(INTERFACE_NODE
, &no_ip_ospf_hello_interval_cmd
);
9501 /* "ip ospf network" commands. */
9502 install_element(INTERFACE_NODE
, &ip_ospf_network_cmd
);
9503 install_element(INTERFACE_NODE
, &no_ip_ospf_network_cmd
);
9505 /* "ip ospf priority" commands. */
9506 install_element(INTERFACE_NODE
, &ip_ospf_priority_cmd
);
9507 install_element(INTERFACE_NODE
, &no_ip_ospf_priority_cmd
);
9509 /* "ip ospf retransmit-interval" commands. */
9510 install_element(INTERFACE_NODE
, &ip_ospf_retransmit_interval_addr_cmd
);
9511 install_element(INTERFACE_NODE
,
9512 &no_ip_ospf_retransmit_interval_addr_cmd
);
9514 /* "ip ospf transmit-delay" commands. */
9515 install_element(INTERFACE_NODE
, &ip_ospf_transmit_delay_addr_cmd
);
9516 install_element(INTERFACE_NODE
, &no_ip_ospf_transmit_delay_addr_cmd
);
9518 /* "ip ospf area" commands. */
9519 install_element(INTERFACE_NODE
, &ip_ospf_area_cmd
);
9520 install_element(INTERFACE_NODE
, &no_ip_ospf_area_cmd
);
9522 /* These commands are compatibitliy for previous version. */
9523 install_element(INTERFACE_NODE
, &ospf_authentication_key_cmd
);
9524 install_element(INTERFACE_NODE
, &ospf_message_digest_key_cmd
);
9525 install_element(INTERFACE_NODE
, &no_ospf_message_digest_key_cmd
);
9526 install_element(INTERFACE_NODE
, &ospf_dead_interval_cmd
);
9527 install_element(INTERFACE_NODE
, &no_ospf_dead_interval_cmd
);
9528 install_element(INTERFACE_NODE
, &ospf_hello_interval_cmd
);
9529 install_element(INTERFACE_NODE
, &no_ospf_hello_interval_cmd
);
9530 install_element(INTERFACE_NODE
, &ospf_cost_cmd
);
9531 install_element(INTERFACE_NODE
, &no_ospf_cost_cmd
);
9532 install_element(INTERFACE_NODE
, &ospf_network_cmd
);
9533 install_element(INTERFACE_NODE
, &no_ospf_network_cmd
);
9534 install_element(INTERFACE_NODE
, &ospf_priority_cmd
);
9535 install_element(INTERFACE_NODE
, &no_ospf_priority_cmd
);
9536 install_element(INTERFACE_NODE
, &ospf_retransmit_interval_cmd
);
9537 install_element(INTERFACE_NODE
, &no_ospf_retransmit_interval_cmd
);
9538 install_element(INTERFACE_NODE
, &ospf_transmit_delay_cmd
);
9539 install_element(INTERFACE_NODE
, &no_ospf_transmit_delay_cmd
);
9542 static void ospf_vty_zebra_init(void)
9544 install_element(OSPF_NODE
, &ospf_redistribute_source_cmd
);
9545 install_element(OSPF_NODE
, &no_ospf_redistribute_source_cmd
);
9546 install_element(OSPF_NODE
, &ospf_redistribute_instance_source_cmd
);
9547 install_element(OSPF_NODE
, &no_ospf_redistribute_instance_source_cmd
);
9549 install_element(OSPF_NODE
, &ospf_distribute_list_out_cmd
);
9550 install_element(OSPF_NODE
, &no_ospf_distribute_list_out_cmd
);
9552 install_element(OSPF_NODE
, &ospf_default_information_originate_cmd
);
9553 install_element(OSPF_NODE
, &no_ospf_default_information_originate_cmd
);
9555 install_element(OSPF_NODE
, &ospf_default_metric_cmd
);
9556 install_element(OSPF_NODE
, &no_ospf_default_metric_cmd
);
9558 install_element(OSPF_NODE
, &ospf_distance_cmd
);
9559 install_element(OSPF_NODE
, &no_ospf_distance_cmd
);
9560 install_element(OSPF_NODE
, &no_ospf_distance_ospf_cmd
);
9561 install_element(OSPF_NODE
, &ospf_distance_ospf_cmd
);
9563 install_element (OSPF_NODE
, &ospf_distance_source_cmd
);
9564 install_element (OSPF_NODE
, &no_ospf_distance_source_cmd
);
9565 install_element (OSPF_NODE
, &ospf_distance_source_access_list_cmd
);
9566 install_element (OSPF_NODE
, &no_ospf_distance_source_access_list_cmd
);
9570 static struct cmd_node ospf_node
= {OSPF_NODE
, "%s(config-router)# ", 1};
9572 static void ospf_interface_clear(struct interface
*ifp
)
9574 if (!if_is_operative(ifp
))
9577 if (IS_DEBUG_OSPF(ism
, ISM_EVENTS
))
9578 zlog_debug("ISM[%s]: clear by reset", ifp
->name
);
9583 DEFUN (clear_ip_ospf_interface
,
9584 clear_ip_ospf_interface_cmd
,
9585 "clear ip ospf interface [IFNAME]",
9588 "OSPF information\n"
9589 "Interface information\n"
9593 struct interface
*ifp
;
9594 struct listnode
*node
, *n1
;
9595 struct ospf
*ospf
= NULL
;
9597 if (argc
== 4) /* Clear all the ospfv2 interfaces. */
9599 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, n1
, ospf
)) {
9600 for (ALL_LIST_ELEMENTS_RO(vrf_iflist(ospf
->vrf_id
),
9602 ospf_interface_clear(ifp
);
9605 /* Interface name is specified. */
9606 ifp
= if_lookup_by_name_all_vrf(argv
[idx_ifname
]->arg
);
9608 vty_out(vty
, "No such interface name\n");
9610 ospf_interface_clear(ifp
);
9616 void ospf_vty_clear_init(void)
9618 install_element(ENABLE_NODE
, &clear_ip_ospf_interface_cmd
);
9622 /* Install OSPF related vty commands. */
9623 void ospf_vty_init(void)
9625 /* Install ospf top node. */
9626 install_node(&ospf_node
, ospf_config_write
);
9628 /* "router ospf" commands. */
9629 install_element(CONFIG_NODE
, &router_ospf_cmd
);
9630 install_element(CONFIG_NODE
, &no_router_ospf_cmd
);
9633 install_default(OSPF_NODE
);
9635 /* "ospf router-id" commands. */
9636 install_element(OSPF_NODE
, &ospf_router_id_cmd
);
9637 install_element(OSPF_NODE
, &ospf_router_id_old_cmd
);
9638 install_element(OSPF_NODE
, &no_ospf_router_id_cmd
);
9640 /* "passive-interface" commands. */
9641 install_element(OSPF_NODE
, &ospf_passive_interface_addr_cmd
);
9642 install_element(OSPF_NODE
, &no_ospf_passive_interface_addr_cmd
);
9644 /* "ospf abr-type" commands. */
9645 install_element(OSPF_NODE
, &ospf_abr_type_cmd
);
9646 install_element(OSPF_NODE
, &no_ospf_abr_type_cmd
);
9648 /* "ospf log-adjacency-changes" commands. */
9649 install_element(OSPF_NODE
, &ospf_log_adjacency_changes_cmd
);
9650 install_element(OSPF_NODE
, &ospf_log_adjacency_changes_detail_cmd
);
9651 install_element(OSPF_NODE
, &no_ospf_log_adjacency_changes_cmd
);
9652 install_element(OSPF_NODE
, &no_ospf_log_adjacency_changes_detail_cmd
);
9654 /* "ospf rfc1583-compatible" commands. */
9655 install_element(OSPF_NODE
, &ospf_compatible_rfc1583_cmd
);
9656 install_element(OSPF_NODE
, &no_ospf_compatible_rfc1583_cmd
);
9657 install_element(OSPF_NODE
, &ospf_rfc1583_flag_cmd
);
9658 install_element(OSPF_NODE
, &no_ospf_rfc1583_flag_cmd
);
9660 /* "network area" commands. */
9661 install_element(OSPF_NODE
, &ospf_network_area_cmd
);
9662 install_element(OSPF_NODE
, &no_ospf_network_area_cmd
);
9664 /* "area authentication" commands. */
9665 install_element(OSPF_NODE
,
9666 &ospf_area_authentication_message_digest_cmd
);
9667 install_element(OSPF_NODE
, &ospf_area_authentication_cmd
);
9668 install_element(OSPF_NODE
, &no_ospf_area_authentication_cmd
);
9670 /* "area range" commands. */
9671 install_element(OSPF_NODE
, &ospf_area_range_cmd
);
9672 install_element(OSPF_NODE
, &ospf_area_range_cost_cmd
);
9673 install_element(OSPF_NODE
, &ospf_area_range_not_advertise_cmd
);
9674 install_element(OSPF_NODE
, &no_ospf_area_range_cmd
);
9675 install_element(OSPF_NODE
, &ospf_area_range_substitute_cmd
);
9676 install_element(OSPF_NODE
, &no_ospf_area_range_substitute_cmd
);
9678 /* "area virtual-link" commands. */
9679 install_element(OSPF_NODE
, &ospf_area_vlink_cmd
);
9680 install_element(OSPF_NODE
, &ospf_area_vlink_intervals_cmd
);
9681 install_element(OSPF_NODE
, &no_ospf_area_vlink_cmd
);
9682 install_element(OSPF_NODE
, &no_ospf_area_vlink_intervals_cmd
);
9685 /* "area stub" commands. */
9686 install_element(OSPF_NODE
, &ospf_area_stub_no_summary_cmd
);
9687 install_element(OSPF_NODE
, &ospf_area_stub_cmd
);
9688 install_element(OSPF_NODE
, &no_ospf_area_stub_no_summary_cmd
);
9689 install_element(OSPF_NODE
, &no_ospf_area_stub_cmd
);
9691 /* "area nssa" commands. */
9692 install_element(OSPF_NODE
, &ospf_area_nssa_cmd
);
9693 install_element(OSPF_NODE
, &ospf_area_nssa_translate_no_summary_cmd
);
9694 install_element(OSPF_NODE
, &ospf_area_nssa_translate_cmd
);
9695 install_element(OSPF_NODE
, &ospf_area_nssa_no_summary_cmd
);
9696 install_element(OSPF_NODE
, &no_ospf_area_nssa_cmd
);
9698 install_element(OSPF_NODE
, &ospf_area_default_cost_cmd
);
9699 install_element(OSPF_NODE
, &no_ospf_area_default_cost_cmd
);
9701 install_element(OSPF_NODE
, &ospf_area_shortcut_cmd
);
9702 install_element(OSPF_NODE
, &no_ospf_area_shortcut_cmd
);
9704 install_element(OSPF_NODE
, &ospf_area_export_list_cmd
);
9705 install_element(OSPF_NODE
, &no_ospf_area_export_list_cmd
);
9707 install_element(OSPF_NODE
, &ospf_area_filter_list_cmd
);
9708 install_element(OSPF_NODE
, &no_ospf_area_filter_list_cmd
);
9710 install_element(OSPF_NODE
, &ospf_area_import_list_cmd
);
9711 install_element(OSPF_NODE
, &no_ospf_area_import_list_cmd
);
9713 /* SPF timer commands */
9714 install_element(OSPF_NODE
, &ospf_timers_throttle_spf_cmd
);
9715 install_element(OSPF_NODE
, &no_ospf_timers_throttle_spf_cmd
);
9717 /* LSA timers commands */
9718 install_element(OSPF_NODE
, &ospf_timers_min_ls_interval_cmd
);
9719 install_element(OSPF_NODE
, &no_ospf_timers_min_ls_interval_cmd
);
9720 install_element(OSPF_NODE
, &ospf_timers_lsa_min_arrival_cmd
);
9721 install_element(OSPF_NODE
, &no_ospf_timers_lsa_min_arrival_cmd
);
9722 install_element(OSPF_NODE
, &ospf_timers_lsa_arrival_cmd
);
9723 install_element(OSPF_NODE
, &no_ospf_timers_lsa_arrival_cmd
);
9725 /* refresh timer commands */
9726 install_element(OSPF_NODE
, &ospf_refresh_timer_cmd
);
9727 install_element(OSPF_NODE
, &no_ospf_refresh_timer_val_cmd
);
9729 /* max-metric commands */
9730 install_element(OSPF_NODE
, &ospf_max_metric_router_lsa_admin_cmd
);
9731 install_element(OSPF_NODE
, &no_ospf_max_metric_router_lsa_admin_cmd
);
9732 install_element(OSPF_NODE
, &ospf_max_metric_router_lsa_startup_cmd
);
9733 install_element(OSPF_NODE
, &no_ospf_max_metric_router_lsa_startup_cmd
);
9734 install_element(OSPF_NODE
, &ospf_max_metric_router_lsa_shutdown_cmd
);
9735 install_element(OSPF_NODE
, &no_ospf_max_metric_router_lsa_shutdown_cmd
);
9737 /* reference bandwidth commands */
9738 install_element(OSPF_NODE
, &ospf_auto_cost_reference_bandwidth_cmd
);
9739 install_element(OSPF_NODE
, &no_ospf_auto_cost_reference_bandwidth_cmd
);
9741 /* "neighbor" commands. */
9742 install_element(OSPF_NODE
, &ospf_neighbor_cmd
);
9743 install_element(OSPF_NODE
, &ospf_neighbor_poll_interval_cmd
);
9744 install_element(OSPF_NODE
, &no_ospf_neighbor_cmd
);
9745 install_element(OSPF_NODE
, &no_ospf_neighbor_poll_cmd
);
9747 /* write multiplier commands */
9748 install_element(OSPF_NODE
, &ospf_write_multiplier_cmd
);
9749 install_element(OSPF_NODE
, &write_multiplier_cmd
);
9750 install_element(OSPF_NODE
, &no_ospf_write_multiplier_cmd
);
9751 install_element(OSPF_NODE
, &no_write_multiplier_cmd
);
9753 /* Init interface related vty commands. */
9756 /* Init zebra related vty commands. */
9757 ospf_vty_zebra_init();