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 DEFUN_NOSH (router_ospf
,
131 "router ospf [(1-65535)]",
132 "Enable a routing process\n"
133 "Start OSPF configuration\n"
137 u_short instance
= 0;
138 int ret
= CMD_SUCCESS
;
140 ospf
= ospf_lookup();
142 vty_out(vty
, "There isn't active ospf instance \n");
143 return CMD_WARNING_CONFIG_FAILED
;
147 instance
= strtoul(argv
[2]->arg
, NULL
, 10);
149 /* The following logic to set the vty qobj index is in place to be able
150 to ignore the commands which dont belong to this instance. */
151 if (ospf
->instance
!= instance
) {
152 VTY_PUSH_CONTEXT_NULL(OSPF_NODE
);
153 ret
= CMD_NOT_MY_INSTANCE
;
155 if (IS_DEBUG_OSPF_EVENT
)
156 zlog_debug("Config command 'router ospf %d' received",
158 ospf
->oi_running
= 1;
159 VTY_PUSH_CONTEXT(OSPF_NODE
, ospf
);
160 ospf_router_id_update(ospf
);
166 DEFUN (no_router_ospf
,
168 "no router ospf [(1-65535)]",
170 "Enable a routing process\n"
171 "Start OSPF configuration\n"
175 u_short instance
= 0;
178 instance
= strtoul(argv
[3]->arg
, NULL
, 10);
180 ospf
= ospf_lookup_instance(instance
);
182 return CMD_NOT_MY_INSTANCE
;
190 DEFUN (ospf_router_id
,
192 "ospf router-id A.B.C.D",
193 "OSPF specific commands\n"
194 "router-id for the OSPF process\n"
195 "OSPF router-id in IP address format\n")
197 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
199 struct listnode
*node
;
200 struct ospf_area
*area
;
201 struct in_addr router_id
;
204 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &router_id
);
206 vty_out(vty
, "Please specify Router ID by A.B.C.D\n");
207 return CMD_WARNING_CONFIG_FAILED
;
210 ospf
->router_id_static
= router_id
;
212 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
))
213 if (area
->full_nbrs
) {
215 "For this router-id change to take effect,"
216 " save config and restart ospfd\n");
220 ospf_router_id_update(ospf
);
225 DEFUN_HIDDEN (ospf_router_id_old
,
226 ospf_router_id_old_cmd
,
228 "router-id for the OSPF process\n"
229 "OSPF router-id in IP address format\n")
231 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
233 struct listnode
*node
;
234 struct ospf_area
*area
;
235 struct in_addr router_id
;
238 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &router_id
);
240 vty_out(vty
, "Please specify Router ID by A.B.C.D\n");
241 return CMD_WARNING_CONFIG_FAILED
;
244 ospf
->router_id_static
= router_id
;
246 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
))
247 if (area
->full_nbrs
) {
249 "For this router-id change to take effect,"
250 " save config and restart ospfd\n");
254 ospf_router_id_update(ospf
);
259 DEFUN (no_ospf_router_id
,
260 no_ospf_router_id_cmd
,
261 "no ospf router-id [A.B.C.D]",
263 "OSPF specific commands\n"
264 "router-id for the OSPF process\n"
265 "OSPF router-id in IP address format\n")
267 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
268 struct listnode
*node
;
269 struct ospf_area
*area
;
271 ospf
->router_id_static
.s_addr
= 0;
273 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
))
274 if (area
->full_nbrs
) {
276 "For this router-id change to take effect,"
277 " save config and restart ospfd\n");
281 ospf_router_id_update(ospf
);
287 static void ospf_passive_interface_default(struct ospf
*ospf
, u_char newval
)
290 struct interface
*ifp
;
291 struct ospf_interface
*oi
;
293 ospf
->passive_interface_default
= newval
;
295 for (ALL_LIST_ELEMENTS_RO(om
->iflist
, ln
, ifp
)) {
296 if (ifp
&& OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp
),
298 UNSET_IF_PARAM(IF_DEF_PARAMS(ifp
), passive_interface
);
300 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, ln
, oi
)) {
301 if (OSPF_IF_PARAM_CONFIGURED(oi
->params
, passive_interface
))
302 UNSET_IF_PARAM(oi
->params
, passive_interface
);
303 /* update multicast memberships */
304 ospf_if_set_multicast(oi
);
308 static void ospf_passive_interface_update_addr(struct ospf
*ospf
,
309 struct interface
*ifp
,
310 struct ospf_if_params
*params
,
316 params
->passive_interface
= value
;
317 if (params
!= IF_DEF_PARAMS(ifp
)) {
318 if (OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp
),
320 dflt
= IF_DEF_PARAMS(ifp
)->passive_interface
;
322 dflt
= ospf
->passive_interface_default
;
325 SET_IF_PARAM(params
, passive_interface
);
327 UNSET_IF_PARAM(params
, passive_interface
);
329 ospf_free_if_params(ifp
, addr
);
330 ospf_if_update_params(ifp
, addr
);
334 static void ospf_passive_interface_update(struct ospf
*ospf
,
335 struct interface
*ifp
,
336 struct ospf_if_params
*params
,
339 params
->passive_interface
= value
;
340 if (params
== IF_DEF_PARAMS(ifp
)) {
341 if (value
!= ospf
->passive_interface_default
)
342 SET_IF_PARAM(params
, passive_interface
);
344 UNSET_IF_PARAM(params
, passive_interface
);
348 DEFUN (ospf_passive_interface
,
349 ospf_passive_interface_addr_cmd
,
350 "passive-interface <IFNAME [A.B.C.D]|default>",
351 "Suppress routing updates on an interface\n"
354 "Suppress routing updates on interfaces by default\n")
356 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
358 struct interface
*ifp
;
359 struct in_addr addr
= {.s_addr
= INADDR_ANY
};
361 struct ospf_if_params
*params
;
362 struct route_node
*rn
;
364 if (strmatch(argv
[1]->text
, "default")) {
365 ospf_passive_interface_default(ospf
, OSPF_IF_PASSIVE
);
369 ifp
= if_get_by_name(argv
[1]->arg
, VRF_DEFAULT
);
371 params
= IF_DEF_PARAMS(ifp
);
374 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
377 "Please specify interface address by A.B.C.D\n");
378 return CMD_WARNING_CONFIG_FAILED
;
381 params
= ospf_get_if_params(ifp
, addr
);
382 ospf_if_update_params(ifp
, addr
);
383 ospf_passive_interface_update_addr(ospf
, ifp
, params
,
384 OSPF_IF_PASSIVE
, addr
);
387 ospf_passive_interface_update(ospf
, ifp
, params
, OSPF_IF_PASSIVE
);
389 /* XXX We should call ospf_if_set_multicast on exactly those
390 * interfaces for which the passive property changed. It is too much
391 * work to determine this set, so we do this for every interface.
392 * This is safe and reasonable because ospf_if_set_multicast uses a
393 * record of joined groups to avoid systems calls if the desired
394 * memberships match the current memership.
397 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
398 struct ospf_interface
*oi
= rn
->info
;
400 if (oi
&& (OSPF_IF_PARAM(oi
, passive_interface
)
402 ospf_if_set_multicast(oi
);
405 * XXX It is not clear what state transitions the interface needs to
406 * undergo when going from active to passive. Fixing this will
407 * require precise identification of interfaces having such a
414 DEFUN (no_ospf_passive_interface
,
415 no_ospf_passive_interface_addr_cmd
,
416 "no passive-interface <IFNAME [A.B.C.D]|default>",
418 "Allow routing updates on an interface\n"
421 "Allow routing updates on interfaces by default\n")
423 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
425 struct interface
*ifp
;
426 struct in_addr addr
= {.s_addr
= INADDR_ANY
};
427 struct ospf_if_params
*params
;
429 struct route_node
*rn
;
431 if (strmatch(argv
[2]->text
, "default")) {
432 ospf_passive_interface_default(ospf
, OSPF_IF_ACTIVE
);
436 ifp
= if_get_by_name(argv
[2]->arg
, VRF_DEFAULT
);
438 params
= IF_DEF_PARAMS(ifp
);
441 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
444 "Please specify interface address by A.B.C.D\n");
445 return CMD_WARNING_CONFIG_FAILED
;
448 params
= ospf_lookup_if_params(ifp
, addr
);
451 ospf_passive_interface_update_addr(ospf
, ifp
, params
,
452 OSPF_IF_ACTIVE
, addr
);
454 ospf_passive_interface_update(ospf
, ifp
, params
, OSPF_IF_ACTIVE
);
456 /* XXX We should call ospf_if_set_multicast on exactly those
457 * interfaces for which the passive property changed. It is too much
458 * work to determine this set, so we do this for every interface.
459 * This is safe and reasonable because ospf_if_set_multicast uses a
460 * record of joined groups to avoid systems calls if the desired
461 * memberships match the current memership.
463 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
464 struct ospf_interface
*oi
= rn
->info
;
467 && (OSPF_IF_PARAM(oi
, passive_interface
) == OSPF_IF_ACTIVE
))
468 ospf_if_set_multicast(oi
);
475 DEFUN (ospf_network_area
,
476 ospf_network_area_cmd
,
477 "network A.B.C.D/M area <A.B.C.D|(0-4294967295)>",
478 "Enable routing on an IP network\n"
479 "OSPF network prefix\n"
480 "Set the OSPF area ID\n"
481 "OSPF area ID in IP address format\n"
482 "OSPF area ID as a decimal value\n")
484 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
485 int idx_ipv4_prefixlen
= 1;
486 int idx_ipv4_number
= 3;
487 struct prefix_ipv4 p
;
488 struct in_addr area_id
;
491 if (ospf
->instance
) {
493 "The network command is not supported in multi-instance ospf\n");
494 return CMD_WARNING_CONFIG_FAILED
;
497 if (ospf
->if_ospf_cli_count
> 0) {
499 "Please remove all ip ospf area x.x.x.x commands first.\n");
500 return CMD_WARNING_CONFIG_FAILED
;
503 /* Get network prefix and Area ID. */
504 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
505 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
507 ret
= ospf_network_set(ospf
, &p
, area_id
, format
);
509 vty_out(vty
, "There is already same network statement.\n");
510 return CMD_WARNING_CONFIG_FAILED
;
516 DEFUN (no_ospf_network_area
,
517 no_ospf_network_area_cmd
,
518 "no network A.B.C.D/M area <A.B.C.D|(0-4294967295)>",
520 "Enable routing on an IP network\n"
521 "OSPF network prefix\n"
522 "Set the OSPF area ID\n"
523 "OSPF area ID in IP address format\n"
524 "OSPF area ID as a decimal value\n")
526 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
527 int idx_ipv4_prefixlen
= 2;
528 int idx_ipv4_number
= 4;
529 struct prefix_ipv4 p
;
530 struct in_addr area_id
;
533 if (ospf
->instance
) {
535 "The network command is not supported in multi-instance ospf\n");
536 return CMD_WARNING_CONFIG_FAILED
;
539 /* Get network prefix and Area ID. */
540 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
541 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
543 ret
= ospf_network_unset(ospf
, &p
, area_id
);
546 "Can't find specified network area configuration.\n");
547 return CMD_WARNING_CONFIG_FAILED
;
553 DEFUN (ospf_area_range
,
555 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [advertise [cost (0-16777215)]]",
556 "OSPF area parameters\n"
557 "OSPF area ID in IP address format\n"
558 "OSPF area ID as a decimal value\n"
559 "Summarize routes matching address/mask (border routers only)\n"
560 "Area range prefix\n"
561 "Advertise this range (default)\n"
562 "User specified metric for this range\n"
563 "Advertised metric for this range\n")
565 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
566 int idx_ipv4_number
= 1;
567 int idx_ipv4_prefixlen
= 3;
569 struct prefix_ipv4 p
;
570 struct in_addr area_id
;
574 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
575 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
577 ospf_area_range_set(ospf
, area_id
, &p
, OSPF_AREA_RANGE_ADVERTISE
);
579 cost
= strtoul(argv
[idx_cost
]->arg
, NULL
, 10);
580 ospf_area_range_cost_set(ospf
, area_id
, &p
, cost
);
586 DEFUN (ospf_area_range_cost
,
587 ospf_area_range_cost_cmd
,
588 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M cost (0-16777215)",
589 "OSPF area parameters\n"
590 "OSPF area ID in IP address format\n"
591 "OSPF area ID as a decimal value\n"
592 "Summarize routes matching address/mask (border routers only)\n"
593 "Area range prefix\n"
594 "User specified metric for this range\n"
595 "Advertised metric for this range\n")
597 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
598 int idx_ipv4_number
= 1;
599 int idx_ipv4_prefixlen
= 3;
601 struct prefix_ipv4 p
;
602 struct in_addr area_id
;
606 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
607 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
609 ospf_area_range_set(ospf
, area_id
, &p
, OSPF_AREA_RANGE_ADVERTISE
);
610 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
613 cost
= strtoul(argv
[idx_cost
]->arg
, NULL
, 10);
614 ospf_area_range_cost_set(ospf
, area_id
, &p
, cost
);
619 DEFUN (ospf_area_range_not_advertise
,
620 ospf_area_range_not_advertise_cmd
,
621 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M not-advertise",
622 "OSPF area parameters\n"
623 "OSPF area ID in IP address format\n"
624 "OSPF area ID as a decimal value\n"
625 "Summarize routes matching address/mask (border routers only)\n"
626 "Area range prefix\n"
627 "DoNotAdvertise this range\n")
629 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
630 int idx_ipv4_number
= 1;
631 int idx_ipv4_prefixlen
= 3;
632 struct prefix_ipv4 p
;
633 struct in_addr area_id
;
636 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
637 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
639 ospf_area_range_set(ospf
, area_id
, &p
, 0);
640 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
646 DEFUN (no_ospf_area_range
,
647 no_ospf_area_range_cmd
,
648 "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [<cost (0-16777215)|advertise [cost (0-16777215)]|not-advertise>]",
650 "OSPF area parameters\n"
651 "OSPF area ID in IP address format\n"
652 "OSPF area ID as a decimal value\n"
653 "Summarize routes matching address/mask (border routers only)\n"
654 "Area range prefix\n"
655 "User specified metric for this range\n"
656 "Advertised metric for this range\n"
657 "Advertise this range (default)\n"
658 "User specified metric for this range\n"
659 "Advertised metric for this range\n"
660 "DoNotAdvertise this range\n")
662 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
663 int idx_ipv4_number
= 2;
664 int idx_ipv4_prefixlen
= 4;
665 struct prefix_ipv4 p
;
666 struct in_addr area_id
;
669 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
670 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
672 ospf_area_range_unset(ospf
, area_id
, &p
);
677 DEFUN (ospf_area_range_substitute
,
678 ospf_area_range_substitute_cmd
,
679 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M",
680 "OSPF area parameters\n"
681 "OSPF area ID in IP address format\n"
682 "OSPF area ID as a decimal value\n"
683 "Summarize routes matching address/mask (border routers only)\n"
684 "Area range prefix\n"
685 "Announce area range as another prefix\n"
686 "Network prefix to be announced instead of range\n")
688 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
689 int idx_ipv4_number
= 1;
690 int idx_ipv4_prefixlen
= 3;
691 int idx_ipv4_prefixlen_2
= 5;
692 struct prefix_ipv4 p
, s
;
693 struct in_addr area_id
;
696 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
697 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
698 str2prefix_ipv4(argv
[idx_ipv4_prefixlen_2
]->arg
, &s
);
700 ospf_area_range_substitute_set(ospf
, area_id
, &p
, &s
);
701 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
707 DEFUN (no_ospf_area_range_substitute
,
708 no_ospf_area_range_substitute_cmd
,
709 "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M",
711 "OSPF area parameters\n"
712 "OSPF area ID in IP address format\n"
713 "OSPF area ID as a decimal value\n"
714 "Summarize routes matching address/mask (border routers only)\n"
715 "Area range prefix\n"
716 "Announce area range as another prefix\n"
717 "Network prefix to be announced instead of range\n")
719 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
720 int idx_ipv4_number
= 2;
721 int idx_ipv4_prefixlen
= 4;
722 int idx_ipv4_prefixlen_2
= 6;
723 struct prefix_ipv4 p
, s
;
724 struct in_addr area_id
;
727 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
728 str2prefix_ipv4(argv
[idx_ipv4_prefixlen
]->arg
, &p
);
729 str2prefix_ipv4(argv
[idx_ipv4_prefixlen_2
]->arg
, &s
);
731 ospf_area_range_substitute_unset(ospf
, area_id
, &p
);
737 /* Command Handler Logic in VLink stuff is delicate!!
739 ALTER AT YOUR OWN RISK!!!!
741 Various dummy values are used to represent 'NoChange' state for
742 VLink configuration NOT being changed by a VLink command, and
743 special syntax is used within the command strings so that the
744 typed in command verbs can be seen in the configuration command
745 bacckend handler. This is to drastically reduce the verbeage
746 required to coe up with a reasonably compatible Cisco VLink command
748 - Matthew Grant <grantma@anathoth.gen.nz>
749 Wed, 21 Feb 2001 15:13:52 +1300
752 /* Configuration data for virtual links
754 struct ospf_vl_config_data
{
755 struct vty
*vty
; /* vty stuff */
756 struct in_addr area_id
; /* area ID from command line */
757 int area_id_fmt
; /* command line area ID format */
758 struct in_addr vl_peer
; /* command line vl_peer */
759 int auth_type
; /* Authehntication type, if given */
760 char *auth_key
; /* simple password if present */
761 int crypto_key_id
; /* Cryptographic key ID */
762 char *md5_key
; /* MD5 authentication key */
763 int hello_interval
; /* Obvious what these are... */
764 int retransmit_interval
;
769 static void ospf_vl_config_data_init(struct ospf_vl_config_data
*vl_config
,
772 memset(vl_config
, 0, sizeof(struct ospf_vl_config_data
));
773 vl_config
->auth_type
= OSPF_AUTH_CMD_NOTSEEN
;
774 vl_config
->vty
= vty
;
777 static struct ospf_vl_data
*
778 ospf_find_vl_data(struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
780 struct ospf_area
*area
;
781 struct ospf_vl_data
*vl_data
;
783 struct in_addr area_id
;
785 vty
= vl_config
->vty
;
786 area_id
= vl_config
->area_id
;
788 if (area_id
.s_addr
== OSPF_AREA_BACKBONE
) {
790 "Configuring VLs over the backbone is not allowed\n");
793 area
= ospf_area_get(ospf
, area_id
);
794 ospf_area_display_format_set(ospf
, area
, vl_config
->area_id_fmt
);
796 if (area
->external_routing
!= OSPF_AREA_DEFAULT
) {
797 if (vl_config
->area_id_fmt
== OSPF_AREA_ID_FMT_DOTTEDQUAD
)
798 vty_out(vty
, "Area %s is %s\n", inet_ntoa(area_id
),
799 area
->external_routing
== OSPF_AREA_NSSA
803 vty_out(vty
, "Area %ld is %s\n",
804 (u_long
)ntohl(area_id
.s_addr
),
805 area
->external_routing
== OSPF_AREA_NSSA
811 if ((vl_data
= ospf_vl_lookup(ospf
, area
, vl_config
->vl_peer
))
813 vl_data
= ospf_vl_data_new(area
, vl_config
->vl_peer
);
814 if (vl_data
->vl_oi
== NULL
) {
815 vl_data
->vl_oi
= ospf_vl_new(ospf
, vl_data
);
816 ospf_vl_add(ospf
, vl_data
);
817 ospf_spf_calculate_schedule(ospf
,
818 SPF_FLAG_CONFIG_CHANGE
);
825 static int ospf_vl_set_security(struct ospf_vl_data
*vl_data
,
826 struct ospf_vl_config_data
*vl_config
)
828 struct crypt_key
*ck
;
830 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
832 vty
= vl_config
->vty
;
834 if (vl_config
->auth_type
!= OSPF_AUTH_CMD_NOTSEEN
) {
835 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), auth_type
);
836 IF_DEF_PARAMS(ifp
)->auth_type
= vl_config
->auth_type
;
839 if (vl_config
->auth_key
) {
840 memset(IF_DEF_PARAMS(ifp
)->auth_simple
, 0,
841 OSPF_AUTH_SIMPLE_SIZE
+ 1);
842 strncpy((char *)IF_DEF_PARAMS(ifp
)->auth_simple
,
843 vl_config
->auth_key
, OSPF_AUTH_SIMPLE_SIZE
);
844 } else if (vl_config
->md5_key
) {
845 if (ospf_crypt_key_lookup(IF_DEF_PARAMS(ifp
)->auth_crypt
,
846 vl_config
->crypto_key_id
)
848 vty_out(vty
, "OSPF: Key %d already exists\n",
849 vl_config
->crypto_key_id
);
850 return CMD_WARNING_CONFIG_FAILED
;
852 ck
= ospf_crypt_key_new();
853 ck
->key_id
= vl_config
->crypto_key_id
;
854 memset(ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+ 1);
855 strncpy((char *)ck
->auth_key
, vl_config
->md5_key
,
858 ospf_crypt_key_add(IF_DEF_PARAMS(ifp
)->auth_crypt
, ck
);
859 } else if (vl_config
->crypto_key_id
!= 0) {
862 if (ospf_crypt_key_lookup(IF_DEF_PARAMS(ifp
)->auth_crypt
,
863 vl_config
->crypto_key_id
)
865 vty_out(vty
, "OSPF: Key %d does not exist\n",
866 vl_config
->crypto_key_id
);
867 return CMD_WARNING_CONFIG_FAILED
;
870 ospf_crypt_key_delete(IF_DEF_PARAMS(ifp
)->auth_crypt
,
871 vl_config
->crypto_key_id
);
877 static int ospf_vl_set_timers(struct ospf_vl_data
*vl_data
,
878 struct ospf_vl_config_data
*vl_config
)
880 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
881 /* Virtual Link data initialised to defaults, so only set
883 if (vl_config
->hello_interval
) {
884 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), v_hello
);
885 IF_DEF_PARAMS(ifp
)->v_hello
= vl_config
->hello_interval
;
888 if (vl_config
->dead_interval
) {
889 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), v_wait
);
890 IF_DEF_PARAMS(ifp
)->v_wait
= vl_config
->dead_interval
;
893 if (vl_config
->retransmit_interval
) {
894 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), retransmit_interval
);
895 IF_DEF_PARAMS(ifp
)->retransmit_interval
=
896 vl_config
->retransmit_interval
;
899 if (vl_config
->transmit_delay
) {
900 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), transmit_delay
);
901 IF_DEF_PARAMS(ifp
)->transmit_delay
= vl_config
->transmit_delay
;
908 /* The business end of all of the above */
909 static int ospf_vl_set(struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
911 struct ospf_vl_data
*vl_data
;
914 vl_data
= ospf_find_vl_data(ospf
, vl_config
);
916 return CMD_WARNING_CONFIG_FAILED
;
918 /* Process this one first as it can have a fatal result, which can
919 only logically occur if the virtual link exists already
920 Thus a command error does not result in a change to the
921 running configuration such as unexpectedly altered timer
923 ret
= ospf_vl_set_security(vl_data
, vl_config
);
924 if (ret
!= CMD_SUCCESS
)
927 /* Set any time based parameters, these area already range checked */
929 ret
= ospf_vl_set_timers(vl_data
, vl_config
);
930 if (ret
!= CMD_SUCCESS
)
936 /* This stuff exists to make specifying all the alias commands A LOT simpler
938 #define VLINK_HELPSTR_IPADDR \
939 "OSPF area parameters\n" \
940 "OSPF area ID in IP address format\n" \
941 "OSPF area ID as a decimal value\n" \
942 "Configure a virtual link\n" \
943 "Router ID of the remote ABR\n"
945 #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
946 "Enable authentication on this virtual link\n" \
949 #define VLINK_HELPSTR_AUTHTYPE_ALL \
950 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
951 "Use null authentication\n" \
952 "Use message-digest authentication\n"
954 #define VLINK_HELPSTR_TIME_PARAM \
955 "Time between HELLO packets\n" \
957 "Time between retransmitting lost link state advertisements\n" \
959 "Link state transmit delay\n" \
961 "Interval time after which a neighbor is declared down\n" \
964 #define VLINK_HELPSTR_AUTH_SIMPLE \
965 "Authentication password (key)\n" \
966 "The OSPF password (key)"
968 #define VLINK_HELPSTR_AUTH_MD5 \
969 "Message digest authentication password (key)\n" \
972 "Use MD5 algorithm\n" \
973 "The OSPF password (key)"
975 DEFUN (ospf_area_vlink
,
977 "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>]",
979 "Enable authentication on this virtual link\n" \
980 "Use null authentication\n" \
981 "Use message-digest authentication\n"
982 "Message digest authentication password (key)\n" \
984 "Use MD5 algorithm\n" \
985 "The OSPF password (key)")
987 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
988 int idx_ipv4_number
= 1;
990 struct ospf_vl_config_data vl_config
;
991 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+ 1];
992 char md5_key
[OSPF_AUTH_MD5_SIZE
+ 1];
996 ospf_vl_config_data_init(&vl_config
, vty
);
998 /* Read off first 2 parameters and check them */
999 ret
= str2area_id(argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
,
1000 &vl_config
.area_id_fmt
);
1002 vty_out(vty
, "OSPF area ID is invalid\n");
1003 return CMD_WARNING_CONFIG_FAILED
;
1006 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1008 vty_out(vty
, "Please specify valid Router ID as a.b.c.d\n");
1009 return CMD_WARNING_CONFIG_FAILED
;
1013 /* Thats all folks! - BUGS B. strikes again!!!*/
1015 return ospf_vl_set(ospf
, &vl_config
);
1018 /* Deal with other parameters */
1019 for (i
= 5; i
< argc
; i
++) {
1021 /* vty_out (vty, "argv[%d]->arg - %s\n", i, argv[i]->text); */
1023 switch (argv
[i
]->arg
[0]) {
1027 || strncmp(argv
[i
]->arg
, "authentication-", 15)
1029 /* authentication-key - this option can occur
1031 command line. At start
1034 authentication option. */
1035 memset(auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1036 strncpy(auth_key
, argv
[i
+ 1]->text
,
1037 OSPF_AUTH_SIMPLE_SIZE
);
1038 vl_config
.auth_key
= auth_key
;
1040 } else if (strncmp(argv
[i
]->arg
, "authentication", 14)
1042 /* authentication - this option can only occur
1045 vl_config
.auth_type
= OSPF_AUTH_SIMPLE
;
1046 if ((i
+ 1) < argc
) {
1047 if (strncmp(argv
[i
+ 1]->arg
, "n", 1)
1049 /* "authentication null" */
1050 vl_config
.auth_type
=
1054 strncmp(argv
[i
+ 1]->arg
, "m",
1059 "message-digest-")) {
1061 * message-digest" */
1062 vl_config
.auth_type
=
1063 OSPF_AUTH_CRYPTOGRAPHIC
;
1071 /* message-digest-key */
1074 vl_config
.crypto_key_id
=
1075 strtol(argv
[i
]->arg
, NULL
, 10);
1076 if (vl_config
.crypto_key_id
< 0)
1077 return CMD_WARNING_CONFIG_FAILED
;
1081 OSPF_AUTH_MD5_SIZE
+ 1);
1082 strncpy(md5_key
, argv
[i
]->arg
,
1083 OSPF_AUTH_MD5_SIZE
);
1084 vl_config
.md5_key
= md5_key
;
1087 vl_config
.md5_key
= NULL
;
1093 /* Action configuration */
1095 return ospf_vl_set(ospf
, &vl_config
);
1098 DEFUN (no_ospf_area_vlink
,
1099 no_ospf_area_vlink_cmd
,
1100 "no area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D [authentication] [<message-digest|null>] [<message-digest-key (1-255) md5 KEY|authentication-key AUTH_KEY>]",
1102 VLINK_HELPSTR_IPADDR
1103 "Enable authentication on this virtual link\n" \
1104 "Use null authentication\n" \
1105 "Use message-digest authentication\n"
1106 "Message digest authentication password (key)\n" \
1108 "Use MD5 algorithm\n" \
1109 "The OSPF password (key)")
1111 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1112 int idx_ipv4_number
= 2;
1114 struct ospf_area
*area
;
1115 struct ospf_vl_config_data vl_config
;
1116 struct ospf_vl_data
*vl_data
= NULL
;
1117 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+ 1];
1121 ospf_vl_config_data_init(&vl_config
, vty
);
1123 ret
= str2area_id(argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
,
1126 vty_out(vty
, "OSPF area ID is invalid\n");
1127 return CMD_WARNING_CONFIG_FAILED
;
1130 area
= ospf_area_lookup_by_area_id(ospf
, vl_config
.area_id
);
1132 vty_out(vty
, "Area does not exist\n");
1133 return CMD_WARNING_CONFIG_FAILED
;
1136 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1138 vty_out(vty
, "Please specify valid Router ID as a.b.c.d\n");
1139 return CMD_WARNING_CONFIG_FAILED
;
1143 /* Basic VLink no command */
1144 /* Thats all folks! - BUGS B. strikes again!!!*/
1145 if ((vl_data
= ospf_vl_lookup(ospf
, area
, vl_config
.vl_peer
)))
1146 ospf_vl_delete(ospf
, vl_data
);
1148 ospf_area_check_free(ospf
, vl_config
.area_id
);
1153 /* If we are down here, we are reseting parameters */
1155 /* Deal with other parameters */
1156 for (i
= 6; i
< argc
; i
++) {
1157 /* vty_out (vty, "argv[%d] - %s\n", i, argv[i]); */
1159 switch (argv
[i
]->arg
[0]) {
1163 || strncmp(argv
[i
]->text
, "authentication-", 15)
1165 /* authentication-key - this option can occur
1167 command line. At start
1170 authentication option. */
1171 memset(auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1172 vl_config
.auth_key
= auth_key
;
1173 } else if (strncmp(argv
[i
]->text
, "authentication", 14)
1175 /* authentication - this option can only occur
1178 vl_config
.auth_type
= OSPF_AUTH_NOTSET
;
1183 /* message-digest-key */
1184 /* Delete one key */
1187 vl_config
.crypto_key_id
=
1188 strtol(argv
[i
]->arg
, NULL
, 10);
1189 if (vl_config
.crypto_key_id
< 0)
1190 return CMD_WARNING_CONFIG_FAILED
;
1191 vl_config
.md5_key
= NULL
;
1193 return CMD_WARNING_CONFIG_FAILED
;
1199 /* Action configuration */
1201 return ospf_vl_set(ospf
, &vl_config
);
1204 DEFUN (ospf_area_vlink_intervals
,
1205 ospf_area_vlink_intervals_cmd
,
1206 "area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D {hello-interval (1-65535)|retransmit-interval (1-65535)|transmit-delay (1-65535)|dead-interval (1-65535)}",
1207 VLINK_HELPSTR_IPADDR
1208 VLINK_HELPSTR_TIME_PARAM
)
1210 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1211 struct ospf_vl_config_data vl_config
;
1214 ospf_vl_config_data_init(&vl_config
, vty
);
1216 char *area_id
= argv
[1]->arg
;
1217 char *router_id
= argv
[3]->arg
;
1219 ret
= str2area_id(area_id
, &vl_config
.area_id
, &vl_config
.area_id_fmt
);
1221 vty_out(vty
, "OSPF area ID is invalid\n");
1222 return CMD_WARNING_CONFIG_FAILED
;
1225 ret
= inet_aton(router_id
, &vl_config
.vl_peer
);
1227 vty_out(vty
, "Please specify valid Router ID as a.b.c.d\n");
1228 return CMD_WARNING_CONFIG_FAILED
;
1231 for (int idx
= 4; idx
< argc
; idx
++) {
1232 if (strmatch(argv
[idx
]->text
, "hello-interval"))
1233 vl_config
.hello_interval
=
1234 strtol(argv
[++idx
]->arg
, NULL
, 10);
1235 else if (strmatch(argv
[idx
]->text
, "retransmit-interval"))
1236 vl_config
.retransmit_interval
=
1237 strtol(argv
[++idx
]->arg
, NULL
, 10);
1238 else if (strmatch(argv
[idx
]->text
, "transmit-delay"))
1239 vl_config
.transmit_delay
=
1240 strtol(argv
[++idx
]->arg
, NULL
, 10);
1241 else if (strmatch(argv
[idx
]->text
, "dead-interval"))
1242 vl_config
.dead_interval
=
1243 strtol(argv
[++idx
]->arg
, NULL
, 10);
1246 /* Action configuration */
1247 return ospf_vl_set(ospf
, &vl_config
);
1250 DEFUN (no_ospf_area_vlink_intervals
,
1251 no_ospf_area_vlink_intervals_cmd
,
1252 "no area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D {hello-interval (1-65535)|retransmit-interval (1-65535)|transmit-delay (1-65535)|dead-interval (1-65535)}",
1254 VLINK_HELPSTR_IPADDR
1255 VLINK_HELPSTR_TIME_PARAM
)
1257 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1258 struct ospf_vl_config_data vl_config
;
1261 ospf_vl_config_data_init(&vl_config
, vty
);
1263 char *area_id
= argv
[2]->arg
;
1264 char *router_id
= argv
[4]->arg
;
1266 ret
= str2area_id(area_id
, &vl_config
.area_id
, &vl_config
.area_id_fmt
);
1268 vty_out(vty
, "OSPF area ID is invalid\n");
1269 return CMD_WARNING_CONFIG_FAILED
;
1272 ret
= inet_aton(router_id
, &vl_config
.vl_peer
);
1274 vty_out(vty
, "Please specify valid Router ID as a.b.c.d\n");
1275 return CMD_WARNING_CONFIG_FAILED
;
1278 for (int idx
= 5; idx
< argc
; idx
++) {
1279 if (strmatch(argv
[idx
]->text
, "hello-interval"))
1280 vl_config
.hello_interval
= OSPF_HELLO_INTERVAL_DEFAULT
;
1281 else if (strmatch(argv
[idx
]->text
, "retransmit-interval"))
1282 vl_config
.retransmit_interval
=
1283 OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
1284 else if (strmatch(argv
[idx
]->text
, "transmit-delay"))
1285 vl_config
.transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
1286 else if (strmatch(argv
[idx
]->text
, "dead-interval"))
1287 vl_config
.dead_interval
=
1288 OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
1291 /* Action configuration */
1292 return ospf_vl_set(ospf
, &vl_config
);
1295 DEFUN (ospf_area_shortcut
,
1296 ospf_area_shortcut_cmd
,
1297 "area <A.B.C.D|(0-4294967295)> shortcut <default|enable|disable>",
1298 "OSPF area parameters\n"
1299 "OSPF area ID in IP address format\n"
1300 "OSPF area ID as a decimal value\n"
1301 "Configure the area's shortcutting mode\n"
1302 "Set default shortcutting behavior\n"
1303 "Enable shortcutting through the area\n"
1304 "Disable shortcutting through the area\n")
1306 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1307 int idx_ipv4_number
= 1;
1308 int idx_enable_disable
= 3;
1309 struct ospf_area
*area
;
1310 struct in_addr area_id
;
1314 VTY_GET_OSPF_AREA_ID_NO_BB("shortcut", area_id
, format
,
1315 argv
[idx_ipv4_number
]->arg
);
1317 area
= ospf_area_get(ospf
, area_id
);
1318 ospf_area_display_format_set(ospf
, area
, format
);
1320 if (strncmp(argv
[idx_enable_disable
]->arg
, "de", 2) == 0)
1321 mode
= OSPF_SHORTCUT_DEFAULT
;
1322 else if (strncmp(argv
[idx_enable_disable
]->arg
, "di", 2) == 0)
1323 mode
= OSPF_SHORTCUT_DISABLE
;
1324 else if (strncmp(argv
[idx_enable_disable
]->arg
, "e", 1) == 0)
1325 mode
= OSPF_SHORTCUT_ENABLE
;
1327 return CMD_WARNING_CONFIG_FAILED
;
1329 ospf_area_shortcut_set(ospf
, area
, mode
);
1331 if (ospf
->abr_type
!= OSPF_ABR_SHORTCUT
)
1333 "Shortcut area setting will take effect "
1334 "only when the router is configured as Shortcut ABR\n");
1339 DEFUN (no_ospf_area_shortcut
,
1340 no_ospf_area_shortcut_cmd
,
1341 "no area <A.B.C.D|(0-4294967295)> shortcut <enable|disable>",
1343 "OSPF area parameters\n"
1344 "OSPF area ID in IP address format\n"
1345 "OSPF area ID as a decimal value\n"
1346 "Deconfigure the area's shortcutting mode\n"
1347 "Deconfigure enabled shortcutting through the area\n"
1348 "Deconfigure disabled shortcutting through the area\n")
1350 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1351 int idx_ipv4_number
= 2;
1352 struct ospf_area
*area
;
1353 struct in_addr area_id
;
1356 VTY_GET_OSPF_AREA_ID_NO_BB("shortcut", area_id
, format
,
1357 argv
[idx_ipv4_number
]->arg
);
1359 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1363 ospf_area_shortcut_unset(ospf
, area
);
1369 DEFUN (ospf_area_stub
,
1371 "area <A.B.C.D|(0-4294967295)> stub",
1372 "OSPF area parameters\n"
1373 "OSPF area ID in IP address format\n"
1374 "OSPF area ID as a decimal value\n"
1375 "Configure OSPF area as stub\n")
1377 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1378 int idx_ipv4_number
= 1;
1379 struct in_addr area_id
;
1382 VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id
, format
,
1383 argv
[idx_ipv4_number
]->arg
);
1385 ret
= ospf_area_stub_set(ospf
, area_id
);
1386 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1390 "First deconfigure all virtual link through this area\n");
1391 return CMD_WARNING_CONFIG_FAILED
;
1394 ospf_area_no_summary_unset(ospf
, area_id
);
1399 DEFUN (ospf_area_stub_no_summary
,
1400 ospf_area_stub_no_summary_cmd
,
1401 "area <A.B.C.D|(0-4294967295)> stub no-summary",
1402 "OSPF stub parameters\n"
1403 "OSPF area ID in IP address format\n"
1404 "OSPF area ID as a decimal value\n"
1405 "Configure OSPF area as stub\n"
1406 "Do not inject inter-area routes into stub\n")
1408 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1409 int idx_ipv4_number
= 1;
1410 struct in_addr area_id
;
1413 VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id
, format
,
1414 argv
[idx_ipv4_number
]->arg
);
1416 ret
= ospf_area_stub_set(ospf
, area_id
);
1417 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1421 "%% Area cannot be stub as it contains a virtual link\n");
1422 return CMD_WARNING_CONFIG_FAILED
;
1425 ospf_area_no_summary_set(ospf
, area_id
);
1430 DEFUN (no_ospf_area_stub
,
1431 no_ospf_area_stub_cmd
,
1432 "no area <A.B.C.D|(0-4294967295)> stub",
1434 "OSPF area parameters\n"
1435 "OSPF area ID in IP address format\n"
1436 "OSPF area ID as a decimal value\n"
1437 "Configure OSPF area as stub\n")
1439 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1440 int idx_ipv4_number
= 2;
1441 struct in_addr area_id
;
1444 VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id
, format
,
1445 argv
[idx_ipv4_number
]->arg
);
1447 ospf_area_stub_unset(ospf
, area_id
);
1448 ospf_area_no_summary_unset(ospf
, area_id
);
1453 DEFUN (no_ospf_area_stub_no_summary
,
1454 no_ospf_area_stub_no_summary_cmd
,
1455 "no area <A.B.C.D|(0-4294967295)> stub no-summary",
1457 "OSPF area parameters\n"
1458 "OSPF area ID in IP address format\n"
1459 "OSPF area ID as a decimal value\n"
1460 "Configure OSPF area as stub\n"
1461 "Do not inject inter-area routes into area\n")
1463 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1464 int idx_ipv4_number
= 2;
1465 struct in_addr area_id
;
1468 VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id
, format
,
1469 argv
[idx_ipv4_number
]->arg
);
1470 ospf_area_no_summary_unset(ospf
, area_id
);
1475 static int ospf_area_nssa_cmd_handler(struct vty
*vty
, int argc
,
1476 struct cmd_token
**argv
, int nosum
)
1478 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1479 struct in_addr area_id
;
1482 VTY_GET_OSPF_AREA_ID_NO_BB("NSSA", area_id
, format
, argv
[1]->arg
);
1484 ret
= ospf_area_nssa_set(ospf
, area_id
);
1485 ospf_area_display_format_set(ospf
, ospf_area_get(ospf
, area_id
),
1489 "%% Area cannot be nssa as it contains a virtual link\n");
1490 return CMD_WARNING_CONFIG_FAILED
;
1494 if (strncmp(argv
[3]->text
, "translate-c", 11) == 0)
1495 ospf_area_nssa_translator_role_set(
1496 ospf
, area_id
, OSPF_NSSA_ROLE_CANDIDATE
);
1497 else if (strncmp(argv
[3]->text
, "translate-n", 11) == 0)
1498 ospf_area_nssa_translator_role_set(
1499 ospf
, area_id
, OSPF_NSSA_ROLE_NEVER
);
1500 else if (strncmp(argv
[3]->text
, "translate-a", 11) == 0)
1501 ospf_area_nssa_translator_role_set(
1502 ospf
, area_id
, OSPF_NSSA_ROLE_ALWAYS
);
1504 ospf_area_nssa_translator_role_set(ospf
, area_id
,
1505 OSPF_NSSA_ROLE_CANDIDATE
);
1509 ospf_area_no_summary_set(ospf
, area_id
);
1511 ospf_area_no_summary_unset(ospf
, area_id
);
1513 ospf_schedule_abr_task(ospf
);
1518 DEFUN (ospf_area_nssa_translate_no_summary
,
1519 ospf_area_nssa_translate_no_summary_cmd
,
1520 "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always> no-summary",
1521 "OSPF area parameters\n"
1522 "OSPF area ID in IP address format\n"
1523 "OSPF area ID as a decimal value\n"
1524 "Configure OSPF area as nssa\n"
1525 "Configure NSSA-ABR for translate election (default)\n"
1526 "Configure NSSA-ABR to never translate\n"
1527 "Configure NSSA-ABR to always translate\n"
1528 "Do not inject inter-area routes into nssa\n")
1530 return ospf_area_nssa_cmd_handler(vty
, argc
, argv
, 1);
1533 DEFUN (ospf_area_nssa_translate
,
1534 ospf_area_nssa_translate_cmd
,
1535 "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always>",
1536 "OSPF area parameters\n"
1537 "OSPF area ID in IP address format\n"
1538 "OSPF area ID as a decimal value\n"
1539 "Configure OSPF area as nssa\n"
1540 "Configure NSSA-ABR for translate election (default)\n"
1541 "Configure NSSA-ABR to never translate\n"
1542 "Configure NSSA-ABR to always translate\n")
1544 return ospf_area_nssa_cmd_handler(vty
, argc
, argv
, 0);
1547 DEFUN (ospf_area_nssa
,
1549 "area <A.B.C.D|(0-4294967295)> nssa",
1550 "OSPF area parameters\n"
1551 "OSPF area ID in IP address format\n"
1552 "OSPF area ID as a decimal value\n"
1553 "Configure OSPF area as nssa\n")
1555 return ospf_area_nssa_cmd_handler(vty
, argc
, argv
, 0);
1558 DEFUN (ospf_area_nssa_no_summary
,
1559 ospf_area_nssa_no_summary_cmd
,
1560 "area <A.B.C.D|(0-4294967295)> nssa no-summary",
1561 "OSPF area parameters\n"
1562 "OSPF area ID in IP address format\n"
1563 "OSPF area ID as a decimal value\n"
1564 "Configure OSPF area as nssa\n"
1565 "Do not inject inter-area routes into nssa\n")
1567 return ospf_area_nssa_cmd_handler(vty
, argc
, argv
, 1);
1570 DEFUN (no_ospf_area_nssa
,
1571 no_ospf_area_nssa_cmd
,
1572 "no area <A.B.C.D|(0-4294967295)> nssa [<translate-candidate|translate-never|translate-always> [no-summary]]",
1574 "OSPF area parameters\n"
1575 "OSPF area ID in IP address format\n"
1576 "OSPF area ID as a decimal value\n"
1577 "Configure OSPF area as nssa\n"
1578 "Configure NSSA-ABR for translate election (default)\n"
1579 "Configure NSSA-ABR to never translate\n"
1580 "Configure NSSA-ABR to always translate\n"
1581 "Do not inject inter-area routes into nssa\n")
1583 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1584 int idx_ipv4_number
= 2;
1585 struct in_addr area_id
;
1588 VTY_GET_OSPF_AREA_ID_NO_BB("NSSA", area_id
, format
,
1589 argv
[idx_ipv4_number
]->arg
);
1591 ospf_area_nssa_unset(ospf
, area_id
);
1592 ospf_area_no_summary_unset(ospf
, area_id
);
1594 ospf_schedule_abr_task(ospf
);
1600 DEFUN (ospf_area_default_cost
,
1601 ospf_area_default_cost_cmd
,
1602 "area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1603 "OSPF area parameters\n"
1604 "OSPF area ID in IP address format\n"
1605 "OSPF area ID as a decimal value\n"
1606 "Set the summary-default cost of a NSSA or stub area\n"
1607 "Stub's advertised default summary cost\n")
1609 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1610 int idx_ipv4_number
= 1;
1612 struct ospf_area
*area
;
1613 struct in_addr area_id
;
1616 struct prefix_ipv4 p
;
1618 VTY_GET_OSPF_AREA_ID_NO_BB("default-cost", area_id
, format
,
1619 argv
[idx_ipv4_number
]->arg
);
1620 cost
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1622 area
= ospf_area_get(ospf
, area_id
);
1623 ospf_area_display_format_set(ospf
, area
, format
);
1625 if (area
->external_routing
== OSPF_AREA_DEFAULT
) {
1626 vty_out(vty
, "The area is neither stub, nor NSSA\n");
1627 return CMD_WARNING_CONFIG_FAILED
;
1630 area
->default_cost
= cost
;
1633 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1635 if (IS_DEBUG_OSPF_EVENT
)
1637 "ospf_abr_announce_stub_defaults(): "
1638 "announcing 0.0.0.0/0 to area %s",
1639 inet_ntoa(area
->area_id
));
1640 ospf_abr_announce_network_to_area(&p
, area
->default_cost
, area
);
1645 DEFUN (no_ospf_area_default_cost
,
1646 no_ospf_area_default_cost_cmd
,
1647 "no area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1649 "OSPF area parameters\n"
1650 "OSPF area ID in IP address format\n"
1651 "OSPF area ID as a decimal value\n"
1652 "Set the summary-default cost of a NSSA or stub area\n"
1653 "Stub's advertised default summary cost\n")
1655 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1656 int idx_ipv4_number
= 2;
1657 struct ospf_area
*area
;
1658 struct in_addr area_id
;
1660 struct prefix_ipv4 p
;
1662 VTY_GET_OSPF_AREA_ID_NO_BB("default-cost", area_id
, format
,
1663 argv
[idx_ipv4_number
]->arg
);
1665 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1669 if (area
->external_routing
== OSPF_AREA_DEFAULT
) {
1670 vty_out(vty
, "The area is neither stub, nor NSSA\n");
1671 return CMD_WARNING_CONFIG_FAILED
;
1674 area
->default_cost
= 1;
1677 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1679 if (IS_DEBUG_OSPF_EVENT
)
1681 "ospf_abr_announce_stub_defaults(): "
1682 "announcing 0.0.0.0/0 to area %s",
1683 inet_ntoa(area
->area_id
));
1684 ospf_abr_announce_network_to_area(&p
, area
->default_cost
, area
);
1687 ospf_area_check_free(ospf
, area_id
);
1692 DEFUN (ospf_area_export_list
,
1693 ospf_area_export_list_cmd
,
1694 "area <A.B.C.D|(0-4294967295)> export-list NAME",
1695 "OSPF area parameters\n"
1696 "OSPF area ID in IP address format\n"
1697 "OSPF area ID as a decimal value\n"
1698 "Set the filter for networks announced to other areas\n"
1699 "Name of the access-list\n")
1701 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1702 int idx_ipv4_number
= 1;
1703 struct ospf_area
*area
;
1704 struct in_addr area_id
;
1707 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1709 area
= ospf_area_get(ospf
, area_id
);
1710 ospf_area_display_format_set(ospf
, area
, format
);
1711 ospf_area_export_list_set(ospf
, area
, argv
[3]->arg
);
1716 DEFUN (no_ospf_area_export_list
,
1717 no_ospf_area_export_list_cmd
,
1718 "no area <A.B.C.D|(0-4294967295)> export-list NAME",
1720 "OSPF area parameters\n"
1721 "OSPF area ID in IP address format\n"
1722 "OSPF area ID as a decimal value\n"
1723 "Unset the filter for networks announced to other areas\n"
1724 "Name of the access-list\n")
1726 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1727 int idx_ipv4_number
= 2;
1728 struct ospf_area
*area
;
1729 struct in_addr area_id
;
1732 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1734 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1738 ospf_area_export_list_unset(ospf
, area
);
1744 DEFUN (ospf_area_import_list
,
1745 ospf_area_import_list_cmd
,
1746 "area <A.B.C.D|(0-4294967295)> import-list NAME",
1747 "OSPF area parameters\n"
1748 "OSPF area ID in IP address format\n"
1749 "OSPF area ID as a decimal value\n"
1750 "Set the filter for networks from other areas announced to the specified one\n"
1751 "Name of the access-list\n")
1753 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1754 int idx_ipv4_number
= 1;
1755 struct ospf_area
*area
;
1756 struct in_addr area_id
;
1759 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1761 area
= ospf_area_get(ospf
, area_id
);
1762 ospf_area_display_format_set(ospf
, area
, format
);
1763 ospf_area_import_list_set(ospf
, area
, argv
[3]->arg
);
1768 DEFUN (no_ospf_area_import_list
,
1769 no_ospf_area_import_list_cmd
,
1770 "no area <A.B.C.D|(0-4294967295)> import-list NAME",
1772 "OSPF area parameters\n"
1773 "OSPF area ID in IP address format\n"
1774 "OSPF area ID as a decimal value\n"
1775 "Unset the filter for networks announced to other areas\n"
1776 "Name of the access-list\n")
1778 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1779 int idx_ipv4_number
= 2;
1780 struct ospf_area
*area
;
1781 struct in_addr area_id
;
1784 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1786 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1790 ospf_area_import_list_unset(ospf
, area
);
1795 DEFUN (ospf_area_filter_list
,
1796 ospf_area_filter_list_cmd
,
1797 "area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>",
1798 "OSPF area parameters\n"
1799 "OSPF area ID in IP address format\n"
1800 "OSPF area ID as a decimal value\n"
1801 "Filter networks between OSPF areas\n"
1802 "Filter prefixes between OSPF areas\n"
1803 "Name of an IP prefix-list\n"
1804 "Filter networks sent to this area\n"
1805 "Filter networks sent from this area\n")
1807 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1808 int idx_ipv4_number
= 1;
1811 struct ospf_area
*area
;
1812 struct in_addr area_id
;
1813 struct prefix_list
*plist
;
1816 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1818 area
= ospf_area_get(ospf
, area_id
);
1819 ospf_area_display_format_set(ospf
, area
, format
);
1820 plist
= prefix_list_lookup(AFI_IP
, argv
[idx_word
]->arg
);
1821 if (strncmp(argv
[idx_in_out
]->arg
, "in", 2) == 0) {
1822 PREFIX_LIST_IN(area
) = plist
;
1823 if (PREFIX_NAME_IN(area
))
1824 free(PREFIX_NAME_IN(area
));
1826 PREFIX_NAME_IN(area
) = strdup(argv
[idx_word
]->arg
);
1827 ospf_schedule_abr_task(ospf
);
1829 PREFIX_LIST_OUT(area
) = plist
;
1830 if (PREFIX_NAME_OUT(area
))
1831 free(PREFIX_NAME_OUT(area
));
1833 PREFIX_NAME_OUT(area
) = strdup(argv
[idx_word
]->arg
);
1834 ospf_schedule_abr_task(ospf
);
1840 DEFUN (no_ospf_area_filter_list
,
1841 no_ospf_area_filter_list_cmd
,
1842 "no area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>",
1844 "OSPF area parameters\n"
1845 "OSPF area ID in IP address format\n"
1846 "OSPF area ID as a decimal value\n"
1847 "Filter networks between OSPF areas\n"
1848 "Filter prefixes between OSPF areas\n"
1849 "Name of an IP prefix-list\n"
1850 "Filter networks sent to this area\n"
1851 "Filter networks sent from this area\n")
1853 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1854 int idx_ipv4_number
= 2;
1857 struct ospf_area
*area
;
1858 struct in_addr area_id
;
1861 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1863 if ((area
= ospf_area_lookup_by_area_id(ospf
, area_id
)) == NULL
)
1866 if (strncmp(argv
[idx_in_out
]->arg
, "in", 2) == 0) {
1867 if (PREFIX_NAME_IN(area
))
1868 if (strcmp(PREFIX_NAME_IN(area
), argv
[idx_word
]->arg
)
1872 PREFIX_LIST_IN(area
) = NULL
;
1873 if (PREFIX_NAME_IN(area
))
1874 free(PREFIX_NAME_IN(area
));
1876 PREFIX_NAME_IN(area
) = NULL
;
1878 ospf_schedule_abr_task(ospf
);
1880 if (PREFIX_NAME_OUT(area
))
1881 if (strcmp(PREFIX_NAME_OUT(area
), argv
[idx_word
]->arg
)
1885 PREFIX_LIST_OUT(area
) = NULL
;
1886 if (PREFIX_NAME_OUT(area
))
1887 free(PREFIX_NAME_OUT(area
));
1889 PREFIX_NAME_OUT(area
) = NULL
;
1891 ospf_schedule_abr_task(ospf
);
1898 DEFUN (ospf_area_authentication_message_digest
,
1899 ospf_area_authentication_message_digest_cmd
,
1900 "area <A.B.C.D|(0-4294967295)> authentication message-digest",
1901 "OSPF area parameters\n"
1902 "OSPF area ID in IP address format\n"
1903 "OSPF area ID as a decimal value\n"
1904 "Enable authentication\n"
1905 "Use message-digest authentication\n")
1907 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1908 int idx_ipv4_number
= 1;
1909 struct ospf_area
*area
;
1910 struct in_addr area_id
;
1913 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1915 area
= ospf_area_get(ospf
, area_id
);
1916 ospf_area_display_format_set(ospf
, area
, format
);
1917 area
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
1922 DEFUN (ospf_area_authentication
,
1923 ospf_area_authentication_cmd
,
1924 "area <A.B.C.D|(0-4294967295)> authentication",
1925 "OSPF area parameters\n"
1926 "OSPF area ID in IP address format\n"
1927 "OSPF area ID as a decimal value\n"
1928 "Enable authentication\n")
1930 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1931 int idx_ipv4_number
= 1;
1932 struct ospf_area
*area
;
1933 struct in_addr area_id
;
1936 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1938 area
= ospf_area_get(ospf
, area_id
);
1939 ospf_area_display_format_set(ospf
, area
, format
);
1940 area
->auth_type
= OSPF_AUTH_SIMPLE
;
1945 DEFUN (no_ospf_area_authentication
,
1946 no_ospf_area_authentication_cmd
,
1947 "no area <A.B.C.D|(0-4294967295)> authentication",
1949 "OSPF area parameters\n"
1950 "OSPF area ID in IP address format\n"
1951 "OSPF area ID as a decimal value\n"
1952 "Enable authentication\n")
1954 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1955 int idx_ipv4_number
= 2;
1956 struct ospf_area
*area
;
1957 struct in_addr area_id
;
1960 VTY_GET_OSPF_AREA_ID(area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1962 area
= ospf_area_lookup_by_area_id(ospf
, area_id
);
1966 area
->auth_type
= OSPF_AUTH_NULL
;
1968 ospf_area_check_free(ospf
, area_id
);
1974 DEFUN (ospf_abr_type
,
1976 "ospf abr-type <cisco|ibm|shortcut|standard>",
1977 "OSPF specific commands\n"
1978 "Set OSPF ABR type\n"
1979 "Alternative ABR, cisco implementation\n"
1980 "Alternative ABR, IBM implementation\n"
1982 "Standard behavior (RFC2328)\n")
1984 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
1986 u_char abr_type
= OSPF_ABR_UNKNOWN
;
1988 if (strncmp(argv
[idx_vendor
]->arg
, "c", 1) == 0)
1989 abr_type
= OSPF_ABR_CISCO
;
1990 else if (strncmp(argv
[idx_vendor
]->arg
, "i", 1) == 0)
1991 abr_type
= OSPF_ABR_IBM
;
1992 else if (strncmp(argv
[idx_vendor
]->arg
, "sh", 2) == 0)
1993 abr_type
= OSPF_ABR_SHORTCUT
;
1994 else if (strncmp(argv
[idx_vendor
]->arg
, "st", 2) == 0)
1995 abr_type
= OSPF_ABR_STAND
;
1997 return CMD_WARNING_CONFIG_FAILED
;
1999 /* If ABR type value is changed, schedule ABR task. */
2000 if (ospf
->abr_type
!= abr_type
) {
2001 ospf
->abr_type
= abr_type
;
2002 ospf_schedule_abr_task(ospf
);
2008 DEFUN (no_ospf_abr_type
,
2009 no_ospf_abr_type_cmd
,
2010 "no ospf abr-type <cisco|ibm|shortcut|standard>",
2012 "OSPF specific commands\n"
2013 "Set OSPF ABR type\n"
2014 "Alternative ABR, cisco implementation\n"
2015 "Alternative ABR, IBM implementation\n"
2019 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2021 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2023 if (strncmp(argv
[idx_vendor
]->arg
, "c", 1) == 0)
2024 abr_type
= OSPF_ABR_CISCO
;
2025 else if (strncmp(argv
[idx_vendor
]->arg
, "i", 1) == 0)
2026 abr_type
= OSPF_ABR_IBM
;
2027 else if (strncmp(argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2028 abr_type
= OSPF_ABR_SHORTCUT
;
2029 else if (strncmp(argv
[idx_vendor
]->arg
, "st", 2) == 0)
2030 abr_type
= OSPF_ABR_STAND
;
2032 return CMD_WARNING_CONFIG_FAILED
;
2034 /* If ABR type value is changed, schedule ABR task. */
2035 if (ospf
->abr_type
== abr_type
) {
2036 ospf
->abr_type
= OSPF_ABR_DEFAULT
;
2037 ospf_schedule_abr_task(ospf
);
2043 DEFUN (ospf_log_adjacency_changes
,
2044 ospf_log_adjacency_changes_cmd
,
2045 "log-adjacency-changes",
2046 "Log changes in adjacency state\n")
2048 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2050 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2051 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2055 DEFUN (ospf_log_adjacency_changes_detail
,
2056 ospf_log_adjacency_changes_detail_cmd
,
2057 "log-adjacency-changes detail",
2058 "Log changes in adjacency state\n"
2059 "Log all state changes\n")
2061 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2063 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2064 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2068 DEFUN (no_ospf_log_adjacency_changes
,
2069 no_ospf_log_adjacency_changes_cmd
,
2070 "no log-adjacency-changes",
2072 "Log changes in adjacency state\n")
2074 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2076 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2077 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2081 DEFUN (no_ospf_log_adjacency_changes_detail
,
2082 no_ospf_log_adjacency_changes_detail_cmd
,
2083 "no log-adjacency-changes detail",
2085 "Log changes in adjacency state\n"
2086 "Log all state changes\n")
2088 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2090 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2094 DEFUN (ospf_compatible_rfc1583
,
2095 ospf_compatible_rfc1583_cmd
,
2096 "compatible rfc1583",
2097 "OSPF compatibility list\n"
2098 "compatible with RFC 1583\n")
2100 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2102 if (!CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)) {
2103 SET_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2104 ospf_spf_calculate_schedule(ospf
, SPF_FLAG_CONFIG_CHANGE
);
2109 DEFUN (no_ospf_compatible_rfc1583
,
2110 no_ospf_compatible_rfc1583_cmd
,
2111 "no compatible rfc1583",
2113 "OSPF compatibility list\n"
2114 "compatible with RFC 1583\n")
2116 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2118 if (CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)) {
2119 UNSET_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2120 ospf_spf_calculate_schedule(ospf
, SPF_FLAG_CONFIG_CHANGE
);
2125 ALIAS(ospf_compatible_rfc1583
, ospf_rfc1583_flag_cmd
,
2126 "ospf rfc1583compatibility",
2127 "OSPF specific commands\n"
2128 "Enable the RFC1583Compatibility flag\n")
2130 ALIAS(no_ospf_compatible_rfc1583
, no_ospf_rfc1583_flag_cmd
,
2131 "no ospf rfc1583compatibility", NO_STR
2132 "OSPF specific commands\n"
2133 "Disable the RFC1583Compatibility flag\n")
2135 static int ospf_timers_spf_set(struct vty
*vty
, unsigned int delay
,
2136 unsigned int hold
, unsigned int max
)
2138 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2140 ospf
->spf_delay
= delay
;
2141 ospf
->spf_holdtime
= hold
;
2142 ospf
->spf_max_holdtime
= max
;
2147 DEFUN (ospf_timers_min_ls_interval
,
2148 ospf_timers_min_ls_interval_cmd
,
2149 "timers throttle lsa all (0-5000)",
2150 "Adjust routing timers\n"
2151 "Throttling adaptive timer\n"
2152 "LSA delay between transmissions\n"
2154 "Delay (msec) between sending LSAs\n")
2156 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2158 unsigned int interval
;
2161 vty_out(vty
, "Insufficient arguments\n");
2162 return CMD_WARNING_CONFIG_FAILED
;
2165 interval
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2167 ospf
->min_ls_interval
= interval
;
2172 DEFUN (no_ospf_timers_min_ls_interval
,
2173 no_ospf_timers_min_ls_interval_cmd
,
2174 "no timers throttle lsa all [(0-5000)]",
2176 "Adjust routing timers\n"
2177 "Throttling adaptive timer\n"
2178 "LSA delay between transmissions\n"
2180 "Delay (msec) between sending LSAs\n")
2182 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2183 ospf
->min_ls_interval
= OSPF_MIN_LS_INTERVAL
;
2188 DEFUN (ospf_timers_throttle_spf
,
2189 ospf_timers_throttle_spf_cmd
,
2190 "timers throttle spf (0-600000) (0-600000) (0-600000)",
2191 "Adjust routing timers\n"
2192 "Throttling adaptive timer\n"
2194 "Delay (msec) from first change received till SPF calculation\n"
2195 "Initial hold time (msec) between consecutive SPF calculations\n"
2196 "Maximum hold time (msec)\n")
2199 int idx_number_2
= 4;
2200 int idx_number_3
= 5;
2201 unsigned int delay
, hold
, max
;
2204 vty_out(vty
, "Insufficient arguments\n");
2205 return CMD_WARNING_CONFIG_FAILED
;
2208 delay
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2209 hold
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
2210 max
= strtoul(argv
[idx_number_3
]->arg
, NULL
, 10);
2212 return ospf_timers_spf_set(vty
, delay
, hold
, max
);
2215 DEFUN (no_ospf_timers_throttle_spf
,
2216 no_ospf_timers_throttle_spf_cmd
,
2217 "no timers throttle spf [(0-600000)(0-600000)(0-600000)]",
2219 "Adjust routing timers\n"
2220 "Throttling adaptive timer\n"
2222 "Delay (msec) from first change received till SPF calculation\n"
2223 "Initial hold time (msec) between consecutive SPF calculations\n"
2224 "Maximum hold time (msec)\n")
2226 return ospf_timers_spf_set(vty
, OSPF_SPF_DELAY_DEFAULT
,
2227 OSPF_SPF_HOLDTIME_DEFAULT
,
2228 OSPF_SPF_MAX_HOLDTIME_DEFAULT
);
2232 DEFUN (ospf_timers_lsa_min_arrival
,
2233 ospf_timers_lsa_min_arrival_cmd
,
2234 "timers lsa min-arrival (0-600000)",
2235 "Adjust routing timers\n"
2237 "Minimum delay in receiving new version of a LSA\n"
2238 "Delay in milliseconds\n")
2240 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2241 ospf
->min_ls_arrival
= strtoul(argv
[argc
- 1]->arg
, NULL
, 10);
2245 DEFUN (no_ospf_timers_lsa_min_arrival
,
2246 no_ospf_timers_lsa_min_arrival_cmd
,
2247 "no timers lsa min-arrival [(0-600000)]",
2249 "Adjust routing timers\n"
2251 "Minimum delay in receiving new version of a LSA\n"
2252 "Delay in milliseconds\n")
2254 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2255 unsigned int minarrival
;
2258 minarrival
= strtoul(argv
[argc
- 1]->arg
, NULL
, 10);
2260 if (ospf
->min_ls_arrival
!= minarrival
2261 || minarrival
== OSPF_MIN_LS_ARRIVAL
)
2265 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2270 /* Deprecated: 08/07/2017 */
2271 ALIAS_HIDDEN (ospf_timers_lsa_min_arrival
,
2272 ospf_timers_lsa_arrival_cmd
,
2273 "timers lsa arrival (0-1000)",
2274 "adjust routing timers\n"
2275 "throttling link state advertisement delays\n"
2276 "ospf minimum arrival interval delay\n"
2277 "delay (msec) between accepted lsas\n");
2279 /* Deprecated: 08/07/2017 */
2280 ALIAS_HIDDEN (no_ospf_timers_lsa_min_arrival
,
2281 no_ospf_timers_lsa_arrival_cmd
,
2282 "no timers lsa arrival (0-1000)",
2284 "adjust routing timers\n"
2285 "throttling link state advertisement delays\n"
2286 "ospf minimum arrival interval delay\n"
2287 "delay (msec) between accepted lsas\n");
2290 DEFUN (ospf_neighbor
,
2292 "neighbor A.B.C.D [priority (0-255) [poll-interval (1-65535)]]",
2294 "Neighbor IP address\n"
2295 "Neighbor Priority\n"
2297 "Dead Neighbor Polling interval\n"
2300 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2304 struct in_addr nbr_addr
;
2305 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2306 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2308 inet_aton(argv
[idx_ipv4
]->arg
, &nbr_addr
);
2311 priority
= strtoul(argv
[idx_pri
]->arg
, NULL
, 10);
2314 interval
= strtoul(argv
[idx_poll
]->arg
, NULL
, 10);
2316 ospf_nbr_nbma_set(ospf
, nbr_addr
);
2319 ospf_nbr_nbma_priority_set(ospf
, nbr_addr
, priority
);
2322 ospf_nbr_nbma_poll_interval_set(ospf
, nbr_addr
, interval
);
2327 DEFUN (ospf_neighbor_poll_interval
,
2328 ospf_neighbor_poll_interval_cmd
,
2329 "neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2331 "Neighbor IP address\n"
2332 "Dead Neighbor Polling interval\n"
2334 "OSPF priority of non-broadcast neighbor\n"
2337 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2341 struct in_addr nbr_addr
;
2342 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2343 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2345 inet_aton(argv
[idx_ipv4
]->arg
, &nbr_addr
);
2347 interval
= strtoul(argv
[idx_poll
]->arg
, NULL
, 10);
2350 priority
= strtoul(argv
[idx_pri
]->arg
, NULL
, 10);
2352 ospf_nbr_nbma_set(ospf
, nbr_addr
);
2353 ospf_nbr_nbma_poll_interval_set(ospf
, nbr_addr
, interval
);
2356 ospf_nbr_nbma_priority_set(ospf
, nbr_addr
, priority
);
2361 DEFUN (no_ospf_neighbor
,
2362 no_ospf_neighbor_cmd
,
2363 "no neighbor A.B.C.D [priority (0-255) [poll-interval (1-65525)]]",
2366 "Neighbor IP address\n"
2367 "Neighbor Priority\n"
2369 "Dead Neighbor Polling interval\n"
2372 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2374 struct in_addr nbr_addr
;
2376 inet_aton(argv
[idx_ipv4
]->arg
, &nbr_addr
);
2378 (void)ospf_nbr_nbma_unset(ospf
, nbr_addr
);
2383 DEFUN (no_ospf_neighbor_poll
,
2384 no_ospf_neighbor_poll_cmd
,
2385 "no neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2388 "Neighbor IP address\n"
2389 "Dead Neighbor Polling interval\n"
2391 "Neighbor Priority\n"
2394 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2396 struct in_addr nbr_addr
;
2398 inet_aton(argv
[idx_ipv4
]->arg
, &nbr_addr
);
2400 (void)ospf_nbr_nbma_unset(ospf
, nbr_addr
);
2405 DEFUN (ospf_refresh_timer
,
2406 ospf_refresh_timer_cmd
,
2407 "refresh timer (10-1800)",
2408 "Adjust refresh parameters\n"
2409 "Set refresh timer\n"
2410 "Timer value in seconds\n")
2412 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2414 unsigned int interval
;
2416 interval
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2417 interval
= (interval
/ OSPF_LSA_REFRESHER_GRANULARITY
)
2418 * OSPF_LSA_REFRESHER_GRANULARITY
;
2420 ospf_timers_refresh_set(ospf
, interval
);
2425 DEFUN (no_ospf_refresh_timer
,
2426 no_ospf_refresh_timer_val_cmd
,
2427 "no refresh timer [(10-1800)]",
2429 "Adjust refresh parameters\n"
2430 "Unset refresh timer\n"
2431 "Timer value in seconds\n")
2433 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2435 unsigned int interval
;
2438 interval
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2440 if (ospf
->lsa_refresh_interval
!= interval
2441 || interval
== OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
2445 ospf_timers_refresh_unset(ospf
);
2451 DEFUN (ospf_auto_cost_reference_bandwidth
,
2452 ospf_auto_cost_reference_bandwidth_cmd
,
2453 "auto-cost reference-bandwidth (1-4294967)",
2454 "Calculate OSPF interface cost according to bandwidth\n"
2455 "Use reference bandwidth method to assign OSPF cost\n"
2456 "The reference bandwidth in terms of Mbits per second\n")
2458 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2461 struct listnode
*node
;
2462 struct interface
*ifp
;
2464 refbw
= strtol(argv
[idx_number
]->arg
, NULL
, 10);
2465 if (refbw
< 1 || refbw
> 4294967) {
2466 vty_out(vty
, "reference-bandwidth value is invalid\n");
2467 return CMD_WARNING_CONFIG_FAILED
;
2470 /* If reference bandwidth is changed. */
2471 if ((refbw
) == ospf
->ref_bandwidth
)
2474 ospf
->ref_bandwidth
= refbw
;
2475 for (ALL_LIST_ELEMENTS_RO(om
->iflist
, node
, ifp
))
2476 ospf_if_recalculate_output_cost(ifp
);
2481 DEFUN (no_ospf_auto_cost_reference_bandwidth
,
2482 no_ospf_auto_cost_reference_bandwidth_cmd
,
2483 "no auto-cost reference-bandwidth [(1-4294967)]",
2485 "Calculate OSPF interface cost according to bandwidth\n"
2486 "Use reference bandwidth method to assign OSPF cost\n"
2487 "The reference bandwidth in terms of Mbits per second\n")
2489 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2490 struct listnode
*node
, *nnode
;
2491 struct interface
*ifp
;
2493 if (ospf
->ref_bandwidth
== OSPF_DEFAULT_REF_BANDWIDTH
)
2496 ospf
->ref_bandwidth
= OSPF_DEFAULT_REF_BANDWIDTH
;
2497 vty_out(vty
, "%% OSPF: Reference bandwidth is changed.\n");
2499 " Please ensure reference bandwidth is consistent across all routers\n");
2501 for (ALL_LIST_ELEMENTS(om
->iflist
, node
, nnode
, ifp
))
2502 ospf_if_recalculate_output_cost(ifp
);
2507 DEFUN (ospf_write_multiplier
,
2508 ospf_write_multiplier_cmd
,
2509 "ospf write-multiplier (1-100)",
2510 "OSPF specific commands\n"
2511 "Write multiplier\n"
2512 "Maximum number of interface serviced per write\n")
2514 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2516 u_int32_t write_oi_count
;
2523 write_oi_count
= strtol(argv
[idx_number
]->arg
, NULL
, 10);
2524 if (write_oi_count
< 1 || write_oi_count
> 100) {
2525 vty_out(vty
, "write-multiplier value is invalid\n");
2526 return CMD_WARNING_CONFIG_FAILED
;
2529 ospf
->write_oi_count
= write_oi_count
;
2533 ALIAS(ospf_write_multiplier
, write_multiplier_cmd
, "write-multiplier (1-100)",
2534 "Write multiplier\n"
2535 "Maximum number of interface serviced per write\n")
2537 DEFUN (no_ospf_write_multiplier
,
2538 no_ospf_write_multiplier_cmd
,
2539 "no ospf write-multiplier (1-100)",
2541 "OSPF specific commands\n"
2542 "Write multiplier\n"
2543 "Maximum number of interface serviced per write\n")
2545 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
2547 ospf
->write_oi_count
= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
;
2551 ALIAS(no_ospf_write_multiplier
, no_write_multiplier_cmd
,
2552 "no write-multiplier (1-100)", NO_STR
2553 "Write multiplier\n"
2554 "Maximum number of interface serviced per write\n")
2556 const char *ospf_abr_type_descr_str
[] = {"Unknown", "Standard (RFC2328)",
2557 "Alternative IBM", "Alternative Cisco",
2558 "Alternative Shortcut"};
2560 const char *ospf_shortcut_mode_descr_str
[] = {"Default", "Enabled", "Disabled"};
2562 static void show_ip_ospf_area(struct vty
*vty
, struct ospf_area
*area
,
2563 json_object
*json_areas
, u_char use_json
)
2565 json_object
*json_area
= NULL
;
2568 json_area
= json_object_new_object();
2572 vty_out(vty
, " Area ID: %s", inet_ntoa(area
->area_id
));
2574 /* Show Area type/mode. */
2575 if (OSPF_IS_AREA_BACKBONE(area
)) {
2577 json_object_boolean_true_add(json_area
, "backbone");
2579 vty_out(vty
, " (Backbone)\n");
2582 if (area
->external_routing
== OSPF_AREA_STUB
) {
2583 if (area
->no_summary
)
2584 json_object_boolean_true_add(
2585 json_area
, "stubNoSummary");
2586 if (area
->shortcut_configured
)
2587 json_object_boolean_true_add(
2588 json_area
, "stubShortcut");
2589 } else if (area
->external_routing
== OSPF_AREA_NSSA
) {
2590 if (area
->no_summary
)
2591 json_object_boolean_true_add(
2592 json_area
, "nssaNoSummary");
2593 if (area
->shortcut_configured
)
2594 json_object_boolean_true_add(
2595 json_area
, "nssaShortcut");
2598 json_object_string_add(
2599 json_area
, "shortcuttingMode",
2600 ospf_shortcut_mode_descr_str
2601 [area
->shortcut_configured
]);
2602 if (area
->shortcut_capability
)
2603 json_object_boolean_true_add(json_area
,
2606 if (area
->external_routing
== OSPF_AREA_STUB
)
2607 vty_out(vty
, " (Stub%s%s)",
2608 area
->no_summary
? ", no summary" : "",
2609 area
->shortcut_configured
? "; " : "");
2610 else if (area
->external_routing
== OSPF_AREA_NSSA
)
2611 vty_out(vty
, " (NSSA%s%s)",
2612 area
->no_summary
? ", no summary" : "",
2613 area
->shortcut_configured
? "; " : "");
2616 vty_out(vty
, " Shortcutting mode: %s",
2617 ospf_shortcut_mode_descr_str
2618 [area
->shortcut_configured
]);
2619 vty_out(vty
, ", S-bit consensus: %s\n",
2620 area
->shortcut_capability
? "ok" : "no");
2624 /* Show number of interfaces */
2626 json_object_int_add(json_area
, "areaIfTotalCounter",
2627 listcount(area
->oiflist
));
2628 json_object_int_add(json_area
, "areaIfActiveCounter",
2632 " Number of interfaces in this area: Total: %d, "
2634 listcount(area
->oiflist
), area
->act_ints
);
2636 if (area
->external_routing
== OSPF_AREA_NSSA
) {
2638 json_object_boolean_true_add(json_area
, "nssa");
2639 if (!IS_OSPF_ABR(area
->ospf
))
2640 json_object_boolean_false_add(json_area
, "abr");
2641 else if (area
->NSSATranslatorState
) {
2642 json_object_boolean_true_add(json_area
, "abr");
2643 if (area
->NSSATranslatorRole
2644 == OSPF_NSSA_ROLE_CANDIDATE
)
2645 json_object_boolean_true_add(
2647 "nssaTranslatorElected");
2648 else if (area
->NSSATranslatorRole
2649 == OSPF_NSSA_ROLE_ALWAYS
)
2650 json_object_boolean_true_add(
2652 "nssaTranslatorAlways");
2654 json_object_boolean_true_add(json_area
, "abr");
2655 if (area
->NSSATranslatorRole
2656 == OSPF_NSSA_ROLE_CANDIDATE
)
2657 json_object_boolean_false_add(
2659 "nssaTranslatorElected");
2661 json_object_boolean_true_add(
2663 "nssaTranslatorNever");
2667 " It is an NSSA configuration. \n Elected NSSA/ABR performs type-7/type-5 LSA translation. \n");
2668 if (!IS_OSPF_ABR(area
->ospf
))
2670 " It is not ABR, therefore not Translator. \n");
2671 else if (area
->NSSATranslatorState
) {
2672 vty_out(vty
, " We are an ABR and ");
2673 if (area
->NSSATranslatorRole
2674 == OSPF_NSSA_ROLE_CANDIDATE
)
2676 "the NSSA Elected Translator. \n");
2677 else if (area
->NSSATranslatorRole
2678 == OSPF_NSSA_ROLE_ALWAYS
)
2680 "always an NSSA Translator. \n");
2682 vty_out(vty
, " We are an ABR, but ");
2683 if (area
->NSSATranslatorRole
2684 == OSPF_NSSA_ROLE_CANDIDATE
)
2686 "not the NSSA Elected Translator. \n");
2689 "never an NSSA Translator. \n");
2694 /* Stub-router state for this area */
2695 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
)) {
2696 char timebuf
[OSPF_TIME_DUMP_SIZE
];
2699 json_object_boolean_true_add(
2700 json_area
, "originStubMaxDistRouterLsa");
2701 if (CHECK_FLAG(area
->stub_router_state
,
2702 OSPF_AREA_ADMIN_STUB_ROUTED
))
2703 json_object_boolean_true_add(
2704 json_area
, "indefiniteActiveAdmin");
2705 if (area
->t_stub_router
) {
2709 &area
->t_stub_router
->u
.sands
,
2712 json_object_int_add(
2714 "activeStartupRemainderMsecs",
2719 " Originating stub / maximum-distance Router-LSA\n");
2720 if (CHECK_FLAG(area
->stub_router_state
,
2721 OSPF_AREA_ADMIN_STUB_ROUTED
))
2723 " Administratively activated (indefinitely)\n");
2724 if (area
->t_stub_router
)
2726 " Active from startup, %s remaining\n",
2727 ospf_timer_dump(area
->t_stub_router
,
2734 /* Show number of fully adjacent neighbors. */
2735 json_object_int_add(json_area
, "nbrFullAdjacentCounter",
2738 /* Show authentication type. */
2739 if (area
->auth_type
== OSPF_AUTH_NULL
)
2740 json_object_string_add(json_area
, "authentication",
2741 "authenticationNone");
2742 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
2743 json_object_string_add(json_area
, "authentication",
2744 "authenticationSimplePassword");
2745 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
2746 json_object_string_add(json_area
, "authentication",
2747 "authenticationMessageDigest");
2749 if (!OSPF_IS_AREA_BACKBONE(area
))
2750 json_object_int_add(json_area
,
2751 "virtualAdjacenciesPassingCounter",
2754 /* Show SPF calculation times. */
2755 json_object_int_add(json_area
, "spfExecutedCounter",
2756 area
->spf_calculation
);
2757 json_object_int_add(json_area
, "lsaNumber", area
->lsdb
->total
);
2758 json_object_int_add(
2759 json_area
, "lsaRouterNumber",
2760 ospf_lsdb_count(area
->lsdb
, OSPF_ROUTER_LSA
));
2761 json_object_int_add(
2762 json_area
, "lsaRouterChecksum",
2763 ospf_lsdb_checksum(area
->lsdb
, OSPF_ROUTER_LSA
));
2764 json_object_int_add(
2765 json_area
, "lsaNetworkNumber",
2766 ospf_lsdb_count(area
->lsdb
, OSPF_NETWORK_LSA
));
2767 json_object_int_add(
2768 json_area
, "lsaNetworkChecksum",
2769 ospf_lsdb_checksum(area
->lsdb
, OSPF_NETWORK_LSA
));
2770 json_object_int_add(
2771 json_area
, "lsaSummaryNumber",
2772 ospf_lsdb_count(area
->lsdb
, OSPF_SUMMARY_LSA
));
2773 json_object_int_add(
2774 json_area
, "lsaSummaryChecksum",
2775 ospf_lsdb_checksum(area
->lsdb
, OSPF_SUMMARY_LSA
));
2776 json_object_int_add(
2777 json_area
, "lsaAsbrNumber",
2778 ospf_lsdb_count(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2779 json_object_int_add(
2780 json_area
, "lsaAsbrChecksum",
2781 ospf_lsdb_checksum(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2782 json_object_int_add(
2783 json_area
, "lsaNssaNumber",
2784 ospf_lsdb_count(area
->lsdb
, OSPF_AS_NSSA_LSA
));
2785 json_object_int_add(
2786 json_area
, "lsaNssaChecksum",
2787 ospf_lsdb_checksum(area
->lsdb
, OSPF_AS_NSSA_LSA
));
2789 /* Show number of fully adjacent neighbors. */
2791 " Number of fully adjacent neighbors in this area:"
2795 /* Show authentication type. */
2796 vty_out(vty
, " Area has ");
2797 if (area
->auth_type
== OSPF_AUTH_NULL
)
2798 vty_out(vty
, "no authentication\n");
2799 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
2800 vty_out(vty
, "simple password authentication\n");
2801 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
2802 vty_out(vty
, "message digest authentication\n");
2804 if (!OSPF_IS_AREA_BACKBONE(area
))
2806 " Number of full virtual adjacencies going through"
2810 /* Show SPF calculation times. */
2811 vty_out(vty
, " SPF algorithm executed %d times\n",
2812 area
->spf_calculation
);
2814 /* Show number of LSA. */
2815 vty_out(vty
, " Number of LSA %ld\n", area
->lsdb
->total
);
2817 " Number of router LSA %ld. Checksum Sum 0x%08x\n",
2818 ospf_lsdb_count(area
->lsdb
, OSPF_ROUTER_LSA
),
2819 ospf_lsdb_checksum(area
->lsdb
, OSPF_ROUTER_LSA
));
2821 " Number of network LSA %ld. Checksum Sum 0x%08x\n",
2822 ospf_lsdb_count(area
->lsdb
, OSPF_NETWORK_LSA
),
2823 ospf_lsdb_checksum(area
->lsdb
, OSPF_NETWORK_LSA
));
2825 " Number of summary LSA %ld. Checksum Sum 0x%08x\n",
2826 ospf_lsdb_count(area
->lsdb
, OSPF_SUMMARY_LSA
),
2827 ospf_lsdb_checksum(area
->lsdb
, OSPF_SUMMARY_LSA
));
2829 " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x\n",
2830 ospf_lsdb_count(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
),
2831 ospf_lsdb_checksum(area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2832 vty_out(vty
, " Number of NSSA LSA %ld. Checksum Sum 0x%08x\n",
2833 ospf_lsdb_count(area
->lsdb
, OSPF_AS_NSSA_LSA
),
2834 ospf_lsdb_checksum(area
->lsdb
, OSPF_AS_NSSA_LSA
));
2838 json_object_int_add(
2839 json_area
, "lsaOpaqueLinkNumber",
2840 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
2841 json_object_int_add(
2842 json_area
, "lsaOpaqueLinkChecksum",
2843 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
2844 json_object_int_add(
2845 json_area
, "lsaOpaqueAreaNumber",
2846 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
2847 json_object_int_add(
2848 json_area
, "lsaOpaqueAreaChecksum",
2849 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
2852 " Number of opaque link LSA %ld. Checksum Sum 0x%08x\n",
2853 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
),
2854 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
2856 " Number of opaque area LSA %ld. Checksum Sum 0x%08x\n",
2857 ospf_lsdb_count(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
),
2858 ospf_lsdb_checksum(area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
2862 json_object_object_add(json_areas
, inet_ntoa(area
->area_id
),
2868 static int show_ip_ospf_common(struct vty
*vty
, struct ospf
*ospf
,
2871 struct listnode
*node
, *nnode
;
2872 struct ospf_area
*area
;
2873 struct timeval result
;
2874 char timebuf
[OSPF_TIME_DUMP_SIZE
];
2875 json_object
*json
= NULL
;
2876 json_object
*json_areas
= NULL
;
2879 json
= json_object_new_object();
2880 json_areas
= json_object_new_object();
2883 if (ospf
->instance
) {
2885 json_object_int_add(json
, "ospfInstance",
2888 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
2892 /* Show Router ID. */
2894 json_object_string_add(json
, "routerId",
2895 inet_ntoa(ospf
->router_id
));
2897 vty_out(vty
, " OSPF Routing Process, Router ID: %s\n",
2898 inet_ntoa(ospf
->router_id
));
2901 /* Graceful shutdown */
2902 if (ospf
->t_deferred_shutdown
) {
2907 &ospf
->t_deferred_shutdown
->u
.sands
,
2910 json_object_int_add(json
, "deferredShutdownMsecs",
2914 " Deferred shutdown in progress, %s remaining\n",
2915 ospf_timer_dump(ospf
->t_deferred_shutdown
,
2916 timebuf
, sizeof(timebuf
)));
2920 /* Show capability. */
2922 json_object_boolean_true_add(json
, "tosRoutesOnly");
2923 json_object_boolean_true_add(json
, "rfc2328Conform");
2924 if (CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)) {
2925 json_object_boolean_true_add(json
,
2926 "rfc1583Compatibility");
2929 vty_out(vty
, " Supports only single TOS (TOS0) routes\n");
2930 vty_out(vty
, " This implementation conforms to RFC2328\n");
2931 vty_out(vty
, " RFC1583Compatibility flag is %s\n",
2932 CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
)
2938 if (CHECK_FLAG(ospf
->config
, OSPF_OPAQUE_CAPABLE
)) {
2939 json_object_boolean_true_add(json
, "opaqueCapable");
2942 vty_out(vty
, " OpaqueCapability flag is %s\n",
2943 CHECK_FLAG(ospf
->config
, OSPF_OPAQUE_CAPABLE
)
2948 /* Show stub-router configuration */
2949 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
2950 || ospf
->stub_router_shutdown_time
2951 != OSPF_STUB_ROUTER_UNCONFIGURED
) {
2953 json_object_boolean_true_add(json
, "stubAdvertisement");
2954 if (ospf
->stub_router_startup_time
2955 != OSPF_STUB_ROUTER_UNCONFIGURED
)
2956 json_object_int_add(
2957 json
, "postStartEnabledMsecs",
2958 ospf
->stub_router_startup_time
/ 1000);
2959 if (ospf
->stub_router_shutdown_time
2960 != OSPF_STUB_ROUTER_UNCONFIGURED
)
2961 json_object_int_add(
2962 json
, "preShutdownEnabledMsecs",
2963 ospf
->stub_router_shutdown_time
/ 1000);
2966 " Stub router advertisement is configured\n");
2967 if (ospf
->stub_router_startup_time
2968 != OSPF_STUB_ROUTER_UNCONFIGURED
)
2970 " Enabled for %us after start-up\n",
2971 ospf
->stub_router_startup_time
);
2972 if (ospf
->stub_router_shutdown_time
2973 != OSPF_STUB_ROUTER_UNCONFIGURED
)
2975 " Enabled for %us prior to full shutdown\n",
2976 ospf
->stub_router_shutdown_time
);
2980 /* Show SPF timers. */
2982 json_object_int_add(json
, "spfScheduleDelayMsecs",
2984 json_object_int_add(json
, "holdtimeMinMsecs",
2985 ospf
->spf_holdtime
);
2986 json_object_int_add(json
, "holdtimeMaxMsecs",
2987 ospf
->spf_max_holdtime
);
2988 json_object_int_add(json
, "holdtimeMultplier",
2989 ospf
->spf_hold_multiplier
);
2992 " Initial SPF scheduling delay %d millisec(s)\n"
2993 " Minimum hold time between consecutive SPFs %d millisec(s)\n"
2994 " Maximum hold time between consecutive SPFs %d millisec(s)\n"
2995 " Hold time multiplier is currently %d\n",
2996 ospf
->spf_delay
, ospf
->spf_holdtime
,
2997 ospf
->spf_max_holdtime
, ospf
->spf_hold_multiplier
);
3001 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
) {
3002 long time_store
= 0;
3005 monotime_since(&ospf
->ts_spf
, NULL
) / 1000LL;
3006 json_object_int_add(json
, "spfLastExecutedMsecs",
3009 time_store
= (1000 * ospf
->ts_spf_duration
.tv_sec
)
3010 + (ospf
->ts_spf_duration
.tv_usec
/ 1000);
3011 json_object_int_add(json
, "spfLastDurationMsecs",
3014 json_object_boolean_true_add(json
, "spfHasNotRun");
3016 vty_out(vty
, " SPF algorithm ");
3017 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
) {
3018 monotime_since(&ospf
->ts_spf
, &result
);
3019 vty_out(vty
, "last executed %s ago\n",
3020 ospf_timeval_dump(&result
, timebuf
,
3022 vty_out(vty
, " Last SPF duration %s\n",
3023 ospf_timeval_dump(&ospf
->ts_spf_duration
,
3024 timebuf
, sizeof(timebuf
)));
3026 vty_out(vty
, "has not been run\n");
3030 if (ospf
->t_spf_calc
) {
3033 monotime_until(&ospf
->t_spf_calc
->u
.sands
, NULL
)
3035 json_object_int_add(json
, "spfTimerDueInMsecs",
3039 json_object_int_add(json
, "lsaMinIntervalMsecs",
3040 ospf
->min_ls_interval
);
3041 json_object_int_add(json
, "lsaMinArrivalMsecs",
3042 ospf
->min_ls_arrival
);
3043 /* Show write multiplier values */
3044 json_object_int_add(json
, "writeMultiplier",
3045 ospf
->write_oi_count
);
3046 /* Show refresh parameters. */
3047 json_object_int_add(json
, "refreshTimerMsecs",
3048 ospf
->lsa_refresh_interval
* 1000);
3050 vty_out(vty
, " SPF timer %s%s\n",
3051 (ospf
->t_spf_calc
? "due in " : "is "),
3052 ospf_timer_dump(ospf
->t_spf_calc
, timebuf
,
3055 vty_out(vty
, " LSA minimum interval %d msecs\n",
3056 ospf
->min_ls_interval
);
3057 vty_out(vty
, " LSA minimum arrival %d msecs\n",
3058 ospf
->min_ls_arrival
);
3060 /* Show write multiplier values */
3061 vty_out(vty
, " Write Multiplier set to %d \n",
3062 ospf
->write_oi_count
);
3064 /* Show refresh parameters. */
3065 vty_out(vty
, " Refresh timer %d secs\n",
3066 ospf
->lsa_refresh_interval
);
3069 /* Show ABR/ASBR flags. */
3070 if (CHECK_FLAG(ospf
->flags
, OSPF_FLAG_ABR
)) {
3072 json_object_string_add(
3074 ospf_abr_type_descr_str
[ospf
->abr_type
]);
3077 " This router is an ABR, ABR type is: %s\n",
3078 ospf_abr_type_descr_str
[ospf
->abr_type
]);
3080 if (CHECK_FLAG(ospf
->flags
, OSPF_FLAG_ASBR
)) {
3082 json_object_string_add(
3084 "injectingExternalRoutingInformation");
3087 " This router is an ASBR "
3088 "(injecting external routing information)\n");
3091 /* Show Number of AS-external-LSAs. */
3093 json_object_int_add(
3094 json
, "lsaExternalCounter",
3095 ospf_lsdb_count(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3096 json_object_int_add(
3097 json
, "lsaExternalChecksum",
3098 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3101 " Number of external LSA %ld. Checksum Sum 0x%08x\n",
3102 ospf_lsdb_count(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
),
3103 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3107 json_object_int_add(
3108 json
, "lsaAsopaqueCounter",
3109 ospf_lsdb_count(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3110 json_object_int_add(
3111 json
, "lsaAsOpaqueChecksum",
3112 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3115 " Number of opaque AS LSA %ld. Checksum Sum 0x%08x\n",
3116 ospf_lsdb_count(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
),
3117 ospf_lsdb_checksum(ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3120 /* Show number of areas attached. */
3122 json_object_int_add(json
, "attachedAreaCounter",
3123 listcount(ospf
->areas
));
3125 vty_out(vty
, " Number of areas attached to this router: %d\n",
3126 listcount(ospf
->areas
));
3128 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
)) {
3129 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
)) {
3131 json_object_boolean_true_add(
3132 json
, "adjacencyChangesLoggedAll");
3135 " All adjacency changes are logged\n");
3138 json_object_boolean_true_add(
3139 json
, "adjacencyChangesLogged");
3141 vty_out(vty
, " Adjacency changes are logged\n");
3144 /* Show each area status. */
3145 for (ALL_LIST_ELEMENTS(ospf
->areas
, node
, nnode
, area
))
3146 show_ip_ospf_area(vty
, area
, json_areas
, use_json
);
3149 json_object_object_add(json
, "areas", json_areas
);
3150 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
3151 json
, JSON_C_TO_STRING_PRETTY
));
3152 json_object_free(json
);
3159 DEFUN (show_ip_ospf
,
3161 "show ip ospf [json]",
3164 "OSPF information\n"
3168 u_char uj
= use_json(argc
, argv
);
3170 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3173 return (show_ip_ospf_common(vty
, ospf
, uj
));
3176 DEFUN (show_ip_ospf_instance
,
3177 show_ip_ospf_instance_cmd
,
3178 "show ip ospf (1-65535) [json]",
3181 "OSPF information\n"
3187 u_short instance
= 0;
3188 u_char uj
= use_json(argc
, argv
);
3190 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3191 ospf
= ospf_lookup_instance(instance
);
3193 return CMD_NOT_MY_INSTANCE
;
3195 if (!ospf
->oi_running
)
3198 return (show_ip_ospf_common(vty
, ospf
, uj
));
3201 static void show_ip_ospf_interface_sub(struct vty
*vty
, struct ospf
*ospf
,
3202 struct interface
*ifp
,
3203 json_object
*json_interface_sub
,
3207 struct ospf_neighbor
*nbr
;
3208 struct route_node
*rn
;
3209 uint32_t bandwidth
= ifp
->bandwidth
? ifp
->bandwidth
: ifp
->speed
;
3211 /* Is interface up? */
3213 is_up
= if_is_operative(ifp
);
3215 json_object_boolean_true_add(json_interface_sub
,
3218 json_object_boolean_false_add(json_interface_sub
,
3221 json_object_int_add(json_interface_sub
, "ifIndex",
3223 json_object_int_add(json_interface_sub
, "mtuBytes", ifp
->mtu
);
3224 json_object_int_add(json_interface_sub
, "bandwidthMbit",
3226 json_object_string_add(json_interface_sub
, "ifFlags",
3227 if_flag_dump(ifp
->flags
));
3229 vty_out(vty
, "%s is %s\n", ifp
->name
,
3230 ((is_up
= if_is_operative(ifp
)) ? "up" : "down"));
3231 vty_out(vty
, " ifindex %u, MTU %u bytes, BW %u Mbit %s\n",
3232 ifp
->ifindex
, ifp
->mtu
, bandwidth
,
3233 if_flag_dump(ifp
->flags
));
3236 /* Is interface OSPF enabled? */
3238 if (ospf_oi_count(ifp
) == 0) {
3239 json_object_boolean_false_add(json_interface_sub
,
3242 } else if (!is_up
) {
3243 json_object_boolean_false_add(json_interface_sub
,
3247 json_object_boolean_true_add(json_interface_sub
,
3250 if (ospf_oi_count(ifp
) == 0) {
3251 vty_out(vty
, " OSPF not enabled on this interface\n");
3253 } else if (!is_up
) {
3255 " OSPF is enabled, but not running on this interface\n");
3260 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
3261 struct ospf_interface
*oi
= rn
->info
;
3266 if (CHECK_FLAG(oi
->connected
->flags
, ZEBRA_IFA_UNNUMBERED
)) {
3268 json_object_boolean_true_add(json_interface_sub
,
3271 vty_out(vty
, " This interface is UNNUMBERED,");
3273 /* Show OSPF interface information. */
3275 json_object_string_add(
3276 json_interface_sub
, "ipAddress",
3277 inet_ntoa(oi
->address
->u
.prefix4
));
3278 json_object_int_add(json_interface_sub
,
3279 "ipAddressPrefixlen",
3280 oi
->address
->prefixlen
);
3282 vty_out(vty
, " Internet Address %s/%d,",
3283 inet_ntoa(oi
->address
->u
.prefix4
),
3284 oi
->address
->prefixlen
);
3286 if (oi
->connected
->destination
3287 || oi
->type
== OSPF_IFTYPE_VIRTUALLINK
) {
3288 struct in_addr
*dest
;
3291 if (CONNECTED_PEER(oi
->connected
)
3292 || oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3297 /* For Vlinks, showing the peer address is
3299 * * * * * informative than the local
3300 * interface that is being used
3302 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3303 dest
= &oi
->vl_data
->peer_addr
;
3305 dest
= &oi
->connected
->destination
->u
3309 json_object_string_add(
3311 "ospfIfType", dstr
);
3312 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3313 json_object_string_add(
3318 json_object_string_add(
3323 vty_out(vty
, " %s %s,", dstr
,
3328 json_object_string_add(json_interface_sub
, "area",
3329 ospf_area_desc_string(oi
->area
));
3330 if (OSPF_IF_PARAM(oi
, mtu_ignore
))
3331 json_object_boolean_true_add(
3333 "mtuMismatchDetect");
3334 json_object_string_add(json_interface_sub
, "routerId",
3335 inet_ntoa(ospf
->router_id
));
3336 json_object_string_add(json_interface_sub
,
3338 ospf_network_type_str
[oi
->type
]);
3339 json_object_int_add(json_interface_sub
, "cost",
3341 json_object_int_add(
3342 json_interface_sub
, "transmitDelayMsecs",
3343 1000 / OSPF_IF_PARAM(oi
, transmit_delay
));
3344 json_object_string_add(json_interface_sub
, "state",
3345 lookup_msg(ospf_ism_state_msg
,
3347 json_object_int_add(json_interface_sub
, "priority",
3350 vty_out(vty
, " Area %s\n",
3351 ospf_area_desc_string(oi
->area
));
3353 vty_out(vty
, " MTU mismatch detection: %s\n",
3354 OSPF_IF_PARAM(oi
, mtu_ignore
) ? "disabled"
3358 " Router ID %s, Network Type %s, Cost: %d\n",
3359 inet_ntoa(ospf
->router_id
),
3360 ospf_network_type_str
[oi
->type
],
3364 " Transmit Delay is %d sec, State %s, Priority %d\n",
3365 OSPF_IF_PARAM(oi
, transmit_delay
),
3366 lookup_msg(ospf_ism_state_msg
, oi
->state
, NULL
),
3370 /* Show DR information. */
3371 if (DR(oi
).s_addr
== 0) {
3374 " No backup designated router on this network\n");
3376 nbr
= ospf_nbr_lookup_by_addr(oi
->nbrs
, &BDR(oi
));
3380 " No backup designated router on this network\n");
3383 json_object_string_add(
3384 json_interface_sub
, "bdrId",
3385 inet_ntoa(nbr
->router_id
));
3386 json_object_string_add(
3389 inet_ntoa(nbr
->address
.u
3393 " Backup Designated Router (ID) %s,",
3394 inet_ntoa(nbr
->router_id
));
3395 vty_out(vty
, " Interface Address %s\n",
3396 inet_ntoa(nbr
->address
.u
3402 /* Next network-LSA sequence number we'll use, if we're elected
3405 && ntohl(oi
->params
->network_lsa_seqnum
)
3406 != OSPF_INITIAL_SEQUENCE_NUMBER
) {
3408 json_object_int_add(
3410 "networkLsaSequence",
3411 ntohl(oi
->params
->network_lsa_seqnum
));
3414 " Saved Network-LSA sequence number 0x%x\n",
3415 ntohl(oi
->params
->network_lsa_seqnum
));
3419 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3420 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
)) {
3421 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3422 json_object_boolean_true_add(
3424 "mcastMemberOspfAllRouters");
3425 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3426 json_object_boolean_true_add(
3428 "mcastMemberOspfDesignatedRouters");
3431 vty_out(vty
, " Multicast group memberships:");
3432 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3433 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
)) {
3434 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3435 vty_out(vty
, " OSPFAllRouters");
3436 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3437 vty_out(vty
, " OSPFDesignatedRouters");
3439 vty_out(vty
, " <None>");
3444 if (OSPF_IF_PARAM(oi
, fast_hello
) == 0)
3445 json_object_int_add(
3446 json_interface_sub
, "timerMsecs",
3447 1000 / OSPF_IF_PARAM(oi
, v_hello
));
3449 json_object_int_add(
3450 json_interface_sub
, "timerMsecs",
3451 1000 / OSPF_IF_PARAM(oi
, fast_hello
));
3452 json_object_int_add(json_interface_sub
,
3454 1000 / OSPF_IF_PARAM(oi
, v_wait
));
3455 json_object_int_add(json_interface_sub
,
3457 1000 / OSPF_IF_PARAM(oi
, v_wait
));
3458 json_object_int_add(
3459 json_interface_sub
, "timerRetransmit",
3460 1000 / OSPF_IF_PARAM(oi
, retransmit_interval
));
3462 vty_out(vty
, " Timer intervals configured,");
3463 vty_out(vty
, " Hello ");
3464 if (OSPF_IF_PARAM(oi
, fast_hello
) == 0)
3465 vty_out(vty
, "%ds,",
3466 OSPF_IF_PARAM(oi
, v_hello
));
3468 vty_out(vty
, "%dms,",
3469 1000 / OSPF_IF_PARAM(oi
, fast_hello
));
3470 vty_out(vty
, " Dead %ds, Wait %ds, Retransmit %d\n",
3471 OSPF_IF_PARAM(oi
, v_wait
),
3472 OSPF_IF_PARAM(oi
, v_wait
),
3473 OSPF_IF_PARAM(oi
, retransmit_interval
));
3476 if (OSPF_IF_PASSIVE_STATUS(oi
) == OSPF_IF_ACTIVE
) {
3477 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3479 long time_store
= 0;
3483 &oi
->t_hello
->u
.sands
,
3486 json_object_int_add(json_interface_sub
,
3487 "timerHelloInMsecs",
3490 vty_out(vty
, " Hello due in %s\n",
3491 ospf_timer_dump(oi
->t_hello
, timebuf
,
3493 } else /* passive-interface is set */
3496 json_object_boolean_true_add(
3498 "timerPassiveIface");
3501 " No Hellos (Passive interface)\n");
3505 json_object_int_add(json_interface_sub
, "nbrCount",
3506 ospf_nbr_count(oi
, 0));
3507 json_object_int_add(json_interface_sub
,
3509 ospf_nbr_count(oi
, NSM_Full
));
3512 " Neighbor Count is %d, Adjacent neighbor count is %d\n",
3513 ospf_nbr_count(oi
, 0),
3514 ospf_nbr_count(oi
, NSM_Full
));
3515 ospf_bfd_interface_show(vty
, ifp
, json_interface_sub
, use_json
);
3519 static int show_ip_ospf_interface_common(struct vty
*vty
, struct ospf
*ospf
,
3520 int argc
, struct cmd_token
**argv
,
3521 int iface_argv
, u_char use_json
)
3523 struct interface
*ifp
;
3524 struct listnode
*node
;
3525 json_object
*json
= NULL
;
3526 json_object
*json_interface_sub
= NULL
;
3529 json
= json_object_new_object();
3532 if (ospf
->instance
) {
3534 json_object_int_add(json
, "ospfInstance",
3537 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
3540 if (argc
== iface_argv
) {
3541 /* Show All Interfaces.*/
3542 for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT
), node
, ifp
)) {
3543 if (ospf_oi_count(ifp
)) {
3545 json_interface_sub
=
3546 json_object_new_object();
3548 show_ip_ospf_interface_sub(vty
, ospf
, ifp
,
3553 json_object_object_add(
3555 json_interface_sub
);
3559 /* Interface name is specified. */
3560 if ((ifp
= if_lookup_by_name(argv
[iface_argv
]->arg
,
3564 json_object_boolean_true_add(json
,
3567 vty_out(vty
, "No such interface name\n");
3570 json_interface_sub
= json_object_new_object();
3572 show_ip_ospf_interface_sub(
3573 vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3576 json_object_object_add(json
, ifp
->name
,
3577 json_interface_sub
);
3582 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
3583 json
, JSON_C_TO_STRING_PRETTY
));
3584 json_object_free(json
);
3591 DEFUN (show_ip_ospf_interface
,
3592 show_ip_ospf_interface_cmd
,
3593 "show ip ospf interface [INTERFACE] [json]",
3596 "OSPF information\n"
3597 "Interface information\n"
3602 u_char uj
= use_json(argc
, argv
);
3604 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3610 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 4, uj
);
3613 DEFUN (show_ip_ospf_instance_interface
,
3614 show_ip_ospf_instance_interface_cmd
,
3615 "show ip ospf (1-65535) interface [INTERFACE] [json]",
3618 "OSPF information\n"
3620 "Interface information\n"
3626 u_short instance
= 0;
3627 u_char uj
= use_json(argc
, argv
);
3629 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3630 ospf
= ospf_lookup_instance(instance
);
3632 return CMD_NOT_MY_INSTANCE
;
3634 if (!ospf
->oi_running
)
3640 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 5, uj
);
3643 static void show_ip_ospf_neighbour_header(struct vty
*vty
)
3645 vty_out(vty
, "\n%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s\n",
3646 "Neighbor ID", "Pri", "State", "Dead Time", "Address",
3647 "Interface", "RXmtL", "RqstL", "DBsmL");
3650 static void show_ip_ospf_neighbor_sub(struct vty
*vty
,
3651 struct ospf_interface
*oi
,
3652 json_object
*json
, u_char use_json
)
3654 struct route_node
*rn
;
3655 struct ospf_neighbor
*nbr
;
3657 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3658 json_object
*json_neighbor
= NULL
;
3660 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
)) {
3661 if ((nbr
= rn
->info
)) {
3662 /* Do not show myself. */
3663 if (nbr
!= oi
->nbr_self
) {
3664 /* Down state is not shown. */
3665 if (nbr
->state
!= NSM_Down
) {
3668 json_object_new_object();
3669 ospf_nbr_state_message(
3682 json_object_int_add(
3686 json_object_string_add(
3687 json_neighbor
, "state",
3689 json_object_int_add(
3693 json_object_string_add(
3696 inet_ntoa(nbr
->src
));
3697 json_object_string_add(
3701 json_object_int_add(
3703 "retransmitCounter",
3704 ospf_ls_retransmit_count(
3706 json_object_int_add(
3709 ospf_ls_request_count(
3711 json_object_int_add(
3714 ospf_db_summary_count(
3716 if (nbr
->state
== NSM_Attempt
3717 && nbr
->router_id
.s_addr
3719 json_object_object_add(
3724 json_object_object_add(
3730 ospf_nbr_state_message(
3733 if (nbr
->state
== NSM_Attempt
3734 && nbr
->router_id
.s_addr
3749 vty_out(vty
, "%9s ",
3754 vty_out(vty
, "%-15s ",
3755 inet_ntoa(nbr
->src
));
3757 "%-20s %5ld %5ld %5d\n",
3759 ospf_ls_retransmit_count(
3761 ospf_ls_request_count(
3763 ospf_db_summary_count(
3772 static int show_ip_ospf_neighbor_common(struct vty
*vty
, struct ospf
*ospf
,
3775 struct ospf_interface
*oi
;
3776 struct listnode
*node
;
3777 json_object
*json
= NULL
;
3780 json
= json_object_new_object();
3782 show_ip_ospf_neighbour_header(vty
);
3784 if (ospf
->instance
) {
3786 json_object_int_add(json
, "ospfInstance",
3789 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
3792 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
))
3793 show_ip_ospf_neighbor_sub(vty
, oi
, json
, use_json
);
3796 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
3797 json
, JSON_C_TO_STRING_PRETTY
));
3798 json_object_free(json
);
3805 DEFUN (show_ip_ospf_neighbor
,
3806 show_ip_ospf_neighbor_cmd
,
3807 "show ip ospf neighbor [json]",
3810 "OSPF information\n"
3815 u_char uj
= use_json(argc
, argv
);
3817 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3820 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
3824 DEFUN (show_ip_ospf_instance_neighbor
,
3825 show_ip_ospf_instance_neighbor_cmd
,
3826 "show ip ospf (1-65535) neighbor [json]",
3829 "OSPF information\n"
3836 u_short instance
= 0;
3837 u_char uj
= use_json(argc
, argv
);
3839 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3840 ospf
= ospf_lookup_instance(instance
);
3842 return CMD_NOT_MY_INSTANCE
;
3844 if (!ospf
->oi_running
)
3847 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
3850 static int show_ip_ospf_neighbor_all_common(struct vty
*vty
, struct ospf
*ospf
,
3853 struct listnode
*node
;
3854 struct ospf_interface
*oi
;
3855 json_object
*json
= NULL
;
3856 json_object
*json_neighbor_sub
= NULL
;
3859 json
= json_object_new_object();
3860 json_neighbor_sub
= json_object_new_object();
3862 show_ip_ospf_neighbour_header(vty
);
3864 if (ospf
->instance
) {
3866 json_object_int_add(json
, "ospfInstance",
3869 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
3872 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
3873 struct listnode
*nbr_node
;
3874 struct ospf_nbr_nbma
*nbr_nbma
;
3876 show_ip_ospf_neighbor_sub(vty
, oi
, json
, use_json
);
3878 /* print Down neighbor status */
3879 for (ALL_LIST_ELEMENTS_RO(oi
->nbr_nbma
, nbr_node
, nbr_nbma
)) {
3880 if (nbr_nbma
->nbr
== NULL
3881 || nbr_nbma
->nbr
->state
== NSM_Down
) {
3883 json_object_int_add(json_neighbor_sub
,
3885 nbr_nbma
->priority
);
3886 json_object_boolean_true_add(
3889 json_object_string_add(
3893 json_object_int_add(
3895 "nbrNbmaRetransmitCounter", 0);
3896 json_object_int_add(
3898 "nbrNbmaRequestCounter", 0);
3899 json_object_int_add(
3901 "nbrNbmaDbSummaryCounter", 0);
3902 json_object_object_add(
3903 json
, inet_ntoa(nbr_nbma
->addr
),
3906 vty_out(vty
, "%-15s %3d %-15s %9s ",
3907 "-", nbr_nbma
->priority
, "Down",
3910 "%-15s %-20s %5d %5d %5d\n",
3911 inet_ntoa(nbr_nbma
->addr
),
3912 IF_NAME(oi
), 0, 0, 0);
3919 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
3920 json
, JSON_C_TO_STRING_PRETTY
));
3921 json_object_free(json
);
3928 DEFUN (show_ip_ospf_neighbor_all
,
3929 show_ip_ospf_neighbor_all_cmd
,
3930 "show ip ospf neighbor all [json]",
3933 "OSPF information\n"
3935 "include down status neighbor\n"
3939 u_char uj
= use_json(argc
, argv
);
3941 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3944 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
3947 DEFUN (show_ip_ospf_instance_neighbor_all
,
3948 show_ip_ospf_instance_neighbor_all_cmd
,
3949 "show ip ospf (1-65535) neighbor all [json]",
3952 "OSPF information\n"
3955 "include down status neighbor\n"
3960 u_short instance
= 0;
3961 u_char uj
= use_json(argc
, argv
);
3963 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3964 ospf
= ospf_lookup_instance(instance
);
3966 return CMD_NOT_MY_INSTANCE
;
3968 if (!ospf
->oi_running
)
3971 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
3974 static int show_ip_ospf_neighbor_int_common(struct vty
*vty
, struct ospf
*ospf
,
3976 struct cmd_token
**argv
,
3979 struct interface
*ifp
;
3980 struct route_node
*rn
;
3981 json_object
*json
= NULL
;
3984 json
= json_object_new_object();
3986 show_ip_ospf_neighbour_header(vty
);
3988 if (ospf
->instance
) {
3990 json_object_int_add(json
, "ospfInstance",
3993 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
3996 ifp
= if_lookup_by_name(argv
[arg_base
]->arg
, VRF_DEFAULT
);
3999 json_object_boolean_true_add(json
, "noSuchIface");
4001 vty_out(vty
, "No such interface.\n");
4005 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
4006 struct ospf_interface
*oi
= rn
->info
;
4011 show_ip_ospf_neighbor_sub(vty
, oi
, json
, use_json
);
4015 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
4016 json
, JSON_C_TO_STRING_PRETTY
));
4017 json_object_free(json
);
4024 DEFUN (show_ip_ospf_neighbor_int
,
4025 show_ip_ospf_neighbor_int_cmd
,
4026 "show ip ospf neighbor IFNAME [json]",
4029 "OSPF information\n"
4035 u_char uj
= use_json(argc
, argv
);
4037 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4040 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 0, argv
, uj
);
4043 DEFUN (show_ip_ospf_instance_neighbor_int
,
4044 show_ip_ospf_instance_neighbor_int_cmd
,
4045 "show ip ospf (1-65535) neighbor IFNAME [json]",
4048 "OSPF information\n"
4056 u_short instance
= 0;
4057 u_char uj
= use_json(argc
, argv
);
4059 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4060 ospf
= ospf_lookup_instance(instance
);
4062 return CMD_NOT_MY_INSTANCE
;
4064 if (!ospf
->oi_running
)
4067 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 1, argv
, uj
);
4070 static void show_ip_ospf_nbr_nbma_detail_sub(struct vty
*vty
,
4071 struct ospf_interface
*oi
,
4072 struct ospf_nbr_nbma
*nbr_nbma
,
4073 u_char use_json
, json_object
*json
)
4075 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4076 json_object
*json_sub
= NULL
;
4079 json_sub
= json_object_new_object();
4080 else /* Show neighbor ID. */
4081 vty_out(vty
, " Neighbor %s,", "-");
4083 /* Show interface address. */
4085 json_object_string_add(json_sub
, "ifaceAddress",
4086 inet_ntoa(nbr_nbma
->addr
));
4088 vty_out(vty
, " interface address %s\n",
4089 inet_ntoa(nbr_nbma
->addr
));
4093 json_object_string_add(json_sub
, "areaId",
4094 ospf_area_desc_string(oi
->area
));
4095 json_object_string_add(json_sub
, "iface", IF_NAME(oi
));
4097 vty_out(vty
, " In the area %s via interface %s\n",
4098 ospf_area_desc_string(oi
->area
), IF_NAME(oi
));
4100 /* Show neighbor priority and state. */
4102 json_object_int_add(json_sub
, "nbrPriority",
4103 nbr_nbma
->priority
);
4104 json_object_string_add(json_sub
, "nbrState", "down");
4106 vty_out(vty
, " Neighbor priority is %d, State is %s,",
4107 nbr_nbma
->priority
, "Down");
4109 /* Show state changes. */
4111 json_object_int_add(json_sub
, "stateChangeCounter",
4112 nbr_nbma
->state_change
);
4114 vty_out(vty
, " %d state changes\n", nbr_nbma
->state_change
);
4116 /* Show PollInterval */
4118 json_object_int_add(json_sub
, "pollInterval", nbr_nbma
->v_poll
);
4120 vty_out(vty
, " Poll interval %d\n", nbr_nbma
->v_poll
);
4122 /* Show poll-interval timer. */
4125 time_store
= monotime_until(&nbr_nbma
->t_poll
->u
.sands
, NULL
)
4127 json_object_int_add(json_sub
, "pollIntervalTimerDueMsec",
4130 vty_out(vty
, " Poll timer due in %s\n",
4131 ospf_timer_dump(nbr_nbma
->t_poll
, timebuf
,
4134 /* Show poll-interval timer thread. */
4136 if (nbr_nbma
->t_poll
!= NULL
)
4137 json_object_string_add(json_sub
,
4138 "pollIntervalTimerThread", "on");
4140 vty_out(vty
, " Thread Poll Timer %s\n",
4141 nbr_nbma
->t_poll
!= NULL
? "on" : "off");
4144 json_object_object_add(json
, "noNbrId", json_sub
);
4147 static void show_ip_ospf_neighbor_detail_sub(struct vty
*vty
,
4148 struct ospf_interface
*oi
,
4149 struct ospf_neighbor
*nbr
,
4150 u_char use_json
, json_object
*json
)
4152 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4153 json_object
*json_sub
= NULL
;
4156 json_sub
= json_object_new_object();
4158 /* Show neighbor ID. */
4159 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4160 vty_out(vty
, " Neighbor %s,", "-");
4162 vty_out(vty
, " Neighbor %s,",
4163 inet_ntoa(nbr
->router_id
));
4166 /* Show interface address. */
4168 json_object_string_add(json_sub
, "ifaceAddress",
4169 inet_ntoa(nbr
->address
.u
.prefix4
));
4171 vty_out(vty
, " interface address %s\n",
4172 inet_ntoa(nbr
->address
.u
.prefix4
));
4176 json_object_string_add(json_sub
, "areaId",
4177 ospf_area_desc_string(oi
->area
));
4178 json_object_string_add(json_sub
, "ifaceName", oi
->ifp
->name
);
4180 vty_out(vty
, " In the area %s via interface %s\n",
4181 ospf_area_desc_string(oi
->area
), oi
->ifp
->name
);
4183 /* Show neighbor priority and state. */
4185 json_object_int_add(json_sub
, "nbrPriority", nbr
->priority
);
4186 json_object_string_add(
4187 json_sub
, "nbrState",
4188 lookup_msg(ospf_nsm_state_msg
, nbr
->state
, NULL
));
4190 vty_out(vty
, " Neighbor priority is %d, State is %s,",
4192 lookup_msg(ospf_nsm_state_msg
, nbr
->state
, NULL
));
4194 /* Show state changes. */
4196 json_object_int_add(json_sub
, "stateChangeCounter",
4199 vty_out(vty
, " %d state changes\n", nbr
->state_change
);
4201 if (nbr
->ts_last_progress
.tv_sec
|| nbr
->ts_last_progress
.tv_usec
) {
4206 monotime_since(&nbr
->ts_last_progress
, &res
) / 1000LL;
4208 json_object_int_add(json_sub
, "lastPrgrsvChangeMsec",
4212 " Most recent state change statistics:\n");
4213 vty_out(vty
, " Progressive change %s ago\n",
4214 ospf_timeval_dump(&res
, timebuf
,
4219 if (nbr
->ts_last_regress
.tv_sec
|| nbr
->ts_last_regress
.tv_usec
) {
4224 monotime_since(&nbr
->ts_last_regress
, &res
) / 1000LL;
4226 json_object_int_add(json_sub
,
4227 "lastRegressiveChangeMsec",
4229 if (nbr
->last_regress_str
)
4230 json_object_string_add(
4231 json_sub
, "lastRegressiveChangeReason",
4232 nbr
->last_regress_str
);
4235 " Regressive change %s ago, due to %s\n",
4236 ospf_timeval_dump(&res
, timebuf
,
4238 (nbr
->last_regress_str
? nbr
->last_regress_str
4243 /* Show Designated Rotuer ID. */
4245 json_object_string_add(json_sub
, "routerDesignatedId",
4246 inet_ntoa(nbr
->d_router
));
4248 vty_out(vty
, " DR is %s,", inet_ntoa(nbr
->d_router
));
4250 /* Show Backup Designated Rotuer ID. */
4252 json_object_string_add(json_sub
, "routerDesignatedBackupId",
4253 inet_ntoa(nbr
->bd_router
));
4255 vty_out(vty
, " BDR is %s\n", inet_ntoa(nbr
->bd_router
));
4259 json_object_int_add(json_sub
, "optionsCounter", nbr
->options
);
4260 json_object_string_add(json_sub
, "optionsList",
4261 ospf_options_dump(nbr
->options
));
4263 vty_out(vty
, " Options %d %s\n", nbr
->options
,
4264 ospf_options_dump(nbr
->options
));
4266 /* Show Router Dead interval timer. */
4268 if (nbr
->t_inactivity
) {
4270 time_store
= monotime_until(&nbr
->t_inactivity
->u
.sands
,
4273 json_object_int_add(json_sub
,
4274 "routerDeadIntervalTimerDueMsec",
4277 json_object_int_add(
4278 json_sub
, "routerDeadIntervalTimerDueMsec", -1);
4280 vty_out(vty
, " Dead timer due in %s\n",
4281 ospf_timer_dump(nbr
->t_inactivity
, timebuf
,
4284 /* Show Database Summary list. */
4286 json_object_int_add(json_sub
, "databaseSummaryListCounter",
4287 ospf_db_summary_count(nbr
));
4289 vty_out(vty
, " Database Summary List %d\n",
4290 ospf_db_summary_count(nbr
));
4292 /* Show Link State Request list. */
4294 json_object_int_add(json_sub
, "linkStateRequestListCounter",
4295 ospf_ls_request_count(nbr
));
4297 vty_out(vty
, " Link State Request List %ld\n",
4298 ospf_ls_request_count(nbr
));
4300 /* Show Link State Retransmission list. */
4302 json_object_int_add(json_sub
,
4303 "linkStateRetransmissionListCounter",
4304 ospf_ls_retransmit_count(nbr
));
4306 vty_out(vty
, " Link State Retransmission List %ld\n",
4307 ospf_ls_retransmit_count(nbr
));
4309 /* Show inactivity timer thread. */
4311 if (nbr
->t_inactivity
!= NULL
)
4312 json_object_string_add(json_sub
,
4313 "threadInactivityTimer", "on");
4315 vty_out(vty
, " Thread Inactivity Timer %s\n",
4316 nbr
->t_inactivity
!= NULL
? "on" : "off");
4318 /* Show Database Description retransmission thread. */
4320 if (nbr
->t_db_desc
!= NULL
)
4321 json_object_string_add(
4323 "threadDatabaseDescriptionRetransmission",
4327 " Thread Database Description Retransmision %s\n",
4328 nbr
->t_db_desc
!= NULL
? "on" : "off");
4330 /* Show Link State Request Retransmission thread. */
4332 if (nbr
->t_ls_req
!= NULL
)
4333 json_object_string_add(
4335 "threadLinkStateRequestRetransmission", "on");
4338 " Thread Link State Request Retransmission %s\n",
4339 nbr
->t_ls_req
!= NULL
? "on" : "off");
4341 /* Show Link State Update Retransmission thread. */
4343 if (nbr
->t_ls_upd
!= NULL
)
4344 json_object_string_add(
4345 json_sub
, "threadLinkStateUpdateRetransmission",
4349 " Thread Link State Update Retransmission %s\n\n",
4350 nbr
->t_ls_upd
!= NULL
? "on" : "off");
4353 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4354 json_object_object_add(json
, "noNbrId", json_sub
);
4356 json_object_object_add(json
, inet_ntoa(nbr
->router_id
),
4360 ospf_bfd_show_info(vty
, nbr
->bfd_info
, json
, use_json
, 0);
4363 static int show_ip_ospf_neighbor_id_common(struct vty
*vty
, struct ospf
*ospf
,
4365 struct cmd_token
**argv
,
4368 struct listnode
*node
;
4369 struct ospf_neighbor
*nbr
;
4370 struct ospf_interface
*oi
;
4371 struct in_addr router_id
;
4373 json_object
*json
= NULL
;
4376 json
= json_object_new_object();
4378 if (ospf
->instance
) {
4380 json_object_int_add(json
, "ospfInstance",
4383 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
4386 ret
= inet_aton(argv
[arg_base
]->arg
, &router_id
);
4389 vty_out(vty
, "Please specify Neighbor ID by A.B.C.D\n");
4391 vty_out(vty
, "{}\n");
4392 json_object_free(json
);
4397 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
4398 if ((nbr
= ospf_nbr_lookup_by_routerid(oi
->nbrs
, &router_id
))) {
4399 show_ip_ospf_neighbor_detail_sub(vty
, oi
, nbr
, use_json
,
4405 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
4406 json
, JSON_C_TO_STRING_PRETTY
));
4407 json_object_free(json
);
4414 DEFUN (show_ip_ospf_neighbor_id
,
4415 show_ip_ospf_neighbor_id_cmd
,
4416 "show ip ospf neighbor A.B.C.D [json]",
4419 "OSPF information\n"
4425 u_char uj
= use_json(argc
, argv
);
4427 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4430 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 0, argv
, uj
);
4433 DEFUN (show_ip_ospf_instance_neighbor_id
,
4434 show_ip_ospf_instance_neighbor_id_cmd
,
4435 "show ip ospf (1-65535) neighbor A.B.C.D [json]",
4438 "OSPF information\n"
4446 u_short instance
= 0;
4447 u_char uj
= use_json(argc
, argv
);
4449 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4450 ospf
= ospf_lookup_instance(instance
);
4452 return CMD_NOT_MY_INSTANCE
;
4454 if (!ospf
->oi_running
)
4457 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 1, argv
, uj
);
4460 static int show_ip_ospf_neighbor_detail_common(struct vty
*vty
,
4464 struct ospf_interface
*oi
;
4465 struct listnode
*node
;
4466 json_object
*json
= NULL
;
4469 json
= json_object_new_object();
4471 if (ospf
->instance
) {
4473 json_object_int_add(json
, "ospfInstance",
4476 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
4479 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
4480 struct route_node
*rn
;
4481 struct ospf_neighbor
*nbr
;
4483 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
)) {
4484 if ((nbr
= rn
->info
)) {
4485 if (nbr
!= oi
->nbr_self
) {
4486 if (nbr
->state
!= NSM_Down
) {
4487 show_ip_ospf_neighbor_detail_sub(
4488 vty
, oi
, nbr
, use_json
,
4497 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
4498 json
, JSON_C_TO_STRING_PRETTY
));
4499 json_object_free(json
);
4506 DEFUN (show_ip_ospf_neighbor_detail
,
4507 show_ip_ospf_neighbor_detail_cmd
,
4508 "show ip ospf neighbor detail [json]",
4511 "OSPF information\n"
4513 "detail of all neighbors\n"
4517 u_char uj
= use_json(argc
, argv
);
4519 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4522 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4525 DEFUN (show_ip_ospf_instance_neighbor_detail
,
4526 show_ip_ospf_instance_neighbor_detail_cmd
,
4527 "show ip ospf (1-65535) neighbor detail [json]",
4530 "OSPF information\n"
4533 "detail of all neighbors\n"
4538 u_short instance
= 0;
4539 u_char uj
= use_json(argc
, argv
);
4541 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4542 ospf
= ospf_lookup_instance(instance
);
4544 return CMD_NOT_MY_INSTANCE
;
4546 if (!ospf
->oi_running
)
4549 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4552 static int show_ip_ospf_neighbor_detail_all_common(struct vty
*vty
,
4556 struct listnode
*node
;
4557 struct ospf_interface
*oi
;
4558 json_object
*json
= NULL
;
4561 json
= json_object_new_object();
4563 if (ospf
->instance
) {
4565 json_object_int_add(json
, "ospfInstance",
4568 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
4571 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
4572 struct route_node
*rn
;
4573 struct ospf_neighbor
*nbr
;
4574 struct ospf_nbr_nbma
*nbr_nbma
;
4576 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
))
4577 if ((nbr
= rn
->info
))
4578 if (nbr
!= oi
->nbr_self
)
4579 if (nbr
->state
!= NSM_Down
)
4580 show_ip_ospf_neighbor_detail_sub(
4584 if (oi
->type
== OSPF_IFTYPE_NBMA
) {
4585 struct listnode
*nd
;
4587 for (ALL_LIST_ELEMENTS_RO(oi
->nbr_nbma
, nd
, nbr_nbma
)) {
4588 if (nbr_nbma
->nbr
== NULL
4589 || nbr_nbma
->nbr
->state
== NSM_Down
)
4590 show_ip_ospf_nbr_nbma_detail_sub(
4591 vty
, oi
, nbr_nbma
, use_json
,
4598 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
4599 json
, JSON_C_TO_STRING_PRETTY
));
4600 json_object_free(json
);
4608 DEFUN (show_ip_ospf_neighbor_detail_all
,
4609 show_ip_ospf_neighbor_detail_all_cmd
,
4610 "show ip ospf neighbor detail all [json]",
4613 "OSPF information\n"
4615 "detail of all neighbors\n"
4616 "include down status neighbor\n"
4620 u_char uj
= use_json(argc
, argv
);
4622 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4625 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4628 DEFUN (show_ip_ospf_instance_neighbor_detail_all
,
4629 show_ip_ospf_instance_neighbor_detail_all_cmd
,
4630 "show ip ospf (1-65535) neighbor detail all [json]",
4633 "OSPF information\n"
4636 "detail of all neighbors\n"
4637 "include down status neighbor\n"
4642 u_short instance
= 0;
4643 u_char uj
= use_json(argc
, argv
);
4645 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4646 ospf
= ospf_lookup_instance(instance
);
4648 return CMD_NOT_MY_INSTANCE
;
4650 if (!ospf
->oi_running
)
4653 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4656 static int show_ip_ospf_neighbor_int_detail_common(struct vty
*vty
,
4659 struct cmd_token
**argv
,
4662 struct ospf_interface
*oi
;
4663 struct interface
*ifp
;
4664 struct route_node
*rn
, *nrn
;
4665 struct ospf_neighbor
*nbr
;
4666 json_object
*json
= NULL
;
4669 json
= json_object_new_object();
4671 if (ospf
->instance
) {
4673 json_object_int_add(json
, "ospfInstance",
4676 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
4679 ifp
= if_lookup_by_name(argv
[arg_base
]->arg
, VRF_DEFAULT
);
4682 vty_out(vty
, "No such interface.\n");
4684 vty_out(vty
, "{}\n");
4685 json_object_free(json
);
4690 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
4691 if ((oi
= rn
->info
)) {
4692 for (nrn
= route_top(oi
->nbrs
); nrn
;
4693 nrn
= route_next(nrn
)) {
4694 if ((nbr
= nrn
->info
)) {
4695 if (nbr
!= oi
->nbr_self
) {
4696 if (nbr
->state
!= NSM_Down
)
4697 show_ip_ospf_neighbor_detail_sub(
4707 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
4708 json
, JSON_C_TO_STRING_PRETTY
));
4709 json_object_free(json
);
4716 DEFUN (show_ip_ospf_neighbor_int_detail
,
4717 show_ip_ospf_neighbor_int_detail_cmd
,
4718 "show ip ospf neighbor IFNAME detail [json]",
4721 "OSPF information\n"
4724 "detail of all neighbors\n"
4728 u_char uj
= use_json(argc
, argv
);
4730 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4733 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 0, argv
, uj
);
4736 DEFUN (show_ip_ospf_instance_neighbor_int_detail
,
4737 show_ip_ospf_instance_neighbor_int_detail_cmd
,
4738 "show ip ospf (1-65535) neighbor IFNAME detail [json]",
4741 "OSPF information\n"
4745 "detail of all neighbors\n"
4750 u_short instance
= 0;
4751 u_char uj
= use_json(argc
, argv
);
4753 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4754 ospf
= ospf_lookup_instance(instance
);
4756 return CMD_NOT_MY_INSTANCE
;
4758 if (!ospf
->oi_running
)
4761 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 1, argv
, uj
);
4764 /* Show functions */
4765 static int show_lsa_summary(struct vty
*vty
, struct ospf_lsa
*lsa
, int self
)
4767 struct router_lsa
*rl
;
4768 struct summary_lsa
*sl
;
4769 struct as_external_lsa
*asel
;
4770 struct prefix_ipv4 p
;
4773 /* If self option is set, check LSA self flag. */
4774 if (self
== 0 || IS_LSA_SELF(lsa
)) {
4775 /* LSA common part show. */
4776 vty_out(vty
, "%-15s ", inet_ntoa(lsa
->data
->id
));
4777 vty_out(vty
, "%-15s %4d 0x%08lx 0x%04x",
4778 inet_ntoa(lsa
->data
->adv_router
), LS_AGE(lsa
),
4779 (u_long
)ntohl(lsa
->data
->ls_seqnum
),
4780 ntohs(lsa
->data
->checksum
));
4781 /* LSA specific part show. */
4782 switch (lsa
->data
->type
) {
4783 case OSPF_ROUTER_LSA
:
4784 rl
= (struct router_lsa
*)lsa
->data
;
4785 vty_out(vty
, " %-d", ntohs(rl
->links
));
4787 case OSPF_SUMMARY_LSA
:
4788 sl
= (struct summary_lsa
*)lsa
->data
;
4791 p
.prefix
= sl
->header
.id
;
4792 p
.prefixlen
= ip_masklen(sl
->mask
);
4793 apply_mask_ipv4(&p
);
4795 vty_out(vty
, " %s/%d", inet_ntoa(p
.prefix
),
4798 case OSPF_AS_EXTERNAL_LSA
:
4799 case OSPF_AS_NSSA_LSA
:
4800 asel
= (struct as_external_lsa
*)lsa
->data
;
4803 p
.prefix
= asel
->header
.id
;
4804 p
.prefixlen
= ip_masklen(asel
->mask
);
4805 apply_mask_ipv4(&p
);
4807 vty_out(vty
, " %s %s/%d [0x%lx]",
4808 IS_EXTERNAL_METRIC(asel
->e
[0].tos
)
4811 inet_ntoa(p
.prefix
), p
.prefixlen
,
4812 (u_long
)ntohl(asel
->e
[0].route_tag
));
4814 case OSPF_NETWORK_LSA
:
4815 case OSPF_ASBR_SUMMARY_LSA
:
4816 case OSPF_OPAQUE_LINK_LSA
:
4817 case OSPF_OPAQUE_AREA_LSA
:
4818 case OSPF_OPAQUE_AS_LSA
:
4828 static const char *show_database_desc
[] = {
4830 "Router Link States",
4832 "Summary Link States",
4833 "ASBR-Summary Link States",
4834 "AS External Link States",
4835 "Group Membership LSA",
4836 "NSSA-external Link States",
4838 "Link-Local Opaque-LSA",
4839 "Area-Local Opaque-LSA",
4840 "AS-external Opaque-LSA",
4843 static const char *show_database_header
[] = {
4845 "Link ID ADV Router Age Seq# CkSum Link count",
4846 "Link ID ADV Router Age Seq# CkSum",
4847 "Link ID ADV Router Age Seq# CkSum Route",
4848 "Link ID ADV Router Age Seq# CkSum",
4849 "Link ID ADV Router Age Seq# CkSum Route",
4850 " --- header for Group Member ----",
4851 "Link ID ADV Router Age Seq# CkSum Route",
4853 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4854 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4855 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4858 static void show_ip_ospf_database_header(struct vty
*vty
, struct ospf_lsa
*lsa
)
4860 struct router_lsa
*rlsa
= (struct router_lsa
*)lsa
->data
;
4862 vty_out(vty
, " LS age: %d\n", LS_AGE(lsa
));
4863 vty_out(vty
, " Options: 0x%-2x : %s\n", lsa
->data
->options
,
4864 ospf_options_dump(lsa
->data
->options
));
4865 vty_out(vty
, " LS Flags: 0x%-2x %s\n", lsa
->flags
,
4866 ((lsa
->flags
& OSPF_LSA_LOCAL_XLT
) ? "(Translated from Type-7)"
4869 if (lsa
->data
->type
== OSPF_ROUTER_LSA
) {
4870 vty_out(vty
, " Flags: 0x%x", rlsa
->flags
);
4873 vty_out(vty
, " :%s%s%s%s",
4874 IS_ROUTER_LSA_BORDER(rlsa
) ? " ABR" : "",
4875 IS_ROUTER_LSA_EXTERNAL(rlsa
) ? " ASBR" : "",
4876 IS_ROUTER_LSA_VIRTUAL(rlsa
) ? " VL-endpoint"
4878 IS_ROUTER_LSA_SHORTCUT(rlsa
) ? " Shortcut"
4883 vty_out(vty
, " LS Type: %s\n",
4884 lookup_msg(ospf_lsa_type_msg
, lsa
->data
->type
, NULL
));
4885 vty_out(vty
, " Link State ID: %s %s\n", inet_ntoa(lsa
->data
->id
),
4886 lookup_msg(ospf_link_state_id_type_msg
, lsa
->data
->type
, NULL
));
4887 vty_out(vty
, " Advertising Router: %s\n",
4888 inet_ntoa(lsa
->data
->adv_router
));
4889 vty_out(vty
, " LS Seq Number: %08lx\n",
4890 (u_long
)ntohl(lsa
->data
->ls_seqnum
));
4891 vty_out(vty
, " Checksum: 0x%04x\n", ntohs(lsa
->data
->checksum
));
4892 vty_out(vty
, " Length: %d\n\n", ntohs(lsa
->data
->length
));
4895 const char *link_type_desc
[] = {
4897 "another Router (point-to-point)",
4898 "a Transit Network",
4903 const char *link_id_desc
[] = {
4904 "(null)", "Neighboring Router ID", "Designated Router address",
4905 "Net", "Neighboring Router ID",
4908 const char *link_data_desc
[] = {
4909 "(null)", "Router Interface address", "Router Interface address",
4910 "Network Mask", "Router Interface address",
4913 /* Show router-LSA each Link information. */
4914 static void show_ip_ospf_database_router_links(struct vty
*vty
,
4915 struct router_lsa
*rl
)
4920 len
= ntohs(rl
->header
.length
) - 4;
4921 for (i
= 0; i
< ntohs(rl
->links
) && len
> 0; len
-= 12, i
++) {
4922 type
= rl
->link
[i
].type
;
4924 vty_out(vty
, " Link connected to: %s\n",
4925 link_type_desc
[type
]);
4926 vty_out(vty
, " (Link ID) %s: %s\n", link_id_desc
[type
],
4927 inet_ntoa(rl
->link
[i
].link_id
));
4928 vty_out(vty
, " (Link Data) %s: %s\n", link_data_desc
[type
],
4929 inet_ntoa(rl
->link
[i
].link_data
));
4930 vty_out(vty
, " Number of TOS metrics: 0\n");
4931 vty_out(vty
, " TOS 0 Metric: %d\n",
4932 ntohs(rl
->link
[i
].metric
));
4937 /* Show router-LSA detail information. */
4938 static int show_router_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
4941 struct router_lsa
*rl
= (struct router_lsa
*)lsa
->data
;
4943 show_ip_ospf_database_header(vty
, lsa
);
4945 vty_out(vty
, " Number of Links: %d\n\n", ntohs(rl
->links
));
4947 show_ip_ospf_database_router_links(vty
, rl
);
4954 /* Show network-LSA detail information. */
4955 static int show_network_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
4960 struct network_lsa
*nl
= (struct network_lsa
*)lsa
->data
;
4962 show_ip_ospf_database_header(vty
, lsa
);
4964 vty_out(vty
, " Network Mask: /%d\n", ip_masklen(nl
->mask
));
4966 length
= ntohs(lsa
->data
->length
) - OSPF_LSA_HEADER_SIZE
- 4;
4968 for (i
= 0; length
> 0; i
++, length
-= 4)
4969 vty_out(vty
, " Attached Router: %s\n",
4970 inet_ntoa(nl
->routers
[i
]));
4978 /* Show summary-LSA detail information. */
4979 static int show_summary_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
4982 struct summary_lsa
*sl
= (struct summary_lsa
*)lsa
->data
;
4984 show_ip_ospf_database_header(vty
, lsa
);
4986 vty_out(vty
, " Network Mask: /%d\n", ip_masklen(sl
->mask
));
4987 vty_out(vty
, " TOS: 0 Metric: %d\n",
4988 GET_METRIC(sl
->metric
));
4995 /* Show summary-ASBR-LSA detail information. */
4996 static int show_summary_asbr_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
4999 struct summary_lsa
*sl
= (struct summary_lsa
*)lsa
->data
;
5001 show_ip_ospf_database_header(vty
, lsa
);
5003 vty_out(vty
, " Network Mask: /%d\n", ip_masklen(sl
->mask
));
5004 vty_out(vty
, " TOS: 0 Metric: %d\n",
5005 GET_METRIC(sl
->metric
));
5012 /* Show AS-external-LSA detail information. */
5013 static int show_as_external_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5016 struct as_external_lsa
*al
=
5017 (struct as_external_lsa
*)lsa
->data
;
5019 show_ip_ospf_database_header(vty
, lsa
);
5021 vty_out(vty
, " Network Mask: /%d\n", ip_masklen(al
->mask
));
5022 vty_out(vty
, " Metric Type: %s\n",
5023 IS_EXTERNAL_METRIC(al
->e
[0].tos
)
5024 ? "2 (Larger than any link state path)"
5026 vty_out(vty
, " TOS: 0\n");
5027 vty_out(vty
, " Metric: %d\n",
5028 GET_METRIC(al
->e
[0].metric
));
5029 vty_out(vty
, " Forward Address: %s\n",
5030 inet_ntoa(al
->e
[0].fwd_addr
));
5033 " External Route Tag: %" ROUTE_TAG_PRI
"\n\n",
5034 (route_tag_t
)ntohl(al
->e
[0].route_tag
));
5041 show_as_external_lsa_stdvty (struct ospf_lsa
*lsa
)
5043 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5045 /* show_ip_ospf_database_header (vty, lsa); */
5047 zlog_debug( " Network Mask: /%d%s",
5048 ip_masklen (al
->mask
), "\n");
5049 zlog_debug( " Metric Type: %s%s",
5050 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5051 "2 (Larger than any link state path)" : "1", "\n");
5052 zlog_debug( " TOS: 0%s", "\n");
5053 zlog_debug( " Metric: %d%s",
5054 GET_METRIC (al
->e
[0].metric
), "\n");
5055 zlog_debug( " Forward Address: %s%s",
5056 inet_ntoa (al
->e
[0].fwd_addr
), "\n");
5058 zlog_debug( " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5059 (route_tag_t
)ntohl (al
->e
[0].route_tag
), "\n", "\n");
5064 /* Show AS-NSSA-LSA detail information. */
5065 static int show_as_nssa_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5068 struct as_external_lsa
*al
=
5069 (struct as_external_lsa
*)lsa
->data
;
5071 show_ip_ospf_database_header(vty
, lsa
);
5073 vty_out(vty
, " Network Mask: /%d\n", ip_masklen(al
->mask
));
5074 vty_out(vty
, " Metric Type: %s\n",
5075 IS_EXTERNAL_METRIC(al
->e
[0].tos
)
5076 ? "2 (Larger than any link state path)"
5078 vty_out(vty
, " TOS: 0\n");
5079 vty_out(vty
, " Metric: %d\n",
5080 GET_METRIC(al
->e
[0].metric
));
5081 vty_out(vty
, " NSSA: Forward Address: %s\n",
5082 inet_ntoa(al
->e
[0].fwd_addr
));
5085 " External Route Tag: %" ROUTE_TAG_PRI
"\n\n",
5086 (route_tag_t
)ntohl(al
->e
[0].route_tag
));
5092 static int show_func_dummy(struct vty
*vty
, struct ospf_lsa
*lsa
)
5097 static int show_opaque_lsa_detail(struct vty
*vty
, struct ospf_lsa
*lsa
)
5100 show_ip_ospf_database_header(vty
, lsa
);
5101 show_opaque_info_detail(vty
, lsa
);
5108 int (*show_function
[])(struct vty
*, struct ospf_lsa
*) = {
5110 show_router_lsa_detail
,
5111 show_network_lsa_detail
,
5112 show_summary_lsa_detail
,
5113 show_summary_asbr_lsa_detail
,
5114 show_as_external_lsa_detail
,
5116 show_as_nssa_lsa_detail
, /* almost same as external */
5118 show_opaque_lsa_detail
,
5119 show_opaque_lsa_detail
,
5120 show_opaque_lsa_detail
,
5123 static void show_lsa_prefix_set(struct vty
*vty
, struct prefix_ls
*lp
,
5124 struct in_addr
*id
, struct in_addr
*adv_router
)
5126 memset(lp
, 0, sizeof(struct prefix_ls
));
5130 else if (adv_router
== NULL
) {
5136 lp
->adv_router
= *adv_router
;
5140 static void show_lsa_detail_proc(struct vty
*vty
, struct route_table
*rt
,
5141 struct in_addr
*id
, struct in_addr
*adv_router
)
5143 struct prefix_ls lp
;
5144 struct route_node
*rn
, *start
;
5145 struct ospf_lsa
*lsa
;
5147 show_lsa_prefix_set(vty
, &lp
, id
, adv_router
);
5148 start
= route_node_get(rt
, (struct prefix
*)&lp
);
5150 route_lock_node(start
);
5151 for (rn
= start
; rn
; rn
= route_next_until(rn
, start
))
5152 if ((lsa
= rn
->info
)) {
5153 if (show_function
[lsa
->data
->type
] != NULL
)
5154 show_function
[lsa
->data
->type
](vty
,
5157 route_unlock_node(start
);
5161 /* Show detail LSA information
5162 -- if id is NULL then show all LSAs. */
5163 static void show_lsa_detail(struct vty
*vty
, struct ospf
*ospf
, int type
,
5164 struct in_addr
*id
, struct in_addr
*adv_router
)
5166 struct listnode
*node
;
5167 struct ospf_area
*area
;
5170 case OSPF_AS_EXTERNAL_LSA
:
5171 case OSPF_OPAQUE_AS_LSA
:
5172 vty_out(vty
, " %s \n\n",
5173 show_database_desc
[type
]);
5174 show_lsa_detail_proc(vty
, AS_LSDB(ospf
, type
), id
, adv_router
);
5177 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
5178 vty_out(vty
, "\n %s (Area %s)\n\n",
5179 show_database_desc
[type
],
5180 ospf_area_desc_string(area
));
5181 show_lsa_detail_proc(vty
, AREA_LSDB(area
, type
), id
,
5188 static void show_lsa_detail_adv_router_proc(struct vty
*vty
,
5189 struct route_table
*rt
,
5190 struct in_addr
*adv_router
)
5192 struct route_node
*rn
;
5193 struct ospf_lsa
*lsa
;
5195 for (rn
= route_top(rt
); rn
; rn
= route_next(rn
))
5196 if ((lsa
= rn
->info
))
5197 if (IPV4_ADDR_SAME(adv_router
,
5198 &lsa
->data
->adv_router
)) {
5199 if (CHECK_FLAG(lsa
->flags
, OSPF_LSA_LOCAL_XLT
))
5201 if (show_function
[lsa
->data
->type
] != NULL
)
5202 show_function
[lsa
->data
->type
](vty
,
5207 /* Show detail LSA information. */
5208 static void show_lsa_detail_adv_router(struct vty
*vty
, struct ospf
*ospf
,
5209 int type
, struct in_addr
*adv_router
)
5211 struct listnode
*node
;
5212 struct ospf_area
*area
;
5215 case OSPF_AS_EXTERNAL_LSA
:
5216 case OSPF_OPAQUE_AS_LSA
:
5217 vty_out(vty
, " %s \n\n",
5218 show_database_desc
[type
]);
5219 show_lsa_detail_adv_router_proc(vty
, AS_LSDB(ospf
, type
),
5223 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
5224 vty_out(vty
, "\n %s (Area %s)\n\n",
5225 show_database_desc
[type
],
5226 ospf_area_desc_string(area
));
5227 show_lsa_detail_adv_router_proc(
5228 vty
, AREA_LSDB(area
, type
), adv_router
);
5234 static void show_ip_ospf_database_summary(struct vty
*vty
, struct ospf
*ospf
,
5237 struct ospf_lsa
*lsa
;
5238 struct route_node
*rn
;
5239 struct ospf_area
*area
;
5240 struct listnode
*node
;
5243 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
5244 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++) {
5246 case OSPF_AS_EXTERNAL_LSA
:
5247 case OSPF_OPAQUE_AS_LSA
:
5252 if (ospf_lsdb_count_self(area
->lsdb
, type
) > 0
5254 && ospf_lsdb_count(area
->lsdb
, type
) > 0)) {
5255 vty_out(vty
, " %s (Area %s)\n\n",
5256 show_database_desc
[type
],
5257 ospf_area_desc_string(area
));
5258 vty_out(vty
, "%s\n",
5259 show_database_header
[type
]);
5261 LSDB_LOOP(AREA_LSDB(area
, type
), rn
, lsa
)
5262 show_lsa_summary(vty
, lsa
, self
);
5269 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++) {
5271 case OSPF_AS_EXTERNAL_LSA
:
5272 case OSPF_OPAQUE_AS_LSA
:
5277 if (ospf_lsdb_count_self(ospf
->lsdb
, type
)
5278 || (!self
&& ospf_lsdb_count(ospf
->lsdb
, type
))) {
5279 vty_out(vty
, " %s\n\n",
5280 show_database_desc
[type
]);
5281 vty_out(vty
, "%s\n", show_database_header
[type
]);
5283 LSDB_LOOP(AS_LSDB(ospf
, type
), rn
, lsa
)
5284 show_lsa_summary(vty
, lsa
, self
);
5293 static void show_ip_ospf_database_maxage(struct vty
*vty
, struct ospf
*ospf
)
5295 struct route_node
*rn
;
5297 vty_out(vty
, "\n MaxAge Link States:\n\n");
5299 for (rn
= route_top(ospf
->maxage_lsa
); rn
; rn
= route_next(rn
)) {
5300 struct ospf_lsa
*lsa
;
5302 if ((lsa
= rn
->info
) != NULL
) {
5303 vty_out(vty
, "Link type: %d\n", lsa
->data
->type
);
5304 vty_out(vty
, "Link State ID: %s\n",
5305 inet_ntoa(lsa
->data
->id
));
5306 vty_out(vty
, "Advertising Router: %s\n",
5307 inet_ntoa(lsa
->data
->adv_router
));
5308 vty_out(vty
, "LSA lock count: %d\n", lsa
->lock
);
5314 #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
5315 #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
5317 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
5318 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
5319 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
5320 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
5322 #define OSPF_LSA_TYPES_DESC \
5323 "ASBR summary link states\n" \
5324 "External link states\n" \
5325 "Network link states\n" \
5326 "Router link states\n" \
5327 "Network summary link states\n" OSPF_LSA_TYPE_NSSA_DESC \
5328 OSPF_LSA_TYPE_OPAQUE_LINK_DESC OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
5329 OSPF_LSA_TYPE_OPAQUE_AS_DESC
5331 static int show_ip_ospf_database_common(struct vty
*vty
, struct ospf
*ospf
,
5332 int arg_base
, int argc
,
5333 struct cmd_token
**argv
)
5337 struct in_addr id
, adv_router
;
5340 vty_out(vty
, "\nOSPF Instance: %d\n", ospf
->instance
);
5342 vty_out(vty
, "\n OSPF Router with ID (%s)\n\n",
5343 inet_ntoa(ospf
->router_id
));
5346 if (argc
== arg_base
+ 4) {
5347 show_ip_ospf_database_summary(vty
, ospf
, 0);
5351 /* Set database type to show. */
5352 if (strncmp(argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5353 type
= OSPF_ROUTER_LSA
;
5354 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5355 type
= OSPF_NETWORK_LSA
;
5356 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5357 type
= OSPF_AS_NSSA_LSA
;
5358 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "su", 2) == 0)
5359 type
= OSPF_SUMMARY_LSA
;
5360 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5361 type
= OSPF_ASBR_SUMMARY_LSA
;
5362 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5363 type
= OSPF_AS_EXTERNAL_LSA
;
5364 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "se", 2) == 0) {
5365 show_ip_ospf_database_summary(vty
, ospf
, 1);
5367 } else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "m", 1) == 0) {
5368 show_ip_ospf_database_maxage(vty
, ospf
);
5370 } else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5371 type
= OSPF_OPAQUE_LINK_LSA
;
5372 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5373 type
= OSPF_OPAQUE_AREA_LSA
;
5374 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5375 type
= OSPF_OPAQUE_AS_LSA
;
5379 /* `show ip ospf database LSA'. */
5380 if (argc
== arg_base
+ 5)
5381 show_lsa_detail(vty
, ospf
, type
, NULL
, NULL
);
5382 else if (argc
>= arg_base
+ 6) {
5383 ret
= inet_aton(argv
[arg_base
+ 5]->arg
, &id
);
5387 /* `show ip ospf database LSA ID'. */
5388 if (argc
== arg_base
+ 6)
5389 show_lsa_detail(vty
, ospf
, type
, &id
, NULL
);
5390 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
5391 else if (argc
== arg_base
+ 7) {
5392 if (strncmp(argv
[arg_base
+ 6]->text
, "s", 1) == 0)
5393 adv_router
= ospf
->router_id
;
5395 ret
= inet_aton(argv
[arg_base
+ 7]->arg
,
5400 show_lsa_detail(vty
, ospf
, type
, &id
, &adv_router
);
5407 DEFUN (show_ip_ospf_database_max
,
5408 show_ip_ospf_database_max_cmd
,
5409 "show ip ospf database <max-age|self-originate>",
5412 "OSPF information\n"
5413 "Database summary\n"
5414 "LSAs in MaxAge list\n"
5415 "Self-originated link states\n")
5419 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5422 return (show_ip_ospf_database_common(vty
, ospf
, 0, argc
, argv
));
5425 DEFUN (show_ip_ospf_instance_database
,
5426 show_ip_ospf_instance_database_cmd
,
5427 "show ip ospf [(1-65535)] database [<asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as> [A.B.C.D [<self-originate|adv-router A.B.C.D>]]]",
5430 "OSPF information\n"
5432 "Database summary\n"
5434 "Link State ID (as an IP address)\n"
5435 "Self-originated link states\n"
5436 "Advertising Router link states\n"
5437 "Advertising Router (as an IP address)\n")
5440 u_short instance
= 0;
5443 if (argv_find(argv
, argc
, "(1-65535)", &idx
)) {
5444 instance
= strtoul(argv
[idx
]->arg
, NULL
, 10);
5445 ospf
= ospf_lookup_instance(instance
);
5447 return CMD_NOT_MY_INSTANCE
;
5449 ospf
= ospf_lookup();
5452 if (!ospf
|| !ospf
->oi_running
)
5455 return (show_ip_ospf_database_common(vty
, ospf
, idx
? 1 : 0, argc
,
5459 DEFUN (show_ip_ospf_instance_database_max
,
5460 show_ip_ospf_instance_database_max_cmd
,
5461 "show ip ospf (1-65535) database <max-age|self-originate>",
5464 "OSPF information\n"
5466 "Database summary\n"
5467 "LSAs in MaxAge list\n"
5468 "Self-originated link states\n")
5472 u_short instance
= 0;
5474 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5476 ospf
= ospf_lookup_instance(instance
);
5478 return CMD_NOT_MY_INSTANCE
;
5480 if (!ospf
->oi_running
)
5483 return (show_ip_ospf_database_common(vty
, ospf
, 1, argc
, argv
));
5487 static int show_ip_ospf_database_type_adv_router_common(struct vty
*vty
,
5489 int arg_base
, int argc
,
5490 struct cmd_token
**argv
)
5494 struct in_addr adv_router
;
5497 vty_out(vty
, "\nOSPF Instance: %d\n", ospf
->instance
);
5499 vty_out(vty
, "\n OSPF Router with ID (%s)\n\n",
5500 inet_ntoa(ospf
->router_id
));
5502 /* Set database type to show. */
5503 if (strncmp(argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5504 type
= OSPF_ROUTER_LSA
;
5505 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5506 type
= OSPF_NETWORK_LSA
;
5507 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5508 type
= OSPF_AS_NSSA_LSA
;
5509 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "s", 1) == 0)
5510 type
= OSPF_SUMMARY_LSA
;
5511 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5512 type
= OSPF_ASBR_SUMMARY_LSA
;
5513 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5514 type
= OSPF_AS_EXTERNAL_LSA
;
5515 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5516 type
= OSPF_OPAQUE_LINK_LSA
;
5517 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5518 type
= OSPF_OPAQUE_AREA_LSA
;
5519 else if (strncmp(argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5520 type
= OSPF_OPAQUE_AS_LSA
;
5524 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
5525 if (strncmp(argv
[arg_base
+ 5]->text
, "s", 1) == 0)
5526 adv_router
= ospf
->router_id
;
5528 ret
= inet_aton(argv
[arg_base
+ 6]->arg
, &adv_router
);
5533 show_lsa_detail_adv_router(vty
, ospf
, type
, &adv_router
);
5538 DEFUN (show_ip_ospf_instance_database_type_adv_router
,
5539 show_ip_ospf_instance_database_type_adv_router_cmd
,
5540 "show ip ospf [(1-65535)] database <asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as> <adv-router A.B.C.D|self-originate>",
5543 "OSPF information\n"
5545 "Database summary\n"
5547 "Advertising Router link states\n"
5548 "Advertising Router (as an IP address)\n"
5549 "Self-originated link states\n")
5552 u_short instance
= 0;
5555 if (argv_find(argv
, argc
, "(1-65535)", &idx
)) {
5556 instance
= strtoul(argv
[idx
]->arg
, NULL
, 10);
5557 ospf
= ospf_lookup_instance(instance
);
5559 return CMD_NOT_MY_INSTANCE
;
5561 ospf
= ospf_lookup();
5563 if (!ospf
|| !ospf
->oi_running
)
5566 return (show_ip_ospf_database_type_adv_router_common(
5567 vty
, ospf
, idx
? 1 : 0, argc
, argv
));
5570 DEFUN (ip_ospf_authentication_args
,
5571 ip_ospf_authentication_args_addr_cmd
,
5572 "ip ospf authentication <null|message-digest> [A.B.C.D]",
5574 "OSPF interface commands\n"
5575 "Enable authentication on this interface\n"
5576 "Use null authentication\n"
5577 "Use message-digest authentication\n"
5578 "Address of interface\n")
5580 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5581 int idx_encryption
= 3;
5583 struct in_addr addr
;
5585 struct ospf_if_params
*params
;
5587 params
= IF_DEF_PARAMS(ifp
);
5590 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5593 "Please specify interface address by A.B.C.D\n");
5594 return CMD_WARNING_CONFIG_FAILED
;
5597 params
= ospf_get_if_params(ifp
, addr
);
5598 ospf_if_update_params(ifp
, addr
);
5601 /* Handle null authentication */
5602 if (argv
[idx_encryption
]->arg
[0] == 'n') {
5603 SET_IF_PARAM(params
, auth_type
);
5604 params
->auth_type
= OSPF_AUTH_NULL
;
5608 /* Handle message-digest authentication */
5609 if (argv
[idx_encryption
]->arg
[0] == 'm') {
5610 SET_IF_PARAM(params
, auth_type
);
5611 params
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5615 vty_out(vty
, "You shouldn't get here!\n");
5616 return CMD_WARNING_CONFIG_FAILED
;
5619 DEFUN (ip_ospf_authentication
,
5620 ip_ospf_authentication_addr_cmd
,
5621 "ip ospf authentication [A.B.C.D]",
5623 "OSPF interface commands\n"
5624 "Enable authentication on this interface\n"
5625 "Address of interface")
5627 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5629 struct in_addr addr
;
5631 struct ospf_if_params
*params
;
5633 params
= IF_DEF_PARAMS(ifp
);
5636 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5639 "Please specify interface address by A.B.C.D\n");
5640 return CMD_WARNING_CONFIG_FAILED
;
5643 params
= ospf_get_if_params(ifp
, addr
);
5644 ospf_if_update_params(ifp
, addr
);
5647 SET_IF_PARAM(params
, auth_type
);
5648 params
->auth_type
= OSPF_AUTH_SIMPLE
;
5653 DEFUN (no_ip_ospf_authentication_args
,
5654 no_ip_ospf_authentication_args_addr_cmd
,
5655 "no ip ospf authentication <null|message-digest> [A.B.C.D]",
5658 "OSPF interface commands\n"
5659 "Enable authentication on this interface\n"
5660 "Use null authentication\n"
5661 "Use message-digest authentication\n"
5662 "Address of interface")
5664 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5665 int idx_encryption
= 4;
5667 struct in_addr addr
;
5669 struct ospf_if_params
*params
;
5670 struct route_node
*rn
;
5673 params
= IF_DEF_PARAMS(ifp
);
5676 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5679 "Please specify interface address by A.B.C.D\n");
5680 return CMD_WARNING_CONFIG_FAILED
;
5683 params
= ospf_lookup_if_params(ifp
, addr
);
5684 if (params
== NULL
) {
5685 vty_out(vty
, "Ip Address specified is unknown\n");
5686 return CMD_WARNING_CONFIG_FAILED
;
5688 params
->auth_type
= OSPF_AUTH_NOTSET
;
5689 UNSET_IF_PARAM(params
, auth_type
);
5690 if (params
!= IF_DEF_PARAMS(ifp
)) {
5691 ospf_free_if_params(ifp
, addr
);
5692 ospf_if_update_params(ifp
, addr
);
5695 if (argv
[idx_encryption
]->arg
[0] == 'n') {
5696 auth_type
= OSPF_AUTH_NULL
;
5697 } else if (argv
[idx_encryption
]->arg
[0] == 'm') {
5698 auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5700 vty_out(vty
, "Unexpected input encountered\n");
5701 return CMD_WARNING_CONFIG_FAILED
;
5704 * Here we have a case where the user has entered
5705 * 'no ip ospf authentication (null | message_digest )'
5706 * we need to find if we have any ip addresses underneath it
5708 * correspond to the associated type.
5710 if (params
->auth_type
== auth_type
) {
5711 params
->auth_type
= OSPF_AUTH_NOTSET
;
5712 UNSET_IF_PARAM(params
, auth_type
);
5715 for (rn
= route_top(IF_OIFS_PARAMS(ifp
)); rn
;
5716 rn
= route_next(rn
)) {
5717 if ((params
= rn
->info
)) {
5718 if (params
->auth_type
== auth_type
) {
5719 params
->auth_type
= OSPF_AUTH_NOTSET
;
5720 UNSET_IF_PARAM(params
, auth_type
);
5721 if (params
!= IF_DEF_PARAMS(ifp
)) {
5722 ospf_free_if_params(
5723 ifp
, rn
->p
.u
.prefix4
);
5724 ospf_if_update_params(
5725 ifp
, rn
->p
.u
.prefix4
);
5735 DEFUN (no_ip_ospf_authentication
,
5736 no_ip_ospf_authentication_addr_cmd
,
5737 "no ip ospf authentication [A.B.C.D]",
5740 "OSPF interface commands\n"
5741 "Enable authentication on this interface\n"
5742 "Address of interface")
5744 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5746 struct in_addr addr
;
5748 struct ospf_if_params
*params
;
5749 struct route_node
*rn
;
5751 params
= IF_DEF_PARAMS(ifp
);
5754 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5757 "Please specify interface address by A.B.C.D\n");
5758 return CMD_WARNING_CONFIG_FAILED
;
5761 params
= ospf_lookup_if_params(ifp
, addr
);
5762 if (params
== NULL
) {
5763 vty_out(vty
, "Ip Address specified is unknown\n");
5764 return CMD_WARNING_CONFIG_FAILED
;
5767 params
->auth_type
= OSPF_AUTH_NOTSET
;
5768 UNSET_IF_PARAM(params
, auth_type
);
5769 if (params
!= IF_DEF_PARAMS(ifp
)) {
5770 ospf_free_if_params(ifp
, addr
);
5771 ospf_if_update_params(ifp
, addr
);
5775 * When a user enters 'no ip ospf authentication'
5776 * We should remove all authentication types from
5779 if ((params
->auth_type
== OSPF_AUTH_NULL
)
5780 || (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
5781 || (params
->auth_type
== OSPF_AUTH_SIMPLE
)) {
5782 params
->auth_type
= OSPF_AUTH_NOTSET
;
5783 UNSET_IF_PARAM(params
, auth_type
);
5786 for (rn
= route_top(IF_OIFS_PARAMS(ifp
)); rn
;
5787 rn
= route_next(rn
)) {
5788 if ((params
= rn
->info
)) {
5790 if ((params
->auth_type
== OSPF_AUTH_NULL
)
5791 || (params
->auth_type
5792 == OSPF_AUTH_CRYPTOGRAPHIC
)
5793 || (params
->auth_type
5794 == OSPF_AUTH_SIMPLE
)) {
5795 params
->auth_type
= OSPF_AUTH_NOTSET
;
5796 UNSET_IF_PARAM(params
, auth_type
);
5797 if (params
!= IF_DEF_PARAMS(ifp
)) {
5798 ospf_free_if_params(
5799 ifp
, rn
->p
.u
.prefix4
);
5800 ospf_if_update_params(
5801 ifp
, rn
->p
.u
.prefix4
);
5812 DEFUN (ip_ospf_authentication_key
,
5813 ip_ospf_authentication_key_addr_cmd
,
5814 "ip ospf authentication-key AUTH_KEY [A.B.C.D]",
5816 "OSPF interface commands\n"
5817 "Authentication password (key)\n"
5818 "The OSPF password (key)\n"
5819 "Address of interface")
5821 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5823 struct in_addr addr
;
5824 struct ospf_if_params
*params
;
5826 params
= IF_DEF_PARAMS(ifp
);
5828 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
5829 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
5831 "Please specify interface address by A.B.C.D\n");
5832 return CMD_WARNING_CONFIG_FAILED
;
5835 params
= ospf_get_if_params(ifp
, addr
);
5836 ospf_if_update_params(ifp
, addr
);
5839 memset(params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
5840 strncpy((char *)params
->auth_simple
, argv
[3]->arg
,
5841 OSPF_AUTH_SIMPLE_SIZE
);
5842 SET_IF_PARAM(params
, auth_simple
);
5847 DEFUN_HIDDEN (ospf_authentication_key
,
5848 ospf_authentication_key_cmd
,
5849 "ospf authentication-key AUTH_KEY [A.B.C.D]",
5850 "OSPF interface commands\n"
5851 "Authentication password (key)\n"
5852 "The OSPF password (key)\n"
5853 "Address of interface\n")
5855 return ip_ospf_authentication_key(self
, vty
, argc
, argv
);
5858 DEFUN (no_ip_ospf_authentication_key
,
5859 no_ip_ospf_authentication_key_authkey_addr_cmd
,
5860 "no ip ospf authentication-key [AUTH_KEY [A.B.C.D]]",
5863 "OSPF interface commands\n"
5864 "Authentication password (key)\n"
5865 "The OSPF password (key)")
5867 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5869 struct in_addr addr
;
5870 struct ospf_if_params
*params
;
5871 params
= IF_DEF_PARAMS(ifp
);
5873 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
5874 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
5876 "Please specify interface address by A.B.C.D\n");
5877 return CMD_WARNING_CONFIG_FAILED
;
5880 params
= ospf_lookup_if_params(ifp
, addr
);
5885 memset(params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
);
5886 UNSET_IF_PARAM(params
, auth_simple
);
5888 if (params
!= IF_DEF_PARAMS(ifp
)) {
5889 ospf_free_if_params(ifp
, addr
);
5890 ospf_if_update_params(ifp
, addr
);
5896 DEFUN_HIDDEN (no_ospf_authentication_key
,
5897 no_ospf_authentication_key_authkey_addr_cmd
,
5898 "no ospf authentication-key [AUTH_KEY [A.B.C.D]]",
5900 "OSPF interface commands\n"
5901 "Authentication password (key)\n"
5902 "The OSPF password (key)")
5904 return no_ip_ospf_authentication_key(self
, vty
, argc
, argv
);
5907 DEFUN (ip_ospf_message_digest_key
,
5908 ip_ospf_message_digest_key_cmd
,
5909 "ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
5911 "OSPF interface commands\n"
5912 "Message digest authentication password (key)\n"
5914 "Use MD5 algorithm\n"
5915 "The OSPF password (key)\n"
5916 "Address of interface\n")
5918 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5919 struct crypt_key
*ck
;
5921 struct in_addr addr
;
5922 struct ospf_if_params
*params
;
5924 params
= IF_DEF_PARAMS(ifp
);
5927 argv_find(argv
, argc
, "(1-255)", &idx
);
5928 char *keyid
= argv
[idx
]->arg
;
5929 argv_find(argv
, argc
, "KEY", &idx
);
5930 char *cryptkey
= argv
[idx
]->arg
;
5932 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
5933 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
5935 "Please specify interface address by A.B.C.D\n");
5936 return CMD_WARNING_CONFIG_FAILED
;
5939 params
= ospf_get_if_params(ifp
, addr
);
5940 ospf_if_update_params(ifp
, addr
);
5943 key_id
= strtol(keyid
, NULL
, 10);
5944 if (ospf_crypt_key_lookup(params
->auth_crypt
, key_id
) != NULL
) {
5945 vty_out(vty
, "OSPF: Key %d already exists\n", key_id
);
5946 return CMD_WARNING_CONFIG_FAILED
;
5949 ck
= ospf_crypt_key_new();
5950 ck
->key_id
= (u_char
)key_id
;
5951 memset(ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+ 1);
5952 strncpy((char *)ck
->auth_key
, cryptkey
, OSPF_AUTH_MD5_SIZE
);
5954 ospf_crypt_key_add(params
->auth_crypt
, ck
);
5955 SET_IF_PARAM(params
, auth_crypt
);
5960 DEFUN_HIDDEN (ospf_message_digest_key
,
5961 ospf_message_digest_key_cmd
,
5962 "ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
5963 "OSPF interface commands\n"
5964 "Message digest authentication password (key)\n"
5966 "Use MD5 algorithm\n"
5967 "The OSPF password (key)\n"
5968 "Address of interface\n")
5970 return ip_ospf_message_digest_key(self
, vty
, argc
, argv
);
5973 DEFUN (no_ip_ospf_message_digest_key
,
5974 no_ip_ospf_message_digest_key_cmd
,
5975 "no ip ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
5978 "OSPF interface commands\n"
5979 "Message digest authentication password (key)\n"
5981 "Use MD5 algorithm\n"
5982 "The OSPF password (key)\n"
5983 "Address of interface\n")
5985 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5987 struct crypt_key
*ck
;
5989 struct in_addr addr
;
5990 struct ospf_if_params
*params
;
5991 params
= IF_DEF_PARAMS(ifp
);
5993 argv_find(argv
, argc
, "(1-255)", &idx
);
5994 char *keyid
= argv
[idx
]->arg
;
5996 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
5997 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
5999 "Please specify interface address by A.B.C.D\n");
6000 return CMD_WARNING_CONFIG_FAILED
;
6003 params
= ospf_lookup_if_params(ifp
, addr
);
6008 key_id
= strtol(keyid
, NULL
, 10);
6009 ck
= ospf_crypt_key_lookup(params
->auth_crypt
, key_id
);
6011 vty_out(vty
, "OSPF: Key %d does not exist\n", key_id
);
6012 return CMD_WARNING_CONFIG_FAILED
;
6015 ospf_crypt_key_delete(params
->auth_crypt
, key_id
);
6017 if (params
!= IF_DEF_PARAMS(ifp
)) {
6018 ospf_free_if_params(ifp
, addr
);
6019 ospf_if_update_params(ifp
, addr
);
6025 DEFUN_HIDDEN (no_ospf_message_digest_key
,
6026 no_ospf_message_digest_key_cmd
,
6027 "no ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
6029 "OSPF interface commands\n"
6030 "Message digest authentication password (key)\n"
6032 "Address of interface")
6034 return no_ip_ospf_message_digest_key(self
, vty
, argc
, argv
);
6037 DEFUN (ip_ospf_cost
,
6039 "ip ospf cost (1-65535) [A.B.C.D]",
6041 "OSPF interface commands\n"
6044 "Address of interface\n")
6046 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6049 struct in_addr addr
;
6050 struct ospf_if_params
*params
;
6051 params
= IF_DEF_PARAMS(ifp
);
6054 char *coststr
= NULL
, *ifaddr
= NULL
;
6055 coststr
= argv_find(argv
, argc
, "(1-65535)", &idx
) ? argv
[idx
]->arg
6057 ifaddr
= argv_find(argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6059 cost
= strtol(coststr
, NULL
, 10);
6062 if (!inet_aton(ifaddr
, &addr
)) {
6064 "Please specify interface address by A.B.C.D\n");
6065 return CMD_WARNING_CONFIG_FAILED
;
6068 params
= ospf_get_if_params(ifp
, addr
);
6069 ospf_if_update_params(ifp
, addr
);
6072 SET_IF_PARAM(params
, output_cost_cmd
);
6073 params
->output_cost_cmd
= cost
;
6075 ospf_if_recalculate_output_cost(ifp
);
6080 DEFUN_HIDDEN (ospf_cost
,
6082 "ospf cost (1-65535) [A.B.C.D]",
6083 "OSPF interface commands\n"
6086 "Address of interface\n")
6088 return ip_ospf_cost(self
, vty
, argc
, argv
);
6091 DEFUN (no_ip_ospf_cost
,
6092 no_ip_ospf_cost_cmd
,
6093 "no ip ospf cost [(1-65535)] [A.B.C.D]",
6095 "OSPF interface commands\n"
6097 "Address of interface")
6099 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6101 struct in_addr addr
;
6102 struct ospf_if_params
*params
;
6104 params
= IF_DEF_PARAMS(ifp
);
6107 char *ifaddr
= NULL
;
6108 ifaddr
= argv_find(argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6110 /* According to the semantics we are mimicking "no ip ospf cost N" is
6111 * always treated as "no ip ospf cost" regardless of the actual value
6112 * of N already configured for the interface. Thus ignore cost. */
6115 if (!inet_aton(ifaddr
, &addr
)) {
6117 "Please specify interface address by A.B.C.D\n");
6118 return CMD_WARNING_CONFIG_FAILED
;
6121 params
= ospf_lookup_if_params(ifp
, addr
);
6126 UNSET_IF_PARAM(params
, output_cost_cmd
);
6128 if (params
!= IF_DEF_PARAMS(ifp
)) {
6129 ospf_free_if_params(ifp
, addr
);
6130 ospf_if_update_params(ifp
, addr
);
6133 ospf_if_recalculate_output_cost(ifp
);
6138 DEFUN_HIDDEN (no_ospf_cost
,
6140 "no ospf cost [(1-65535)] [A.B.C.D]",
6142 "OSPF interface commands\n"
6145 "Address of interface\n")
6147 return no_ip_ospf_cost(self
, vty
, argc
, argv
);
6150 static void ospf_nbr_timer_update(struct ospf_interface
*oi
)
6152 struct route_node
*rn
;
6153 struct ospf_neighbor
*nbr
;
6155 for (rn
= route_top(oi
->nbrs
); rn
; rn
= route_next(rn
))
6156 if ((nbr
= rn
->info
)) {
6157 nbr
->v_inactivity
= OSPF_IF_PARAM(oi
, v_wait
);
6158 nbr
->v_db_desc
= OSPF_IF_PARAM(oi
, retransmit_interval
);
6159 nbr
->v_ls_req
= OSPF_IF_PARAM(oi
, retransmit_interval
);
6160 nbr
->v_ls_upd
= OSPF_IF_PARAM(oi
, retransmit_interval
);
6164 static int ospf_vty_dead_interval_set(struct vty
*vty
, const char *interval_str
,
6165 const char *nbr_str
,
6166 const char *fast_hello_str
)
6168 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6171 struct in_addr addr
;
6173 struct ospf_if_params
*params
;
6174 struct ospf_interface
*oi
;
6175 struct route_node
*rn
;
6177 params
= IF_DEF_PARAMS(ifp
);
6180 ret
= inet_aton(nbr_str
, &addr
);
6183 "Please specify interface address by A.B.C.D\n");
6184 return CMD_WARNING_CONFIG_FAILED
;
6187 params
= ospf_get_if_params(ifp
, addr
);
6188 ospf_if_update_params(ifp
, addr
);
6192 seconds
= strtoul(interval_str
, NULL
, 10);
6194 /* reset fast_hello too, just to be sure */
6195 UNSET_IF_PARAM(params
, fast_hello
);
6196 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6197 } else if (fast_hello_str
) {
6198 hellomult
= strtoul(fast_hello_str
, NULL
, 10);
6199 /* 1s dead-interval with sub-second hellos desired */
6200 seconds
= OSPF_ROUTER_DEAD_INTERVAL_MINIMAL
;
6201 SET_IF_PARAM(params
, fast_hello
);
6202 params
->fast_hello
= hellomult
;
6205 "Please specify dead-interval or hello-multiplier\n");
6206 return CMD_WARNING_CONFIG_FAILED
;
6209 SET_IF_PARAM(params
, v_wait
);
6210 params
->v_wait
= seconds
;
6212 /* Update timer values in neighbor structure. */
6215 if ((ospf
= ospf_lookup())) {
6216 oi
= ospf_if_lookup_by_local_addr(ospf
, ifp
, addr
);
6218 ospf_nbr_timer_update(oi
);
6221 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
))
6222 if ((oi
= rn
->info
))
6223 ospf_nbr_timer_update(oi
);
6229 DEFUN (ip_ospf_dead_interval
,
6230 ip_ospf_dead_interval_cmd
,
6231 "ip ospf dead-interval (1-65535) [A.B.C.D]",
6233 "OSPF interface commands\n"
6234 "Interval time after which a neighbor is declared down\n"
6236 "Address of interface\n")
6239 char *interval
= argv_find(argv
, argc
, "(1-65535)", &idx
)
6243 argv_find(argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6244 return ospf_vty_dead_interval_set(vty
, interval
, ifaddr
, NULL
);
6248 DEFUN_HIDDEN (ospf_dead_interval
,
6249 ospf_dead_interval_cmd
,
6250 "ospf dead-interval (1-65535) [A.B.C.D]",
6251 "OSPF interface commands\n"
6252 "Interval time after which a neighbor is declared down\n"
6254 "Address of interface\n")
6256 return ip_ospf_dead_interval(self
, vty
, argc
, argv
);
6259 DEFUN (ip_ospf_dead_interval_minimal
,
6260 ip_ospf_dead_interval_minimal_addr_cmd
,
6261 "ip ospf dead-interval minimal hello-multiplier (1-10) [A.B.C.D]",
6263 "OSPF interface commands\n"
6264 "Interval time after which a neighbor is declared down\n"
6265 "Minimal 1s dead-interval with fast sub-second hellos\n"
6266 "Hello multiplier factor\n"
6267 "Number of Hellos to send each second\n"
6268 "Address of interface\n")
6273 return ospf_vty_dead_interval_set(
6274 vty
, NULL
, argv
[idx_ipv4
]->arg
, argv
[idx_number
]->arg
);
6276 return ospf_vty_dead_interval_set(vty
, NULL
, NULL
,
6277 argv
[idx_number
]->arg
);
6280 DEFUN (no_ip_ospf_dead_interval
,
6281 no_ip_ospf_dead_interval_cmd
,
6282 "no ip ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6285 "OSPF interface commands\n"
6286 "Interval time after which a neighbor is declared down\n"
6288 "Address of interface")
6290 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6291 int idx_ipv4
= argc
- 1;
6292 struct in_addr addr
= {.s_addr
= 0L};
6294 struct ospf_if_params
*params
;
6295 struct ospf_interface
*oi
;
6296 struct route_node
*rn
;
6298 params
= IF_DEF_PARAMS(ifp
);
6300 if (argv
[idx_ipv4
]->type
== IPV4_TKN
) {
6301 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6304 "Please specify interface address by A.B.C.D\n");
6305 return CMD_WARNING_CONFIG_FAILED
;
6308 params
= ospf_lookup_if_params(ifp
, addr
);
6313 UNSET_IF_PARAM(params
, v_wait
);
6314 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
6316 UNSET_IF_PARAM(params
, fast_hello
);
6317 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6319 if (params
!= IF_DEF_PARAMS(ifp
)) {
6320 ospf_free_if_params(ifp
, addr
);
6321 ospf_if_update_params(ifp
, addr
);
6324 /* Update timer values in neighbor structure. */
6328 if ((ospf
= ospf_lookup())) {
6329 oi
= ospf_if_lookup_by_local_addr(ospf
, ifp
, addr
);
6331 ospf_nbr_timer_update(oi
);
6334 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
))
6335 if ((oi
= rn
->info
))
6336 ospf_nbr_timer_update(oi
);
6342 DEFUN_HIDDEN (no_ospf_dead_interval
,
6343 no_ospf_dead_interval_cmd
,
6344 "no ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6346 "OSPF interface commands\n"
6347 "Interval time after which a neighbor is declared down\n"
6349 "Address of interface")
6351 return no_ip_ospf_dead_interval(self
, vty
, argc
, argv
);
6354 DEFUN (ip_ospf_hello_interval
,
6355 ip_ospf_hello_interval_cmd
,
6356 "ip ospf hello-interval (1-65535) [A.B.C.D]",
6358 "OSPF interface commands\n"
6359 "Time between HELLO packets\n"
6361 "Address of interface\n")
6363 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6365 struct in_addr addr
;
6366 struct ospf_if_params
*params
;
6367 params
= IF_DEF_PARAMS(ifp
);
6368 u_int32_t seconds
= 0;
6370 argv_find(argv
, argc
, "(1-65535)", &idx
);
6371 seconds
= strtol(argv
[idx
]->arg
, NULL
, 10);
6373 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6374 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6376 "Please specify interface address by A.B.C.D\n");
6377 return CMD_WARNING_CONFIG_FAILED
;
6380 params
= ospf_get_if_params(ifp
, addr
);
6381 ospf_if_update_params(ifp
, addr
);
6384 SET_IF_PARAM(params
, v_hello
);
6385 params
->v_hello
= seconds
;
6390 DEFUN_HIDDEN (ospf_hello_interval
,
6391 ospf_hello_interval_cmd
,
6392 "ospf hello-interval (1-65535) [A.B.C.D]",
6393 "OSPF interface commands\n"
6394 "Time between HELLO packets\n"
6396 "Address of interface\n")
6398 return ip_ospf_hello_interval(self
, vty
, argc
, argv
);
6401 DEFUN (no_ip_ospf_hello_interval
,
6402 no_ip_ospf_hello_interval_cmd
,
6403 "no ip ospf hello-interval [(1-65535) [A.B.C.D]]",
6406 "OSPF interface commands\n"
6407 "Time between HELLO packets\n" // ignored
6409 "Address of interface\n")
6411 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6413 struct in_addr addr
;
6414 struct ospf_if_params
*params
;
6416 params
= IF_DEF_PARAMS(ifp
);
6418 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6419 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6421 "Please specify interface address by A.B.C.D\n");
6422 return CMD_WARNING_CONFIG_FAILED
;
6425 params
= ospf_lookup_if_params(ifp
, addr
);
6430 UNSET_IF_PARAM(params
, v_hello
);
6431 params
->v_hello
= OSPF_HELLO_INTERVAL_DEFAULT
;
6433 if (params
!= IF_DEF_PARAMS(ifp
)) {
6434 ospf_free_if_params(ifp
, addr
);
6435 ospf_if_update_params(ifp
, addr
);
6441 DEFUN_HIDDEN (no_ospf_hello_interval
,
6442 no_ospf_hello_interval_cmd
,
6443 "no ospf hello-interval [(1-65535) [A.B.C.D]]",
6445 "OSPF interface commands\n"
6446 "Time between HELLO packets\n" // ignored
6448 "Address of interface\n")
6450 return no_ip_ospf_hello_interval(self
, vty
, argc
, argv
);
6453 DEFUN (ip_ospf_network
,
6454 ip_ospf_network_cmd
,
6455 "ip ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
6457 "OSPF interface commands\n"
6459 "Specify OSPF broadcast multi-access network\n"
6460 "Specify OSPF NBMA network\n"
6461 "Specify OSPF point-to-multipoint network\n"
6462 "Specify OSPF point-to-point network\n")
6464 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6466 int old_type
= IF_DEF_PARAMS(ifp
)->type
;
6467 struct route_node
*rn
;
6469 if (old_type
== OSPF_IFTYPE_LOOPBACK
) {
6471 "This is a loopback interface. Can't set network type.\n");
6472 return CMD_WARNING_CONFIG_FAILED
;
6475 if (argv_find(argv
, argc
, "broadcast", &idx
))
6476 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_BROADCAST
;
6477 else if (argv_find(argv
, argc
, "non-broadcast", &idx
))
6478 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_NBMA
;
6479 else if (argv_find(argv
, argc
, "point-to-multipoint", &idx
))
6480 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_POINTOMULTIPOINT
;
6481 else if (argv_find(argv
, argc
, "point-to-point", &idx
))
6482 IF_DEF_PARAMS(ifp
)->type
= OSPF_IFTYPE_POINTOPOINT
;
6484 if (IF_DEF_PARAMS(ifp
)->type
== old_type
)
6487 SET_IF_PARAM(IF_DEF_PARAMS(ifp
), type
);
6489 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
6490 struct ospf_interface
*oi
= rn
->info
;
6495 oi
->type
= IF_DEF_PARAMS(ifp
)->type
;
6497 if (oi
->state
> ISM_Down
) {
6498 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceDown
);
6499 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceUp
);
6506 DEFUN_HIDDEN (ospf_network
,
6508 "ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
6509 "OSPF interface commands\n"
6511 "Specify OSPF broadcast multi-access network\n"
6512 "Specify OSPF NBMA network\n"
6513 "Specify OSPF point-to-multipoint network\n"
6514 "Specify OSPF point-to-point network\n")
6516 return ip_ospf_network(self
, vty
, argc
, argv
);
6519 DEFUN (no_ip_ospf_network
,
6520 no_ip_ospf_network_cmd
,
6521 "no ip ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
6524 "OSPF interface commands\n"
6526 "Specify OSPF broadcast multi-access network\n"
6527 "Specify OSPF NBMA network\n"
6528 "Specify OSPF point-to-multipoint network\n"
6529 "Specify OSPF point-to-point network\n")
6531 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6532 int old_type
= IF_DEF_PARAMS(ifp
)->type
;
6533 struct route_node
*rn
;
6535 IF_DEF_PARAMS(ifp
)->type
= ospf_default_iftype(ifp
);
6537 if (IF_DEF_PARAMS(ifp
)->type
== old_type
)
6540 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
6541 struct ospf_interface
*oi
= rn
->info
;
6546 oi
->type
= IF_DEF_PARAMS(ifp
)->type
;
6548 if (oi
->state
> ISM_Down
) {
6549 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceDown
);
6550 OSPF_ISM_EVENT_EXECUTE(oi
, ISM_InterfaceUp
);
6557 DEFUN_HIDDEN (no_ospf_network
,
6558 no_ospf_network_cmd
,
6559 "no ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
6561 "OSPF interface commands\n"
6563 "Specify OSPF broadcast multi-access network\n"
6564 "Specify OSPF NBMA network\n"
6565 "Specify OSPF point-to-multipoint network\n"
6566 "Specify OSPF point-to-point network\n")
6568 return no_ip_ospf_network(self
, vty
, argc
, argv
);
6571 DEFUN (ip_ospf_priority
,
6572 ip_ospf_priority_cmd
,
6573 "ip ospf priority (0-255) [A.B.C.D]",
6575 "OSPF interface commands\n"
6578 "Address of interface")
6580 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6583 struct route_node
*rn
;
6584 struct in_addr addr
;
6585 struct ospf_if_params
*params
;
6586 params
= IF_DEF_PARAMS(ifp
);
6588 argv_find(argv
, argc
, "(0-255)", &idx
);
6589 priority
= strtol(argv
[idx
]->arg
, NULL
, 10);
6591 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6592 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6594 "Please specify interface address by A.B.C.D\n");
6595 return CMD_WARNING_CONFIG_FAILED
;
6598 params
= ospf_get_if_params(ifp
, addr
);
6599 ospf_if_update_params(ifp
, addr
);
6602 SET_IF_PARAM(params
, priority
);
6603 params
->priority
= priority
;
6605 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
6606 struct ospf_interface
*oi
= rn
->info
;
6611 if (PRIORITY(oi
) != OSPF_IF_PARAM(oi
, priority
)) {
6612 PRIORITY(oi
) = OSPF_IF_PARAM(oi
, priority
);
6613 OSPF_ISM_EVENT_SCHEDULE(oi
, ISM_NeighborChange
);
6620 DEFUN_HIDDEN (ospf_priority
,
6622 "ospf priority (0-255) [A.B.C.D]",
6623 "OSPF interface commands\n"
6626 "Address of interface")
6628 return ip_ospf_priority(self
, vty
, argc
, argv
);
6631 DEFUN (no_ip_ospf_priority
,
6632 no_ip_ospf_priority_cmd
,
6633 "no ip ospf priority [(0-255) [A.B.C.D]]",
6636 "OSPF interface commands\n"
6637 "Router priority\n" // ignored
6639 "Address of interface")
6641 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6643 struct route_node
*rn
;
6644 struct in_addr addr
;
6645 struct ospf_if_params
*params
;
6647 params
= IF_DEF_PARAMS(ifp
);
6649 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6650 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6652 "Please specify interface address by A.B.C.D\n");
6653 return CMD_WARNING_CONFIG_FAILED
;
6656 params
= ospf_lookup_if_params(ifp
, addr
);
6661 UNSET_IF_PARAM(params
, priority
);
6662 params
->priority
= OSPF_ROUTER_PRIORITY_DEFAULT
;
6664 if (params
!= IF_DEF_PARAMS(ifp
)) {
6665 ospf_free_if_params(ifp
, addr
);
6666 ospf_if_update_params(ifp
, addr
);
6669 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next(rn
)) {
6670 struct ospf_interface
*oi
= rn
->info
;
6675 if (PRIORITY(oi
) != OSPF_IF_PARAM(oi
, priority
)) {
6676 PRIORITY(oi
) = OSPF_IF_PARAM(oi
, priority
);
6677 OSPF_ISM_EVENT_SCHEDULE(oi
, ISM_NeighborChange
);
6684 DEFUN_HIDDEN (no_ospf_priority
,
6685 no_ospf_priority_cmd
,
6686 "no ospf priority [(0-255) [A.B.C.D]]",
6688 "OSPF interface commands\n"
6691 "Address of interface")
6693 return no_ip_ospf_priority(self
, vty
, argc
, argv
);
6696 DEFUN (ip_ospf_retransmit_interval
,
6697 ip_ospf_retransmit_interval_addr_cmd
,
6698 "ip ospf retransmit-interval (3-65535) [A.B.C.D]",
6700 "OSPF interface commands\n"
6701 "Time between retransmitting lost link state advertisements\n"
6703 "Address of interface")
6705 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6708 struct in_addr addr
;
6709 struct ospf_if_params
*params
;
6710 params
= IF_DEF_PARAMS(ifp
);
6712 argv_find(argv
, argc
, "(3-65535)", &idx
);
6713 seconds
= strtol(argv
[idx
]->arg
, NULL
, 10);
6715 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6716 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6718 "Please specify interface address by A.B.C.D\n");
6719 return CMD_WARNING_CONFIG_FAILED
;
6722 params
= ospf_get_if_params(ifp
, addr
);
6723 ospf_if_update_params(ifp
, addr
);
6726 SET_IF_PARAM(params
, retransmit_interval
);
6727 params
->retransmit_interval
= seconds
;
6732 DEFUN_HIDDEN (ospf_retransmit_interval
,
6733 ospf_retransmit_interval_cmd
,
6734 "ospf retransmit-interval (3-65535) [A.B.C.D]",
6735 "OSPF interface commands\n"
6736 "Time between retransmitting lost link state advertisements\n"
6738 "Address of interface")
6740 return ip_ospf_retransmit_interval(self
, vty
, argc
, argv
);
6743 DEFUN (no_ip_ospf_retransmit_interval
,
6744 no_ip_ospf_retransmit_interval_addr_cmd
,
6745 "no ip ospf retransmit-interval [(3-65535)] [A.B.C.D]",
6748 "OSPF interface commands\n"
6749 "Time between retransmitting lost link state advertisements\n"
6751 "Address of interface\n")
6753 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6755 struct in_addr addr
;
6756 struct ospf_if_params
*params
;
6758 params
= IF_DEF_PARAMS(ifp
);
6760 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6761 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6763 "Please specify interface address by A.B.C.D\n");
6764 return CMD_WARNING_CONFIG_FAILED
;
6767 params
= ospf_lookup_if_params(ifp
, addr
);
6772 UNSET_IF_PARAM(params
, retransmit_interval
);
6773 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
6775 if (params
!= IF_DEF_PARAMS(ifp
)) {
6776 ospf_free_if_params(ifp
, addr
);
6777 ospf_if_update_params(ifp
, addr
);
6783 DEFUN_HIDDEN (no_ospf_retransmit_interval
,
6784 no_ospf_retransmit_interval_cmd
,
6785 "no ospf retransmit-interval [(3-65535)] [A.B.C.D]",
6787 "OSPF interface commands\n"
6788 "Time between retransmitting lost link state advertisements\n"
6790 "Address of interface\n")
6792 return no_ip_ospf_retransmit_interval(self
, vty
, argc
, argv
);
6795 DEFUN (ip_ospf_transmit_delay
,
6796 ip_ospf_transmit_delay_addr_cmd
,
6797 "ip ospf transmit-delay (1-65535) [A.B.C.D]",
6799 "OSPF interface commands\n"
6800 "Link state transmit delay\n"
6802 "Address of interface")
6804 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6807 struct in_addr addr
;
6808 struct ospf_if_params
*params
;
6810 params
= IF_DEF_PARAMS(ifp
);
6811 argv_find(argv
, argc
, "(1-65535)", &idx
);
6812 seconds
= strtol(argv
[idx
]->arg
, NULL
, 10);
6814 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6815 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6817 "Please specify interface address by A.B.C.D\n");
6818 return CMD_WARNING_CONFIG_FAILED
;
6821 params
= ospf_get_if_params(ifp
, addr
);
6822 ospf_if_update_params(ifp
, addr
);
6825 SET_IF_PARAM(params
, transmit_delay
);
6826 params
->transmit_delay
= seconds
;
6831 DEFUN_HIDDEN (ospf_transmit_delay
,
6832 ospf_transmit_delay_cmd
,
6833 "ospf transmit-delay (1-65535) [A.B.C.D]",
6834 "OSPF interface commands\n"
6835 "Link state transmit delay\n"
6837 "Address of interface")
6839 return ip_ospf_transmit_delay(self
, vty
, argc
, argv
);
6842 DEFUN (no_ip_ospf_transmit_delay
,
6843 no_ip_ospf_transmit_delay_addr_cmd
,
6844 "no ip ospf transmit-delay [(1-65535)] [A.B.C.D]",
6847 "OSPF interface commands\n"
6848 "Link state transmit delay\n"
6849 "Address of interface")
6851 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6853 struct in_addr addr
;
6854 struct ospf_if_params
*params
;
6856 params
= IF_DEF_PARAMS(ifp
);
6858 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6859 if (!inet_aton(argv
[idx
]->arg
, &addr
)) {
6861 "Please specify interface address by A.B.C.D\n");
6862 return CMD_WARNING_CONFIG_FAILED
;
6865 params
= ospf_lookup_if_params(ifp
, addr
);
6870 UNSET_IF_PARAM(params
, transmit_delay
);
6871 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
6873 if (params
!= IF_DEF_PARAMS(ifp
)) {
6874 ospf_free_if_params(ifp
, addr
);
6875 ospf_if_update_params(ifp
, addr
);
6882 DEFUN_HIDDEN (no_ospf_transmit_delay
,
6883 no_ospf_transmit_delay_cmd
,
6884 "no ospf transmit-delay",
6886 "OSPF interface commands\n"
6887 "Link state transmit delay\n")
6889 return no_ip_ospf_transmit_delay(self
, vty
, argc
, argv
);
6892 DEFUN (ip_ospf_area
,
6894 "ip ospf [(1-65535)] area <A.B.C.D|(0-4294967295)> [A.B.C.D]",
6896 "OSPF interface commands\n"
6898 "Enable OSPF on this interface\n"
6899 "OSPF area ID in IP address format\n"
6900 "OSPF area ID as a decimal value\n"
6901 "Address of interface\n")
6903 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6906 struct in_addr area_id
;
6907 struct in_addr addr
;
6908 struct ospf_if_params
*params
;
6909 struct route_node
*rn
;
6911 u_short instance
= 0;
6914 if (argv_find(argv
, argc
, "(1-65535)", &idx
))
6915 instance
= strtol(argv
[idx
]->arg
, NULL
, 10);
6917 argv_find(argv
, argc
, "area", &idx
);
6918 areaid
= argv
[idx
+ 1]->arg
;
6920 ospf
= ospf_lookup_instance(instance
);
6922 params
= IF_DEF_PARAMS(ifp
);
6923 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
6924 UNSET_IF_PARAM(params
, if_area
);
6925 ospf_interface_area_unset(ifp
);
6926 ospf
= ospf_lookup();
6927 ospf
->if_ospf_cli_count
--;
6929 return CMD_NOT_MY_INSTANCE
;
6932 ret
= str2area_id(areaid
, &area_id
, &format
);
6934 vty_out(vty
, "Please specify area by A.B.C.D|<0-4294967295>\n");
6935 return CMD_WARNING_CONFIG_FAILED
;
6937 if (memcmp(ifp
->name
, "VLINK", 5) == 0) {
6938 vty_out(vty
, "Cannot enable OSPF on a virtual link.\n");
6939 return CMD_WARNING_CONFIG_FAILED
;
6942 params
= IF_DEF_PARAMS(ifp
);
6943 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)
6944 && !IPV4_ADDR_SAME(¶ms
->if_area
, &area_id
)) {
6946 "Must remove previous area config before changing ospf area \n");
6947 return CMD_WARNING_CONFIG_FAILED
;
6950 // Check if we have an address arg and proccess it
6951 if (argc
== idx
+ 3) {
6952 inet_aton(argv
[idx
+ 2]->arg
, &addr
);
6953 // update/create address-level params
6954 params
= ospf_get_if_params((ifp
), (addr
));
6955 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
6957 "Must remove previous area/address config before changing ospf area");
6958 return CMD_WARNING_CONFIG_FAILED
;
6960 ospf_if_update_params((ifp
), (addr
));
6963 for (rn
= route_top(ospf
->networks
); rn
; rn
= route_next(rn
)) {
6964 if (rn
->info
!= NULL
) {
6966 "Please remove all network commands first.\n");
6967 return CMD_WARNING_CONFIG_FAILED
;
6971 /* enable ospf on this interface with area_id */
6972 SET_IF_PARAM(params
, if_area
);
6973 params
->if_area
= area_id
;
6974 ospf_interface_area_set(ifp
);
6975 ospf
->if_ospf_cli_count
++;
6980 DEFUN (no_ip_ospf_area
,
6981 no_ip_ospf_area_cmd
,
6982 "no ip ospf [(1-65535)] area [<A.B.C.D|(0-4294967295)> [A.B.C.D]]",
6985 "OSPF interface commands\n"
6987 "Disable OSPF on this interface\n"
6988 "OSPF area ID in IP address format\n"
6989 "OSPF area ID as a decimal value\n"
6990 "Address of interface\n")
6992 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6995 struct ospf_if_params
*params
;
6996 u_short instance
= 0;
6997 struct in_addr addr
;
6999 if (argv_find(argv
, argc
, "(1-65535)", &idx
))
7000 instance
= strtol(argv
[idx
]->arg
, NULL
, 10);
7002 ospf
= ospf_lookup_instance(instance
);
7004 return CMD_NOT_MY_INSTANCE
;
7006 argv_find(argv
, argc
, "area", &idx
);
7008 // Check if we have an address arg and proccess it
7009 if (argc
== idx
+ 3) {
7010 inet_aton(argv
[idx
+ 2]->arg
, &addr
);
7011 params
= ospf_lookup_if_params(ifp
, addr
);
7012 if ((params
) == NULL
)
7015 params
= IF_DEF_PARAMS(ifp
);
7017 if (!OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
7019 "Can't find specified interface area configuration.\n");
7020 return CMD_WARNING_CONFIG_FAILED
;
7023 UNSET_IF_PARAM(params
, if_area
);
7024 if (params
!= IF_DEF_PARAMS((ifp
))) {
7025 ospf_free_if_params((ifp
), (addr
));
7026 ospf_if_update_params((ifp
), (addr
));
7029 ospf_interface_area_unset(ifp
);
7030 ospf
->if_ospf_cli_count
--;
7034 DEFUN (ospf_redistribute_source
,
7035 ospf_redistribute_source_cmd
,
7036 "redistribute " FRR_REDIST_STR_OSPFD
" [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7038 FRR_REDIST_HELP_STR_OSPFD
7039 "Metric for redistributed routes\n"
7040 "OSPF default metric\n"
7041 "OSPF exterior metric type for redistributed routes\n"
7042 "Set OSPF External Type 1/2 metrics\n"
7043 "Route map reference\n"
7044 "Pointer to route-map entries\n")
7046 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7047 int idx_protocol
= 1;
7051 struct ospf_redist
*red
;
7057 /* Get distribute source. */
7058 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
7060 return CMD_WARNING_CONFIG_FAILED
;
7062 red
= ospf_redist_add(ospf
, source
, 0);
7064 /* Get metric value. */
7065 if (argv_find(argv
, argc
, "(0-16777214)", &idx
)) {
7066 if (!str2metric(argv
[idx
]->arg
, &metric
))
7067 return CMD_WARNING_CONFIG_FAILED
;
7069 /* Get metric type. */
7070 else if (argv_find(argv
, argc
, "(1-2)", &idx
)) {
7071 if (!str2metric_type(argv
[idx
]->arg
, &type
))
7072 return CMD_WARNING_CONFIG_FAILED
;
7075 else if (argv_find(argv
, argc
, "WORD", &idx
)) {
7076 ospf_routemap_set(red
, argv
[idx
]->arg
);
7078 ospf_routemap_unset(red
);
7080 return ospf_redistribute_set(ospf
, source
, 0, type
, metric
);
7083 DEFUN (no_ospf_redistribute_source
,
7084 no_ospf_redistribute_source_cmd
,
7085 "no redistribute " FRR_REDIST_STR_OSPFD
" [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7088 FRR_REDIST_HELP_STR_OSPFD
7089 "Metric for redistributed routes\n"
7090 "OSPF default metric\n"
7091 "OSPF exterior metric type for redistributed routes\n"
7092 "Set OSPF External Type 1/2 metrics\n"
7093 "Route map reference\n"
7094 "Pointer to route-map entries\n")
7096 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7097 int idx_protocol
= 2;
7099 struct ospf_redist
*red
;
7101 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
7103 return CMD_WARNING_CONFIG_FAILED
;
7105 red
= ospf_redist_lookup(ospf
, source
, 0);
7109 ospf_routemap_unset(red
);
7110 return ospf_redistribute_unset(ospf
, source
, 0);
7113 DEFUN (ospf_redistribute_instance_source
,
7114 ospf_redistribute_instance_source_cmd
,
7115 "redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
7117 "Open Shortest Path First\n"
7118 "Non-main Kernel Routing Table\n"
7119 "Instance ID/Table ID\n"
7120 "Metric for redistributed routes\n"
7121 "OSPF default metric\n"
7122 "OSPF exterior metric type for redistributed routes\n"
7123 "Set OSPF External Type 1/2 metrics\n"
7124 "Route map reference\n"
7125 "Pointer to route-map entries\n")
7127 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7128 int idx_ospf_table
= 1;
7135 struct ospf_redist
*red
;
7140 source
= proto_redistnum(AFI_IP
, argv
[idx_ospf_table
]->text
);
7142 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7147 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
) {
7149 "Instance redistribution in non-instanced OSPF not allowed\n");
7150 return CMD_WARNING_CONFIG_FAILED
;
7153 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
)) {
7154 vty_out(vty
, "Same instance OSPF redistribution not allowed\n");
7155 return CMD_WARNING_CONFIG_FAILED
;
7158 /* Get metric value. */
7159 if (argv_find(argv
, argc
, "metric", &idx
))
7160 if (!str2metric(argv
[idx
+ 1]->arg
, &metric
))
7161 return CMD_WARNING_CONFIG_FAILED
;
7164 /* Get metric type. */
7165 if (argv_find(argv
, argc
, "metric-type", &idx
))
7166 if (!str2metric_type(argv
[idx
+ 1]->arg
, &type
))
7167 return CMD_WARNING_CONFIG_FAILED
;
7169 red
= ospf_redist_add(ospf
, source
, instance
);
7172 if (argv_find(argv
, argc
, "route-map", &idx
))
7173 ospf_routemap_set(red
, argv
[idx
+ 1]->arg
);
7175 ospf_routemap_unset(red
);
7177 return ospf_redistribute_set(ospf
, source
, instance
, type
, metric
);
7180 DEFUN (no_ospf_redistribute_instance_source
,
7181 no_ospf_redistribute_instance_source_cmd
,
7182 "no redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
7185 "Open Shortest Path First\n"
7186 "Non-main Kernel Routing Table\n"
7187 "Instance ID/Table Id\n"
7188 "Metric for redistributed routes\n"
7189 "OSPF default metric\n"
7190 "OSPF exterior metric type for redistributed routes\n"
7191 "Set OSPF External Type 1/2 metrics\n"
7192 "Route map reference\n"
7193 "Pointer to route-map entries\n")
7195 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7196 int idx_ospf_table
= 2;
7199 struct ospf_redist
*red
;
7202 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
7203 source
= ZEBRA_ROUTE_OSPF
;
7205 source
= ZEBRA_ROUTE_TABLE
;
7207 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7209 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
) {
7211 "Instance redistribution in non-instanced OSPF not allowed\n");
7212 return CMD_WARNING_CONFIG_FAILED
;
7215 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
)) {
7216 vty_out(vty
, "Same instance OSPF redistribution not allowed\n");
7217 return CMD_WARNING_CONFIG_FAILED
;
7220 red
= ospf_redist_lookup(ospf
, source
, instance
);
7224 ospf_routemap_unset(red
);
7225 return ospf_redistribute_unset(ospf
, source
, instance
);
7228 DEFUN (ospf_distribute_list_out
,
7229 ospf_distribute_list_out_cmd
,
7230 "distribute-list WORD out " FRR_REDIST_STR_OSPFD
,
7231 "Filter networks in routing updates\n"
7232 "Access-list name\n"
7234 FRR_REDIST_HELP_STR_OSPFD
)
7236 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7240 char *proto
= argv
[argc
- 1]->text
;
7242 /* Get distribute source. */
7243 source
= proto_redistnum(AFI_IP
, proto
);
7245 return CMD_WARNING_CONFIG_FAILED
;
7247 return ospf_distribute_list_out_set(ospf
, source
, argv
[idx_word
]->arg
);
7250 DEFUN (no_ospf_distribute_list_out
,
7251 no_ospf_distribute_list_out_cmd
,
7252 "no distribute-list WORD out " FRR_REDIST_STR_OSPFD
,
7254 "Filter networks in routing updates\n"
7255 "Access-list name\n"
7257 FRR_REDIST_HELP_STR_OSPFD
)
7259 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7263 char *proto
= argv
[argc
- 1]->text
;
7264 source
= proto_redistnum(AFI_IP
, proto
);
7266 return CMD_WARNING_CONFIG_FAILED
;
7268 return ospf_distribute_list_out_unset(ospf
, source
,
7269 argv
[idx_word
]->arg
);
7272 /* Default information originate. */
7273 DEFUN (ospf_default_information_originate
,
7274 ospf_default_information_originate_cmd
,
7275 "default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7276 "Control distribution of default information\n"
7277 "Distribute a default route\n"
7278 "Always advertise default route\n"
7279 "OSPF default metric\n"
7281 "OSPF metric type for default routes\n"
7282 "Set OSPF External Type 1/2 metrics\n"
7283 "Route map reference\n"
7284 "Pointer to route-map entries\n")
7286 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7287 int default_originate
= DEFAULT_ORIGINATE_ZEBRA
;
7290 struct ospf_redist
*red
;
7293 red
= ospf_redist_add(ospf
, DEFAULT_ROUTE
, 0);
7295 /* Check whether "always" was specified */
7296 if (argv_find(argv
, argc
, "always", &idx
))
7297 default_originate
= DEFAULT_ORIGINATE_ALWAYS
;
7298 /* Get metric value */
7299 else if (argv_find(argv
, argc
, "(0-16777214)", &idx
)) {
7300 if (!str2metric(argv
[idx
]->arg
, &metric
))
7301 return CMD_WARNING_CONFIG_FAILED
;
7303 /* Get metric type. */
7304 else if (argv_find(argv
, argc
, "(1-2)", &idx
)) {
7305 if (!str2metric_type(argv
[idx
]->arg
, &type
))
7306 return CMD_WARNING_CONFIG_FAILED
;
7309 else if (argv_find(argv
, argc
, "WORD", &idx
))
7310 ospf_routemap_set(red
, argv
[idx
]->arg
);
7312 ospf_routemap_unset(red
);
7314 return ospf_redistribute_default_set(ospf
, default_originate
, type
,
7318 DEFUN (no_ospf_default_information_originate
,
7319 no_ospf_default_information_originate_cmd
,
7320 "no default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7322 "Control distribution of default information\n"
7323 "Distribute a default route\n"
7324 "Always advertise default route\n"
7325 "OSPF default metric\n"
7327 "OSPF metric type for default routes\n"
7328 "Set OSPF External Type 1/2 metrics\n"
7329 "Route map reference\n"
7330 "Pointer to route-map entries\n")
7332 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7333 struct prefix_ipv4 p
;
7334 struct ospf_external
*ext
;
7335 struct ospf_redist
*red
;
7338 p
.prefix
.s_addr
= 0;
7341 ospf_external_lsa_flush(ospf
, DEFAULT_ROUTE
, &p
, 0);
7343 if ((ext
= ospf_external_lookup(DEFAULT_ROUTE
, 0))
7344 && EXTERNAL_INFO(ext
)) {
7345 ospf_external_info_delete(DEFAULT_ROUTE
, 0, p
);
7346 ospf_external_del(DEFAULT_ROUTE
, 0);
7349 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
7353 ospf_routemap_unset(red
);
7354 return ospf_redistribute_default_unset(ospf
);
7357 DEFUN (ospf_default_metric
,
7358 ospf_default_metric_cmd
,
7359 "default-metric (0-16777214)",
7360 "Set metric of redistributed routes\n"
7363 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7367 if (!str2metric(argv
[idx_number
]->arg
, &metric
))
7368 return CMD_WARNING_CONFIG_FAILED
;
7370 ospf
->default_metric
= metric
;
7375 DEFUN (no_ospf_default_metric
,
7376 no_ospf_default_metric_cmd
,
7377 "no default-metric [(0-16777214)]",
7379 "Set metric of redistributed routes\n"
7382 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7384 ospf
->default_metric
= -1;
7390 DEFUN (ospf_distance
,
7393 "Administrative distance\n"
7394 "OSPF Administrative distance\n")
7396 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7399 ospf
->distance_all
= atoi(argv
[idx_number
]->arg
);
7404 DEFUN (no_ospf_distance
,
7405 no_ospf_distance_cmd
,
7406 "no distance (1-255)",
7408 "Administrative distance\n"
7409 "OSPF Administrative distance\n")
7411 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7413 ospf
->distance_all
= 0;
7418 DEFUN (no_ospf_distance_ospf
,
7419 no_ospf_distance_ospf_cmd
,
7420 "no distance ospf [{intra-area [(1-255)]|inter-area [(1-255)]|external [(1-255)]}]",
7422 "Administrative distance\n"
7423 "OSPF administrative distance\n"
7424 "Intra-area routes\n"
7425 "Distance for intra-area routes\n"
7426 "Inter-area routes\n"
7427 "Distance for inter-area routes\n"
7429 "Distance for external routes\n")
7431 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7437 if (argv_find(argv
, argc
, "intra-area", &idx
) || argc
== 3)
7438 idx
= ospf
->distance_intra
= 0;
7439 if (argv_find(argv
, argc
, "inter-area", &idx
) || argc
== 3)
7440 idx
= ospf
->distance_inter
= 0;
7441 if (argv_find(argv
, argc
, "external", &idx
) || argc
== 3)
7442 ospf
->distance_external
= 0;
7447 DEFUN (ospf_distance_ospf
,
7448 ospf_distance_ospf_cmd
,
7449 "distance ospf {intra-area (1-255)|inter-area (1-255)|external (1-255)}",
7450 "Administrative distance\n"
7451 "OSPF administrative distance\n"
7452 "Intra-area routes\n"
7453 "Distance for intra-area routes\n"
7454 "Inter-area routes\n"
7455 "Distance for inter-area routes\n"
7457 "Distance for external routes\n")
7459 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7462 if (argv_find(argv
, argc
, "intra-area", &idx
))
7463 ospf
->distance_intra
= atoi(argv
[idx
+ 1]->arg
);
7465 if (argv_find(argv
, argc
, "inter-area", &idx
))
7466 ospf
->distance_inter
= atoi(argv
[idx
+ 1]->arg
);
7468 if (argv_find(argv
, argc
, "external", &idx
))
7469 ospf
->distance_external
= atoi(argv
[idx
+ 1]->arg
);
7475 DEFUN (ospf_distance_source
,
7476 ospf_distance_source_cmd
,
7477 "distance (1-255) A.B.C.D/M",
7478 "Administrative distance\n"
7480 "IP source prefix\n")
7482 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7484 int idx_ipv4_prefixlen
= 2;
7489 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
7494 DEFUN (no_ospf_distance_source
,
7495 no_ospf_distance_source_cmd
,
7496 "no distance (1-255) A.B.C.D/M",
7498 "Administrative distance\n"
7500 "IP source prefix\n")
7502 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7504 int idx_ipv4_prefixlen
= 3;
7509 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
7514 DEFUN (ospf_distance_source_access_list
,
7515 ospf_distance_source_access_list_cmd
,
7516 "distance (1-255) A.B.C.D/M WORD",
7517 "Administrative distance\n"
7519 "IP source prefix\n"
7520 "Access list name\n")
7522 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7524 int idx_ipv4_prefixlen
= 2;
7530 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
7535 DEFUN (no_ospf_distance_source_access_list
,
7536 no_ospf_distance_source_access_list_cmd
,
7537 "no distance (1-255) A.B.C.D/M WORD",
7539 "Administrative distance\n"
7541 "IP source prefix\n"
7542 "Access list name\n")
7544 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7546 int idx_ipv4_prefixlen
= 3;
7552 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
7558 DEFUN (ip_ospf_mtu_ignore
,
7559 ip_ospf_mtu_ignore_addr_cmd
,
7560 "ip ospf mtu-ignore [A.B.C.D]",
7562 "OSPF interface commands\n"
7563 "Disable MTU mismatch detection on this interface\n"
7564 "Address of interface")
7566 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7568 struct in_addr addr
;
7571 struct ospf_if_params
*params
;
7572 params
= IF_DEF_PARAMS(ifp
);
7575 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7578 "Please specify interface address by A.B.C.D\n");
7579 return CMD_WARNING_CONFIG_FAILED
;
7581 params
= ospf_get_if_params(ifp
, addr
);
7582 ospf_if_update_params(ifp
, addr
);
7584 params
->mtu_ignore
= 1;
7585 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
7586 SET_IF_PARAM(params
, mtu_ignore
);
7588 UNSET_IF_PARAM(params
, mtu_ignore
);
7589 if (params
!= IF_DEF_PARAMS(ifp
)) {
7590 ospf_free_if_params(ifp
, addr
);
7591 ospf_if_update_params(ifp
, addr
);
7597 DEFUN (no_ip_ospf_mtu_ignore
,
7598 no_ip_ospf_mtu_ignore_addr_cmd
,
7599 "no ip ospf mtu-ignore [A.B.C.D]",
7601 "OSPF interface commands\n"
7602 "Disable MTU mismatch detection on this interface\n"
7603 "Address of interface")
7605 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7607 struct in_addr addr
;
7610 struct ospf_if_params
*params
;
7611 params
= IF_DEF_PARAMS(ifp
);
7614 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7617 "Please specify interface address by A.B.C.D\n");
7618 return CMD_WARNING_CONFIG_FAILED
;
7620 params
= ospf_get_if_params(ifp
, addr
);
7621 ospf_if_update_params(ifp
, addr
);
7623 params
->mtu_ignore
= 0;
7624 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
7625 SET_IF_PARAM(params
, mtu_ignore
);
7627 UNSET_IF_PARAM(params
, mtu_ignore
);
7628 if (params
!= IF_DEF_PARAMS(ifp
)) {
7629 ospf_free_if_params(ifp
, addr
);
7630 ospf_if_update_params(ifp
, addr
);
7637 DEFUN (ospf_max_metric_router_lsa_admin
,
7638 ospf_max_metric_router_lsa_admin_cmd
,
7639 "max-metric router-lsa administrative",
7640 "OSPF maximum / infinite-distance metric\n"
7641 "Advertise own Router-LSA with infinite distance (stub router)\n"
7642 "Administratively applied, for an indefinite period\n")
7644 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7645 struct listnode
*ln
;
7646 struct ospf_area
*area
;
7648 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
7649 SET_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
7651 if (!CHECK_FLAG(area
->stub_router_state
,
7652 OSPF_AREA_IS_STUB_ROUTED
))
7653 ospf_router_lsa_update_area(area
);
7656 /* Allows for areas configured later to get the property */
7657 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_SET
;
7662 DEFUN (no_ospf_max_metric_router_lsa_admin
,
7663 no_ospf_max_metric_router_lsa_admin_cmd
,
7664 "no max-metric router-lsa administrative",
7666 "OSPF maximum / infinite-distance metric\n"
7667 "Advertise own Router-LSA with infinite distance (stub router)\n"
7668 "Administratively applied, for an indefinite period\n")
7670 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7671 struct listnode
*ln
;
7672 struct ospf_area
*area
;
7674 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
7675 UNSET_FLAG(area
->stub_router_state
,
7676 OSPF_AREA_ADMIN_STUB_ROUTED
);
7678 /* Don't trample on the start-up stub timer */
7679 if (CHECK_FLAG(area
->stub_router_state
,
7680 OSPF_AREA_IS_STUB_ROUTED
)
7681 && !area
->t_stub_router
) {
7682 UNSET_FLAG(area
->stub_router_state
,
7683 OSPF_AREA_IS_STUB_ROUTED
);
7684 ospf_router_lsa_update_area(area
);
7687 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET
;
7691 DEFUN (ospf_max_metric_router_lsa_startup
,
7692 ospf_max_metric_router_lsa_startup_cmd
,
7693 "max-metric router-lsa on-startup (5-86400)",
7694 "OSPF maximum / infinite-distance metric\n"
7695 "Advertise own Router-LSA with infinite distance (stub router)\n"
7696 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7697 "Time (seconds) to advertise self as stub-router\n")
7699 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7701 unsigned int seconds
;
7704 vty_out(vty
, "%% Must supply stub-router period");
7705 return CMD_WARNING_CONFIG_FAILED
;
7708 seconds
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7710 ospf
->stub_router_startup_time
= seconds
;
7715 DEFUN (no_ospf_max_metric_router_lsa_startup
,
7716 no_ospf_max_metric_router_lsa_startup_cmd
,
7717 "no max-metric router-lsa on-startup [(5-86400)]",
7719 "OSPF maximum / infinite-distance metric\n"
7720 "Advertise own Router-LSA with infinite distance (stub router)\n"
7721 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7722 "Time (seconds) to advertise self as stub-router\n")
7724 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7725 struct listnode
*ln
;
7726 struct ospf_area
*area
;
7728 ospf
->stub_router_startup_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
7730 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
7731 SET_FLAG(area
->stub_router_state
,
7732 OSPF_AREA_WAS_START_STUB_ROUTED
);
7733 OSPF_TIMER_OFF(area
->t_stub_router
);
7735 /* Don't trample on admin stub routed */
7736 if (!CHECK_FLAG(area
->stub_router_state
,
7737 OSPF_AREA_ADMIN_STUB_ROUTED
)) {
7738 UNSET_FLAG(area
->stub_router_state
,
7739 OSPF_AREA_IS_STUB_ROUTED
);
7740 ospf_router_lsa_update_area(area
);
7747 DEFUN (ospf_max_metric_router_lsa_shutdown
,
7748 ospf_max_metric_router_lsa_shutdown_cmd
,
7749 "max-metric router-lsa on-shutdown (5-100)",
7750 "OSPF maximum / infinite-distance metric\n"
7751 "Advertise own Router-LSA with infinite distance (stub router)\n"
7752 "Advertise stub-router prior to full shutdown of OSPF\n"
7753 "Time (seconds) to wait till full shutdown\n")
7755 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7757 unsigned int seconds
;
7760 vty_out(vty
, "%% Must supply stub-router shutdown period");
7761 return CMD_WARNING_CONFIG_FAILED
;
7764 seconds
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7766 ospf
->stub_router_shutdown_time
= seconds
;
7771 DEFUN (no_ospf_max_metric_router_lsa_shutdown
,
7772 no_ospf_max_metric_router_lsa_shutdown_cmd
,
7773 "no max-metric router-lsa on-shutdown [(5-100)]",
7775 "OSPF maximum / infinite-distance metric\n"
7776 "Advertise own Router-LSA with infinite distance (stub router)\n"
7777 "Advertise stub-router prior to full shutdown of OSPF\n"
7778 "Time (seconds) to wait till full shutdown\n")
7780 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
7782 ospf
->stub_router_shutdown_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
7787 static void config_write_stub_router(struct vty
*vty
, struct ospf
*ospf
)
7789 struct listnode
*ln
;
7790 struct ospf_area
*area
;
7792 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
7793 vty_out(vty
, " max-metric router-lsa on-startup %u\n",
7794 ospf
->stub_router_startup_time
);
7795 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
7796 vty_out(vty
, " max-metric router-lsa on-shutdown %u\n",
7797 ospf
->stub_router_shutdown_time
);
7798 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, ln
, area
)) {
7799 if (CHECK_FLAG(area
->stub_router_state
,
7800 OSPF_AREA_ADMIN_STUB_ROUTED
)) {
7801 vty_out(vty
, " max-metric router-lsa administrative\n");
7808 static void show_ip_ospf_route_network(struct vty
*vty
, struct route_table
*rt
)
7810 struct route_node
*rn
;
7811 struct ospf_route
* or ;
7812 struct listnode
*pnode
, *pnnode
;
7813 struct ospf_path
*path
;
7815 vty_out(vty
, "============ OSPF network routing table ============\n");
7817 for (rn
= route_top(rt
); rn
; rn
= route_next(rn
))
7818 if ((or = rn
->info
) != NULL
) {
7820 snprintf(buf1
, 19, "%s/%d", inet_ntoa(rn
->p
.u
.prefix4
),
7823 switch (or->path_type
) {
7824 case OSPF_PATH_INTER_AREA
:
7825 if (or->type
== OSPF_DESTINATION_NETWORK
)
7827 "N IA %-18s [%d] area: %s\n",
7829 inet_ntoa(or->u
.std
.area_id
));
7830 else if (or->type
== OSPF_DESTINATION_DISCARD
)
7832 "D IA %-18s Discard entry\n",
7835 case OSPF_PATH_INTRA_AREA
:
7836 vty_out(vty
, "N %-18s [%d] area: %s\n",
7838 inet_ntoa(or->u
.std
.area_id
));
7844 if (or->type
== OSPF_DESTINATION_NETWORK
)
7845 for (ALL_LIST_ELEMENTS(or->paths
, pnode
, pnnode
,
7847 if (if_lookup_by_index(path
->ifindex
,
7849 if (path
->nexthop
.s_addr
== 0)
7851 "%24s directly attached to %s\n",
7858 "%24s via %s, %s\n",
7871 static void show_ip_ospf_route_router(struct vty
*vty
, struct route_table
*rtrs
)
7873 struct route_node
*rn
;
7874 struct ospf_route
* or ;
7875 struct listnode
*pnode
;
7876 struct listnode
*node
;
7877 struct ospf_path
*path
;
7879 vty_out(vty
, "============ OSPF router routing table =============\n");
7880 for (rn
= route_top(rtrs
); rn
; rn
= route_next(rn
))
7884 vty_out(vty
, "R %-15s ",
7885 inet_ntoa(rn
->p
.u
.prefix4
));
7887 for (ALL_LIST_ELEMENTS_RO((struct list
*)rn
->info
, node
,
7890 vty_out(vty
, "%24s", "");
7893 vty_out(vty
, "%s [%d] area: %s",
7894 (or->path_type
== OSPF_PATH_INTER_AREA
7897 or->cost
, inet_ntoa(or->u
.std
.area_id
));
7899 vty_out(vty
, "%s%s\n",
7900 (or->u
.std
.flags
& ROUTER_LSA_BORDER
7903 (or->u
.std
.flags
& ROUTER_LSA_EXTERNAL
7907 for (ALL_LIST_ELEMENTS_RO(or->paths
, pnode
,
7909 if (if_lookup_by_index(path
->ifindex
,
7911 if (path
->nexthop
.s_addr
== 0)
7913 "%24s directly attached to %s\n",
7920 "%24s via %s, %s\n",
7934 static void show_ip_ospf_route_external(struct vty
*vty
, struct route_table
*rt
)
7936 struct route_node
*rn
;
7937 struct ospf_route
*er
;
7938 struct listnode
*pnode
, *pnnode
;
7939 struct ospf_path
*path
;
7941 vty_out(vty
, "============ OSPF external routing table ===========\n");
7942 for (rn
= route_top(rt
); rn
; rn
= route_next(rn
))
7943 if ((er
= rn
->info
) != NULL
) {
7945 snprintf(buf1
, 19, "%s/%d", inet_ntoa(rn
->p
.u
.prefix4
),
7948 switch (er
->path_type
) {
7949 case OSPF_PATH_TYPE1_EXTERNAL
:
7951 "N E1 %-18s [%d] tag: %" ROUTE_TAG_PRI
7953 buf1
, er
->cost
, er
->u
.ext
.tag
);
7955 case OSPF_PATH_TYPE2_EXTERNAL
:
7957 "N E2 %-18s [%d/%d] tag: %" ROUTE_TAG_PRI
7959 buf1
, er
->cost
, er
->u
.ext
.type2_cost
,
7964 for (ALL_LIST_ELEMENTS(er
->paths
, pnode
, pnnode
,
7966 if (if_lookup_by_index(path
->ifindex
,
7968 if (path
->nexthop
.s_addr
== 0)
7970 "%24s directly attached to %s\n",
7977 "%24s via %s, %s\n",
7990 static int show_ip_ospf_border_routers_common(struct vty
*vty
,
7994 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
7996 if (ospf
->new_table
== NULL
) {
7997 vty_out(vty
, "No OSPF routing information exist\n");
8001 /* Show Network routes.
8002 show_ip_ospf_route_network (vty, ospf->new_table); */
8004 /* Show Router routes. */
8005 show_ip_ospf_route_router(vty
, ospf
->new_rtrs
);
8012 DEFUN (show_ip_ospf_border_routers
,
8013 show_ip_ospf_border_routers_cmd
,
8014 "show ip ospf border-routers",
8017 "OSPF information\n"
8018 "Show all the ABR's and ASBR's\n")
8022 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
8025 return show_ip_ospf_border_routers_common(vty
, ospf
);
8028 DEFUN (show_ip_ospf_instance_border_routers
,
8029 show_ip_ospf_instance_border_routers_cmd
,
8030 "show ip ospf (1-65535) border-routers",
8033 "OSPF information\n"
8035 "Show all the ABR's and ASBR's\n")
8039 u_short instance
= 0;
8041 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8042 ospf
= ospf_lookup_instance(instance
);
8044 return CMD_NOT_MY_INSTANCE
;
8046 if (!ospf
->oi_running
)
8049 return show_ip_ospf_border_routers_common(vty
, ospf
);
8052 static int show_ip_ospf_route_common(struct vty
*vty
, struct ospf
*ospf
)
8055 vty_out(vty
, "\nOSPF Instance: %d\n\n", ospf
->instance
);
8057 if (ospf
->new_table
== NULL
) {
8058 vty_out(vty
, "No OSPF routing information exist\n");
8062 /* Show Network routes. */
8063 show_ip_ospf_route_network(vty
, ospf
->new_table
);
8065 /* Show Router routes. */
8066 show_ip_ospf_route_router(vty
, ospf
->new_rtrs
);
8068 /* Show AS External routes. */
8069 show_ip_ospf_route_external(vty
, ospf
->old_external_route
);
8076 DEFUN (show_ip_ospf_route
,
8077 show_ip_ospf_route_cmd
,
8078 "show ip ospf route",
8081 "OSPF information\n"
8082 "OSPF routing table\n")
8086 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
8089 return show_ip_ospf_route_common(vty
, ospf
);
8092 DEFUN (show_ip_ospf_instance_route
,
8093 show_ip_ospf_instance_route_cmd
,
8094 "show ip ospf (1-65535) route",
8097 "OSPF information\n"
8099 "OSPF routing table\n")
8103 u_short instance
= 0;
8105 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
8106 ospf
= ospf_lookup_instance(instance
);
8108 return CMD_NOT_MY_INSTANCE
;
8110 if (!ospf
->oi_running
)
8113 return show_ip_ospf_route_common(vty
, ospf
);
8116 const char *ospf_abr_type_str
[] = {"unknown", "standard", "ibm", "cisco",
8119 const char *ospf_shortcut_mode_str
[] = {"default", "enable", "disable"};
8121 const char *ospf_int_type_str
[] = {"unknown", /* should never be used. */
8122 "point-to-point", "broadcast",
8123 "non-broadcast", "point-to-multipoint",
8124 "virtual-link", /* should never be used. */
8127 /* Configuration write function for ospfd. */
8128 static int config_write_interface(struct vty
*vty
)
8130 struct listnode
*n1
, *n2
;
8131 struct interface
*ifp
;
8132 struct crypt_key
*ck
;
8134 struct route_node
*rn
= NULL
;
8135 struct ospf_if_params
*params
;
8136 struct ospf
*ospf
= ospf_lookup();
8138 for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT
), n1
, ifp
)) {
8139 if (memcmp(ifp
->name
, "VLINK", 5) == 0)
8142 if (ifp
->ifindex
== IFINDEX_DELETED
)
8145 vty_out(vty
, "!\n");
8146 vty_out(vty
, "interface %s\n", ifp
->name
);
8148 vty_out(vty
, " description %s\n", ifp
->desc
);
8152 params
= IF_DEF_PARAMS(ifp
);
8155 /* Interface Network print. */
8156 if (OSPF_IF_PARAM_CONFIGURED(params
, type
)
8157 && params
->type
!= OSPF_IFTYPE_LOOPBACK
) {
8158 if (params
->type
!= ospf_default_iftype(ifp
)) {
8159 vty_out(vty
, " ip ospf network %s",
8162 if (params
!= IF_DEF_PARAMS(ifp
))
8170 /* OSPF interface authentication print */
8171 if (OSPF_IF_PARAM_CONFIGURED(params
, auth_type
)
8172 && params
->auth_type
!= OSPF_AUTH_NOTSET
) {
8173 const char *auth_str
;
8175 /* Translation tables are not that much help
8177 of the simple option */
8178 switch (params
->auth_type
) {
8180 case OSPF_AUTH_NULL
:
8184 case OSPF_AUTH_SIMPLE
:
8188 case OSPF_AUTH_CRYPTOGRAPHIC
:
8189 auth_str
= " message-digest";
8197 vty_out(vty
, " ip ospf authentication%s",
8199 if (params
!= IF_DEF_PARAMS(ifp
))
8201 inet_ntoa(rn
->p
.u
.prefix4
));
8205 /* Simple Authentication Password print. */
8206 if (OSPF_IF_PARAM_CONFIGURED(params
, auth_simple
)
8207 && params
->auth_simple
[0] != '\0') {
8208 vty_out(vty
, " ip ospf authentication-key %s",
8209 params
->auth_simple
);
8210 if (params
!= IF_DEF_PARAMS(ifp
))
8212 inet_ntoa(rn
->p
.u
.prefix4
));
8216 /* Cryptographic Authentication Key print. */
8217 for (ALL_LIST_ELEMENTS_RO(params
->auth_crypt
, n2
, ck
)) {
8219 " ip ospf message-digest-key %d md5 %s",
8220 ck
->key_id
, ck
->auth_key
);
8221 if (params
!= IF_DEF_PARAMS(ifp
))
8223 inet_ntoa(rn
->p
.u
.prefix4
));
8227 /* Interface Output Cost print. */
8228 if (OSPF_IF_PARAM_CONFIGURED(params
, output_cost_cmd
)) {
8229 vty_out(vty
, " ip ospf cost %u",
8230 params
->output_cost_cmd
);
8231 if (params
!= IF_DEF_PARAMS(ifp
))
8233 inet_ntoa(rn
->p
.u
.prefix4
));
8237 /* Hello Interval print. */
8238 if (OSPF_IF_PARAM_CONFIGURED(params
, v_hello
)
8239 && params
->v_hello
!= OSPF_HELLO_INTERVAL_DEFAULT
) {
8240 vty_out(vty
, " ip ospf hello-interval %u",
8242 if (params
!= IF_DEF_PARAMS(ifp
))
8244 inet_ntoa(rn
->p
.u
.prefix4
));
8249 /* Router Dead Interval print. */
8250 if (OSPF_IF_PARAM_CONFIGURED(params
, v_wait
)
8252 != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
) {
8253 vty_out(vty
, " ip ospf dead-interval ");
8256 if (OSPF_IF_PARAM_CONFIGURED(params
,
8259 "minimal hello-multiplier %d",
8260 params
->fast_hello
);
8262 vty_out(vty
, "%u", params
->v_wait
);
8264 if (params
!= IF_DEF_PARAMS(ifp
))
8266 inet_ntoa(rn
->p
.u
.prefix4
));
8270 /* Router Priority print. */
8271 if (OSPF_IF_PARAM_CONFIGURED(params
, priority
)
8273 != OSPF_ROUTER_PRIORITY_DEFAULT
) {
8274 vty_out(vty
, " ip ospf priority %u",
8276 if (params
!= IF_DEF_PARAMS(ifp
))
8278 inet_ntoa(rn
->p
.u
.prefix4
));
8282 /* Retransmit Interval print. */
8283 if (OSPF_IF_PARAM_CONFIGURED(params
,
8284 retransmit_interval
)
8285 && params
->retransmit_interval
8286 != OSPF_RETRANSMIT_INTERVAL_DEFAULT
) {
8287 vty_out(vty
, " ip ospf retransmit-interval %u",
8288 params
->retransmit_interval
);
8289 if (params
!= IF_DEF_PARAMS(ifp
))
8291 inet_ntoa(rn
->p
.u
.prefix4
));
8295 /* Transmit Delay print. */
8296 if (OSPF_IF_PARAM_CONFIGURED(params
, transmit_delay
)
8297 && params
->transmit_delay
8298 != OSPF_TRANSMIT_DELAY_DEFAULT
) {
8299 vty_out(vty
, " ip ospf transmit-delay %u",
8300 params
->transmit_delay
);
8301 if (params
!= IF_DEF_PARAMS(ifp
))
8303 inet_ntoa(rn
->p
.u
.prefix4
));
8308 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
)) {
8310 vty_out(vty
, " ip ospf %d",
8313 vty_out(vty
, " ip ospf");
8315 vty_out(vty
, " area %s",
8316 inet_ntoa(params
->if_area
));
8317 if (params
!= IF_DEF_PARAMS(ifp
))
8319 inet_ntoa(rn
->p
.u
.prefix4
));
8324 ospf_bfd_write_config(vty
, params
);
8326 /* MTU ignore print. */
8327 if (OSPF_IF_PARAM_CONFIGURED(params
, mtu_ignore
)
8328 && params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
) {
8329 if (params
->mtu_ignore
== 0)
8330 vty_out(vty
, " no ip ospf mtu-ignore");
8332 vty_out(vty
, " ip ospf mtu-ignore");
8333 if (params
!= IF_DEF_PARAMS(ifp
))
8335 inet_ntoa(rn
->p
.u
.prefix4
));
8342 rn
= route_top(IF_OIFS_PARAMS(ifp
));
8344 rn
= route_next(rn
);
8354 ospf_opaque_config_write_if(vty
, ifp
);
8360 static int config_write_network_area(struct vty
*vty
, struct ospf
*ospf
)
8362 struct route_node
*rn
;
8363 u_char buf
[INET_ADDRSTRLEN
];
8365 /* `network area' print. */
8366 for (rn
= route_top(ospf
->networks
); rn
; rn
= route_next(rn
))
8368 struct ospf_network
*n
= rn
->info
;
8370 memset(buf
, 0, INET_ADDRSTRLEN
);
8372 /* Create Area ID string by specified Area ID format. */
8373 if (n
->area_id_fmt
== OSPF_AREA_ID_FMT_DOTTEDQUAD
)
8374 strncpy((char *)buf
, inet_ntoa(n
->area_id
),
8377 sprintf((char *)buf
, "%lu",
8378 (unsigned long int)ntohl(
8379 n
->area_id
.s_addr
));
8381 /* Network print. */
8382 vty_out(vty
, " network %s/%d area %s\n",
8383 inet_ntoa(rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
8390 static int config_write_ospf_area(struct vty
*vty
, struct ospf
*ospf
)
8392 struct listnode
*node
;
8393 struct ospf_area
*area
;
8394 u_char buf
[INET_ADDRSTRLEN
];
8396 /* Area configuration print. */
8397 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
8398 struct route_node
*rn1
;
8400 area_id2str((char *)buf
, INET_ADDRSTRLEN
, &area
->area_id
,
8403 if (area
->auth_type
!= OSPF_AUTH_NULL
) {
8404 if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
8405 vty_out(vty
, " area %s authentication\n", buf
);
8408 " area %s authentication message-digest\n",
8412 if (area
->shortcut_configured
!= OSPF_SHORTCUT_DEFAULT
)
8413 vty_out(vty
, " area %s shortcut %s\n", buf
,
8414 ospf_shortcut_mode_str
8415 [area
->shortcut_configured
]);
8417 if ((area
->external_routing
== OSPF_AREA_STUB
)
8418 || (area
->external_routing
== OSPF_AREA_NSSA
)) {
8419 if (area
->external_routing
== OSPF_AREA_STUB
)
8420 vty_out(vty
, " area %s stub", buf
);
8421 else if (area
->external_routing
== OSPF_AREA_NSSA
) {
8422 vty_out(vty
, " area %s nssa", buf
);
8423 switch (area
->NSSATranslatorRole
) {
8424 case OSPF_NSSA_ROLE_NEVER
:
8425 vty_out(vty
, " translate-never");
8427 case OSPF_NSSA_ROLE_ALWAYS
:
8428 vty_out(vty
, " translate-always");
8430 case OSPF_NSSA_ROLE_CANDIDATE
:
8432 vty_out(vty
, " translate-candidate");
8436 if (area
->no_summary
)
8437 vty_out(vty
, " no-summary");
8441 if (area
->default_cost
!= 1)
8442 vty_out(vty
, " area %s default-cost %d\n", buf
,
8443 area
->default_cost
);
8446 for (rn1
= route_top(area
->ranges
); rn1
; rn1
= route_next(rn1
))
8448 struct ospf_area_range
*range
= rn1
->info
;
8450 vty_out(vty
, " area %s range %s/%d", buf
,
8451 inet_ntoa(rn1
->p
.u
.prefix4
),
8454 if (range
->cost_config
8455 != OSPF_AREA_RANGE_COST_UNSPEC
)
8456 vty_out(vty
, " cost %d",
8457 range
->cost_config
);
8459 if (!CHECK_FLAG(range
->flags
,
8460 OSPF_AREA_RANGE_ADVERTISE
))
8461 vty_out(vty
, " not-advertise");
8463 if (CHECK_FLAG(range
->flags
,
8464 OSPF_AREA_RANGE_SUBSTITUTE
))
8465 vty_out(vty
, " substitute %s/%d",
8466 inet_ntoa(range
->subst_addr
),
8467 range
->subst_masklen
);
8472 if (EXPORT_NAME(area
))
8473 vty_out(vty
, " area %s export-list %s\n", buf
,
8476 if (IMPORT_NAME(area
))
8477 vty_out(vty
, " area %s import-list %s\n", buf
,
8480 if (PREFIX_NAME_IN(area
))
8481 vty_out(vty
, " area %s filter-list prefix %s in\n", buf
,
8482 PREFIX_NAME_IN(area
));
8484 if (PREFIX_NAME_OUT(area
))
8485 vty_out(vty
, " area %s filter-list prefix %s out\n",
8486 buf
, PREFIX_NAME_OUT(area
));
8492 static int config_write_ospf_nbr_nbma(struct vty
*vty
, struct ospf
*ospf
)
8494 struct ospf_nbr_nbma
*nbr_nbma
;
8495 struct route_node
*rn
;
8497 /* Static Neighbor configuration print. */
8498 for (rn
= route_top(ospf
->nbr_nbma
); rn
; rn
= route_next(rn
))
8499 if ((nbr_nbma
= rn
->info
)) {
8500 vty_out(vty
, " neighbor %s", inet_ntoa(nbr_nbma
->addr
));
8502 if (nbr_nbma
->priority
8503 != OSPF_NEIGHBOR_PRIORITY_DEFAULT
)
8504 vty_out(vty
, " priority %d",
8505 nbr_nbma
->priority
);
8507 if (nbr_nbma
->v_poll
!= OSPF_POLL_INTERVAL_DEFAULT
)
8508 vty_out(vty
, " poll-interval %d",
8517 static int config_write_virtual_link(struct vty
*vty
, struct ospf
*ospf
)
8519 struct listnode
*node
;
8520 struct ospf_vl_data
*vl_data
;
8521 char buf
[INET_ADDRSTRLEN
];
8523 /* Virtual-Link print */
8524 for (ALL_LIST_ELEMENTS_RO(ospf
->vlinks
, node
, vl_data
)) {
8525 struct listnode
*n2
;
8526 struct crypt_key
*ck
;
8527 struct ospf_interface
*oi
;
8529 if (vl_data
!= NULL
) {
8530 memset(buf
, 0, INET_ADDRSTRLEN
);
8532 area_id2str(buf
, sizeof(buf
), &vl_data
->vl_area_id
,
8533 vl_data
->vl_area_id_fmt
);
8534 oi
= vl_data
->vl_oi
;
8537 if (OSPF_IF_PARAM(oi
, v_hello
)
8538 != OSPF_HELLO_INTERVAL_DEFAULT
8539 || OSPF_IF_PARAM(oi
, v_wait
)
8540 != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
8541 || OSPF_IF_PARAM(oi
, retransmit_interval
)
8542 != OSPF_RETRANSMIT_INTERVAL_DEFAULT
8543 || OSPF_IF_PARAM(oi
, transmit_delay
)
8544 != OSPF_TRANSMIT_DELAY_DEFAULT
)
8546 " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d\n",
8547 buf
, inet_ntoa(vl_data
->vl_peer
),
8548 OSPF_IF_PARAM(oi
, v_hello
),
8549 OSPF_IF_PARAM(oi
, retransmit_interval
),
8550 OSPF_IF_PARAM(oi
, transmit_delay
),
8551 OSPF_IF_PARAM(oi
, v_wait
));
8553 vty_out(vty
, " area %s virtual-link %s\n", buf
,
8554 inet_ntoa(vl_data
->vl_peer
));
8556 if (IF_DEF_PARAMS(vl_data
->vl_oi
->ifp
)->auth_simple
[0]
8559 " area %s virtual-link %s authentication-key %s\n",
8560 buf
, inet_ntoa(vl_data
->vl_peer
),
8561 IF_DEF_PARAMS(vl_data
->vl_oi
->ifp
)
8564 for (ALL_LIST_ELEMENTS_RO(
8565 IF_DEF_PARAMS(vl_data
->vl_oi
->ifp
)
8569 " area %s virtual-link %s"
8570 " message-digest-key %d md5 %s\n",
8571 buf
, inet_ntoa(vl_data
->vl_peer
),
8572 ck
->key_id
, ck
->auth_key
);
8580 static int config_write_ospf_redistribute(struct vty
*vty
, struct ospf
*ospf
)
8584 /* redistribute print. */
8585 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++) {
8586 struct list
*red_list
;
8587 struct listnode
*node
;
8588 struct ospf_redist
*red
;
8590 red_list
= ospf
->redist
[type
];
8594 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
8595 vty_out(vty
, " redistribute %s",
8596 zebra_route_string(type
));
8598 vty_out(vty
, " %d", red
->instance
);
8600 if (red
->dmetric
.value
>= 0)
8601 vty_out(vty
, " metric %d", red
->dmetric
.value
);
8603 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
8604 vty_out(vty
, " metric-type 1");
8606 if (ROUTEMAP_NAME(red
))
8607 vty_out(vty
, " route-map %s",
8608 ROUTEMAP_NAME(red
));
8617 static int config_write_ospf_default_metric(struct vty
*vty
, struct ospf
*ospf
)
8619 if (ospf
->default_metric
!= -1)
8620 vty_out(vty
, " default-metric %d\n", ospf
->default_metric
);
8624 static int config_write_ospf_distribute(struct vty
*vty
, struct ospf
*ospf
)
8627 struct ospf_redist
*red
;
8630 /* distribute-list print. */
8631 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
8632 if (DISTRIBUTE_NAME(ospf
, type
))
8633 vty_out(vty
, " distribute-list %s out %s\n",
8634 DISTRIBUTE_NAME(ospf
, type
),
8635 zebra_route_string(type
));
8637 /* default-information print. */
8638 if (ospf
->default_originate
!= DEFAULT_ORIGINATE_NONE
) {
8639 vty_out(vty
, " default-information originate");
8640 if (ospf
->default_originate
== DEFAULT_ORIGINATE_ALWAYS
)
8641 vty_out(vty
, " always");
8643 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
8645 if (red
->dmetric
.value
>= 0)
8646 vty_out(vty
, " metric %d",
8647 red
->dmetric
.value
);
8648 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
8649 vty_out(vty
, " metric-type 1");
8651 if (ROUTEMAP_NAME(red
))
8652 vty_out(vty
, " route-map %s",
8653 ROUTEMAP_NAME(red
));
8663 static int config_write_ospf_distance(struct vty
*vty
, struct ospf
*ospf
)
8665 struct route_node
*rn
;
8666 struct ospf_distance
*odistance
;
8668 if (ospf
->distance_all
)
8669 vty_out(vty
, " distance %d\n", ospf
->distance_all
);
8671 if (ospf
->distance_intra
|| ospf
->distance_inter
8672 || ospf
->distance_external
) {
8673 vty_out(vty
, " distance ospf");
8675 if (ospf
->distance_intra
)
8676 vty_out(vty
, " intra-area %d", ospf
->distance_intra
);
8677 if (ospf
->distance_inter
)
8678 vty_out(vty
, " inter-area %d", ospf
->distance_inter
);
8679 if (ospf
->distance_external
)
8680 vty_out(vty
, " external %d", ospf
->distance_external
);
8685 for (rn
= route_top(ospf
->distance_table
); rn
; rn
= route_next(rn
))
8686 if ((odistance
= rn
->info
) != NULL
) {
8687 vty_out(vty
, " distance %d %s/%d %s\n",
8688 odistance
->distance
, inet_ntoa(rn
->p
.u
.prefix4
),
8690 odistance
->access_list
? odistance
->access_list
8696 /* OSPF configuration write function. */
8697 static int ospf_config_write(struct vty
*vty
)
8700 struct interface
*ifp
;
8701 struct ospf_interface
*oi
;
8702 struct listnode
*node
;
8705 ospf
= ospf_lookup();
8706 if (ospf
!= NULL
&& ospf
->oi_running
) {
8707 /* `router ospf' print. */
8709 vty_out(vty
, "router ospf %d\n", ospf
->instance
);
8711 vty_out(vty
, "router ospf\n");
8715 if (!ospf
->networks
)
8718 /* Router ID print. */
8719 if (ospf
->router_id_static
.s_addr
!= 0)
8720 vty_out(vty
, " ospf router-id %s\n",
8721 inet_ntoa(ospf
->router_id_static
));
8723 /* ABR type print. */
8724 if (ospf
->abr_type
!= OSPF_ABR_DEFAULT
)
8725 vty_out(vty
, " ospf abr-type %s\n",
8726 ospf_abr_type_str
[ospf
->abr_type
]);
8728 /* log-adjacency-changes flag print. */
8729 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
)) {
8730 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
8731 vty_out(vty
, " log-adjacency-changes detail\n");
8732 else if (!DFLT_OSPF_LOG_ADJACENCY_CHANGES
)
8733 vty_out(vty
, " log-adjacency-changes\n");
8734 } else if (DFLT_OSPF_LOG_ADJACENCY_CHANGES
) {
8735 vty_out(vty
, " no log-adjacency-changes\n");
8738 /* RFC1583 compatibility flag print -- Compatible with CISCO
8740 if (CHECK_FLAG(ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
8741 vty_out(vty
, " compatible rfc1583\n");
8743 /* auto-cost reference-bandwidth configuration. */
8744 if (ospf
->ref_bandwidth
!= OSPF_DEFAULT_REF_BANDWIDTH
) {
8746 "! Important: ensure reference bandwidth "
8747 "is consistent across all routers\n");
8748 vty_out(vty
, " auto-cost reference-bandwidth %d\n",
8749 ospf
->ref_bandwidth
);
8752 /* SPF timers print. */
8753 if (ospf
->spf_delay
!= OSPF_SPF_DELAY_DEFAULT
8754 || ospf
->spf_holdtime
!= OSPF_SPF_HOLDTIME_DEFAULT
8755 || ospf
->spf_max_holdtime
!= OSPF_SPF_MAX_HOLDTIME_DEFAULT
)
8756 vty_out(vty
, " timers throttle spf %d %d %d\n",
8757 ospf
->spf_delay
, ospf
->spf_holdtime
,
8758 ospf
->spf_max_holdtime
);
8760 /* LSA timers print. */
8761 if (ospf
->min_ls_interval
!= OSPF_MIN_LS_INTERVAL
)
8762 vty_out(vty
, " timers throttle lsa all %d\n",
8763 ospf
->min_ls_interval
);
8764 if (ospf
->min_ls_arrival
!= OSPF_MIN_LS_ARRIVAL
)
8765 vty_out(vty
, " timers lsa min-arrival %d\n",
8766 ospf
->min_ls_arrival
);
8768 /* Write multiplier print. */
8769 if (ospf
->write_oi_count
!= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
)
8770 vty_out(vty
, " ospf write-multiplier %d\n",
8771 ospf
->write_oi_count
);
8773 /* Max-metric router-lsa print */
8774 config_write_stub_router(vty
, ospf
);
8776 /* SPF refresh parameters print. */
8777 if (ospf
->lsa_refresh_interval
8778 != OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
8779 vty_out(vty
, " refresh timer %d\n",
8780 ospf
->lsa_refresh_interval
);
8782 /* Redistribute information print. */
8783 config_write_ospf_redistribute(vty
, ospf
);
8785 /* passive-interface print. */
8786 if (ospf
->passive_interface_default
== OSPF_IF_PASSIVE
)
8787 vty_out(vty
, " passive-interface default\n");
8789 for (ALL_LIST_ELEMENTS_RO(om
->iflist
, node
, ifp
))
8790 if (OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp
),
8792 && IF_DEF_PARAMS(ifp
)->passive_interface
8793 != ospf
->passive_interface_default
) {
8794 vty_out(vty
, " %spassive-interface %s\n",
8795 IF_DEF_PARAMS(ifp
)->passive_interface
8800 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, node
, oi
)) {
8801 if (!OSPF_IF_PARAM_CONFIGURED(oi
->params
,
8804 if (OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(oi
->ifp
),
8805 passive_interface
)) {
8806 if (oi
->params
->passive_interface
8807 == IF_DEF_PARAMS(oi
->ifp
)
8808 ->passive_interface
)
8810 } else if (oi
->params
->passive_interface
8811 == ospf
->passive_interface_default
)
8814 vty_out(vty
, " %spassive-interface %s %s\n",
8815 oi
->params
->passive_interface
? "" : "no ",
8817 inet_ntoa(oi
->address
->u
.prefix4
));
8820 /* Network area print. */
8821 config_write_network_area(vty
, ospf
);
8823 /* Area config print. */
8824 config_write_ospf_area(vty
, ospf
);
8826 /* static neighbor print. */
8827 config_write_ospf_nbr_nbma(vty
, ospf
);
8829 /* Virtual-Link print. */
8830 config_write_virtual_link(vty
, ospf
);
8832 /* Default metric configuration. */
8833 config_write_ospf_default_metric(vty
, ospf
);
8835 /* Distribute-list and default-information print. */
8836 config_write_ospf_distribute(vty
, ospf
);
8838 /* Distance configuration. */
8839 config_write_ospf_distance(vty
, ospf
);
8841 ospf_opaque_config_write_router(vty
, ospf
);
8847 void ospf_vty_show_init(void)
8849 /* "show ip ospf" commands. */
8850 install_element(VIEW_NODE
, &show_ip_ospf_cmd
);
8852 install_element(VIEW_NODE
, &show_ip_ospf_instance_cmd
);
8854 /* "show ip ospf database" commands. */
8855 install_element(VIEW_NODE
, &show_ip_ospf_database_max_cmd
);
8857 install_element(VIEW_NODE
,
8858 &show_ip_ospf_instance_database_type_adv_router_cmd
);
8859 install_element(VIEW_NODE
, &show_ip_ospf_instance_database_cmd
);
8860 install_element(VIEW_NODE
, &show_ip_ospf_instance_database_max_cmd
);
8862 /* "show ip ospf interface" commands. */
8863 install_element(VIEW_NODE
, &show_ip_ospf_interface_cmd
);
8865 install_element(VIEW_NODE
, &show_ip_ospf_instance_interface_cmd
);
8867 /* "show ip ospf neighbor" commands. */
8868 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_int_detail_cmd
);
8869 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_int_cmd
);
8870 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_id_cmd
);
8871 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_detail_all_cmd
);
8872 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_detail_cmd
);
8873 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_cmd
);
8874 install_element(VIEW_NODE
, &show_ip_ospf_neighbor_all_cmd
);
8876 install_element(VIEW_NODE
,
8877 &show_ip_ospf_instance_neighbor_int_detail_cmd
);
8878 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_cmd
);
8879 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_id_cmd
);
8880 install_element(VIEW_NODE
,
8881 &show_ip_ospf_instance_neighbor_detail_all_cmd
);
8882 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_cmd
);
8883 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_cmd
);
8884 install_element(VIEW_NODE
, &show_ip_ospf_instance_neighbor_all_cmd
);
8886 /* "show ip ospf route" commands. */
8887 install_element(VIEW_NODE
, &show_ip_ospf_route_cmd
);
8888 install_element(VIEW_NODE
, &show_ip_ospf_border_routers_cmd
);
8890 install_element(VIEW_NODE
, &show_ip_ospf_instance_route_cmd
);
8891 install_element(VIEW_NODE
, &show_ip_ospf_instance_border_routers_cmd
);
8895 /* ospfd's interface node. */
8896 static struct cmd_node interface_node
= {INTERFACE_NODE
, "%s(config-if)# ", 1};
8898 /* Initialization of OSPF interface. */
8899 static void ospf_vty_if_init(void)
8901 /* Install interface node. */
8902 install_node(&interface_node
, config_write_interface
);
8905 /* "ip ospf authentication" commands. */
8906 install_element(INTERFACE_NODE
, &ip_ospf_authentication_args_addr_cmd
);
8907 install_element(INTERFACE_NODE
, &ip_ospf_authentication_addr_cmd
);
8908 install_element(INTERFACE_NODE
,
8909 &no_ip_ospf_authentication_args_addr_cmd
);
8910 install_element(INTERFACE_NODE
, &no_ip_ospf_authentication_addr_cmd
);
8911 install_element(INTERFACE_NODE
, &ip_ospf_authentication_key_addr_cmd
);
8912 install_element(INTERFACE_NODE
,
8913 &no_ip_ospf_authentication_key_authkey_addr_cmd
);
8914 install_element(INTERFACE_NODE
,
8915 &no_ospf_authentication_key_authkey_addr_cmd
);
8917 /* "ip ospf message-digest-key" commands. */
8918 install_element(INTERFACE_NODE
, &ip_ospf_message_digest_key_cmd
);
8919 install_element(INTERFACE_NODE
, &no_ip_ospf_message_digest_key_cmd
);
8921 /* "ip ospf cost" commands. */
8922 install_element(INTERFACE_NODE
, &ip_ospf_cost_cmd
);
8923 install_element(INTERFACE_NODE
, &no_ip_ospf_cost_cmd
);
8925 /* "ip ospf mtu-ignore" commands. */
8926 install_element(INTERFACE_NODE
, &ip_ospf_mtu_ignore_addr_cmd
);
8927 install_element(INTERFACE_NODE
, &no_ip_ospf_mtu_ignore_addr_cmd
);
8929 /* "ip ospf dead-interval" commands. */
8930 install_element(INTERFACE_NODE
, &ip_ospf_dead_interval_cmd
);
8931 install_element(INTERFACE_NODE
,
8932 &ip_ospf_dead_interval_minimal_addr_cmd
);
8933 install_element(INTERFACE_NODE
, &no_ip_ospf_dead_interval_cmd
);
8935 /* "ip ospf hello-interval" commands. */
8936 install_element(INTERFACE_NODE
, &ip_ospf_hello_interval_cmd
);
8937 install_element(INTERFACE_NODE
, &no_ip_ospf_hello_interval_cmd
);
8939 /* "ip ospf network" commands. */
8940 install_element(INTERFACE_NODE
, &ip_ospf_network_cmd
);
8941 install_element(INTERFACE_NODE
, &no_ip_ospf_network_cmd
);
8943 /* "ip ospf priority" commands. */
8944 install_element(INTERFACE_NODE
, &ip_ospf_priority_cmd
);
8945 install_element(INTERFACE_NODE
, &no_ip_ospf_priority_cmd
);
8947 /* "ip ospf retransmit-interval" commands. */
8948 install_element(INTERFACE_NODE
, &ip_ospf_retransmit_interval_addr_cmd
);
8949 install_element(INTERFACE_NODE
,
8950 &no_ip_ospf_retransmit_interval_addr_cmd
);
8952 /* "ip ospf transmit-delay" commands. */
8953 install_element(INTERFACE_NODE
, &ip_ospf_transmit_delay_addr_cmd
);
8954 install_element(INTERFACE_NODE
, &no_ip_ospf_transmit_delay_addr_cmd
);
8956 /* "ip ospf area" commands. */
8957 install_element(INTERFACE_NODE
, &ip_ospf_area_cmd
);
8958 install_element(INTERFACE_NODE
, &no_ip_ospf_area_cmd
);
8960 /* These commands are compatibitliy for previous version. */
8961 install_element(INTERFACE_NODE
, &ospf_authentication_key_cmd
);
8962 install_element(INTERFACE_NODE
, &ospf_message_digest_key_cmd
);
8963 install_element(INTERFACE_NODE
, &no_ospf_message_digest_key_cmd
);
8964 install_element(INTERFACE_NODE
, &ospf_dead_interval_cmd
);
8965 install_element(INTERFACE_NODE
, &no_ospf_dead_interval_cmd
);
8966 install_element(INTERFACE_NODE
, &ospf_hello_interval_cmd
);
8967 install_element(INTERFACE_NODE
, &no_ospf_hello_interval_cmd
);
8968 install_element(INTERFACE_NODE
, &ospf_cost_cmd
);
8969 install_element(INTERFACE_NODE
, &no_ospf_cost_cmd
);
8970 install_element(INTERFACE_NODE
, &ospf_network_cmd
);
8971 install_element(INTERFACE_NODE
, &no_ospf_network_cmd
);
8972 install_element(INTERFACE_NODE
, &ospf_priority_cmd
);
8973 install_element(INTERFACE_NODE
, &no_ospf_priority_cmd
);
8974 install_element(INTERFACE_NODE
, &ospf_retransmit_interval_cmd
);
8975 install_element(INTERFACE_NODE
, &no_ospf_retransmit_interval_cmd
);
8976 install_element(INTERFACE_NODE
, &ospf_transmit_delay_cmd
);
8977 install_element(INTERFACE_NODE
, &no_ospf_transmit_delay_cmd
);
8980 static void ospf_vty_zebra_init(void)
8982 install_element(OSPF_NODE
, &ospf_redistribute_source_cmd
);
8983 install_element(OSPF_NODE
, &no_ospf_redistribute_source_cmd
);
8984 install_element(OSPF_NODE
, &ospf_redistribute_instance_source_cmd
);
8985 install_element(OSPF_NODE
, &no_ospf_redistribute_instance_source_cmd
);
8987 install_element(OSPF_NODE
, &ospf_distribute_list_out_cmd
);
8988 install_element(OSPF_NODE
, &no_ospf_distribute_list_out_cmd
);
8990 install_element(OSPF_NODE
, &ospf_default_information_originate_cmd
);
8991 install_element(OSPF_NODE
, &no_ospf_default_information_originate_cmd
);
8993 install_element(OSPF_NODE
, &ospf_default_metric_cmd
);
8994 install_element(OSPF_NODE
, &no_ospf_default_metric_cmd
);
8996 install_element(OSPF_NODE
, &ospf_distance_cmd
);
8997 install_element(OSPF_NODE
, &no_ospf_distance_cmd
);
8998 install_element(OSPF_NODE
, &no_ospf_distance_ospf_cmd
);
8999 install_element(OSPF_NODE
, &ospf_distance_ospf_cmd
);
9001 install_element (OSPF_NODE
, &ospf_distance_source_cmd
);
9002 install_element (OSPF_NODE
, &no_ospf_distance_source_cmd
);
9003 install_element (OSPF_NODE
, &ospf_distance_source_access_list_cmd
);
9004 install_element (OSPF_NODE
, &no_ospf_distance_source_access_list_cmd
);
9008 static struct cmd_node ospf_node
= {OSPF_NODE
, "%s(config-router)# ", 1};
9010 static void ospf_interface_clear(struct interface
*ifp
)
9012 if (!if_is_operative(ifp
))
9015 if (IS_DEBUG_OSPF(ism
, ISM_EVENTS
))
9016 zlog_debug("ISM[%s]: clear by reset", ifp
->name
);
9021 DEFUN (clear_ip_ospf_interface
,
9022 clear_ip_ospf_interface_cmd
,
9023 "clear ip ospf interface [IFNAME]",
9026 "OSPF information\n"
9027 "Interface information\n"
9031 struct interface
*ifp
;
9032 struct listnode
*node
;
9034 if (argc
== 4) /* Clear all the ospfv2 interfaces. */
9036 for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT
), node
, ifp
))
9037 ospf_interface_clear(ifp
);
9038 } else /* Interface name is specified. */
9040 if ((ifp
= if_lookup_by_name(argv
[idx_ifname
]->arg
,
9043 vty_out(vty
, "No such interface name\n");
9045 ospf_interface_clear(ifp
);
9051 void ospf_vty_clear_init(void)
9053 install_element(ENABLE_NODE
, &clear_ip_ospf_interface_cmd
);
9057 /* Install OSPF related vty commands. */
9058 void ospf_vty_init(void)
9060 /* Install ospf top node. */
9061 install_node(&ospf_node
, ospf_config_write
);
9063 /* "router ospf" commands. */
9064 install_element(CONFIG_NODE
, &router_ospf_cmd
);
9065 install_element(CONFIG_NODE
, &no_router_ospf_cmd
);
9068 install_default(OSPF_NODE
);
9070 /* "ospf router-id" commands. */
9071 install_element(OSPF_NODE
, &ospf_router_id_cmd
);
9072 install_element(OSPF_NODE
, &ospf_router_id_old_cmd
);
9073 install_element(OSPF_NODE
, &no_ospf_router_id_cmd
);
9075 /* "passive-interface" commands. */
9076 install_element(OSPF_NODE
, &ospf_passive_interface_addr_cmd
);
9077 install_element(OSPF_NODE
, &no_ospf_passive_interface_addr_cmd
);
9079 /* "ospf abr-type" commands. */
9080 install_element(OSPF_NODE
, &ospf_abr_type_cmd
);
9081 install_element(OSPF_NODE
, &no_ospf_abr_type_cmd
);
9083 /* "ospf log-adjacency-changes" commands. */
9084 install_element(OSPF_NODE
, &ospf_log_adjacency_changes_cmd
);
9085 install_element(OSPF_NODE
, &ospf_log_adjacency_changes_detail_cmd
);
9086 install_element(OSPF_NODE
, &no_ospf_log_adjacency_changes_cmd
);
9087 install_element(OSPF_NODE
, &no_ospf_log_adjacency_changes_detail_cmd
);
9089 /* "ospf rfc1583-compatible" commands. */
9090 install_element(OSPF_NODE
, &ospf_compatible_rfc1583_cmd
);
9091 install_element(OSPF_NODE
, &no_ospf_compatible_rfc1583_cmd
);
9092 install_element(OSPF_NODE
, &ospf_rfc1583_flag_cmd
);
9093 install_element(OSPF_NODE
, &no_ospf_rfc1583_flag_cmd
);
9095 /* "network area" commands. */
9096 install_element(OSPF_NODE
, &ospf_network_area_cmd
);
9097 install_element(OSPF_NODE
, &no_ospf_network_area_cmd
);
9099 /* "area authentication" commands. */
9100 install_element(OSPF_NODE
,
9101 &ospf_area_authentication_message_digest_cmd
);
9102 install_element(OSPF_NODE
, &ospf_area_authentication_cmd
);
9103 install_element(OSPF_NODE
, &no_ospf_area_authentication_cmd
);
9105 /* "area range" commands. */
9106 install_element(OSPF_NODE
, &ospf_area_range_cmd
);
9107 install_element(OSPF_NODE
, &ospf_area_range_cost_cmd
);
9108 install_element(OSPF_NODE
, &ospf_area_range_not_advertise_cmd
);
9109 install_element(OSPF_NODE
, &no_ospf_area_range_cmd
);
9110 install_element(OSPF_NODE
, &ospf_area_range_substitute_cmd
);
9111 install_element(OSPF_NODE
, &no_ospf_area_range_substitute_cmd
);
9113 /* "area virtual-link" commands. */
9114 install_element(OSPF_NODE
, &ospf_area_vlink_cmd
);
9115 install_element(OSPF_NODE
, &ospf_area_vlink_intervals_cmd
);
9116 install_element(OSPF_NODE
, &no_ospf_area_vlink_cmd
);
9117 install_element(OSPF_NODE
, &no_ospf_area_vlink_intervals_cmd
);
9120 /* "area stub" commands. */
9121 install_element(OSPF_NODE
, &ospf_area_stub_no_summary_cmd
);
9122 install_element(OSPF_NODE
, &ospf_area_stub_cmd
);
9123 install_element(OSPF_NODE
, &no_ospf_area_stub_no_summary_cmd
);
9124 install_element(OSPF_NODE
, &no_ospf_area_stub_cmd
);
9126 /* "area nssa" commands. */
9127 install_element(OSPF_NODE
, &ospf_area_nssa_cmd
);
9128 install_element(OSPF_NODE
, &ospf_area_nssa_translate_no_summary_cmd
);
9129 install_element(OSPF_NODE
, &ospf_area_nssa_translate_cmd
);
9130 install_element(OSPF_NODE
, &ospf_area_nssa_no_summary_cmd
);
9131 install_element(OSPF_NODE
, &no_ospf_area_nssa_cmd
);
9133 install_element(OSPF_NODE
, &ospf_area_default_cost_cmd
);
9134 install_element(OSPF_NODE
, &no_ospf_area_default_cost_cmd
);
9136 install_element(OSPF_NODE
, &ospf_area_shortcut_cmd
);
9137 install_element(OSPF_NODE
, &no_ospf_area_shortcut_cmd
);
9139 install_element(OSPF_NODE
, &ospf_area_export_list_cmd
);
9140 install_element(OSPF_NODE
, &no_ospf_area_export_list_cmd
);
9142 install_element(OSPF_NODE
, &ospf_area_filter_list_cmd
);
9143 install_element(OSPF_NODE
, &no_ospf_area_filter_list_cmd
);
9145 install_element(OSPF_NODE
, &ospf_area_import_list_cmd
);
9146 install_element(OSPF_NODE
, &no_ospf_area_import_list_cmd
);
9148 /* SPF timer commands */
9149 install_element(OSPF_NODE
, &ospf_timers_throttle_spf_cmd
);
9150 install_element(OSPF_NODE
, &no_ospf_timers_throttle_spf_cmd
);
9152 /* LSA timers commands */
9153 install_element(OSPF_NODE
, &ospf_timers_min_ls_interval_cmd
);
9154 install_element(OSPF_NODE
, &no_ospf_timers_min_ls_interval_cmd
);
9155 install_element(OSPF_NODE
, &ospf_timers_lsa_min_arrival_cmd
);
9156 install_element(OSPF_NODE
, &no_ospf_timers_lsa_min_arrival_cmd
);
9157 install_element(OSPF_NODE
, &ospf_timers_lsa_arrival_cmd
);
9158 install_element(OSPF_NODE
, &no_ospf_timers_lsa_arrival_cmd
);
9160 /* refresh timer commands */
9161 install_element(OSPF_NODE
, &ospf_refresh_timer_cmd
);
9162 install_element(OSPF_NODE
, &no_ospf_refresh_timer_val_cmd
);
9164 /* max-metric commands */
9165 install_element(OSPF_NODE
, &ospf_max_metric_router_lsa_admin_cmd
);
9166 install_element(OSPF_NODE
, &no_ospf_max_metric_router_lsa_admin_cmd
);
9167 install_element(OSPF_NODE
, &ospf_max_metric_router_lsa_startup_cmd
);
9168 install_element(OSPF_NODE
, &no_ospf_max_metric_router_lsa_startup_cmd
);
9169 install_element(OSPF_NODE
, &ospf_max_metric_router_lsa_shutdown_cmd
);
9170 install_element(OSPF_NODE
, &no_ospf_max_metric_router_lsa_shutdown_cmd
);
9172 /* reference bandwidth commands */
9173 install_element(OSPF_NODE
, &ospf_auto_cost_reference_bandwidth_cmd
);
9174 install_element(OSPF_NODE
, &no_ospf_auto_cost_reference_bandwidth_cmd
);
9176 /* "neighbor" commands. */
9177 install_element(OSPF_NODE
, &ospf_neighbor_cmd
);
9178 install_element(OSPF_NODE
, &ospf_neighbor_poll_interval_cmd
);
9179 install_element(OSPF_NODE
, &no_ospf_neighbor_cmd
);
9180 install_element(OSPF_NODE
, &no_ospf_neighbor_poll_cmd
);
9182 /* write multiplier commands */
9183 install_element(OSPF_NODE
, &ospf_write_multiplier_cmd
);
9184 install_element(OSPF_NODE
, &write_multiplier_cmd
);
9185 install_element(OSPF_NODE
, &no_ospf_write_multiplier_cmd
);
9186 install_element(OSPF_NODE
, &no_write_multiplier_cmd
);
9188 /* Init interface related vty commands. */
9191 /* Init zebra related vty commands. */
9192 ospf_vty_zebra_init();